Completed
Branch BUG-8866-category-permalink (0af2d2)
by
unknown
22:53 queued 19s
created
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Aim extends EE_Onsite_Gateway{
28
+class EEG_Aim extends EE_Onsite_Gateway {
29 29
 	protected $_login_id;
30 30
 	protected $_transaction_key;
31 31
 	protected $_currencies_supported = array(
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 			$primary_registrant = $transaction->primary_registration();
99 99
 			//if we're are charging for the full amount, show the normal line items
100 100
 			//and the itemized total adds up properly
101
-			if( $this->_can_easily_itemize_transaction_for( $payment ) ){
101
+			if ($this->_can_easily_itemize_transaction_for($payment)) {
102 102
 				$total_line_item = $transaction->total_line_item();
103 103
 				foreach ($total_line_item->get_items() as $line_item) {
104 104
 					$this->addLineItem($item_num++, $line_item->name(), $line_item->desc(), $line_item->quantity(), $line_item->unit_price(), 'N');
105 105
 					$order_description .= $line_item->desc().', ';
106 106
 				}
107
-				foreach($total_line_item->tax_descendants() as $tax_line_item){
107
+				foreach ($total_line_item->tax_descendants() as $tax_line_item) {
108 108
 					$this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N');
109 109
 				}
110
-			}else{//partial payment
111
-				$order_description = sprintf(__("Payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code());
110
+			} else {//partial payment
111
+				$order_description = sprintf(__("Payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code());
112 112
 			}
113 113
 
114 114
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
 			//start transaction
118 118
 			$this->setField('amount', $this->format_currency($payment->amount()));
119
-			$this->setField('description',substr(rtrim($order_description, ', '), 0, 255));
119
+			$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
120 120
 			$this->setField('card_num', $billing_info['credit_card']);
121 121
 			$this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']);
122 122
 			$this->setField('card_code', $billing_info['cvv']);
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 			$this->setField('company', $billing_info['company']);
127 127
 			$this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
128 128
 			$this->setField('city', $billing_info['city']);
129
-			$this->setField('state', $billing_info['state'] );
130
-			$this->setField('country', $billing_info['country'] );
129
+			$this->setField('state', $billing_info['state']);
130
+			$this->setField('country', $billing_info['country']);
131 131
 			$this->setField('zip', $billing_info['zip']);
132 132
 			$this->setField('fax', $billing_info['fax']);
133 133
 			$this->setField('cust_id', $primary_registrant->ID());
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 			//invoice_num would be nice to have itbe unique per SPCO page-load, taht way if users
136 136
 			//press back, they don't submit a duplicate. However, we may be keepin gthe user on teh same spco page
137 137
 			//in which case, we need to generate teh invoice num per request right here...
138
-			$this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
138
+			$this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
139 139
 			//tell AIM that any duplicates sent in the next 5 minutes are to be ignored
140
-            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS );
140
+            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
141 141
 
142 142
 
143 143
 			if ($this->_test_transactions) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			//Capture response
148 148
 			$this->type = "AUTH_CAPTURE";
149 149
 			$response = $this->_sendRequest($payment);
150
-			if (!empty($response)){
150
+			if ( ! empty($response)) {
151 151
 				if ($this->_debug_mode) {
152 152
 					$txn_id = $response->invoice_number;
153 153
 				} else {
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 				$payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status();
157 157
 				$payment->set_status($payment_status);
158 158
 				//make sure we interpret the AMT as a float, not an international string (where periods are thousand seperators)
159
-				$payment->set_amount( floatval( $response->amount ) );
160
-				$payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code));
161
-				$payment->set_txn_id_chq_nmbr( $txn_id );
159
+				$payment->set_amount(floatval($response->amount));
160
+				$payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code));
161
+				$payment->set_txn_id_chq_nmbr($txn_id);
162 162
 				$payment->set_extra_accntng($primary_registrant->reg_code());
163
-				$payment->set_details(print_r($response,true));
163
+				$payment->set_details(print_r($response, true));
164 164
 			} else {
165 165
 				$payment->set_status($this->_pay_model->failed_status());
166 166
 				$payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
167
-				$payment->set_details(print_r($response,true));
167
+				$payment->set_details(print_r($response, true));
168 168
 			}
169 169
 		return $payment;
170 170
 	}
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
216 216
 		$x_keys = array();
217 217
 		foreach ($this->_x_post_fields as $key => $value) {
218
-			$x_keys[] = "x_$key=" . urlencode($value);
218
+			$x_keys[] = "x_$key=".urlencode($value);
219 219
 		}
220 220
 		// Add line items
221 221
 		foreach ($this->_additional_line_items as $key => $value) {
222
-			$x_keys[] =  "x_line_item=" . urlencode($value);
222
+			$x_keys[] = "x_line_item=".urlencode($value);
223 223
 		}
224 224
 		$this->_log_clean_request($x_keys, $payment);
225 225
 		$post_url = ($this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL);
226 226
 		$curl_request = curl_init($post_url);
227
-		curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys));
227
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys));
228 228
 		curl_setopt($curl_request, CURLOPT_HEADER, 0);
229 229
 		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
230 230
 		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
231 231
 		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
232 232
 		if ($this->VERIFY_PEER) {
233
-			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/ssl/cert.pem');
233
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)).'/ssl/cert.pem');
234 234
 		} else {
235 235
 			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
236 236
 		}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		$response = curl_exec($curl_request);
243 243
 
244 244
 		curl_close($curl_request);
245
-		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
245
+		$response_obj = new EE_AuthorizeNetAIM_Response($response);
246 246
 
247 247
 		return $this->_log_and_clean_response($response_obj, $payment);
248 248
 	}
@@ -251,18 +251,18 @@  discard block
 block discarded – undo
251 251
 	 * @param array $request_array
252 252
 	 * @param EEI_Payment $payment
253 253
 	 */
254
-	private function _log_clean_request($request_array,$payment){
255
-		$keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' );
256
-		foreach($request_array as $index => $keyvaltogether ) {
257
-			foreach( $keys_to_filter_out as $key ) {
258
-				if( strpos( $keyvaltogether, $key ) === 0 ){
254
+	private function _log_clean_request($request_array, $payment) {
255
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
256
+		foreach ($request_array as $index => $keyvaltogether) {
257
+			foreach ($keys_to_filter_out as $key) {
258
+				if (strpos($keyvaltogether, $key) === 0) {
259 259
 					//found it at the first character
260 260
 					//so its one of them
261
-					unset( $request_array[ $index ] );
261
+					unset($request_array[$index]);
262 262
 				}
263 263
 			}
264 264
 		}
265
-		$this->log(array('AIM Request sent:'=>$request_array),$payment);
265
+		$this->log(array('AIM Request sent:'=>$request_array), $payment);
266 266
 	}
267 267
 
268 268
 	/**
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @param EE_AuthorizeNetAIM_Response $response_obj
271 271
 	 * @param EE_Payment $payment
272 272
 	 */
273
-	private function _log_and_clean_response($response_obj,$payment){
273
+	private function _log_and_clean_response($response_obj, $payment) {
274 274
 		$response_obj->account_number = '';
275
-		$this->log(array('AIM Response received:'=>$response_obj),$payment);
275
+		$this->log(array('AIM Response received:'=>$response_obj), $payment);
276 276
 		return $response_obj;
277 277
 	}
278 278
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 			// Split Array
369 369
 			$this->response = $response;
370 370
 			if ($encap_char) {
371
-				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
371
+				$this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
372 372
 			} else {
373 373
 				$this->_response_array = explode($delimiter, $response);
374 374
 			}
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 			$this->held = ($this->response_code == self::HELD);
439 439
 
440 440
 			if ($this->error || $this->declined || $this->held) {
441
-				$this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> ';
441
+				$this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> ';
442 442
 
443 443
 
444 444
 				/* $this->error_message = "AuthorizeNet Error:
Please login to merge, or discard this patch.
core/db_models/EEM_Event.model.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once( EE_MODELS . 'EEM_CPT_Base.model.php');
2
+require_once(EE_MODELS.'EEM_CPT_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * EEM_Event Model
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author				Michael Nelson, Brent Christensen
12 12
  *
13 13
  */
14
-class EEM_Event  extends EEM_CPT_Base{
14
+class EEM_Event  extends EEM_CPT_Base {
15 15
 
16 16
 	/**
17 17
 	 * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the event
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 * @param string $timezone
52 52
 	 * @return EEM_Event
53 53
 	 */
54
-	public static function instance( $timezone = NULL ){
54
+	public static function instance($timezone = NULL) {
55 55
 
56 56
 		// check if instance of EEM_Event already exists
57
-		if ( ! self::$_instance instanceof EEM_Event ) {
57
+		if ( ! self::$_instance instanceof EEM_Event) {
58 58
 			// instantiate Espresso_model
59
-			self::$_instance = new self( $timezone );
59
+			self::$_instance = new self($timezone);
60 60
 		}
61 61
 		//we might have a timezone set, let set_timezone decide what to do with it
62
-		self::$_instance->set_timezone( $timezone );
62
+		self::$_instance->set_timezone($timezone);
63 63
 		// EEM_Event object
64 64
 		return self::$_instance;
65 65
 	}
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 	 * @param string $timezone
71 71
 	 * @return EEM_Event
72 72
 	 */
73
-	protected function __construct($timezone = null){
73
+	protected function __construct($timezone = null) {
74 74
 
75
-		EE_Registry::instance()->load_model( 'Registration' );
75
+		EE_Registry::instance()->load_model('Registration');
76 76
 
77
-		$this->singular_item = __('Event','event_espresso');
78
-		$this->plural_item = __('Events','event_espresso');
77
+		$this->singular_item = __('Event', 'event_espresso');
78
+		$this->plural_item = __('Events', 'event_espresso');
79 79
 
80 80
 		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
81 81
 		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
@@ -89,57 +89,57 @@  discard block
 block discarded – undo
89 89
 			array(
90 90
 				EEM_Event::cancelled => array(
91 91
 					'label' => __('Cancelled', 'event_espresso'),
92
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE )
92
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE)
93 93
 				),
94 94
 				EEM_Event::postponed => array(
95 95
 					'label' => __('Postponed', 'event_espresso'),
96
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE )
96
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE)
97 97
 				),
98 98
 				EEM_Event::sold_out => array(
99 99
 					'label' => __('Sold Out', 'event_espresso'),
100
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE )
100
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE)
101 101
 				)
102 102
 			)
103 103
 		);
104 104
 
105
-		self::$_default_reg_status = empty( self::$_default_reg_status ) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
105
+		self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
106 106
 
107 107
 		$this->_tables = array(
108
-			'Event_CPT'=>new EE_Primary_Table( 'posts','ID' ),
109
-			'Event_Meta'=> new EE_Secondary_Table( 'esp_event_meta', 'EVTM_ID', 'EVT_ID' )
108
+			'Event_CPT'=>new EE_Primary_Table('posts', 'ID'),
109
+			'Event_Meta'=> new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID')
110 110
 		);
111 111
 
112 112
 		$this->_fields = array(
113 113
 			'Event_CPT'=>array(
114
-				'EVT_ID'=>new EE_Primary_Key_Int_Field( 'ID', __( 'Post ID for Event','event_espresso' )),
115
-				'EVT_name'=>new EE_Plain_Text_Field( 'post_title', __( 'Event Name','event_espresso' ), FALSE, '' ),
116
-				'EVT_desc'=>new EE_Post_Content_Field( 'post_content', __( 'Event Description', 'event_espresso' ), FALSE, '' ),
117
-				'EVT_slug'=>new EE_Slug_Field( 'post_name', __( 'Event Slug', 'event_espresso' ), FALSE, '' ),
118
-				'EVT_created'=>new EE_Datetime_Field( 'post_date', __( 'Date/Time Event Created', 'event_espresso' ), FALSE, time()),
119
-				'EVT_short_desc'=>new EE_Simple_HTML_Field( 'post_excerpt', __( 'Event Short Description', 'event_espresso' ), FALSE,'' ),
120
-				'EVT_modified'=>new EE_Datetime_Field( 'post_modified', __( 'Date/Time Event Modified', 'event_espresso' ), FALSE, time()),
121
-				'EVT_wp_user'=>new EE_WP_User_Field( 'post_author', __( 'Event Creator ID', 'event_espresso'), FALSE),
122
-				'parent'=>new EE_Integer_Field( 'post_parent', __( 'Event Parent ID', 'event_espresso' ), FALSE, 0 ),
123
-				'EVT_order'=>new EE_Integer_Field( 'menu_order', __( 'Event Menu Order', 'event_espresso' ), FALSE, 1 ),
124
-				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'),// EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
-				'status' => new EE_WP_Post_Status_Field( 'post_status', __( 'Event Status', 'event_espresso' ), FALSE, 'draft', $this->_custom_stati )
114
+				'EVT_ID'=>new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')),
115
+				'EVT_name'=>new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), FALSE, ''),
116
+				'EVT_desc'=>new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), FALSE, ''),
117
+				'EVT_slug'=>new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), FALSE, ''),
118
+				'EVT_created'=>new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), FALSE, time()),
119
+				'EVT_short_desc'=>new EE_Simple_HTML_Field('post_excerpt', __('Event Short Description', 'event_espresso'), FALSE, ''),
120
+				'EVT_modified'=>new EE_Datetime_Field('post_modified', __('Date/Time Event Modified', 'event_espresso'), FALSE, time()),
121
+				'EVT_wp_user'=>new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), FALSE),
122
+				'parent'=>new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), FALSE, 0),
123
+				'EVT_order'=>new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), FALSE, 1),
124
+				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'), // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
+				'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), FALSE, 'draft', $this->_custom_stati)
126 126
 			),
127 127
 			'Event_Meta'=>array(
128
-				'EVTM_ID'=> new EE_DB_Only_Float_Field( 'EVTM_ID', __( 'Event Meta Row ID','event_espresso' ), FALSE ),
129
-				'EVT_ID_fk'=>new EE_DB_Only_Int_Field( 'EVT_ID', __( 'Foreign key to Event ID from Event Meta table', 'event_espresso' ), FALSE ),
130
-				'EVT_display_desc'=>new EE_Boolean_Field( 'EVT_display_desc', __( 'Display Description Flag', 'event_espresso' ), FALSE, 1 ),
131
-				'EVT_display_ticket_selector'=>new EE_Boolean_Field( 'EVT_display_ticket_selector', __( 'Display Ticket Selector Flag', 'event_espresso' ), FALSE, 1 ),
132
-				'EVT_visible_on'=>new EE_Datetime_Field( 'EVT_visible_on', __( 'Event Visible Date', 'event_espresso' ), TRUE, time()),
133
-				'EVT_additional_limit'=>new EE_Integer_Field( 'EVT_additional_limit', __( 'Limit of Additional Registrations on Same Transaction', 'event_espresso' ), TRUE, 10 ),
128
+				'EVTM_ID'=> new EE_DB_Only_Float_Field('EVTM_ID', __('Event Meta Row ID', 'event_espresso'), FALSE),
129
+				'EVT_ID_fk'=>new EE_DB_Only_Int_Field('EVT_ID', __('Foreign key to Event ID from Event Meta table', 'event_espresso'), FALSE),
130
+				'EVT_display_desc'=>new EE_Boolean_Field('EVT_display_desc', __('Display Description Flag', 'event_espresso'), FALSE, 1),
131
+				'EVT_display_ticket_selector'=>new EE_Boolean_Field('EVT_display_ticket_selector', __('Display Ticket Selector Flag', 'event_espresso'), FALSE, 1),
132
+				'EVT_visible_on'=>new EE_Datetime_Field('EVT_visible_on', __('Event Visible Date', 'event_espresso'), TRUE, time()),
133
+				'EVT_additional_limit'=>new EE_Integer_Field('EVT_additional_limit', __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), TRUE, 10),
134 134
 				'EVT_default_registration_status'=>new EE_Enum_Text_Field(
135
-					'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
135
+					'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
136 136
 				),
137
-				'EVT_member_only'=>new EE_Boolean_Field( 'EVT_member_only', __( 'Member-Only Event Flag', 'event_espresso' ), FALSE, FALSE ),
138
-				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __( 'Event Phone Number', 'event_espresso' ), FALSE ),
139
-				'EVT_allow_overflow'=>new EE_Boolean_Field(  'EVT_allow_overflow', __( 'Allow Overflow on Event', 'event_espresso' ), FALSE, FALSE ),
140
-				'EVT_timezone_string'=>new EE_Plain_Text_Field( 'EVT_timezone_string', __( 'Timezone (name) for Event times', 'event_espresso' ), FALSE ),
141
-				'EVT_external_URL'=>new EE_Plain_Text_Field( 'EVT_external_URL', __( 'URL of Event Page if hosted elsewhere', 'event_espresso' ), TRUE ),
142
-				'EVT_donations'=>new EE_Boolean_Field( 'EVT_donations', __( 'Accept Donations?', 'event_espresso' ), FALSE, FALSE )
137
+				'EVT_member_only'=>new EE_Boolean_Field('EVT_member_only', __('Member-Only Event Flag', 'event_espresso'), FALSE, FALSE),
138
+				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __('Event Phone Number', 'event_espresso'), FALSE),
139
+				'EVT_allow_overflow'=>new EE_Boolean_Field('EVT_allow_overflow', __('Allow Overflow on Event', 'event_espresso'), FALSE, FALSE),
140
+				'EVT_timezone_string'=>new EE_Plain_Text_Field('EVT_timezone_string', __('Timezone (name) for Event times', 'event_espresso'), FALSE),
141
+				'EVT_external_URL'=>new EE_Plain_Text_Field('EVT_external_URL', __('URL of Event Page if hosted elsewhere', 'event_espresso'), TRUE),
142
+				'EVT_donations'=>new EE_Boolean_Field('EVT_donations', __('Accept Donations?', 'event_espresso'), FALSE, FALSE)
143 143
 
144 144
 			));
145 145
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 			'WP_User' => new EE_Belongs_To_Relation(),
155 155
 		);
156 156
 		//this model is generally available for reading
157
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
158
-		parent::__construct( $timezone );
157
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
158
+		parent::__construct($timezone);
159 159
 	}
160 160
 
161 161
 
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	/**
164 164
 	 * @param string $default_reg_status
165 165
 	 */
166
-	public static function set_default_reg_status( $default_reg_status ) {
166
+	public static function set_default_reg_status($default_reg_status) {
167 167
 		self::$_default_reg_status = $default_reg_status;
168 168
 		//if EEM_Event has already been instantiated, then we need to reset the `EVT_default_reg_status` field to use the new default.
169
-		if ( self::$_instance instanceof EEM_Event ) {
169
+		if (self::$_instance instanceof EEM_Event) {
170 170
 			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = new EE_Enum_Text_Field(
171
-				'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), false, $default_reg_status, EEM_Registration::reg_status_array()
171
+				'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), false, $default_reg_status, EEM_Registration::reg_status_array()
172 172
 			);
173
-			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize( 'Event_Meta', 'EVT_default_registration_status', 'EEM_Event' );
173
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize('Event_Meta', 'EVT_default_registration_status', 'EEM_Event');
174 174
 		}
175 175
 	}
176 176
 
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	*		@return 		array
184 184
 	*/
185 185
 	public function get_all_question_groups() {
186
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
187
-			array( 'QSG_deleted' => FALSE ),
188
-			'order_by' => array( 'QSG_order' => 'ASC' )
186
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
187
+			array('QSG_deleted' => FALSE),
188
+			'order_by' => array('QSG_order' => 'ASC')
189 189
 		));
190 190
 	}
191 191
 
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	* 		@param		int $EVT_ID
202 202
 	*		@return 		array
203 203
 	*/
204
-	public function get_all_event_question_groups( $EVT_ID = 0 ) {
205
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
206
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
204
+	public function get_all_event_question_groups($EVT_ID = 0) {
205
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
206
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
207 207
 			return FALSE;
208 208
 		}
209
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
210
-			array( 'EVT_ID' => $EVT_ID )
209
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
210
+			array('EVT_ID' => $EVT_ID)
211 211
 		));
212 212
 	}
213 213
 
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 	* 		@param		boolean	$for_primary_attendee
224 224
 	*		@return 		array
225 225
 	*/
226
-	public function get_event_question_groups( $EVT_ID = 0, $for_primary_attendee = TRUE ) {
227
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
228
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
226
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = TRUE) {
227
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
228
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
229 229
 			return FALSE;
230 230
 		}
231
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
232
-			array( 'EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee )
231
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
232
+			array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee)
233 233
 		));
234 234
 	}
235 235
 
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 	* 		@param		EE_Registration 	$registration
247 247
 	*		@return 		array
248 248
 	*/
249
-	public function get_question_groups_for_event( $EVT_ID = 0, EE_Registration $registration ) {
249
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) {
250 250
 
251
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
252
-			EE_Error::add_error( __( 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
251
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
252
+			EE_Error::add_error(__('An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
253 253
 			return FALSE;
254 254
 		}
255 255
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			'QSG_deleted' => FALSE
260 260
 		);
261 261
 
262
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
262
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
263 263
 			$where_params,
264 264
 			'order_by' => array('QSG_order' => 'ASC')
265 265
 		));
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	* 		@param		string		$QSG_IDs  csv list of $QSG IDs
280 280
 	*		@return 		array
281 281
 	*/
282
-	public function get_questions_in_groups( $QSG_IDs = '' ) {
282
+	public function get_questions_in_groups($QSG_IDs = '') {
283 283
 
284
-		if ( empty( $QSG_IDs )) {
285
-			EE_Error::add_error( __( 'An error occurred. No Question Group IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
284
+		if (empty($QSG_IDs)) {
285
+			EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
286 286
 			return FALSE;
287 287
 		}
288 288
 
289
-		return EE_Registry::instance()->load_model( 'Question' )->get_all( array(
289
+		return EE_Registry::instance()->load_model('Question')->get_all(array(
290 290
 			array(
291
-				'Question_Group.QSG_ID' => array( 'IN', $QSG_IDs ),
291
+				'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
292 292
 				'QST_deleted' => FALSE,
293 293
 				'QST_admin_only' => is_admin()
294 294
 			),
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 	* 		@param		string		$QST_IDs  csv list of $QST IDs
311 311
 	*		@return 		array
312 312
 	*/
313
-	public function get_options_for_question( $QST_IDs ) {
313
+	public function get_options_for_question($QST_IDs) {
314 314
 
315
-		if ( empty( $QST_IDs )) {
316
-			EE_Error::add_error( __( 'An error occurred. No Question IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
315
+		if (empty($QST_IDs)) {
316
+			EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
317 317
 			return FALSE;
318 318
 		}
319 319
 
320
-		return EE_Registry::instance()->load_model( 'Question_Option' )->get_all( array(
320
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(array(
321 321
 			array(
322
-				'Question.QST_ID' => array( 'IN', $QST_IDs ),
322
+				'Question.QST_ID' => array('IN', $QST_IDs),
323 323
 				'QSO_deleted' => FALSE
324 324
 			),
325 325
 			'order_by' => 'QSO_ID'
@@ -338,45 +338,45 @@  discard block
 block discarded – undo
338 338
 	 * @throws EE_Error
339 339
 	 * @return 	array
340 340
 	 */
341
-	public function assemble_array_of_groups_questions_and_options( EE_Registration $registration, $EVT_ID = 0 ) {
341
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) {
342 342
 
343
-		if ( empty( $EVT_ID ) ) {
344
-			throw new EE_Error( __( 'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso' ) );
343
+		if (empty($EVT_ID)) {
344
+			throw new EE_Error(__('An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso'));
345 345
 		}
346 346
 
347 347
 		$questions = array();
348 348
 
349 349
 		// get all question groups for event
350
-		$qgs = $this->get_question_groups_for_event( $EVT_ID, $registration );
351
-		if ( !empty( $qgs ) ) {
352
-			foreach ( $qgs as $qg ) {
350
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
351
+		if ( ! empty($qgs)) {
352
+			foreach ($qgs as $qg) {
353 353
 			 	$qsts = $qg->questions();
354
-			 	$questions[ $qg->ID() ] = $qg->model_field_array();
355
-			 	$questions[ $qg->ID() ]['QSG_questions'] = array();
356
-			 	foreach ( $qsts as $qst ) {
357
-			 		if ( $qst->is_system_question() )
354
+			 	$questions[$qg->ID()] = $qg->model_field_array();
355
+			 	$questions[$qg->ID()]['QSG_questions'] = array();
356
+			 	foreach ($qsts as $qst) {
357
+			 		if ($qst->is_system_question())
358 358
 			 			continue;
359
-			 		$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) );
359
+			 		$answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID())));
360 360
 			 		$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
361 361
 			 		$qst_name = $qstn_id = $qst->ID();
362 362
 			 		$ans_id = $answer->ID();
363
-			 		$qst_name = !empty( $ans_id ) ?  '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
363
+			 		$qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
364 364
 			 		$input_name = '';
365
-			 		$input_id = sanitize_key( $qst->display_text() );
365
+			 		$input_id = sanitize_key($qst->display_text());
366 366
 			 		$input_class = '';
367 367
 			 		$questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
368
-		 			$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn' . $input_name . $qst_name;
369
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
370
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
371
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
372
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
373
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
374
-
375
-					if ( $qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN' ) {
376
-						$QSOs = $qst->options(TRUE,$answer->value());
377
-						if ( is_array( $QSOs ) ) {
378
-							foreach ( $QSOs as $QSO_ID => $QSO ) {
379
-								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
368
+		 			$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'.$input_name.$qst_name;
369
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
370
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
371
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
372
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
373
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
374
+
375
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
376
+						$QSOs = $qst->options(TRUE, $answer->value());
377
+						if (is_array($QSOs)) {
378
+							foreach ($QSOs as $QSO_ID => $QSO) {
379
+								$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
380 380
 							}
381 381
 						}
382 382
 					}
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 	* 		@param		$QST
401 401
 	*		@return 		string		string
402 402
 	*/
403
-	private function _generate_question_input_name( $QST ) {
403
+	private function _generate_question_input_name($QST) {
404 404
 
405
-		if ( $QST->QST_system ) {
405
+		if ($QST->QST_system) {
406 406
 			$qst_name = $QST->QST_system;
407 407
 /*			switch( $QST->QST_system ) {
408 408
 
@@ -469,36 +469,36 @@  discard block
 block discarded – undo
469 469
 	 * @param bool    $count whether to return the count or not (default FALSE)
470 470
 	 * @return array 	EE_Event objects
471 471
 	 */
472
-	public function get_active_events( $query_params, $count = FALSE ) {
473
-		if ( array_key_exists( 0, $query_params ) ) {
472
+	public function get_active_events($query_params, $count = FALSE) {
473
+		if (array_key_exists(0, $query_params)) {
474 474
 			$where_params = $query_params[0];
475
-			unset( $query_params[0] );
475
+			unset($query_params[0]);
476 476
 		} else {
477 477
 			$where_params = array();
478 478
 		}
479 479
 
480 480
 		//if we have count make sure we don't include group by
481
-		if ( $count && isset( $query_params['group_by'] ) ) {
482
-			unset( $query_params['group_by'] );
481
+		if ($count && isset($query_params['group_by'])) {
482
+			unset($query_params['group_by']);
483 483
 		}
484 484
 
485 485
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
486 486
 		$where_params['status'] = 'publish';
487 487
 		//if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
488
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
489
-			$where_params['Datetime.DTT_EVT_start******'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
488
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
489
+			$where_params['Datetime.DTT_EVT_start******'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
490 490
 		} else {
491
-			$where_params['Datetime.DTT_EVT_start'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
491
+			$where_params['Datetime.DTT_EVT_start'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
492 492
 		}
493 493
 
494
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
495
-			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
494
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
495
+			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
496 496
 		} else {
497
-			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
497
+			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
498 498
 		}
499 499
 		$query_params[0] = $where_params;
500 500
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
501
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
501
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
502 502
 	}
503 503
 
504 504
 
@@ -513,30 +513,30 @@  discard block
 block discarded – undo
513 513
 	 * @param bool    $count whether to return the count or not (default FALSE)
514 514
 	 * @return array               EE_Event objects
515 515
 	 */
516
-	public function get_upcoming_events( $query_params, $count = FALSE ) {
517
-		if ( array_key_exists( 0, $query_params ) ) {
516
+	public function get_upcoming_events($query_params, $count = FALSE) {
517
+		if (array_key_exists(0, $query_params)) {
518 518
 			$where_params = $query_params[0];
519
-			unset( $query_params[0] );
519
+			unset($query_params[0]);
520 520
 		} else {
521 521
 			$where_params = array();
522 522
 		}
523 523
 
524 524
 		//if we have count make sure we don't include group by
525
-		if ( $count && isset( $query_params['group_by'] ) ) {
526
-			unset( $query_params['group_by'] );
525
+		if ($count && isset($query_params['group_by'])) {
526
+			unset($query_params['group_by']);
527 527
 		}
528 528
 
529 529
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
530 530
 		$where_params['status'] = 'publish';
531 531
 		//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
532
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
533
-			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
532
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
533
+			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
534 534
 		} else {
535
-			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
535
+			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
536 536
 		}
537 537
 		$query_params[0] = $where_params;
538 538
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
539
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
539
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
540 540
 	}
541 541
 
542 542
 
@@ -548,56 +548,56 @@  discard block
 block discarded – undo
548 548
 	 * @param bool    $count whether to return the count or not (default FALSE)
549 549
 	 * @return array 	EE_Event objects
550 550
 	 */
551
-	public function get_expired_events( $query_params, $count = FALSE ) {
551
+	public function get_expired_events($query_params, $count = FALSE) {
552 552
 
553
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
553
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
554 554
 
555 555
 		//if we have count make sure we don't include group by
556
-		if ( $count && isset( $query_params['group_by'] ) ) {
557
-			unset( $query_params['group_by'] );
556
+		if ($count && isset($query_params['group_by'])) {
557
+			unset($query_params['group_by']);
558 558
 		}
559 559
 
560 560
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
561
-		if ( isset( $where_params['status'] ) ) {
562
-			unset( $where_params['status'] );
561
+		if (isset($where_params['status'])) {
562
+			unset($where_params['status']);
563 563
 		}
564 564
 		$exclude_query = $query_params;
565
-		if ( isset( $exclude_query[0] ) ) {
566
-			unset( $exclude_query[0] );
565
+		if (isset($exclude_query[0])) {
566
+			unset($exclude_query[0]);
567 567
 		}
568
-		$exclude_query[0] = array( 'Datetime.DTT_EVT_end' => array( '>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) );
568
+		$exclude_query[0] = array('Datetime.DTT_EVT_end' => array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')));
569 569
 		//first get all events that have datetimes where its not expired.
570
-		$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Event_CPT.ID' );
571
-		$event_ids = array_keys( $event_ids );
570
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
571
+		$event_ids = array_keys($event_ids);
572 572
 
573 573
 		//if we have any additional query_params, let's add them to the 'AND' condition
574 574
 		$and_condition = array(
575
-			'Datetime.DTT_EVT_end' => array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ),
576
-			'EVT_ID' =>  array( 'NOT IN', $event_ids )
575
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
576
+			'EVT_ID' =>  array('NOT IN', $event_ids)
577 577
 			);
578 578
 
579
-		if ( isset( $where_params['OR'] ) ) {
579
+		if (isset($where_params['OR'])) {
580 580
 			$and_condition['OR'] = $where_params['OR'];
581
-			unset( $where_params['OR'] );
581
+			unset($where_params['OR']);
582 582
 		}
583 583
 
584
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
584
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
585 585
 			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
586
-			unset( $where_params['Datetime.DTT_EVT_end'] );
586
+			unset($where_params['Datetime.DTT_EVT_end']);
587 587
 		}
588 588
 
589
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
589
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
590 590
 			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
591
-			unset( $where_params['Datetime.DTT_EVT_start'] );
591
+			unset($where_params['Datetime.DTT_EVT_start']);
592 592
 		}
593 593
 
594 594
 		//merge remaining $where params with the and conditions.
595
-		$and_condtion = array_merge( $and_condition, $where_params );
595
+		$and_condtion = array_merge($and_condition, $where_params);
596 596
 
597 597
 		$where_params['AND'] = $and_condition;
598 598
 		$query_params[0] = $where_params;
599 599
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
600
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
600
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
601 601
 	}
602 602
 
603 603
 
@@ -608,40 +608,40 @@  discard block
 block discarded – undo
608 608
 	 * @param  boolean $count        whether to return the count or not (default FALSE)
609 609
 	 * @return EE_Event[]            array of EE_Event objects
610 610
 	 */
611
-	public function get_inactive_events( $query_params, $count = FALSE ) {
612
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
611
+	public function get_inactive_events($query_params, $count = FALSE) {
612
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
613 613
 
614 614
 		//let's add in specific query_params for inactive events.
615
-		if ( isset( $where_params['status'] ) ) {
616
-			unset( $where_params['status'] );
615
+		if (isset($where_params['status'])) {
616
+			unset($where_params['status']);
617 617
 		}
618 618
 
619 619
 		//if we have count make sure we don't include group by
620
-		if ( $count && isset( $query_params['group_by'] ) ) {
621
-			unset( $query_params['group_by'] );
620
+		if ($count && isset($query_params['group_by'])) {
621
+			unset($query_params['group_by']);
622 622
 		}
623 623
 
624 624
 		//if we have any additional query_params, let's add them to the 'AND' condition
625
-		$where_params['AND']['status'] = array( '!=', 'publish' );
625
+		$where_params['AND']['status'] = array('!=', 'publish');
626 626
 
627
-		if ( isset( $where_params['OR'] ) ) {
627
+		if (isset($where_params['OR'])) {
628 628
 			$where_params['AND']['OR'] = $where_params['OR'];
629
-			unset( $where_params['OR'] );
629
+			unset($where_params['OR']);
630 630
 		}
631 631
 
632
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
632
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
633 633
 			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
634
-			unset( $where_params['Datetime.DTT_EVT_end'] );
634
+			unset($where_params['Datetime.DTT_EVT_end']);
635 635
 		}
636 636
 
637
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
637
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
638 638
 			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
639
-			unset( $where_params['Datetime.DTT_EVT_start'] );
639
+			unset($where_params['Datetime.DTT_EVT_start']);
640 640
 		}
641 641
 
642 642
 		$query_params[0] = $where_params;
643 643
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" 
644
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
644
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
645 645
 	}
646 646
 
647 647
 
@@ -649,13 +649,13 @@  discard block
 block discarded – undo
649 649
 	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships because we don't want to override any existing global default prices but instead insert NEW prices that get attached to the event.
650 650
 	 * See parent for param descriptions
651 651
 	 */
652
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
652
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
653 653
 
654
-		if ( $relationName == 'Price' ) {
654
+		if ($relationName == 'Price') {
655 655
 			//let's get the PRC object for the given ID to make sure that we aren't dealing with a default
656 656
 			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
657 657
 			//if EVT_ID = 0, then this is a default
658
-			if ( $prc_chk->get('EVT_ID') == 0 ) {
658
+			if ($prc_chk->get('EVT_ID') == 0) {
659 659
 				//let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
660 660
 				$prc_chk->set('PRC_ID', 0);
661 661
 			}
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 		}
666 666
 
667 667
 		//otherwise carry on as normal
668
-		return parent::add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query);
668
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
669 669
 	}
670 670
 
671 671
 
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 1 patch
Spacing   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @param $table_name
58 58
 	 * @return string
59 59
 	 */
60
-	public static function ensure_table_name_has_prefix( $table_name ) {
60
+	public static function ensure_table_name_has_prefix($table_name) {
61 61
 		global $wpdb;
62
-		return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
62
+		return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
63 63
 	}
64 64
 
65 65
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * be called on plugin activation and reactivation
86 86
 	 * @return boolean success, whether the database and folders are setup properly
87 87
 	 */
88
-	public static function initialize_db_and_folders(){
88
+	public static function initialize_db_and_folders() {
89 89
 		$good_filesystem = EEH_Activation::create_upload_directories();
90 90
 		$good_db = EEH_Activation::create_database_tables();
91 91
 		return $good_filesystem && $good_db;
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * upon activation of a new plugin, reactivation, and at the end
100 100
 	 * of running migration scripts
101 101
 	 */
102
-	public static function initialize_db_content(){
102
+	public static function initialize_db_content() {
103 103
 		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
104
-		if( EEH_Activation::$_initialized_db_content_already_in_this_request ) {
104
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
105 105
 			return;
106 106
 		}
107 107
 		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		EEH_Activation::remove_cron_tasks();
119 119
 		EEH_Activation::create_cron_tasks();
120 120
 		//also, check for CAF default db content
121
-		do_action( 'AHEE__EEH_Activation__initialize_db_content' );
121
+		do_action('AHEE__EEH_Activation__initialize_db_content');
122 122
 		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
123 123
 		//which users really won't care about on initial activation
124 124
 		EE_Error::overwrite_success();
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @return array
138 138
 	 * @throws \EE_Error
139 139
 	 */
140
-	public static function get_cron_tasks( $which_to_include ) {
140
+	public static function get_cron_tasks($which_to_include) {
141 141
 		$cron_tasks = apply_filters(
142 142
 			'FHEE__EEH_Activation__get_cron_tasks',
143 143
 			array(
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 				'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
147 147
 			)
148 148
 		);
149
-		if( $which_to_include === 'all' ) {
149
+		if ($which_to_include === 'all') {
150 150
 			//leave as-is
151
-		}elseif( $which_to_include === 'old' ) {
152
-			$cron_tasks = array_filter( $cron_tasks, function ( $value ) {
151
+		}elseif ($which_to_include === 'old') {
152
+			$cron_tasks = array_filter($cron_tasks, function($value) {
153 153
 				return $value === EEH_Activation::cron_task_no_longer_in_use;
154 154
 			});
155
-		}elseif( $which_to_include === 'current' ) {
156
-			$cron_tasks = array_filter( $cron_tasks );
157
-		}elseif( WP_DEBUG ) {
158
-			throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) );
159
-		}else{
155
+		}elseif ($which_to_include === 'current') {
156
+			$cron_tasks = array_filter($cron_tasks);
157
+		}elseif (WP_DEBUG) {
158
+			throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include));
159
+		} else {
160 160
 			//leave as-is
161 161
 		}
162 162
 		return $cron_tasks;
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public static function create_cron_tasks() {
169 169
 
170
-		foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) {
171
-			if( ! wp_next_scheduled( $hook_name ) ) {
172
-				wp_schedule_event( time(), $frequency, $hook_name );
170
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
171
+			if ( ! wp_next_scheduled($hook_name)) {
172
+				wp_schedule_event(time(), $frequency, $hook_name);
173 173
 			}
174 174
 		}
175 175
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * Remove the currently-existing and now-removed cron tasks.
180 180
 	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
181 181
 	 */
182
-	public static function remove_cron_tasks( $remove_all = true ) {
182
+	public static function remove_cron_tasks($remove_all = true) {
183 183
 		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
184 184
 		$crons = _get_cron_array();
185
-		$crons = is_array( $crons ) ? $crons : array();
185
+		$crons = is_array($crons) ? $crons : array();
186 186
 		/* reminder that $crons looks like: top-level keys are timestamps,
187 187
 		 * and their values are arrays.
188 188
 		 * The 2nd level arrays have keys with each of the cron task hooknames to run at that time
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		 *					...
201 201
 		 *      ...
202 202
 		 */
203
-		foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) {
204
-			foreach( $crons as $timestamp => $hooks_to_fire_at_time ) {
205
-				if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) )  {
206
-					unset( $crons[ $timestamp ][ $hook_name ] );
203
+		foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) {
204
+			foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
205
+				if (array_key_exists($hook_name, $hooks_to_fire_at_time)) {
206
+					unset($crons[$timestamp][$hook_name]);
207 207
 				}
208 208
 			}
209 209
 		}
210
-		_set_cron_array( $crons );
210
+		_set_cron_array($crons);
211 211
 	}
212 212
 
213 213
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public static function CPT_initialization() {
224 224
 		// register Custom Post Types
225
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
225
+		EE_Registry::instance()->load_core('Register_CPTs');
226 226
 		flush_rewrite_rules();
227 227
 	}
228 228
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * 	@return void
241 241
 	 */
242 242
 	public static function reset_and_update_config() {
243
-		do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) );
244
-		add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 );
243
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
244
+		add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3);
245 245
 		//EE_Config::reset();
246 246
 	}
247 247
 
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public static function load_calendar_config() {
256 256
 		// grab array of all plugin folders and loop thru it
257
-		$plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR );
258
-		if ( empty( $plugins ) ) {
257
+		$plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
258
+		if (empty($plugins)) {
259 259
 			return;
260 260
 		}
261
-		foreach ( $plugins as $plugin_path ) {
261
+		foreach ($plugins as $plugin_path) {
262 262
 			// grab plugin folder name from path
263
-			$plugin = basename( $plugin_path );
263
+			$plugin = basename($plugin_path);
264 264
 			// drill down to Espresso plugins
265
-			if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) {
265
+			if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) {
266 266
 				// then to calendar related plugins
267
-				if ( strpos( $plugin, 'calendar' ) !== FALSE ) {
267
+				if (strpos($plugin, 'calendar') !== FALSE) {
268 268
 					// this is what we are looking for
269
-					$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
269
+					$calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
270 270
 					// does it exist in this folder ?
271
-					if ( is_readable( $calendar_config )) {
271
+					if (is_readable($calendar_config)) {
272 272
 						// YEAH! let's load it
273
-						require_once( $calendar_config );
273
+						require_once($calendar_config);
274 274
 					}
275 275
 				}
276 276
 			}
@@ -287,21 +287,21 @@  discard block
 block discarded – undo
287 287
 	 * @param \EE_Config $EE_Config
288 288
 	 * @return \stdClass
289 289
 	 */
290
-	public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) {
291
-		$convert_from_array = array( 'addons' );
290
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) {
291
+		$convert_from_array = array('addons');
292 292
 		// in case old settings were saved as an array
293
-		if ( is_array( $settings ) && in_array( $config, $convert_from_array )) {
293
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
294 294
 			// convert existing settings to an object
295 295
 			$config_array = $settings;
296 296
 			$settings = new stdClass();
297
-			foreach ( $config_array as $key => $value ){
298
-				if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) {
299
-					$EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value );
297
+			foreach ($config_array as $key => $value) {
298
+				if ($key == 'calendar' && class_exists('EE_Calendar_Config')) {
299
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
300 300
 				} else {
301 301
 					$settings->$key = $value;
302 302
 				}
303 303
 			}
304
-			add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' );
304
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
305 305
 		}
306 306
 		return $settings;
307 307
 	}
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public static function deactivate_event_espresso() {
319 319
 		// check permissions
320
-		if ( current_user_can( 'activate_plugins' )) {
321
-			deactivate_plugins( EE_PLUGIN_BASENAME, TRUE );
320
+		if (current_user_can('activate_plugins')) {
321
+			deactivate_plugins(EE_PLUGIN_BASENAME, TRUE);
322 322
 		}
323 323
 	}
324 324
 
@@ -340,79 +340,79 @@  discard block
 block discarded – undo
340 340
 		$critical_pages = array(
341 341
 			array(
342 342
 				'id' =>'reg_page_id',
343
-				'name' => __( 'Registration Checkout', 'event_espresso' ),
343
+				'name' => __('Registration Checkout', 'event_espresso'),
344 344
 				'post' => NULL,
345 345
 				'code' => 'ESPRESSO_CHECKOUT'
346 346
 			),
347 347
 			array(
348 348
 				'id' => 'txn_page_id',
349
-				'name' => __( 'Transactions', 'event_espresso' ),
349
+				'name' => __('Transactions', 'event_espresso'),
350 350
 				'post' => NULL,
351 351
 				'code' => 'ESPRESSO_TXN_PAGE'
352 352
 			),
353 353
 			array(
354 354
 				'id' => 'thank_you_page_id',
355
-				'name' => __( 'Thank You', 'event_espresso' ),
355
+				'name' => __('Thank You', 'event_espresso'),
356 356
 				'post' => NULL,
357 357
 				'code' => 'ESPRESSO_THANK_YOU'
358 358
 			),
359 359
 			array(
360 360
 				'id' => 'cancel_page_id',
361
-				'name' => __( 'Registration Cancelled', 'event_espresso' ),
361
+				'name' => __('Registration Cancelled', 'event_espresso'),
362 362
 				'post' => NULL,
363 363
 				'code' => 'ESPRESSO_CANCELLED'
364 364
 			),
365 365
 		);
366 366
 
367
-		foreach ( $critical_pages as $critical_page ) {
367
+		foreach ($critical_pages as $critical_page) {
368 368
 			// is critical page ID set in config ?
369
-			if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) {
369
+			if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) {
370 370
 				// attempt to find post by ID
371
-				$critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] );
371
+				$critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']);
372 372
 			}
373 373
 			// no dice?
374
-			if ( $critical_page['post'] == NULL ) {
374
+			if ($critical_page['post'] == NULL) {
375 375
 				// attempt to find post by title
376
-				$critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] );
376
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
377 377
 				// still nothing?
378
-				if ( $critical_page['post'] == NULL ) {
379
-					$critical_page = EEH_Activation::create_critical_page( $critical_page );
378
+				if ($critical_page['post'] == NULL) {
379
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
380 380
 					// REALLY? Still nothing ??!?!?
381
-					if ( $critical_page['post'] == NULL ) {
382
-						$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
383
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
381
+					if ($critical_page['post'] == NULL) {
382
+						$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
383
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
384 384
 						break;
385 385
 					}
386 386
 				}
387 387
 			}
388 388
 			// track post_shortcodes
389
-			if ( $critical_page['post'] ) {
390
-				EEH_Activation::_track_critical_page_post_shortcodes( $critical_page );
389
+			if ($critical_page['post']) {
390
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
391 391
 			}
392 392
 			// check that Post ID matches critical page ID in config
393
-			if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) {
393
+			if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) {
394 394
 				//update Config with post ID
395 395
 				EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID;
396
-				if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) {
397
-					$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
398
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
396
+				if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
397
+					$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
398
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
399 399
 				}
400 400
 			}
401 401
 
402
-			$critical_page_problem =  ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem;
402
+			$critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem;
403 403
 
404 404
 		}
405 405
 
406
-		if ( $critical_page_problem ) {
406
+		if ($critical_page_problem) {
407 407
 			$msg = sprintf(
408
-				__('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' ),
409
-				'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'
408
+				__('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'),
409
+				'<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>'
410 410
 			);
411
-			EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg );
411
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
412 412
 		}
413 413
 
414
-		if ( EE_Error::has_notices() ) {
415
-			EE_Error::get_notices( FALSE, TRUE, TRUE );
414
+		if (EE_Error::has_notices()) {
415
+			EE_Error::get_notices(FALSE, TRUE, TRUE);
416 416
 		}
417 417
 
418 418
 	}
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 	 * parameter to the shortcode
426 426
 	 * @return WP_Post or NULl
427 427
 	 */
428
-	public static function get_page_by_ee_shortcode($ee_shortcode){
428
+	public static function get_page_by_ee_shortcode($ee_shortcode) {
429 429
 		global $wpdb;
430 430
 		$shortcode_and_opening_bracket = '['.$ee_shortcode;
431 431
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
432
-		if($post_id){
432
+		if ($post_id) {
433 433
 			return get_post($post_id);
434
-		}else{
434
+		} else {
435 435
 			return NULL;
436 436
 		}
437 437
 
@@ -448,32 +448,32 @@  discard block
 block discarded – undo
448 448
 	 * @param array $critical_page
449 449
 	 * @return array
450 450
 	 */
451
-	public static function create_critical_page( $critical_page ) {
451
+	public static function create_critical_page($critical_page) {
452 452
 
453 453
 		$post_args = array(
454 454
 			'post_title' => $critical_page['name'],
455 455
 			'post_status' => 'publish',
456 456
 			'post_type' => 'page',
457 457
 			'comment_status' => 'closed',
458
-			'post_content' => '[' . $critical_page['code'] . ']'
458
+			'post_content' => '['.$critical_page['code'].']'
459 459
 		);
460 460
 
461
-		$post_id = wp_insert_post( $post_args );
462
-		if ( ! $post_id ) {
461
+		$post_id = wp_insert_post($post_args);
462
+		if ( ! $post_id) {
463 463
 			$msg = sprintf(
464
-				__( 'The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso' ),
464
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
465 465
 				$critical_page['name']
466 466
 			);
467
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
467
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
468 468
 			return $critical_page;
469 469
 		}
470 470
 		// get newly created post's details
471
-		if ( ! $critical_page['post'] = get_post( $post_id )) {
471
+		if ( ! $critical_page['post'] = get_post($post_id)) {
472 472
 			$msg = sprintf(
473
-				__( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ),
473
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
474 474
 				$critical_page['name']
475 475
 			);
476
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
476
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477 477
 		}
478 478
 
479 479
 		return $critical_page;
@@ -492,34 +492,34 @@  discard block
 block discarded – undo
492 492
 	 * @param array $critical_page
493 493
 	 * @return void
494 494
 	 */
495
-	private static function _track_critical_page_post_shortcodes( $critical_page = array() ) {
495
+	private static function _track_critical_page_post_shortcodes($critical_page = array()) {
496 496
 		// check the goods
497
-		if ( ! $critical_page['post'] instanceof WP_Post ) {
497
+		if ( ! $critical_page['post'] instanceof WP_Post) {
498 498
 			$msg = sprintf(
499
-				__( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ),
499
+				__('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'),
500 500
 				$critical_page['name']
501 501
 			);
502
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
502
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
503 503
 			return;
504 504
 		}
505 505
 		// map shortcode to post
506
-		EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID;
506
+		EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
507 507
 		// and make sure it's NOT added to the WP "Posts Page"
508 508
 		// name of the WP Posts Page
509 509
 		$posts_page = EE_Registry::instance()->CFG->get_page_for_posts();
510
-		if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) {
511
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] );
510
+		if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) {
511
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]);
512 512
 		}
513
-		if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) {
514
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] );
513
+		if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) {
514
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]);
515 515
 		}
516 516
 		// update post_shortcode CFG
517
-		if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) {
517
+		if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
518 518
 			$msg = sprintf(
519
-				__( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ),
519
+				__('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'),
520 520
 				$critical_page['name']
521 521
 			);
522
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
522
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
523 523
 		}
524 524
 	}
525 525
 
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
 	public static function get_default_creator_id() {
538 538
 		global $wpdb;
539 539
 
540
-		if ( ! empty( self::$_default_creator_id ) ) {
540
+		if ( ! empty(self::$_default_creator_id)) {
541 541
 			return self::$_default_creator_id;
542 542
 		}/**/
543 543
 
544
-		$role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' );
544
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
545 545
 
546 546
 		//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.
547
-		$pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check );
548
-		if ( $pre_filtered_id !== false ) {
547
+		$pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check);
548
+		if ($pre_filtered_id !== false) {
549 549
 			return (int) $pre_filtered_id;
550 550
 		}
551 551
 
552
-		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' );
553
-		$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 . '%' );
554
-		$user_id = $wpdb->get_var( $query );
555
-		 $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id );
556
-		 if ( $user_id && intval( $user_id ) ) {
557
-		 	self::$_default_creator_id =  intval( $user_id );
552
+		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities');
553
+		$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.'%');
554
+		$user_id = $wpdb->get_var($query);
555
+		 $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
556
+		 if ($user_id && intval($user_id)) {
557
+		 	self::$_default_creator_id = intval($user_id);
558 558
 		 	return self::$_default_creator_id;
559 559
 		 } else {
560 560
 		 	return NULL;
@@ -581,29 +581,29 @@  discard block
 block discarded – undo
581 581
 	 * 	@return void
582 582
 	 * @throws EE_Error if there are database errors
583 583
 	 */
584
-	public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) {
585
-		if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){
584
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) {
585
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) {
586 586
 			return;
587 587
 		}
588
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
589
-		if ( ! function_exists( 'dbDelta' )) {
590
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
588
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
589
+		if ( ! function_exists('dbDelta')) {
590
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
591 591
 		}
592 592
 		/** @var WPDB $wpdb */
593 593
 		global $wpdb;
594
-		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
594
+		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
595 595
 		// do we need to first delete an existing version of this table ?
596
-		if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){
596
+		if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) {
597 597
 			// ok, delete the table... but ONLY if it's empty
598
-			$deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name );
598
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
599 599
 			// table is NOT empty, are you SURE you want to delete this table ???
600
-			if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){
601
-				EEH_Activation::delete_unused_db_table( $wp_table_name );
602
-			} else if ( ! $deleted_safely ) {
600
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
601
+				EEH_Activation::delete_unused_db_table($wp_table_name);
602
+			} else if ( ! $deleted_safely) {
603 603
 				// so we should be more cautious rather than just dropping tables so easily
604 604
 				EE_Error::add_persistent_admin_notice(
605
-						'bad_table_' . $wp_table_name . '_detected',
606
-						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' ),
605
+						'bad_table_'.$wp_table_name.'_detected',
606
+						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'),
607 607
 								$wp_table_name,
608 608
 								"<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>",
609 609
 								'<b>wp-config.php</b>',
@@ -612,25 +612,25 @@  discard block
 block discarded – undo
612 612
 			}
613 613
 		}
614 614
 		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
615
-		if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) {
615
+		if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) {
616 616
 			$SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
617 617
 			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
618 618
 			//happened. And then we can choose to tell the end user
619
-			$old_show_errors_policy = $wpdb->show_errors( TRUE );
620
-			$old_error_suppression_policy = $wpdb->suppress_errors( FALSE );
619
+			$old_show_errors_policy = $wpdb->show_errors(TRUE);
620
+			$old_error_suppression_policy = $wpdb->suppress_errors(FALSE);
621 621
 			ob_start();
622
-			dbDelta( $SQL );
622
+			dbDelta($SQL);
623 623
 			$output = ob_get_contents();
624 624
 			ob_end_clean();
625
-			$wpdb->show_errors( $old_show_errors_policy );
626
-			$wpdb->suppress_errors( $old_error_suppression_policy );
627
-			if( ! empty( $output ) ){
628
-				throw new EE_Error( $output	);
625
+			$wpdb->show_errors($old_show_errors_policy);
626
+			$wpdb->suppress_errors($old_error_suppression_policy);
627
+			if ( ! empty($output)) {
628
+				throw new EE_Error($output);
629 629
 			}
630 630
 		} else {
631 631
 			throw new EE_Error(
632 632
 				sprintf(
633
-					__( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ),
633
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'),
634 634
 					'<br />',
635 635
 					$sql
636 636
 				)
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)'
653 653
 	 * @return bool|int
654 654
 	 */
655
-	public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){
656
-		if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){
655
+	public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') {
656
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) {
657 657
 			return FALSE;
658 658
 		}
659 659
 		global $wpdb;
660
-		$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
660
+		$full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
661 661
 		$fields = self::get_fields_on_table($table_name);
662
-		if (!in_array($column_name, $fields)){
663
-			$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info";
662
+		if ( ! in_array($column_name, $fields)) {
663
+			$alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info";
664 664
 			//echo "alter query:$alter_query";
665 665
 			return $wpdb->query($alter_query);
666 666
 		}
@@ -679,15 +679,15 @@  discard block
 block discarded – undo
679 679
 	 * 	@param string $table_name, without prefixed $wpdb->prefix
680 680
 	 * 	@return array of database column names
681 681
 	 */
682
-	public static function get_fields_on_table( $table_name = NULL ) {
682
+	public static function get_fields_on_table($table_name = NULL) {
683 683
 		global $wpdb;
684
-		$table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
685
-		if ( ! empty( $table_name )) {
684
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
685
+		if ( ! empty($table_name)) {
686 686
 			$columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name ");
687 687
 			if ($columns !== FALSE) {
688 688
 				$field_array = array();
689
-				foreach($columns as $column ){
690
-					$field_array[] = $column->Field;;
689
+				foreach ($columns as $column) {
690
+					$field_array[] = $column->Field; ;
691 691
 				}
692 692
 				return $field_array;
693 693
 			}
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 	 * @param string $table_name
706 706
 	 * @return bool
707 707
 	 */
708
-	public static function db_table_is_empty( $table_name ) {
708
+	public static function db_table_is_empty($table_name) {
709 709
 		global $wpdb;
710
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
711
-		if ( EEH_Activation::table_exists( $table_name ) ) {
712
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
713
-			return absint( $count ) === 0 ? true : false;
710
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
711
+		if (EEH_Activation::table_exists($table_name)) {
712
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
713
+			return absint($count) === 0 ? true : false;
714 714
 		}
715 715
 		return false;
716 716
 	}
@@ -725,9 +725,9 @@  discard block
 block discarded – undo
725 725
 	 * @param string $table_name
726 726
 	 * @return bool | int
727 727
 	 */
728
-	public static function delete_db_table_if_empty( $table_name ) {
729
-		if ( EEH_Activation::db_table_is_empty( $table_name ) ) {
730
-			return EEH_Activation::delete_unused_db_table( $table_name );
728
+	public static function delete_db_table_if_empty($table_name) {
729
+		if (EEH_Activation::db_table_is_empty($table_name)) {
730
+			return EEH_Activation::delete_unused_db_table($table_name);
731 731
 		}
732 732
 		return false;
733 733
 	}
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 	 * @param string $table_name
743 743
 	 * @return bool | int
744 744
 	 */
745
-	public static function delete_unused_db_table( $table_name ) {
745
+	public static function delete_unused_db_table($table_name) {
746 746
 		global $wpdb;
747
-		if ( EEH_Activation::table_exists( $table_name ) ) {
748
-			$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
749
-			return $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
747
+		if (EEH_Activation::table_exists($table_name)) {
748
+			$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
749
+			return $wpdb->query("DROP TABLE IF EXISTS $table_name");
750 750
 		}
751 751
 		return false;
752 752
 	}
@@ -762,18 +762,18 @@  discard block
 block discarded – undo
762 762
 	 * @param string $index_name
763 763
 	 * @return bool | int
764 764
 	 */
765
-	public static function drop_index( $table_name, $index_name ) {
766
-		if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){
765
+	public static function drop_index($table_name, $index_name) {
766
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) {
767 767
 			return FALSE;
768 768
 		}
769 769
 		global $wpdb;
770
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
770
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
771 771
 		$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'";
772 772
 		if (
773
-			$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name
774
-			&& $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name
773
+			$wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name
774
+			&& $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name
775 775
 		) {
776
-			return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
776
+			return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name");
777 777
 		}
778 778
 		return TRUE;
779 779
 	}
@@ -789,27 +789,27 @@  discard block
 block discarded – undo
789 789
 	 * @return boolean success (whether database is setup properly or not)
790 790
 	 */
791 791
 	public static function create_database_tables() {
792
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
792
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
793 793
 		//find the migration script that sets the database to be compatible with the code
794 794
 		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
795
-		if( $dms_name ){
796
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name );
797
-			$current_data_migration_script->set_migrating( false );
795
+		if ($dms_name) {
796
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
797
+			$current_data_migration_script->set_migrating(false);
798 798
 			$current_data_migration_script->schema_changes_before_migration();
799 799
 			$current_data_migration_script->schema_changes_after_migration();
800
-			if( $current_data_migration_script->get_errors() ){
801
-				if( WP_DEBUG ){
802
-					foreach( $current_data_migration_script->get_errors() as $error ){
803
-						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
800
+			if ($current_data_migration_script->get_errors()) {
801
+				if (WP_DEBUG) {
802
+					foreach ($current_data_migration_script->get_errors() as $error) {
803
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
804 804
 					}
805
-				}else{
806
-					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' ) );
805
+				} else {
806
+					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'));
807 807
 				}
808 808
 				return false;
809 809
 			}
810 810
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
811
-		}else{
812
-			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__);
811
+		} else {
812
+			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__);
813 813
 			return false;
814 814
 		}
815 815
 		return true;
@@ -829,27 +829,27 @@  discard block
 block discarded – undo
829 829
 	public static function initialize_system_questions() {
830 830
 		// QUESTION GROUPS
831 831
 		global $wpdb;
832
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' );
832
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
833 833
 		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
834 834
 		// what we have
835
-		$question_groups = $wpdb->get_col( $SQL );
835
+		$question_groups = $wpdb->get_col($SQL);
836 836
 		// check the response
837
-		$question_groups = is_array( $question_groups ) ? $question_groups : array();
837
+		$question_groups = is_array($question_groups) ? $question_groups : array();
838 838
 		// what we should have
839
-		$QSG_systems = array( 1, 2 );
839
+		$QSG_systems = array(1, 2);
840 840
 		// loop thru what we should have and compare to what we have
841
-		foreach ( $QSG_systems as $QSG_system ) {
841
+		foreach ($QSG_systems as $QSG_system) {
842 842
 			// reset values array
843 843
 			$QSG_values = array();
844 844
 			// 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)
845
-			if ( ! in_array( "$QSG_system", $question_groups )) {
845
+			if ( ! in_array("$QSG_system", $question_groups)) {
846 846
 				// add it
847
-				switch ( $QSG_system ) {
847
+				switch ($QSG_system) {
848 848
 
849 849
 					case 1:
850 850
 							$QSG_values = array(
851
-									'QSG_name' => __( 'Personal Information', 'event_espresso' ),
852
-									'QSG_identifier' => 'personal-information-' . time(),
851
+									'QSG_name' => __('Personal Information', 'event_espresso'),
852
+									'QSG_identifier' => 'personal-information-'.time(),
853 853
 									'QSG_desc' => '',
854 854
 									'QSG_order' => 1,
855 855
 									'QSG_show_group_name' => 1,
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 
862 862
 					case 2:
863 863
 							$QSG_values = array(
864
-									'QSG_name' => __( 'Address Information','event_espresso' ),
865
-									'QSG_identifier' => 'address-information-' . time(),
864
+									'QSG_name' => __('Address Information', 'event_espresso'),
865
+									'QSG_identifier' => 'address-information-'.time(),
866 866
 									'QSG_desc' => '',
867 867
 									'QSG_order' => 2,
868 868
 									'QSG_show_group_name' => 1,
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
 
875 875
 				}
876 876
 				// make sure we have some values before inserting them
877
-				if ( ! empty( $QSG_values )) {
877
+				if ( ! empty($QSG_values)) {
878 878
 					// insert system question
879 879
 					$wpdb->insert(
880 880
 						$table_name,
881 881
 						$QSG_values,
882
-						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' )
882
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
883 883
 					);
884
-					$QSG_IDs[ $QSG_system ] = $wpdb->insert_id;
884
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
885 885
 				}
886 886
 			}
887 887
 		}
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 
891 891
 		// QUESTIONS
892 892
 		global $wpdb;
893
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' );
893
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
894 894
 		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
895 895
 		// what we have
896
-		$questions = $wpdb->get_col( $SQL );
896
+		$questions = $wpdb->get_col($SQL);
897 897
 		// what we should have
898 898
 		$QST_systems = array(
899 899
 			'fname',
@@ -910,25 +910,25 @@  discard block
 block discarded – undo
910 910
 		$order_for_group_1 = 1;
911 911
 		$order_for_group_2 = 1;
912 912
 		// loop thru what we should have and compare to what we have
913
-		foreach ( $QST_systems as $QST_system ) {
913
+		foreach ($QST_systems as $QST_system) {
914 914
 			// reset values array
915 915
 			$QST_values = array();
916 916
 			// if we don't have what we should have
917
-			if ( ! in_array( $QST_system, $questions )) {
917
+			if ( ! in_array($QST_system, $questions)) {
918 918
 				// add it
919
-				switch ( $QST_system ) {
919
+				switch ($QST_system) {
920 920
 
921 921
 					case 'fname':
922 922
 							$QST_values = array(
923
-									'QST_display_text' => __( 'First Name', 'event_espresso' ),
924
-									'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ),
923
+									'QST_display_text' => __('First Name', 'event_espresso'),
924
+									'QST_admin_label' => __('First Name - System Question', 'event_espresso'),
925 925
 									'QST_system' => 'fname',
926 926
 									'QST_type' => 'TEXT',
927 927
 									'QST_required' => 1,
928
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
928
+									'QST_required_text' => __('This field is required', 'event_espresso'),
929 929
 									'QST_order' => 1,
930 930
 									'QST_admin_only' => 0,
931
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
931
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
932 932
 									'QST_wp_user' => self::get_default_creator_id(),
933 933
 									'QST_deleted' => 0
934 934
 								);
@@ -936,15 +936,15 @@  discard block
 block discarded – undo
936 936
 
937 937
 					case 'lname':
938 938
 							$QST_values = array(
939
-									'QST_display_text' => __( 'Last Name', 'event_espresso' ),
940
-									'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ),
939
+									'QST_display_text' => __('Last Name', 'event_espresso'),
940
+									'QST_admin_label' => __('Last Name - System Question', 'event_espresso'),
941 941
 									'QST_system' => 'lname',
942 942
 									'QST_type' => 'TEXT',
943 943
 									'QST_required' => 1,
944
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
944
+									'QST_required_text' => __('This field is required', 'event_espresso'),
945 945
 									'QST_order' => 2,
946 946
 									'QST_admin_only' => 0,
947
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
947
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
948 948
 									'QST_wp_user' => self::get_default_creator_id(),
949 949
 									'QST_deleted' => 0
950 950
 								);
@@ -952,15 +952,15 @@  discard block
 block discarded – undo
952 952
 
953 953
 					case 'email':
954 954
 							$QST_values = array(
955
-									'QST_display_text' => __( 'Email Address', 'event_espresso' ),
956
-									'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ),
955
+									'QST_display_text' => __('Email Address', 'event_espresso'),
956
+									'QST_admin_label' => __('Email Address - System Question', 'event_espresso'),
957 957
 									'QST_system' => 'email',
958 958
 									'QST_type' => 'TEXT',
959 959
 									'QST_required' => 1,
960
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
960
+									'QST_required_text' => __('This field is required', 'event_espresso'),
961 961
 									'QST_order' => 3,
962 962
 									'QST_admin_only' => 0,
963
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
963
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
964 964
 									'QST_wp_user' => self::get_default_creator_id(),
965 965
 									'QST_deleted' => 0
966 966
 								);
@@ -968,15 +968,15 @@  discard block
 block discarded – undo
968 968
 
969 969
 					case 'address':
970 970
 							$QST_values = array(
971
-									'QST_display_text' => __( 'Address', 'event_espresso' ),
972
-									'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ),
971
+									'QST_display_text' => __('Address', 'event_espresso'),
972
+									'QST_admin_label' => __('Address - System Question', 'event_espresso'),
973 973
 									'QST_system' => 'address',
974 974
 									'QST_type' => 'TEXT',
975 975
 									'QST_required' => 0,
976
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
976
+									'QST_required_text' => __('This field is required', 'event_espresso'),
977 977
 									'QST_order' => 4,
978 978
 									'QST_admin_only' => 0,
979
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
979
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
980 980
 									'QST_wp_user' => self::get_default_creator_id(),
981 981
 									'QST_deleted' => 0
982 982
 								);
@@ -984,15 +984,15 @@  discard block
 block discarded – undo
984 984
 
985 985
 					case 'address2':
986 986
 							$QST_values = array(
987
-									'QST_display_text' => __( 'Address2', 'event_espresso' ),
988
-									'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ),
987
+									'QST_display_text' => __('Address2', 'event_espresso'),
988
+									'QST_admin_label' => __('Address2 - System Question', 'event_espresso'),
989 989
 									'QST_system' => 'address2',
990 990
 									'QST_type' => 'TEXT',
991 991
 									'QST_required' => 0,
992
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
992
+									'QST_required_text' => __('This field is required', 'event_espresso'),
993 993
 									'QST_order' => 5,
994 994
 									'QST_admin_only' => 0,
995
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
995
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
996 996
 									'QST_wp_user' => self::get_default_creator_id(),
997 997
 									'QST_deleted' => 0
998 998
 								);
@@ -1000,15 +1000,15 @@  discard block
 block discarded – undo
1000 1000
 
1001 1001
 					case 'city':
1002 1002
 							$QST_values = array(
1003
-									'QST_display_text' => __( 'City', 'event_espresso' ),
1004
-									'QST_admin_label' => __( 'City - System Question', 'event_espresso' ),
1003
+									'QST_display_text' => __('City', 'event_espresso'),
1004
+									'QST_admin_label' => __('City - System Question', 'event_espresso'),
1005 1005
 									'QST_system' => 'city',
1006 1006
 									'QST_type' => 'TEXT',
1007 1007
 									'QST_required' => 0,
1008
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1008
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1009 1009
 									'QST_order' => 6,
1010 1010
 									'QST_admin_only' => 0,
1011
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1011
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012 1012
 									'QST_wp_user' => self::get_default_creator_id(),
1013 1013
 									'QST_deleted' => 0
1014 1014
 								);
@@ -1016,12 +1016,12 @@  discard block
 block discarded – undo
1016 1016
 
1017 1017
 					case 'state':
1018 1018
 							$QST_values = array(
1019
-									'QST_display_text' => __( 'State/Province', 'event_espresso' ),
1020
-									'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ),
1019
+									'QST_display_text' => __('State/Province', 'event_espresso'),
1020
+									'QST_admin_label' => __('State/Province - System Question', 'event_espresso'),
1021 1021
 									'QST_system' => 'state',
1022 1022
 									'QST_type' => 'STATE',
1023 1023
 									'QST_required' => 0,
1024
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1024
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1025 1025
 									'QST_order' => 7,
1026 1026
 									'QST_admin_only' => 0,
1027 1027
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1031,12 +1031,12 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
 					case 'country' :
1033 1033
 							$QST_values = array(
1034
-									'QST_display_text' => __( 'Country', 'event_espresso' ),
1035
-									'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ),
1034
+									'QST_display_text' => __('Country', 'event_espresso'),
1035
+									'QST_admin_label' => __('Country - System Question', 'event_espresso'),
1036 1036
 									'QST_system' => 'country',
1037 1037
 									'QST_type' => 'COUNTRY',
1038 1038
 									'QST_required' => 0,
1039
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1039
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1040 1040
 									'QST_order' => 8,
1041 1041
 									'QST_admin_only' => 0,
1042 1042
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1046,15 +1046,15 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
 					case 'zip':
1048 1048
 							$QST_values = array(
1049
-									'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ),
1050
-									'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ),
1049
+									'QST_display_text' => __('Zip/Postal Code', 'event_espresso'),
1050
+									'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'),
1051 1051
 									'QST_system' => 'zip',
1052 1052
 									'QST_type' => 'TEXT',
1053 1053
 									'QST_required' => 0,
1054
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1054
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1055 1055
 									'QST_order' => 9,
1056 1056
 									'QST_admin_only' => 0,
1057
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1057
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1058 1058
 									'QST_wp_user' => self::get_default_creator_id(),
1059 1059
 									'QST_deleted' => 0
1060 1060
 								);
@@ -1062,49 +1062,49 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
 					case 'phone':
1064 1064
 							$QST_values = array(
1065
-									'QST_display_text' => __( 'Phone Number', 'event_espresso' ),
1066
-									'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ),
1065
+									'QST_display_text' => __('Phone Number', 'event_espresso'),
1066
+									'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'),
1067 1067
 									'QST_system' => 'phone',
1068 1068
 									'QST_type' => 'TEXT',
1069 1069
 									'QST_required' => 0,
1070
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1070
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1071 1071
 									'QST_order' => 10,
1072 1072
 									'QST_admin_only' => 0,
1073
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1073
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1074 1074
 									'QST_wp_user' => self::get_default_creator_id(),
1075 1075
 									'QST_deleted' => 0
1076 1076
 								);
1077 1077
 						break;
1078 1078
 
1079 1079
 				}
1080
-				if ( ! empty( $QST_values )) {
1080
+				if ( ! empty($QST_values)) {
1081 1081
 					// insert system question
1082 1082
 					$wpdb->insert(
1083 1083
 						$table_name,
1084 1084
 						$QST_values,
1085
-						array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' )
1085
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1086 1086
 					);
1087 1087
 					$QST_ID = $wpdb->insert_id;
1088 1088
 
1089 1089
 					// QUESTION GROUP QUESTIONS
1090
-					if(  in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) {
1090
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1091 1091
 						$system_question_we_want = EEM_Question_Group::system_personal;
1092 1092
 					} else {
1093 1093
 						$system_question_we_want = EEM_Question_Group::system_address;
1094 1094
 					}
1095
-					if( isset( $QSG_IDs[ $system_question_we_want ] ) ) {
1096
-						$QSG_ID = $QSG_IDs[ $system_question_we_want ];
1095
+					if (isset($QSG_IDs[$system_question_we_want])) {
1096
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1097 1097
 					} else {
1098
-						$id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) );
1099
-						if( is_array( $id_col ) ) {
1100
-							$QSG_ID = reset( $id_col );
1098
+						$id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
1099
+						if (is_array($id_col)) {
1100
+							$QSG_ID = reset($id_col);
1101 1101
 						} else {
1102 1102
 							//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
1103 1103
                                                         EE_Log::instance()->log( 
1104 1104
                                                                 __FILE__, 
1105 1105
                                                                 __FUNCTION__, 
1106 1106
                                                                 sprintf( 
1107
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1107
+                                                                        __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1108 1108
                                                                         $QST_ID ), 
1109 1109
                                                                 'error' );
1110 1110
                                                         continue;
@@ -1113,9 +1113,9 @@  discard block
 block discarded – undo
1113 1113
                                         
1114 1114
 					// add system questions to groups
1115 1115
 					$wpdb->insert(
1116
-						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1117
-						array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ),
1118
-						array( '%d', '%d','%d' )
1116
+						EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'),
1117
+						array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++),
1118
+						array('%d', '%d', '%d')
1119 1119
 					);
1120 1120
 				}
1121 1121
 			}
@@ -1127,11 +1127,11 @@  discard block
 block discarded – undo
1127 1127
 	 * Makes sure the default payment method (Invoice) is active.
1128 1128
 	 * This used to be done automatically as part of constructing the old gateways config
1129 1129
 	 */
1130
-	public static function insert_default_payment_methods(){
1131
-		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1132
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1133
-			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1134
-		}else{
1130
+	public static function insert_default_payment_methods() {
1131
+		if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1132
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1133
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1134
+		} else {
1135 1135
 			EEM_Payment_Method::instance()->verify_button_urls();
1136 1136
 		}
1137 1137
 	}
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 		global $wpdb;
1149 1149
 
1150
-		if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) {
1150
+		if (EEH_Activation::table_exists(EEM_Status::instance()->table())) {
1151 1151
 
1152 1152
 			$table_name = EEM_Status::instance()->table();
1153 1153
 
@@ -1213,38 +1213,38 @@  discard block
 block discarded – undo
1213 1213
 	 * 	@return boolean success of verifying upload directories exist
1214 1214
 	 */
1215 1215
 	public static function create_upload_directories() {
1216
-		EE_Registry::instance()->load_helper( 'File' );
1216
+		EE_Registry::instance()->load_helper('File');
1217 1217
 		// Create the required folders
1218 1218
 		$folders = array(
1219 1219
 				EVENT_ESPRESSO_TEMPLATE_DIR,
1220 1220
 				EVENT_ESPRESSO_GATEWAY_DIR,
1221
-				EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1222
-				EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1223
-				EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'
1221
+				EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1222
+				EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1223
+				EVENT_ESPRESSO_UPLOAD_DIR.'tickets/'
1224 1224
 		);
1225
-		foreach ( $folders as $folder ) {
1225
+		foreach ($folders as $folder) {
1226 1226
 			try {
1227
-				EEH_File::ensure_folder_exists_and_is_writable( $folder );
1228
-				@ chmod( $folder, 0755 );
1229
-			} catch( EE_Error $e ){
1227
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1228
+				@ chmod($folder, 0755);
1229
+			} catch (EE_Error $e) {
1230 1230
 				EE_Error::add_error(
1231 1231
 					sprintf(
1232
-						__(  'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ),
1232
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1233 1233
 						$folder,
1234
-						'<br />' . $e->getMessage()
1234
+						'<br />'.$e->getMessage()
1235 1235
 					),
1236 1236
 					__FILE__, __FUNCTION__, __LINE__
1237 1237
 				);
1238 1238
 				//indicate we'll need to fix this later
1239
-				update_option( EEH_Activation::upload_directories_incomplete_option_name, true );
1239
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1240 1240
 				return FALSE;
1241 1241
 			}
1242 1242
 		}
1243 1243
 		//just add the .htaccess file to the logs directory to begin with. Even if logging
1244 1244
 		//is disabled, there might be activation errors recorded in there
1245
-		EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' );
1245
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1246 1246
 		//remember EE's folders are all good
1247
-		delete_option( EEH_Activation::upload_directories_incomplete_option_name );
1247
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1248 1248
 		return TRUE;
1249 1249
 	}
1250 1250
 	
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 	 * @return boolean
1258 1258
 	 */
1259 1259
 	public static function upload_directories_incomplete() {
1260
-		return get_option( EEH_Activation::upload_directories_incomplete_option_name, false );
1260
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1261 1261
 	}
1262 1262
 
1263 1263
 
@@ -1276,16 +1276,16 @@  discard block
 block discarded – undo
1276 1276
 		$installed_messengers = $default_messengers = array();
1277 1277
 
1278 1278
 		//include our helper
1279
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1279
+		EE_Registry::instance()->load_helper('MSG_Template');
1280 1280
 
1281 1281
 		//get all installed messenger objects
1282 1282
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1283 1283
 
1284 1284
 		//let's setup the $installed messengers in an array AND the messengers that are set to be activated on install.
1285
-		foreach ( $installed['messengers'] as $msgr ) {
1286
-			if ( $msgr instanceof EE_messenger ) {
1285
+		foreach ($installed['messengers'] as $msgr) {
1286
+			if ($msgr instanceof EE_messenger) {
1287 1287
 				$installed_messengers[$msgr->name] = $msgr;
1288
-				if ( $msgr->activate_on_install ) {
1288
+				if ($msgr->activate_on_install) {
1289 1289
 					$default_messengers[] = $msgr->name;
1290 1290
 				}
1291 1291
 			}
@@ -1295,36 +1295,36 @@  discard block
 block discarded – undo
1295 1295
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1296 1296
 
1297 1297
 		//things that have already been activated before
1298
-		$has_activated = get_option( 'ee_has_activated_messenger' );
1298
+		$has_activated = get_option('ee_has_activated_messenger');
1299 1299
 
1300 1300
 		//do an initial loop to determine if we need to continue
1301 1301
 		$def_ms = array();
1302
-		foreach ( $default_messengers as $msgr ) {
1303
-			if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue;
1302
+		foreach ($default_messengers as $msgr) {
1303
+			if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue;
1304 1304
 			$def_ms[] = $msgr;
1305 1305
 		}
1306 1306
 
1307 1307
 		//setup the $installed_mts in an array
1308
-		foreach ( $installed['message_types'] as $imt ) {
1309
-			if ( $imt instanceof EE_message_type ) {
1308
+		foreach ($installed['message_types'] as $imt) {
1309
+			if ($imt instanceof EE_message_type) {
1310 1310
 				$installed_mts[$imt->name] = $imt;
1311 1311
 			}
1312 1312
 		}
1313 1313
 
1314 1314
 		//loop through default array for default messengers (if present)
1315
-		if ( ! empty( $def_ms ) ) {
1316
-			foreach ( $def_ms as $messenger ) {
1315
+		if ( ! empty($def_ms)) {
1316
+			foreach ($def_ms as $messenger) {
1317 1317
 				//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.
1318
-				if ( ! isset( $installed_messengers[$messenger] )) {
1318
+				if ( ! isset($installed_messengers[$messenger])) {
1319 1319
 					continue;
1320 1320
 				}
1321 1321
 				/** @var EE_messenger[] $installed_messengers  */
1322 1322
 				$default_mts = $installed_messengers[$messenger]->get_default_message_types();
1323 1323
 				$active_messengers[$messenger]['obj'] = $installed_messengers[$messenger];
1324
-				foreach ( $default_mts as $index => $mt ) {
1324
+				foreach ($default_mts as $index => $mt) {
1325 1325
 					//is there an installed_mt matching the default string?  If not then nothing to do here.
1326
-					if ( ! isset( $installed_mts[$mt] ) ) {
1327
-						unset( $default_mts[$index] );
1326
+					if ( ! isset($installed_mts[$mt])) {
1327
+						unset($default_mts[$index]);
1328 1328
 						continue;
1329 1329
 					}
1330 1330
 
@@ -1333,41 +1333,41 @@  discard block
 block discarded – undo
1333 1333
 					/** @var EE_message_type[] $installed_mts */
1334 1334
 					$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1335 1335
 					$settings = array();
1336
-					if ( is_array( $settings_fields ) ) {
1337
-						foreach ( $settings_fields as $field => $values ) {
1338
-							if ( isset( $values['default'] ) ) {
1336
+					if (is_array($settings_fields)) {
1337
+						foreach ($settings_fields as $field => $values) {
1338
+							if (isset($values['default'])) {
1339 1339
 								$settings[$field] = $values['default'];
1340 1340
 							}
1341 1341
 						}
1342 1342
 					}
1343 1343
 
1344
-					$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1344
+					$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1345 1345
 					$has_activated[$messenger][] = $mt;
1346 1346
 				}
1347 1347
 
1348 1348
 				//setup any initial settings for the messenger
1349 1349
 				$msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields();
1350 1350
 
1351
-				if ( !empty( $msgr_settings ) ) {
1352
-					foreach ( $msgr_settings as $field => $value ) {
1351
+				if ( ! empty($msgr_settings)) {
1352
+					foreach ($msgr_settings as $field => $value) {
1353 1353
 						$active_messengers[$messenger]['settings'][$field] = $value;
1354 1354
 					}
1355 1355
 				}
1356 1356
 
1357 1357
 				//now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate.
1358
-				EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1358
+				EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1359 1359
 
1360 1360
 				//let's generate all the templates but only if the messenger has default_mts (otherwise its just activated).
1361
-				if ( !empty( $default_mts ) ) {
1362
-					$success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE );
1361
+				if ( ! empty($default_mts)) {
1362
+					$success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE);
1363 1363
 				}
1364 1364
 			}
1365 1365
 		} //end check for empty( $def_ms )
1366 1366
 
1367 1367
 		//still need to see if there are any message types to activate for active messengers
1368
-		foreach ( $active_messengers as $messenger => $settings ) {
1368
+		foreach ($active_messengers as $messenger => $settings) {
1369 1369
 			$msg_obj = $settings['obj'];
1370
-			if ( ! $msg_obj instanceof EE_messenger ) {
1370
+			if ( ! $msg_obj instanceof EE_messenger) {
1371 1371
 				continue;
1372 1372
 			}
1373 1373
 
@@ -1375,45 +1375,45 @@  discard block
 block discarded – undo
1375 1375
 			$new_default_mts = array();
1376 1376
 
1377 1377
 			//loop through each default mt reported by the messenger and make sure its set in its active db entry.
1378
-			foreach( $all_default_mts as $index => $mt ) {
1378
+			foreach ($all_default_mts as $index => $mt) {
1379 1379
 				//already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated).
1380
-				if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ||  EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) {
1380
+				if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) {
1381 1381
 					continue;
1382 1382
 				}
1383 1383
 
1384 1384
 				//is there an installed_mt matching the default string?  If not then nothing to do here.
1385
-				if ( ! isset( $installed_mts[$mt] ) ) {
1386
-					unset( $all_default_mts[$mt] );
1385
+				if ( ! isset($installed_mts[$mt])) {
1386
+					unset($all_default_mts[$mt]);
1387 1387
 					continue;
1388 1388
 				}
1389 1389
 
1390 1390
 				$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1391 1391
 				$settings = array();
1392
-				if ( is_array( $settings_fields ) ) {
1393
-					foreach ( $settings_fields as $field => $values ) {
1394
-						if ( isset( $values['default'] ) ) {
1392
+				if (is_array($settings_fields)) {
1393
+					foreach ($settings_fields as $field => $values) {
1394
+						if (isset($values['default'])) {
1395 1395
 							$settings[$field] = $values['default'];
1396 1396
 						}
1397 1397
 					}
1398 1398
 				}
1399 1399
 
1400
-				$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1400
+				$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1401 1401
 				$new_default_mts[] = $mt;
1402 1402
 				$has_activated[$messenger][] = $mt;
1403 1403
 			}
1404 1404
 
1405 1405
 
1406
-			if ( ! empty( $new_default_mts ) ) {
1407
-				$success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE );
1406
+			if ( ! empty($new_default_mts)) {
1407
+				$success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE);
1408 1408
 			}
1409 1409
 
1410 1410
 		}
1411 1411
 
1412 1412
 		//now let's save the settings for this messenger!
1413
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1413
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1414 1414
 
1415 1415
 		//update $has_activated record
1416
-		update_option( 'ee_has_activated_messenger', $has_activated );
1416
+		update_option('ee_has_activated_messenger', $has_activated);
1417 1417
 
1418 1418
 		//that's it!
1419 1419
 		return $success;
@@ -1433,47 +1433,47 @@  discard block
 block discarded – undo
1433 1433
 	 */
1434 1434
 	public static function validate_messages_system() {
1435 1435
 		//include our helper
1436
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1436
+		EE_Registry::instance()->load_helper('MSG_Template');
1437 1437
 
1438 1438
 		//get active and installed  messengers/message types.
1439 1439
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1440 1440
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1441 1441
 		$installed_messengers = $installed_mts = array();
1442 1442
 		//set up the arrays so they can be handled easier.
1443
-		foreach( $installed['messengers'] as $im ) {
1444
-			if ( $im instanceof EE_messenger ) {
1443
+		foreach ($installed['messengers'] as $im) {
1444
+			if ($im instanceof EE_messenger) {
1445 1445
 				$installed_messengers[$im->name] = $im;
1446 1446
 			}
1447 1447
 		}
1448
-		foreach( $installed['message_types'] as $imt ) {
1449
-			if ( $imt instanceof EE_message_type ) {
1448
+		foreach ($installed['message_types'] as $imt) {
1449
+			if ($imt instanceof EE_message_type) {
1450 1450
 				$installed_mts[$imt->name] = $imt;
1451 1451
 			}
1452 1452
 		}
1453 1453
 
1454 1454
 		//now let's loop through the active array and validate
1455
-		foreach( $active_messengers as $messenger => $active_details ) {
1455
+		foreach ($active_messengers as $messenger => $active_details) {
1456 1456
 			//first let's see if this messenger is installed.
1457
-			if ( ! isset( $installed_messengers[$messenger] ) ) {
1457
+			if ( ! isset($installed_messengers[$messenger])) {
1458 1458
 				//not set so let's just remove from actives and make sure templates are inactive.
1459
-				unset( $active_messengers[$messenger] );
1460
-				EEH_MSG_Template::update_to_inactive( $messenger );
1459
+				unset($active_messengers[$messenger]);
1460
+				EEH_MSG_Template::update_to_inactive($messenger);
1461 1461
 				continue;
1462 1462
 			}
1463 1463
 
1464 1464
 			//messenger is active, so let's just make sure that any active message types not installed are deactivated.
1465
-			$mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array();
1466
-			foreach ( $mts as $mt_name => $mt ) {
1467
-				if ( ! isset( $installed_mts[$mt_name] )  ) {
1468
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
1469
-					EEH_MSG_Template::update_to_inactive( $messenger, $mt_name );
1465
+			$mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array();
1466
+			foreach ($mts as $mt_name => $mt) {
1467
+				if ( ! isset($installed_mts[$mt_name])) {
1468
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]);
1469
+					EEH_MSG_Template::update_to_inactive($messenger, $mt_name);
1470 1470
 				}
1471 1471
 			}
1472 1472
 		}
1473 1473
 
1474 1474
 		//all done! let's update the active_messengers.
1475
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1476
-		do_action( 'AHEE__EEH_Activation__validate_messages_system' );
1475
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1476
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1477 1477
 		return;
1478 1478
 	}
1479 1479
 
@@ -1487,12 +1487,12 @@  discard block
 block discarded – undo
1487 1487
 	 * 	@static
1488 1488
 	 * 	@return void
1489 1489
 	 */
1490
-	public static function create_no_ticket_prices_array(){
1490
+	public static function create_no_ticket_prices_array() {
1491 1491
 		// this creates an array for tracking events that have no active ticket prices created
1492 1492
 		// this allows us to warn admins of the situation so that it can be corrected
1493
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE );
1494
-		if ( ! $espresso_no_ticket_prices ) {
1495
-			add_option( 'ee_no_ticket_prices', array(), '', FALSE );
1493
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE);
1494
+		if ( ! $espresso_no_ticket_prices) {
1495
+			add_option('ee_no_ticket_prices', array(), '', FALSE);
1496 1496
 		}
1497 1497
 	}
1498 1498
 
@@ -1514,24 +1514,24 @@  discard block
 block discarded – undo
1514 1514
 	 * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/
1515 1515
 	 * @global wpdb $wpdb
1516 1516
 	 */
1517
-	public static function delete_all_espresso_cpt_data(){
1517
+	public static function delete_all_espresso_cpt_data() {
1518 1518
 		global $wpdb;
1519 1519
 		//get all the CPT post_types
1520 1520
 		$ee_post_types = array();
1521
-		foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){
1522
-			if ( method_exists( $model_name, 'instance' )) {
1523
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1524
-				if ( $model_obj instanceof EEM_CPT_Base ) {
1525
-					$ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type());
1521
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1522
+			if (method_exists($model_name, 'instance')) {
1523
+				$model_obj = call_user_func(array($model_name, 'instance'));
1524
+				if ($model_obj instanceof EEM_CPT_Base) {
1525
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1526 1526
 				}
1527 1527
 			}
1528 1528
 		}
1529 1529
 		//get all our CPTs
1530
-		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")";
1530
+		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1531 1531
 		$cpt_ids = $wpdb->get_col($query);
1532 1532
 		//delete each post meta and term relations too
1533
-		foreach($cpt_ids as $post_id){
1534
-			wp_delete_post($post_id,true);
1533
+		foreach ($cpt_ids as $post_id) {
1534
+			wp_delete_post($post_id, true);
1535 1535
 		}
1536 1536
 	}
1537 1537
 
@@ -1545,18 +1545,18 @@  discard block
 block discarded – undo
1545 1545
 	 * @param bool $remove_all
1546 1546
 	 * @return void
1547 1547
 	 */
1548
-	public static function delete_all_espresso_tables_and_data( $remove_all = true ) {
1548
+	public static function delete_all_espresso_tables_and_data($remove_all = true) {
1549 1549
 		global $wpdb;
1550 1550
 		$undeleted_tables = array();
1551 1551
 
1552 1552
 		// load registry
1553
-		foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){
1554
-			if ( method_exists( $model_name, 'instance' )) {
1555
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1556
-				if ( $model_obj instanceof EEM_Base ) {
1557
-					foreach ( $model_obj->get_tables() as $table ) {
1558
-						if ( strpos( $table->get_table_name(), 'esp_' )) {
1559
-							switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) {
1553
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1554
+			if (method_exists($model_name, 'instance')) {
1555
+				$model_obj = call_user_func(array($model_name, 'instance'));
1556
+				if ($model_obj instanceof EEM_Base) {
1557
+					foreach ($model_obj->get_tables() as $table) {
1558
+						if (strpos($table->get_table_name(), 'esp_')) {
1559
+							switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
1560 1560
 								case false :
1561 1561
 									$undeleted_tables[] = $table->get_table_name();
1562 1562
 								break;
@@ -1581,8 +1581,8 @@  discard block
 block discarded – undo
1581 1581
 			'esp_promotion_rule',
1582 1582
 			'esp_rule'
1583 1583
 		);
1584
-		foreach( $tables_without_models as $table ){
1585
-			EEH_Activation::delete_db_table_if_empty( $table );
1584
+		foreach ($tables_without_models as $table) {
1585
+			EEH_Activation::delete_db_table_if_empty($table);
1586 1586
 		}
1587 1587
 
1588 1588
 
@@ -1620,58 +1620,58 @@  discard block
 block discarded – undo
1620 1620
 			'ee_job_parameters_' => false,
1621 1621
 			'ee_upload_directories_incomplete' => true,
1622 1622
 		);
1623
-		if( is_main_site() ) {
1624
-			$wp_options_to_delete[ 'ee_network_config' ] = true;
1623
+		if (is_main_site()) {
1624
+			$wp_options_to_delete['ee_network_config'] = true;
1625 1625
 		}
1626 1626
 
1627 1627
 		$undeleted_options = array();
1628
-		foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) {
1628
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1629 1629
 
1630
-			if( $no_wildcard ){
1631
-				if( ! delete_option( $option_name ) ){
1630
+			if ($no_wildcard) {
1631
+				if ( ! delete_option($option_name)) {
1632 1632
 					$undeleted_options[] = $option_name;
1633 1633
 				}
1634
-			}else{
1635
-				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1636
-				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1637
-					if( ! delete_option( $option_name_from_wildcard ) ){
1634
+			} else {
1635
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1636
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1637
+					if ( ! delete_option($option_name_from_wildcard)) {
1638 1638
 						$undeleted_options[] = $option_name_from_wildcard;
1639 1639
 					}
1640 1640
 				}
1641 1641
 			}
1642 1642
 		}
1643 1643
                 //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1644
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1644
+                remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1645 1645
 
1646
-		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1646
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1647 1647
 			$db_update_sans_ee4 = array();
1648
-			foreach($espresso_db_update as $version => $times_activated){
1649
-				if( $version[0] =='3'){//if its NON EE4
1648
+			foreach ($espresso_db_update as $version => $times_activated) {
1649
+				if ($version[0] == '3') {//if its NON EE4
1650 1650
 					$db_update_sans_ee4[$version] = $times_activated;
1651 1651
 				}
1652 1652
 			}
1653
-			update_option( 'espresso_db_update', $db_update_sans_ee4 );
1653
+			update_option('espresso_db_update', $db_update_sans_ee4);
1654 1654
 		}
1655 1655
 
1656 1656
 		$errors = '';
1657
-		if ( ! empty( $undeleted_tables )) {
1657
+		if ( ! empty($undeleted_tables)) {
1658 1658
 			$errors .= sprintf(
1659
-				__( 'The following tables could not be deleted: %s%s', 'event_espresso' ),
1659
+				__('The following tables could not be deleted: %s%s', 'event_espresso'),
1660 1660
 				'<br/>',
1661
-				implode( ',<br/>', $undeleted_tables )
1661
+				implode(',<br/>', $undeleted_tables)
1662 1662
 			);
1663 1663
 		}
1664
-		if ( ! empty( $undeleted_options )) {
1665
-			$errors .= ! empty( $undeleted_tables ) ? '<br/>' : '';
1664
+		if ( ! empty($undeleted_options)) {
1665
+			$errors .= ! empty($undeleted_tables) ? '<br/>' : '';
1666 1666
 			$errors .= sprintf(
1667
-				__( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ),
1667
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1668 1668
 				'<br/>',
1669
-				implode( ',<br/>', $undeleted_options )
1669
+				implode(',<br/>', $undeleted_options)
1670 1670
 			);
1671 1671
 
1672 1672
 		}
1673
-		if ( $errors != '' ) {
1674
-			EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ );
1673
+		if ($errors != '') {
1674
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1675 1675
 		}
1676 1676
 	}
1677 1677
 
@@ -1681,23 +1681,23 @@  discard block
 block discarded – undo
1681 1681
 	 * @param string $table_name with or without $wpdb->prefix
1682 1682
 	 * @return boolean
1683 1683
 	 */
1684
-	public static function table_exists( $table_name ){
1684
+	public static function table_exists($table_name) {
1685 1685
 		global $wpdb, $EZSQL_ERROR;
1686
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
1686
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
1687 1687
 		//ignore if this causes an sql error
1688 1688
 		$old_error = $wpdb->last_error;
1689 1689
 		$old_suppress_errors = $wpdb->suppress_errors();
1690
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
1690
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
1691 1691
 		$ezsql_error_cache = $EZSQL_ERROR;
1692
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
1693
-		$wpdb->show_errors( $old_show_errors_value );
1694
-		$wpdb->suppress_errors( $old_suppress_errors );
1692
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
1693
+		$wpdb->show_errors($old_show_errors_value);
1694
+		$wpdb->suppress_errors($old_suppress_errors);
1695 1695
 		$new_error = $wpdb->last_error;
1696 1696
 		$wpdb->last_error = $old_error;
1697 1697
 		$EZSQL_ERROR = $ezsql_error_cache;
1698
-		if( empty( $new_error ) ){
1698
+		if (empty($new_error)) {
1699 1699
 			return TRUE;
1700
-		}else{
1700
+		} else {
1701 1701
 			return FALSE;
1702 1702
 		}
1703 1703
 	}
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 	/**
1706 1706
 	 * Resets the cache on EEH_Activation
1707 1707
 	 */
1708
-	public static function reset(){
1708
+	public static function reset() {
1709 1709
 		self::$_default_creator_id = NULL;
1710 1710
 		self::$_initialized_db_content_already_in_this_request = false;
1711 1711
 	}
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Spacing   +381 added lines, -381 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 		$this->_name = 'pricing';
55 55
 
56 56
 		//capability check
57
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) {
57
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
61
+		EE_Registry::instance()->load_helper('DTT_Helper');
62 62
 
63 63
 		//if we were going to add our own metaboxes we'd use the below.
64 64
 		$this->_metaboxes = array(
65 65
 			0 => array(
66
-				'page_route' => array('edit','create_new'),
66
+				'page_route' => array('edit', 'create_new'),
67 67
 				'func' => 'pricing_metabox',
68 68
 				'label' => __('Event Tickets & Datetimes', 'event_espresso'),
69 69
 				'priority' => 'high',
70 70
 				'context' => 'normal'
71 71
 				),
72 72
 
73
-			);/**/
73
+			); /**/
74 74
 
75 75
 		$this->_remove_metaboxes = array(
76 76
 			0 => array(
@@ -89,24 +89,24 @@  discard block
 block discarded – undo
89 89
 		 *
90 90
 		 * @var array  Expected an array returned with 'date' and 'time' keys.
91 91
 		 */
92
-		$this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
92
+		$this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
93 93
 				'date' => 'Y-m-d',
94 94
 				'time' => 'h:i a'
95 95
 			));
96 96
 
97 97
 		//validate
98
-		$this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null;
99
-		$this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null;
98
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
99
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
100 100
 
101 101
 		//validate format strings
102
-		$format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
103
-		if ( is_array( $format_validation ) ) {
104
-			$msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>';
105
-			foreach ( $format_validation as $error ) {
106
-				$msg .= '<li>' . $error . '</li>';
102
+		$format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
103
+		if (is_array($format_validation)) {
104
+			$msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>';
105
+			foreach ($format_validation as $error) {
106
+				$msg .= '<li>'.$error.'</li>';
107 107
 			}
108
-			$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
109
-			EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
108
+			$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
109
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
110 110
 			$this->_date_format_strings = array(
111 111
 				'date' => 'Y-m-d',
112 112
 				'time' => 'h:i a'
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
 		$this->_scripts_styles = array(
118 118
 			'registers' => array(
119 119
 				'ee-tickets-datetimes-css' => array(
120
-					'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
120
+					'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
121 121
 					'type' => 'css'
122 122
 					),
123 123
 				'ee-dtt-ticket-metabox' => array(
124
-					'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
124
+					'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
125 125
 					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
126 126
 					)
127 127
 				),
128 128
 			'deregisters' => array(
129
-				'event-editor-css' => array('type' => 'css' ),
129
+				'event-editor-css' => array('type' => 'css'),
130 130
 				'event-datetime-metabox' => array('type' => 'js')
131 131
 				),
132 132
 			'enqueues' => array(
133
-				'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ),
134
-				'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' )
133
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
134
+				'ee-dtt-ticket-metabox' => array('edit', 'create_new')
135 135
 				),
136 136
 			'localize' => array(
137 137
 				'ee-dtt-ticket-metabox' => array(
138 138
 					'DTT_TRASH_BLOCK' => array(
139 139
 						'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'),
140 140
 						'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'),
141
-						'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>',
141
+						'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>',
142 142
 						'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
143 143
 						'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
144
-						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>'
144
+						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>'
145 145
 						),
146 146
 					'DTT_ERROR_MSG' => array(
147 147
 						'no_ticket_name' => __('General Admission', 'event_espresso'),
148
-						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>'
148
+						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>'
149 149
 						),
150 150
 					'DTT_OVERSELL_WARNING' => array(
151 151
 						'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'),
152 152
 						'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso')
153 153
 						),
154
-					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ),
155
-					'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) )
154
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']),
155
+					'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week'))
156 156
 					)
157 157
 				)
158 158
 			);
159 159
 
160 160
 
161
-		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 );
162
-		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 );
161
+		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10);
162
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10);
163 163
 	}
164 164
 
165 165
 
166 166
 
167
-	public function caf_updates( $update_callbacks ) {
168
-		foreach ( $update_callbacks as $key => $callback ) {
169
-			if ( $callback[1] == '_default_tickets_update' )
170
-				unset( $update_callbacks[$key] );
167
+	public function caf_updates($update_callbacks) {
168
+		foreach ($update_callbacks as $key => $callback) {
169
+			if ($callback[1] == '_default_tickets_update')
170
+				unset($update_callbacks[$key]);
171 171
 		}
172 172
 
173
-		$update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' );
173
+		$update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
174 174
 		return $update_callbacks;
175 175
 	}
176 176
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @param  array    $data   The request data from the form
184 184
 	 * @return bool             success or fail
185 185
 	 */
186
-	public function dtt_and_tickets_caf_update( $evtobj, $data ) {
186
+	public function dtt_and_tickets_caf_update($evtobj, $data) {
187 187
 		//first we need to start with datetimes cause they are the "root" items attached to events.
188
-		$saved_dtts = $this->_update_dtts( $evtobj, $data );
188
+		$saved_dtts = $this->_update_dtts($evtobj, $data);
189 189
 		//next tackle the tickets (and prices?)
190
-		$this->_update_tkts( $evtobj, $saved_dtts, $data );
190
+		$this->_update_tkts($evtobj, $saved_dtts, $data);
191 191
 	}
192 192
 
193 193
 
@@ -198,41 +198,41 @@  discard block
 block discarded – undo
198 198
 	 * @param  array    	$data    the request data from the form
199 199
 	 * @return EE_Datetime[]
200 200
 	 */
201
-	protected function _update_dtts( $evt_obj, $data ) {
202
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
201
+	protected function _update_dtts($evt_obj, $data) {
202
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
203 203
 		$saved_dtt_ids = array();
204 204
 		$saved_dtt_objs = array();
205 205
 
206
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
206
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
207 207
 			//trim all values to ensure any excess whitespace is removed.
208 208
 			$dtt = array_map(
209
-				function( $datetime_data ) {
210
-					return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data );
209
+				function($datetime_data) {
210
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
211 211
 				},
212 212
 				$dtt
213 213
 			);
214
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
214
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
215 215
 			$datetime_values = array(
216
-				'DTT_ID' 			=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
217
-				'DTT_name' 			=> ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '',
218
-				'DTT_description' 	=> ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '',
216
+				'DTT_ID' 			=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
217
+				'DTT_name' 			=> ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
218
+				'DTT_description' 	=> ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
219 219
 				'DTT_EVT_start' 	=> $dtt['DTT_EVT_start'],
220 220
 				'DTT_EVT_end' 		=> $dtt['DTT_EVT_end'],
221
-				'DTT_reg_limit' 	=> empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ],
222
-				'DTT_order' 		=> ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'],
221
+				'DTT_reg_limit' 	=> empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
222
+				'DTT_order' 		=> ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
223 223
 			);
224 224
 
225 225
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
226 226
 
227
-			if ( !empty( $dtt['DTT_ID'] ) ) {
228
-				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] );
227
+			if ( ! empty($dtt['DTT_ID'])) {
228
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
229 229
 
230 230
 				//set date and time format according to what is set in this class.
231
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
232
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
231
+				$DTM->set_date_format($this->_date_format_strings['date']);
232
+				$DTM->set_time_format($this->_date_format_strings['time']);
233 233
 
234
-				foreach ( $datetime_values as $field => $value ) {
235
-					$DTM->set( $field, $value );
234
+				foreach ($datetime_values as $field => $value) {
235
+					$DTM->set($field, $value);
236 236
 				}
237 237
 
238 238
 				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
@@ -240,24 +240,24 @@  discard block
 block discarded – undo
240 240
 				$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
241 241
 
242 242
 			} else {
243
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE );
243
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE);
244 244
 
245 245
 				//reset date and times to match the format
246
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
247
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
248
-				foreach( $datetime_values as $field => $value ) {
249
-					$DTM->set( $field, $value );
246
+				$DTM->set_date_format($this->_date_format_strings['date']);
247
+				$DTM->set_time_format($this->_date_format_strings['time']);
248
+				foreach ($datetime_values as $field => $value) {
249
+					$DTM->set($field, $value);
250 250
 				}
251 251
 			}
252 252
 
253 253
 
254 254
 			$DTM->save();
255
-			$DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' );
255
+			$DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
256 256
 			$evt_obj->save();
257 257
 
258 258
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
259
-			if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) {
260
-				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') );
259
+			if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
260
+				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
261 261
 				EE_Registry::instance()->load_helper('DTT_Helper');
262 262
 				$DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
263 263
 				$DTM->save();
@@ -273,25 +273,25 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		//now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
276
-		$old_datetimes = explode(',', $data['datetime_IDs'] );
276
+		$old_datetimes = explode(',', $data['datetime_IDs']);
277 277
 		$old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
278 278
 
279
-		if ( is_array( $old_datetimes ) ) {
280
-			$dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids );
281
-			foreach ( $dtts_to_delete as $id ) {
282
-				$id = absint( $id );
283
-				if ( empty( $id ) )
279
+		if (is_array($old_datetimes)) {
280
+			$dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
281
+			foreach ($dtts_to_delete as $id) {
282
+				$id = absint($id);
283
+				if (empty($id))
284 284
 					continue;
285 285
 
286 286
 				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
287 287
 
288 288
 				//remove tkt relationships.
289 289
 				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
290
-				foreach ( $related_tickets as $tkt ) {
290
+				foreach ($related_tickets as $tkt) {
291 291
 					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
292 292
 				}
293 293
 
294
-				$evt_obj->_remove_relation_to( $id, 'Datetime' );
294
+				$evt_obj->_remove_relation_to($id, 'Datetime');
295 295
 				$dtt_to_remove->refresh_cache_of_related_objects();
296 296
 
297 297
 			}
@@ -312,86 +312,86 @@  discard block
 block discarded – undo
312 312
 	 * @param  array            $data       incoming request data
313 313
 	 * @return EE_Ticket[]
314 314
 	 */
315
-	protected function _update_tkts( $evtobj, $saved_dtts, $data ) {
315
+	protected function _update_tkts($evtobj, $saved_dtts, $data) {
316 316
 
317 317
 		$new_tkt = null;
318 318
 		$new_default = null;
319 319
 		//stripslashes because WP filtered the $_POST ($data) array to add slashes
320 320
 		$data = stripslashes_deep($data);
321
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
321
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
322 322
 		$saved_tickets = $dtts_on_existing = array();
323
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
323
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
324 324
 
325 325
 		//load money helper
326
-		EE_Registry::instance()->load_helper( 'Money' );
326
+		EE_Registry::instance()->load_helper('Money');
327 327
 
328
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
328
+		foreach ($data['edit_tickets'] as $row => $tkt) {
329 329
 
330 330
 			$update_prices = $create_new_TKT = FALSE;
331 331
 
332 332
 			//figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
333 333
 
334
-			$starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]);
335
-			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] );
334
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
335
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
336 336
 			$dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
337 337
 			$dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
338 338
 
339 339
 			// trim inputs to ensure any excess whitespace is removed.
340 340
 			$tkt = array_map(
341
-				function( $ticket_data ) {
342
-					return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data );
341
+				function($ticket_data) {
342
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
343 343
 				},
344 344
 				$tkt
345 345
 			);
346 346
 
347 347
 			//note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
348 348
 			//note incoming ['TKT_price'] value is already in standard notation (via js).
349
-			$ticket_price = isset( $tkt['TKT_price'] ) ?  round ( (float) $tkt['TKT_price'], 3 ) : 0;
349
+			$ticket_price = isset($tkt['TKT_price']) ?  round ((float) $tkt['TKT_price'], 3) : 0;
350 350
 
351 351
 			//note incoming base price needs converted from localized value.
352
-			$base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0;
352
+			$base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
353 353
 			//if ticket price == 0 and $base_price != 0 then ticket price == base_price
354 354
 			$ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
355
-			$base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0;
355
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
356 356
 
357 357
 			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
358 358
 
359 359
 			$now = null;
360
-			if ( empty( $tkt['TKT_start_date'] ) ) {
360
+			if (empty($tkt['TKT_start_date'])) {
361 361
 				//lets' use now in the set timezone.
362
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
363
-				$tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
362
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
363
+				$tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
364 364
 			}
365 365
 
366
-			if ( empty( $tkt['TKT_end_date'] ) ) {
366
+			if (empty($tkt['TKT_end_date'])) {
367 367
 				/**
368 368
 				 * set the TKT_end_date to the first datetime attached to the ticket.
369 369
 				 */
370
-				$first_dtt = $saved_dtts[reset( $tkt_dtt_rows )];
371
-				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] );
370
+				$first_dtt = $saved_dtts[reset($tkt_dtt_rows)];
371
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']);
372 372
 			}
373 373
 
374 374
 			$TKT_values = array(
375
-				'TKT_ID' 			=> ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
376
-				'TTM_ID' 			=> ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
377
-				'TKT_name' 			=> ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
378
-				'TKT_description' 	=> ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
375
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
376
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
377
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
378
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
379 379
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
380 380
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
381
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ],
382
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'],
383
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
384
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
381
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
382
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
383
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
384
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
385 385
 				'TKT_row' 			=> $row,
386
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0,
387
-				'TKT_taxable' 		=> ! empty( $tkt['TKT_taxable'] ) ? 1 : 0,
388
-				'TKT_required' 		=> ! empty( $tkt['TKT_required'] ) ? 1 : 0,
386
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
387
+				'TKT_taxable' 		=> ! empty($tkt['TKT_taxable']) ? 1 : 0,
388
+				'TKT_required' 		=> ! empty($tkt['TKT_required']) ? 1 : 0,
389 389
 				'TKT_price' 		=> $ticket_price
390 390
 			);
391 391
 
392 392
 
393 393
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
394
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
394
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
395 395
 				$TKT_values['TKT_ID'] = 0;
396 396
 				$TKT_values['TKT_is_default'] = 0;
397 397
 				$update_prices = TRUE;
@@ -403,21 +403,21 @@  discard block
 block discarded – undo
403 403
 			// but DID have it's items modified.
404 404
 			// keep in mind that if the TKT has been sold (and we have changed pricing information),
405 405
 			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
406
-			if ( absint( $TKT_values['TKT_ID'] ) ) {
407
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] );
408
-				if ( $TKT instanceof EE_Ticket ) {
406
+			if (absint($TKT_values['TKT_ID'])) {
407
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
408
+				if ($TKT instanceof EE_Ticket) {
409 409
 
410
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
410
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
411 411
 					// are there any registrations using this ticket ?
412 412
 					$tickets_sold = $TKT->count_related(
413 413
 						'Registration',
414
-						array( array(
415
-								'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) )
416
-						) )
414
+						array(array(
415
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
416
+						))
417 417
 					);
418 418
 					//set ticket formats
419
-					$TKT->set_date_format( $this->_date_format_strings['date'] );
420
-					$TKT->set_time_format( $this->_date_format_strings['time'] );
419
+					$TKT->set_date_format($this->_date_format_strings['date']);
420
+					$TKT->set_time_format($this->_date_format_strings['time']);
421 421
 
422 422
 					// let's just check the total price for the existing ticket
423 423
 					// and determine if it matches the new total price.
@@ -427,17 +427,17 @@  discard block
 block discarded – undo
427 427
 							? TRUE : FALSE;
428 428
 
429 429
 					//set new values
430
-					foreach ( $TKT_values as $field => $value ) {
431
-						if ( $field === 'TKT_qty' ) {
432
-							$TKT->set_qty( $value );
430
+					foreach ($TKT_values as $field => $value) {
431
+						if ($field === 'TKT_qty') {
432
+							$TKT->set_qty($value);
433 433
 						} else {
434
-							$TKT->set( $field, $value );
434
+							$TKT->set($field, $value);
435 435
 						}
436 436
 					}
437 437
 
438 438
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
439
-					if ( $create_new_TKT ) {
440
-						$new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id );
439
+					if ($create_new_TKT) {
440
+						$new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id);
441 441
 					}
442 442
 				}
443 443
 
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 				$TKT = EE_Ticket::new_instance(
447 447
 					$TKT_values,
448 448
 					$timezone,
449
-					array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ]  )
449
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
450 450
 				);
451
-				if ( $TKT instanceof EE_Ticket ) {
451
+				if ($TKT instanceof EE_Ticket) {
452 452
 					// make sure ticket has an ID of setting relations won't work
453 453
 					$TKT->save();
454
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
454
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
455 455
 					$update_prices = TRUE;
456 456
 				}
457 457
 			}
@@ -459,38 +459,38 @@  discard block
 block discarded – undo
459 459
 			//$TKT->save();
460 460
 
461 461
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
462
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
463
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
462
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
463
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
464 464
 				EE_Registry::instance()->load_helper('DTT_Helper');
465 465
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
466 466
 			}
467 467
 
468 468
 			//let's make sure the base price is handled
469
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT;
469
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT;
470 470
 
471 471
 			//add/update price_modifiers
472
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT;
472
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
473 473
 
474 474
 			//need to make sue that the TKT_price is accurate after saving the prices.
475 475
 			$TKT->ensure_TKT_Price_correct();
476 476
 
477 477
 			//handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
478
-			if ( ! defined('DOING_AUTOSAVE' ) ) {
479
-				if ( !empty($tkt['TKT_is_default_selector'] ) ) {
478
+			if ( ! defined('DOING_AUTOSAVE')) {
479
+				if ( ! empty($tkt['TKT_is_default_selector'])) {
480 480
 					$update_prices = TRUE;
481 481
 					$new_default = clone $TKT;
482
-					$new_default->set( 'TKT_ID', 0 );
483
-					$new_default->set( 'TKT_is_default', 1 );
484
-					$new_default->set( 'TKT_row', 1 );
485
-					$new_default->set( 'TKT_price', $ticket_price );
482
+					$new_default->set('TKT_ID', 0);
483
+					$new_default->set('TKT_is_default', 1);
484
+					$new_default->set('TKT_row', 1);
485
+					$new_default->set('TKT_price', $ticket_price);
486 486
 					//remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
487 487
 					$new_default->_remove_relations('Datetime');
488 488
 					//todo we need to add the current attached prices as new prices to the new default ticket.
489
-					$new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices );
489
+					$new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
490 490
 					//don't forget the base price!
491
-					$new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id );
491
+					$new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id);
492 492
 					$new_default->save();
493
-					do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data );
493
+					do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data);
494 494
 				}
495 495
 			}
496 496
 
@@ -501,19 +501,19 @@  discard block
 block discarded – undo
501 501
 			//let's assign any tickets that have been setup to the saved_tickets tracker
502 502
 			//save existing TKT
503 503
 			$TKT->save();
504
-			if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) {
504
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
505 505
 				//save new TKT
506 506
 				$new_tkt->save();
507 507
 				//add new ticket to array
508
-				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
508
+				$saved_tickets[$new_tkt->ID()] = $new_tkt;
509 509
 
510
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data );
510
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
511 511
 
512 512
 			} else {
513 513
 				//add tkt to saved tkts
514
-				$saved_tickets[ $TKT->ID() ] = $TKT;
514
+				$saved_tickets[$TKT->ID()] = $TKT;
515 515
 
516
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data );
516
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
517 517
 			}
518 518
 
519 519
 		}
@@ -523,22 +523,22 @@  discard block
 block discarded – undo
523 523
 		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
524 524
 		// Or a draft event was saved and in the process of editing a ticket is trashed.
525 525
 		// No sense in keeping all the related data in the db!
526
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
527
-		$tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) );
526
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
527
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
528 528
 
529
-		foreach ( $tickets_removed as $id ) {
530
-			$id = absint( $id );
529
+		foreach ($tickets_removed as $id) {
530
+			$id = absint($id);
531 531
 
532 532
 			//get the ticket for this id
533 533
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
534 534
 
535 535
 			//if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
536
-			if ( $tkt_to_remove->get('TKT_is_default') )
536
+			if ($tkt_to_remove->get('TKT_is_default'))
537 537
 				continue;
538 538
 
539 539
 			// if this tkt has any registrations attached so then we just ARCHIVE
540 540
 			// because we don't actually permanently delete these tickets.
541
-			if ( $tkt_to_remove->count_related('Registration') > 0 ) {
541
+			if ($tkt_to_remove->count_related('Registration') > 0) {
542 542
 				$tkt_to_remove->delete();
543 543
 				continue;
544 544
 			}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 			// (remember this process can ONLY kick off if there are NO tkts_sold)
548 548
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
549 549
 
550
-			foreach( $dtts as $dtt ) {
550
+			foreach ($dtts as $dtt) {
551 551
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
552 552
 			}
553 553
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
556 556
 			$tkt_to_remove->delete_related_permanently('Price');
557 557
 
558
-			do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove );
558
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
559 559
 
560 560
 			// finally let's delete this ticket
561 561
 			// (which should not be blocked at this point b/c we've removed all our relationships)
@@ -587,39 +587,39 @@  discard block
 block discarded – undo
587 587
 		// and removing the ticket from datetimes it got removed from.
588 588
 
589 589
 		// first let's add datetimes
590
-		if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) {
591
-			foreach ( $added_datetimes as $row_id ) {
592
-				$row_id = (int)$row_id;
593
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
594
-					$ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
590
+		if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
591
+			foreach ($added_datetimes as $row_id) {
592
+				$row_id = (int) $row_id;
593
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
594
+					$ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
595 595
 					// Is this an existing ticket (has an ID) and does it have any sold?
596 596
 					// If so, then we need to add that to the DTT sold because this DTT is getting added.
597
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
598
-						$saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() );
599
-						$saved_datetimes[ $row_id ]->save();
597
+					if ($ticket->ID() && $ticket->sold() > 0) {
598
+						$saved_datetimes[$row_id]->increase_sold($ticket->sold());
599
+						$saved_datetimes[$row_id]->save();
600 600
 					}
601 601
 				}
602 602
 			}
603 603
 		}
604 604
 		// then remove datetimes
605
-		if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) {
606
-			foreach ( $removed_datetimes as $row_id ) {
607
-				$row_id = (int)$row_id;
605
+		if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
606
+			foreach ($removed_datetimes as $row_id) {
607
+				$row_id = (int) $row_id;
608 608
 				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
609 609
 				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
610
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
611
-					$ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
610
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
611
+					$ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
612 612
 					// Is this an existing ticket (has an ID) and does it have any sold?
613 613
 					// If so, then we need to remove it's sold from the DTT_sold.
614
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
615
-						$saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() );
616
-						$saved_datetimes[ $row_id ]->save();
614
+					if ($ticket->ID() && $ticket->sold() > 0) {
615
+						$saved_datetimes[$row_id]->decrease_sold($ticket->sold());
616
+						$saved_datetimes[$row_id]->save();
617 617
 					}
618 618
 				}
619 619
 			}
620 620
 		}
621 621
 		// cap ticket qty by datetime reg limits
622
-		$ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) );
622
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
623 623
 		return $ticket;
624 624
 	}
625 625
 
@@ -640,39 +640,39 @@  discard block
 block discarded – undo
640 640
 		EE_Ticket $ticket,
641 641
 		$price_rows = array(),
642 642
 		$ticket_price = 0,
643
-		$base_price = 0 ,
643
+		$base_price = 0,
644 644
 		$base_price_id = 0
645 645
 	) {
646 646
 
647 647
 		// create new ticket that's a copy of the existing
648 648
 		// except a new id of course (and not archived)
649 649
 		// AND has the new TKT_price associated with it.
650
-		$new_ticket = clone( $ticket );
651
-		$new_ticket->set( 'TKT_ID', 0 );
652
-		$new_ticket->set( 'TKT_deleted', 0 );
653
-		$new_ticket->set( 'TKT_price', $ticket_price );
654
-		$new_ticket->set( 'TKT_sold', 0 );
650
+		$new_ticket = clone($ticket);
651
+		$new_ticket->set('TKT_ID', 0);
652
+		$new_ticket->set('TKT_deleted', 0);
653
+		$new_ticket->set('TKT_price', $ticket_price);
654
+		$new_ticket->set('TKT_sold', 0);
655 655
 		// let's get a new ID for this ticket
656 656
 		$new_ticket->save();
657 657
 		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
658
-		$datetimes_on_existing = $ticket->get_many_related( 'Datetime' );
658
+		$datetimes_on_existing = $ticket->get_many_related('Datetime');
659 659
 		$new_ticket = $this->_update_ticket_datetimes(
660 660
 			$new_ticket,
661 661
 			$datetimes_on_existing,
662
-			array_keys( $datetimes_on_existing )
662
+			array_keys($datetimes_on_existing)
663 663
 		);
664 664
 
665 665
 		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
666 666
 		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
667 667
 		// available.
668
-		if ( $ticket->sold() > 0 ) {
668
+		if ($ticket->sold() > 0) {
669 669
 			$new_qty = $ticket->qty() - $ticket->sold();
670
-			$new_ticket->set_qty( $new_qty );
670
+			$new_ticket->set_qty($new_qty);
671 671
 		}
672 672
 		//now we update the prices just for this ticket
673
-		$new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true );
673
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
674 674
 		//and we update the base price
675
-		$new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id );
675
+		$new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
676 676
 		return $new_ticket;
677 677
 	}
678 678
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * @param int|bool 		$base_price_id  if present then this is the base_price_id being updated.
693 693
 	 * @return EE_Ticket
694 694
 	 */
695
-	protected function  _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) {
695
+	protected function  _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) {
696 696
 
697 697
 		//let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
698 698
 		$current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers();
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		$updated_prices = array();
701 701
 
702 702
 		// if $base_price ! FALSE then updating a base price.
703
-		if ( $base_price !== FALSE ) {
703
+		if ($base_price !== FALSE) {
704 704
 			$prices[1] = array(
705 705
 				'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id,
706 706
 				'PRT_ID' => 1,
@@ -711,47 +711,47 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 
713 713
 		//possibly need to save tkt
714
-		if ( ! $ticket->ID() )
714
+		if ( ! $ticket->ID())
715 715
 			$ticket->save();
716 716
 
717
-		foreach ( $prices as $row => $prc ) {
718
-			$prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL;
719
-			if ( empty($prt_id) )
717
+		foreach ($prices as $row => $prc) {
718
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL;
719
+			if (empty($prt_id))
720 720
 				continue; //prices MUST have a price type id.
721 721
 			$PRC_values = array(
722
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
722
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
723 723
 				'PRT_ID' => $prt_id,
724
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
725
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
726
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
724
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
725
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
726
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
727 727
 				'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor
728 728
 				'PRC_order' => $row
729 729
 				);
730
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
730
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
731 731
 				$PRC_values['PRC_ID'] = 0;
732
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
732
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
733 733
 			} else {
734
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
734
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
735 735
 				//update this price with new values
736
-				foreach ( $PRC_values as $field => $newprc ) {
737
-					$PRC->set( $field, $newprc );
736
+				foreach ($PRC_values as $field => $newprc) {
737
+					$PRC->set($field, $newprc);
738 738
 				}
739 739
 			}
740 740
 			$PRC->save();
741 741
 			$prcid = $PRC->ID();
742 742
 			$updated_prices[$prcid] = $PRC;
743
-			$ticket->_add_relation_to( $PRC, 'Price' );
743
+			$ticket->_add_relation_to($PRC, 'Price');
744 744
 		}
745 745
 
746 746
 		//now let's remove any prices that got removed from the ticket
747
-		if ( !empty ( $current_prices_on_ticket ) ) {
747
+		if ( ! empty ($current_prices_on_ticket)) {
748 748
 			$current = array_keys($current_prices_on_ticket);
749 749
 			$updated = array_keys($updated_prices);
750 750
 			$prices_to_remove = array_diff($current, $updated);
751
-			if ( !empty( $prices_to_remove ) ) {
752
-				foreach ( $prices_to_remove as $prc_id ) {
751
+			if ( ! empty($prices_to_remove)) {
752
+				foreach ($prices_to_remove as $prc_id) {
753 753
 					$p = $current_prices_on_ticket[$prc_id];
754
-					$ticket->_remove_relation_to( $p, 'Price' );
754
+					$ticket->_remove_relation_to($p, 'Price');
755 755
 
756 756
 					//delete permanently the price
757 757
 					$p->delete_permanently();
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
 
766 766
 
767
-	public function autosave_handling( $event_admin_obj ) {
767
+	public function autosave_handling($event_admin_obj) {
768 768
 		return $event_admin_obj; //doing nothing for the moment.
769 769
 		//todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
770 770
 
@@ -798,12 +798,12 @@  discard block
 block discarded – undo
798 798
 
799 799
 		//default main template args
800 800
 		$main_template_args = array(
801
-			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
801
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
802 802
 			'existing_datetime_ids' => '',
803 803
 			'total_dtt_rows' => 1,
804
-			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
804
+			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
805 805
 			'datetime_rows' => '',
806
-			'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
806
+			'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
807 807
 			'ticket_rows' => '',
808 808
 			'existing_ticket_ids' => '',
809 809
 			'total_ticket_rows' => 1,
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 
814 814
 		$timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL;
815 815
 
816
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
816
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
817 817
 
818 818
 		/**
819 819
 		 * 1. Start with retrieving Datetimes
@@ -821,37 +821,37 @@  discard block
 block discarded – undo
821 821
 		 * 3. For each ticket get related prices
822 822
 		 */
823 823
 
824
-		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) );
825
-		$times = $DTM->get_all_event_dates( $evtID );
824
+		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone));
825
+		$times = $DTM->get_all_event_dates($evtID);
826 826
 
827 827
 
828 828
 
829 829
 		$main_template_args['total_dtt_rows'] = count($times);
830
-		foreach ( $times as $time ) {
830
+		foreach ($times as $time) {
831 831
 			$dttid = $time->get('DTT_ID');
832 832
 			$dttrow = $time->get('DTT_order');
833 833
 			$existing_datetime_ids[] = $dttid;
834 834
 
835 835
 			//tickets attached
836
-			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array();
836
+			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array();
837 837
 
838 838
 			//if there are no related tickets this is likely a new event OR autodraft
839 839
 			// event so we need to generate the default tickets because dtts
840 840
 			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
841 841
 			// datetime on the event.
842
-			if ( empty ( $related_tickets ) && count( $times ) < 2 ) {
842
+			if (empty ($related_tickets) && count($times) < 2) {
843 843
 				$related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
844 844
 
845 845
 				//this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
846 846
 				$default_prices = EEM_Price::instance()->get_all_default_prices();
847 847
 
848
-				$main_default_ticket = reset( $related_tickets );
849
-				if ( $main_default_ticket instanceof EE_Ticket ) {
850
-					foreach ( $default_prices as $default_price ) {
851
-						if ( $default_price->is_base_price() ) {
848
+				$main_default_ticket = reset($related_tickets);
849
+				if ($main_default_ticket instanceof EE_Ticket) {
850
+					foreach ($default_prices as $default_price) {
851
+						if ($default_price->is_base_price()) {
852 852
 							continue;
853 853
 						}
854
-						$main_default_ticket->cache( 'Price', $default_price );
854
+						$main_default_ticket->cache('Price', $default_price);
855 855
 					}
856 856
 				}
857 857
 			}
@@ -860,11 +860,11 @@  discard block
 block discarded – undo
860 860
 			//we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information.
861 861
 
862 862
 			//loop through and setup the ticket rows and make sure the order is set.
863
-			foreach ( $related_tickets as $ticket ) {
863
+			foreach ($related_tickets as $ticket) {
864 864
 				$tktid = $ticket->get('TKT_ID');
865 865
 				$tktrow = $ticket->get('TKT_row');
866 866
 				//we only want unique tickets in our final display!!
867
-				if ( !in_array( $tktid, $existing_ticket_ids ) ) {
867
+				if ( ! in_array($tktid, $existing_ticket_ids)) {
868 868
 					$existing_ticket_ids[] = $tktid;
869 869
 					$all_tickets[] = $ticket;
870 870
 				}
@@ -873,56 +873,56 @@  discard block
 block discarded – undo
873 873
 				$datetime_tickets[$dttid][] = $tktrow;
874 874
 
875 875
 				//temporary cache of this datetime info for this ticket for later processing of ticket rows.
876
-				if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) )
876
+				if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid]))
877 877
 					$ticket_datetimes[$tktid][] = $dttrow;
878 878
 			}
879 879
 		}
880 880
 
881
-		$main_template_args['total_ticket_rows'] = count( $existing_ticket_ids );
882
-		$main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids );
883
-		$main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids );
881
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
882
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
883
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
884 884
 
885 885
 		//sort $all_tickets by order
886
-		usort( $all_tickets, function( $a, $b ) {
886
+		usort($all_tickets, function($a, $b) {
887 887
 			$a_order = (int) $a->get('TKT_order');
888 888
 			$b_order = (int) $b->get('TKT_order');
889
-			if ( $a_order == $b_order ) {
889
+			if ($a_order == $b_order) {
890 890
 				return 0;
891 891
 			}
892
-			return ( $a_order < $b_order ) ? -1 : 1;
892
+			return ($a_order < $b_order) ? -1 : 1;
893 893
 		});
894 894
 
895 895
 		//k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
896 896
 		$dttrow = 1;
897
-		foreach ( $times as $time ) {
898
-			$main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times );
897
+		foreach ($times as $time) {
898
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times);
899 899
 			$dttrow++;
900 900
 		}
901 901
 
902 902
 		//then loop through all tickets for the ticket rows.
903 903
 		$tktrow = 1;
904
-		foreach ( $all_tickets as $ticket ) {
905
-			$main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets );
904
+		foreach ($all_tickets as $ticket) {
905
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets);
906 906
 			$tktrow++;
907 907
 		}
908 908
 
909 909
 		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
910
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
911
-		EEH_Template::display_template( $template, $main_template_args );
910
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php';
911
+		EEH_Template::display_template($template, $main_template_args);
912 912
 		return;
913 913
 	}
914 914
 
915 915
 
916 916
 
917
-	protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) {
917
+	protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) {
918 918
 
919 919
 		$dtt_display_template_args = array(
920
-			'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ),
921
-			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ),
920
+			'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
921
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default),
922 922
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow
923 923
 			);
924
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
925
-		return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE);
924
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php';
925
+		return EEH_Template::display_template($template, $dtt_display_template_args, TRUE);
926 926
 	}
927 927
 
928 928
 
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 	 *
941 941
 	 * @return string Generated edit row.
942 942
 	 */
943
-	protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) {
943
+	protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) {
944 944
 
945 945
 		// if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true.
946 946
 		$default = ! $dtt instanceof EE_Datetime ? true : false;
@@ -948,30 +948,30 @@  discard block
 block discarded – undo
948 948
 		$template_args = array(
949 949
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
950 950
 			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
951
-			'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
951
+			'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
952 952
 			'DTT_ID' => $default ? '' : $dtt->ID(),
953 953
 			'DTT_name' => $default ? '' : $dtt->name(),
954 954
 			'DTT_description' => $default ? '' : $dtt->description(),
955
-			'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
956
-			'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
957
-			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'),
955
+			'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
956
+			'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
957
+			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
958 958
 			'DTT_order' => $default ? 'DTTNUM' : $dttrow,
959 959
 			'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'),
960
-			'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
961
-			'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0  ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
960
+			'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
961
+			'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
962 962
 			);
963 963
 
964
-		$template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
964
+		$template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
965 965
 
966 966
 		//allow filtering of template args at this point.
967
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event );
967
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
968 968
 
969
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
970
-		return EEH_Template::display_template( $template, $template_args, TRUE );
969
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php';
970
+		return EEH_Template::display_template($template, $template_args, TRUE);
971 971
 	}
972 972
 
973 973
 
974
-	protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) {
974
+	protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) {
975 975
 
976 976
 		$template_args = array(
977 977
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
@@ -979,47 +979,47 @@  discard block
 block discarded – undo
979 979
 			'DTT_description' => $default ? '' : $dtt->description(),
980 980
 			'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '',
981 981
 			'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
982
-			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
982
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
983 983
 			'DTT_ID' => $default ? '' : $dtt->ID()
984 984
 			);
985 985
 
986 986
 		//need to setup the list items (but only if this isnt' a default skeleton setup)
987
-		if ( !$default ) {
987
+		if ( ! $default) {
988 988
 			$tktrow = 1;
989
-			foreach ( $all_tickets as $ticket ) {
990
-				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default );
989
+			foreach ($all_tickets as $ticket) {
990
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default);
991 991
 				$tktrow++;
992 992
 			}
993 993
 		}
994 994
 
995 995
 		//filter template args at this point
996
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event );
996
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
997 997
 
998
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
999
-		return EEH_Template::display_template( $template, $template_args, TRUE );
998
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php';
999
+		return EEH_Template::display_template($template, $template_args, TRUE);
1000 1000
 	}
1001 1001
 
1002 1002
 
1003 1003
 
1004
-	protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) {
1005
-		$tktid = !empty( $ticket ) ? $ticket->ID() : 0;
1006
-		$dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array();
1004
+	protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) {
1005
+		$tktid = ! empty($ticket) ? $ticket->ID() : 0;
1006
+		$dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
1007 1007
 
1008
-		$displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0;
1008
+		$displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
1009 1009
 		$template_args = array(
1010 1010
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
1011
-			'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow,
1011
+			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1012 1012
 			'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1013 1013
 			'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1014
-			'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'),
1015
-			'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1014
+			'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1015
+			'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(),
1016 1016
 			);
1017 1017
 
1018 1018
 		//filter template args
1019
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event );
1019
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1020 1020
 
1021
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1022
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1021
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php';
1022
+		return EEH_Template::display_template($template, $template_args, TRUE);
1023 1023
 	}
1024 1024
 
1025 1025
 
@@ -1041,37 +1041,37 @@  discard block
 block discarded – undo
1041 1041
 	 *
1042 1042
 	 * @return [type] [description]
1043 1043
 	 */
1044
-	protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) {
1044
+	protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) {
1045 1045
 
1046 1046
 		//if $ticket is not an instance of EE_Ticket then force default to true.
1047
-		$default =  ! $ticket instanceof EE_Ticket ? true : false;
1047
+		$default = ! $ticket instanceof EE_Ticket ? true : false;
1048 1048
 
1049
-		$prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array();
1049
+		$prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1050 1050
 
1051 1051
 		//if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on
1052 1052
 		//the object.  This is done by not including any query_params.
1053
-		if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1  || empty( $prices ) ) ) {
1054
-			$prices = $ticket->get_many_related( 'Price' );
1053
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1054
+			$prices = $ticket->get_many_related('Price');
1055 1055
 		}
1056 1056
 
1057 1057
 		// check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1058
-		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE;
1058
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE;
1059 1059
 
1060
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1060
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1061 1061
 
1062 1062
 		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1063 1063
 		$base_price = $default ? NULL :  $ticket->base_price();
1064 1064
 		$count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE);
1065 1065
 
1066 1066
 		//breaking out complicated condition for ticket_status
1067
-		if ( $default ) {
1068
-			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1067
+		if ($default) {
1068
+			$ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1069 1069
 		} else {
1070
-			$ticket_status_class =  $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1070
+			$ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status();
1071 1071
 		}
1072 1072
 
1073 1073
 		//breaking out complicated condition for TKT_taxable
1074
-		if ( $default ) {
1074
+		if ($default) {
1075 1075
 			$TKT_taxable = '';
1076 1076
 		} else {
1077 1077
 			$TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
@@ -1086,19 +1086,19 @@  discard block
 block discarded – undo
1086 1086
 			'edit_tkt_expanded' => '',
1087 1087
 			'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1088 1088
 			'TKT_name' => $default ? '' : $ticket->get('TKT_name'),
1089
-			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
1090
-			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']  ),
1091
-			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1089
+			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1090
+			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1091
+			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1092 1092
 			'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE),
1093 1093
 			'TKT_price_code' => EE_Registry::instance()->CFG->currency->code,
1094 1094
 			'TKT_price_amount' => $default ? 0 : $ticket_subtotal,
1095
-			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'),
1096
-			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'),
1097
-			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'),
1098
-			'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ),
1099
-			'TKT_max' => $default ? '' :  $ticket->get_pretty('TKT_max','input'),
1095
+			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1096
+			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1097
+			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1098
+			'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1099
+			'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1100 1100
 			'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'),
1101
-			'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ),
1101
+			'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))),
1102 1102
 			'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'),
1103 1103
 			'TKT_description' => $default ? '' : $ticket->get('TKT_description'),
1104 1104
 			'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'),
@@ -1107,99 +1107,99 @@  discard block
 block discarded – undo
1107 1107
 			'ticket_price_rows' => '',
1108 1108
 			'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'),
1109 1109
 			'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1110
-			'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"',
1111
-			'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '',
1110
+			'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1111
+			'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1112 1112
 			'total_price_rows' => count($prices) > 1 ? count($prices) : 1,
1113 1113
 			'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '',
1114 1114
 			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1115 1115
 			'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts),
1116
-			'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ),
1116
+			'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)),
1117 1117
 			'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'),
1118 1118
 			'TKT_taxable' => $TKT_taxable,
1119 1119
 			'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1120 1120
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1121
-			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ),
1121
+			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE),
1122 1122
 			'TKT_subtotal_amount' => $ticket_subtotal,
1123
-			'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ),
1123
+			'tax_rows' => $this->_get_tax_rows($tktrow, $ticket),
1124 1124
 			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE,
1125 1125
 			'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1126 1126
 			'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1127 1127
 			'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1128 1128
 			);
1129 1129
 
1130
-		$template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1130
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1131 1131
 
1132 1132
 		//handle rows that should NOT be empty
1133
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1133
+		if (empty($template_args['TKT_start_date'])) {
1134 1134
 			//if empty then the start date will be now.
1135
-			$template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp'));
1136
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1135
+			$template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp'));
1136
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1137 1137
 		}
1138 1138
 
1139
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1139
+		if (empty($template_args['TKT_end_date'])) {
1140 1140
 
1141 1141
 			//get the earliest datetime (if present);
1142
-			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1142
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1143 1143
 
1144
-			if ( !empty( $earliest_dtt ) ) {
1145
-				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
1144
+			if ( ! empty($earliest_dtt)) {
1145
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
1146 1146
 			} else {
1147 1147
 				//default so let's just use what's been set for the default date-time which is 30 days from now.
1148
-				$template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") )  );
1148
+				$template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1149 1149
 			}
1150
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1150
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1151 1151
 		}
1152 1152
 
1153 1153
 		//generate ticket_datetime items
1154
-		if ( ! $default ) {
1154
+		if ( ! $default) {
1155 1155
 			$dttrow = 1;
1156
-			foreach ( $all_dtts as $dtt ) {
1157
-				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default );
1156
+			foreach ($all_dtts as $dtt) {
1157
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default);
1158 1158
 				$dttrow++;
1159 1159
 			}
1160 1160
 		}
1161 1161
 
1162 1162
 		$prcrow = 1;
1163
-		foreach ( $prices as $price ) {
1164
-			if ( $price->is_base_price() ) {
1163
+		foreach ($prices as $price) {
1164
+			if ($price->is_base_price()) {
1165 1165
 				$prcrow++;
1166 1166
 				continue;
1167 1167
 			}
1168
-			$show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1  ? FALSE : TRUE;
1169
-			$show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE;
1170
-			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create );
1168
+			$show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE;
1169
+			$show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE;
1170
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create);
1171 1171
 			$prcrow++;
1172 1172
 		}
1173 1173
 
1174 1174
 		//filter $template_args
1175
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event );
1175
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event);
1176 1176
 
1177
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1178
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1177
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php';
1178
+		return EEH_Template::display_template($template, $template_args, TRUE);
1179 1179
 	}
1180 1180
 
1181 1181
 
1182 1182
 
1183 1183
 
1184 1184
 
1185
-	protected function _get_tax_rows( $tktrow, $ticket ) {
1185
+	protected function _get_tax_rows($tktrow, $ticket) {
1186 1186
 		$tax_rows = '';
1187
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1187
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php';
1188 1188
 		$template_args = array();
1189
-		$taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1190
-		foreach ( $taxes as $tax ) {
1191
-			$tax_added = $this->_get_tax_added( $tax, $ticket );
1189
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1190
+		foreach ($taxes as $tax) {
1191
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1192 1192
 			$template_args = array(
1193
-				'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1193
+				'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1194 1194
 				'tax_id' => $tax->ID(),
1195 1195
 				'tkt_row' => $tktrow,
1196 1196
 				'tax_label' => $tax->get('PRC_name'),
1197 1197
 				'tax_added' => $tax_added,
1198
-				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ),
1198
+				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE),
1199 1199
 				'tax_amount' => $tax->get('PRC_amount')
1200 1200
 				);
1201
-			$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event  );
1202
-			$tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE );
1201
+			$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event);
1202
+			$tax_rows .= EEH_Template::display_template($template, $template_args, TRUE);
1203 1203
 		}
1204 1204
 
1205 1205
 
@@ -1207,81 +1207,81 @@  discard block
 block discarded – undo
1207 1207
 	}
1208 1208
 
1209 1209
 
1210
-	protected function _get_tax_added( EE_Price $tax, $ticket ) {
1211
-		$subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal();
1210
+	protected function _get_tax_added(EE_Price $tax, $ticket) {
1211
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1212 1212
 		return $subtotal * $tax->get('PRC_amount') / 100;
1213 1213
 	}
1214 1214
 
1215 1215
 
1216 1216
 
1217 1217
 
1218
-	protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) {
1219
-		$send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1218
+	protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) {
1219
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1220 1220
 		$template_args = array(
1221 1221
 			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1222 1222
 			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1223 1223
 			'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1224
-			'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ),
1224
+			'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1225 1225
 			'PRC_ID' => $default && empty($price) ? 0 : $price->ID(),
1226 1226
 			'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1227 1227
 			'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'),
1228 1228
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1229 1229
 			'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"',
1230
-			'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1231
-			'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1232
-			'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ),
1233
-			'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1234
-			'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ),
1230
+			'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1231
+			'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1232
+			'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1233
+			'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1234
+			'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1235 1235
 			'show_trash_icon' => $show_trash ? '' : ' style="display:none;"',
1236 1236
 			'show_create_button' => $show_create ? '' : ' style="display:none;"',
1237
-			'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'),
1238
-			'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1237
+			'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'),
1238
+			'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1239 1239
 			);
1240 1240
 
1241
-	$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event );
1241
+	$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event);
1242 1242
 
1243
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1244
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1243
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php';
1244
+		return EEH_Template::display_template($template, $template_args, TRUE);
1245 1245
 	}
1246 1246
 
1247 1247
 
1248
-	protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1249
-		if ( $price->is_base_price() ) {
1250
-			return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default );
1248
+	protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1249
+		if ($price->is_base_price()) {
1250
+			return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1251 1251
 		} else {
1252
-			return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled );
1252
+			return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1253 1253
 		}
1254 1254
 
1255 1255
 	}
1256 1256
 
1257 1257
 
1258
-	protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) {
1258
+	protected function _get_base_price_template($tktrow, $prcrow, $price, $default) {
1259 1259
 		$template_args = array(
1260 1260
 				'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1261
-				'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1262
-				'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'),
1261
+				'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1262
+				'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1263 1263
 				'PRT_name' => __('Price', 'event_espresso'),
1264 1264
 				'price_selected_operator' => '+',
1265 1265
 				'price_selected_is_percent' => 0
1266 1266
 			);
1267
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1267
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php';
1268 1268
 
1269
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event );
1269
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1270 1270
 
1271
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1271
+		return EEH_Template::display_template($template, $template_args, TRUE);
1272 1272
 	}
1273 1273
 
1274 1274
 
1275 1275
 
1276
-	protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1277
-		$select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1278
-		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) );
1279
-		$price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1280
-		$all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array();
1281
-		$selected_price_type_id = $default && empty( $price ) ? 0 : $price->type();
1276
+	protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1277
+		$select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]';
1278
+		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3'))));
1279
+		$price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php';
1280
+		$all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array();
1281
+		$selected_price_type_id = $default && empty($price) ? 0 : $price->type();
1282 1282
 		$price_option_spans = '';
1283 1283
 		//setup pricetypes for selector
1284
-		foreach ( $price_types as $price_type ) {
1284
+		foreach ($price_types as $price_type) {
1285 1285
 			$all_price_types[] = array(
1286 1286
 				'id' => $price_type->ID(),
1287 1287
 				'text' => $price_type->get('PRT_name'),
@@ -1293,50 +1293,50 @@  discard block
 block discarded – undo
1293 1293
 				'PRT_operator' => $price_type->is_discount() ? '-' : '+',
1294 1294
 				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1295 1295
 				);
1296
-			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE );
1296
+			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE);
1297 1297
 		}
1298 1298
 
1299
-		$select_params = $disabled ? 'style="width:auto;" disabled'  : 'style="width:auto;"';
1299
+		$select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1300 1300
 		$main_name = $select_name;
1301
-		$select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1301
+		$select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name;
1302 1302
 
1303 1303
 		$template_args = array(
1304 1304
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1305
-			'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1306
-			'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ),
1305
+			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1306
+			'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1307 1307
 			'main_name' => $main_name,
1308 1308
 			'selected_price_type_id' => $selected_price_type_id,
1309 1309
 			'price_option_spans' => $price_option_spans,
1310
-			'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ),
1311
-			'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ),
1310
+			'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1311
+			'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1312 1312
 			'disabled' => $disabled
1313 1313
 			);
1314 1314
 
1315
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event );
1315
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1316 1316
 
1317
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1317
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php';
1318 1318
 
1319
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1319
+		return EEH_Template::display_template($template, $template_args, TRUE);
1320 1320
 	}
1321 1321
 
1322 1322
 
1323 1323
 
1324
-	protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) {
1325
-		$dttid = !empty($dtt) ? $dtt->ID() : 0;
1326
-		$displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0;
1327
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1324
+	protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) {
1325
+		$dttid = ! empty($dtt) ? $dtt->ID() : 0;
1326
+		$displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0;
1327
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1328 1328
 		$template_args = array(
1329
-			'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow,
1329
+			'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow,
1330 1330
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1331
-			'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '',
1332
-			'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '',
1333
-			'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ),
1331
+			'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '',
1332
+			'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '',
1333
+			'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE),
1334 1334
 			'tkt_status_class' => '',
1335 1335
 			);
1336 1336
 
1337
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event );
1338
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1339
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1337
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1338
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1339
+		return EEH_Template::display_template($template, $template_args, TRUE);
1340 1340
 	}
1341 1341
 
1342 1342
 
@@ -1344,53 +1344,53 @@  discard block
 block discarded – undo
1344 1344
 	protected function _get_ticket_js_structure($all_dtts, $all_tickets) {
1345 1345
 		$template_args = array(
1346 1346
 			'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts),
1347
-			'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE),
1348
-			'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ),
1347
+			'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE),
1348
+			'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL),
1349 1349
 			'default_price_rows' => '',
1350 1350
 			'default_base_price_amount' => 0,
1351 1351
 			'default_base_price_name' => '',
1352 1352
 			'default_base_price_description' => '',
1353
-			'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ),
1354
-			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ),
1353
+			'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE),
1354
+			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE),
1355 1355
 			'existing_available_datetime_tickets_list' => '',
1356 1356
 			'existing_available_ticket_datetimes_list' => '',
1357
-			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ),
1358
-			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE )
1357
+			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE),
1358
+			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE)
1359 1359
 			);
1360 1360
 
1361 1361
 		$tktrow = 1;
1362
-		foreach ( $all_tickets as $ticket ) {
1363
-			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE );
1362
+		foreach ($all_tickets as $ticket) {
1363
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE);
1364 1364
 			$tktrow++;
1365 1365
 		}
1366 1366
 
1367 1367
 
1368 1368
 		$dttrow = 1;
1369
-		foreach ( $all_dtts as $dtt ) {
1370
-			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE );
1369
+		foreach ($all_dtts as $dtt) {
1370
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE);
1371 1371
 			$dttrow++;
1372 1372
 		}
1373 1373
 
1374 1374
 		$default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1375 1375
 		$prcrow = 1;
1376
-		foreach ( $default_prices as $price ) {
1377
-			if ( $price->is_base_price() ) {
1376
+		foreach ($default_prices as $price) {
1377
+			if ($price->is_base_price()) {
1378 1378
 				$template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float');
1379 1379
 				$template_args['default_base_price_name'] = $price->get('PRC_name');
1380 1380
 				$template_args['default_base_price_description'] = $price->get('PRC_desc');
1381 1381
 				$prcrow++;
1382 1382
 				continue;
1383 1383
 			}
1384
-			$show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1  ? FALSE : TRUE;
1385
-			$show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE;
1386
-			$template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create );
1384
+			$show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE;
1385
+			$show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE;
1386
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create);
1387 1387
 			$prcrow++;
1388 1388
 		}
1389 1389
 
1390
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event );
1390
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1391 1391
 
1392
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1393
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1392
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php';
1393
+		return EEH_Template::display_template($template, $template_args, TRUE);
1394 1394
 	}
1395 1395
 
1396 1396
 
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 1 patch
Spacing   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION') )
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION'))
2 2
 	exit('NO direct script access allowed');
3 3
 
4 4
 /**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @access public
74 74
 	 * @return void
75 75
 	 */
76
-	public function __construct( $routing = TRUE ) {
76
+	public function __construct($routing = TRUE) {
77 77
 		//make sure MSG Template helper is loaded.
78 78
 		EE_Registry::instance()->load_helper('MSG_Template');
79 79
 		//make sure messages autoloader is running
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array();
96 96
 
97
-		$this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : NULL;
97
+		$this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : NULL;
98 98
 
99
-		EE_Registry::instance()->load_lib( 'messages' );
99
+		EE_Registry::instance()->load_lib('messages');
100 100
 		//we're also going to set the active messengers and active message types in here.
101 101
 		$this->_active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
102
-		$this->_active_messengers = !empty($this->_active_messengers) ?  $this->_active_messengers : array();
103
-		$this->_active_message_types = !empty($this->_active_messenger) && !empty($this->_active_messengers[$this->_active_messenger]) && ! empty(  $this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger . '-message_types'] ) ? array_keys($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger . '-message_types']) : array();
102
+		$this->_active_messengers = ! empty($this->_active_messengers) ? $this->_active_messengers : array();
103
+		$this->_active_message_types = ! empty($this->_active_messenger) && ! empty($this->_active_messengers[$this->_active_messenger]) && ! empty($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger.'-message_types']) ? array_keys($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger.'-message_types']) : array();
104 104
 
105 105
 
106 106
 		//what about saving the objects in the active_messengers and active_message_types?
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 	 * @return void
119 119
 	 */
120 120
 	protected function _load_active_messenger_objects() {
121
-		foreach ( $this->_active_messengers as $messenger => $values ) {
122
-			$ref = ucwords( str_replace( '_' , ' ', $messenger) );
123
-			$ref = str_replace( ' ', '_', $ref );
124
-			$classname = 'EE_' . $ref . '_messenger';
125
-			require_once( EE_LIBRARIES . 'messages'. DS .'messenger' . DS . $classname . '.class.php' );
126
-			if ( !class_exists($classname) )
127
-				throw new EE_Error( sprintf( __('There is no messenger for the given classname (%s)', 'event_espresso'), $classname ) );
128
-
129
-			$a = new ReflectionClass( $classname );
121
+		foreach ($this->_active_messengers as $messenger => $values) {
122
+			$ref = ucwords(str_replace('_', ' ', $messenger));
123
+			$ref = str_replace(' ', '_', $ref);
124
+			$classname = 'EE_'.$ref.'_messenger';
125
+			require_once(EE_LIBRARIES.'messages'.DS.'messenger'.DS.$classname.'.class.php');
126
+			if ( ! class_exists($classname))
127
+				throw new EE_Error(sprintf(__('There is no messenger for the given classname (%s)', 'event_espresso'), $classname));
128
+
129
+			$a = new ReflectionClass($classname);
130 130
 			$this->_active_messengers[$messenger]['obj'] = $a->newInstance();
131 131
 		}
132 132
 	}
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 	 * @return void
142 142
 	 */
143 143
 	protected function _load_active_message_type_objects() {
144
-		if ( empty($this->_active_message_types) ) return;
145
-		foreach ( $this->_active_message_types as $message_type ) {
146
-			$ref = ucwords( str_replace( '_' , ' ', $message_type) );
147
-			$ref = str_replace( ' ', '_', $ref );
148
-			$classname = 'EE_' . $ref . '_message_type';
144
+		if (empty($this->_active_message_types)) return;
145
+		foreach ($this->_active_message_types as $message_type) {
146
+			$ref = ucwords(str_replace('_', ' ', $message_type));
147
+			$ref = str_replace(' ', '_', $ref);
148
+			$classname = 'EE_'.$ref.'_message_type';
149 149
 
150
-			if ( !class_exists($classname) )
151
-				throw new EE_Error( sprintf( __('There is no message type for the given classname (%s)', 'event_espresso'), $classname ) );
150
+			if ( ! class_exists($classname))
151
+				throw new EE_Error(sprintf(__('There is no message type for the given classname (%s)', 'event_espresso'), $classname));
152 152
 
153
-			$a = new ReflectionClass( $classname );
153
+			$a = new ReflectionClass($classname);
154 154
 			$this->_active_message_types[$message_type]['obj'] = $a->newInstance();
155 155
 		}
156 156
 	}
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 
159 159
 
160 160
 	protected function _ajax_hooks() {
161
-		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) );
162
-		add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') );
163
-		add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') );
164
-		add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) );
165
-		add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) );
161
+		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
162
+		add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
163
+		add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
164
+		add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
165
+		add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
166 166
 	}
167 167
 
168 168
 
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 	*		@return void
195 195
 	*/
196 196
 	protected function _set_page_routes() {
197
-		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
198
-		$grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $grp_id;
197
+		$grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
198
+		$grp_id = empty($grp_id) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $grp_id;
199 199
 
200 200
 		$this->_page_routes = array(
201 201
 				'default'=> array(
@@ -231,35 +231,35 @@  discard block
 block discarded – undo
231 231
 				'insert_message_template' => array(
232 232
 					'func' => '_insert_or_update_message_template',
233 233
 					'capability' => 'ee_edit_messages',
234
-					'args' => array( 'new_template' => TRUE ),
234
+					'args' => array('new_template' => TRUE),
235 235
 					'noheader' => TRUE
236 236
 					 ),
237 237
 				'update_message_template' => array(
238 238
 					'func' => '_insert_or_update_message_template',
239 239
 					'capability' => 'ee_edit_message',
240 240
 					'obj_id' => $grp_id,
241
-					'args' => array( 'new_template' => FALSE ),
241
+					'args' => array('new_template' => FALSE),
242 242
 					'noheader' => TRUE
243 243
 					),
244 244
 				'trash_message_template' => array(
245 245
 					'func' => '_trash_or_restore_message_template',
246 246
 					'capability' => 'ee_delete_message',
247 247
 					'obj_id' => $grp_id,
248
-					'args' => array( 'trash' => TRUE, 'all' => TRUE ),
248
+					'args' => array('trash' => TRUE, 'all' => TRUE),
249 249
 					'noheader' => TRUE
250 250
 					),
251 251
 				'trash_message_template_context' => array(
252 252
 					'func' => '_trash_or_restore_message_template',
253 253
 					'capability' => 'ee_delete_message',
254 254
 					'obj_id' => $grp_id,
255
-					'args' => array( 'trash' => TRUE ),
255
+					'args' => array('trash' => TRUE),
256 256
 					'noheader' => TRUE
257 257
 					),
258 258
 				'restore_message_template' => array(
259 259
 					'func' => '_trash_or_restore_message_template',
260 260
 					'capability' => 'ee_delete_message',
261 261
 					'obj_id' => $grp_id,
262
-					'args' => array( 'trash' => FALSE, 'all' => TRUE ),
262
+					'args' => array('trash' => FALSE, 'all' => TRUE),
263 263
 					'noheader' => TRUE
264 264
 					),
265 265
 				'restore_message_template_context' => array(
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 						'filename' => 'messages_overview_other',
339 339
 					),
340 340
 				),
341
-				'help_tour' => array( 'Messages_Overview_Help_Tour' ),
341
+				'help_tour' => array('Messages_Overview_Help_Tour'),
342 342
 				'require_nonce' => FALSE
343 343
 				),
344 344
 			'custom_mtps' => array(
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 					),
374 374
 				'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'),
375 375
 				'has_metaboxes' => TRUE,
376
-				'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ),
376
+				'help_tour' => array('Message_Templates_Edit_Help_Tour'),
377 377
 				'help_tabs' => array(
378 378
 						'edit_message_template' => array(
379 379
 							'title' => __('Message Template Editor', 'event_espresso'),
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 							'filename' => 'messages_settings_messengers'
430 430
 							),
431 431
                     ),
432
-				'help_tour' => array( 'Messages_Settings_Help_Tour' ),
432
+				'help_tour' => array('Messages_Settings_Help_Tour'),
433 433
 				'require_nonce' => FALSE
434 434
 				)
435 435
 			/*'reports' => array(
@@ -479,43 +479,43 @@  discard block
 block discarded – undo
479 479
 
480 480
 
481 481
 	public function messages_help_tab() {
482
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php';
483
-		EEH_Template::display_template( $templatepath, array());
482
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php';
483
+		EEH_Template::display_template($templatepath, array());
484 484
 	}
485 485
 
486 486
 
487 487
 	public function messengers_help_tab() {
488
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php';
489
-		EEH_Template::display_template( $templatepath, array());
488
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php';
489
+		EEH_Template::display_template($templatepath, array());
490 490
 	}
491 491
 
492 492
 
493 493
 	public function message_types_help_tab() {
494
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php';
495
-		EEH_Template::display_template( $templatepath, array());
494
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php';
495
+		EEH_Template::display_template($templatepath, array());
496 496
 	}
497 497
 
498 498
 
499 499
 	public function messages_overview_help_tab() {
500
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php';
501
-		EEH_Template::display_template( $templatepath, array());
500
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php';
501
+		EEH_Template::display_template($templatepath, array());
502 502
 	}
503 503
 
504 504
 
505 505
 	public function message_templates_help_tab() {
506
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php';
507
-		EEH_Template::display_template( $templatepath, array());
506
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php';
507
+		EEH_Template::display_template($templatepath, array());
508 508
 	}
509 509
 
510 510
 
511 511
 	public function edit_message_template_help_tab() {
512
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php';
513
-		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />';
514
-		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />';
515
-		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />';
516
-		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />';
517
-		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />';
518
-		EEH_Template::display_template( $templatepath, $args);
512
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php';
513
+		$args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />';
514
+		$args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />';
515
+		$args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />';
516
+		$args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />';
517
+		$args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />';
518
+		EEH_Template::display_template($templatepath, $args);
519 519
 	}
520 520
 
521 521
 
@@ -523,25 +523,25 @@  discard block
 block discarded – undo
523 523
 	public function message_template_shortcodes_help_tab() {
524 524
 		$this->_set_shortcodes();
525 525
 		$args['shortcodes'] = $this->_shortcodes;
526
-		$template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php';
527
-		EEH_Template::display_template( $template_path, $args );
526
+		$template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php';
527
+		EEH_Template::display_template($template_path, $args);
528 528
 	}
529 529
 
530 530
 
531 531
 
532 532
 	public function preview_message_help_tab() {
533
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php';
534
-		EEH_Template::display_template( $templatepath, array());
533
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php';
534
+		EEH_Template::display_template($templatepath, array());
535 535
 	}
536 536
 
537 537
 
538 538
 	public function settings_help_tab() {
539
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php';
540
-		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
541
-		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
539
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php';
540
+		$args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />';
541
+		$args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />';
542 542
 		$args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>';
543 543
 		$args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>';
544
-		EEH_Template::display_template( $templatepath, $args);
544
+		EEH_Template::display_template($templatepath, $args);
545 545
 	}
546 546
 
547 547
 
@@ -549,24 +549,24 @@  discard block
 block discarded – undo
549 549
 
550 550
 
551 551
 	public function load_scripts_styles() {
552
-		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION );
552
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
553 553
 		wp_enqueue_style('espresso_ee_msg');
554 554
 
555
-		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE );
555
+		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
556 556
 	}
557 557
 
558 558
 
559 559
 
560 560
 
561 561
 
562
-	public function wp_editor_css( $mce_css ) {
562
+	public function wp_editor_css($mce_css) {
563 563
 		//if we're on the edit_message_template route
564
-		if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger  ) {
564
+		if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
565 565
 			$message_type_name = $this->_active_message_type_name;
566 566
 
567 567
 			//we're going to REPLACE the existing mce css
568 568
 			//we need to get the css file location from the active messenger
569
-			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, TRUE, 'wpeditor', $this->_variation );
569
+			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, TRUE, 'wpeditor', $this->_variation);
570 570
 		}
571 571
 
572 572
 		return $mce_css;
@@ -584,37 +584,37 @@  discard block
 block discarded – undo
584 584
 			$this->_message_template_group->messenger_obj()->label['singular'],
585 585
 			$this->_message_template_group->message_type_obj()->label['singular']
586 586
 		);
587
-		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' );
587
+		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso');
588 588
 
589
-		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION );
589
+		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION);
590 590
 
591 591
 		wp_enqueue_script('ee_admin_js');
592 592
 		wp_enqueue_script('ee_msgs_edit_js');
593 593
 
594 594
 		//add in special css for tiny_mce
595
-		add_filter( 'mce_css', array( $this, 'wp_editor_css' ) );
595
+		add_filter('mce_css', array($this, 'wp_editor_css'));
596 596
 	}
597 597
 
598 598
 
599 599
 
600 600
 	public function load_scripts_styles_display_preview_message() {
601 601
 		$this->_set_message_template_group();
602
-		if ( isset( $this->_req_data['messenger'] ) ) {
602
+		if (isset($this->_req_data['messenger'])) {
603 603
 			$this->_active_messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj'];
604 604
 		}
605 605
 
606
-		$message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : '';
606
+		$message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
607 607
 
608 608
 
609
-		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, TRUE, 'preview', $this->_variation ) );
609
+		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, TRUE, 'preview', $this->_variation));
610 610
 	}
611 611
 
612 612
 
613 613
 
614 614
 	public function load_scripts_styles_settings() {
615
-		wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION );
616
-		wp_enqueue_style( 'ee-text-links' );
617
-		wp_enqueue_style( 'ee-message-settings' );
615
+		wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION);
616
+		wp_enqueue_style('ee-text-links');
617
+		wp_enqueue_style('ee-message-settings');
618 618
 
619 619
 		wp_enqueue_script('ee-messages-settings');
620 620
 	}
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 
651 651
 	protected function _custom_mtps_preview() {
652 652
 		$this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso');
653
-		$this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />';
653
+		$this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />';
654 654
 		$this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso.  With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>';
655
-		$this->display_admin_caf_preview_page( 'custom_message_types', FALSE );
655
+		$this->display_admin_caf_preview_page('custom_message_types', FALSE);
656 656
 	}
657 657
 
658 658
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 	 * @param bool $global whether to return just global (true) or custom templates (false)
675 675
 	 * @return array|WP_Error object
676 676
 	 */
677
-	public function get_message_templates( $perpage = 10, $type = 'in_use', $count = FALSE, $all = FALSE, $global = TRUE ) {
677
+	public function get_message_templates($perpage = 10, $type = 'in_use', $count = FALSE, $all = FALSE, $global = TRUE) {
678 678
 		global $espresso_wp_user;
679 679
 		// start with an empty array
680 680
 		$message_templates = array();
@@ -684,24 +684,24 @@  discard block
 block discarded – undo
684 684
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
685 685
 		$orderby = $this->_req_data['orderby'];
686 686
 
687
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC';
687
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
688 688
 
689
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
690
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage;
689
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
690
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage;
691 691
 
692
-		$offset = ($current_page-1)*$per_page;
693
-		$limit = $all ? NULL : array( $offset, $per_page );
692
+		$offset = ($current_page - 1) * $per_page;
693
+		$limit = $all ? NULL : array($offset, $per_page);
694 694
 
695 695
 
696 696
 		//options will match what is in the _views array property
697
-		switch( $type ) {
697
+		switch ($type) {
698 698
 
699 699
 			case 'in_use':
700
-				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, TRUE );
700
+				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, TRUE);
701 701
 				break;
702 702
 
703 703
 			default:
704
-				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global );
704
+				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
705 705
 
706 706
 		}
707 707
 
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		$imts = $installed_objects['message_types'];
738 738
 		$installed = array();
739 739
 
740
-		foreach ( $imts as $message_type ) {
740
+		foreach ($imts as $message_type) {
741 741
 			$installed[$message_type->name]['obj'] = $message_type;
742 742
 		}
743 743
 
@@ -769,24 +769,24 @@  discard block
 block discarded – undo
769 769
 	 * @access  protected
770 770
 	 * @return void
771 771
 	 */
772
-	protected function _add_message_template(  $message_type = '', $messenger='', $GRP_ID = '' ) {
772
+	protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') {
773 773
 		//set values override any request data
774
-		$message_type = !empty( $message_type ) ? $message_type : '';
775
-		$message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type;
774
+		$message_type = ! empty($message_type) ? $message_type : '';
775
+		$message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type;
776 776
 
777
-		$messenger = !empty( $messenger ) ? $messenger : '';
778
-		$messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger;
777
+		$messenger = ! empty($messenger) ? $messenger : '';
778
+		$messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger;
779 779
 
780
-		$GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : '';
781
-		$GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID;
780
+		$GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
781
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
782 782
 
783 783
 		//we need messenger and message type.  They should be coming from the event editor. If not here then return error
784
-		if ( empty( $message_type ) || empty( $messenger )  )
784
+		if (empty($message_type) || empty($messenger))
785 785
 			throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));
786 786
 
787 787
 		//we need the GRP_ID for the template being used as the base for the new template
788
-		if ( empty( $GRP_ID ) )
789
-			throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );
788
+		if (empty($GRP_ID))
789
+			throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso'));
790 790
 
791 791
 		//let's just make sure the template gets generated!
792 792
 
@@ -805,8 +805,8 @@  discard block
 block discarded – undo
805 805
 	 * @param string $messenger    messenger slug
806 806
 	 * @param int      $GRP_ID         GRP_ID for the related message template group this new template will be based off of.
807 807
 	 */
808
-	public function add_message_template( $message_type, $messenger, $GRP_ID ) {
809
-		$this->_add_message_template( $message_type, $messenger, $GRP_ID );
808
+	public function add_message_template($message_type, $messenger, $GRP_ID) {
809
+		$this->_add_message_template($message_type, $messenger, $GRP_ID);
810 810
 	}
811 811
 
812 812
 
@@ -817,36 +817,36 @@  discard block
 block discarded – undo
817 817
 	 * @return void
818 818
 	 */
819 819
 	protected function _edit_message_template() {
820
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '');
820
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
821 821
 
822 822
 		//we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates.
823
-		add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 );
823
+		add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
824 824
 
825
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE;
825
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE;
826 826
 
827 827
 		$this->_set_shortcodes(); //this also sets the _message_template property.
828 828
 		$message_template_group = $this->_message_template_group;
829 829
 		$c_label = $message_template_group->context_label();
830 830
 		$c_config = $message_template_group->contexts_config();
831 831
 
832
-		reset( $c_config );
833
-		$context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) ? strtolower($this->_req_data['context']) : key($c_config);
832
+		reset($c_config);
833
+		$context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) ? strtolower($this->_req_data['context']) : key($c_config);
834 834
 
835 835
 
836
-		if ( empty($GRP_ID) ) {
836
+		if (empty($GRP_ID)) {
837 837
 			$action = 'insert_message_template';
838 838
 			$button_both = FALSE;
839
-			$button_text = array( __( 'Save','event_espresso') );
839
+			$button_text = array(__('Save', 'event_espresso'));
840 840
 			$button_actions = array('something_different');
841 841
 			$referrer = FALSE;
842
-			$edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
842
+			$edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => TRUE), EE_MSG_ADMIN_URL);
843 843
 		} else {
844 844
 			$action = 'update_message_template';
845 845
 			$button_both = TRUE;
846 846
 			$button_text = array();
847 847
 			$button_actions = array();
848 848
 			$referrer = $this->_admin_base_url;
849
-			$edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
849
+			$edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => TRUE), EE_MSG_ADMIN_URL);
850 850
 		}
851 851
 
852 852
 		//set active messenger for this view
@@ -856,13 +856,13 @@  discard block
 block discarded – undo
856 856
 
857 857
 		//Do we have any validation errors?
858 858
 		$validators = $this->_get_transient();
859
-		$v_fields = !empty($validators) ? array_keys($validators) : array();
859
+		$v_fields = ! empty($validators) ? array_keys($validators) : array();
860 860
 
861 861
 
862 862
 		//we need to assemble the title from Various details
863
-		$context_label = sprintf( __('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'] ));
863
+		$context_label = sprintf(__('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label']));
864 864
 
865
-		$title = sprintf( __(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label );
865
+		$title = sprintf(__(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label);
866 866
 
867 867
 		$this->_template_args['GRP_ID'] = $GRP_ID;
868 868
 		$this->_template_args['message_template'] = $message_template_group;
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 		$MSG = new EE_messages();
874 874
 		$template_field_structure = $MSG->get_fields($message_template_group->messenger(), $message_template_group->message_type());
875 875
 
876
-		if ( !$template_field_structure ) {
876
+		if ( ! $template_field_structure) {
877 877
 			$template_field_structure = FALSE;
878 878
 			$template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso');
879 879
 		}
@@ -883,38 +883,38 @@  discard block
 block discarded – undo
883 883
 
884 884
 
885 885
 		//if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array.
886
-		if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) {
887
-			foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) {
888
-				unset( $template_field_structure[$context][$reference_field] );
886
+		if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
887
+			foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
888
+				unset($template_field_structure[$context][$reference_field]);
889 889
 			}
890 890
 		}
891 891
 
892 892
 		//let's loop through the template_field_structure and actually assemble the input fields!
893
-		if ( !empty($template_field_structure) ) {
894
-			$id_prefix= 'ee-msg-edit-template-fields-';
895
-			foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) {
893
+		if ( ! empty($template_field_structure)) {
894
+			$id_prefix = 'ee-msg-edit-template-fields-';
895
+			foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
896 896
 				//if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them.
897
-				if ( $template_field == 'extra' ) {
897
+				if ($template_field == 'extra') {
898 898
 					$this->_template_args['is_extra_fields'] = TRUE;
899
-					foreach ( $field_setup_array as $reference_field => $new_fields_array ) {
900
-						foreach ( $new_fields_array as $extra_field =>  $extra_array ) {
899
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
900
+						foreach ($new_fields_array as $extra_field =>  $extra_array) {
901 901
 							//let's verify if we need this extra field via the shortcodes parameter.
902 902
 							$continue = FALSE;
903
-							if ( isset( $extra_array['shortcodes_required'] ) ) {
904
-								foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) {
905
-									if ( !array_key_exists( $shortcode, $this->_shortcodes ) )
903
+							if (isset($extra_array['shortcodes_required'])) {
904
+								foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
905
+									if ( ! array_key_exists($shortcode, $this->_shortcodes))
906 906
 										$continue = TRUE;
907 907
 								}
908
-								if ( $continue ) continue;
908
+								if ($continue) continue;
909 909
 							}
910 910
 
911
-							$field_id = $reference_field . '-' . $extra_field . '-content';
911
+							$field_id = $reference_field.'-'.$extra_field.'-content';
912 912
 							$template_form_fields[$field_id] = $extra_array;
913
-							$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']';
914
-							$css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : '';
915
-							$template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array($extra_field, $v_fields) && ( is_array($validators[$extra_field] ) && isset( $validators[$extra_field]['msg'] ) ) ? 'validate-error ' . $css_class : $css_class;
913
+							$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']';
914
+							$css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : '';
915
+							$template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($extra_field, $v_fields) && (is_array($validators[$extra_field]) && isset($validators[$extra_field]['msg'])) ? 'validate-error '.$css_class : $css_class;
916 916
 							$content = $message_templates[$context][$reference_field]->get('MTP_content');
917
-							$template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) : '';
917
+							$template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) : '';
918 918
 
919 919
 							//do we have a validation error?  if we do then let's use that value instead
920 920
 							$template_form_fields[$field_id]['value'] = isset($validators[$extra_field]) ? $validators[$extra_field]['value'] : $template_form_fields[$field_id]['value'];
@@ -924,32 +924,32 @@  discard block
 block discarded – undo
924 924
 
925 925
 							//shortcode selector
926 926
 							$field_name_to_use = $extra_field == 'main' ? 'content' : $extra_field;
927
-							$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $field_name_to_use, $field_id );
927
+							$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($field_name_to_use, $field_id);
928 928
 
929
-							if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) {
929
+							if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') {
930 930
 								//we want to decode the entities
931
-								$template_form_fields[$field_id]['value'] = stripslashes( html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") );
931
+								$template_form_fields[$field_id]['value'] = stripslashes(html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8"));
932 932
 
933 933
 							}/**/
934 934
 						}
935
-						$templatefield_MTP_id = $reference_field . '-MTP_ID';
936
-						$templatefield_templatename_id = $reference_field . '-name';
935
+						$templatefield_MTP_id = $reference_field.'-MTP_ID';
936
+						$templatefield_templatename_id = $reference_field.'-name';
937 937
 
938 938
 						$template_form_fields[$templatefield_MTP_id] = array(
939
-							'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
939
+							'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]',
940 940
 							'label' => NULL,
941 941
 							'input' => 'hidden',
942 942
 							'type' => 'int',
943 943
 							'required' => FALSE,
944 944
 							'validation' => FALSE,
945
-							'value' => !empty($message_templates) ? $message_templates[$context][$reference_field]->ID() : '',
945
+							'value' => ! empty($message_templates) ? $message_templates[$context][$reference_field]->ID() : '',
946 946
 							'css_class' => '',
947 947
 							'format' => '%d',
948 948
 							'db-col' => 'MTP_ID'
949 949
 						);
950 950
 
951 951
 						$template_form_fields[$templatefield_templatename_id] = array(
952
-							'name' => 'MTP_template_fields[' . $reference_field . '][name]',
952
+							'name' => 'MTP_template_fields['.$reference_field.'][name]',
953 953
 							'label' => NULL,
954 954
 							'input' => 'hidden',
955 955
 							'type' => 'string',
@@ -963,10 +963,10 @@  discard block
 block discarded – undo
963 963
 					}
964 964
 					continue; //skip the next stuff, we got the necessary fields here for this dataset.
965 965
 				} else {
966
-					$field_id = $template_field . '-content';
966
+					$field_id = $template_field.'-content';
967 967
 					$template_form_fields[$field_id] = $field_setup_array;
968
-					$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]';
969
-					$template_form_fields[$field_id]['value'] = !empty($message_templates) && is_array($message_templates[$context]) && isset($message_templates[$context][$template_field]) ?$message_templates[$context][$template_field]->get('MTP_content') : '';
968
+					$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]';
969
+					$template_form_fields[$field_id]['value'] = ! empty($message_templates) && is_array($message_templates[$context]) && isset($message_templates[$context][$template_field]) ? $message_templates[$context][$template_field]->get('MTP_content') : '';
970 970
 
971 971
 					//do we have a validator error for this field?  if we do then we'll use that value instead
972 972
 					$template_form_fields[$field_id]['value'] = isset($validators[$template_field]) ? $validators[$template_field]['value'] : $template_form_fields[$field_id]['value'];
@@ -974,12 +974,12 @@  discard block
 block discarded – undo
974 974
 
975 975
 					$template_form_fields[$field_id]['db-col'] = 'MTP_content';
976 976
 					$css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : '';
977
-					$template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array( $template_field, $v_fields ) && isset( $validators[$template_field]['msg'] ) ? 'validate-error ' . $css_class : $css_class;
977
+					$template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($template_field, $v_fields) && isset($validators[$template_field]['msg']) ? 'validate-error '.$css_class : $css_class;
978 978
 
979 979
 					//shortcode selector
980
-					$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $template_field, $field_id );
980
+					$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($template_field, $field_id);
981 981
 
982
-					if ( isset( $field_setup_array['input'] ) && $field_setup_array['input'] == 'wp_editor' ) {
982
+					if (isset($field_setup_array['input']) && $field_setup_array['input'] == 'wp_editor') {
983 983
 						//we want to decode the entities
984 984
 						$template_form_fields[$field_id]['value'] = $template_form_fields[$field_id]['value'];
985 985
 					}/**/
@@ -987,25 +987,25 @@  discard block
 block discarded – undo
987 987
 
988 988
 				//k took care of content field(s) now let's take care of others.
989 989
 
990
-				$templatefield_MTP_id = $template_field . '-MTP_ID';
991
-				$templatefield_field_templatename_id = $template_field . '-name';
990
+				$templatefield_MTP_id = $template_field.'-MTP_ID';
991
+				$templatefield_field_templatename_id = $template_field.'-name';
992 992
 
993 993
 				//foreach template field there are actually two form fields created
994 994
 				$template_form_fields[$templatefield_MTP_id] = array(
995
-					'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
995
+					'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]',
996 996
 					'label' => NULL,
997 997
 					'input' => 'hidden',
998 998
 					'type' => 'int',
999 999
 					'required' => FALSE,
1000 1000
 					'validation' => TRUE,
1001
-					'value' => !empty($message_templates) ? $message_templates[$context][$template_field]->ID() : '',
1001
+					'value' => ! empty($message_templates) ? $message_templates[$context][$template_field]->ID() : '',
1002 1002
 					'css_class' => '',
1003 1003
 					'format' => '%d',
1004 1004
 					'db-col' => 'MTP_ID'
1005 1005
 				);
1006 1006
 
1007 1007
 				$template_form_fields[$templatefield_field_templatename_id] = array(
1008
-					'name' => 'MTP_template_fields[' . $template_field . '][name]',
1008
+					'name' => 'MTP_template_fields['.$template_field.'][name]',
1009 1009
 					'label' => NULL,
1010 1010
 					'input' => 'hidden',
1011 1011
 					'type' => 'string',
@@ -1149,15 +1149,15 @@  discard block
 block discarded – undo
1149 1149
 				'value' => $GRP_ID
1150 1150
 				);
1151 1151
 			$sidebar_form_fields['ee-msg-evt-nonce'] = array(
1152
-				'name' => $action . '_nonce',
1152
+				'name' => $action.'_nonce',
1153 1153
 				'input' => 'hidden',
1154 1154
 				'type' => 'string',
1155
-				'value' => wp_create_nonce( $action . '_nonce')
1155
+				'value' => wp_create_nonce($action.'_nonce')
1156 1156
 				);
1157 1157
 
1158 1158
 			$sidebar_array = array('ee-msg-is-global', 'ee-msg-is-override', 'ee-msg-deleted', 'ee-msg-is-active');
1159 1159
 
1160
-			if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) {
1160
+			if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1161 1161
 				$sidebar_form_fields['ee-msg-template-switch'] = array(
1162 1162
 					'name' => 'template_switch',
1163 1163
 					'input' => 'hidden',
@@ -1167,19 +1167,19 @@  discard block
 block discarded – undo
1167 1167
 			}
1168 1168
 
1169 1169
 
1170
-			$template_fields = $this->_generate_admin_form_fields( $template_form_fields );
1171
-			$sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields );
1170
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1171
+			$sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields);
1172 1172
 
1173 1173
 
1174 1174
 		} //end if ( !empty($template_field_structure) )
1175 1175
 
1176 1176
 		//set extra content for publish box
1177 1177
 		$this->_template_args['publish_box_extra_content'] = $sidebar_fields;
1178
-		$this->_set_publish_post_box_vars( 'id', $GRP_ID );
1178
+		$this->_set_publish_post_box_vars('id', $GRP_ID);
1179 1179
 
1180 1180
 		//add preview button
1181
-		$preview_url = parent::add_query_args_and_nonce( array( 'message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context,'GRP_ID' => $GRP_ID, 'action' => 'preview_message' ), $this->_admin_base_url );
1182
-		$preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>';
1181
+		$preview_url = parent::add_query_args_and_nonce(array('message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context, 'GRP_ID' => $GRP_ID, 'action' => 'preview_message'), $this->_admin_base_url);
1182
+		$preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>';
1183 1183
 
1184 1184
 
1185 1185
 		//setup context switcher
@@ -1206,16 +1206,16 @@  discard block
 block discarded – undo
1206 1206
 		$this->_template_args['before_admin_page_content'] .= $this->_add_form_element_before();
1207 1207
 		$this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1208 1208
 
1209
-		$this->_template_path = $this->_template_args['GRP_ID'] ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1209
+		$this->_template_path = $this->_template_args['GRP_ID'] ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php';
1210 1210
 
1211 1211
 		//send along EE_Message_Template_Group object for further template use.
1212 1212
 		$this->_template_args['MTP'] = $message_template_group;
1213 1213
 
1214
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, TRUE );
1214
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE);
1215 1215
 
1216 1216
 
1217 1217
 		//finally, let's set the admin_page title
1218
-		$this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title );
1218
+		$this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1219 1219
 
1220 1220
 
1221 1221
 		//we need to take care of setting the shortcodes property for use elsewhere.
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 	}
1229 1229
 
1230 1230
 
1231
-	public function filter_tinymce_init( $mceInit, $editor_id ) {
1231
+	public function filter_tinymce_init($mceInit, $editor_id) {
1232 1232
 		return $mceInit;
1233 1233
 	}
1234 1234
 
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 	}
1240 1240
 
1241 1241
 	public function _add_form_element_before() {
1242
-		return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">';
1242
+		return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">';
1243 1243
 	}
1244 1244
 
1245 1245
 	public function _add_form_element_after() {
@@ -1257,32 +1257,32 @@  discard block
 block discarded – undo
1257 1257
 	 * @return json json object
1258 1258
 	 */
1259 1259
 	public function switch_template_pack() {
1260
-		$GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1261
-		$template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : '';
1260
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1261
+		$template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1262 1262
 
1263 1263
 		//verify we have needed values.
1264
-		if ( empty( $GRP_ID ) || empty( $template_pack ) ) {
1264
+		if (empty($GRP_ID) || empty($template_pack)) {
1265 1265
 			$this->_template_args['error'] = TRUE;
1266
-			EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__  );
1266
+			EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1267 1267
 		} else {
1268 1268
 			//get template, set the new template_pack and then reset to default
1269
-			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1269
+			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1270 1270
 
1271
-			$mtpg->set_template_pack_name( $template_pack );
1271
+			$mtpg->set_template_pack_name($template_pack);
1272 1272
 			$this->_req_data['msgr'] = $mtpg->messenger();
1273 1273
 			$this->_req_data['mt'] = $mtpg->message_type();
1274 1274
 
1275 1275
 			$query_args = $this->_reset_to_default_template();
1276 1276
 
1277
-			if ( empty( $query_args['id'] ) ) {
1278
-				EE_Error::add_error( __('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1277
+			if (empty($query_args['id'])) {
1278
+				EE_Error::add_error(__('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1279 1279
 				$this->_template_args['error'] = TRUE;
1280 1280
 			} else {
1281
-				$template_label =$mtpg->get_template_pack()->label;
1281
+				$template_label = $mtpg->get_template_pack()->label;
1282 1282
 				$template_pack_labels = $mtpg->messenger_obj()->get_supports_labels();
1283
-				EE_Error::add_success( sprintf( __('This message template has been successfully switched to use the %s %s.  Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack ) );
1283
+				EE_Error::add_success(sprintf(__('This message template has been successfully switched to use the %s %s.  Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack));
1284 1284
 				//generate the redirect url for js.
1285
-				$url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1285
+				$url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1286 1286
 				$this->_template_args['data']['redirect_url'] = $url;
1287 1287
 				$this->_template_args['success'] = true;
1288 1288
 			}
@@ -1303,56 +1303,56 @@  discard block
 block discarded – undo
1303 1303
 	protected function _reset_to_default_template() {
1304 1304
 		$success = TRUE;
1305 1305
 		$templates = array();
1306
-		$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1306
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1307 1307
 		//we need to make sure we've got the info we need.
1308
-		if ( !isset( $this->_req_data['msgr'] ) && !isset( $this->_req_data['mt'] ) && !isset( $this->_req_data['GRP_ID'] ) ) {
1309
-			EE_Error::add_error( __('In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1308
+		if ( ! isset($this->_req_data['msgr']) && ! isset($this->_req_data['mt']) && ! isset($this->_req_data['GRP_ID'])) {
1309
+			EE_Error::add_error(__('In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1310 1310
 			$success = FALSE;
1311 1311
 		}
1312 1312
 
1313 1313
 		//all templates will be reset to whatever the defaults are for the global template matching the messenger and message type.
1314
-		$success = !empty( $GRP_ID ) ? TRUE : FALSE;
1314
+		$success = ! empty($GRP_ID) ? TRUE : FALSE;
1315 1315
 
1316
-		if ( $success ) {
1316
+		if ($success) {
1317 1317
 
1318 1318
 			//let's first determine if the incoming template is a global template, if it isn't then we need to get the global template matching messenger and message type.
1319
-			$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1319
+			$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1320 1320
 
1321 1321
 
1322 1322
 			//note this is ONLY deleteing the template fields (Message Template rows) NOT the message template group.
1323
-			$success = $this->_delete_mtp_permanently( $GRP_ID, FALSE );
1323
+			$success = $this->_delete_mtp_permanently($GRP_ID, FALSE);
1324 1324
 
1325
-			if ( $success ) {
1325
+			if ($success) {
1326 1326
 				//if successfully deleted, lets generate the new ones.  Note. We set GLOBAL to true, because resets on ANY template will use the related global template defaults for regeneration.  This means that if a custom template is reset it resets to whatever the related global template is.  HOWEVER, we DO keep the template pack and template variation set for the current custom template when resetting.
1327
-				$templates = $this->_generate_new_templates( $this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, TRUE );
1327
+				$templates = $this->_generate_new_templates($this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, TRUE);
1328 1328
 			}
1329 1329
 
1330 1330
 		}
1331 1331
 
1332 1332
 		//any error messages?
1333
-		if ( !$success ) {
1334
-			EE_Error::add_error( __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1333
+		if ( ! $success) {
1334
+			EE_Error::add_error(__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1335 1335
 		}
1336 1336
 
1337 1337
 		//all good, let's add a success message!
1338
-		if ( $success && ! empty( $templates ) ) {
1338
+		if ($success && ! empty($templates)) {
1339 1339
 			$templates = $templates[0]; //the info for the template we generated is the first element in the returned array.
1340 1340
 			EE_Error::overwrite_success();
1341
-			EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') );
1341
+			EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
1342 1342
 		}
1343 1343
 
1344 1344
 
1345 1345
 		$query_args = array(
1346
-			'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : NULL,
1347
-			'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : NULL,
1348
-			'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'default'
1346
+			'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : NULL,
1347
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : NULL,
1348
+			'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'default'
1349 1349
 			);
1350 1350
 
1351 1351
 		//if called via ajax then we return query args otherwise redirect
1352
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1352
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1353 1353
 			return $query_args;
1354 1354
 		} else {
1355
-			$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
1355
+			$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
1356 1356
 		}
1357 1357
 
1358 1358
 	}
@@ -1365,20 +1365,20 @@  discard block
 block discarded – undo
1365 1365
 	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
1366 1366
 	 * @return void
1367 1367
 	 */
1368
-	public function _preview_message( $send = FALSE ) {
1368
+	public function _preview_message($send = FALSE) {
1369 1369
 		//first make sure we've got the necessary parameters
1370
-		if ( !isset( $this->_req_data['message_type'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['GRP_ID'] ) ) {
1371
-			EE_Error::add_error( __('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1370
+		if ( ! isset($this->_req_data['message_type']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['GRP_ID'])) {
1371
+			EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1372 1372
 		}
1373 1373
 
1374
-		EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] );
1374
+		EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
1375 1375
 
1376 1376
 		$MSG = new EE_messages();
1377 1377
 
1378 1378
 		//get the preview!
1379
-		$preview = $MSG->preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send );
1379
+		$preview = $MSG->preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send);
1380 1380
 
1381
-		if ( $send ) {
1381
+		if ($send) {
1382 1382
 			return $preview;
1383 1383
 		}
1384 1384
 
@@ -1388,16 +1388,16 @@  discard block
 block discarded – undo
1388 1388
 			'context' => $this->_req_data['context'],
1389 1389
 			'action' => 'edit_message_template'
1390 1390
 			);
1391
-		$go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1392
-		$preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>';
1391
+		$go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1392
+		$preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>';
1393 1393
 
1394 1394
 		//let's provide a helpful title for context
1395
-		$preview_title = sprintf( __('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular']) );
1395
+		$preview_title = sprintf(__('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular']));
1396 1396
 
1397 1397
 
1398 1398
 		//setup display of preview.
1399 1399
 		$this->_admin_page_title = $preview_title;
1400
-		$this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview);
1400
+		$this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview);
1401 1401
 		$this->_template_args['data']['force_json'] = TRUE;
1402 1402
 	}
1403 1403
 
@@ -1425,9 +1425,9 @@  discard block
 block discarded – undo
1425 1425
 	 * @return void
1426 1426
 	 */
1427 1427
 	protected function _register_edit_meta_boxes() {
1428
-		add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' );
1429
-		add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1430
-		add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1428
+		add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default');
1429
+		add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high');
1430
+		add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high');
1431 1431
 	}
1432 1432
 
1433 1433
 
@@ -1448,10 +1448,10 @@  discard block
 block discarded – undo
1448 1448
 
1449 1449
 		$tp_select_values = array();
1450 1450
 
1451
-		foreach ( $template_packs as $tp ) {
1451
+		foreach ($template_packs as $tp) {
1452 1452
 			//only include template packs that support this messenger and message type!
1453 1453
 			$supports = $tp->get_supports();
1454
-			if ( ! isset( $supports[$this->_message_template_group->messenger()] ) || ! in_array( $this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()] ) ) {
1454
+			if ( ! isset($supports[$this->_message_template_group->messenger()]) || ! in_array($this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()])) {
1455 1455
 				//not supported
1456 1456
 				continue;
1457 1457
 			}
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 		}
1464 1464
 
1465 1465
 		//if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack.  This still allows for the odd template pack to override.
1466
-		if ( empty( $tp_select_values ) ) {
1466
+		if (empty($tp_select_values)) {
1467 1467
 			$tp_select_values[] = array(
1468 1468
 				'text' => __('Default', 'event_espresso'),
1469 1469
 				'id' => 'default'
@@ -1471,27 +1471,27 @@  discard block
 block discarded – undo
1471 1471
 		}
1472 1472
 
1473 1473
 		//setup variation select values for the currently selected template.
1474
-		$variations = $this->_message_template_group->get_template_pack()->get_variations( $this->_message_template_group->messenger(), $this->_message_template_group->message_type() );
1474
+		$variations = $this->_message_template_group->get_template_pack()->get_variations($this->_message_template_group->messenger(), $this->_message_template_group->message_type());
1475 1475
 		$variations_select_values = array();
1476
-		foreach ( $variations as $variation => $label ) {
1476
+		foreach ($variations as $variation => $label) {
1477 1477
 			$variations_select_values[] = array(
1478 1478
 				'text' => $label,
1479 1479
 				'id' => $variation
1480 1480
 				);
1481 1481
 		}
1482 1482
 
1483
-		$template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels();
1483
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
1484 1484
 
1485
-		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input( 'MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name() );
1486
-		$template_args['variations_selector'] = EEH_Form_Fields::select_input( 'MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation() );
1485
+		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input('MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name());
1486
+		$template_args['variations_selector'] = EEH_Form_Fields::select_input('MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation());
1487 1487
 		$template_args['template_pack_label'] = $template_pack_labels->template_pack;
1488 1488
 		$template_args['template_variation_label'] = $template_pack_labels->template_variation;
1489 1489
 		$template_args['template_pack_description'] = $template_pack_labels->template_pack_description;
1490 1490
 		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
1491 1491
 
1492
-		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
1492
+		$template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php';
1493 1493
 
1494
-		EEH_Template::display_template( $template, $template_args );
1494
+		EEH_Template::display_template($template, $template_args);
1495 1495
 	}
1496 1496
 
1497 1497
 
@@ -1512,52 +1512,52 @@  discard block
 block discarded – undo
1512 1512
 			'GRP_ID' => $this->_message_template_group->GRP_ID()
1513 1513
 			);
1514 1514
 
1515
-		$button = $this->get_action_link_or_button( 'reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button' );
1515
+		$button = $this->get_action_link_or_button('reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button');
1516 1516
 
1517 1517
 
1518 1518
 		//test button
1519 1519
 		//first we need to see if there are any fields
1520 1520
 		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
1521 1521
 
1522
-		if ( !empty( $fields ) ) {
1522
+		if ( ! empty($fields)) {
1523 1523
 			//yup there be fields
1524
-			foreach ( $fields as $field => $config ) {
1525
-				$field_id = $this->_message_template_group->messenger() . '_' . $field;
1524
+			foreach ($fields as $field => $config) {
1525
+				$field_id = $this->_message_template_group->messenger().'_'.$field;
1526 1526
 				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
1527
-				$default = isset( $config['default'] ) ? $config['default'] : '';
1528
-				$default = isset( $config['value'] ) ? $config['value'] : $default;
1527
+				$default = isset($config['default']) ? $config['default'] : '';
1528
+				$default = isset($config['value']) ? $config['value'] : $default;
1529 1529
 
1530 1530
 				//if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults
1531 1531
 				$fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : '';
1532
-				$existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix;
1532
+				$existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix;
1533 1533
 
1534 1534
 				$template_form_fields[$field_id] = array(
1535
-					'name' => 'test_settings_fld[' . $field . ']',
1535
+					'name' => 'test_settings_fld['.$field.']',
1536 1536
 					'label' => $config['label'],
1537 1537
 					'input' => $config['input'],
1538 1538
 					'type' => $config['type'],
1539 1539
 					'required' => $config['required'],
1540 1540
 					'validation' => $config['validation'],
1541
-					'value' => isset( $existing[$field] ) ? $existing[$field] : $default,
1541
+					'value' => isset($existing[$field]) ? $existing[$field] : $default,
1542 1542
 					'css_class' => $config['css_class'],
1543
-					'options' => isset( $config['options'] ) ? $config['options'] : array(),
1543
+					'options' => isset($config['options']) ? $config['options'] : array(),
1544 1544
 					'default' => $default,
1545 1545
 					'format' => $config['format']
1546 1546
 					);
1547 1547
 			}
1548 1548
 		}
1549 1549
 
1550
-		$test_settings_fields = !empty( $template_form_fields) ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) : '';
1550
+		$test_settings_fields = ! empty($template_form_fields) ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') : '';
1551 1551
 
1552 1552
 		$test_settings_html = '';
1553 1553
 		//print out $test_settings_fields
1554
-		if ( !empty( $test_settings_fields ) ) {
1554
+		if ( ! empty($test_settings_fields)) {
1555 1555
 			echo $test_settings_fields;
1556
-			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="' . __('Test Send', 'event_espresso') . '" /><div style="clear:both"></div>';
1556
+			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="'.__('Test Send', 'event_espresso').'" /><div style="clear:both"></div>';
1557 1557
 		}
1558 1558
 
1559 1559
 		//and button
1560
-		echo $test_settings_html . '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>' . '<div class="publishing-action alignright resetbutton">' . $button . '</div><div style="clear:both"></div>';
1560
+		echo $test_settings_html.'<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'.'<div class="publishing-action alignright resetbutton">'.$button.'</div><div style="clear:both"></div>';
1561 1561
 	}
1562 1562
 
1563 1563
 
@@ -1572,13 +1572,13 @@  discard block
 block discarded – undo
1572 1572
      * @param string $linked_input_id The css id of the input that the shortcodes get added to.
1573 1573
      * @return string
1574 1574
     */
1575
-	protected function _get_shortcode_selector( $field, $linked_input_id ) {
1575
+	protected function _get_shortcode_selector($field, $linked_input_id) {
1576 1576
 		$template_args = array(
1577
-			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
1577
+			'shortcodes' => $this->_get_shortcodes(array($field), true),
1578 1578
 			'fieldname' => $field,
1579 1579
 			'linked_input_id' => $linked_input_id
1580 1580
 		);
1581
-		return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true );
1581
+		return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true);
1582 1582
 	}
1583 1583
 
1584 1584
 
@@ -1592,13 +1592,13 @@  discard block
 block discarded – undo
1592 1592
 		$shortcodes = $this->_get_shortcodes(array(), FALSE); //just make sure shortcodes property is set
1593 1593
 		$messenger = $this->_message_template_group->messenger_obj();
1594 1594
 		//now let's set the content depending on the status of the shortcodes array
1595
-		if ( empty( $shortcodes ) ) {
1596
-			$content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>';
1595
+		if (empty($shortcodes)) {
1596
+			$content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>';
1597 1597
 			echo $content;
1598 1598
 		} else {
1599 1599
 			$alt = 0;
1600 1600
 			?>
1601
-			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p>
1601
+			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p>
1602 1602
 			<?php
1603 1603
 		}
1604 1604
 
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
 	protected function _set_shortcodes() {
1616 1616
 
1617 1617
 		//no need to run this if the property is already set
1618
-		if ( !empty($this->_shortcodes ) ) return;
1618
+		if ( ! empty($this->_shortcodes)) return;
1619 1619
 
1620 1620
 		$this->_shortcodes = $this->_get_shortcodes();
1621 1621
 	}
@@ -1632,14 +1632,14 @@  discard block
 block discarded – undo
1632 1632
 	 * @param  boolean $merged Whether to merge all the shortcodes into one list of unique shortcodes
1633 1633
 	 * @return array          Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true just an array of shortcode/label pairs.
1634 1634
 	 */
1635
-	protected function _get_shortcodes( $fields = array(), $merged = TRUE ) {
1635
+	protected function _get_shortcodes($fields = array(), $merged = TRUE) {
1636 1636
 		$this->_set_message_template_group();
1637 1637
 
1638 1638
 		//we need the messenger and message template to retrieve the valid shortcodes array.
1639
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE;
1640
-		$context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() );
1639
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE;
1640
+		$context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config());
1641 1641
 
1642
-		return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array();
1642
+		return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
1643 1643
 	}
1644 1644
 
1645 1645
 
@@ -1652,19 +1652,19 @@  discard block
 block discarded – undo
1652 1652
 	 */
1653 1653
 	protected function _set_message_template_group() {
1654 1654
 
1655
-		if ( !empty( $this->_message_template_group ) )
1655
+		if ( ! empty($this->_message_template_group))
1656 1656
 			return; //get out if this is already set.
1657 1657
 
1658
-		$GRP_ID =  ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : FALSE;
1659
-		$GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID;
1658
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : FALSE;
1659
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
1660 1660
 
1661 1661
 		//let's get the message templates
1662 1662
 		$MTP = EEM_Message_Template_Group::instance();
1663 1663
 
1664
-		if ( empty($GRP_ID) )
1664
+		if (empty($GRP_ID))
1665 1665
 			$this->_message_template_group = $MTP->create_default_object();
1666 1666
 		else
1667
-			$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );
1667
+			$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID);
1668 1668
 
1669 1669
 		$this->_template_pack = $this->_message_template_group->get_template_pack();
1670 1670
 		$this->_variation = $this->_message_template_group->get_template_pack_variation();
@@ -1690,26 +1690,26 @@  discard block
 block discarded – undo
1690 1690
 		<div class="ee-msg-switcher-container">
1691 1691
 			<form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm">
1692 1692
 				<?php
1693
-					foreach ( $args as $name => $value ) {
1694
-						if ( $name == 'context' || empty($value) || $name == 'extra' ) continue;
1693
+					foreach ($args as $name => $value) {
1694
+						if ($name == 'context' || empty($value) || $name == 'extra') continue;
1695 1695
 						?>
1696 1696
 						<input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" />
1697 1697
 						<?php
1698 1698
 					}
1699 1699
 					//setup nonce_url
1700
-					wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
1700
+					wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false);
1701 1701
 				?>
1702 1702
 				<select name="context">
1703 1703
 					<?php
1704 1704
 					$context_templates = $template_group_object->context_templates();
1705
-					if ( is_array($context_templates) ) :
1706
-							foreach ( $context_templates as $context => $template_fields ) :
1705
+					if (is_array($context_templates)) :
1706
+							foreach ($context_templates as $context => $template_fields) :
1707 1707
 								$checked = ($context == $args['context']) ? 'selected="selected"' : '';
1708 1708
 					?>
1709 1709
 					<option value="<?php echo $context; ?>" <?php echo $checked; ?>><?php echo $context_details[$context]['label']; ?></option>
1710 1710
 					<?php endforeach; endif; ?>
1711 1711
 				</select>
1712
-				<?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?>
1712
+				<?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?>
1713 1713
 				<input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>">
1714 1714
 			</form>
1715 1715
 			<?php echo $args['extra']; ?>
@@ -1733,8 +1733,8 @@  discard block
 block discarded – undo
1733 1733
 	 * @param int $index This helps us know which template field to select from the request array.
1734 1734
 	 */
1735 1735
 	protected function _set_message_template_column_values($index) {
1736
-		if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) {
1737
-			foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) {
1736
+		if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
1737
+			foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
1738 1738
 				$this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
1739 1739
 			}
1740 1740
 		} else {
@@ -1766,27 +1766,27 @@  discard block
 block discarded – undo
1766 1766
 
1767 1767
 
1768 1768
 
1769
-	protected function _insert_or_update_message_template($new = FALSE ) {
1769
+	protected function _insert_or_update_message_template($new = FALSE) {
1770 1770
 
1771
-		do_action ( 'AHEE_log', __FILE__, __FUNCTION__, '');
1771
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1772 1772
 		$success = 0;
1773 1773
 		$override = FALSE;
1774 1774
 
1775 1775
 		//setup notices description
1776
-		$messenger = !empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'] ) ) : false;
1777
-		$message_type = !empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'] ) ) : false;
1778
-		$context = !empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'] ) ) : false;
1776
+		$messenger = ! empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) : false;
1777
+		$message_type = ! empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) : false;
1778
+		$context = ! empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) : false;
1779 1779
 
1780
-		$item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : '';
1780
+		$item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : '';
1781 1781
 		$item_desc .= 'Message Template';
1782 1782
 		$query_args = array();
1783 1783
 		$validates = '';
1784 1784
 
1785 1785
 		//if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit.
1786
-		if ( $new ) {
1787
-			$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1788
-			if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) {
1789
-				if ( empty($edit_array) ) {
1786
+		if ($new) {
1787
+			$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1788
+			if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) {
1789
+				if (empty($edit_array)) {
1790 1790
 					$success = 0;
1791 1791
 				} else {
1792 1792
 					$success = 1;
@@ -1805,34 +1805,34 @@  discard block
 block discarded – undo
1805 1805
 
1806 1806
 
1807 1807
 			//run update for each template field in displayed context
1808
-			if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) {
1809
-				EE_Error::add_error( __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1808
+			if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
1809
+				EE_Error::add_error(__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1810 1810
 				$success = 0;
1811 1811
 				$action_desc = '';
1812 1812
 
1813 1813
 			} else {
1814 1814
 				//first validate all fields!
1815
-				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
1815
+				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
1816 1816
 
1817 1817
 				//if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.  WE need to make sure there is no actual error messages in validates.
1818
-				if ( is_array($validates) && !empty($validates) ) {
1818
+				if (is_array($validates) && ! empty($validates)) {
1819 1819
 					//add the transient so when the form loads we know which fields to highlight
1820
-					$this->_add_transient( 'edit_message_template', $validates );
1820
+					$this->_add_transient('edit_message_template', $validates);
1821 1821
 
1822 1822
 					$success = 0;
1823
-					$action_desc ='';
1823
+					$action_desc = '';
1824 1824
 
1825 1825
 					//setup notices
1826
-					foreach ( $validates as $field => $error ) {
1827
-						if ( isset($error['msg'] ) )
1828
-							EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );
1826
+					foreach ($validates as $field => $error) {
1827
+						if (isset($error['msg']))
1828
+							EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
1829 1829
 					}
1830 1830
 
1831 1831
 				} else {
1832
-					foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) {
1832
+					foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
1833 1833
 						$set_column_values = $this->_set_message_template_column_values($template_field);
1834 1834
 
1835
-						$where_cols_n_values = array( 'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']);
1835
+						$where_cols_n_values = array('MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']);
1836 1836
 
1837 1837
 						$message_template_fields = array(
1838 1838
 							'GRP_ID' => $set_column_values['GRP_ID'],
@@ -1840,10 +1840,10 @@  discard block
 block discarded – undo
1840 1840
 							'MTP_context' => $set_column_values['MTP_context'],
1841 1841
 							'MTP_content' => $set_column_values['MTP_content']
1842 1842
 							);
1843
-						if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) {
1844
-							if ( $updated === FALSE ) {
1845
-								$msg = sprintf( __('%s field was NOT updated for some reason', 'event_espresso'), $template_field );
1846
-								EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ );
1843
+						if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
1844
+							if ($updated === FALSE) {
1845
+								$msg = sprintf(__('%s field was NOT updated for some reason', 'event_espresso'), $template_field);
1846
+								EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1847 1847
 							} else {
1848 1848
 								$success = 1;
1849 1849
 							}
@@ -1860,24 +1860,24 @@  discard block
 block discarded – undo
1860 1860
 						'MTP_is_override' => $set_column_values['MTP_is_override'],
1861 1861
 						'MTP_deleted' => $set_column_values['MTP_deleted'],
1862 1862
 						'MTP_is_active' => $set_column_values['MTP_is_active'],
1863
-						'MTP_name' => !empty( $this->_req_data['ee_msg_non_global_fields']['MTP_name'] ) ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] : '',
1864
-						'MTP_description' => !empty( $this->_req_data['ee_msg_non_global_fields']['MTP_description'] ) ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] : ''
1863
+						'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] : '',
1864
+						'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] : ''
1865 1865
 						);
1866 1866
 
1867
-					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] );
1868
-					$updated = $MTPG->update( $mtpg_fields, array($mtpg_where) );
1867
+					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
1868
+					$updated = $MTPG->update($mtpg_fields, array($mtpg_where));
1869 1869
 
1870
-					if ( $updated === FALSE ) {
1871
-						$msg = sprintf( __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), $set_column_values['GRP_ID'] );
1872
-						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ );
1870
+					if ($updated === FALSE) {
1871
+						$msg = sprintf(__('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), $set_column_values['GRP_ID']);
1872
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1873 1873
 					} else {
1874 1874
 						//k now we need to ensure the template_pack and template_variation fields are set.
1875
-						$template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) ? $this->_req_data['MTP_template_pack'] : 'default';
1876
-						$template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) ? $this->_req_data['MTP_template_variation'] : 'default';
1877
-						$mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] );
1878
-						if ( $mtpg_obj instanceof EE_Message_Template_Group ) {
1879
-							$mtpg_obj->set_template_pack_name( $template_pack );
1880
-							$mtpg_obj->set_template_pack_variation( $template_variation );
1875
+						$template_pack = ! empty($this->_req_data['MTP_template_pack']) ? $this->_req_data['MTP_template_pack'] : 'default';
1876
+						$template_variation = ! empty($this->_req_data['MTP_template_variation']) ? $this->_req_data['MTP_template_variation'] : 'default';
1877
+						$mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
1878
+						if ($mtpg_obj instanceof EE_Message_Template_Group) {
1879
+							$mtpg_obj->set_template_pack_name($template_pack);
1880
+							$mtpg_obj->set_template_pack_variation($template_variation);
1881 1881
 						}
1882 1882
 						$success = 1;
1883 1883
 					}
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 		}
1888 1888
 
1889 1889
 		//we return things differently if doing ajax
1890
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1890
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1891 1891
 			$this->_template_args['success'] = $success;
1892 1892
 			$this->_template_args['error'] = ! $success ? TRUE : FALSE;
1893 1893
 			$this->_template_args['content'] = '';
@@ -1895,9 +1895,9 @@  discard block
 block discarded – undo
1895 1895
 				'grpID' => $edit_array['GRP_ID'],
1896 1896
 				'templateName' => $edit_array['template_name']
1897 1897
 				);
1898
-			if ( $success ) {
1898
+			if ($success) {
1899 1899
 				EE_Error::overwrite_success();
1900
-				EE_Error::add_success( __('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso') );
1900
+				EE_Error::add_success(__('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso'));
1901 1901
 			}
1902 1902
 
1903 1903
 			$this->_return_json();
@@ -1905,13 +1905,13 @@  discard block
 block discarded – undo
1905 1905
 
1906 1906
 
1907 1907
 		//was a test send triggered?
1908
-		if ( isset( $this->_req_data['test_button'] ) ) {
1908
+		if (isset($this->_req_data['test_button'])) {
1909 1909
 			EE_Error::overwrite_success();
1910
-			$this->_do_test_send( $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] );
1910
+			$this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
1911 1911
 			$override = TRUE;
1912 1912
 		}
1913 1913
 
1914
-		if ( empty( $query_args ) ) {
1914
+		if (empty($query_args)) {
1915 1915
 			$query_args = array(
1916 1916
 				'id' => $this->_req_data['GRP_ID'],
1917 1917
 				'context' => $this->_req_data['MTP_context'],
@@ -1919,7 +1919,7 @@  discard block
 block discarded – undo
1919 1919
 				);
1920 1920
 		}
1921 1921
 
1922
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override );
1922
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
1923 1923
 	}
1924 1924
 
1925 1925
 
@@ -1932,24 +1932,24 @@  discard block
 block discarded – undo
1932 1932
 	 * @param  string $message_type message type being tested
1933 1933
 	 * @return void
1934 1934
 	 */
1935
-	protected function _do_test_send( $context, $messenger, $message_type ) {
1935
+	protected function _do_test_send($context, $messenger, $message_type) {
1936 1936
 		//set things up for preview
1937 1937
 		$this->_req_data['messenger'] = $messenger;
1938 1938
 		$this->_req_data['message_type'] = $message_type;
1939 1939
 		$this->_req_data['context'] = $context;
1940
-		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : '';
1940
+		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
1941 1941
 
1942 1942
 		//let's save any existing fields that might be required by the messenger
1943
-		if ( isset( $this->_req_data['test_settings_fld'] ) ) {
1944
-			$this->_active_messengers[$messenger]['obj']->set_existing_test_settings( $this->_req_data['test_settings_fld'] );
1943
+		if (isset($this->_req_data['test_settings_fld'])) {
1944
+			$this->_active_messengers[$messenger]['obj']->set_existing_test_settings($this->_req_data['test_settings_fld']);
1945 1945
 		}
1946 1946
 
1947 1947
 		$success = $this->_preview_message(TRUE);
1948 1948
 
1949
-		if ( $success ) {
1950
-			EE_Error::add_success( __('Test message sent', 'event_espresso') );
1949
+		if ($success) {
1950
+			EE_Error::add_success(__('Test message sent', 'event_espresso'));
1951 1951
 		} else {
1952
-			EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1952
+			EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1953 1953
 		}
1954 1954
 	}
1955 1955
 
@@ -1971,12 +1971,12 @@  discard block
 block discarded – undo
1971 1971
 	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) {
1972 1972
 
1973 1973
 		//if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates.
1974
-		if ( empty( $message_types ) )
1974
+		if (empty($message_types))
1975 1975
 			return true;
1976 1976
 
1977
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1977
+		EE_Registry::instance()->load_helper('MSG_Template');
1978 1978
 
1979
-		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID,  $global);
1979
+		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
1980 1980
 
1981 1981
 	}
1982 1982
 
@@ -1992,33 +1992,33 @@  discard block
 block discarded – undo
1992 1992
 	 * @param boolean $all whether this is going to trash/restore all contexts within a template group (TRUE) OR just an individual context (FALSE).
1993 1993
 	 * @return void
1994 1994
 	 */
1995
-	protected function _trash_or_restore_message_template($trash = TRUE, $all = FALSE ) {
1996
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1995
+	protected function _trash_or_restore_message_template($trash = TRUE, $all = FALSE) {
1996
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1997 1997
 		$MTP = EEM_Message_Template_Group::instance();
1998 1998
 
1999 1999
 		$success = 1;
2000 2000
 
2001 2001
 		//incoming GRP_IDs
2002
-		if ( $all ) {
2002
+		if ($all) {
2003 2003
 			//Checkboxes
2004
-			if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) {
2004
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2005 2005
 				//if array has more than one element then success message should be plural.
2006 2006
 				//todo: what about nonce?
2007
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2007
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2008 2008
 
2009 2009
 				//cycle through checkboxes
2010
-				while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) {
2011
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2012
-					if ( ! $trashed_or_restored ) {
2010
+				while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2011
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2012
+					if ( ! $trashed_or_restored) {
2013 2013
 						$success = 0;
2014 2014
 					}
2015 2015
 				}
2016 2016
 			} else {
2017 2017
 				//grab single GRP_ID and handle
2018
-				$GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
2019
-				if ( ! empty( $GRP_ID ) ) {
2020
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2021
-					if ( ! $trashed_or_restored ) {
2018
+				$GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
2019
+				if ( ! empty($GRP_ID)) {
2020
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2021
+					if ( ! $trashed_or_restored) {
2022 2022
 						$success = 0;
2023 2023
 					}
2024 2024
 				} else {
@@ -2030,13 +2030,13 @@  discard block
 block discarded – undo
2030 2030
 
2031 2031
 		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2032 2032
 
2033
-		$action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc;
2033
+		$action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc;
2034 2034
 
2035 2035
 		$item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
2036 2036
 
2037
-		$item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2037
+		$item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2038 2038
 
2039
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, array() );
2039
+		$this->_redirect_after_action($success, $item_desc, $action_desc, array());
2040 2040
 
2041 2041
 	}
2042 2042
 
@@ -2052,26 +2052,26 @@  discard block
 block discarded – undo
2052 2052
 	 * @return void
2053 2053
 	 */
2054 2054
 	protected function _delete_message_template() {
2055
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2055
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2056 2056
 
2057 2057
 		$success = 1;
2058 2058
 
2059 2059
 		//checkboxes
2060
-		if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) {
2060
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2061 2061
 			//if array has more than one element then success message should be plural
2062
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2062
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2063 2063
 
2064 2064
 			//cycle through bulk action checkboxes
2065
-			while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) {
2066
-				$success = $this->_delete_mtp_permanently( $GRP_ID );
2065
+			while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2066
+				$success = $this->_delete_mtp_permanently($GRP_ID);
2067 2067
 			}
2068 2068
 		} else {
2069 2069
 			//grab single grp_id and delete
2070
-			$GRP_ID = absint($this->_req_data['id'] );
2071
-			$success = $this->_delete_mtp_permanently( $GRP_ID );
2070
+			$GRP_ID = absint($this->_req_data['id']);
2071
+			$success = $this->_delete_mtp_permanently($GRP_ID);
2072 2072
 		}
2073 2073
 
2074
-		$this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() );
2074
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
2075 2075
 
2076 2076
 	}
2077 2077
 
@@ -2084,20 +2084,20 @@  discard block
 block discarded – undo
2084 2084
 	 * @param  bool $include_group whether to delete the Message Template Group as well.
2085 2085
 	 * @return success        boolean to indicate the success of the deletes or not.
2086 2086
 	 */
2087
-	private function _delete_mtp_permanently( $GRP_ID, $include_group = TRUE ) {
2087
+	private function _delete_mtp_permanently($GRP_ID, $include_group = TRUE) {
2088 2088
 		$success = 1;
2089 2089
 		$MTPG = EEM_Message_Template_Group::instance();
2090 2090
 		//first let's GET this group
2091
-		$MTG = $MTPG->get_one_by_ID( $GRP_ID );
2091
+		$MTG = $MTPG->get_one_by_ID($GRP_ID);
2092 2092
 		//then delete permanently all the related Message Templates
2093
-		$deleted = $MTG->delete_related_permanently( 'Message_Template' );
2093
+		$deleted = $MTG->delete_related_permanently('Message_Template');
2094 2094
 
2095
-		if ( $deleted === 0 )
2095
+		if ($deleted === 0)
2096 2096
 			$success = 0;
2097 2097
 
2098 2098
 		//now delete permanently this particular group
2099 2099
 
2100
-		if ( $include_group && ! $MTG->delete_permanently() ) {
2100
+		if ($include_group && ! $MTG->delete_permanently()) {
2101 2101
 			$success = 0;
2102 2102
 		}
2103 2103
 		return $success;
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 	*	@return string
2116 2116
 	*/
2117 2117
 	protected function _learn_more_about_message_templates_link() {
2118
-		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2118
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>';
2119 2119
 	}
2120 2120
 
2121 2121
 
@@ -2129,14 +2129,14 @@  discard block
 block discarded – undo
2129 2129
 	 */
2130 2130
 	protected function _settings() {
2131 2131
 
2132
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
2132
+		EE_Registry::instance()->load_helper('Tabbed_Content');
2133 2133
 
2134 2134
 		$this->_set_m_mt_settings();
2135 2135
 
2136
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2136
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2137 2137
 
2138 2138
 		//let's setup the messenger tabs
2139
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger );
2139
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger);
2140 2140
 		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
2141 2141
 		$this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->';
2142 2142
 
@@ -2155,10 +2155,10 @@  discard block
 block discarded – undo
2155 2155
 	 */
2156 2156
 	protected function _set_m_mt_settings() {
2157 2157
 		//first if this is already set then lets get out no need to regenerate data.
2158
-		if ( !empty($this->_m_mt_settings) )
2158
+		if ( ! empty($this->_m_mt_settings))
2159 2159
 			return;
2160 2160
 
2161
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2161
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2162 2162
 
2163 2163
 		//get all installed messengers and message_types
2164 2164
 		$installed_message_objects = $this->_get_installed_message_objects();
@@ -2168,10 +2168,10 @@  discard block
 block discarded – undo
2168 2168
 
2169 2169
 		//assemble the array for the _tab_text_links helper
2170 2170
 
2171
-		foreach ( $messengers as $messenger ) {
2171
+		foreach ($messengers as $messenger) {
2172 2172
 			$this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
2173 2173
 				'label' => ucwords($messenger->label['singular']),
2174
-				'class' => isset( $this->_active_messengers[$messenger->name] ) ? 'messenger-active' : '',
2174
+				'class' => isset($this->_active_messengers[$messenger->name]) ? 'messenger-active' : '',
2175 2175
 				'href' => $messenger->name,
2176 2176
 				'title' => __('Modify this Messenger', 'event_espresso'),
2177 2177
 				'slug' => $messenger->name,
@@ -2181,23 +2181,23 @@  discard block
 block discarded – undo
2181 2181
 			$message_types_for_messenger = $messenger->get_valid_message_types();
2182 2182
 
2183 2183
 			//assemble the array for the ACTIVE and INACTIVE message types with the selected messenger //note that all message types will be in the inactive box if the messenger is NOT active.
2184
-			$selected_settings = isset( $this->_active_messengers[$messenger->name]['settings'] ) ? $this->_active_messengers[$messenger->name]['settings'] : array();
2185
-			foreach ( $message_types as $message_type ) {
2184
+			$selected_settings = isset($this->_active_messengers[$messenger->name]['settings']) ? $this->_active_messengers[$messenger->name]['settings'] : array();
2185
+			foreach ($message_types as $message_type) {
2186 2186
 				//first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox.
2187
-				if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) {
2187
+				if ( ! in_array($message_type->name, $message_types_for_messenger)) {
2188 2188
 					continue;
2189 2189
 				}
2190 2190
 
2191
-				$a_or_i = isset( $selected_settings[$messenger->name . '-message_types'][$message_type->name] ) && $selected_settings[$messenger->name . '-message_types'][$message_type->name] ? 'active' : 'inactive';
2191
+				$a_or_i = isset($selected_settings[$messenger->name.'-message_types'][$message_type->name]) && $selected_settings[$messenger->name.'-message_types'][$message_type->name] ? 'active' : 'inactive';
2192 2192
 
2193 2193
 				$this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
2194 2194
 						'label' => ucwords($message_type->label['singular']),
2195
-						'class' => 'message-type-' . $a_or_i,
2196
-						'slug_id' => $message_type->name . '-messagetype-' . $messenger->name,
2197
-						'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
2198
-						'href' => 'espresso_' . $message_type->name . '_message_type_settings',
2195
+						'class' => 'message-type-'.$a_or_i,
2196
+						'slug_id' => $message_type->name.'-messagetype-'.$messenger->name,
2197
+						'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'),
2198
+						'href' => 'espresso_'.$message_type->name.'_message_type_settings',
2199 2199
 						'title' => $a_or_i == 'active' ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') : __('Drag this message type to the messenger to activate', 'event_espresso'),
2200
-						'content' => $a_or_i == 'active' ? $this->_message_type_settings_content( $message_type, $messenger, TRUE ) : $this->_message_type_settings_content( $message_type, $messenger ),
2200
+						'content' => $a_or_i == 'active' ? $this->_message_type_settings_content($message_type, $messenger, TRUE) : $this->_message_type_settings_content($message_type, $messenger),
2201 2201
 						'slug' => $message_type->name,
2202 2202
 						'active' => $a_or_i == 'active' ? TRUE : FALSE,
2203 2203
 						'obj' => $message_type
@@ -2214,34 +2214,34 @@  discard block
 block discarded – undo
2214 2214
 	 * @param  boolean $active       Whether the message type is active or not
2215 2215
 	 * @return string                html output for the content
2216 2216
 	 */
2217
-	protected function _message_type_settings_content( $message_type, $messenger, $active = FALSE ) {
2217
+	protected function _message_type_settings_content($message_type, $messenger, $active = FALSE) {
2218 2218
 		//get message type fields
2219 2219
 		$fields = $message_type->get_admin_settings_fields();
2220
-		$settings_template_args['template_form_fields']= '';
2220
+		$settings_template_args['template_form_fields'] = '';
2221 2221
 
2222
-		if ( !empty( $fields ) && $active ) {
2222
+		if ( ! empty($fields) && $active) {
2223 2223
 
2224
-			$existing_settings = $message_type->get_existing_admin_settings( $messenger->name );
2224
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
2225 2225
 
2226
-			foreach( $fields as $fldname => $fldprops ) {
2227
-				$field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname;
2226
+			foreach ($fields as $fldname => $fldprops) {
2227
+				$field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname;
2228 2228
 				$template_form_field[$field_id] = array(
2229
-					'name' => 'message_type_settings[' . $fldname . ']',
2229
+					'name' => 'message_type_settings['.$fldname.']',
2230 2230
 					'label' => $fldprops['label'],
2231 2231
 					'input' => $fldprops['field_type'],
2232 2232
 					'type' => $fldprops['value_type'],
2233 2233
 					'required' => $fldprops['required'],
2234 2234
 					'validation' => $fldprops['validation'],
2235
-					'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2236
-					'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(),
2237
-					'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'],
2235
+					'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2236
+					'options' => isset($fldprops['options']) ? $fldprops['options'] : array(),
2237
+					'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2238 2238
 					'css_class' => 'no-drag',
2239 2239
 					'format' => $fldprops['format']
2240 2240
 					);
2241 2241
 			}
2242 2242
 
2243 2243
 
2244
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : '';
2244
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : '';
2245 2245
 		}
2246 2246
 
2247 2247
 		$settings_template_args['description'] = $message_type->description;
@@ -2261,13 +2261,13 @@  discard block
 block discarded – undo
2261 2261
 					)
2262 2262
 				);
2263 2263
 
2264
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2265
-		$settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : '';
2264
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2265
+		$settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : '';
2266 2266
 
2267 2267
 
2268 2268
 
2269
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
2270
-		$content = EEH_Template::display_template( $template, $settings_template_args, TRUE );
2269
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php';
2270
+		$content = EEH_Template::display_template($template, $settings_template_args, TRUE);
2271 2271
 		return $content;
2272 2272
 	}
2273 2273
 
@@ -2284,21 +2284,21 @@  discard block
 block discarded – undo
2284 2284
 		$m_boxes = $mt_boxes = array();
2285 2285
 		$m_template_args = $mt_template_args = array();
2286 2286
 
2287
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2287
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2288 2288
 
2289
-		foreach ( $this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array ) {
2289
+		foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
2290 2290
 
2291
-			$hide_on_message = isset( $this->_active_messengers[$messenger] ) ? '' : 'hidden';
2292
-			$hide_off_message = isset( $this->_active_messengers[$messenger] ) ? 'hidden' : '';
2291
+			$hide_on_message = isset($this->_active_messengers[$messenger]) ? '' : 'hidden';
2292
+			$hide_off_message = isset($this->_active_messengers[$messenger]) ? 'hidden' : '';
2293 2293
 
2294 2294
 			//messenger meta boxes
2295 2295
 			$active = $selected_messenger == $messenger ? TRUE : FALSE;
2296
-			$active_mt_tabs = isset(  $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] ) ?  $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : '';
2297
-			$m_boxes[$messenger . '_a_box'] = sprintf( __('%s Settings', 'event_espresso'), $tab_array['label'] );
2298
-			$m_template_args[$messenger . '_a_box'] = array(
2299
-					'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2300
-					'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '',
2301
-					'content' => $this->_get_messenger_box_content( $tab_array['obj'] ),
2296
+			$active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : '';
2297
+			$m_boxes[$messenger.'_a_box'] = sprintf(__('%s Settings', 'event_espresso'), $tab_array['label']);
2298
+			$m_template_args[$messenger.'_a_box'] = array(
2299
+					'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2300
+					'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '',
2301
+					'content' => $this->_get_messenger_box_content($tab_array['obj']),
2302 2302
 					'hidden' => $active ? '' : ' hidden',
2303 2303
 					'hide_on_message' => $hide_on_message,
2304 2304
 					'messenger' => $messenger,
@@ -2307,10 +2307,10 @@  discard block
 block discarded – undo
2307 2307
 
2308 2308
 
2309 2309
 			//message type meta boxes (which is really just the inactive container for each messenger showing inactive message types for that messenger)
2310
-			$mt_boxes[$messenger . '_i_box'] = __('Inactive Message Types', 'event_espresso');
2311
-			$mt_template_args[$messenger . '_i_box'] = array(
2312
-				'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2313
-				'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '',
2310
+			$mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso');
2311
+			$mt_template_args[$messenger.'_i_box'] = array(
2312
+				'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2313
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '',
2314 2314
 				'hidden' => $active ? '' : ' hidden',
2315 2315
 				'hide_on_message' => $hide_on_message,
2316 2316
 				'hide_off_message' => $hide_off_message,
@@ -2320,19 +2320,19 @@  discard block
 block discarded – undo
2320 2320
 		}
2321 2321
 
2322 2322
 		//register messenger metaboxes
2323
-		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
2324
-		foreach ( $m_boxes as $box => $label ) {
2325
-			$callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] );
2326
-			$msgr = str_replace( '_a_box', '', $box );
2327
-			add_meta_box( 'espresso_' . $msgr . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args );
2323
+		$m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php';
2324
+		foreach ($m_boxes as $box => $label) {
2325
+			$callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
2326
+			$msgr = str_replace('_a_box', '', $box);
2327
+			add_meta_box('espresso_'.$msgr.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
2328 2328
 		}
2329 2329
 
2330 2330
 		//register message type metaboxes
2331
-		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
2332
-		foreach ( $mt_boxes as $box => $label ) {
2333
-			$callback_args = array( 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] );
2334
-			$mt = str_replace( '_i_box', '', $box );
2335
-			add_meta_box( 'espresso_' . $mt . '_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args );
2331
+		$mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php';
2332
+		foreach ($mt_boxes as $box => $label) {
2333
+			$callback_args = array('template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]);
2334
+			$mt = str_replace('_i_box', '', $box);
2335
+			add_meta_box('espresso_'.$mt.'_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args);
2336 2336
 		}
2337 2337
 
2338 2338
 	}
@@ -2343,13 +2343,13 @@  discard block
 block discarded – undo
2343 2343
 	 * @param  array $tab_array  This is an array of message type tab details used to generate the tabs
2344 2344
 	 * @return string            html formatted tabs
2345 2345
 	 */
2346
-	protected function _get_mt_tabs( $tab_array ) {
2346
+	protected function _get_mt_tabs($tab_array) {
2347 2347
 		$tab_array = (array) $tab_array;
2348
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
2348
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php';
2349 2349
 		$tabs = '';
2350 2350
 
2351
-		foreach ( $tab_array as $tab ) {
2352
-			$tabs .=  EEH_Template::display_template( $template, $tab, TRUE );
2351
+		foreach ($tab_array as $tab) {
2352
+			$tabs .= EEH_Template::display_template($template, $tab, TRUE);
2353 2353
 		}
2354 2354
 
2355 2355
 		return $tabs;
@@ -2363,7 +2363,7 @@  discard block
 block discarded – undo
2363 2363
 	 * @param  object $messenger The messenger we're setting up content for
2364 2364
 	 * @return string            html formatted content
2365 2365
 	 */
2366
-	protected function _get_messenger_box_content( $messenger ) {
2366
+	protected function _get_messenger_box_content($messenger) {
2367 2367
 
2368 2368
 		$fields = $messenger->get_admin_settings_fields();
2369 2369
 		$settings_template_args['template_form_fields'] = '';
@@ -2372,27 +2372,27 @@  discard block
 block discarded – undo
2372 2372
 		$settings_template_args['active'] = isset($this->_active_messengers[$messenger->name]) ? TRUE : FALSE;
2373 2373
 
2374 2374
 
2375
-		if ( !empty( $fields ) ) {
2375
+		if ( ! empty($fields)) {
2376 2376
 
2377 2377
 			$existing_settings = $messenger->get_existing_admin_settings();
2378 2378
 
2379
-			foreach( $fields as $fldname => $fldprops ) {
2380
-				$field_id = $messenger->name . '-' . $fldname;
2379
+			foreach ($fields as $fldname => $fldprops) {
2380
+				$field_id = $messenger->name.'-'.$fldname;
2381 2381
 				$template_form_field[$field_id] = array(
2382
-					'name' => 'messenger_settings[' . $field_id . ']',
2382
+					'name' => 'messenger_settings['.$field_id.']',
2383 2383
 					'label' => $fldprops['label'],
2384 2384
 					'input' => $fldprops['field_type'],
2385 2385
 					'type' => $fldprops['value_type'],
2386 2386
 					'required' => $fldprops['required'],
2387 2387
 					'validation' => $fldprops['validation'],
2388
-					'value' => isset( $existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'],
2388
+					'value' => isset($existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'],
2389 2389
 					'css_class' => '',
2390 2390
 					'format' => $fldprops['format']
2391 2391
 					);
2392 2392
 			}
2393 2393
 
2394 2394
 
2395
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) : '';
2395
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') : '';
2396 2396
 		}
2397 2397
 
2398 2398
 		//we also need some hidden fields
@@ -2408,8 +2408,8 @@  discard block
 block discarded – undo
2408 2408
 			);
2409 2409
 
2410 2410
 		//make sure any active message types that are existing are included in the hidden fields
2411
-		if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) {
2412
-			foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) {
2411
+		if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
2412
+			foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
2413 2413
 				$settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array(
2414 2414
 						'type' => 'hidden',
2415 2415
 						'value' => $mt
@@ -2417,25 +2417,25 @@  discard block
 block discarded – undo
2417 2417
 			}
2418 2418
 		}
2419 2419
 
2420
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2420
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2421 2421
 
2422
-		$active = isset( $this->_active_messengers[$messenger->name] ) ? TRUE : FALSE;
2422
+		$active = isset($this->_active_messengers[$messenger->name]) ? TRUE : FALSE;
2423 2423
 
2424 2424
 		$settings_template_args['messenger'] = $messenger->name;
2425 2425
 		$settings_template_args['description'] = $messenger->description;
2426 2426
 		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
2427 2427
 
2428 2428
 
2429
-		$settings_template_args['show_hide_edit_form'] = isset( $this->_active_messengers[$messenger->name] ) ? $settings_template_args['show_hide_edit_form'] : ' hidden';
2429
+		$settings_template_args['show_hide_edit_form'] = isset($this->_active_messengers[$messenger->name]) ? $settings_template_args['show_hide_edit_form'] : ' hidden';
2430 2430
 
2431
-		$settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : $settings_template_args['show_hide_edit_form'];
2431
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : $settings_template_args['show_hide_edit_form'];
2432 2432
 
2433 2433
 
2434 2434
 		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
2435
-		$settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
2435
+		$settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce');
2436 2436
 		$settings_template_args['on_off_status'] = $active ? true : false;
2437
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
2438
-		$content = EEH_Template::display_template( $template, $settings_template_args, TRUE);
2437
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php';
2438
+		$content = EEH_Template::display_template($template, $settings_template_args, TRUE);
2439 2439
 		return $content;
2440 2440
 	}
2441 2441
 
@@ -2449,39 +2449,39 @@  discard block
 block discarded – undo
2449 2449
 	public function activate_messenger_toggle() {
2450 2450
 		$success = TRUE;
2451 2451
 		//let's check that we have required data
2452
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2453
-			EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2452
+		if ( ! isset($this->_req_data['messenger'])) {
2453
+			EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2454 2454
 			$success = FALSE;
2455 2455
 		}
2456 2456
 
2457 2457
 		//do a nonce check here since we're not arriving via a normal route
2458
-		$nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : '';
2459
-		$nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
2458
+		$nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : '';
2459
+		$nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce';
2460 2460
 
2461
-		$this->_verify_nonce( $nonce, $nonce_ref );
2461
+		$this->_verify_nonce($nonce, $nonce_ref);
2462 2462
 
2463 2463
 
2464 2464
 
2465
-		if ( !isset( $this->_req_data[ 'status' ])) {
2466
-			EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2465
+		if ( ! isset($this->_req_data['status'])) {
2466
+			EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2467 2467
 			$success = FALSE;
2468 2468
 		}
2469 2469
 
2470 2470
 		//do check to verify we have a valid status.
2471 2471
 		$status = $this->_req_data['status'];
2472 2472
 
2473
-		if ( $status != 'off' && $status != 'on' ) {
2474
-			EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ );
2473
+		if ($status != 'off' && $status != 'on') {
2474
+			EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__);
2475 2475
 			$success = FALSE;
2476 2476
 		}
2477 2477
 
2478
-		if ( $success ) {
2478
+		if ($success) {
2479 2479
 			//made it here?  Stop dawdling then!!
2480
-			if ( $status == 'off' ) {
2480
+			if ($status == 'off') {
2481 2481
 				//off = deactivate.  get it?
2482
-				$success = $this->_activate_messenger( $this->_req_data['messenger'], TRUE );
2482
+				$success = $this->_activate_messenger($this->_req_data['messenger'], TRUE);
2483 2483
 			} else {
2484
-				$success = $this->_activate_messenger( $this->_req_data['messenger'] );
2484
+				$success = $this->_activate_messenger($this->_req_data['messenger']);
2485 2485
 			}
2486 2486
 		}
2487 2487
 
@@ -2507,26 +2507,26 @@  discard block
 block discarded – undo
2507 2507
 
2508 2508
 
2509 2509
 		//let's make sure we have the necessary data
2510
-		if ( !isset( $this->_req_data[ 'message_type' ] ) ) {
2511
-			EE_Error::add_error( __('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2510
+		if ( ! isset($this->_req_data['message_type'])) {
2511
+			EE_Error::add_error(__('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2512 2512
 			$success = FALSE;
2513 2513
 		}
2514 2514
 
2515 2515
 
2516 2516
 		//do a nonce check here since we're not arriving via a normal route
2517
-		$nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : '';
2518
-		$nonce_ref = $this->_req_data['message_type'] . '_nonce';
2517
+		$nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
2518
+		$nonce_ref = $this->_req_data['message_type'].'_nonce';
2519 2519
 
2520
-		$this->_verify_nonce( $nonce, $nonce_ref );
2520
+		$this->_verify_nonce($nonce, $nonce_ref);
2521 2521
 
2522 2522
 
2523
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2524
-			EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2523
+		if ( ! isset($this->_req_data['messenger'])) {
2524
+			EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2525 2525
 			$success = FALSE;
2526 2526
 		}
2527 2527
 
2528
-		if ( !isset( $this->_req_data[ 'status' ])) {
2529
-			EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2528
+		if ( ! isset($this->_req_data['status'])) {
2529
+			EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2530 2530
 			$success = FALSE;
2531 2531
 		}
2532 2532
 
@@ -2534,16 +2534,16 @@  discard block
 block discarded – undo
2534 2534
 		//do check to verify we have a valid status.
2535 2535
 		$status = $this->_req_data['status'];
2536 2536
 
2537
-		if ( $status != 'activate' && $status != 'deactivate' ) {
2538
-			EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ );
2537
+		if ($status != 'activate' && $status != 'deactivate') {
2538
+			EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__);
2539 2539
 			$success = FALSE;
2540 2540
 		}
2541 2541
 
2542 2542
 
2543
-		if ( $success ) {
2543
+		if ($success) {
2544 2544
 			//made it here? um, what are you waiting for then?
2545 2545
 			$deactivate = $status == 'deactivate' ? TRUE : FALSE;
2546
-			$success = $this->_activate_messenger( $this->_req_data['messenger'], $deactivate, $this->_req_data['message_type'] );
2546
+			$success = $this->_activate_messenger($this->_req_data['messenger'], $deactivate, $this->_req_data['message_type']);
2547 2547
 		}
2548 2548
 
2549 2549
 		$this->_template_args['success'] = $success;
@@ -2570,28 +2570,28 @@  discard block
 block discarded – undo
2570 2570
 		$templates = TRUE;
2571 2571
 		$this->_set_m_mt_settings();
2572 2572
 
2573
-		if ( !$deactivate ) {
2573
+		if ( ! $deactivate) {
2574 2574
 
2575 2575
 
2576 2576
 			//we are activating.  we can use $this->_m_mt_settings to get all the installed messengers
2577
-			$this->_active_messengers[$messenger]['settings'] = !isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings'];
2577
+			$this->_active_messengers[$messenger]['settings'] = ! isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings'];
2578 2578
 			$this->_active_messengers[$messenger]['obj'] = $this->_m_mt_settings['messenger_tabs'][$messenger]['obj'];
2579 2579
 
2580 2580
 			//get has_active so we can sure its kept up to date.
2581
-			$has_activated = get_option( 'ee_has_activated_messages' );
2581
+			$has_activated = get_option('ee_has_activated_messages');
2582 2582
 
2583
-			if ( empty( $has_activated[$messenger] ) ) {
2583
+			if (empty($has_activated[$messenger])) {
2584 2584
 				$has_activated[$messenger] = array();
2585 2585
 			}
2586 2586
 
2587 2587
 			//k we need to get what default message types are to be associated with the messenger that's been activated.
2588 2588
 			$default_types = $message_type ? (array) $message_type : $this->_active_messengers[$messenger]['obj']->get_default_message_types();
2589 2589
 
2590
-			foreach ( $default_types as $type ) {
2590
+			foreach ($default_types as $type) {
2591 2591
 				$settings_fields = $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$type]['obj']->get_admin_settings_fields();
2592
-				if ( !empty( $settings_fields ) ) {
2592
+				if ( ! empty($settings_fields)) {
2593 2593
 					//we have fields for this message type so let's get the defaults for saving.
2594
-					foreach ( $settings_fields as $field => $values ) {
2594
+					foreach ($settings_fields as $field => $values) {
2595 2595
 						$settings[$field] = $values['default'];
2596 2596
 					}
2597 2597
 					//let's set the data for reloading this message type form in ajax
@@ -2599,9 +2599,9 @@  discard block
 block discarded – undo
2599 2599
 				} else {
2600 2600
 					$settings = array();
2601 2601
 				}
2602
-				$this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$type]['settings'] =  $settings;
2602
+				$this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$type]['settings'] = $settings;
2603 2603
 
2604
-				if ( ! in_array( $type, $has_activated[$messenger] ) ) {
2604
+				if ( ! in_array($type, $has_activated[$messenger])) {
2605 2605
 					$has_activated[$messenger][] = $type;
2606 2606
 				}
2607 2607
 			}
@@ -2609,41 +2609,41 @@  discard block
 block discarded – undo
2609 2609
 			//any default settings for the messenger?
2610 2610
 			$msgr_settings = $this->_active_messengers[$messenger]['obj']->get_admin_settings_fields();
2611 2611
 
2612
-			if ( !empty( $msgr_settings ) ) {
2613
-				foreach ( $msgr_settings as $field => $value ) {
2612
+			if ( ! empty($msgr_settings)) {
2613
+				foreach ($msgr_settings as $field => $value) {
2614 2614
 					$this->_active_messengers[$messenger]['settings'][$field] = $value;
2615 2615
 				}
2616 2616
 			}
2617 2617
 
2618 2618
 			//update settings in database
2619
-			EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2620
-			update_option( 'ee_has_activated_messages', $has_activated );
2619
+			EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2620
+			update_option('ee_has_activated_messages', $has_activated);
2621 2621
 
2622 2622
 
2623 2623
 			//generate new templates (if necessary)
2624
-			$templates = $this->_generate_new_templates( $messenger, $default_types, 0, TRUE );
2624
+			$templates = $this->_generate_new_templates($messenger, $default_types, 0, TRUE);
2625 2625
 
2626 2626
 			EE_Error::overwrite_success();
2627 2627
 
2628 2628
 			//if generation failed then we need to remove the active messenger.
2629
-			if ( !$templates ) {
2629
+			if ( ! $templates) {
2630 2630
 				unset($this->_active_messengers[$messenger]);
2631
-				EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2631
+				EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2632 2632
 			} else {
2633 2633
 				//all is good let's do a success message
2634
-				if ( $message_type ) {
2635
-					EE_Error::add_success( sprintf( __('%s message type has been successfully activated with the %s messenger', 'event_espresso'),ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords( $this->_active_messengers[$messenger]['obj']->label['singular'] ) ) );
2634
+				if ($message_type) {
2635
+					EE_Error::add_success(sprintf(__('%s message type has been successfully activated with the %s messenger', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords($this->_active_messengers[$messenger]['obj']->label['singular'])));
2636 2636
 
2637 2637
 					//if message type was invoice then let's make sure we activate the invoice payment method.
2638
-					if ( $message_type == 'invoice' ) {
2639
-						EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
2640
-						$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
2641
-						if ( $pm instanceof EE_Payment_Method ) {
2642
-							EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) );
2638
+					if ($message_type == 'invoice') {
2639
+						EE_Registry::instance()->load_lib('Payment_Method_Manager');
2640
+						$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
2641
+						if ($pm instanceof EE_Payment_Method) {
2642
+							EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso'));
2643 2643
 						}
2644 2644
 					}
2645 2645
 				} else {
2646
-					EE_Error::add_success( sprintf( __('%s messenger has been successfully activated', 'event_espresso'), ucwords( $this->_active_messengers[$messenger]['obj']->label['singular'] ) ) );
2646
+					EE_Error::add_success(sprintf(__('%s messenger has been successfully activated', 'event_espresso'), ucwords($this->_active_messengers[$messenger]['obj']->label['singular'])));
2647 2647
 				}
2648 2648
 			}
2649 2649
 
@@ -2659,36 +2659,36 @@  discard block
 block discarded – undo
2659 2659
 			$update_array = array(
2660 2660
 				'MTP_messenger' => $messenger);
2661 2661
 
2662
-			if ( $message_type ) {
2662
+			if ($message_type) {
2663 2663
 				$update_array['MTP_message_type'] = $message_type;
2664 2664
 			}
2665 2665
 
2666
-			$success = $MTP->update( array( 'MTP_is_active' => 0 ), array($update_array) );
2666
+			$success = $MTP->update(array('MTP_is_active' => 0), array($update_array));
2667 2667
 
2668 2668
 			$messenger_obj = $this->_active_messengers[$messenger]['obj'];
2669 2669
 
2670 2670
 			//if this is a message type deactivation then we're only unsetting the message type otherwise unset the messenger
2671
-			if ( $message_type ) {
2672
-				unset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] );
2671
+			if ($message_type) {
2672
+				unset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type]);
2673 2673
 			} else {
2674
-				unset( $this->_active_messengers[$messenger] );
2674
+				unset($this->_active_messengers[$messenger]);
2675 2675
 			}
2676 2676
 
2677
-			EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2677
+			EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2678 2678
 			EE_Error::overwrite_success();
2679
-			if ( $message_type ) {
2680
-				EE_Error::add_success( sprintf( __('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular']) ) );
2679
+			if ($message_type) {
2680
+				EE_Error::add_success(sprintf(__('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular'])));
2681 2681
 			} else {
2682
-				EE_Error::add_success( sprintf( __('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'] ) ) );
2682
+				EE_Error::add_success(sprintf(__('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'])));
2683 2683
 			}
2684 2684
 
2685 2685
 			//if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
2686
-			if ( $messenger == 'html'  || $message_type == 'invoice') {
2687
-				EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
2688
-				$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' );
2689
-				if ( $count_updated > 0 ) {
2690
-					$msg = $message_type == 'invoice' ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then vist the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ) : __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' );
2691
-					EE_Error::add_attention( $msg );
2686
+			if ($messenger == 'html' || $message_type == 'invoice') {
2687
+				EE_Registry::instance()->load_lib('Payment_Method_Manager');
2688
+				$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
2689
+				if ($count_updated > 0) {
2690
+					$msg = $message_type == 'invoice' ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then vist the payment methods admin page to reactivate the invoice payment method.', 'event_espresso') : __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso');
2691
+					EE_Error::add_attention($msg);
2692 2692
 				}
2693 2693
 			}
2694 2694
 
@@ -2705,8 +2705,8 @@  discard block
 block discarded – undo
2705 2705
 	 * @return string html data
2706 2706
 	 */
2707 2707
 	public function update_mt_form() {
2708
-		if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) {
2709
-			EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ );
2708
+		if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
2709
+			EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__);
2710 2710
 			$this->_return_json();
2711 2711
 		}
2712 2712
 
@@ -2715,7 +2715,7 @@  discard block
 block discarded – undo
2715 2715
 		$message_type = $message_types[$this->_req_data['message_type']]['obj'];
2716 2716
 		$messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj'];
2717 2717
 
2718
-		$content = $this->_message_type_settings_content ( $message_type, $messenger, TRUE, TRUE );
2718
+		$content = $this->_message_type_settings_content($message_type, $messenger, TRUE, TRUE);
2719 2719
 		$this->_template_args['success'] = true;
2720 2720
 		$this->_template_args['content'] = $content;
2721 2721
 		$this->_return_json();
@@ -2729,36 +2729,36 @@  discard block
 block discarded – undo
2729 2729
 	 * @return json success or fail message
2730 2730
 	 */
2731 2731
 	public function save_settings() {
2732
-		if ( !isset( $this->_req_data['type'] ) ) {
2733
-			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2732
+		if ( ! isset($this->_req_data['type'])) {
2733
+			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2734 2734
 			$this->_template_args['error'] = TRUE;
2735 2735
 			$this->_return_json();
2736 2736
 		}
2737 2737
 
2738 2738
 
2739
-		if ( $this->_req_data['type'] == 'messenger' ) {
2739
+		if ($this->_req_data['type'] == 'messenger') {
2740 2740
 			$settings = $this->_req_data['messenger_settings']; //this should be an array.
2741 2741
 			$messenger = $settings['messenger'];
2742 2742
 			//let's setup the settings data
2743
-			foreach ( $settings as $key => $value ) {
2744
-				switch ( $key ) {
2743
+			foreach ($settings as $key => $value) {
2744
+				switch ($key) {
2745 2745
 					case 'messenger' :
2746
-						unset( $settings['messenger'] );
2746
+						unset($settings['messenger']);
2747 2747
 						break;
2748 2748
 					case 'message_types' :
2749
-						if ( isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] ) ) {
2750
-							foreach ( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] as $mt => $v ) {
2751
-								if ( isset( $settings['message_types'][$mt] ) )
2752
-									$settings[$messenger . '-message_types'][$mt]['settings'] = isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ? $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] : array();
2749
+						if (isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'])) {
2750
+							foreach ($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'] as $mt => $v) {
2751
+								if (isset($settings['message_types'][$mt]))
2752
+									$settings[$messenger.'-message_types'][$mt]['settings'] = isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) ? $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt] : array();
2753 2753
 							}
2754 2754
 						} else {
2755
-							foreach ( $value as $mt => $v ) {
2755
+							foreach ($value as $mt => $v) {
2756 2756
 								//let's see if this message type is already present and has settings.
2757
-								$settings[$messenger . '-message_types'][$mt]['settings'] = array();
2757
+								$settings[$messenger.'-message_types'][$mt]['settings'] = array();
2758 2758
 							}
2759 2759
 						}
2760 2760
 						//k settings are set let's get rid of the message types index
2761
-						unset( $settings['message_types'] );
2761
+						unset($settings['message_types']);
2762 2762
 						break;
2763 2763
 					default :
2764 2764
 						$settings[$key] = $value;
@@ -2768,36 +2768,36 @@  discard block
 block discarded – undo
2768 2768
 			$this->_active_messengers[$messenger]['settings'] = $settings;
2769 2769
 		}
2770 2770
 
2771
-		else if ( $this->_req_data['type'] == 'message_type' ) {
2771
+		else if ($this->_req_data['type'] == 'message_type') {
2772 2772
 			$settings = $this->_req_data['message_type_settings'];
2773 2773
 			$messenger = $settings['messenger'];
2774 2774
 			$message_type = $settings['message_type'];
2775 2775
 
2776
-			foreach ( $settings as $key => $value ) {
2777
-				switch ( $key ) {
2776
+			foreach ($settings as $key => $value) {
2777
+				switch ($key) {
2778 2778
 					case 'messenger' :
2779
-						unset( $settings['messenger'] );
2779
+						unset($settings['messenger']);
2780 2780
 						break;
2781 2781
 					case 'message_type' :
2782
-						unset( $settings['message_type'] );
2782
+						unset($settings['message_type']);
2783 2783
 						break;
2784 2784
 					default :
2785 2785
 						$settings['settings'][$key] = $value;
2786
-						unset( $settings[$key] );
2786
+						unset($settings[$key]);
2787 2787
 						break;
2788 2788
 				}
2789 2789
 			}
2790 2790
 
2791
-			$this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] = $settings;
2791
+			$this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type] = $settings;
2792 2792
 		}
2793 2793
 
2794 2794
 		//okay we should have the data all setup.  Now we just update!
2795
-		$success = EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2795
+		$success = EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2796 2796
 
2797
-		if ( $success ) {
2798
-			EE_Error::add_success( __('Settings updated', 'event_espresso') );
2797
+		if ($success) {
2798
+			EE_Error::add_success(__('Settings updated', 'event_espresso'));
2799 2799
 		} else {
2800
-			EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2800
+			EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2801 2801
 		}
2802 2802
 
2803 2803
 		$this->_template_args['success'] = $success;
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 1 patch
Spacing   +396 added lines, -396 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $routing
57 57
 	 * @return Transactions_Admin_Page
58 58
 	 */
59
-	public function __construct( $routing = TRUE ) {
60
-		parent::__construct( $routing );
59
+	public function __construct($routing = TRUE) {
60
+		parent::__construct($routing);
61 61
 	}
62 62
 
63 63
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @return void
81 81
 	 */
82 82
 	protected function _ajax_hooks() {
83
-		add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds'));
84
-		add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds'));
85
-		add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment'));
83
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
84
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
85
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
86 86
 	}
87 87
 
88 88
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			'buttons' => array(
98 98
 				'add' => __('Add New Transaction', 'event_espresso'),
99 99
 				'edit' => __('Edit Transaction', 'event_espresso'),
100
-				'delete' => __('Delete Transaction','event_espresso')
100
+				'delete' => __('Delete Transaction', 'event_espresso')
101 101
 				)
102 102
 			);
103 103
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->_set_transaction_status_array();
115 115
 
116
-		$txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0;
116
+		$txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0;
117 117
 
118 118
 		$this->_page_routes = array(
119 119
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 						'filename' => 'transactions_overview_views_filters_search'
186 186
 					),
187 187
 				),
188
-				'help_tour' => array( 'Transactions_Overview_Help_Tour' ),
188
+				'help_tour' => array('Transactions_Overview_Help_Tour'),
189 189
 				/**
190 190
 				 * commented out because currently we are not displaying tips for transaction list table status but this
191 191
 				 * may change in a later iteration so want to keep the code for then.
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				'nav' => array(
198 198
 					'label' => __('View Transaction', 'event_espresso'),
199 199
 					'order' => 5,
200
-					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
200
+					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
201 201
 					'persistent' => FALSE
202 202
 					),
203 203
 				'help_tabs' => array(
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 						'filename' => 'transactions_view_transaction_primary_registrant_billing_information'
219 219
 					),
220 220
 				),
221
-				'qtips' => array( 'Transaction_Details_Tips' ),
222
-				'help_tour' => array( 'Transaction_Details_Help_Tour' ),
221
+				'qtips' => array('Transaction_Details_Tips'),
222
+				'help_tour' => array('Transaction_Details_Help_Tour'),
223 223
 				'metaboxes' => array('_transaction_details_metaboxes'),
224 224
 
225 225
 				'require_nonce' => FALSE
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 	protected function _add_screen_options() {}
235 235
 	protected function _add_feature_pointers() {}
236 236
 	public function admin_init() {
237
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' );
238
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
239
-		EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status;
240
-		EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status;
237
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso');
238
+		EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', 'event_espresso');
239
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
240
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
241 241
 	}
242 242
 	public function admin_notices() {}
243 243
 	public function admin_footer_scripts() {}
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	public function load_scripts_styles() {
306 306
 		//enqueue style
307
-		wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION );
307
+		wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION);
308 308
 		wp_enqueue_style('espresso_txn');
309 309
 
310 310
 		//scripts
311 311
 		add_filter('FHEE_load_accounting_js', '__return_true');
312 312
 
313 313
 		//scripts
314
-		wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
314
+		wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
315 315
 		wp_enqueue_script('espresso_txn');
316 316
 
317 317
 	}
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 	 *	@return void
352 352
 	 */
353 353
 	protected function _set_list_table_views_default() {
354
-		$this->_views = array (
355
-			'all' => array (
354
+		$this->_views = array(
355
+			'all' => array(
356 356
 				'slug' 		=> 'all',
357 357
 				'label' 		=> __('View All Transactions', 'event_espresso'),
358 358
 				'count' 	=> 0
@@ -380,20 +380,20 @@  discard block
 block discarded – undo
380 380
 	 *	@return void
381 381
 	 */
382 382
 	private function _set_transaction_object() {
383
-		if ( is_object( $this->_transaction) )
383
+		if (is_object($this->_transaction))
384 384
 			return; //get out we've already set the object
385 385
 
386 386
 	    $TXN = EEM_Transaction::instance();
387 387
 
388
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
388
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
389 389
 
390 390
 	    //get transaction object
391 391
 	    $this->_transaction = $TXN->get_one_by_ID($TXN_ID);
392
-	    $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL;
392
+	    $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL;
393 393
 
394
-	 	if ( empty( $this->_transaction ) ) {
395
-	    	$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID .  __(' could not be retrieved.', 'event_espresso');
396
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
394
+	 	if (empty($this->_transaction)) {
395
+	    	$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.__(' could not be retrieved.', 'event_espresso');
396
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
397 397
 	    }
398 398
 	}
399 399
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 				),
420 420
 				'view_receipt' => array(
421 421
 					'class' => 'dashicons dashicons-media-default',
422
-					'desc' => __('View Transaction Receipt', 'event_espresso' )
422
+					'desc' => __('View Transaction Receipt', 'event_espresso')
423 423
 				),
424 424
 				'view_registration' => array(
425 425
 					'class' => 'dashicons dashicons-clipboard',
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
 			)
429 429
 		);
430 430
 
431
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) {
431
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
432 432
 
433
-			EE_Registry::instance()->load_helper( 'MSG_Template' );
434
-			if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) {
433
+			EE_Registry::instance()->load_helper('MSG_Template');
434
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
435 435
 				$items['send_payment_reminder'] = array(
436 436
 					'class' => 'dashicons dashicons-email-alt',
437 437
 					'desc' => __('Send Payment Reminder', 'event_espresso')
@@ -452,29 +452,29 @@  discard block
 block discarded – undo
452 452
 			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
453 453
 			array(
454 454
 				'overpaid'   => array(
455
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
456
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' )
455
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
456
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence')
457 457
 				),
458 458
 				'complete'   => array(
459
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
460
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' )
459
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
460
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence')
461 461
 				),
462 462
 				'incomplete' => array(
463
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
464
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' )
463
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
464
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence')
465 465
 				),
466 466
 				'abandoned'  => array(
467
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
468
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' )
467
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
468
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence')
469 469
 				),
470 470
 				'failed'     => array(
471
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
472
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' )
471
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
472
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence')
473 473
 				)
474 474
 			)
475 475
 		);
476 476
 
477
-		return array_merge( $items, $more_items);
477
+		return array_merge($items, $more_items);
478 478
 	}
479 479
 
480 480
 
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
 	 */
488 488
 	protected function _transactions_overview_list_table() {
489 489
 		$this->_admin_page_title = __('Transactions', 'event_espresso');
490
-		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL;
491
-		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : '';
492
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() );
490
+		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL;
491
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : '';
492
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
493 493
 		$this->display_admin_list_table_page_with_no_sidebar();
494 494
 	}
495 495
 
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
 	*	@return void
504 504
 	*/
505 505
 	protected function _transaction_details() {
506
-		do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction );
507
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
506
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
507
+		EE_Registry::instance()->load_helper('MSG_Template');
508 508
 
509 509
 		$this->_set_transaction_status_array();
510 510
 
@@ -517,75 +517,75 @@  discard block
 block discarded – undo
517 517
 		$attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL;
518 518
 
519 519
 		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
520
-		$this->_template_args['txn_nmbr']['label'] = __( 'Transaction Number', 'event_espresso' );
520
+		$this->_template_args['txn_nmbr']['label'] = __('Transaction Number', 'event_espresso');
521 521
 
522
-		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a' );
523
-		$this->_template_args['txn_datetime']['label'] = __( 'Date', 'event_espresso' );
522
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a');
523
+		$this->_template_args['txn_datetime']['label'] = __('Date', 'event_espresso');
524 524
 
525
-		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
526
-		$this->_template_args['txn_status']['label'] = __( 'Transaction Status', 'event_espresso' );
527
-		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
525
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
526
+		$this->_template_args['txn_status']['label'] = __('Transaction Status', 'event_espresso');
527
+		$this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
528 528
 
529 529
 		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
530 530
 		$this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
531 531
 
532
-		if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) {
533
-			EE_Registry::instance()->load_helper( 'MSG_Template' );
534
-			$this->_template_args['send_payment_reminder_button'] = EEH_MSG_Template::is_mt_active( 'payment_reminder' )
532
+		if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
533
+			EE_Registry::instance()->load_helper('MSG_Template');
534
+			$this->_template_args['send_payment_reminder_button'] = EEH_MSG_Template::is_mt_active('payment_reminder')
535 535
 				 && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code
536 536
 				 && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code
537
-				 ? EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'send_payment_reminder', 'TXN_ID'=>$this->_transaction->ID(), 'redirect_to' => 'view_transaction' ), TXN_ADMIN_URL ), __(' Send Payment Reminder'), 'button secondary-button right',  'dashicons dashicons-email-alt' )
537
+				 ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=>'send_payment_reminder', 'TXN_ID'=>$this->_transaction->ID(), 'redirect_to' => 'view_transaction'), TXN_ADMIN_URL), __(' Send Payment Reminder'), 'button secondary-button right', 'dashicons dashicons-email-alt')
538 538
 				 : '';
539 539
 		} else {
540 540
 			$this->_template_args['send_payment_reminder_button'] = '';
541 541
 		}
542 542
 
543 543
 		$amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
544
-		$this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE );
545
-		if ( EE_Registry::instance()->CFG->currency->sign_b4 ) {
546
-			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
544
+		$this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE);
545
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
546
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due'];
547 547
 		} else {
548
-			$this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
548
+			$this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign;
549 549
 		}
550
-		$this->_template_args['amount_due_class'] =  '';
550
+		$this->_template_args['amount_due_class'] = '';
551 551
 
552
-		if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) {
552
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
553 553
 			// paid in full
554
-			$this->_template_args['amount_due'] =  FALSE;
555
-		} elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) {
554
+			$this->_template_args['amount_due'] = FALSE;
555
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
556 556
 			// overpaid
557
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
558
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) {
557
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
558
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) {
559 559
 			// monies owing
560
-			$this->_template_args['amount_due_class'] =  'txn-overview-part-payment-spn';
561
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) {
560
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
561
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) {
562 562
 			// no payments made yet
563
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
564
-		} elseif ( $this->_transaction->get('TXN_total') == 0 ) {
563
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
564
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
565 565
 			// free event
566
-			$this->_template_args['amount_due'] =  FALSE;
566
+			$this->_template_args['amount_due'] = FALSE;
567 567
 		}
568 568
 
569 569
 		$payment_method = $this->_transaction->payment_method();
570 570
 
571
-		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' );
571
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso');
572 572
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
573 573
 		// link back to overview
574
-		$this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : TXN_ADMIN_URL;
574
+		$this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : TXN_ADMIN_URL;
575 575
 
576 576
 
577 577
 		//next and previous links
578
-		$next_txn = $this->_transaction->next(null, array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), 'TXN_ID' );
579
-		$this->_template_args['next_transaction'] = $next_txn ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ), TXN_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : '';
580
-		$previous_txn = $this->_transaction->previous( null, array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), 'TXN_ID' );
581
-		$this->_template_args['previous_transaction'] = $previous_txn ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ), TXN_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : '';
578
+		$next_txn = $this->_transaction->next(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
579
+		$this->_template_args['next_transaction'] = $next_txn ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
580
+		$previous_txn = $this->_transaction->previous(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
581
+		$this->_template_args['previous_transaction'] = $previous_txn ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
582 582
 
583 583
 
584 584
 		// grab messages at the last second
585 585
 		$this->_template_args['notices'] = EE_Error::get_notices();
586 586
 		// path to template
587
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
588
-		$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
587
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
588
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
589 589
 
590 590
 		// the details template wrapper
591 591
 		$this->display_admin_page_with_sidebar();
@@ -604,18 +604,18 @@  discard block
 block discarded – undo
604 604
 
605 605
 		$this->_set_transaction_object();
606 606
 
607
-		add_meta_box( 'edit-txn-details-mbox', __( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' );
607
+		add_meta_box('edit-txn-details-mbox', __('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high');
608 608
 		add_meta_box(
609 609
 			'edit-txn-attendees-mbox',
610
-			__( 'Attendees Registered in this Transaction', 'event_espresso' ),
611
-			array( $this, 'txn_attendees_meta_box' ),
610
+			__('Attendees Registered in this Transaction', 'event_espresso'),
611
+			array($this, 'txn_attendees_meta_box'),
612 612
 			$this->_wp_page_slug,
613 613
 			'normal',
614 614
 			'high',
615
-			array( 'TXN_ID' => $this->_transaction->ID() )
615
+			array('TXN_ID' => $this->_transaction->ID())
616 616
 		);
617
-		add_meta_box( 'edit-txn-registrant-mbox', __( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
618
-		add_meta_box( 'edit-txn-billing-info-mbox', __( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
617
+		add_meta_box('edit-txn-registrant-mbox', __('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
618
+		add_meta_box('edit-txn-billing-info-mbox', __('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
619 619
 
620 620
 	}
621 621
 
@@ -636,15 +636,15 @@  discard block
 block discarded – undo
636 636
 
637 637
 		//get line table
638 638
 		EEH_Autoloader::register_line_item_display_autoloaders();
639
-		$Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' );
640
-		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() );
639
+		$Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy');
640
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
641 641
 		$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
642 642
 
643 643
 		// process taxes
644
-		$taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax )));
645
-		$this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE;
644
+		$taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
645
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE;
646 646
 
647
-		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE );
647
+		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
648 648
 		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
649 649
 		$this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
650 650
 
@@ -652,63 +652,63 @@  discard block
 block discarded – undo
652 652
 
653 653
 		// process payment details
654 654
 		$payments = $this->_transaction->get_many_related('Payment');
655
-		if( ! empty(  $payments ) ) {
656
-			$this->_template_args[ 'payments' ] = $payments;
657
-			$this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments );
655
+		if ( ! empty($payments)) {
656
+			$this->_template_args['payments'] = $payments;
657
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
658 658
 		} else {
659
-			$this->_template_args[ 'payments' ] = false;
660
-			$this->_template_args[ 'existing_reg_payments' ] = array();
659
+			$this->_template_args['payments'] = false;
660
+			$this->_template_args['existing_reg_payments'] = array();
661 661
 		}
662 662
 
663
-		$this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment'  ), TXN_ADMIN_URL );
664
-		$this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL );
663
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
664
+		$this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
665 665
 
666
-		if ( isset( $txn_details['invoice_number'] )) {
666
+		if (isset($txn_details['invoice_number'])) {
667 667
 			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
668
-			$this->_template_args['txn_details']['invoice_number']['label'] = __( 'Invoice Number', 'event_espresso' );
668
+			$this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
669 669
 		}
670 670
 
671 671
 		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
672
-		$this->_template_args['txn_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' );
672
+		$this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
673 673
 
674
-		$this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '';
675
-		$this->_template_args['txn_details']['ip_address']['label'] = __( 'Transaction placed from IP', 'event_espresso' );
674
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
675
+		$this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso');
676 676
 
677
-		$this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '';
678
-		$this->_template_args['txn_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' );
677
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
678
+		$this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
679 679
 
680 680
 		$reg_steps = '<ul>';
681
-		foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) {
682
-			if ( $reg_step_status === true ) {
683
-				$reg_steps .= '<li style="color:#70cc50">' . sprintf( __( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
684
-			} else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) {
685
-					$reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
686
-							__( '%1$s : Initiated %2$s', 'event_espresso' ),
687
-							ucwords( str_replace( '_', ' ', $reg_step ) ),
688
-							gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) )
689
-						) . '</li>';
681
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
682
+			if ($reg_step_status === true) {
683
+				$reg_steps .= '<li style="color:#70cc50">'.sprintf(__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
684
+			} else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
685
+					$reg_steps .= '<li style="color:#2EA2CC">'.sprintf(
686
+							__('%1$s : Initiated %2$s', 'event_espresso'),
687
+							ucwords(str_replace('_', ' ', $reg_step)),
688
+							gmdate(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
689
+						).'</li>';
690 690
 				} else {
691
-				$reg_steps .= '<li style="color:#E76700">' . sprintf( __( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
691
+				$reg_steps .= '<li style="color:#E76700">'.sprintf(__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
692 692
 			}
693 693
 		}
694 694
 		$reg_steps .= '</ul>';
695 695
 		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
696
-		$this->_template_args['txn_details']['reg_steps']['label'] = __( 'Registration Step Progress', 'event_espresso' );
696
+		$this->_template_args['txn_details']['reg_steps']['label'] = __('Registration Step Progress', 'event_espresso');
697 697
 
698 698
 
699 699
 		$this->_get_registrations_to_apply_payment_to();
700
-		$this->_get_payment_methods( $payments );
700
+		$this->_get_payment_methods($payments);
701 701
 		$this->_get_payment_status_array();
702 702
 		$this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
703 703
 
704
-		$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction'  ), TXN_ADMIN_URL );
705
-		$this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL );
706
-		$this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL );
704
+		$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
705
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
706
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
707 707
 
708 708
 		// 'espresso_delete_payment_nonce'
709 709
 
710
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
711
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
710
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
711
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
712 712
 
713 713
 	}
714 714
 
@@ -723,27 +723,27 @@  discard block
 block discarded – undo
723 723
 	 * @param EE_Payment[] $payments
724 724
 	 * @return array
725 725
 	 */
726
-	protected function _get_registration_payment_IDs( $payments = array() ) {
726
+	protected function _get_registration_payment_IDs($payments = array()) {
727 727
 		$existing_reg_payments = array();
728 728
 		// get all reg payments for these payments
729
-		$reg_payments = EEM_Registration_Payment::instance()->get_all( array(
729
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(array(
730 730
 			array(
731 731
 				'PAY_ID' => array(
732 732
 					'IN',
733
-					array_keys( $payments )
733
+					array_keys($payments)
734 734
 				)
735 735
 			)
736
-		) );
737
-		if ( ! empty( $reg_payments ) ) {
738
-			foreach ( $payments as $payment ) {
739
-				if ( ! $payment instanceof EE_Payment ) {
736
+		));
737
+		if ( ! empty($reg_payments)) {
738
+			foreach ($payments as $payment) {
739
+				if ( ! $payment instanceof EE_Payment) {
740 740
 					continue;
741
-				} else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) {
742
-					$existing_reg_payments[ $payment->ID() ] = array();
741
+				} else if ( ! isset($existing_reg_payments[$payment->ID()])) {
742
+					$existing_reg_payments[$payment->ID()] = array();
743 743
 				}
744
-				foreach ( $reg_payments as $reg_payment ) {
745
-					if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) {
746
-						$existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID();
744
+				foreach ($reg_payments as $reg_payment) {
745
+					if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) {
746
+						$existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
747 747
 					}
748 748
 				}
749 749
 			}
@@ -780,39 +780,39 @@  discard block
 block discarded – undo
780 780
 		$registrations_to_apply_payment_to .= '<br /><div class="admin-primary-mbox-tbl-wrap">';
781 781
 		$registrations_to_apply_payment_to .= '<table class="admin-primary-mbox-tbl">';
782 782
 		$registrations_to_apply_payment_to .= '<thead><tr>';
783
-		$registrations_to_apply_payment_to .= '<td>' . __( 'ID', 'event_espresso' ) . '</td>';
784
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Registrant', 'event_espresso' ) . '</td>';
785
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Ticket', 'event_espresso' ) . '</td>';
786
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Event', 'event_espresso' ) . '</td>';
787
-		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">' . __( 'Paid', 'event_espresso' ) . '</td>';
788
-		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">' . __( 'Owing', 'event_espresso' ) . '</td>';
789
-		$registrations_to_apply_payment_to .= '<td class="jst-cntr">' . __( 'Apply', 'event_espresso' ) . '</td>';
783
+		$registrations_to_apply_payment_to .= '<td>'.__('ID', 'event_espresso').'</td>';
784
+		$registrations_to_apply_payment_to .= '<td>'.__('Registrant', 'event_espresso').'</td>';
785
+		$registrations_to_apply_payment_to .= '<td>'.__('Ticket', 'event_espresso').'</td>';
786
+		$registrations_to_apply_payment_to .= '<td>'.__('Event', 'event_espresso').'</td>';
787
+		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">'.__('Paid', 'event_espresso').'</td>';
788
+		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">'.__('Owing', 'event_espresso').'</td>';
789
+		$registrations_to_apply_payment_to .= '<td class="jst-cntr">'.__('Apply', 'event_espresso').'</td>';
790 790
 		$registrations_to_apply_payment_to .= '</tr></thead><tbody>';
791 791
 		// get registrations for TXN
792
-		$registrations = $this->_transaction->registrations( $query_params );
793
-		foreach ( $registrations as $registration ) {
794
-			if ( $registration instanceof EE_Registration ) {
792
+		$registrations = $this->_transaction->registrations($query_params);
793
+		foreach ($registrations as $registration) {
794
+			if ($registration instanceof EE_Registration) {
795 795
 				$owing = $registration->final_price() - $registration->paid();
796
-				$taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> ' . __( '+ tax', 'event_espresso' ) . '</span>' : '';
797
-				$checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments ) ? ' checked="checked"' : '';
798
-				$registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-' . $registration->ID() . '">';
796
+				$taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> '.__('+ tax', 'event_espresso').'</span>' : '';
797
+				$checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) ? ' checked="checked"' : '';
798
+				$registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-'.$registration->ID().'">';
799 799
 				// add html for checkbox input and label
800
-				$registrations_to_apply_payment_to .= '<td>' . $registration->ID() . '</td>';
801
-				$registrations_to_apply_payment_to .= '<td>' . $registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ) . '</td>';
802
-				$registrations_to_apply_payment_to .= '<td>' . $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable . '</td>';
803
-				$registrations_to_apply_payment_to .= '<td>' . $registration->event_name() . '</td>';
804
-				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">' . $registration->pretty_paid() . '</td>';
805
-				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">' . EEH_Template::format_currency( $owing ) . '</td>';
800
+				$registrations_to_apply_payment_to .= '<td>'.$registration->ID().'</td>';
801
+				$registrations_to_apply_payment_to .= '<td>'.$registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __('Unknown Attendee', 'event_espresso').'</td>';
802
+				$registrations_to_apply_payment_to .= '<td>'.$registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable.'</td>';
803
+				$registrations_to_apply_payment_to .= '<td>'.$registration->event_name().'</td>';
804
+				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">'.$registration->pretty_paid().'</td>';
805
+				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">'.EEH_Template::format_currency($owing).'</td>';
806 806
 				$registrations_to_apply_payment_to .= '<td class="jst-cntr">';
807 807
 				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
808
-				$registrations_to_apply_payment_to .= '<input type="checkbox" value="' . $registration->ID() . '" name="txn_admin_payment[registrations]"' . $checked . $disabled . '>';
808
+				$registrations_to_apply_payment_to .= '<input type="checkbox" value="'.$registration->ID().'" name="txn_admin_payment[registrations]"'.$checked.$disabled.'>';
809 809
 				$registrations_to_apply_payment_to .= '</td>';
810 810
 				$registrations_to_apply_payment_to .= '</tr>';
811 811
 			}
812 812
 		}
813 813
 		$registrations_to_apply_payment_to .= '</tbody></table></div>';
814
-		$registrations_to_apply_payment_to .= '<p class="clear description">' . __( 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso' ) . '</p></div>';
815
-		$this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to;
814
+		$registrations_to_apply_payment_to .= '<p class="clear description">'.__('The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso').'</p></div>';
815
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
816 816
 	}
817 817
 
818 818
 
@@ -829,9 +829,9 @@  discard block
 block discarded – undo
829 829
 		$statuses = EEM_Registration::reg_status_array(array(), TRUE);
830 830
 		//let's add a "don't change" option.
831 831
 		$status_array['NAN'] = __('Leave the Same', 'event_espresso');
832
-		$status_array = array_merge( $status_array, $statuses );
833
-		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' );
834
-		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' );
832
+		$status_array = array_merge($status_array, $statuses);
833
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status');
834
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status');
835 835
 
836 836
 	}
837 837
 
@@ -846,21 +846,21 @@  discard block
 block discarded – undo
846 846
 	 * @param EE_Payment[] to show on this page
847 847
 	 *	@return void
848 848
 	 */
849
-	private function _get_payment_methods( $payments = array() ) {
849
+	private function _get_payment_methods($payments = array()) {
850 850
 		$payment_methods_of_payments = array();
851
-		foreach( $payments as $payment ){
852
-			if( $payment instanceof EE_Payment ){
853
-				$payment_methods_of_payments[] = $payment->get( 'PMD_ID' );
851
+		foreach ($payments as $payment) {
852
+			if ($payment instanceof EE_Payment) {
853
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
854 854
 			}
855 855
 		}
856
-		if( $payment_methods_of_payments ){
857
-			$query_args = array( array( 'OR*payment_method_for_payment' => array(
858
-					'PMD_ID' => array( 'IN', $payment_methods_of_payments ),
859
-					'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) );
860
-		}else{
861
-			$query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) );
856
+		if ($payment_methods_of_payments) {
857
+			$query_args = array(array('OR*payment_method_for_payment' => array(
858
+					'PMD_ID' => array('IN', $payment_methods_of_payments),
859
+					'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') )));
860
+		} else {
861
+			$query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
862 862
 		}
863
-		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args );
863
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
864 864
 	}
865 865
 
866 866
 
@@ -874,46 +874,46 @@  discard block
 block discarded – undo
874 874
 	 * @param array $metabox
875 875
 	 * @return void
876 876
 	 */
877
-	public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) {
877
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array())) {
878 878
 
879
-		extract( $metabox['args'] );
879
+		extract($metabox['args']);
880 880
 		$this->_template_args['post'] = $post;
881 881
 		$this->_template_args['event_attendees'] = array();
882 882
 		// process items in cart
883
-		$line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) );
884
-		if ( ! empty( $line_items )) {
885
-			foreach ( $line_items as $item ) {
886
-				if ( $item instanceof EE_Line_Item ) {
887
-					switch( $item->OBJ_type() ) {
883
+		$line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
884
+		if ( ! empty($line_items)) {
885
+			foreach ($line_items as $item) {
886
+				if ($item instanceof EE_Line_Item) {
887
+					switch ($item->OBJ_type()) {
888 888
 
889 889
 						case 'Event' :
890 890
 							break;
891 891
 
892 892
 						case 'Ticket' :
893 893
 							$ticket = $item->ticket();
894
-							if ( empty( $ticket )) {
894
+							if (empty($ticket)) {
895 895
 								continue; //right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
896 896
 							}
897
-							$ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ));
897
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
898 898
 							$event = $ticket->get_first_related('Registration')->get_first_related('Event');
899
-							$event_name = $event instanceof EE_Event ? $event->get('EVT_name') . ' - ' . $item->get('LIN_name') : '';
899
+							$event_name = $event instanceof EE_Event ? $event->get('EVT_name').' - '.$item->get('LIN_name') : '';
900 900
 
901
-							$registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() )));
902
-							foreach( $registrations as $registration ) {
903
-								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] 						= $registration->get('REG_count');
904
-								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] 	= $event_name;
905
-								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] 				= $ticket_price;
901
+							$registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID())));
902
+							foreach ($registrations as $registration) {
903
+								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->get('REG_count');
904
+								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
905
+								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price;
906 906
 								// attendee info
907 907
 								$attendee = $registration->get_first_related('Attendee');
908
-								if ( $attendee instanceof EE_Attendee ) {
908
+								if ($attendee instanceof EE_Attendee) {
909 909
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 			= $attendee->ID();
910 910
 									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= $attendee->full_name();
911
-									$this->_template_args['event_attendees'][$registration->ID()]['email'] 			= '<a href="mailto:' . $attendee->email() . '?subject=' . $event->get('EVT_name') . __(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>';
912
-									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		=  implode(',<br>', $attendee->full_address_as_array() );
911
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event->get('EVT_name').__(' Event', 'event_espresso').'">'.$attendee->email().'</a>';
912
+									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		= implode(',<br>', $attendee->full_address_as_array());
913 913
 								} else {
914 914
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 			= '';
915 915
 									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= '';
916
-									$this->_template_args['event_attendees'][$registration->ID()]['email'] 			= '';
916
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '';
917 917
 									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		= '';
918 918
 								}
919 919
 							}
@@ -923,12 +923,12 @@  discard block
 block discarded – undo
923 923
 				}
924 924
 			}
925 925
 
926
-			$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees'  ), TXN_ADMIN_URL );
927
-			echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE );
926
+			$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL);
927
+			echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE);
928 928
 
929 929
 		} else {
930 930
 			echo sprintf(
931
-				__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ),
931
+				__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'),
932 932
 				'<p class="important-notice">',
933 933
 				'</p>'
934 934
 			);
@@ -947,20 +947,20 @@  discard block
 block discarded – undo
947 947
 	 */
948 948
 	public function txn_registrant_side_meta_box() {
949 949
 		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
950
-		if ( ! $primary_att instanceof EE_Attendee ) {
950
+		if ( ! $primary_att instanceof EE_Attendee) {
951 951
 			$this->_template_args['no_attendee_message'] = __('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.', 'event_espresso');
952 952
 			$primary_att = EEM_Attendee::instance()->create_default_object();
953 953
 		}
954
-		$this->_template_args['ATT_ID'] 						= $primary_att->ID();
954
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
955 955
 		$this->_template_args['prime_reg_fname']		= $primary_att->fname();
956 956
 		$this->_template_args['prime_reg_lname']		= $primary_att->lname();
957
-		$this->_template_args['prime_reg_email'] 		= $primary_att->email();
957
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
958 958
 		$this->_template_args['prime_reg_phone'] 	= $primary_att->phone();
959
-		$this->_template_args['edit_attendee_url'] 	= EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID()  ), REG_ADMIN_URL );
959
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL);
960 960
 		// get formatted address for registrant
961
-		EE_Registry::instance()->load_helper( 'Formatter' );
962
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att );
963
-		echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE );
961
+		EE_Registry::instance()->load_helper('Formatter');
962
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
963
+		echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE);
964 964
 	}
965 965
 
966 966
 
@@ -976,12 +976,12 @@  discard block
 block discarded – undo
976 976
 
977 977
 		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
978 978
 		$this->_template_args['billing_form_url'] = add_query_arg(
979
-			array( 'action' => 'edit_transaction', 'process' => 'billing'  ),
979
+			array('action' => 'edit_transaction', 'process' => 'billing'),
980 980
 			TXN_ADMIN_URL
981 981
 		);
982 982
 
983
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
984
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/
983
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
984
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/
985 985
 	}
986 986
 
987 987
 
@@ -994,43 +994,43 @@  discard block
 block discarded – undo
994 994
 	*	@return void
995 995
 	*/
996 996
 	public function apply_payments_or_refunds() {
997
-		$json_response_data = array( 'return_data' => FALSE );
997
+		$json_response_data = array('return_data' => FALSE);
998 998
 		$valid_data = $this->_validate_payment_request_data();
999
-		if ( ! empty( $valid_data ) ) {
1000
-			$PAY_ID = $valid_data[ 'PAY_ID' ];
999
+		if ( ! empty($valid_data)) {
1000
+			$PAY_ID = $valid_data['PAY_ID'];
1001 1001
 			//save  the new payment
1002
-			$payment = $this->_create_payment_from_request_data( $valid_data );
1002
+			$payment = $this->_create_payment_from_request_data($valid_data);
1003 1003
 			// get the TXN for this payment
1004 1004
 			$transaction = $payment->transaction();
1005 1005
 			// verify transaction
1006
-			if ( $transaction instanceof EE_Transaction ) {
1006
+			if ($transaction instanceof EE_Transaction) {
1007 1007
 				// calculate_total_payments_and_update_status
1008
-				$this->_process_transaction_payments( $transaction );
1009
-				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment );
1010
-				$this->_remove_existing_registration_payments( $payment, $PAY_ID );
1008
+				$this->_process_transaction_payments($transaction);
1009
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1010
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1011 1011
 				// apply payment to registrations (if applicable)
1012
-				if ( ! empty( $REG_IDs ) ) {
1013
-					$this->_update_registration_payments( $transaction, $payment, $REG_IDs );
1012
+				if ( ! empty($REG_IDs)) {
1013
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1014 1014
 					$this->_maybe_send_notifications();
1015 1015
 					// now process status changes for the same registrations
1016
-					$this->_process_registration_status_change( $transaction, $REG_IDs );
1016
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1017 1017
 				}
1018
-				$this->_maybe_send_notifications( $payment );
1018
+				$this->_maybe_send_notifications($payment);
1019 1019
 				//prepare to render page
1020
-				$json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs );
1021
-				do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment );
1020
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1021
+				do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment);
1022 1022
 			} else {
1023 1023
 				EE_Error::add_error(
1024
-					__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ),
1024
+					__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'),
1025 1025
 					__FILE__, __FUNCTION__, __LINE__
1026 1026
 				);
1027 1027
 			}
1028 1028
 		} else {
1029
-			EE_Error::add_error( __( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1029
+			EE_Error::add_error(__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1030 1030
 		}
1031 1031
 
1032
-		$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
1033
-		echo json_encode( array_merge( $json_response_data, $notices ));
1032
+		$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
1033
+		echo json_encode(array_merge($json_response_data, $notices));
1034 1034
 		die();
1035 1035
 	}
1036 1036
 
@@ -1042,30 +1042,30 @@  discard block
 block discarded – undo
1042 1042
 	 * @return array
1043 1043
 	 */
1044 1044
 	protected function _validate_payment_request_data() {
1045
-		if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) {
1045
+		if ( ! isset($this->_req_data['txn_admin_payment'])) {
1046 1046
 			return false;
1047 1047
 		}
1048 1048
 		$payment_form = $this->_generate_payment_form_section();
1049 1049
 		try {
1050
-			if ( $payment_form->was_submitted() ) {
1050
+			if ($payment_form->was_submitted()) {
1051 1051
 				$payment_form->receive_form_submission();
1052
-				if ( ! $payment_form->is_valid() ) {
1052
+				if ( ! $payment_form->is_valid()) {
1053 1053
 					$submission_error_messages = array();
1054
-					foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) {
1055
-						if ( $validation_error instanceof EE_Validation_Error ) {
1054
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1055
+						if ($validation_error instanceof EE_Validation_Error) {
1056 1056
 							$submission_error_messages[] = sprintf(
1057
-								_x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ),
1057
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1058 1058
 								$validation_error->get_form_section()->html_label_text(),
1059 1059
 								$validation_error->getMessage()
1060 1060
 							);
1061 1061
 						}
1062 1062
 					}
1063
-					EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
1063
+					EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1064 1064
 					return array();
1065 1065
 				}
1066 1066
 			}
1067
-		} catch ( EE_Error $e ) {
1068
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
1067
+		} catch (EE_Error $e) {
1068
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1069 1069
 			return array();
1070 1070
 		}
1071 1071
 		return $payment_form->valid_data();
@@ -1087,63 +1087,63 @@  discard block
 block discarded – undo
1087 1087
 						array(
1088 1088
 							'default' => 0,
1089 1089
 							'required' => false,
1090
-							'html_label_text' => __( 'Payment ID', 'event_espresso' ),
1091
-							'validation_strategies' => array( new EE_Int_Normalization() )
1090
+							'html_label_text' => __('Payment ID', 'event_espresso'),
1091
+							'validation_strategies' => array(new EE_Int_Normalization())
1092 1092
 						)
1093 1093
 					),
1094 1094
 					'TXN_ID' => new EE_Text_Input(
1095 1095
 						array(
1096 1096
 							'default' => 0,
1097 1097
 							'required' => true,
1098
-							'html_label_text' => __( 'Transaction ID', 'event_espresso' ),
1099
-							'validation_strategies' => array( new EE_Int_Normalization() )
1098
+							'html_label_text' => __('Transaction ID', 'event_espresso'),
1099
+							'validation_strategies' => array(new EE_Int_Normalization())
1100 1100
 						)
1101 1101
 					),
1102 1102
 					'type' => new EE_Text_Input(
1103 1103
 						array(
1104 1104
 							'default' => 1,
1105 1105
 							'required' => true,
1106
-							'html_label_text' => __( 'Payment or Refund', 'event_espresso' ),
1107
-							'validation_strategies' => array( new EE_Int_Normalization() )
1106
+							'html_label_text' => __('Payment or Refund', 'event_espresso'),
1107
+							'validation_strategies' => array(new EE_Int_Normalization())
1108 1108
 						)
1109 1109
 					),
1110 1110
 					'amount' => new EE_Text_Input(
1111 1111
 						array(
1112 1112
 							'default' => 0,
1113 1113
 							'required' => true,
1114
-							'html_label_text' => __( 'Payment amount', 'event_espresso' ),
1115
-							'validation_strategies' => array( new EE_Float_Normalization() )
1114
+							'html_label_text' => __('Payment amount', 'event_espresso'),
1115
+							'validation_strategies' => array(new EE_Float_Normalization())
1116 1116
 						)
1117 1117
 					),
1118 1118
 					'status' => new EE_Text_Input(
1119 1119
 						array(
1120 1120
 							'default' => EEM_Payment::status_id_approved,
1121 1121
 							'required' => true,
1122
-							'html_label_text' => __( 'Payment status', 'event_espresso' ),
1122
+							'html_label_text' => __('Payment status', 'event_espresso'),
1123 1123
 						)
1124 1124
 					),
1125 1125
 					'PMD_ID' => new EE_Text_Input(
1126 1126
 						array(
1127 1127
 							'default' => 2,
1128 1128
 							'required' => true,
1129
-							'html_label_text' => __( 'Payment Method', 'event_espresso' ),
1130
-							'validation_strategies' => array( new EE_Int_Normalization() )
1129
+							'html_label_text' => __('Payment Method', 'event_espresso'),
1130
+							'validation_strategies' => array(new EE_Int_Normalization())
1131 1131
 						)
1132 1132
 					),
1133 1133
 					'date' => new EE_Text_Input(
1134 1134
 						array(
1135 1135
 							'default' => time(),
1136 1136
 							'required' => true,
1137
-							'html_label_text' => __( 'Payment date', 'event_espresso' ),
1137
+							'html_label_text' => __('Payment date', 'event_espresso'),
1138 1138
 						)
1139 1139
 					),
1140 1140
 					'txn_id_chq_nmbr' => new EE_Text_Input(
1141 1141
 						array(
1142 1142
 							'default' => '',
1143 1143
 							'required' => false,
1144
-							'html_label_text' => __( 'Transaction or Cheque Number', 'event_espresso' ),
1144
+							'html_label_text' => __('Transaction or Cheque Number', 'event_espresso'),
1145 1145
                                                         'validation_strategies' => array(
1146
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1146
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1147 1147
                                                         )
1148 1148
 						)
1149 1149
 					),
@@ -1151,9 +1151,9 @@  discard block
 block discarded – undo
1151 1151
 						array(
1152 1152
 							'default' => '',
1153 1153
 							'required' => false,
1154
-							'html_label_text' => __( 'Purchase Order Number', 'event_espresso' ),
1154
+							'html_label_text' => __('Purchase Order Number', 'event_espresso'),
1155 1155
                                                         'validation_strategies' => array(
1156
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1156
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1157 1157
                                                         )
1158 1158
 						)
1159 1159
 					),
@@ -1161,9 +1161,9 @@  discard block
 block discarded – undo
1161 1161
 						array(
1162 1162
 							'default' => '',
1163 1163
 							'required' => false,
1164
-							'html_label_text' => __( 'Extra Field for Accounting', 'event_espresso' ),
1164
+							'html_label_text' => __('Extra Field for Accounting', 'event_espresso'),
1165 1165
                                                         'validation_strategies' => array(
1166
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1166
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1167 1167
                                                         )
1168 1168
 						)
1169 1169
 					),
@@ -1180,34 +1180,34 @@  discard block
 block discarded – undo
1180 1180
 	 * @param array $valid_data
1181 1181
 	 * @return EE_Payment
1182 1182
 	 */
1183
-	protected function _create_payment_from_request_data( $valid_data ) {
1184
-		$PAY_ID = $valid_data[ 'PAY_ID' ];
1183
+	protected function _create_payment_from_request_data($valid_data) {
1184
+		$PAY_ID = $valid_data['PAY_ID'];
1185 1185
 		// get payment amount
1186
-		$amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0;
1186
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1187 1187
 		// payments have a type value of 1 and refunds have a type value of -1
1188 1188
 		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1189
-		$amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount;
1189
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1190 1190
 		$payment = EE_Payment::new_instance(
1191 1191
 			array(
1192
-				'TXN_ID' 								=> $valid_data[ 'TXN_ID' ],
1193
-				'STS_ID' 								=> $valid_data[ 'status' ],
1194
-				'PAY_timestamp' 				=> $valid_data[ 'date' ],
1192
+				'TXN_ID' 								=> $valid_data['TXN_ID'],
1193
+				'STS_ID' 								=> $valid_data['status'],
1194
+				'PAY_timestamp' 				=> $valid_data['date'],
1195 1195
 				'PAY_source'           			=> EEM_Payment_Method::scope_admin,
1196
-				'PMD_ID'               				=> $valid_data[ 'PMD_ID' ],
1196
+				'PMD_ID'               				=> $valid_data['PMD_ID'],
1197 1197
 				'PAY_amount'           			=> $amount,
1198
-				'PAY_txn_id_chq_nmbr'  	=> $valid_data[ 'txn_id_chq_nmbr' ],
1199
-				'PAY_po_number'        		=> $valid_data[ 'po_number' ],
1200
-				'PAY_extra_accntng'    		=> $valid_data[ 'accounting' ],
1198
+				'PAY_txn_id_chq_nmbr'  	=> $valid_data['txn_id_chq_nmbr'],
1199
+				'PAY_po_number'        		=> $valid_data['po_number'],
1200
+				'PAY_extra_accntng'    		=> $valid_data['accounting'],
1201 1201
 				'PAY_details'          				=> $valid_data,
1202 1202
 				'PAY_ID'               				=> $PAY_ID
1203 1203
 			),
1204 1204
 			'',
1205
-			array( 'Y-m-d', 'H:i a' )
1205
+			array('Y-m-d', 'H:i a')
1206 1206
 		);
1207
-		if ( ! $payment->save() ) {
1207
+		if ( ! $payment->save()) {
1208 1208
 			EE_Error::add_error(
1209 1209
 				sprintf(
1210
-					__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ),
1210
+					__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1211 1211
 					$payment->ID()
1212 1212
 				),
1213 1213
 				__FILE__, __FUNCTION__, __LINE__
@@ -1224,15 +1224,15 @@  discard block
 block discarded – undo
1224 1224
 	 * @param \EE_Transaction $transaction
1225 1225
 	 * @return array
1226 1226
 	 */
1227
-	protected function _process_transaction_payments( EE_Transaction $transaction ) {
1227
+	protected function _process_transaction_payments(EE_Transaction $transaction) {
1228 1228
 		/** @type EE_Transaction_Payments $transaction_payments */
1229
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1229
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1230 1230
 		//update the transaction with this payment
1231
-		if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) {
1232
-			EE_Error::add_success( __( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1231
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1232
+			EE_Error::add_success(__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1233 1233
 		} else {
1234 1234
 			EE_Error::add_error(
1235
-				__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' )
1235
+				__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso')
1236 1236
 				, __FILE__, __FUNCTION__, __LINE__
1237 1237
 			);
1238 1238
 		}
@@ -1248,19 +1248,19 @@  discard block
 block discarded – undo
1248 1248
 	 * @param \EE_Payment $payment
1249 1249
 	 * @return array
1250 1250
 	 */
1251
-	protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) {
1251
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) {
1252 1252
 		$REG_IDs = array();
1253 1253
 		// grab array of IDs for specific registrations to apply changes to
1254
-		if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) {
1255
-			$REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ];
1254
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1255
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1256 1256
 		}
1257 1257
 		//nothing specified ? then get all reg IDs
1258
-		if ( empty( $REG_IDs ) ) {
1258
+		if (empty($REG_IDs)) {
1259 1259
 			$registrations = $payment->transaction()->registrations();
1260
-			$REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment );
1260
+			$REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment);
1261 1261
 		}
1262 1262
 		// ensure that REG_IDs are integers and NOT strings
1263
-		return array_map( 'intval', $REG_IDs );
1263
+		return array_map('intval', $REG_IDs);
1264 1264
 	}
1265 1265
 
1266 1266
 
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 	/**
1278 1278
 	 * @param array $existing_reg_payment_REG_IDs
1279 1279
 	 */
1280
-	public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) {
1280
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) {
1281 1281
 		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1282 1282
 	}
1283 1283
 
@@ -1292,13 +1292,13 @@  discard block
 block discarded – undo
1292 1292
 	 * @param \EE_Payment $payment
1293 1293
 	 * @return array
1294 1294
 	 */
1295
-	protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) {
1296
-		if ( $this->existing_reg_payment_REG_IDs() === null ) {
1295
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) {
1296
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1297 1297
 			// let's get any existing reg payment records for this payment
1298
-			$existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' );
1298
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1299 1299
 			// but we only want the REG IDs, so grab the array keys
1300
-			$existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array();
1301
-			$this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs );
1300
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array();
1301
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1302 1302
 		}
1303 1303
 		return $this->existing_reg_payment_REG_IDs();
1304 1304
 	}
@@ -1317,23 +1317,23 @@  discard block
 block discarded – undo
1317 1317
 	 * @param int         $PAY_ID
1318 1318
 	 * @return bool;
1319 1319
 	 */
1320
-	protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) {
1320
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) {
1321 1321
 		// newly created payments will have nothing recorded for $PAY_ID
1322
-		if ( $PAY_ID == 0 ) {
1322
+		if ($PAY_ID == 0) {
1323 1323
 			return false;
1324 1324
 		}
1325
-		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1326
-		if ( empty( $existing_reg_payment_REG_IDs )) {
1325
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1326
+		if (empty($existing_reg_payment_REG_IDs)) {
1327 1327
 			return false;
1328 1328
 		}
1329 1329
 		/** @type EE_Transaction_Payments $transaction_payments */
1330
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1330
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1331 1331
 		return $transaction_payments->delete_registration_payments_and_update_registrations(
1332 1332
 			$payment,
1333 1333
 			array(
1334 1334
 				array(
1335 1335
 					'PAY_ID' => $payment->ID(),
1336
-					'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ),
1336
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1337 1337
 				)
1338 1338
 			)
1339 1339
 		);
@@ -1352,25 +1352,25 @@  discard block
 block discarded – undo
1352 1352
 	 * @param array $REG_IDs
1353 1353
 	 * @return bool
1354 1354
 	 */
1355
-	protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) {
1355
+	protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) {
1356 1356
 		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
1357 1357
 		// so let's do that using our set of REG_IDs from the form
1358 1358
 		$registration_query_where_params = array(
1359
-			'REG_ID' => array( 'IN', $REG_IDs )
1359
+			'REG_ID' => array('IN', $REG_IDs)
1360 1360
 		);
1361 1361
 		// but add in some conditions regarding payment,
1362 1362
 		// so that we don't apply payments to registrations that are free or have already been paid for
1363 1363
 		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
1364
-		if ( ! $payment->is_a_refund() ) {
1365
-			$registration_query_where_params[ 'REG_final_price' ]  = array( '!=', 0 );
1366
-			$registration_query_where_params[ 'REG_final_price*' ]  = array( '!=', 'REG_paid', true );
1364
+		if ( ! $payment->is_a_refund()) {
1365
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
1366
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
1367 1367
 		}
1368 1368
 		//EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ );
1369
-		$registrations = $transaction->registrations( array( $registration_query_where_params ) );
1370
-		if ( ! empty( $registrations ) ) {
1369
+		$registrations = $transaction->registrations(array($registration_query_where_params));
1370
+		if ( ! empty($registrations)) {
1371 1371
 			/** @type EE_Payment_Processor $payment_processor */
1372
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1373
-			$payment_processor->process_registration_payments( $transaction, $payment, $registrations );
1372
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1373
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
1374 1374
 		}
1375 1375
 	}
1376 1376
 
@@ -1386,22 +1386,22 @@  discard block
 block discarded – undo
1386 1386
 	 * @param array $REG_IDs
1387 1387
 	 * @return bool
1388 1388
 	 */
1389
-	protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) {
1389
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) {
1390 1390
 		// first if there is no change in status then we get out.
1391 1391
 		if (
1392
-			! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] )
1392
+			! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status'])
1393 1393
 			|| $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN'
1394 1394
 		) {
1395 1395
 			//no error message, no change requested, just nothing to do man.
1396 1396
 			return FALSE;
1397 1397
 		}
1398 1398
 		/** @type EE_Transaction_Processor $transaction_processor */
1399
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1399
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1400 1400
 		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
1401 1401
 		return $transaction_processor->manually_update_registration_statuses(
1402 1402
 			$transaction,
1403
-			sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ),
1404
-			array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) )
1403
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
1404
+			array(array('REG_ID' => array('IN', $REG_IDs)))
1405 1405
 		);
1406 1406
 	}
1407 1407
 
@@ -1416,16 +1416,16 @@  discard block
 block discarded – undo
1416 1416
 	 * @param bool | null        $delete_txn_reg_status_change
1417 1417
 	 * @return array
1418 1418
 	 */
1419
-	protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) {
1419
+	protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) {
1420 1420
 		// was the payment deleted ?
1421
-		if ( is_bool( $delete_txn_reg_status_change )) {
1421
+		if (is_bool($delete_txn_reg_status_change)) {
1422 1422
 			return array(
1423 1423
 				'PAY_ID' 				=> $payment->ID(),
1424 1424
 				'amount' 			=> $payment->amount(),
1425 1425
 				'total_paid' 			=> $payment->transaction()->paid(),
1426 1426
 				'txn_status' 			=> $payment->transaction()->status_ID(),
1427 1427
 				'pay_status' 		=> $payment->STS_ID(),
1428
-				'registrations' 	=> $this->_registration_payment_data_array( $REG_IDs ),
1428
+				'registrations' 	=> $this->_registration_payment_data_array($REG_IDs),
1429 1429
 				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
1430 1430
 			);
1431 1431
 		} else {
@@ -1437,16 +1437,16 @@  discard block
 block discarded – undo
1437 1437
 				'pay_status' 	=> $payment->STS_ID(),
1438 1438
 				'PAY_ID'           => $payment->ID(),
1439 1439
 				'STS_ID' 			=> $payment->STS_ID(),
1440
-				'status' 			=> self::$_pay_status[ $payment->STS_ID() ],
1441
-				'date' 				=> $payment->timestamp( 'Y-m-d', 'h:i a' ),
1442
-				'method' 		=> strtoupper( $payment->source() ),
1440
+				'status' 			=> self::$_pay_status[$payment->STS_ID()],
1441
+				'date' 				=> $payment->timestamp('Y-m-d', 'h:i a'),
1442
+				'method' 		=> strtoupper($payment->source()),
1443 1443
 				'PM_ID' 			=> $payment->payment_method() ? $payment->payment_method()->ID() : 1,
1444
-				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : __( "Unknown", 'event_espresso' ),
1444
+				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'),
1445 1445
 				'gateway_response' 	=> $payment->gateway_response(),
1446 1446
 				'txn_id_chq_nmbr'  	=> $payment->txn_id_chq_nmbr(),
1447 1447
 				'po_number'        		=> $payment->po_number(),
1448 1448
 				'extra_accntng'    		=> $payment->extra_accntng(),
1449
-				'registrations'    			=> $this->_registration_payment_data_array( $REG_IDs ),
1449
+				'registrations'    			=> $this->_registration_payment_data_array($REG_IDs),
1450 1450
 			);
1451 1451
 		}
1452 1452
 	}
@@ -1461,42 +1461,42 @@  discard block
 block discarded – undo
1461 1461
 	*	@return void
1462 1462
 	*/
1463 1463
 	public function delete_payment() {
1464
-		$json_response_data = array( 'return_data' => FALSE );
1465
-		$PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0;
1466
-		if ( $PAY_ID ) {
1467
-			$delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false;
1468
-			$payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID );
1469
-			if ( $payment instanceof EE_Payment ) {
1470
-				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1464
+		$json_response_data = array('return_data' => FALSE);
1465
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
1466
+		if ($PAY_ID) {
1467
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
1468
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
1469
+			if ($payment instanceof EE_Payment) {
1470
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1471 1471
 				/** @type EE_Transaction_Payments $transaction_payments */
1472
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1473
-				if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) {
1474
-					EE_Error::add_success( __( 'The Payment was successfully deleted.', 'event_espresso' ) );
1475
-					$json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change );
1476
-					if ( $delete_txn_reg_status_change ) {
1472
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1473
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
1474
+					EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso'));
1475
+					$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change);
1476
+					if ($delete_txn_reg_status_change) {
1477 1477
 						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
1478 1478
 						//MAKE sure we also add the delete_txn_req_status_change to the
1479 1479
 						//$_REQUEST global because that's how messages will be looking for it.
1480 1480
 						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
1481 1481
 						$this->_maybe_send_notifications();
1482
-						$this->_process_registration_status_change( $payment->transaction(), $REG_IDs );
1482
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
1483 1483
 						//$this->_maybe_send_notifications( $payment );
1484 1484
 					}
1485 1485
 				}
1486 1486
 			} else {
1487 1487
 				EE_Error::add_error(
1488
-					__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ),
1488
+					__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
1489 1489
 					__FILE__, __FUNCTION__, __LINE__
1490 1490
 				);
1491 1491
 			}
1492 1492
 		} else {
1493 1493
 			EE_Error::add_error(
1494
-				__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ),
1494
+				__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'),
1495 1495
 				__FILE__, __FUNCTION__, __LINE__
1496 1496
 			);
1497 1497
 		}
1498
-		$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
1499
-		echo json_encode( array_merge( $json_response_data, $notices ));
1498
+		$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
1499
+		echo json_encode(array_merge($json_response_data, $notices));
1500 1500
 		die();
1501 1501
 	}
1502 1502
 
@@ -1510,17 +1510,17 @@  discard block
 block discarded – undo
1510 1510
 	 * @param array $REG_IDs
1511 1511
 	 * @return array
1512 1512
 	 */
1513
-	protected function _registration_payment_data_array( $REG_IDs ) {
1513
+	protected function _registration_payment_data_array($REG_IDs) {
1514 1514
 		$registration_payment_data = array();
1515 1515
 		//if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
1516
-		if ( ! empty( $REG_IDs ) ) {
1517
-			EE_Registry::instance()->load_helper( 'Template' );
1518
-			$registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) );
1519
-			foreach ( $registrations as $registration ) {
1520
-				if ( $registration instanceof EE_Registration ) {
1521
-					$registration_payment_data[ $registration->ID() ] = array(
1516
+		if ( ! empty($REG_IDs)) {
1517
+			EE_Registry::instance()->load_helper('Template');
1518
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
1519
+			foreach ($registrations as $registration) {
1520
+				if ($registration instanceof EE_Registration) {
1521
+					$registration_payment_data[$registration->ID()] = array(
1522 1522
 						'paid' => $registration->pretty_paid(),
1523
-						'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ),
1523
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
1524 1524
 					);
1525 1525
 				}
1526 1526
 			}
@@ -1540,30 +1540,30 @@  discard block
 block discarded – undo
1540 1540
 	 * @access protected
1541 1541
 	 * @param \EE_Payment | null $payment
1542 1542
 	 */
1543
-	protected function _maybe_send_notifications( $payment = null ) {
1544
-		switch ( $payment instanceof EE_Payment ) {
1543
+	protected function _maybe_send_notifications($payment = null) {
1544
+		switch ($payment instanceof EE_Payment) {
1545 1545
 			// payment notifications
1546 1546
 			case true :
1547 1547
 				if (
1548 1548
 					isset(
1549
-						$this->_req_data[ 'txn_payments' ],
1550
-						$this->_req_data[ 'txn_payments' ][ 'send_notifications' ]
1549
+						$this->_req_data['txn_payments'],
1550
+						$this->_req_data['txn_payments']['send_notifications']
1551 1551
 					) &&
1552
-					filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1552
+					filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1553 1553
 				) {
1554
-					$this->_process_payment_notification( $payment );
1554
+					$this->_process_payment_notification($payment);
1555 1555
 				}
1556 1556
 				break;
1557 1557
 			// registration notifications
1558 1558
 			case false :
1559 1559
 				if (
1560 1560
 					isset(
1561
-						$this->_req_data[ 'txn_reg_status_change' ],
1562
-						$this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ]
1561
+						$this->_req_data['txn_reg_status_change'],
1562
+						$this->_req_data['txn_reg_status_change']['send_notifications']
1563 1563
 					) &&
1564
-					filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1564
+					filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1565 1565
 				) {
1566
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
1566
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
1567 1567
 				}
1568 1568
 				break;
1569 1569
 		}
@@ -1579,11 +1579,11 @@  discard block
 block discarded – undo
1579 1579
 	*	@return void
1580 1580
 	*/
1581 1581
 	protected function _send_payment_reminder() {
1582
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
1583
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1584
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array();
1585
-		do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction );
1586
-		$this->_redirect_after_action( FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE );
1582
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
1583
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1584
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array();
1585
+		do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction);
1586
+		$this->_redirect_after_action(FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE);
1587 1587
 	}
1588 1588
 
1589 1589
 
@@ -1597,36 +1597,36 @@  discard block
 block discarded – undo
1597 1597
 	 * @param string   $view
1598 1598
 	 * @return mixed int = count || array of transaction objects
1599 1599
 	 */
1600
-	public function get_transactions( $perpage, $count = FALSE, $view = '' ) {
1600
+	public function get_transactions($perpage, $count = FALSE, $view = '') {
1601 1601
 
1602 1602
 		$TXN = EEM_Transaction::instance();
1603 1603
 
1604
-	    $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' ));
1605
-	    $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' );
1604
+	    $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year'));
1605
+	    $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1606 1606
 
1607 1607
 	    //make sure our timestamps start and end right at the boundaries for each day
1608
-	    $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
1609
-	    $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
1608
+	    $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1609
+	    $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1610 1610
 
1611 1611
 
1612 1612
 	    //convert to timestamps
1613
-	    $start_date = strtotime( $start_date );
1614
-	    $end_date = strtotime( $end_date );
1613
+	    $start_date = strtotime($start_date);
1614
+	    $end_date = strtotime($end_date);
1615 1615
 
1616 1616
 	    //makes sure start date is the lowest value and vice versa
1617
-	    $start_date = min( $start_date, $end_date );
1618
-	    $end_date = max( $start_date, $end_date );
1617
+	    $start_date = min($start_date, $end_date);
1618
+	    $end_date = max($start_date, $end_date);
1619 1619
 
1620 1620
 	    //convert to correct format for query
1621
-	$start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
1622
-	$end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
1621
+	$start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
1622
+	$end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
1623 1623
 
1624 1624
 
1625 1625
 
1626 1626
 	    //set orderby
1627 1627
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1628 1628
 
1629
-		switch ( $this->_req_data['orderby'] ) {
1629
+		switch ($this->_req_data['orderby']) {
1630 1630
 			case 'TXN_ID':
1631 1631
 				$orderby = 'TXN_ID';
1632 1632
 				break;
@@ -1640,66 +1640,66 @@  discard block
 block discarded – undo
1640 1640
 				$orderby = 'TXN_timestamp';
1641 1641
 		}
1642 1642
 
1643
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
1644
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1645
-		$per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10;
1646
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1643
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
1644
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1645
+		$per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10;
1646
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1647 1647
 
1648
-		$offset = ($current_page-1)*$per_page;
1649
-		$limit = array( $offset, $per_page );
1648
+		$offset = ($current_page - 1) * $per_page;
1649
+		$limit = array($offset, $per_page);
1650 1650
 
1651 1651
 		$_where = array(
1652
-			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ),
1652
+			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)),
1653 1653
 			'Registration.REG_count' => 1
1654 1654
 		);
1655 1655
 
1656
-		if ( isset( $this->_req_data['EVT_ID'] ) ) {
1656
+		if (isset($this->_req_data['EVT_ID'])) {
1657 1657
 			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
1658 1658
 		}
1659 1659
 
1660
-		if ( isset( $this->_req_data['s'] ) ) {
1661
-			$search_string = '%' . $this->_req_data['s'] . '%';
1660
+		if (isset($this->_req_data['s'])) {
1661
+			$search_string = '%'.$this->_req_data['s'].'%';
1662 1662
 			$_where['OR'] = array(
1663
-				'Registration.Event.EVT_name' => array( 'LIKE', $search_string ),
1664
-				'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ),
1665
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ),
1666
-				'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ),
1667
-				'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ),
1668
-				'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ),
1669
-				'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ),
1670
-				'Registration.Attendee.ATT_email' => array('LIKE', $search_string ),
1671
-				'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ),
1672
-				'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ),
1673
-				'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ),
1674
-				'Registration.REG_final_price' => array( 'LIKE', $search_string ),
1675
-				'Registration.REG_code' => array( 'LIKE', $search_string ),
1676
-				'Registration.REG_count' => array( 'LIKE' , $search_string ),
1677
-				'Registration.REG_group_size' => array( 'LIKE' , $search_string ),
1678
-				'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ),
1679
-				'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ),
1680
-				'Payment.PAY_source' => array('LIKE', $search_string ),
1681
-				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ),
1682
-				'TXN_session_data' => array( 'LIKE', $search_string ),
1683
-				'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string )
1663
+				'Registration.Event.EVT_name' => array('LIKE', $search_string),
1664
+				'Registration.Event.EVT_desc' => array('LIKE', $search_string),
1665
+				'Registration.Event.EVT_short_desc' => array('LIKE', $search_string),
1666
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
1667
+				'Registration.Attendee.ATT_fname' => array('LIKE', $search_string),
1668
+				'Registration.Attendee.ATT_lname' => array('LIKE', $search_string),
1669
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
1670
+				'Registration.Attendee.ATT_email' => array('LIKE', $search_string),
1671
+				'Registration.Attendee.ATT_address' => array('LIKE', $search_string),
1672
+				'Registration.Attendee.ATT_address2' => array('LIKE', $search_string),
1673
+				'Registration.Attendee.ATT_city' => array('LIKE', $search_string),
1674
+				'Registration.REG_final_price' => array('LIKE', $search_string),
1675
+				'Registration.REG_code' => array('LIKE', $search_string),
1676
+				'Registration.REG_count' => array('LIKE', $search_string),
1677
+				'Registration.REG_group_size' => array('LIKE', $search_string),
1678
+				'Registration.Ticket.TKT_name' => array('LIKE', $search_string),
1679
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
1680
+				'Payment.PAY_source' => array('LIKE', $search_string),
1681
+				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string),
1682
+				'TXN_session_data' => array('LIKE', $search_string),
1683
+				'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string)
1684 1684
 				);
1685 1685
 		}
1686 1686
 
1687 1687
 		//failed transactions
1688
-		$failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE;
1689
-		$abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE;
1688
+		$failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE: FALSE;
1689
+		$abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE: FALSE;
1690 1690
 
1691
-		if ( $failed ) {
1692
-			$_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code;
1693
-		} else if ( $abandoned ) {
1691
+		if ($failed) {
1692
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
1693
+		} else if ($abandoned) {
1694 1694
 				$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
1695 1695
 		} else {
1696
-				$_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code );
1697
-				$_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code );
1696
+				$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
1697
+				$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
1698 1698
 		}
1699 1699
 
1700
-		$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit );
1700
+		$query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit);
1701 1701
 
1702
-		$transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params);
1702
+		$transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params);
1703 1703
 
1704 1704
 
1705 1705
 		return $transactions;
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Spacing   +510 added lines, -510 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param bool $routing
43 43
 	 * @return Registrations_Admin_Page
44 44
 	 */
45
-	public function __construct( $routing = TRUE ) {
46
-		parent::__construct( $routing );
45
+	public function __construct($routing = TRUE) {
46
+		parent::__construct($routing);
47 47
 	}
48 48
 
49 49
 
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 				'trash' => 'post.php'
76 76
 			);
77 77
 
78
-		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 );
78
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
79 79
 		//add filters so that the comment urls don't take users to a confusing 404 page
80
-		add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 );
80
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
81 81
 	}
82 82
 
83 83
 
84
-	public function clear_comment_link( $link, $comment, $args ) {
84
+	public function clear_comment_link($link, $comment, $args) {
85 85
 		//gotta make sure this only happens on this route
86
-		$post_type = get_post_type( $comment->comment_post_ID);
87
-		if ( $post_type == 'espresso_attendees' )
86
+		$post_type = get_post_type($comment->comment_post_ID);
87
+		if ($post_type == 'espresso_attendees')
88 88
 			return '#commentsdiv';
89 89
 		return $link;
90 90
 	}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 	protected function _ajax_hooks() {
94 94
 		//todo: all hooks for registrations ajax goes in here
95
-		add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' ));
95
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
96 96
 	}
97 97
 
98 98
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 					'add-attendee' => __('Add Contact', 'event_espresso'),
108 108
 					'edit' => __('Edit Contact', 'event_espresso'),
109 109
 					'report'=>  __("Event Registrations CSV Report", "event_espresso"),
110
-					'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ),
111
-					'contact_list_report' => __( 'Contact List Report', 'event_espresso' ),
110
+					'report_all' => __('All Registrations CSV Report', 'event_espresso'),
111
+					'contact_list_report' => __('Contact List Report', 'event_espresso'),
112 112
 					'contact_list_export'=>  __("Export Data", "event_espresso"),
113 113
 				),
114 114
 			'publishbox' => array(
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 
137 137
 		$this->_get_registration_status_array();
138 138
 
139
-		$reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0;
140
-		$att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0;
141
-		$att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id;
139
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0;
140
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0;
141
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id;
142 142
 
143 143
 		$this->_page_routes = array(
144 144
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 				'edit_registration'	=> array(
157 157
 						'func' => '_registration_details',
158
-						'args' => array( 'edit' ),
158
+						'args' => array('edit'),
159 159
 						'noheader' => TRUE,
160 160
 						'capability' => 'ee_edit_registration',
161 161
 						'obj_id' => $reg_id
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
 				'restore_registrations' => array(
172 172
 					'func' => '_trash_or_restore_registrations',
173
-					'args' => array( 'trash' => FALSE ),
173
+					'args' => array('trash' => FALSE),
174 174
 					'noheader' => TRUE,
175 175
 					'capability' => 'ee_delete_registrations'
176 176
 					),
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 						'filename' => 'registrations_overview_other'
405 405
 					)
406 406
                 ),
407
-				'help_tour' => array( 'Registration_Overview_Help_Tour' ),
407
+				'help_tour' => array('Registration_Overview_Help_Tour'),
408 408
 				'qtips' => array('Registration_List_Table_Tips'),
409 409
 				'list_table' => 'EE_Registrations_List_Table',
410 410
 				'require_nonce' => FALSE
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 				'nav' => array(
415 415
 					'label' => __('REG Details', 'event_espresso'),
416 416
 					'order' => 15,
417
-					'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
417
+					'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
418 418
 					'persistent' => FALSE
419 419
 					),
420 420
                 'help_tabs' => array(
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 						'filename' => 'registrations_details_registrant_details'
436 436
 						)
437 437
 					),
438
-				'help_tour' => array( 'Registration_Details_Help_Tour' ),
439
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ),
438
+				'help_tour' => array('Registration_Details_Help_Tour'),
439
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')),
440 440
 				'require_nonce' => FALSE
441 441
 				),
442 442
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 					'order' => 15,
461 461
 					'persistent' => FALSE
462 462
 					),
463
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ),
463
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')),
464 464
 				'require_nonce' => FALSE
465 465
 				),
466 466
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 					'label' => __('Edit Contact', 'event_espresso'),
470 470
 					'order' => 15,
471 471
 					'persistent' => FALSE,
472
-					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
472
+					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
473 473
 					),
474 474
 				'metaboxes' => array('attendee_editor_metaboxes'),
475 475
 				'require_nonce' => FALSE
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 						'filename' => 'registrations_contact_list_other'
500 500
 					)
501 501
                 ),
502
-				'help_tour' => array( 'Contact_List_Help_Tour' ),
502
+				'help_tour' => array('Contact_List_Help_Tour'),
503 503
 				'metaboxes' => array(),
504 504
 				'require_nonce' => FALSE
505 505
 				),
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	protected function _add_screen_options() {}
519 519
 	protected function _add_feature_pointers() {}
520 520
 	public function admin_init() {
521
-		EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' );
521
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso');
522 522
 	}
523 523
 	public function admin_notices() {}
524 524
 	public function admin_footer_scripts() {}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	*		@return void
537 537
 	*/
538 538
 	private function _get_registration_status_array() {
539
-		self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE);
539
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE);
540 540
 	}
541 541
 
542 542
 
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 	public function load_scripts_styles() {
560 560
 		//style
561 561
 		//wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
562
-		wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
562
+		wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
563 563
 		wp_enqueue_style('espresso_reg');
564 564
 
565 565
 		//script
566
-		wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
566
+		wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
567 567
 		wp_enqueue_script('espresso_reg');
568 568
 	}
569 569
 
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 	public function load_scripts_styles_edit_attendee() {
573 573
 		//stuff to only show up on our attendee edit details page.
574 574
 		$attendee_details_translations = array(
575
-			'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') )
575
+			'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created'))
576 576
 			);
577
-		wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations );
577
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
578 578
 		wp_enqueue_script('jquery-validate');
579 579
 	}
580 580
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 
593 593
 	public function load_scripts_styles_contact_list() {
594 594
 		wp_deregister_style('espresso_reg');
595
-		wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
595
+		wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
596 596
 		wp_enqueue_style('espresso_att');
597 597
 	}
598 598
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 
602 602
 
603 603
 	public function load_scripts_styles_new_registration() {
604
-		wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE );
604
+		wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE);
605 605
 		wp_enqueue_script('ee-spco-for-admin');
606
-		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
606
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
607 607
 		EE_Form_Section_Proper::wp_enqueue_scripts();
608 608
 		EED_Ticket_Selector::load_tckt_slctr_assets();
609 609
 		EE_Datepicker_Input::enqueue_styles_and_scripts();
@@ -642,23 +642,23 @@  discard block
 block discarded – undo
642 642
 
643 643
 		/** setup reg status bulk actions **/
644 644
 		$def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
645
-		if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
645
+		if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
646 646
 			$def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso');
647 647
 		}
648 648
 		$def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
649
-		if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
649
+		if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
650 650
 			$def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso');
651 651
 		}
652 652
 		$def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
653
-		if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
653
+		if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
654 654
 			$def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso');
655 655
 		}
656 656
 		$def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
657
-		if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
657
+		if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
658 658
 			$def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso');
659 659
 		}
660 660
 		$def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
661
-		if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
661
+		if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
662 662
 			$def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso');
663 663
 		}
664 664
 
@@ -667,29 +667,29 @@  discard block
 block discarded – undo
667 667
 				'slug' => 'all',
668 668
 				'label' => __('View All Registrations', 'event_espresso'),
669 669
 				'count' => 0,
670
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
670
+				'bulk_action' => array_merge($def_reg_status_actions, array(
671 671
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
672
-					) )
672
+					))
673 673
 				),
674 674
 			'month' => array(
675 675
 				'slug' => 'month',
676 676
 				'label' => __('This Month', 'event_espresso'),
677 677
 				'count' => 0,
678
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
678
+				'bulk_action' => array_merge($def_reg_status_actions, array(
679 679
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
680 680
 					))
681 681
 				),
682 682
 			'today' => array(
683 683
 				'slug' => 'today',
684
-				'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ),
684
+				'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
685 685
 				'count' => 0,
686
-				'bulk_action' => array_merge( $def_reg_status_actions,  array(
686
+				'bulk_action' => array_merge($def_reg_status_actions, array(
687 687
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
688 688
 					))
689 689
 				)
690 690
 			);
691 691
 
692
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) {
692
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) {
693 693
 			$this->_views['incomplete'] = array(
694 694
 				'slug' => 'incomplete',
695 695
 				'label' => __('Incomplete', 'event_espresso'),
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 				)
726 726
 			);
727 727
 
728
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) {
728
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) {
729 729
 			$this->_views['trash'] = array(
730 730
 				'slug' => 'trash',
731 731
 				'label' => __('Trash', 'event_espresso'),
@@ -764,42 +764,42 @@  discard block
 block discarded – undo
764 764
 				'desc' => __('View Transaction Invoice', 'event_espresso')
765 765
 				),
766 766
  			);
767
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
767
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) {
768 768
 			$fc_items['resend_registration'] = array(
769 769
 				'class' => 'dashicons dashicons-email-alt',
770 770
 				'desc' => __('Resend Registration Details', 'event_espresso')
771 771
 				);
772 772
 		} else {
773
-			$fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' );
773
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
774 774
 		}
775 775
 
776 776
 		$sc_items = array(
777 777
 			'approved_status' => array(
778
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
779
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' )
778
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
779
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')
780 780
 				),
781 781
 			'pending_status' => array(
782
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
783
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' )
782
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
783
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence')
784 784
 				),
785 785
 			'incomplete_status' => array(
786
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
787
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' )
786
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
787
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence')
788 788
 			),
789 789
 			'not_approved' => array(
790
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
791
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' )
790
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
791
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence')
792 792
 				),
793 793
 			'declined_status' => array(
794
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
795
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' )
794
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
795
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence')
796 796
 				),
797 797
 			'cancelled_status' => array(
798
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
799
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' )
798
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
799
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence')
800 800
 				)
801 801
 			);
802
-		return array_merge( $fc_items, $sc_items );
802
+		return array_merge($fc_items, $sc_items);
803 803
 	}
804 804
 
805 805
 
@@ -812,15 +812,15 @@  discard block
 block discarded – undo
812 812
 
813 813
 
814 814
 	protected function _registrations_overview_list_table() {
815
-		$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE;
816
-		if ( $EVT_ID ) {
817
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registrations', 'espresso_registrations_new_registration', $EVT_ID ) ) {
818
-				$this->_admin_page_title .= $this->get_action_link_or_button( 'new_registration', 'add-registrant', array( 'event_id' => $EVT_ID ), 'add-new-h2' );
815
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE;
816
+		if ($EVT_ID) {
817
+			if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', 'espresso_registrations_new_registration', $EVT_ID)) {
818
+				$this->_admin_page_title .= $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $EVT_ID), 'add-new-h2');
819 819
 			}
820
-			$event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
821
-			$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%s Viewing registrations for the event: %s%s', 'event_espresso'), '<h2>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce( array('action' => 'edit', 'post' => $event->ID() ), EVENTS_ADMIN_URL ) . '">' . $event->get('EVT_name') . '</a>', '</h2>' ) : '';
820
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
821
+			$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(__('%s Viewing registrations for the event: %s%s', 'event_espresso'), '<h2>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'">'.$event->get('EVT_name').'</a>', '</h2>') : '';
822 822
 		}
823
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() );
823
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
824 824
 		$this->display_admin_list_table_page_with_no_sidebar();
825 825
 	}
826 826
 
@@ -835,19 +835,19 @@  discard block
 block discarded – undo
835 835
 	 */
836 836
 	private function _set_registration_object() {
837 837
 		//get out if we've already set the object
838
-		if ( is_object( $this->_registration )) {
838
+		if (is_object($this->_registration)) {
839 839
 			return TRUE;
840 840
 		}
841 841
 
842 842
 	    $REG = EEM_Registration::instance();
843 843
 
844
-		$REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
844
+		$REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE;
845 845
 
846
-		if ( $this->_registration = $REG->get_one_by_ID( $REG_ID ))
846
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID))
847 847
 			return TRUE;
848 848
 		else {
849
-			$error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID );
850
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
849
+			$error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID);
850
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
851 851
 			$this->_registration = NULL;
852 852
 			return FALSE;
853 853
 		}
@@ -866,25 +866,25 @@  discard block
 block discarded – undo
866 866
 	 * @internal param bool $all whether to ignore all query params and just return ALL registrations (or count if count is set)
867 867
 	 * @return mixed (int|array)  int = count || array of registration objects
868 868
 	 */
869
-	public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) {
870
-
871
-		$EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE;
872
-		$CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE;
873
-		$reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE;
874
-		$month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april
875
-		$today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'today' ? TRUE : FALSE;
876
-		$this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'month' ? TRUE  : FALSE;
869
+	public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) {
870
+
871
+		$EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE;
872
+		$CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE;
873
+		$reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE;
874
+		$month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april
875
+		$today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'today' ? TRUE : FALSE;
876
+		$this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'month' ? TRUE  : FALSE;
877 877
 		$start_date = FALSE;
878 878
 		$end_date = FALSE;
879 879
 		$_where = array();
880
-		$trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'trash' ? TRUE : FALSE;
881
-		$incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'incomplete' ? TRUE : FALSE;
880
+		$trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'trash' ? TRUE : FALSE;
881
+		$incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'incomplete' ? TRUE : FALSE;
882 882
 
883 883
 		//set orderby
884 884
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
885 885
 
886 886
 
887
-		switch ( $this->_req_data['orderby'] ) {
887
+		switch ($this->_req_data['orderby']) {
888 888
 			case '_REG_ID':
889 889
 				$orderby = 'REG_ID';
890 890
 				break;
@@ -904,26 +904,26 @@  discard block
 block discarded – undo
904 904
 				$orderby = 'REG_date';
905 905
 		}
906 906
 
907
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
908
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
909
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
907
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
908
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
909
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
910 910
 
911 911
 
912
-		$offset = ($current_page-1)*$per_page;
913
-		$limit = $count  ? NULL : array( $offset, $per_page );
912
+		$offset = ($current_page - 1) * $per_page;
913
+		$limit = $count ? NULL : array($offset, $per_page);
914 914
 
915
-		if($EVT_ID){
916
-			$_where['EVT_ID']=$EVT_ID;
915
+		if ($EVT_ID) {
916
+			$_where['EVT_ID'] = $EVT_ID;
917 917
 		}
918
-		if($CAT_ID){
918
+		if ($CAT_ID) {
919 919
 			$_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
920 920
 		}
921
-		if ( $incomplete ) {
921
+		if ($incomplete) {
922 922
 			$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
923 923
 		} else if ( ! $trash) {
924
-			$_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete );
924
+			$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
925 925
 		}
926
-		if($reg_status){
926
+		if ($reg_status) {
927 927
 			$_where['STS_ID'] = $reg_status;
928 928
 		}
929 929
 
@@ -935,105 +935,105 @@  discard block
 block discarded – undo
935 935
 		$time_start = ' 00:00:00';
936 936
 		$time_end = ' 23:59:59';
937 937
 
938
-		if($today_a || $today ){
938
+		if ($today_a || $today) {
939 939
 			$curdate = date('Y-m-d', current_time('timestamp'));
940
-			$_where['REG_date']= array('BETWEEN',
940
+			$_where['REG_date'] = array('BETWEEN',
941 941
 				array(
942
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ),
943
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ),
942
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'),
943
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'),
944 944
 			));
945
-		}elseif($this_month_a || $this_month){
945
+		}elseif ($this_month_a || $this_month) {
946 946
 			$this_month_r = date('m', current_time('timestamp'));
947
-			$days_this_month = date( 't', current_time('timestamp') );
948
-			$_where['REG_date']= array('BETWEEN',
947
+			$days_this_month = date('t', current_time('timestamp'));
948
+			$_where['REG_date'] = array('BETWEEN',
949 949
 				array(
950
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ),
951
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' )
950
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'),
951
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s')
952 952
 			));
953
-		}elseif($month_range){
953
+		}elseif ($month_range) {
954 954
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
955
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
956
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
957
-			$days_in_month = date('t', strtotime($year_r .  '-' . $month_r . '-' . '01') );
958
-			$_where['REG_date']= array('BETWEEN',
959
-				array(  EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month .  ' 23:59:59', 'Y-m-d H:i:s' ) ) );
960
-		}elseif($start_date && $end_date){
955
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
956
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
957
+			$days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01'));
958
+			$_where['REG_date'] = array('BETWEEN',
959
+				array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s')));
960
+		}elseif ($start_date && $end_date) {
961 961
 			throw new EE_Error("not yet supported");
962
-		}elseif($start_date){
962
+		}elseif ($start_date) {
963 963
 			throw new EE_Error("not yet supported");
964
-		}elseif($end_date){
964
+		}elseif ($end_date) {
965 965
 			throw new EE_Error("not yet supported");
966 966
 		}
967 967
 
968
-		if ( ! empty( $this->_req_data['s'] ) ) {
969
-			$sstr = '%' . $this->_req_data['s'] . '%';
968
+		if ( ! empty($this->_req_data['s'])) {
969
+			$sstr = '%'.$this->_req_data['s'].'%';
970 970
 			$_where['OR'] = array(
971
-				'Event.EVT_name' => array( 'LIKE', $sstr),
972
-				'Event.EVT_desc' => array( 'LIKE', $sstr ),
973
-				'Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
974
-				'Attendee.ATT_full_name' => array( 'LIKE', $sstr ),
975
-				'Attendee.ATT_fname' => array( 'LIKE', $sstr ),
976
-				'Attendee.ATT_lname' => array( 'LIKE', $sstr ),
977
-				'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ),
978
-				'Attendee.ATT_email' => array('LIKE', $sstr ),
979
-				'Attendee.ATT_address' => array( 'LIKE', $sstr ),
980
-				'Attendee.ATT_address2' => array( 'LIKE', $sstr ),
981
-				'Attendee.ATT_city' => array( 'LIKE', $sstr ),
982
-				'REG_final_price' => array( 'LIKE', $sstr ),
983
-				'REG_code' => array( 'LIKE', $sstr ),
984
-				'REG_count' => array( 'LIKE' , $sstr ),
985
-				'REG_group_size' => array( 'LIKE' , $sstr ),
986
-				'Ticket.TKT_name' => array( 'LIKE', $sstr ),
987
-				'Ticket.TKT_description' => array( 'LIKE', $sstr ),
988
-				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr )
971
+				'Event.EVT_name' => array('LIKE', $sstr),
972
+				'Event.EVT_desc' => array('LIKE', $sstr),
973
+				'Event.EVT_short_desc' => array('LIKE', $sstr),
974
+				'Attendee.ATT_full_name' => array('LIKE', $sstr),
975
+				'Attendee.ATT_fname' => array('LIKE', $sstr),
976
+				'Attendee.ATT_lname' => array('LIKE', $sstr),
977
+				'Attendee.ATT_short_bio' => array('LIKE', $sstr),
978
+				'Attendee.ATT_email' => array('LIKE', $sstr),
979
+				'Attendee.ATT_address' => array('LIKE', $sstr),
980
+				'Attendee.ATT_address2' => array('LIKE', $sstr),
981
+				'Attendee.ATT_city' => array('LIKE', $sstr),
982
+				'REG_final_price' => array('LIKE', $sstr),
983
+				'REG_code' => array('LIKE', $sstr),
984
+				'REG_count' => array('LIKE', $sstr),
985
+				'REG_group_size' => array('LIKE', $sstr),
986
+				'Ticket.TKT_name' => array('LIKE', $sstr),
987
+				'Ticket.TKT_description' => array('LIKE', $sstr),
988
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr)
989 989
 				);
990 990
 		}
991 991
 
992 992
 		//capability checks
993
-		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) {
993
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
994 994
 			$_where['AND'] = array(
995 995
 				'Event.EVT_wp_user' => get_current_user_id()
996 996
 				);
997 997
 		}
998 998
 
999 999
 
1000
-		if( $count ){
1001
-			if ( $trash ) {
1002
-				return EEM_Registration::instance()->count_deleted( array( $_where ));
1003
-			} else if ( $incomplete ) {
1004
-				return EEM_Registration::instance()->count( array( $_where ));
1000
+		if ($count) {
1001
+			if ($trash) {
1002
+				return EEM_Registration::instance()->count_deleted(array($_where));
1003
+			} else if ($incomplete) {
1004
+				return EEM_Registration::instance()->count(array($_where));
1005 1005
 			} else {
1006
-				return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' ));
1006
+				return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only'));
1007 1007
 			}
1008 1008
 		} else {
1009 1009
 			//make sure we remove default where conditions cause all registrations matching query are returned
1010
-			$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' );
1011
-			if ( $per_page !== -1 ) {
1010
+			$query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only');
1011
+			if ($per_page !== -1) {
1012 1012
 				$query_params['limit'] = $limit;
1013 1013
 			}
1014
-			$registrations =  $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1014
+			$registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1015 1015
 
1016 1016
 
1017
-			if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration &&  $registrations[0]->event_obj()) {
1017
+			if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) {
1018 1018
 				$first_registration = $registrations[0];
1019 1019
 				//EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1020 1020
 				$event_name = $first_registration->event_obj()->name();
1021
-				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1021
+				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1022 1022
 				// edit event link
1023
-				if ( $event_name != '' ) {
1024
-					$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL );
1025
-					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
1026
-					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
1023
+				if ($event_name != '') {
1024
+					$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL);
1025
+					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>';
1026
+					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
1027 1027
 				}
1028 1028
 
1029
-				$back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL );
1030
-				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">&laquo; ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>';
1029
+				$back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL);
1030
+				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">&laquo; '.__('Back to All Registrations', 'event_espresso').'</a>';
1031 1031
 
1032 1032
 				$this->_template_args['before_admin_page_content'] = '
1033 1033
 			<div id="admin-page-header">
1034
-				<h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1>
1035
-				<h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3>
1036
-				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1034
+				<h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1>
1035
+				<h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3>
1036
+				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span>
1037 1037
 			</div>
1038 1038
 			';
1039 1039
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 
1072 1072
 		$this->_set_registration_object();
1073 1073
 
1074
-		if ( is_object( $this->_registration )) {
1074
+		if (is_object($this->_registration)) {
1075 1075
 			$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1076 1076
 			$this->_session = $transaction->session_data();
1077 1077
 
@@ -1079,10 +1079,10 @@  discard block
 block discarded – undo
1079 1079
 
1080 1080
 
1081 1081
 			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1082
-			$this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' );
1082
+			$this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1083 1083
 
1084
-			$this->_template_args['reg_datetime']['value'] =  $this->_registration->pretty_date('l F j, Y','g:i:s a') ;
1085
-			$this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' );
1084
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->pretty_date('l F j, Y', 'g:i:s a');
1085
+			$this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1086 1086
 
1087 1087
 			$this->_template_args['grand_total'] = $transaction->total();
1088 1088
 
@@ -1090,19 +1090,19 @@  discard block
 block discarded – undo
1090 1090
 			// link back to overview
1091 1091
 			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1092 1092
 			$this->_template_args['registration'] = $this->_registration;
1093
-			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL );
1094
-			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) );
1095
-			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) );
1093
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL);
1094
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php'));
1095
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php'));
1096 1096
 
1097 1097
 			//next and previous links
1098
-			$next_reg = $this->_registration->next(null, array(), 'REG_ID' );
1099
-			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : '';
1100
-			$previous_reg = $this->_registration->previous( null, array(), 'REG_ID' );
1101
-			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : '';
1098
+			$next_reg = $this->_registration->next(null, array(), 'REG_ID');
1099
+			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1100
+			$previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1101
+			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1102 1102
 
1103 1103
 			// grab header
1104
-			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1105
-			$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1104
+			$template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1105
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1106 1106
 
1107 1107
 		} else {
1108 1108
 
@@ -1123,14 +1123,14 @@  discard block
 block discarded – undo
1123 1123
 	protected function _registration_details_metaboxes() {
1124 1124
 		$this->_set_registration_object();
1125 1125
 		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1126
-		add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' );
1127
-		add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1128
-		if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) {
1129
-			add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1126
+		add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1127
+		add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1128
+		if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) {
1129
+			add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1130 1130
 		}
1131
-		add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' );
1132
-		if ( $this->_registration->group_size() > 1 ) {
1133
-			add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1131
+		add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1132
+		if ($this->_registration->group_size() > 1) {
1133
+			add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1134 1134
 		}
1135 1135
 	}
1136 1136
 
@@ -1151,23 +1151,23 @@  discard block
 block discarded – undo
1151 1151
 
1152 1152
 		//let's get an array of all possible buttons that we can just reference
1153 1153
 		$status_buttons = $this->_get_reg_status_buttons();
1154
-		$template_args[ 'reg_status_value' ] = $this->_registration->pretty_status();
1155
-		$template_args[ 'reg_status_class' ] = 'status-' . $this->_registration->status_ID();
1154
+		$template_args['reg_status_value'] = $this->_registration->pretty_status();
1155
+		$template_args['reg_status_class'] = 'status-'.$this->_registration->status_ID();
1156 1156
 		$template_args['attendee'] = $this->_registration->attendee();
1157
-		$template = REG_TEMPLATE_PATH . 'reg_status_change_buttons.template.php';
1158
-		if ( $this->_set_registration_object() ) {
1157
+		$template = REG_TEMPLATE_PATH.'reg_status_change_buttons.template.php';
1158
+		if ($this->_set_registration_object()) {
1159 1159
 			$current_status = $this->_registration->status_ID();
1160
-			unset( $status_buttons[$current_status] );
1161
-			if ( $current_status != EEM_Registration::status_id_pending_payment && $is_complete ) {
1162
-				unset( $status_buttons[EEM_Registration::status_id_pending_payment] );
1160
+			unset($status_buttons[$current_status]);
1161
+			if ($current_status != EEM_Registration::status_id_pending_payment && $is_complete) {
1162
+				unset($status_buttons[EEM_Registration::status_id_pending_payment]);
1163 1163
 			}
1164
-			$template_args['status_buttons'] = implode( "\n", $status_buttons );
1164
+			$template_args['status_buttons'] = implode("\n", $status_buttons);
1165 1165
 		}
1166 1166
 		$template_args['form_url'] = REG_ADMIN_URL;
1167 1167
 		$template_args['REG_ID'] = $this->_registration->ID();
1168
-		$template_args['nonce'] = wp_nonce_field( 'change_reg_status_nonce',  'change_reg_status_nonce', FALSE, FALSE );
1168
+		$template_args['nonce'] = wp_nonce_field('change_reg_status_nonce', 'change_reg_status_nonce', FALSE, FALSE);
1169 1169
 
1170
-		EEH_Template::display_template( $template, $template_args );
1170
+		EEH_Template::display_template($template, $template_args);
1171 1171
 
1172 1172
 	}
1173 1173
 
@@ -1181,11 +1181,11 @@  discard block
 block discarded – undo
1181 1181
 	private function _get_reg_status_buttons() {
1182 1182
 
1183 1183
 		$buttons = array(
1184
-			EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) . '">',
1185
-			EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_pending_payment . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) . '">',
1186
-			EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_not_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) . '">',
1187
-			EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_declined . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) . '">',
1188
-			EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_cancelled . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) . '">',
1184
+			EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence').'">',
1185
+			EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_pending_payment.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence').'">',
1186
+			EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_not_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence').'">',
1187
+			EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_declined.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence').'">',
1188
+			EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_cancelled.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence').'">',
1189 1189
 			);
1190 1190
 		return $buttons;
1191 1191
 	}
@@ -1199,13 +1199,13 @@  discard block
 block discarded – undo
1199 1199
 	 *
1200 1200
 	 * @return array  (array with reg_id(s) updated and whether update was successful.
1201 1201
 	 */
1202
-	protected function _set_registration_status_from_request( $status = false, $notify = false ) {
1203
-		$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? (array) $this->_req_data['_REG_ID'] : array();
1202
+	protected function _set_registration_status_from_request($status = false, $notify = false) {
1203
+		$REG_ID = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array();
1204 1204
 
1205
-		$success = $this->_set_registration_status( $REG_ID, $status );
1205
+		$success = $this->_set_registration_status($REG_ID, $status);
1206 1206
 
1207 1207
 		//notify?
1208
-		if ( $success && $notify && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
1208
+		if ($success && $notify && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) {
1209 1209
 			$this->_process_resend_registration();
1210 1210
 		}
1211 1211
 
@@ -1223,19 +1223,19 @@  discard block
 block discarded – undo
1223 1223
 	 * @param bool $status
1224 1224
 	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations).
1225 1225
 	 */
1226
-	protected function _set_registration_status( $REG_ID, $status = false ) {
1226
+	protected function _set_registration_status($REG_ID, $status = false) {
1227 1227
 		$success = true;
1228 1228
 		// set default status if none is passed
1229 1229
 		$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1230 1230
 
1231 1231
 		//typecast and sanitize reg_id
1232
-		$reg_ids = array_filter( (array) $REG_ID, 'absint' );
1232
+		$reg_ids = array_filter((array) $REG_ID, 'absint');
1233 1233
 
1234 1234
 		//loop through REG_ID's and change status
1235
-		foreach ( $reg_ids as $r_id ) {
1236
-			$registration = EEM_Registration::instance()->get_one_by_ID( $r_id );
1237
-			if ( $registration instanceof EE_Registration ) {
1238
-				$registration->set_status( $status );
1235
+		foreach ($reg_ids as $r_id) {
1236
+			$registration = EEM_Registration::instance()->get_one_by_ID($r_id);
1237
+			if ($registration instanceof EE_Registration) {
1238
+				$registration->set_status($status);
1239 1239
 				$result = $registration->save();
1240 1240
 
1241 1241
 				//verifying explicit fails because update *may* just return 0 for 0 rows affected
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 		$this->_req_data['_REG_ID'] = $reg_ids;
1248 1248
 
1249 1249
 		//return $success and processed registrations
1250
-		return array( 'REG_ID' => $reg_ids, 'success' => $success );
1250
+		return array('REG_ID' => $reg_ids, 'success' => $success);
1251 1251
 	}
1252 1252
 
1253 1253
 
@@ -1259,37 +1259,37 @@  discard block
 block discarded – undo
1259 1259
 	 * @param   bool    $notify indicates whether the _set_registration_status_from_request does notifications or not.
1260 1260
 	 * @return void
1261 1261
 	 */
1262
-	protected function _reg_status_change_return( $STS_ID, $notify = false ) {
1262
+	protected function _reg_status_change_return($STS_ID, $notify = false) {
1263 1263
 
1264
-		$result = ! empty( $STS_ID ) ? $this->_set_registration_status_from_request( $STS_ID, $notify ) : array( 'success' => false );
1264
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) : array('success' => false);
1265 1265
 
1266 1266
 
1267
-		$success = isset( $result['success'] ) && $result['success'];
1267
+		$success = isset($result['success']) && $result['success'];
1268 1268
 
1269 1269
 		//setup success message
1270
-		if ( $success ) {
1271
-			$msg = is_array( $result['REG_ID'] ) && count( $result['REG_ID'] ) > 1  ? sprintf( __('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) :  sprintf( __('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) ;
1272
-			EE_Error::add_success( $msg );
1270
+		if ($success) {
1271
+			$msg = is_array($result['REG_ID']) && count($result['REG_ID']) > 1 ? sprintf(__('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower')) : sprintf(__('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower'));
1272
+			EE_Error::add_success($msg);
1273 1273
 		} else {
1274
-			EE_Error::add_error( __('Something went wrong, and the status was not changed', 'event_espresso' ), __FILE__, __LINE__, __FUNCTION__ );
1274
+			EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
1275 1275
 		}
1276 1276
 
1277
-		$route = isset( $this->_req_data['return'] ) && $this->_req_data['return'] == 'view_registration' ? array( 'action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0] ) : array( 'action' => 'default' );
1277
+		$route = isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration' ? array('action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0]) : array('action' => 'default');
1278 1278
 		//unset nonces
1279
-		foreach ( $this->_req_data as $ref => $value ) {
1280
-			if ( strpos( $ref, 'nonce' ) !== false ) {
1281
-				unset( $this->_req_data[$ref] );
1279
+		foreach ($this->_req_data as $ref => $value) {
1280
+			if (strpos($ref, 'nonce') !== false) {
1281
+				unset($this->_req_data[$ref]);
1282 1282
 				continue;
1283 1283
 			}
1284 1284
 
1285
-			$value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value );
1285
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1286 1286
 			$this->_req_data[$ref] = $value;
1287 1287
 		}
1288 1288
 
1289 1289
 		//merge request vars so that the reloaded list table contains any existing filter query params
1290
-		$route = array_merge( $this->_req_data, $route );
1290
+		$route = array_merge($this->_req_data, $route);
1291 1291
 
1292
-		$this->_redirect_after_action( $success, '', '', $route, true );
1292
+		$this->_redirect_after_action($success, '', '', $route, true);
1293 1293
 
1294 1294
 		}
1295 1295
 
@@ -1302,29 +1302,29 @@  discard block
 block discarded – undo
1302 1302
 	protected function _change_reg_status() {
1303 1303
 		$this->_req_data['return'] = 'view_registration';
1304 1304
 		//set notify based on whether the send notifications toggle is set or not
1305
-		$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1306
-		$this->_req_data[ '_reg_status_id' ] = isset( $this->_req_data[ '_reg_status_id' ] ) ? $this->_req_data[ '_reg_status_id' ] : '';
1305
+		$notify = ! empty($this->_req_data['txn_reg_status_change']['send_notifications']);
1306
+		$this->_req_data['_reg_status_id'] = isset($this->_req_data['_reg_status_id']) ? $this->_req_data['_reg_status_id'] : '';
1307 1307
 
1308
-		switch ( $this->_req_data['_reg_status_id'] ) {
1309
-			case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) :
1310
-				$this->approve_registration( $notify );
1308
+		switch ($this->_req_data['_reg_status_id']) {
1309
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1310
+				$this->approve_registration($notify);
1311 1311
 				break;
1312
-			case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) :
1313
-				$this->pending_registration( $notify );
1312
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1313
+				$this->pending_registration($notify);
1314 1314
 				break;
1315
-			case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) :
1316
-				$this->not_approve_registration( $notify );
1315
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1316
+				$this->not_approve_registration($notify);
1317 1317
 				break;
1318
-			case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) :
1319
-				$this->decline_registration( $notify );
1318
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1319
+				$this->decline_registration($notify);
1320 1320
 				break;
1321
-			case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) :
1322
-				$this->cancel_registration( $notify );
1321
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1322
+				$this->cancel_registration($notify);
1323 1323
 				break;
1324 1324
 			default :
1325 1325
 				$result['success'] = false;
1326
-				unset( $this->_req_data['return'] );
1327
-				$this->_reg_status_change_return( '', false );
1326
+				unset($this->_req_data['return']);
1327
+				$this->_reg_status_change_return('', false);
1328 1328
 				break;
1329 1329
 		}
1330 1330
 	}
@@ -1337,8 +1337,8 @@  discard block
 block discarded – undo
1337 1337
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1338 1338
 	*		@return void
1339 1339
 	*/
1340
-	protected function approve_registration( $notify = false ) {
1341
-		$this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify );
1340
+	protected function approve_registration($notify = false) {
1341
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1342 1342
 	}
1343 1343
 
1344 1344
 
@@ -1350,8 +1350,8 @@  discard block
 block discarded – undo
1350 1350
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1351 1351
 	*		@return void
1352 1352
 	*/
1353
-	protected function decline_registration( $notify = false ) {
1354
-		$this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify );
1353
+	protected function decline_registration($notify = false) {
1354
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1355 1355
 	}
1356 1356
 
1357 1357
 
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1364 1364
 	*		@return void
1365 1365
 	*/
1366
-	protected function cancel_registration( $notify = false ) {
1367
-		$this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify );
1366
+	protected function cancel_registration($notify = false) {
1367
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1368 1368
 	}
1369 1369
 
1370 1370
 
@@ -1377,8 +1377,8 @@  discard block
 block discarded – undo
1377 1377
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1378 1378
 	*		@return void
1379 1379
 	*/
1380
-	protected function not_approve_registration( $notify = false ) {
1381
-		$this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify );
1380
+	protected function not_approve_registration($notify = false) {
1381
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1382 1382
 	}
1383 1383
 
1384 1384
 
@@ -1389,8 +1389,8 @@  discard block
 block discarded – undo
1389 1389
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1390 1390
 	*		@return void
1391 1391
 	*/
1392
-	protected function pending_registration( $notify = false ) {
1393
-		$this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify );
1392
+	protected function pending_registration($notify = false) {
1393
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1394 1394
 	}
1395 1395
 
1396 1396
 
@@ -1404,75 +1404,75 @@  discard block
 block discarded – undo
1404 1404
 	public function _reg_details_meta_box() {
1405 1405
 		EEH_Autoloader::register_line_item_display_autoloaders();
1406 1406
 		EEH_Autoloader::register_line_item_filter_autoloaders();
1407
-		EE_Registry::instance()->load_Helper( 'Line_Item' );
1407
+		EE_Registry::instance()->load_Helper('Line_Item');
1408 1408
 		$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1409 1409
 		$this->_session = $transaction->session_data();
1410 1410
 
1411 1411
 		$filters = new EE_Line_Item_Filter_Collection();
1412
-		$filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) );
1413
-		$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1414
-		$line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() );
1412
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1413
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
1414
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1415 1415
 		$filtered_line_item_tree = $line_item_filter_processor->process();
1416 1416
 
1417 1417
 		$this->_template_args['REG_ID'] = $this->_registration->ID();
1418
-		$line_item_display = new EE_Line_Item_Display( 'reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy' );
1419
-		$this->_template_args['line_item_table'] = $line_item_display->display_line_item( $filtered_line_item_tree, array( 'EE_Registration' => $this->_registration ) );
1418
+		$line_item_display = new EE_Line_Item_Display('reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
1419
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, array('EE_Registration' => $this->_registration));
1420 1420
 
1421 1421
 
1422 1422
 		$attendee = $this->_registration->attendee();
1423 1423
 
1424 1424
 
1425
-		$this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array('action'=> 'view_transaction', 'TXN_ID' => $transaction->ID() ), TXN_ADMIN_URL ), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart' ) : '';
1426
-		$this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'resend_registration', '_REG_ID'=>$this->_registration->ID(), 'redirect_to' => 'view_registration' ), REG_ADMIN_URL ), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt' ) : '';
1425
+		$this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ?EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=> 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart') : '';
1426
+		$this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration') ?EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=>'resend_registration', '_REG_ID'=>$this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
1427 1427
 
1428 1428
 
1429 1429
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1430
-		$payment = $transaction->get_first_related( 'Payment' );
1430
+		$payment = $transaction->get_first_related('Payment');
1431 1431
 		$payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1432
-		$payment_method = $payment->get_first_related( 'Payment_Method' );
1432
+		$payment_method = $payment->get_first_related('Payment_Method');
1433 1433
 		$payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
1434
-		$reg_status_class = 'status-' . $this->_registration->status_ID();
1434
+		$reg_status_class = 'status-'.$this->_registration->status_ID();
1435 1435
 		$reg_details = array(
1436 1436
 			'payment_method' => $payment_method->name(),
1437 1437
 			'response_msg' => $payment->gateway_response(),
1438
-			'registration_id' => $this->_registration->get( 'REG_code' ),
1438
+			'registration_id' => $this->_registration->get('REG_code'),
1439 1439
 			'registration_session' => $this->_registration->session_ID(),
1440
-			'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '',
1441
-			'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '',
1440
+			'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1441
+			'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1442 1442
 			);
1443 1443
 
1444 1444
 
1445
-		if ( isset( $reg_details['registration_id'] )) {
1445
+		if (isset($reg_details['registration_id'])) {
1446 1446
 			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1447
-			$this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' );
1447
+			$this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1448 1448
 			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1449 1449
 		}
1450 1450
 
1451
-		if ( isset( $reg_details['payment_method'] ) ) {
1451
+		if (isset($reg_details['payment_method'])) {
1452 1452
 			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1453
-			$this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' );
1453
+			$this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
1454 1454
 			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1455 1455
 			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1456
-			$this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' );
1456
+			$this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
1457 1457
 			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1458 1458
 		}
1459 1459
 
1460 1460
 		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1461
-		$this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' );
1461
+		$this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
1462 1462
 		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1463 1463
 
1464 1464
 		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1465
-		$this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' );
1465
+		$this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
1466 1466
 		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1467 1467
 
1468 1468
 		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1469
-		$this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' );
1469
+		$this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1470 1470
 		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1471 1471
 
1472
-		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL );
1472
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL);
1473 1473
 
1474
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1475
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1474
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
1475
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1476 1476
 
1477 1477
 	}
1478 1478
 
@@ -1488,23 +1488,23 @@  discard block
 block discarded – undo
1488 1488
 	*/
1489 1489
 	public function _reg_questions_meta_box() {
1490 1490
 
1491
-		add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $this, 'form_before_question_group' ), 10, 1 );
1492
-		add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $this, 'form_after_question_group' ), 10, 1 );
1493
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'form_form_field_label_wrap' ), 10, 1 );
1494
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'form_form_field_input__wrap' ), 10, 1 );
1491
+		add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($this, 'form_before_question_group'), 10, 1);
1492
+		add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($this, 'form_after_question_group'), 10, 1);
1493
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'form_form_field_label_wrap'), 10, 1);
1494
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'form_form_field_input__wrap'), 10, 1);
1495 1495
 
1496
-		$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $this->_registration, $this->_registration->get('EVT_ID') );
1496
+		$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($this->_registration, $this->_registration->get('EVT_ID'));
1497 1497
 
1498 1498
 		//EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1499 1499
 
1500
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
1501
-		$this->_template_args['att_questions'] = EEH_Form_Fields::generate_question_groups_html( $question_groups );
1500
+		EE_Registry::instance()->load_helper('Form_Fields');
1501
+		$this->_template_args['att_questions'] = EEH_Form_Fields::generate_question_groups_html($question_groups);
1502 1502
 
1503 1503
 		$this->_template_args['reg_questions_form_action'] = 'update_attendee_registration_form';
1504 1504
 		$this->_template_args['REG_ID'] = $this->_registration->ID();
1505 1505
 
1506
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1507
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1506
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
1507
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1508 1508
 
1509 1509
 	}
1510 1510
 
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 	 * 		@param 		string 		$output
1520 1520
 	 * 		@return 		string
1521 1521
 	 */
1522
-	public function form_before_question_group( $output ) {
1522
+	public function form_before_question_group($output) {
1523 1523
 		return '
1524 1524
 	<table class="form-table ee-width-100">
1525 1525
 		<tbody>
@@ -1536,13 +1536,13 @@  discard block
 block discarded – undo
1536 1536
 	 * 		@param 		string 		$output
1537 1537
 	 * 		@return 		string
1538 1538
 	 */
1539
-	public function form_after_question_group( $output ) {
1539
+	public function form_after_question_group($output) {
1540 1540
 		return  '
1541 1541
 			<tr class="hide-if-no-js">
1542 1542
 				<th> </th>
1543 1543
 				<td class="reg-admin-edit-attendee-question-td">
1544
-					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '">
1545
-						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span>
1544
+					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'">
1545
+						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span>
1546 1546
 						<div class="dashicons dashicons-edit"></div>
1547 1547
 					</a>
1548 1548
 				</td>
@@ -1562,11 +1562,11 @@  discard block
 block discarded – undo
1562 1562
 	 * 		@param 		string 		$label
1563 1563
 	 * 		@return 		string
1564 1564
 	 */
1565
-	public function form_form_field_label_wrap( $label ) {
1565
+	public function form_form_field_label_wrap($label) {
1566 1566
 		return '
1567 1567
 			<tr>
1568 1568
 				<th>
1569
-					' . $label  . '
1569
+					' . $label.'
1570 1570
 				</th>';
1571 1571
 	}
1572 1572
 
@@ -1580,10 +1580,10 @@  discard block
 block discarded – undo
1580 1580
 	 * 		@param 		string 		$label
1581 1581
 	 * 		@return 		string
1582 1582
 	 */
1583
-	public function form_form_field_input__wrap( $input ) {
1583
+	public function form_form_field_input__wrap($input) {
1584 1584
 		return '
1585 1585
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
1586
-					' . $input . '
1586
+					' . $input.'
1587 1587
 				</td>
1588 1588
 			</tr>';
1589 1589
 	}
@@ -1597,13 +1597,13 @@  discard block
 block discarded – undo
1597 1597
 	*		@return void
1598 1598
 	*/
1599 1599
 	protected function _update_attendee_registration_form() {
1600
-		$qstns = isset( $this->_req_data['qstn'] ) ? $this->_req_data['qstn'] : FALSE;
1601
-		$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
1602
-		$qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns );
1603
-		$success = $this->_save_attendee_registration_form( $REG_ID, $qstns );
1600
+		$qstns = isset($this->_req_data['qstn']) ? $this->_req_data['qstn'] : FALSE;
1601
+		$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE;
1602
+		$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
1603
+		$success = $this->_save_attendee_registration_form($REG_ID, $qstns);
1604 1604
 		$what = __('Registration Form', 'event_espresso');
1605
-		$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
1606
-		$this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
1605
+		$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
1606
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1607 1607
 
1608 1608
 	}
1609 1609
 
@@ -1616,26 +1616,26 @@  discard block
 block discarded – undo
1616 1616
 	 * @param bool $qstns
1617 1617
 	 * @return bool
1618 1618
 	 */
1619
-	private function _save_attendee_registration_form( $REG_ID = FALSE, $qstns = FALSE ) {
1619
+	private function _save_attendee_registration_form($REG_ID = FALSE, $qstns = FALSE) {
1620 1620
 
1621
-		if ( ! $REG_ID || ! $qstns ) {
1622
-			EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1621
+		if ( ! $REG_ID || ! $qstns) {
1622
+			EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1623 1623
 		}
1624 1624
 		$success = TRUE;
1625 1625
 
1626 1626
 		// allow others to get in on this awesome fun   :D
1627
-		do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns );
1627
+		do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns);
1628 1628
 		// loop thru questions... FINALLY!!!
1629 1629
 
1630
-		foreach ( $qstns as $QST_ID => $qstn ) {
1630
+		foreach ($qstns as $QST_ID => $qstn) {
1631 1631
 			//if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
1632
-			if ( !is_array($qstn) ) {
1633
-				$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
1632
+			if ( ! is_array($qstn)) {
1633
+				$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
1634 1634
 				continue;
1635 1635
 			}
1636 1636
 
1637 1637
 
1638
-			foreach ( $qstn as $ANS_ID => $ANS_value ) {
1638
+			foreach ($qstn as $ANS_ID => $ANS_value) {
1639 1639
 				//get answer
1640 1640
 				$query_params = array(
1641 1641
 					0 => array(
@@ -1646,8 +1646,8 @@  discard block
 block discarded – undo
1646 1646
 					);
1647 1647
 				$answer = EEM_Answer::instance()->get_one($query_params);
1648 1648
 				//this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
1649
-				if ( ! $answer instanceof EE_Answer ) {
1650
-					$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
1649
+				if ( ! $answer instanceof EE_Answer) {
1650
+					$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
1651 1651
 					continue 2;
1652 1652
 				}
1653 1653
 
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
 
1662 1662
 
1663 1663
 	//TODO: try changing this to use the model directly... not indirectly through creating a default object...
1664
-	private function _save_new_answer( $REG_ID, $QST_ID, $ans ) {
1664
+	private function _save_new_answer($REG_ID, $QST_ID, $ans) {
1665 1665
 		$set_values = array(
1666 1666
 			'QST_ID' => $QST_ID,
1667 1667
 			'REG_ID' => $REG_ID,
@@ -1688,30 +1688,30 @@  discard block
 block discarded – undo
1688 1688
 		$registrations = $REG->get_all(array(
1689 1689
 			array(
1690 1690
 				'TXN_ID'=>$this->_registration->transaction_ID(),
1691
-				'REG_ID'=>array('!=',$this->_registration->ID())
1691
+				'REG_ID'=>array('!=', $this->_registration->ID())
1692 1692
 			),
1693 1693
 			'force_join'=>array('Attendee')));
1694 1694
 
1695 1695
 		$this->_template_args['attendees'] = array();
1696 1696
 		$this->_template_args['attendee_notice'] = '';
1697 1697
 		EE_Registry::instance()->load_helper('Array');
1698
-		if ( empty( $registrations)  || ( is_array($registrations) &&  ! EEH_Array::get_one_item_from_array($registrations) ) ) {
1699
-			EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1698
+		if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) {
1699
+			EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1700 1700
 			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
1701 1701
 		} else {
1702 1702
 
1703 1703
 			$att_nmbr = 1;
1704
-			foreach ( $registrations as $registration ) {
1704
+			foreach ($registrations as $registration) {
1705 1705
 				/* @var $registration EE_Registration */
1706 1706
 				$attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object();
1707
-				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1708
-				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1709
-				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1710
-				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1707
+				$this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1708
+				$this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1709
+				$this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1710
+				$this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1711 1711
 
1712
-				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() );
1712
+				$this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array());
1713 1713
 
1714
-				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
1714
+				$this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
1715 1715
 
1716 1716
 				$att_nmbr++;
1717 1717
 			}
@@ -1723,8 +1723,8 @@  discard block
 block discarded – undo
1723 1723
 
1724 1724
 	//			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1725 1725
 		}
1726
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1727
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1726
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
1727
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1728 1728
 
1729 1729
 	}
1730 1730
 
@@ -1745,11 +1745,11 @@  discard block
 block discarded – undo
1745 1745
 		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
1746 1746
 
1747 1747
 		//now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show cereate button or not)
1748
-		if ( ! $this->_registration->is_primary_registrant() ) {
1748
+		if ( ! $this->_registration->is_primary_registrant()) {
1749 1749
 			$primary_registration = $this->_registration->get_primary_registration();
1750 1750
 			$primary_attendee = $primary_registration->attendee();
1751 1751
 
1752
-			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) {
1752
+			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
1753 1753
 				//in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
1754 1754
 				$primary_registration = NULL;
1755 1755
 			}
@@ -1758,28 +1758,28 @@  discard block
 block discarded – undo
1758 1758
 		}
1759 1759
 
1760 1760
 		$this->_template_args['ATT_ID'] = $attendee->ID();
1761
-		$this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
1762
-		$this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
1763
-		$this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
1761
+		$this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname;
1762
+		$this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname;
1763
+		$this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email;
1764 1764
 		$this->_template_args['phone'] = $attendee->phone();
1765 1765
 
1766
-		EE_Registry::instance()->load_helper( 'Formatter' );
1767
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee );
1766
+		EE_Registry::instance()->load_helper('Formatter');
1767
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
1768 1768
 
1769 1769
 
1770 1770
 		//edit link
1771
-		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
1772
-		$this->_template_args['att_edit_label'] = __('View/Edit Contact' );
1771
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
1772
+		$this->_template_args['att_edit_label'] = __('View/Edit Contact');
1773 1773
 
1774 1774
 		//create link
1775
-		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee',  '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): '';
1775
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : '';
1776 1776
 		$this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
1777 1777
 
1778 1778
 		$this->_template_args['att_check'] = $att_check;
1779 1779
 
1780 1780
 
1781
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
1782
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1781
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
1782
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1783 1783
 	}
1784 1784
 
1785 1785
 
@@ -1792,7 +1792,7 @@  discard block
 block discarded – undo
1792 1792
 	 * @access protected
1793 1793
 	 * @return void
1794 1794
 	 */
1795
-	protected function _trash_or_restore_registrations( $trash = TRUE ) {
1795
+	protected function _trash_or_restore_registrations($trash = TRUE) {
1796 1796
 		$REGM = EEM_Registration::instance();
1797 1797
 
1798 1798
 		$success = 1;
@@ -1802,26 +1802,26 @@  discard block
 block discarded – undo
1802 1802
 		$dtts = array();
1803 1803
 
1804 1804
 		//if empty _REG_ID then get out because there's nothing to do
1805
-		if ( empty( $this->_req_data['_REG_ID'] ) ) {
1805
+		if (empty($this->_req_data['_REG_ID'])) {
1806 1806
 			$msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso');
1807
-			EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ );
1808
-			$this->_redirect_after_action(FALSE, '', '', array(), TRUE );
1807
+			EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
1808
+			$this->_redirect_after_action(FALSE, '', '', array(), TRUE);
1809 1809
 		}
1810 1810
 
1811 1811
 		//Checkboxes
1812
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1812
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1813 1813
 			// if array has more than one element than success message should be plural
1814
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
1814
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
1815 1815
 			// cycle thru checkboxes
1816
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
1816
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
1817 1817
 
1818 1818
 				$REG = $REGM->get_one_by_ID($REG_ID);
1819 1819
 				$payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
1820
-				if ( $payment_count > 0 ) {
1821
-					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' );
1820
+				if ($payment_count > 0) {
1821
+					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso');
1822 1822
 					$error = 1;
1823 1823
 					$success = 0;
1824
-					EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ );
1824
+					EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
1825 1825
 					continue; //can't trash this registration because it has payments.
1826 1826
 				}
1827 1827
 				$ticket = $REG->get_first_related('Ticket');
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 				$dtts = array_merge($dtts, $dtt);
1831 1831
 
1832 1832
 				$updated = $trash ? $REG->delete() : $REG->restore();
1833
-				if ( !$updated ) {
1833
+				if ( ! $updated) {
1834 1834
 					$success = 0;
1835 1835
 				} else {
1836 1836
 					$success = 2;
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
 			$tickets[$ticket->ID()] = $ticket;
1846 1846
 			$dtts = $ticket->get_many_related('Datetime');
1847 1847
 			$updated = $trash ? $REG->delete() : $REG->restore();
1848
-			if ( ! $updated ) {
1848
+			if ( ! $updated) {
1849 1849
 				$success = 0;
1850 1850
 			}
1851 1851
 
@@ -1855,10 +1855,10 @@  discard block
 block discarded – undo
1855 1855
 		EEM_Ticket::instance()->update_tickets_sold($tickets);
1856 1856
 		EEM_Datetime::instance()->update_sold($dtts);
1857 1857
 
1858
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
1859
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
1858
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
1859
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
1860 1860
 		$overwrite_msgs = $error ? TRUE : FALSE;
1861
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs );
1861
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
1862 1862
 	}
1863 1863
 
1864 1864
 
@@ -1882,16 +1882,16 @@  discard block
 block discarded – undo
1882 1882
 		$success = 1;
1883 1883
 
1884 1884
 		//Checkboxes
1885
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1885
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1886 1886
 			// if array has more than one element than success message should be plural
1887
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
1887
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
1888 1888
 			// cycle thru checkboxes
1889
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
1889
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
1890 1890
 				$REG = $REG_MDL->get_one_by_ID($REG_ID);
1891
-				if ( ! $REG instanceof EE_Registration )
1891
+				if ( ! $REG instanceof EE_Registration)
1892 1892
 					continue;
1893 1893
 				$deleted = $this->_delete_registration($REG);
1894
-				if ( !$deleted ) {
1894
+				if ( ! $deleted) {
1895 1895
 					$success = 0;
1896 1896
 				}
1897 1897
 			}
@@ -1901,15 +1901,15 @@  discard block
 block discarded – undo
1901 1901
 			$REG_ID = $this->_req_data['_REG_ID'];
1902 1902
 			$REG = $REG_MDL->get_one_by_ID($REG_ID);
1903 1903
 			$deleted = $this->_delete_registration($REG);
1904
-			if ( ! $deleted ) {
1904
+			if ( ! $deleted) {
1905 1905
 				$success = 0;
1906 1906
 			}
1907 1907
 
1908 1908
 		}
1909 1909
 
1910
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
1911
-		$action_desc = __( 'permanently deleted.', 'event_espresso' );
1912
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE );
1910
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
1911
+		$action_desc = __('permanently deleted.', 'event_espresso');
1912
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE);
1913 1913
 	}
1914 1914
 
1915 1915
 
@@ -1921,31 +1921,31 @@  discard block
 block discarded – undo
1921 1921
 	 * @param  EE_Registration $REG registration to be deleted permenantly
1922 1922
 	 * @return boolean              true = successful deletion, false = fail.
1923 1923
 	 */
1924
-	protected function _delete_registration( EE_Registration $REG ) {
1924
+	protected function _delete_registration(EE_Registration $REG) {
1925 1925
 		//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
1926 1926
 		$TXN = $REG->get_first_related('Transaction');
1927 1927
 		$REGS = $TXN->get_many_related('Registration');
1928 1928
 
1929 1929
 		$all_trashed = TRUE;
1930
-		foreach ( $REGS as $registration ) {
1931
-			if ( ! $registration->get('REG_deleted') )
1930
+		foreach ($REGS as $registration) {
1931
+			if ( ! $registration->get('REG_deleted'))
1932 1932
 				$all_trashed = FALSE;
1933 1933
 		}
1934 1934
 
1935
-		if ( ! $all_trashed ) {
1936
-			EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1935
+		if ( ! $all_trashed) {
1936
+			EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1937 1937
 			return false;
1938 1938
 		}
1939 1939
 
1940 1940
 		//k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
1941
-		foreach ( $REGS as $registration ) {
1941
+		foreach ($REGS as $registration) {
1942 1942
 
1943 1943
 			//delete related answers
1944 1944
 			$registration->delete_related_permanently('Answer');
1945 1945
 
1946 1946
 			//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
1947 1947
 			$attendee = $registration->get_first_related('Attendee');
1948
-			if ( $attendee instanceof EE_Attendee ) {
1948
+			if ($attendee instanceof EE_Attendee) {
1949 1949
 				$registration->_remove_relation_to($attendee, 'Attendee');
1950 1950
 			}
1951 1951
 
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
 			//now delete permanently the checkins related to this registration.
1956 1956
 			$registration->delete_related_permanently('Checkin');
1957 1957
 
1958
-			if ( $registration->ID() === $REG->ID() )
1958
+			if ($registration->ID() === $REG->ID())
1959 1959
 				continue; //we don't want to delete permanently the existing registration just yet.
1960 1960
 
1961 1961
 			//remove relation to transaction for these registrations if NOT the existing registrations
@@ -1988,34 +1988,34 @@  discard block
 block discarded – undo
1988 1988
 	 * @return void
1989 1989
 	 */
1990 1990
 	public function new_registration() {
1991
-		if ( ! $this->_set_reg_event() ) {
1992
-			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') );
1991
+		if ( ! $this->_set_reg_event()) {
1992
+			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso'));
1993 1993
 		}
1994
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
1994
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
1995 1995
 
1996 1996
 		// gotta start with a clean slate if we're not coming here via ajax
1997
-		if ( ! defined('DOING_AJAX' ) && ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ))) {
1998
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
1997
+		if ( ! defined('DOING_AJAX') && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))) {
1998
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1999 1999
 		}
2000 2000
 
2001
-		$this->_template_args['event_name'] = '' ;
2001
+		$this->_template_args['event_name'] = '';
2002 2002
 		// event name
2003
-		if ( $this->_reg_event ) {
2003
+		if ($this->_reg_event) {
2004 2004
 			$this->_template_args['event_name'] = $this->_reg_event->name();
2005
-			$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL );
2006
-			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
2007
-			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
2005
+			$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL);
2006
+			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>';
2007
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
2008 2008
 		}
2009 2009
 
2010 2010
 		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2011 2011
 
2012
-		if ( defined('DOING_AJAX' ) )
2012
+		if (defined('DOING_AJAX'))
2013 2013
 			$this->_return_json();
2014 2014
 
2015 2015
 
2016 2016
 		// grab header
2017
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2018
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2017
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2018
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2019 2019
 
2020 2020
 		//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2021 2021
 		// the details template wrapper
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
 	 */
2034 2034
 	protected function _get_registration_step_content() {
2035 2035
 
2036
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php';
2036
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php';
2037 2037
 		$template_args = array(
2038 2038
 			'title' => '',
2039 2039
 			'content' => '',
@@ -2054,11 +2054,11 @@  discard block
 block discarded – undo
2054 2054
 
2055 2055
 		//if the cart is empty then we know we're at step one so we'll display ticket selector
2056 2056
 		$cart = EE_Registry::instance()->SSN->get_session_data('cart');
2057
-		$step = empty( $cart ) ? 'ticket' : 'questions';
2058
-		switch ( $step ) {
2057
+		$step = empty($cart) ? 'ticket' : 'questions';
2058
+		switch ($step) {
2059 2059
 			case 'ticket' :
2060 2060
 				$template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2061
-				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event );
2061
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2062 2062
 				$template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso');
2063 2063
 				$template_args['show_notification_toggle'] = FALSE;
2064 2064
 				break;
@@ -2071,9 +2071,9 @@  discard block
 block discarded – undo
2071 2071
 				break;
2072 2072
 		}
2073 2073
 
2074
-		$this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route.
2074
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route.
2075 2075
 
2076
-		return EEH_Template::display_template( $template_path, $template_args, TRUE );
2076
+		return EEH_Template::display_template($template_path, $template_args, TRUE);
2077 2077
 	}
2078 2078
 
2079 2079
 
@@ -2087,11 +2087,11 @@  discard block
 block discarded – undo
2087 2087
 	*		@return boolean
2088 2088
 	*/
2089 2089
 	private function _set_reg_event() {
2090
-		if ( is_object( $this->_reg_event )) {
2090
+		if (is_object($this->_reg_event)) {
2091 2091
 			return TRUE;
2092 2092
 		}
2093
-		$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE;
2094
-		if ( ! $EVT_ID ) {
2093
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE;
2094
+		if ( ! $EVT_ID) {
2095 2095
 			return FALSE;
2096 2096
 		}
2097 2097
 
@@ -2112,62 +2112,62 @@  discard block
 block discarded – undo
2112 2112
 	public function process_reg_step() {
2113 2113
 
2114 2114
 		$this->_set_reg_event();
2115
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
2115
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
2116 2116
 
2117 2117
 		//what step are we on?
2118
-		$cart = EE_Registry::instance()->SSN->get_session_data( 'cart' );
2119
-		$step = empty( $cart ) ? 'ticket' : 'questions';
2118
+		$cart = EE_Registry::instance()->SSN->get_session_data('cart');
2119
+		$step = empty($cart) ? 'ticket' : 'questions';
2120 2120
 
2121 2121
 		//if doing ajax then we need to verify the nonce
2122
-		if ( 'DOING_AJAX' ) {
2123
-			$nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : '';
2124
-			$this->_verify_nonce( $nonce, $this->_req_nonce );
2122
+		if ('DOING_AJAX') {
2123
+			$nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2124
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2125 2125
 		}
2126 2126
 
2127
-		switch ( $step ) {
2127
+		switch ($step) {
2128 2128
 			case 'ticket' :
2129 2129
 				//process ticket selection
2130 2130
 				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2131
-				if ( $success ) {
2132
-					EE_Error::add_success( __('Tickets Selected. Now complete the registration.'), 'event_espresso');
2131
+				if ($success) {
2132
+					EE_Error::add_success(__('Tickets Selected. Now complete the registration.'), 'event_espresso');
2133 2133
 				} else {
2134 2134
 					$query_args['step_error'] = $this->_req_data['step_error'] = TRUE;
2135 2135
 				}
2136
-				if ( defined('DOING_AJAX') ) {
2136
+				if (defined('DOING_AJAX')) {
2137 2137
 					$this->new_registration(); //display next step
2138 2138
 				} else {
2139 2139
 					$query_args['action'] = 'new_registration';
2140 2140
 					$query_args['processing_registration'] = true;
2141 2141
 					$query_args['event_id'] = $this->_reg_event->ID();
2142
-					$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2142
+					$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2143 2143
 				}
2144 2144
 				break;
2145 2145
 			case 'questions' :
2146
-				if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) {
2147
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 );
2146
+				if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2147
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2148 2148
 				}
2149 2149
 				//process registration
2150 2150
 				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2151
-				if ( ! $transaction instanceof EE_Transaction ) {
2151
+				if ( ! $transaction instanceof EE_Transaction) {
2152 2152
 					$query_args = array(
2153 2153
 						'action' => 'new_registration',
2154 2154
 						'processing_registration' => true,
2155 2155
 						'event_id' => $this->_reg_event->ID()
2156 2156
 					);
2157 2157
 
2158
-					if ( defined('DOING_AJAX' )) {
2158
+					if (defined('DOING_AJAX')) {
2159 2159
 						//display registration form again because there are errors (maybe validation?)
2160 2160
 						$this->new_registration();
2161 2161
 						return;
2162 2162
 					} else {
2163
-						$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2163
+						$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2164 2164
 						return;
2165 2165
 					}
2166 2166
 				}
2167 2167
 				/** @type EE_Transaction_Payments $transaction_payments */
2168
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
2168
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2169 2169
 				// maybe update status, and make sure to save transaction if not done already
2170
-				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid( $transaction )) {
2170
+				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid($transaction)) {
2171 2171
 					$transaction->save();
2172 2172
 				}
2173 2173
 				$query_args = array(
@@ -2175,8 +2175,8 @@  discard block
 block discarded – undo
2175 2175
 					'TXN_ID' => $transaction->ID(),
2176 2176
 					'page' => 'espresso_transactions'
2177 2177
 				);
2178
-				EE_Error::add_success( __('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso') );
2179
-				$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2178
+				EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso'));
2179
+				$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2180 2180
 				break;
2181 2181
 			}
2182 2182
 
@@ -2196,7 +2196,7 @@  discard block
 block discarded – undo
2196 2196
 	*		@return void
2197 2197
 	*/
2198 2198
 	protected function _attendee_contact_list_table() {
2199
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2199
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2200 2200
 		$this->_search_btn_label = __('Contacts', 'event_espresso');
2201 2201
 		$this->display_admin_list_table_page_with_no_sidebar();
2202 2202
 	}
@@ -2211,10 +2211,10 @@  discard block
 block discarded – undo
2211 2211
 	*		@access public
2212 2212
 	*		@return array
2213 2213
 	*/
2214
-	public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) {
2214
+	public function get_attendees($per_page, $count = FALSE, $trash = FALSE) {
2215 2215
 
2216
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2217
-		require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' );
2216
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2217
+		require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
2218 2218
 		$ATT_MDL = EEM_Attendee::instance();
2219 2219
 
2220 2220
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
@@ -2242,47 +2242,47 @@  discard block
 block discarded – undo
2242 2242
 				$orderby = 'ATT_lname';
2243 2243
 		}
2244 2244
 
2245
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
2245
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
2246 2246
 
2247
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
2248
-		$per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10;
2249
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
2247
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2248
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2249
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2250 2250
 
2251 2251
 		$_where = array();
2252 2252
 
2253
-		if ( isset( $this->_req_data['s'] ) ) {
2254
-			$sstr = '%' . $this->_req_data['s'] . '%';
2253
+		if (isset($this->_req_data['s'])) {
2254
+			$sstr = '%'.$this->_req_data['s'].'%';
2255 2255
 			$_where['OR'] = array(
2256
-				'Registration.Event.EVT_name' => array( 'LIKE', $sstr),
2257
-				'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ),
2258
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
2259
-				'ATT_fname' => array( 'LIKE', $sstr ),
2260
-				'ATT_lname' => array( 'LIKE', $sstr ),
2261
-				'ATT_short_bio' => array( 'LIKE', $sstr ),
2262
-				'ATT_email' => array('LIKE', $sstr ),
2263
-				'ATT_address' => array( 'LIKE', $sstr ),
2264
-				'ATT_address2' => array( 'LIKE', $sstr ),
2265
-				'ATT_city' => array( 'LIKE', $sstr ),
2266
-				'Country.CNT_name' => array( 'LIKE', $sstr ),
2267
-				'State.STA_name' => array('LIKE', $sstr ),
2268
-				'ATT_phone' => array( 'LIKE', $sstr ),
2269
-				'Registration.REG_final_price' => array( 'LIKE', $sstr ),
2270
-				'Registration.REG_code' => array( 'LIKE', $sstr ),
2271
-				'Registration.REG_count' => array( 'LIKE' , $sstr ),
2272
-				'Registration.REG_group_size' => array( 'LIKE' , $sstr )
2256
+				'Registration.Event.EVT_name' => array('LIKE', $sstr),
2257
+				'Registration.Event.EVT_desc' => array('LIKE', $sstr),
2258
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2259
+				'ATT_fname' => array('LIKE', $sstr),
2260
+				'ATT_lname' => array('LIKE', $sstr),
2261
+				'ATT_short_bio' => array('LIKE', $sstr),
2262
+				'ATT_email' => array('LIKE', $sstr),
2263
+				'ATT_address' => array('LIKE', $sstr),
2264
+				'ATT_address2' => array('LIKE', $sstr),
2265
+				'ATT_city' => array('LIKE', $sstr),
2266
+				'Country.CNT_name' => array('LIKE', $sstr),
2267
+				'State.STA_name' => array('LIKE', $sstr),
2268
+				'ATT_phone' => array('LIKE', $sstr),
2269
+				'Registration.REG_final_price' => array('LIKE', $sstr),
2270
+				'Registration.REG_code' => array('LIKE', $sstr),
2271
+				'Registration.REG_count' => array('LIKE', $sstr),
2272
+				'Registration.REG_group_size' => array('LIKE', $sstr)
2273 2273
 				);
2274 2274
 		}
2275 2275
 
2276 2276
 
2277
-		$offset = ($current_page-1)*$per_page;
2278
-		$limit = $count ? NULL : array( $offset, $per_page );
2277
+		$offset = ($current_page - 1) * $per_page;
2278
+		$limit = $count ? NULL : array($offset, $per_page);
2279 2279
 
2280
-		if ( $trash ) {
2281
-			$_where['status'] = array( '!=', 'publish' );
2282
-			$all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2280
+		if ($trash) {
2281
+			$_where['status'] = array('!=', 'publish');
2282
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2283 2283
 		} else {
2284
-			$_where['status'] = array( 'IN', array( 'publish' ) );
2285
-			$all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit)) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) );
2284
+			$_where['status'] = array('IN', array('publish'));
2285
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2286 2286
 		}
2287 2287
 
2288 2288
 		return $all_attendees;
@@ -2299,10 +2299,10 @@  discard block
 block discarded – undo
2299 2299
 	 */
2300 2300
 	protected function _resend_registration() {
2301 2301
 		$this->_process_resend_registration();
2302
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array(
2302
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array(
2303 2303
 			'action' => 'default'
2304 2304
 		);
2305
-		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE );
2305
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2306 2306
 	}
2307 2307
 
2308 2308
 
@@ -2310,27 +2310,27 @@  discard block
 block discarded – undo
2310 2310
 
2311 2311
 
2312 2312
 
2313
-	public function _registrations_report(){
2314
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2315
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce( 
2313
+	public function _registrations_report() {
2314
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2315
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce( 
2316 2316
 				array(
2317 2317
 					'page' => 'espresso_batch',
2318 2318
 					'batch' => 'file',
2319
-					'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2320
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ),
2321
-					'return_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2322
-				)) );
2319
+					'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2320
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2321
+					'return_url' => urlencode($this->_req_data['return_url']),
2322
+				)));
2323 2323
 		} else {
2324
-			EE_Registry::instance()->load_helper( 'File' );
2324
+			EE_Registry::instance()->load_helper('File');
2325 2325
 			$new_request_args = array(
2326 2326
 				'export' => 'report',
2327 2327
 				'action' => 'registrations_report_for_event',
2328
-				'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2328
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2329 2329
 			);
2330 2330
 			$this->_req_data = array_merge($this->_req_data, $new_request_args);
2331 2331
 
2332
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2333
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2332
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2333
+				require_once(EE_CLASSES.'EE_Export.class.php');
2334 2334
 				$EE_Export = EE_Export::instance($this->_req_data);
2335 2335
 				$EE_Export->export();
2336 2336
 			}
@@ -2339,28 +2339,28 @@  discard block
 block discarded – undo
2339 2339
 
2340 2340
 
2341 2341
 
2342
-	public function _contact_list_export(){
2343
-		EE_Registry::instance()->load_helper( 'File' );
2344
-		if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2345
-			require_once(EE_CLASSES . 'EE_Export.class.php');
2342
+	public function _contact_list_export() {
2343
+		EE_Registry::instance()->load_helper('File');
2344
+		if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2345
+			require_once(EE_CLASSES.'EE_Export.class.php');
2346 2346
 			$EE_Export = EE_Export::instance($this->_req_data);
2347 2347
 			$EE_Export->export_attendees();
2348 2348
 		}
2349 2349
 	}
2350 2350
 
2351
-	public function _contact_list_report(){
2352
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2353
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce( 
2351
+	public function _contact_list_report() {
2352
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2353
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce( 
2354 2354
 				array(
2355 2355
 					'page' => 'espresso_batch',
2356 2356
 					'batch' => 'file',
2357
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ),
2358
-					'return_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2359
-				)) );
2357
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2358
+					'return_url' => urlencode($this->_req_data['return_url']),
2359
+				)));
2360 2360
 		} else {
2361
-			EE_Registry::instance()->load_helper( 'File' );
2362
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2363
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2361
+			EE_Registry::instance()->load_helper('File');
2362
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2363
+				require_once(EE_CLASSES.'EE_Export.class.php');
2364 2364
 				$EE_Export = EE_Export::instance($this->_req_data);
2365 2365
 				$EE_Export->report_attendees();
2366 2366
 			}
@@ -2380,73 +2380,73 @@  discard block
 block discarded – undo
2380 2380
 	 * @return void
2381 2381
 	 */
2382 2382
 	protected function _duplicate_attendee() {
2383
-		$action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default';
2383
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2384 2384
 		//verify we have necessary info
2385
-		if ( empty($this->_req_data['_REG_ID'] )  ) {
2386
-			EE_Error::add_error( __('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'),  __FILE__, __LINE__, __FUNCTION__ );
2387
-			$query_args = array( 'action' => $action );
2385
+		if (empty($this->_req_data['_REG_ID'])) {
2386
+			EE_Error::add_error(__('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2387
+			$query_args = array('action' => $action);
2388 2388
 			$this->_redirect_after_action('', '', '', $query_args, TRUE);
2389 2389
 		}
2390 2390
 
2391 2391
 		//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2392
-		$registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] );
2392
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2393 2393
 		$attendee = $registration->attendee();
2394 2394
 
2395 2395
 		//remove relation of existing attendee on registration
2396
-		$registration->_remove_relation_to($attendee, 'Attendee' );
2396
+		$registration->_remove_relation_to($attendee, 'Attendee');
2397 2397
 		//new attendee
2398 2398
 		$new_attendee = clone $attendee;
2399
-		$new_attendee->set( 'ATT_ID', 0 );
2399
+		$new_attendee->set('ATT_ID', 0);
2400 2400
 		$new_attendee->save();
2401 2401
 
2402 2402
 		//add new attendee to reg
2403
-		$registration->_add_relation_to( $new_attendee, 'Attendee');
2403
+		$registration->_add_relation_to($new_attendee, 'Attendee');
2404 2404
 
2405
-		EE_Error::add_success( __('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso') );
2405
+		EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso'));
2406 2406
 
2407 2407
 		//redirect to edit page for attendee
2408
-		$query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' );
2408
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2409 2409
 
2410
-		$this->_redirect_after_action( '', '', '', $query_args, TRUE );
2410
+		$this->_redirect_after_action('', '', '', $query_args, TRUE);
2411 2411
 	}
2412 2412
 
2413 2413
 
2414 2414
 	//related to cpt routes
2415 2415
 	protected function _insert_update_cpt_item($post_id, $post) {
2416 2416
 		$success = true;
2417
-		$attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id );
2417
+		$attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2418 2418
 		//for attendee updates
2419
-		if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) {
2419
+		if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2420 2420
 			//note we should only be UPDATING attendees at this point.
2421 2421
 			$updated_fields = array(
2422 2422
 				'ATT_fname' => $this->_req_data['ATT_fname'],
2423 2423
 				'ATT_lname' => $this->_req_data['ATT_lname'],
2424
-				'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2424
+				'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
2425 2425
 				'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2426 2426
 				'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2427
-				'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '',
2428
-				'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '',
2429
-				'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '',
2430
-				'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '',
2431
-				'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '',
2432
-				'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : ''
2427
+				'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2428
+				'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2429
+				'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2430
+				'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2431
+				'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2432
+				'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : ''
2433 2433
 				);
2434
-			foreach ( $updated_fields as $field => $value ) {
2434
+			foreach ($updated_fields as $field => $value) {
2435 2435
 				$attendee->set($field, $value);
2436 2436
 			}
2437 2437
 
2438 2438
 			$success = $attendee->save();
2439 2439
 
2440
-			$attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() );
2441
-			foreach ( $attendee_update_callbacks as $a_callback ) {
2442
-				if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) {
2443
-					throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback ) );
2440
+			$attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array());
2441
+			foreach ($attendee_update_callbacks as $a_callback) {
2442
+				if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2443
+					throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback));
2444 2444
 				}
2445 2445
 			}
2446 2446
 		}
2447 2447
 
2448
-		if ( $success === FALSE )
2449
-			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2448
+		if ($success === FALSE)
2449
+			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2450 2450
 
2451 2451
 	}
2452 2452
 
@@ -2466,17 +2466,17 @@  discard block
 block discarded – undo
2466 2466
 		remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2467 2467
 		remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2468 2468
 
2469
-		if ( post_type_supports( 'espresso_attendees', 'excerpt') ) {
2470
-			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' );
2469
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
2470
+			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal');
2471 2471
 		}
2472 2472
 
2473
-		if ( post_type_supports( 'espresso_attendees', 'comments') ) {
2473
+		if (post_type_supports('espresso_attendees', 'comments')) {
2474 2474
 			add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2475 2475
 		}
2476 2476
 
2477
-		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' );
2478
-		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' );
2479
-		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2477
+		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2478
+		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2479
+		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2480 2480
 	}
2481 2481
 
2482 2482
 
@@ -2485,10 +2485,10 @@  discard block
 block discarded – undo
2485 2485
 	 * @param  WP_Post $post wp post object
2486 2486
 	 * @return string        attendee contact info ( and form )
2487 2487
 	 */
2488
-	public function attendee_contact_info( $post ) {
2488
+	public function attendee_contact_info($post) {
2489 2489
 		//get attendee object ( should already have it )
2490 2490
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2491
-		$template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2491
+		$template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php';
2492 2492
 		EEH_Template::display_template($template, $this->_template_args);
2493 2493
 	}
2494 2494
 
@@ -2504,12 +2504,12 @@  discard block
 block discarded – undo
2504 2504
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2505 2505
 		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
2506 2506
 				new EE_Question_Form_Input(
2507
-				EE_Question::new_instance( array(
2507
+				EE_Question::new_instance(array(
2508 2508
 					'QST_ID' => 0,
2509 2509
 					'QST_display_text' => __('State/Province', 'event_espresso'),
2510 2510
 					'QST_system' => 'admin-state'
2511 2511
 					)),
2512
-				EE_Answer::new_instance( array(
2512
+				EE_Answer::new_instance(array(
2513 2513
 					'ANS_ID' => 0,
2514 2514
 					'ANS_value' => $this->_cpt_model_obj->state_ID()
2515 2515
 					)),
@@ -2522,12 +2522,12 @@  discard block
 block discarded – undo
2522 2522
 			));
2523 2523
 		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
2524 2524
 				new EE_Question_Form_Input(
2525
-				EE_Question::new_instance( array(
2525
+				EE_Question::new_instance(array(
2526 2526
 					'QST_ID' => 0,
2527 2527
 					'QST_display_text' => __('Country', 'event_espresso'),
2528 2528
 					'QST_system' => 'admin-country'
2529 2529
 					)),
2530
-				EE_Answer::new_instance( array(
2530
+				EE_Answer::new_instance(array(
2531 2531
 					'ANS_ID' => 0,
2532 2532
 					'ANS_value' => $this->_cpt_model_obj->country_ID()
2533 2533
 					)),
@@ -2538,8 +2538,8 @@  discard block
 block discarded – undo
2538 2538
 					'append_qstn_id' => FALSE
2539 2539
 					)
2540 2540
 				));
2541
-		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2542
-		EEH_Template::display_template($template, $this->_template_args );
2541
+		$template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
2542
+		EEH_Template::display_template($template, $this->_template_args);
2543 2543
 
2544 2544
 	}
2545 2545
 
@@ -2549,11 +2549,11 @@  discard block
 block discarded – undo
2549 2549
 	*		@access protected
2550 2550
 	*		@return void
2551 2551
 	*/
2552
-	public function attendee_registrations_meta_box( $post ) {
2552
+	public function attendee_registrations_meta_box($post) {
2553 2553
 
2554 2554
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2555 2555
 		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2556
-		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2556
+		$template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
2557 2557
 		EEH_Template::display_template($template, $this->_template_args);
2558 2558
 
2559 2559
 	}
@@ -2567,8 +2567,8 @@  discard block
 block discarded – undo
2567 2567
 	 * @return string        html for new form.
2568 2568
 	 */
2569 2569
 	public function after_title_form_fields($post) {
2570
-		if ( $post->post_type == 'espresso_attendees' ) {
2571
-			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2570
+		if ($post->post_type == 'espresso_attendees') {
2571
+			$template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
2572 2572
 			$template_args['attendee'] = $this->_cpt_model_obj;
2573 2573
 			EEH_Template::display_template($template, $template_args);
2574 2574
 		}
@@ -2585,21 +2585,21 @@  discard block
 block discarded – undo
2585 2585
 	*		@access protected
2586 2586
 	*		@return void
2587 2587
 	*/
2588
-	protected function _trash_or_restore_attendees( $trash = TRUE ) {
2588
+	protected function _trash_or_restore_attendees($trash = TRUE) {
2589 2589
 
2590
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2590
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2591 2591
 
2592 2592
 		$ATT_MDL = EEM_Attendee::instance();
2593 2593
 
2594 2594
 		$success = 1;
2595 2595
 		//Checkboxes
2596
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2596
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2597 2597
 			// if array has more than one element than success message should be plural
2598
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2598
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2599 2599
 			// cycle thru checkboxes
2600
-			while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) {
2601
-				$updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID);
2602
-				if ( !$updated ) {
2600
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2601
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2602
+				if ( ! $updated) {
2603 2603
 					$success = 0;
2604 2604
 				}
2605 2605
 			}
@@ -2608,18 +2608,18 @@  discard block
 block discarded – undo
2608 2608
 			// grab single id and delete
2609 2609
 			$ATT_ID = absint($this->_req_data['ATT_ID']);
2610 2610
 			//get attendee
2611
-			$att = $ATT_MDL->get_one_by_ID( $ATT_ID );
2611
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
2612 2612
 			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2613 2613
 			$updated = $att->save();
2614
-			if ( ! $updated ) {
2614
+			if ( ! $updated) {
2615 2615
 				$success = 0;
2616 2616
 			}
2617 2617
 
2618 2618
 		}
2619 2619
 
2620
-		$what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' );
2621
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
2622
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) );
2620
+		$what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2621
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2622
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2623 2623
 
2624 2624
 	}
2625 2625
 
Please login to merge, or discard this patch.