Completed
Branch BUG-10059-allow-multiple-invoi... (76c0cc)
by
unknown
40:24 queued 26:41
created
payment_methods/Paypal_Express/EEG_Paypal_Express.gateway.php 2 patches
Doc Comments   -4 removed lines patch added patch discarded remove patch
@@ -404,10 +404,6 @@
 block discarded – undo
404 404
 	/**
405 405
 	 *  Log a "Cleared" request.
406 406
 	 *
407
-	 *	@param array        $response
408
-	 *	@param EEI_Payment  $payment
409
-	 *	@param string  		$info
410
-	 *	@return void
411 407
 	 */
412 408
 	private function _log_clean_request( $request_prms, $payment, $info ) {
413 409
 		$cleaned_request_data = $request_prms;
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); }
2 2
 
3 3
 /**
4 4
  * ----------------------------------------------
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 *  @param type $settings_array
84 84
 	 */
85
-	public function set_settings( $settings_array ) {
85
+	public function set_settings($settings_array) {
86 86
 		parent::set_settings($settings_array);
87 87
 		// Redirect URL.
88
-		if ( $this->_debug_mode ) {
88
+		if ($this->_debug_mode) {
89 89
 			$this->_base_gateway_url = 'https://api-3t.sandbox.paypal.com/nvp';
90 90
 		} else {
91 91
 			$this->_base_gateway_url = 'https://api-3t.paypal.com/nvp';
@@ -100,19 +100,19 @@  discard block
 block discarded – undo
100 100
 	 *  @param type $return_url
101 101
 	 *  @param type $cancel_url
102 102
 	 */
103
-	public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) {
104
-		if ( ! $payment instanceof EEI_Payment ) {
105
-			$payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) );
106
-			$payment->set_status( $this->_pay_model->failed_status() );
103
+	public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) {
104
+		if ( ! $payment instanceof EEI_Payment) {
105
+			$payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso'));
106
+			$payment->set_status($this->_pay_model->failed_status());
107 107
 			return $payment;
108 108
 		}
109 109
 		$transaction = $payment->transaction();
110
-		if ( ! $transaction instanceof EEI_Transaction ) {
111
-			$payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) );
112
-			$payment->set_status( $this->_pay_model->failed_status() );
110
+		if ( ! $transaction instanceof EEI_Transaction) {
111
+			$payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso'));
112
+			$payment->set_status($this->_pay_model->failed_status());
113 113
 			return $payment;
114 114
 		}
115
-		$order_description = substr( $this->_format_order_description($payment), 0, 127 );
115
+		$order_description = substr($this->_format_order_description($payment), 0, 127);
116 116
 		$primary_registration = $transaction->primary_registration();
117 117
 		$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false;
118 118
 		$locale = explode('-', get_bloginfo('language'));
@@ -126,28 +126,28 @@  discard block
 block discarded – undo
126 126
 			'RETURNURL' => $return_url,
127 127
 			'CANCELURL' => $cancel_url,
128 128
 			'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
129
-			'SOLUTIONTYPE' => 'Sole',	// Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. 
130
-			'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this
129
+			'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. 
130
+			'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this
131 131
 			'LOCALECODE' => $locale[1]	// Locale of the pages displayed by PayPal during Express Checkout.
132 132
 		);
133 133
 
134 134
 		// Show itemized list.
135
-		if ( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) {
135
+		if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) {
136 136
 			$item_num = 0;
137 137
 			$itemized_sum = 0;
138 138
 			$total_line_items = $transaction->total_line_item();
139 139
 			// Go through each item in the list.
140
-			foreach ( $total_line_items->get_items() as $line_item ) {
141
-				if ( $line_item instanceof EE_Line_Item ) {
140
+			foreach ($total_line_items->get_items() as $line_item) {
141
+				if ($line_item instanceof EE_Line_Item) {
142 142
 					// PayPal doesn't like line items with 0.00 amount, so we may skip those.
143
-					if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) {
143
+					if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) {
144 144
 						continue;
145 145
 					}
146 146
 
147 147
 					$unit_price = $line_item->unit_price();
148 148
 					$line_item_quantity = $line_item->quantity();
149 149
 					// This is a discount.
150
-					if ( $line_item->is_percent() ) {
150
+					if ($line_item->is_percent()) {
151 151
 						$unit_price = $line_item->total();
152 152
 						$line_item_quantity = 1;
153 153
 					}
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 					// Item description.
157 157
 					$token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127);
158 158
 					// Cost of individual item.
159
-					$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price );
159
+					$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price);
160 160
 					// Item Number.
161 161
 					$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
162 162
 					// Item quantity.
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
174 174
 			$token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
175 175
 
176
-			$itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 );
176
+			$itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2);
177 177
 			// If we were not able to recognize some item like promotion, surcharge or cancellation, 
178 178
 			// add the difference as an extra line item.
179
-			if ( $itemized_sum_diff_from_txn_total != 0 ) {
179
+			if ($itemized_sum_diff_from_txn_total != 0) {
180 180
 				// Item Name.
181
-				$token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 );
181
+				$token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127);
182 182
 				// Item description.
183
-				$token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr( $line_item->desc(), 0, 127 );
183
+				$token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127);
184 184
 				// Cost of individual item.
185
-				$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total );
185
+				$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
186 186
 				// Item Number.
187 187
 				$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
188 188
 				// Item quantity.
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 		} else {
193 193
 			// Just one Item.
194 194
 			// Item Name.
195
-			$token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( sprintf( __('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code() ), 0, 127 );
195
+			$token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr(sprintf(__('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code()), 0, 127);
196 196
 			// Item description.
197
-			$token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( sprintf( __('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code() ), 0, 127 );
197
+			$token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr(sprintf(__('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code()), 0, 127);
198 198
 			// Cost of individual item.
199
-			$token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() );
199
+			$token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount());
200 200
 			// Item Number.
201 201
 			$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1;
202 202
 			// Item quantity.
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 			// Digital item is sold.
205 205
 			$token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical';
206 206
 			// Item's sales S/H and tax amount.
207
-			$token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() );
207
+			$token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount());
208 208
 			$token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0';
209 209
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
210 210
 			$token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
211 211
 		}
212 212
 		// Automatically filling out shipping and contact information.
213
-		if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) {
214
-			$token_request_dtls['NOSHIPPING'] = '2';	//  If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
213
+		if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) {
214
+			$token_request_dtls['NOSHIPPING'] = '2'; //  If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
215 215
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address();
216 216
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2();
217 217
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city();
@@ -220,34 +220,34 @@  discard block
 block discarded – undo
220 220
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
221 221
 			$token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
222 222
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
223
-		} elseif ( ! $this->_request_shipping_addr ) {
223
+		} elseif ( ! $this->_request_shipping_addr) {
224 224
 			// Do not request shipping details on the PP Checkout page.
225 225
 			$token_request_dtls['NOSHIPPING'] = '1';
226 226
 			$token_request_dtls['REQCONFIRMSHIPPING'] = '0';
227 227
 
228 228
 		}
229 229
 		// Used a business/personal logo on the PayPal page.
230
-		if ( ! empty($this->_image_url) ) {
230
+		if ( ! empty($this->_image_url)) {
231 231
 			$token_request_dtls['LOGOIMG'] = $this->_image_url;
232 232
 		}
233 233
 		// Request PayPal token.
234
-		$token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment );
235
-		$token_rstatus = $this->_ppExpress_check_response( $token_request_response );
236
-		$response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array();
237
-		if ( $token_rstatus['status'] ) {
234
+		$token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment);
235
+		$token_rstatus = $this->_ppExpress_check_response($token_request_response);
236
+		$response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array();
237
+		if ($token_rstatus['status']) {
238 238
 			// We got the Token so we may continue with the payment and redirect the client.
239
-			$payment->set_details( $response_args );
239
+			$payment->set_details($response_args);
240 240
 
241
-			$gateway_url = ( $this->_debug_mode ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
242
-			$payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] );
241
+			$gateway_url = ($this->_debug_mode) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
242
+			$payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']);
243 243
 		} else {
244
-			if ( isset($response_args['L_ERRORCODE']) ) {
245
-				$payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] );
244
+			if (isset($response_args['L_ERRORCODE'])) {
245
+				$payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']);
246 246
 			} else {
247
-				$payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) );
247
+				$payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso'));
248 248
 			}
249
-			$payment->set_details( $response_args );
250
-			$payment->set_status( $this->_pay_model->failed_status() );
249
+			$payment->set_details($response_args);
250
+			$payment->set_status($this->_pay_model->failed_status());
251 251
 		}
252 252
 
253 253
 		return $payment;
@@ -263,24 +263,24 @@  discard block
 block discarded – undo
263 263
 	 *  @param type $transaction
264 264
 	 *  @return EEI_Payment
265 265
 	 */
266
-	public function handle_payment_update( $update_info, $transaction ) {
267
-		$payment = ( $transaction instanceof EEI_Transaction ) ? $transaction->last_payment() : null;
266
+	public function handle_payment_update($update_info, $transaction) {
267
+		$payment = ($transaction instanceof EEI_Transaction) ? $transaction->last_payment() : null;
268 268
 
269
-		if ( $payment instanceof EEI_Payment ) {
270
-			$this->log( array( 'Return from Authorization' => $update_info ), $payment );
269
+		if ($payment instanceof EEI_Payment) {
270
+			$this->log(array('Return from Authorization' => $update_info), $payment);
271 271
 
272 272
 			$payment_details = $payment->details();
273 273
 			$transaction = $payment->transaction();
274
-			if ( ! $transaction instanceof EEI_Transaction ) {
275
-				$payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) );
276
-				$payment->set_status( $this->_pay_model->failed_status() );
274
+			if ( ! $transaction instanceof EEI_Transaction) {
275
+				$payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso'));
276
+				$payment->set_status($this->_pay_model->failed_status());
277 277
 				return $payment;
278 278
 			}
279 279
 			$primary_registrant = $transaction->primary_registration();
280 280
 
281 281
 			// Check if we still have the token.
282
-			if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) {
283
-				$payment->set_status( $this->_pay_model->failed_status() );
282
+			if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
283
+				$payment->set_status($this->_pay_model->failed_status());
284 284
 				return $payment;
285 285
 			}
286 286
 
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 				'TOKEN' => $payment_details['TOKEN']
290 290
 			);
291 291
 			// Request Customer Details.
292
-			$cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment );
293
-			$cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response );
294
-			$cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array();
295
-			if ( $cdetails_rstatus['status'] ) {
292
+			$cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment);
293
+			$cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response);
294
+			$cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array();
295
+			if ($cdetails_rstatus['status']) {
296 296
 				// We got the PayerID so now we can Complete the transaction.
297 297
 				$docheckout_request_dtls = array(
298 298
 					'METHOD' => 'DoExpressCheckoutPayment',
@@ -303,39 +303,39 @@  discard block
 block discarded – undo
303 303
 					'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code()
304 304
 				);
305 305
 				// Payment Checkout/Capture.
306
-				$docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment );
307
-				$docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response );
308
-				$docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array();
309
-				if ( $docheckout_rstatus['status'] ) {
306
+				$docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment);
307
+				$docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response);
308
+				$docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array();
309
+				if ($docheckout_rstatus['status']) {
310 310
 					// All is well, payment approved.
311 311
 					$primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : '';
312
-					$payment->set_extra_accntng( $primary_registration_code );
313
-					$payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval( $docheckout_response_args['PAYMENTINFO_0_AMT'] ) : 0 );
314
-					$payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null );
315
-					$payment->set_details( $cdata_response_args );
316
-					$payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' );
317
-					$payment->set_status( $this->_pay_model->approved_status() );
312
+					$payment->set_extra_accntng($primary_registration_code);
313
+					$payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval($docheckout_response_args['PAYMENTINFO_0_AMT']) : 0);
314
+					$payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null);
315
+					$payment->set_details($cdata_response_args);
316
+					$payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '');
317
+					$payment->set_status($this->_pay_model->approved_status());
318 318
 				} else {
319
-					if ( isset($docheckout_response_args['L_ERRORCODE']) ) {
320
-						$payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] );
319
+					if (isset($docheckout_response_args['L_ERRORCODE'])) {
320
+						$payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']);
321 321
 					} else {
322
-						$payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) );
322
+						$payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso'));
323 323
 					}
324
-					$payment->set_details( $docheckout_response_args );
325
-					$payment->set_status( $this->_pay_model->declined_status() );
324
+					$payment->set_details($docheckout_response_args);
325
+					$payment->set_status($this->_pay_model->declined_status());
326 326
 				}
327 327
 			} else {
328
-				if ( isset($cdata_response_args['L_ERRORCODE']) ) {
329
-					$payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] );
328
+				if (isset($cdata_response_args['L_ERRORCODE'])) {
329
+					$payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']);
330 330
 				} else {
331
-					$payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) );
331
+					$payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso'));
332 332
 				}
333
-				$payment->set_details( $cdata_response_args );
334
-				$payment->set_status( $this->_pay_model->failed_status() );
333
+				$payment->set_details($cdata_response_args);
334
+				$payment->set_status($this->_pay_model->failed_status());
335 335
 			}
336 336
 		} else {
337
-			$payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) );
338
-			$payment->set_status( $this->_pay_model->failed_status() );
337
+			$payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso'));
338
+			$payment->set_status($this->_pay_model->failed_status());
339 339
 		}
340 340
 
341 341
 		return $payment;
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 	 *  @param EEI_Payment  $payment
351 351
 	 *	@return mixed
352 352
 	 */
353
-	public function _ppExpress_request( $request_params, $request_text, $payment ) {
353
+	public function _ppExpress_request($request_params, $request_text, $payment) {
354 354
 		$request_dtls = array(
355 355
 			'VERSION' => '204.0',
356
-			'USER' => urlencode( $this->_api_username ),
357
-			'PWD' => urlencode( $this->_api_password ),
358
-			'SIGNATURE' => urlencode( $this->_api_signature )
356
+			'USER' => urlencode($this->_api_username),
357
+			'PWD' => urlencode($this->_api_password),
358
+			'SIGNATURE' => urlencode($this->_api_signature)
359 359
 		);
360
-		$dtls = array_merge( $request_dtls, $request_params );
360
+		$dtls = array_merge($request_dtls, $request_params);
361 361
 
362
-		$this->_log_clean_request( $dtls, $payment, $request_text . ' Request' );
362
+		$this->_log_clean_request($dtls, $payment, $request_text.' Request');
363 363
 		// Request Customer Details.
364 364
 		$request_response = wp_remote_post(
365 365
 			$this->_base_gateway_url,
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
 				'httpversion' => '1.1',
370 370
 				'cookies' => array(),
371 371
 				'headers' => array(),
372
-				'body' => http_build_query( $dtls )
372
+				'body' => http_build_query($dtls)
373 373
 			)
374 374
 		);
375 375
 		// Log the response.
376
-		$this->log( array( $request_text . ' Response' => $request_response), $payment );
376
+		$this->log(array($request_text.' Response' => $request_response), $payment);
377 377
 
378 378
 		return $request_response;
379 379
 	}
@@ -385,31 +385,31 @@  discard block
 block discarded – undo
385 385
 	 *	@param mixed        $request_response
386 386
 	 *	@return array
387 387
 	 */
388
-	public function _ppExpress_check_response( $request_response ) {
389
-		if ( ! is_wp_error( $request_response ) && $request_response['body'] && ! empty($request_response['body'] ) ) {
388
+	public function _ppExpress_check_response($request_response) {
389
+		if ( ! is_wp_error($request_response) && $request_response['body'] && ! empty($request_response['body'])) {
390 390
 			$response_args = array();
391
-			parse_str( urldecode($request_response['body']), $response_args );
392
-			if ( isset($response_args['ACK']) 
391
+			parse_str(urldecode($request_response['body']), $response_args);
392
+			if (isset($response_args['ACK']) 
393 393
 				&& $response_args['ACK'] === 'Success' 
394
-				&& ( isset($response_args['PAYERID']) 
394
+				&& (isset($response_args['PAYERID']) 
395 395
 					|| isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) 
396
-					|| ( isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed' ) 
396
+					|| (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') 
397 397
 					|| isset($response_args['TOKEN']) 
398 398
 				) 
399 399
 			) {
400 400
 				// Response status OK, return response parameters for further processing.
401 401
 				return array('status' => true, 'args' => $response_args);
402 402
 			} else {
403
-				if ( isset($response_args['ACK']) ) {
403
+				if (isset($response_args['ACK'])) {
404 404
 					$errors = $this->_get_errors($response_args);
405
-					return array( 'status' => false, 'args' => $errors );
405
+					return array('status' => false, 'args' => $errors);
406 406
 				} else {
407
-					return array( 'status' => false, 'args' => $request_response );
407
+					return array('status' => false, 'args' => $request_response);
408 408
 				}
409 409
 			}
410 410
 		} else {
411 411
 			// If we got here then there was an error in this request.
412
-			return array( 'status' => false, 'args' => $request_response );
412
+			return array('status' => false, 'args' => $request_response);
413 413
 		}
414 414
 	}
415 415
 
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 	 *	@param string  		$info
423 423
 	 *	@return void
424 424
 	 */
425
-	private function _log_clean_request( $request_prms, $payment, $info ) {
425
+	private function _log_clean_request($request_prms, $payment, $info) {
426 426
 		$cleaned_request_data = $request_prms;
427 427
 		unset($cleaned_request_data['PWD']);
428 428
 		unset($cleaned_request_data['USER']);
429 429
 		unset($cleaned_request_data['SIGNATURE']);
430
-		$this->log( array($info => $cleaned_request_data), $payment );
430
+		$this->log(array($info => $cleaned_request_data), $payment);
431 431
 	}
432 432
 
433 433
 
@@ -437,16 +437,16 @@  discard block
 block discarded – undo
437 437
 	 *  @param array	$data_array
438 438
 	 *  @return array
439 439
 	 */
440
-	private function _get_errors( $data_array ) {
440
+	private function _get_errors($data_array) {
441 441
 		$errors = array();
442 442
 		$n = 0;
443
-		while ( isset($data_array['L_ERRORCODE' . $n . '']) ) {
444
-			$l_error_code = isset($data_array['L_ERRORCODE' . $n . '']) ? $data_array['L_ERRORCODE' . $n . ''] : '';
445
-			$l_severity_code = isset($data_array['L_SEVERITYCODE' . $n . '']) ? $data_array['L_SEVERITYCODE' . $n . ''] : '';
446
-			$l_short_message = isset($data_array['L_SHORTMESSAGE' . $n . '']) ? $data_array['L_SHORTMESSAGE' . $n . ''] : '';
447
-			$l_long_message = isset($data_array['L_LONGMESSAGE' . $n . '']) ? $data_array['L_LONGMESSAGE' . $n . ''] : '';
443
+		while (isset($data_array['L_ERRORCODE'.$n.''])) {
444
+			$l_error_code = isset($data_array['L_ERRORCODE'.$n.'']) ? $data_array['L_ERRORCODE'.$n.''] : '';
445
+			$l_severity_code = isset($data_array['L_SEVERITYCODE'.$n.'']) ? $data_array['L_SEVERITYCODE'.$n.''] : '';
446
+			$l_short_message = isset($data_array['L_SHORTMESSAGE'.$n.'']) ? $data_array['L_SHORTMESSAGE'.$n.''] : '';
447
+			$l_long_message = isset($data_array['L_LONGMESSAGE'.$n.'']) ? $data_array['L_LONGMESSAGE'.$n.''] : '';
448 448
 
449
-			if ( $n == 0 ) {
449
+			if ($n == 0) {
450 450
 				$errors = array(
451 451
 					'L_ERRORCODE' => $l_error_code,
452 452
 					'L_SHORTMESSAGE' => $l_short_message,
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
 					'L_SEVERITYCODE' => $l_severity_code
455 455
 				);
456 456
 			} else {
457
-				$errors['L_ERRORCODE'] .= ', ' . $l_error_code;
458
-				$errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
459
-				$errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
460
-				$errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
457
+				$errors['L_ERRORCODE'] .= ', '.$l_error_code;
458
+				$errors['L_SHORTMESSAGE'] .= ', '.$l_short_message;
459
+				$errors['L_LONGMESSAGE'] .= ', '.$l_long_message;
460
+				$errors['L_SEVERITYCODE'] .= ', '.$l_severity_code;
461 461
 			}
462 462
 
463 463
 			$n++;
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/templates/paypal_express_intro.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
1
-<?php printf( __('PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">','</a>' ); ?> 
2 1
\ No newline at end of file
2
+<?php printf(__('PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">', '</a>'); ?> 
3 3
\ No newline at end of file
Please login to merge, or discard this patch.
Paypal_Express/templates/paypal_express_debug_info.template.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { exit('No direct script access allowed'); } ?>
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } ?>
2 2
 
3 3
 <div id="ppexpress-sandbox-panel" class="sandbox-panel">
4 4
 
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 
7 7
 	<h4><?php _e('How do I test specific error codes?', 'event_espresso'); ?></h4>
8 8
 	<p>
9
-		<?php _e( 'To trigger an error condition on an amount-related field, 
9
+		<?php _e('To trigger an error condition on an amount-related field, 
10 10
 			specify a error code value as a number with two digits to the right of the decimal point. 
11 11
 			For example, specify a value of 107.55 to trigger the 10755 error.', 
12
-		'event_espresso');?>
12
+		'event_espresso'); ?>
13 13
 	</p>
14 14
 	<p>
15
-		<?php printf( __( 'More details can be found here: %1$s Testing Error Conditions %2$s.', 'event_espresso'), '<a href="https://developer.paypal.com/docs/classic/lifecycle/sb_error-conditions">', '</a>');?>
15
+		<?php printf(__('More details can be found here: %1$s Testing Error Conditions %2$s.', 'event_espresso'), '<a href="https://developer.paypal.com/docs/classic/lifecycle/sb_error-conditions">', '</a>'); ?>
16 16
 	</p>
17 17
 
18 18
 </div>
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/EE_PMT_Paypal_Express.pm.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 class EE_PMT_Paypal_Express extends EE_PMT_Base {
16 16
 
17 17
 	/**
18
-     * Class constructor.
19
-     */
18
+	 * Class constructor.
19
+	 */
20 20
 	public function __construct( $pm_instance = NULL ) {
21 21
 		require_once( $this->file_folder() . 'EEG_Paypal_Express.gateway.php' );
22 22
 		$this->_gateway = new EEG_Paypal_Express();
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); }
2 2
 
3 3
 /**
4 4
  * ----------------------------------------------
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
      * Class constructor.
19 19
      */
20
-	public function __construct( $pm_instance = NULL ) {
21
-		require_once( $this->file_folder() . 'EEG_Paypal_Express.gateway.php' );
20
+	public function __construct($pm_instance = NULL) {
21
+		require_once($this->file_folder().'EEG_Paypal_Express.gateway.php');
22 22
 		$this->_gateway = new EEG_Paypal_Express();
23 23
 
24
-		$this->_pretty_name = __( 'PayPal Express', 'event_espresso' );
25
-		$this->_template_path = $this->file_folder() . 'templates' . DS;
26
-		$this->_default_description = __( 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso' );
27
-		$this->_default_button_url = $this->file_url() . 'lib' . DS . 'paypal-express-checkout-logo.png';
24
+		$this->_pretty_name = __('PayPal Express', 'event_espresso');
25
+		$this->_template_path = $this->file_folder().'templates'.DS;
26
+		$this->_default_description = __('After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso');
27
+		$this->_default_button_url = $this->file_url().'lib'.DS.'paypal-express-checkout-logo.png';
28 28
 
29
-		parent::__construct( $pm_instance );
29
+		parent::__construct($pm_instance);
30 30
 	}
31 31
 
32 32
 
@@ -58,34 +58,34 @@  discard block
 block discarded – undo
58 58
 				'extra_meta_inputs' => array(
59 59
 					'api_username' => new EE_Text_Input(
60 60
 						array(
61
-							'html_label_text'=> sprintf( __( 'API Username %s', 'event_espresso' ), $this->get_help_tab_link() ),
61
+							'html_label_text'=> sprintf(__('API Username %s', 'event_espresso'), $this->get_help_tab_link()),
62 62
 							'required' => true,
63 63
 						)
64 64
 					),
65 65
 					'api_password' => new EE_Text_Input(
66 66
 						array(
67
-							'html_label_text' => sprintf( __( 'API Password %s', 'event_espresso' ), $this->get_help_tab_link() ),
67
+							'html_label_text' => sprintf(__('API Password %s', 'event_espresso'), $this->get_help_tab_link()),
68 68
 							'required' => true
69 69
 						)
70 70
 					),
71 71
 					'api_signature' => new EE_Text_Input(
72 72
 						array(
73
-							'html_label_text' => sprintf( __( 'API Signature %s', 'event_espresso' ), $this->get_help_tab_link() ),
73
+							'html_label_text' => sprintf(__('API Signature %s', 'event_espresso'), $this->get_help_tab_link()),
74 74
 							'required' => true
75 75
 						)
76 76
 					),
77 77
 					'request_shipping_addr' => new EE_Yes_No_Input(
78 78
 						array(
79
-							'html_label_text' => sprintf( __( 'Request Shipping Address %s', 'event_espresso' ), $this->get_help_tab_link() ),
80
-							'html_help_text'  => __( 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso' ),
79
+							'html_label_text' => sprintf(__('Request Shipping Address %s', 'event_espresso'), $this->get_help_tab_link()),
80
+							'html_help_text'  => __('If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso'),
81 81
 							'required' => true,
82 82
 							'default' => true,
83 83
 						)
84 84
 					),
85 85
 					'image_url' => new EE_Admin_File_Uploader_Input(
86 86
 						array(
87
-							'html_label_text' => sprintf( __( 'Image URL %s', 'event_espresso' ), $this->get_help_tab_link() ),
88
-							'html_help_text' => __( 'Used for your business/personal logo on the PayPal page', 'event_espresso' ),
87
+							'html_label_text' => sprintf(__('Image URL %s', 'event_espresso'), $this->get_help_tab_link()),
88
+							'html_help_text' => __('Used for your business/personal logo on the PayPal page', 'event_espresso'),
89 89
 							'required' => false
90 90
 						)
91 91
 					),
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 *	@param \EE_Transaction $transaction
103 103
 	 *	@return \EE_Billing_Info_Form
104 104
 	 */
105
-	public function generate_new_billing_form( EE_Transaction $transaction = null ) {
106
-		if ( $this->_pm_instance->debug_mode() ) {
105
+	public function generate_new_billing_form(EE_Transaction $transaction = null) {
106
+		if ($this->_pm_instance->debug_mode()) {
107 107
 			$form = new EE_Billing_Info_Form(
108 108
 				$this->_pm_instance,
109 109
 				array(
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 							array(
114 114
 								'layout_strategy' => new EE_Template_Layout(
115 115
 									array(
116
-										'layout_template_file' => $this->_template_path . 'paypal_express_debug_info.template.php',
117
-										'template_args' => array( 'debug_mode' => $this->_pm_instance->debug_mode() )
116
+										'layout_template_file' => $this->_template_path.'paypal_express_debug_info.template.php',
117
+										'template_args' => array('debug_mode' => $this->_pm_instance->debug_mode())
118 118
 									)
119 119
 								)
120 120
 							)
Please login to merge, or discard this patch.
core/exceptions/SendMessageException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\exceptions;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -15,5 +15,5 @@  discard block
 block discarded – undo
15 15
  * @author        Darren Ethier
16 16
  * @since         4.9.11.rc.001
17 17
  */
18
-class SendMessageException extends \RuntimeException  {}
18
+class SendMessageException extends \RuntimeException {}
19 19
 // End of file SendMessageException.php
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
core/business/EE_Registration_Processor.class.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\domain\entities\RegUrlLink;
4 4
 use EventEspresso\core\domain\services\registration\CreateRegistrationService;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
7
-EE_Registry::instance()->load_class( 'Processor_Base' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
7
+EE_Registry::instance()->load_class('Processor_Base');
8 8
 
9 9
 /**
10 10
  * Class EE_Registration_Processor
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public static function instance() {
68 68
 		// check if class object is instantiated
69
-		if ( ! self::$_instance instanceof EE_Registration_Processor ) {
69
+		if ( ! self::$_instance instanceof EE_Registration_Processor) {
70 70
 			self::$_instance = new self();
71 71
 		}
72 72
 		return self::$_instance;
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @param int $REG_ID
87 87
 	 * @return string
88 88
 	 */
89
-	public function old_reg_status( $REG_ID ) {
90
-		return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null;
89
+	public function old_reg_status($REG_ID) {
90
+		return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null;
91 91
 	}
92 92
 
93 93
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 * @param int $REG_ID
97 97
 	 * @param string $old_reg_status
98 98
 	 */
99
-	public function set_old_reg_status( $REG_ID, $old_reg_status ) {
99
+	public function set_old_reg_status($REG_ID, $old_reg_status) {
100 100
 		// only set the first time
101
-		if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) {
102
-			$this->_old_reg_status[ $REG_ID ] = $old_reg_status;
101
+		if ( ! isset($this->_old_reg_status[$REG_ID])) {
102
+			$this->_old_reg_status[$REG_ID] = $old_reg_status;
103 103
 		}
104 104
 	}
105 105
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param int $REG_ID
110 110
 	 * @return string
111 111
 	 */
112
-	public function new_reg_status( $REG_ID ) {
113
-		return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null;
112
+	public function new_reg_status($REG_ID) {
113
+		return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null;
114 114
 	}
115 115
 
116 116
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param int $REG_ID
120 120
 	 * @param string $new_reg_status
121 121
 	 */
122
-	public function set_new_reg_status( $REG_ID, $new_reg_status ) {
123
-		$this->_new_reg_status[ $REG_ID ] = $new_reg_status;
122
+	public function set_new_reg_status($REG_ID, $new_reg_status) {
123
+		$this->_new_reg_status[$REG_ID] = $new_reg_status;
124 124
 	}
125 125
 
126 126
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param int $REG_ID
132 132
 	 * @return bool
133 133
 	 */
134
-	public function reg_status_updated( $REG_ID ) {
135
-		return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false;
134
+	public function reg_status_updated($REG_ID) {
135
+		return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false;
136 136
 	}
137 137
 
138 138
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Registration $registration
142 142
 	 * @throws \EE_Error
143 143
 	 */
144
-	public function update_registration_status_and_trigger_notifications( \EE_Registration $registration ) {
145
-		$this->toggle_incomplete_registration_status_to_default( $registration, false );
146
-		$this->toggle_registration_status_for_default_approved_events( $registration, false );
147
-		$this->toggle_registration_status_if_no_monies_owing( $registration, false );
144
+	public function update_registration_status_and_trigger_notifications(\EE_Registration $registration) {
145
+		$this->toggle_incomplete_registration_status_to_default($registration, false);
146
+		$this->toggle_registration_status_for_default_approved_events($registration, false);
147
+		$this->toggle_registration_status_if_no_monies_owing($registration, false);
148 148
 		$registration->save();
149 149
 		// trigger notifications
150
-		$this->trigger_registration_update_notifications( $registration );
150
+		$this->trigger_registration_update_notifications($registration);
151 151
 	}
152 152
 
153 153
 
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 	 * @return boolean
163 163
 	 * @throws \EE_Error
164 164
 	 */
165
-	public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) {
165
+	public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) {
166 166
 		// set initial REG_Status
167
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
167
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
168 168
 		// set incoming REG_Status
169
-		$this->set_new_reg_status( $registration->ID(), $new_reg_status );
169
+		$this->set_new_reg_status($registration->ID(), $new_reg_status);
170 170
 		// toggle reg status but only if it has changed and the user can do so
171 171
 		if (
172
-			$this->reg_status_updated( $registration->ID() ) &&
173
-			EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() )
172
+			$this->reg_status_updated($registration->ID()) &&
173
+			EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID())
174 174
 		) {
175 175
 			// change status to new value
176
-			if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) ) && $save ) {
176
+			if ($registration->set_status($this->new_reg_status($registration->ID())) && $save) {
177 177
 				$registration->save();
178 178
 			}
179 179
 			return TRUE;
@@ -193,30 +193,30 @@  discard block
 block discarded – undo
193 193
 	 * @return void
194 194
 	 * @throws \EE_Error
195 195
 	 */
196
-	public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) {
196
+	public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) {
197 197
 		$existing_reg_status = $registration->status_ID();
198 198
 		// set initial REG_Status
199
-		$this->set_old_reg_status( $registration->ID(), $existing_reg_status );
199
+		$this->set_old_reg_status($registration->ID(), $existing_reg_status);
200 200
 		// is the registration currently incomplete ?
201
-		if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) {
201
+		if ($registration->status_ID() === EEM_Registration::status_id_incomplete) {
202 202
 			// grab default reg status for the event, if set
203 203
 			$event_default_registration_status = $registration->event()->default_registration_status();
204 204
 			// if no default reg status is set for the event, then use the global value
205
-			$STS_ID = ! empty( $event_default_registration_status )
205
+			$STS_ID = ! empty($event_default_registration_status)
206 206
 				? $event_default_registration_status
207 207
 				: EE_Registry::instance()->CFG->registration->default_STS_ID;
208 208
 			// if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered
209 209
 			$STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID;
210 210
 			// set incoming REG_Status
211
-			$this->set_new_reg_status( $registration->ID(), $STS_ID );
212
-			$registration->set_status( $STS_ID );
213
-			if ( $save ) {
211
+			$this->set_new_reg_status($registration->ID(), $STS_ID);
212
+			$registration->set_status($STS_ID);
213
+			if ($save) {
214 214
 				$registration->save();
215 215
 			}
216 216
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
217
-			if ( ! EE_Processor_Base::$IPN ) {
217
+			if ( ! EE_Processor_Base::$IPN) {
218 218
 				// otherwise, send out notifications
219
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
219
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
220 220
 			}
221 221
 			// DEBUG LOG
222 222
 			//$this->log(
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 	 * @return boolean
242 242
 	 * @throws \EE_Error
243 243
 	 */
244
-	public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) {
244
+	public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) {
245 245
 		$reg_status = $registration->status_ID();
246 246
 		// set initial REG_Status
247
-		$this->set_old_reg_status( $registration->ID(), $reg_status );
247
+		$this->set_old_reg_status($registration->ID(), $reg_status);
248 248
 		// if not already, toggle reg status to approved IF the event default reg status is approved
249 249
 		// ( as long as the registration wasn't cancelled or declined at some point )
250 250
 		if (
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 			$registration->event()->default_registration_status() === EEM_Registration::status_id_approved
255 255
 		) {
256 256
 			// set incoming REG_Status
257
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
257
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
258 258
 			// toggle status to approved
259
-			$registration->set_status( EEM_Registration::status_id_approved );
260
-			if ( $save ) {
259
+			$registration->set_status(EEM_Registration::status_id_approved);
260
+			if ($save) {
261 261
 				$registration->save();
262 262
 			}
263 263
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
264
-			if ( ! EE_Processor_Base::$IPN ) {
264
+			if ( ! EE_Processor_Base::$IPN) {
265 265
 				// otherwise, send out notifications
266
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
266
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
267 267
 			}
268 268
 			// DEBUG LOG
269 269
 			//$this->log(
@@ -291,19 +291,19 @@  discard block
 block discarded – undo
291 291
 	 * @return bool
292 292
 	 * @throws \EE_Error
293 293
 	 */
294
-	public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) {
294
+	public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) {
295 295
 		// set initial REG_Status
296
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
296
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
297 297
 		//EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ );
298 298
 		// was a payment just made ?
299 299
 		if (
300
-			isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) &&
301
-			$additional_details[ 'payment_updates' ] &&
302
-			$additional_details[ 'last_payment' ] instanceof EE_Payment
300
+			isset($additional_details['payment_updates'], $additional_details['last_payment']) &&
301
+			$additional_details['payment_updates'] &&
302
+			$additional_details['last_payment'] instanceof EE_Payment
303 303
 		) {
304
-			$payment = $additional_details[ 'last_payment' ];
304
+			$payment = $additional_details['last_payment'];
305 305
 			$total_paid = 0;
306
-			foreach ( self::$_amount_paid as $reg => $amount_paid ) {
306
+			foreach (self::$_amount_paid as $reg => $amount_paid) {
307 307
 				$total_paid += $amount_paid;
308 308
 			}
309 309
 		} else {
@@ -327,30 +327,30 @@  discard block
 block discarded – undo
327 327
 					$registration->transaction()->is_completed() ||
328 328
 					$registration->transaction()->is_overpaid() ||
329 329
 					$registration->transaction()->is_free() ||
330
-					apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration )
330
+					apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration)
331 331
 				) || (
332 332
 					$payment instanceof EE_Payment &&
333 333
 					$payment->is_approved() &&
334 334
 					// this specific registration has not yet been paid for
335
-					! isset( self::$_amount_paid[ $registration->ID() ] ) &&
335
+					! isset(self::$_amount_paid[$registration->ID()]) &&
336 336
 					// payment amount, less what we have already attributed to other registrations, is greater than this reg's final price
337 337
 					$payment->amount() - $total_paid >= $registration->final_price()
338 338
 				)
339 339
 			)
340 340
 		) {
341 341
 			// mark as paid
342
-			self::$_amount_paid[ $registration->ID() ] = $registration->final_price();
342
+			self::$_amount_paid[$registration->ID()] = $registration->final_price();
343 343
 			// track new REG_Status
344
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
344
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
345 345
 			// toggle status to approved
346
-			$registration->set_status( EEM_Registration::status_id_approved );
347
-			if ( $save ) {
346
+			$registration->set_status(EEM_Registration::status_id_approved);
347
+			if ($save) {
348 348
 				$registration->save();
349 349
 			}
350 350
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
351
-			if ( ! EE_Processor_Base::$IPN ) {
351
+			if ( ! EE_Processor_Base::$IPN) {
352 352
 				// otherwise, send out notifications
353
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
353
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
354 354
 			}
355 355
 			// DEBUG LOG
356 356
 			//$this->log(
@@ -376,27 +376,27 @@  discard block
 block discarded – undo
376 376
 	 * @param array 	$additional_details
377 377
 	 * @return void
378 378
 	 */
379
-	public function trigger_registration_update_notifications( $registration, $additional_details = array() ) {
379
+	public function trigger_registration_update_notifications($registration, $additional_details = array()) {
380 380
 		try {
381
-			if ( ! $registration instanceof EE_Registration ) {
382
-				throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) );
381
+			if ( ! $registration instanceof EE_Registration) {
382
+				throw new EE_Error(__('An invalid registration was received.', 'event_espresso'));
383 383
 			}
384
-			EE_Registry::instance()->load_helper( 'Debug_Tools' );
384
+			EE_Registry::instance()->load_helper('Debug_Tools');
385 385
 			EEH_Debug_Tools::log(
386 386
 				__CLASS__,
387 387
 				__FUNCTION__,
388 388
 				__LINE__,
389
-				array( $registration->transaction(), $additional_details ),
389
+				array($registration->transaction(), $additional_details),
390 390
 				false,
391
-				'EE_Transaction: ' . $registration->transaction()->ID()
391
+				'EE_Transaction: '.$registration->transaction()->ID()
392 392
 			);
393 393
 			do_action(
394 394
 				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
395 395
 				$registration,
396 396
 				$additional_details
397 397
 			);
398
-		} catch( Exception $e ) {
399
-			EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() );
398
+		} catch (Exception $e) {
399
+			EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine());
400 400
 		}
401 401
 	}
402 402
 
@@ -410,22 +410,22 @@  discard block
 block discarded – undo
410 410
 	 * @return bool
411 411
 	 * @throws \EE_Error
412 412
 	 */
413
-	public function update_registration_after_checkout_or_payment(  EE_Registration $registration, $additional_details = array() ) {
413
+	public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) {
414 414
 		// set initial REG_Status
415
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
415
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
416 416
 
417 417
 		// if the registration status gets updated, then save the registration
418 418
 		if (
419
-			$this->toggle_registration_status_for_default_approved_events( $registration, false )
420
-			|| $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )
419
+			$this->toggle_registration_status_for_default_approved_events($registration, false)
420
+			|| $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)
421 421
 		) {
422 422
 			$registration->save();
423 423
 		}
424 424
 
425 425
 		// set new  REG_Status
426
-		$this->set_new_reg_status( $registration->ID(), $registration->status_ID() );
427
-		return $this->reg_status_updated( $registration->ID() )
428
-		       && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved
426
+		$this->set_new_reg_status($registration->ID(), $registration->status_ID());
427
+		return $this->reg_status_updated($registration->ID())
428
+		       && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved
429 429
 			? true
430 430
 			: false;
431 431
 	}
@@ -441,20 +441,20 @@  discard block
 block discarded – undo
441 441
 	 * @return void
442 442
 	 * @throws \EE_Error
443 443
 	 */
444
-	public function update_registration_final_prices( $transaction, $save_regs = true ) {
445
-		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() );
446
-		foreach( $transaction->registrations() as $registration ) {
444
+	public function update_registration_final_prices($transaction, $save_regs = true) {
445
+		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
446
+		foreach ($transaction->registrations() as $registration) {
447 447
 			/** @var EE_Line_Item $line_item */
448
-			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration );
449
-			if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) {
450
-				$registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] );
451
-				if( $save_regs ) {
448
+			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
449
+			if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) {
450
+				$registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]);
451
+				if ($save_regs) {
452 452
 					$registration->save();
453 453
 				}
454 454
 			}
455 455
 		}
456 456
 		//and make sure there's no rounding problem
457
-		$this->fix_reg_final_price_rounding_issue( $transaction );
457
+		$this->fix_reg_final_price_rounding_issue($transaction);
458 458
 	}
459 459
 
460 460
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 	 * @return boolean success verifying that there is NO difference after this method is done
475 475
 	 * @throws \EE_Error
476 476
 	 */
477
-	public function fix_reg_final_price_rounding_issue( $transaction ) {
477
+	public function fix_reg_final_price_rounding_issue($transaction) {
478 478
 		$reg_final_price_sum = EEM_Registration::instance()->sum(
479 479
 			array(
480 480
 				array(
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
 			),
484 484
 			'REG_final_price'
485 485
 		);
486
-		$diff =  $transaction->total() - (float) $reg_final_price_sum;
486
+		$diff = $transaction->total() - (float) $reg_final_price_sum;
487 487
 		//ok then, just grab one of the registrations
488
-		if( $diff !== 0 ) {
488
+		if ($diff !== 0) {
489 489
 			$a_reg = EEM_Registration::instance()->get_one(
490 490
 					array(
491 491
 						array(
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 					));
495 495
 			$success = $a_reg instanceof EE_Registration
496 496
 				? $a_reg->save(
497
-					array( 'REG_final_price' => $a_reg->final_price() + $diff )
497
+					array('REG_final_price' => $a_reg->final_price() + $diff)
498 498
 				)
499 499
 				: false;
500 500
 			return $success ? true : false;
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
 		$update_reg = true
520 520
 	) {
521 521
 		// these reg statuses should not be considered in any calculations involving monies owing
522
-		$closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses
522
+		$closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses
523 523
 			: EEM_Registration::closed_reg_statuses();
524
-		if ( ! in_array( $registration->status_ID(), $closed_reg_statuses ) ) {
524
+		if ( ! in_array($registration->status_ID(), $closed_reg_statuses)) {
525 525
 			return false;
526 526
 		}
527 527
 		$registration->set_final_price(0);
528
-		if ( $update_reg ) {
528
+		if ($update_reg) {
529 529
 			$registration->save();
530 530
 		}
531 531
 		return true;
@@ -548,23 +548,23 @@  discard block
 block discarded – undo
548 548
 		$update_reg = true
549 549
 	) {
550 550
 		// these reg statuses should not be considered in any calculations involving monies owing
551
-		$closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses
551
+		$closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses
552 552
 			: EEM_Registration::closed_reg_statuses();
553
-		if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) {
553
+		if (in_array($registration->status_ID(), $closed_reg_statuses)) {
554 554
 			return false;
555 555
 		}
556 556
 		$ticket = $registration->ticket();
557
-		if ( ! $ticket instanceof EE_Ticket ) {
557
+		if ( ! $ticket instanceof EE_Ticket) {
558 558
 			throw new EE_Error(
559 559
 				sprintf(
560
-					__( 'The Ticket for Registration %1$d was not found or is invalid.',
561
-						'event_espresso' ),
560
+					__('The Ticket for Registration %1$d was not found or is invalid.',
561
+						'event_espresso'),
562 562
 					$registration->ticket_ID()
563 563
 				)
564 564
 			);
565 565
 		}
566
-		$registration->set_final_price( $ticket->price() );
567
-		if ( $update_reg ) {
566
+		$registration->set_final_price($ticket->price());
567
+		if ($update_reg) {
568 568
 			$registration->save();
569 569
 		}
570 570
 		return true;
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		$total_ticket_count = 1
603 603
 	) {
604 604
 		EE_Error::doing_it_wrong(
605
-			__CLASS__ . '::' . __FUNCTION__,
605
+			__CLASS__.'::'.__FUNCTION__,
606 606
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
607 607
 				'\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'),
608 608
 			'4.9.1',
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	public function generate_reg_url_link($att_nmbr, $item)
646 646
 	{
647 647
 		EE_Error::doing_it_wrong(
648
-			__CLASS__ . '::' . __FUNCTION__,
648
+			__CLASS__.'::'.__FUNCTION__,
649 649
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
650 650
 				'EventEspresso\core\domain\entities\RegUrlLink'),
651 651
 			'4.9.1',
@@ -665,11 +665,11 @@  discard block
 block discarded – undo
665 665
 	 * @return string
666 666
 	 * @throws \EE_Error
667 667
 	 */
668
-	public function generate_reg_code( EE_Registration $registration ) {
668
+	public function generate_reg_code(EE_Registration $registration) {
669 669
 		EE_Error::doing_it_wrong(
670
-			__CLASS__ . '::' . __FUNCTION__,
670
+			__CLASS__.'::'.__FUNCTION__,
671 671
 			sprintf(
672
-				__( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ),
672
+				__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
673 673
 				'EventEspresso\core\domain\entities\RegCode'
674 674
 			),
675 675
 			'4.9.1',
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 		return apply_filters(
679 679
 			'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code',
680 680
 			new RegCode(
681
-				RegUrlLink::fromRegistration( $registration ),
681
+				RegUrlLink::fromRegistration($registration),
682 682
 				$registration->transaction(),
683 683
 				$registration->ticket()
684 684
 			),
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Queue.lib.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use \EventEspresso\core\exceptions\SendMessageException;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 /**
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param \EE_Message_Repository       $message_repository
78 78
 	 */
79
-	public function __construct( EE_Message_Repository $message_repository ) {
80
-		$this->_batch_count        = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 );
79
+	public function __construct(EE_Message_Repository $message_repository) {
80
+		$this->_batch_count        = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50);
81 81
 		$this->_rate_limit         = $this->get_rate_limit();
82 82
 		$this->_message_repository = $message_repository;
83 83
 	}
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 *                                 use the messenger send method but typically is based on preview data.
97 97
 	 * @return bool          Whether the message was successfully added to the repository or not.
98 98
 	 */
99
-	public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) {
99
+	public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) {
100 100
 		$data['preview'] = $preview;
101 101
 		$data['test_send'] = $test_send;
102
-		return $this->_message_repository->add( $message, $data );
102
+		return $this->_message_repository->add($message, $data);
103 103
 	}
104 104
 
105 105
 
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	 * @param bool          $persist    This flag indicates whether to attempt to delete the object from the db as well.
112 112
 	 * @return bool
113 113
 	 */
114
-	public function remove( EE_Message $message, $persist = false ) {
115
-		if ( $persist && $this->_message_repository->current() !== $message ) {
114
+	public function remove(EE_Message $message, $persist = false) {
115
+		if ($persist && $this->_message_repository->current() !== $message) {
116 116
 			//get pointer on right message
117
-			if ( $this->_message_repository->has( $message ) ) {
117
+			if ($this->_message_repository->has($message)) {
118 118
 				$this->_message_repository->rewind();
119
-				while( $this->_message_repository->valid() ) {
120
-					if ( $this->_message_repository->current() === $message ) {
119
+				while ($this->_message_repository->valid()) {
120
+					if ($this->_message_repository->current() === $message) {
121 121
 						break;
122 122
 					}
123 123
 					$this->_message_repository->next();
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				return false;
127 127
 			}
128 128
 		}
129
-		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message );
129
+		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message);
130 130
 	}
131 131
 
132 132
 
@@ -166,29 +166,29 @@  discard block
 block discarded – undo
166 166
 	 * @return bool  true if successfully retrieved batch, false no batch ready.
167 167
 	 */
168 168
 	public function get_batch_to_generate() {
169
-		if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) {
169
+		if ($this->is_locked(EE_Messages_Queue::action_generating)) {
170 170
 			return false;
171 171
 		}
172 172
 
173 173
 		//lock batch generation to prevent race conditions.
174
-		$this->lock_queue( EE_Messages_Queue::action_generating );
174
+		$this->lock_queue(EE_Messages_Queue::action_generating);
175 175
 
176 176
 		$query_args = array(
177 177
 			// key 0 = where conditions
178
-			0 => array( 'STS_ID' => EEM_Message::status_incomplete ),
178
+			0 => array('STS_ID' => EEM_Message::status_incomplete),
179 179
 			'order_by' => $this->_get_priority_orderby(),
180 180
 			'limit' => $this->_batch_count
181 181
 		);
182
-		$messages = EEM_Message::instance()->get_all( $query_args );
182
+		$messages = EEM_Message::instance()->get_all($query_args);
183 183
 
184
-		if ( ! $messages ) {
184
+		if ( ! $messages) {
185 185
 			return false; //nothing to generate
186 186
 		}
187 187
 
188
-		foreach ( $messages as $message ) {
189
-			if ( $message instanceof EE_Message ) {
188
+		foreach ($messages as $message) {
189
+			if ($message instanceof EE_Message) {
190 190
 				$data = $message->all_extra_meta_array();
191
-				$this->add( $message, $data );
191
+				$this->add($message, $data);
192 192
 			}
193 193
 		}
194 194
 		return true;
@@ -211,34 +211,34 @@  discard block
 block discarded – undo
211 211
 	 *               to assist with notifying user.
212 212
 	 */
213 213
 	public function get_to_send_batch_and_send() {
214
-		if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) {
214
+		if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) {
215 215
 			return false;
216 216
 		}
217 217
 
218
-		$this->lock_queue( EE_Messages_Queue::action_sending );
218
+		$this->lock_queue(EE_Messages_Queue::action_sending);
219 219
 
220 220
 		$batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit;
221 221
 
222 222
 		$query_args = array(
223 223
 			// key 0 = where conditions
224
-			0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ),
224
+			0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())),
225 225
 			'order_by' => $this->_get_priority_orderby(),
226 226
 			'limit' => $batch
227 227
 		);
228 228
 
229
-		$messages_to_send = EEM_Message::instance()->get_all( $query_args );
229
+		$messages_to_send = EEM_Message::instance()->get_all($query_args);
230 230
 
231 231
 
232 232
 		//any to send?
233
-		if ( ! $messages_to_send ) {
234
-			$this->unlock_queue( EE_Messages_Queue::action_sending );
233
+		if ( ! $messages_to_send) {
234
+			$this->unlock_queue(EE_Messages_Queue::action_sending);
235 235
 			return false;
236 236
 		}
237 237
 
238 238
 		//add to queue.
239
-		foreach ( $messages_to_send as $message ) {
240
-			if ( $message instanceof EE_Message ) {
241
-				$this->add( $message );
239
+		foreach ($messages_to_send as $message) {
240
+			if ($message instanceof EE_Message) {
241
+				$this->add($message);
242 242
 			}
243 243
 		}
244 244
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		$this->execute();
247 247
 
248 248
 		//release lock
249
-		$this->unlock_queue( EE_Messages_Queue::action_sending );
249
+		$this->unlock_queue(EE_Messages_Queue::action_sending);
250 250
 		return true;
251 251
 	}
252 252
 
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @param   string  $type   The type of queue being locked.
260 260
 	 */
261
-	public function lock_queue( $type = EE_Messages_Queue::action_generating ) {
262
-		set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) );
261
+	public function lock_queue($type = EE_Messages_Queue::action_generating) {
262
+		set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type));
263 263
 	}
264 264
 
265 265
 
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @param   string  $type   The type of queue being unlocked.
272 272
 	 */
273
-	public function unlock_queue( $type = EE_Messages_Queue::action_generating ) {
274
-		delete_transient( $this->_get_lock_key( $type ) );
273
+	public function unlock_queue($type = EE_Messages_Queue::action_generating) {
274
+		delete_transient($this->_get_lock_key($type));
275 275
 	}
276 276
 
277 277
 
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 	 * @param string $type  The type of lock.
283 283
 	 * @return string
284 284
 	 */
285
-	protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) {
286
-		return '_ee_lock_' . $type;
285
+	protected function _get_lock_key($type = EE_Messages_Queue::action_generating) {
286
+		return '_ee_lock_'.$type;
287 287
 	}
288 288
 
289 289
 
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
 	 * @param string $type  The type of lock
295 295
 	 * @return int   time to expiry in seconds.
296 296
 	 */
297
-	protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) {
298
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type );
297
+	protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) {
298
+		return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type);
299 299
 	}
300 300
 
301 301
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 * @return int
314 314
 	 */
315 315
 	protected function _get_rate_limit_expiry() {
316
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS );
316
+		return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS);
317 317
 	}
318 318
 
319 319
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @return int
325 325
 	 */
326 326
 	protected function _default_rate_limit() {
327
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 );
327
+		return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200);
328 328
 	}
329 329
 
330 330
 
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 	 * @param  string $type The type of lock being checked for.
351 351
 	 * @return bool
352 352
 	 */
353
-	public function is_locked( $type = EE_Messages_Queue::action_generating ) {
353
+	public function is_locked($type = EE_Messages_Queue::action_generating) {
354 354
 		/**
355 355
 		 * This filters the default is_locked behaviour.
356 356
 		 */
357 357
 		$is_locked = filter_var(
358 358
 			apply_filters(
359 359
 				'FHEE__EE_Messages_Queue__is_locked',
360
-				get_transient( $this->_get_lock_key( $type ) ),
360
+				get_transient($this->_get_lock_key($type)),
361 361
 				$this
362 362
 			),
363 363
 			FILTER_VALIDATE_BOOLEAN
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 		 *            Also implemented here because messages processed on the same request should not have any locks applied.
369 369
 		 */
370 370
 		if (
371
-			apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
371
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
372 372
 			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
373 373
 		) {
374 374
 			$is_locked = false;
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
 	 * @return int
391 391
 	 */
392 392
 	public function get_rate_limit() {
393
-		if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) {
393
+		if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) {
394 394
 			$rate_limit = $this->_default_rate_limit();
395
-			set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() );
395
+			set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key());
396 396
 		}
397 397
 		return $rate_limit;
398 398
 	}
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	 * This updates existing rate limit with the new limit which is the old minus the batch.
405 405
 	 * @param int $batch_completed  This sets the new rate limit based on the given batch that was completed.
406 406
 	 */
407
-	public function set_rate_limit( $batch_completed ) {
407
+	public function set_rate_limit($batch_completed) {
408 408
 		//first get the most up to date rate limit (in case its expired and reset)
409 409
 		$rate_limit = $this->get_rate_limit();
410 410
 		$new_limit = $rate_limit - $batch_completed;
411 411
 		//updating the transient option directly to avoid resetting the expiry.
412
-		update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit );
412
+		update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit);
413 413
 	}
414 414
 
415 415
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @param string $task This indicates what type of request is going to be initiated.
423 423
 	 * @param int    $priority  This indicates the priority that triggers initiating the request.
424 424
 	 */
425
-	public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) {
425
+	public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) {
426 426
 		//determine what status is matched with the priority as part of the trigger conditions.
427 427
 		$status = $task == 'generate'
428 428
 			? EEM_Message::status_incomplete
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
 		 *   the same request.
443 443
 		 */
444 444
 		if (
445
-			apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
445
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
446 446
 			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
447 447
 		) {
448
-			$messages_processor = EE_Registry::instance()->load_lib( 'Messages_Processor' );
449
-			if ( $messages_processor instanceof EE_Messages_Processor ) {
450
-				return $messages_processor->process_immediately_from_queue( $this );
448
+			$messages_processor = EE_Registry::instance()->load_lib('Messages_Processor');
449
+			if ($messages_processor instanceof EE_Messages_Processor) {
450
+				return $messages_processor->process_immediately_from_queue($this);
451 451
 			}
452 452
 			//if we get here then that means the messages processor couldn't be loaded so messages will just remain
453 453
 			//queued for manual triggering by end user.
454 454
 		}
455 455
 
456
-		if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) {
457
-			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task );
456
+		if ($this->_message_repository->count_by_priority_and_status($priority, $status)) {
457
+			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task);
458 458
 		}
459 459
 	}
460 460
 
@@ -479,53 +479,53 @@  discard block
 block discarded – undo
479 479
 	 *                    Also, if the messenger is an request type messenger (or a preview),
480 480
 	 * 					  its entirely possible that the messenger will exit before
481 481
 	 */
482
-	public function execute( $save = true, $sending_messenger = null, $by_priority = false ) {
482
+	public function execute($save = true, $sending_messenger = null, $by_priority = false) {
483 483
 		$messages_sent = 0;
484 484
 		$this->_did_hook = array();
485 485
 		$this->_message_repository->rewind();
486 486
 
487
-		while ( $this->_message_repository->valid() ) {
487
+		while ($this->_message_repository->valid()) {
488 488
 			$error_messages = array();
489 489
 			/** @type EE_Message $message */
490 490
 			$message = $this->_message_repository->current();
491 491
 			//only process things that are queued for sending
492
-			if ( ! in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) {
492
+			if ( ! in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) {
493 493
 				$this->_message_repository->next();
494 494
 				continue;
495 495
 			}
496 496
 			//if $by_priority is set and does not match then continue;
497
-			if ( $by_priority && $by_priority != $message->priority() ) {
497
+			if ($by_priority && $by_priority != $message->priority()) {
498 498
 				$this->_message_repository->next();
499 499
 				continue;
500 500
 			}
501 501
 			//error checking
502
-			if ( ! $message->valid_messenger() ) {
502
+			if ( ! $message->valid_messenger()) {
503 503
 				$error_messages[] = sprintf(
504
-					__( 'The %s messenger is not active at time of sending.', 'event_espresso' ),
504
+					__('The %s messenger is not active at time of sending.', 'event_espresso'),
505 505
 					$message->messenger()
506 506
 				);
507 507
 			}
508
-			if ( ! $message->valid_message_type() ) {
508
+			if ( ! $message->valid_message_type()) {
509 509
 				$error_messages[] = sprintf(
510
-					__( 'The %s message type is not active at the time of sending.', 'event_espresso' ),
510
+					__('The %s message type is not active at the time of sending.', 'event_espresso'),
511 511
 					$message->message_type()
512 512
 				);
513 513
 			}
514 514
 			// if there was supposed to be a sending messenger for this message, but it was invalid/inactive,
515 515
 			// then it will instead be an EE_Error object, so let's check for that
516
-			if ( $sending_messenger instanceof EE_Error ) {
516
+			if ($sending_messenger instanceof EE_Error) {
517 517
 				$error_messages[] = $sending_messenger->getMessage();
518 518
 			}
519 519
 			// if there are no errors, then let's process the message
520
-			if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) {
520
+			if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) {
521 521
 				$messages_sent++;
522 522
 			}
523
-			$this->_set_error_message( $message, $error_messages );
523
+			$this->_set_error_message($message, $error_messages);
524 524
 			//add modified time
525
-			$message->set_modified( time() );
525
+			$message->set_modified(time());
526 526
 			$this->_message_repository->next();
527 527
 		}
528
-		if ( $save ) {
528
+		if ($save) {
529 529
 			$this->save();
530 530
 		}
531 531
 		return $messages_sent;
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	 * @param mixed 	 $sending_messenger (optional)
541 541
 	 * @return bool
542 542
 	 */
543
-	protected function _process_message( EE_Message $message, $sending_messenger = null ) {
543
+	protected function _process_message(EE_Message $message, $sending_messenger = null) {
544 544
 		// these *should* have been validated in the execute() method above
545 545
 		$messenger = $message->messenger_object();
546 546
 		$message_type = $message->message_type_object();
@@ -550,20 +550,20 @@  discard block
 block discarded – undo
550 550
 			&& $messenger instanceof EE_messenger
551 551
 			&& $sending_messenger->name != $messenger->name
552 552
 		) {
553
-			$messenger->do_secondary_messenger_hooks( $sending_messenger->name );
553
+			$messenger->do_secondary_messenger_hooks($sending_messenger->name);
554 554
 			$messenger = $sending_messenger;
555 555
 		}
556 556
 		// send using messenger, but double check objects
557
-		if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) {
557
+		if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) {
558 558
 			//set hook for message type (but only if not using another messenger to send).
559
-			if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) {
560
-				$message_type->do_messenger_hooks( $messenger );
561
-				$this->_did_hook[ $message_type->name ] = 1;
559
+			if ( ! isset($this->_did_hook[$message_type->name])) {
560
+				$message_type->do_messenger_hooks($messenger);
561
+				$this->_did_hook[$message_type->name] = 1;
562 562
 			}
563 563
 			//if preview then use preview method
564 564
 			return $this->_message_repository->is_preview()
565
-				? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() )
566
-				: $this->_do_send( $message, $messenger, $message_type );
565
+				? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send())
566
+				: $this->_do_send($message, $messenger, $message_type);
567 567
 		}
568 568
 		return false;
569 569
 	}
@@ -581,12 +581,12 @@  discard block
 block discarded – undo
581 581
 	 * @param array $status  Stati to check for in queue
582 582
 	 * @return int  Count of EE_Message's matching the given status.
583 583
 	 */
584
-	public function count_STS_in_queue( $status ) {
584
+	public function count_STS_in_queue($status) {
585 585
 		$count = 0;
586
-		$status = is_array( $status ) ? $status : array( $status );
586
+		$status = is_array($status) ? $status : array($status);
587 587
 		$this->_message_repository->rewind();
588
-		foreach( $this->_message_repository as $message ) {
589
-			if ( in_array( $message->STS_ID(), $status ) ) {
588
+		foreach ($this->_message_repository as $message) {
589
+			if (in_array($message->STS_ID(), $status)) {
590 590
 				$count++;
591 591
 			}
592 592
 		}
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 	 * @param $test_send
604 604
 	 * @return bool   true means all went well, false means, not so much.
605 605
 	 */
606
-	protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) {
607
-		if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) {
608
-			if ( ! $test_send ) {
609
-				$message->set_content( $preview );
606
+	protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) {
607
+		if ($preview = $messenger->get_preview($message, $message_type, $test_send)) {
608
+			if ( ! $test_send) {
609
+				$message->set_content($preview);
610 610
 			}
611
-			$message->set_STS_ID( EEM_Message::status_sent );
611
+			$message->set_STS_ID(EEM_Message::status_sent);
612 612
 			return true;
613 613
 		} else {
614
-			$message->set_STS_ID( EEM_Message::status_failed );
614
+			$message->set_STS_ID(EEM_Message::status_failed);
615 615
 			return false;
616 616
 		}
617 617
 	}
@@ -633,18 +633,18 @@  discard block
 block discarded – undo
633 633
 	 *
634 634
 	 * @return bool true means all went well, false means, not so much.
635 635
 	 */
636
-	protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) {
636
+	protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) {
637 637
 		try {
638
-			if ( $messenger->send_message( $message, $message_type ) ) {
639
-				$message->set_STS_ID( EEM_Message::status_sent );
638
+			if ($messenger->send_message($message, $message_type)) {
639
+				$message->set_STS_ID(EEM_Message::status_sent);
640 640
 				return true;
641 641
 			} else {
642
-				$message->set_STS_ID( EEM_Message::status_retry );
642
+				$message->set_STS_ID(EEM_Message::status_retry);
643 643
 				return false;
644 644
 			}
645
-		} catch( SendMessageException $e ) {
646
-			$message->set_STS_ID( EEM_Message::status_failed );
647
-			$message->set_error_message( $e->getMessage() );
645
+		} catch (SendMessageException $e) {
646
+			$message->set_STS_ID(EEM_Message::status_failed);
647
+			$message->set_error_message($e->getMessage());
648 648
 			return false;
649 649
 		}
650 650
 	}
@@ -658,21 +658,21 @@  discard block
 block discarded – undo
658 658
 	 * @param EE_Message $message
659 659
 	 * @param array      $error_messages the response from the messenger.
660 660
 	 */
661
-	protected function _set_error_message( EE_Message $message, $error_messages ) {
661
+	protected function _set_error_message(EE_Message $message, $error_messages) {
662 662
 		$error_messages = (array) $error_messages;
663
-		if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) {
663
+		if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) {
664 664
 			$notices = EE_Error::has_notices();
665
-			$error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' );
666
-			if ( $notices === 1 ) {
665
+			$error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso');
666
+			if ($notices === 1) {
667 667
 				$notices = EE_Error::get_vanilla_notices();
668
-				$notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array();
669
-				$error_messages[] = implode( "\n", $notices['errors'] );
668
+				$notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array();
669
+				$error_messages[] = implode("\n", $notices['errors']);
670 670
 			}
671 671
 		}
672
-		if ( count( $error_messages ) > 0 ) {
673
-			$msg = __( 'Message was not executed successfully.', 'event_espresso' );
674
-			$msg = $msg . "\n" . implode( "\n", $error_messages );
675
-			$message->set_error_message( $msg );
672
+		if (count($error_messages) > 0) {
673
+			$msg = __('Message was not executed successfully.', 'event_espresso');
674
+			$msg = $msg."\n".implode("\n", $error_messages);
675
+			$message->set_error_message($msg);
676 676
 		}
677 677
 	}
678 678
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_messenger.lib.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use \EventEspresso\core\exceptions\SendMessageException;
3 3
 
4
-if (!defined('EVENT_ESPRESSO_VERSION') )
4
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
5 5
 	exit('NO direct script access allowed');
6 6
 
7 7
 /**
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @return void
280 280
 	 */
281 281
 	public function enqueue_scripts_styles() {
282
-		do_action( 'AHEE__EE_messenger__enqueue_scripts_styles');
282
+		do_action('AHEE__EE_messenger__enqueue_scripts_styles');
283 283
 	}
284 284
 
285 285
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 
350 350
 		$this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure.  Usually these affect things like font style, color, borders etc.  In some cases the styles will also make minor layout changes.');
351 351
 
352
-		$this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this );
352
+		$this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
353 353
 	}
354 354
 
355 355
 
@@ -364,10 +364,10 @@  discard block
 block discarded – undo
364 364
 	 * @return stdClass
365 365
 	 */
366 366
 	public function get_supports_labels() {
367
-		if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) {
367
+		if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
368 368
 			$this->_set_supports_labels_defaults();
369 369
 		}
370
-		return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this );
370
+		return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
371 371
 	}
372 372
 
373 373
 
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 	 *
388 388
 	 * @return string                    path or url for the requested variation.
389 389
 	 */
390
-	public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) {
390
+	public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) {
391 391
 		$this->_tmp_pack = $pack;
392
-		$variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters );
393
-		$variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path;
392
+		$variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
393
+		$variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
394 394
 		return $variation_path;
395 395
 
396 396
 	}
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 	 * @return array
409 409
 	 */
410 410
 	public function get_default_message_types() {
411
-		$class = get_class( $this );
411
+		$class = get_class($this);
412 412
 
413 413
 		//messenger specific filter
414
-		$default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this );
414
+		$default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this);
415 415
 
416 416
 		//all messengers filter
417
-		$default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this );
417
+		$default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
418 418
 		return $default_types;
419 419
 	}
420 420
 
@@ -429,14 +429,14 @@  discard block
 block discarded – undo
429 429
 	 * @return array
430 430
 	 */
431 431
 	public function get_valid_message_types() {
432
-		$class = get_class( $this );
432
+		$class = get_class($this);
433 433
 
434 434
 		//messenger specific filter
435 435
 		//messenger specific filter
436
-		$valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this );
436
+		$valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
437 437
 
438 438
 		//all messengers filter
439
-		$valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this );
439
+		$valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
440 440
 		return $valid_types;
441 441
 	}
442 442
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	 * @access public
451 451
 	 * @param array $new_config Whatever is put in here will reset the _validator_config property
452 452
 	 */
453
-	public function set_validator_config( $new_config ) {
453
+	public function set_validator_config($new_config) {
454 454
 		$this->_validator_config = $new_config;
455 455
 	}
456 456
 
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 	public function get_validator_config() {
467 467
 		$class = get_class($this);
468 468
 
469
-		$config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this );
470
-		$config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this );
469
+		$config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this);
470
+		$config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
471 471
 		return $config;
472 472
 	}
473 473
 
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 * @access public
485 485
 	 * @return string content for page
486 486
 	 */
487
-	public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) {
488
-		return $this->_get_admin_page_content( $page, $action, $extra, $message_types );
487
+	public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) {
488
+		return $this->_get_admin_page_content($page, $action, $extra, $message_types);
489 489
 	}
490 490
 
491 491
 
@@ -495,20 +495,20 @@  discard block
 block discarded – undo
495 495
 	 * @param array $extra
496 496
 	 * @return mixed|string
497 497
 	 */
498
-	protected function _get_admin_content_events_edit( $message_types, $extra ) {
498
+	protected function _get_admin_content_events_edit($message_types, $extra) {
499 499
 		//defaults
500 500
 		$template_args = array();
501 501
 		$selector_rows = '';
502 502
 
503 503
 		//we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
504
-		$event_id = isset( $extra['event'] ) ? $extra['event'] : NULL;
504
+		$event_id = isset($extra['event']) ? $extra['event'] : NULL;
505 505
 
506
-		$template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
507
-		$template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
506
+		$template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
507
+		$template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php';
508 508
 
509 509
 		//array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
510 510
 		$global_templates = EEM_Message_Template_Group::instance()->get_all(
511
-			array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
511
+			array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true))
512 512
 		);
513 513
 		$templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
514 514
 			$event_id,
@@ -517,55 +517,55 @@  discard block
 block discarded – undo
517 517
 				'MTP_is_active' => true
518 518
 			)
519 519
 		);
520
-		$templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array();
520
+		$templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array();
521 521
 
522 522
 		//so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
523
-		foreach ( $global_templates as $mtpgID => $mtpg ) {
524
-			if ( $mtpg instanceof EE_Message_Template_Group ) {
523
+		foreach ($global_templates as $mtpgID => $mtpg) {
524
+			if ($mtpg instanceof EE_Message_Template_Group) {
525 525
 				//verify this message type is supposed to show on this page
526 526
 				$mtp_obj = $mtpg->message_type_obj();
527
-				if ( ! $mtp_obj instanceof EE_message_type ) {
527
+				if ( ! $mtp_obj instanceof EE_message_type) {
528 528
 					continue;
529 529
 				}
530
-				$mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages;
531
-				if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) {
530
+				$mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
531
+				if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
532 532
 					continue;
533 533
 				}
534 534
 				$select_values = array();
535
-				$select_values[ $mtpgID ] = __( 'Global', 'event_espresso' );
536
-				$default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null;
535
+				$select_values[$mtpgID] = __('Global', 'event_espresso');
536
+				$default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
537 537
 				//if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
538
-				if ( ! $mtpg->get( 'MTP_is_override' ) ) {
538
+				if ( ! $mtpg->get('MTP_is_override')) {
539 539
 					//any custom templates for this message type?
540
-					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() );
541
-					foreach ( $custom_templates as $cmtpgID => $cmtpg ) {
542
-						$select_values[ $cmtpgID ] = $cmtpg->name();
543
-						$default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value;
540
+					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
541
+					foreach ($custom_templates as $cmtpgID => $cmtpg) {
542
+						$select_values[$cmtpgID] = $cmtpg->name();
543
+						$default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
544 544
 					}
545 545
 				}
546 546
 				//if there is no $default_value then we set it as the global
547
-				$default_value = empty( $default_value ) ? $mtpgID : $default_value;
548
-				$edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) );
549
-				$create_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) );
550
-				$st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] );
551
-				$st_args[ 'mt_slug' ] = $mtpg->message_type();
552
-				$st_args[ 'messenger_slug' ] = $this->name;
553
-				$st_args[ 'selector' ] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' );
547
+				$default_value = empty($default_value) ? $mtpgID : $default_value;
548
+				$edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php'));
549
+				$create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php'));
550
+				$st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
551
+				$st_args['mt_slug'] = $mtpg->message_type();
552
+				$st_args['messenger_slug'] = $this->name;
553
+				$st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector');
554 554
 				//note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
555
-				$st_args[ 'create_button' ] = $mtpg->get( 'MTP_is_override' ) ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __( 'Create New Custom', 'event_espresso' ) . '</a>';
556
-				$st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : '';
557
-				$st_args[ 'edit_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __( 'Edit', 'event_espresso' ) . '</a>' : '';
558
-				$selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true );
555
+				$st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>';
556
+				$st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : '';
557
+				$st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : '';
558
+				$selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
559 559
 			}
560 560
 		}
561 561
 
562 562
 		//if no selectors present then get out.
563
-		if ( empty( $selector_rows ) ) {
563
+		if (empty($selector_rows)) {
564 564
 			return '';
565 565
 		}
566 566
 
567 567
 		$template_args['selector_rows'] = $selector_rows;
568
-		return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE );
568
+		return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE);
569 569
 	}
570 570
 
571 571
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @return array $this->_template_fields
581 581
 	 */
582 582
 	public function get_template_fields() {
583
-		$template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this );
584
-		$template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this );
583
+		$template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this);
584
+		$template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
585 585
 		return $template_fields;
586 586
 	}
587 587
 
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	 * @param mixed $value
596 596
 	 */
597 597
 	protected function _set_template_value($item, $value) {
598
-		if ( array_key_exists($item, $this->_template_fields) ) {
599
-			$prop = '_' . $item;
600
-			$this->{$prop}= $value;
598
+		if (array_key_exists($item, $this->_template_fields)) {
599
+			$prop = '_'.$item;
600
+			$this->{$prop} = $value;
601 601
 		}
602 602
 	}
603 603
 
@@ -615,18 +615,18 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @throws SendMessageException
617 617
 	 */
618
-	final public function send_message( $message, EE_message_type $message_type ) {
618
+	final public function send_message($message, EE_message_type $message_type) {
619 619
 		try {
620
-			$this->_validate_and_setup( $message );
620
+			$this->_validate_and_setup($message);
621 621
 			$this->_incoming_message_type = $message_type;
622 622
 			$response = $this->_send_message();
623
-			if ( $response instanceof WP_Error ) {
624
-				EE_Error::add_error( $response->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
623
+			if ($response instanceof WP_Error) {
624
+				EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
625 625
 				$response = false;
626 626
 			}
627
-		} catch ( \Exception $e ) {
627
+		} catch (\Exception $e) {
628 628
 			//convert to an instance of SendMessageException
629
-			throw new SendMessageException( $e->getMessage() );
629
+			throw new SendMessageException($e->getMessage());
630 630
 		}
631 631
 		return $response;
632 632
 	}
@@ -640,28 +640,28 @@  discard block
 block discarded – undo
640 640
 	 * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
641 641
 	 * @return string          return the message html content
642 642
 	 */
643
-	public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) {
644
-		$this->_validate_and_setup( $message );
643
+	public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) {
644
+		$this->_validate_and_setup($message);
645 645
 
646 646
 		$this->_incoming_message_type = $message_type;
647 647
 
648
-		if ( $send ) {
648
+		if ($send) {
649 649
 			//are we overriding any existing template fields?
650 650
 			$settings = $this->get_existing_test_settings();
651
-			if ( ! empty( $settings ) ) {
652
-				foreach ( $settings as $field => $value ) {
653
-					$this->_set_template_value( $field, $value );
651
+			if ( ! empty($settings)) {
652
+				foreach ($settings as $field => $value) {
653
+					$this->_set_template_value($field, $value);
654 654
 				}
655 655
 			}
656 656
 		}
657 657
 
658 658
 		//enqueue preview js so that any links/buttons on the page are disabled.
659
-		if ( ! $send ) {
659
+		if ( ! $send) {
660 660
 			// the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
661 661
 			// it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
662
-			add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
663
-			add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
664
-			add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 );
662
+			add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10);
663
+			add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10);
664
+			add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10);
665 665
 		}
666 666
 
667 667
 		return $send ? $this->_send_message() : $this->_preview();
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
 	 */
680 680
 	public function add_preview_script() {
681 681
 		//error message
682
-		EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso' );
683
-		wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true );
684
-		wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings );
685
-		wp_enqueue_script( 'ee-messages-preview-js' );
682
+		EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso');
683
+		wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
684
+		wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
685
+		wp_enqueue_script('ee-messages-preview-js');
686 686
 	}
687 687
 
688 688
 
@@ -693,13 +693,13 @@  discard block
 block discarded – undo
693 693
 	 * @param  EE_Message $message
694 694
 	 * @throws EE_Error
695 695
 	 */
696
-	protected function _validate_and_setup( EE_Message $message ) {
696
+	protected function _validate_and_setup(EE_Message $message) {
697 697
 		$template_pack = $message->get_template_pack();
698 698
 		$variation = $message->get_template_pack_variation();
699 699
 
700 700
 		//verify we have the required template pack value on the $message object.
701
-		if ( ! $template_pack instanceof EE_Messages_Template_Pack ) {
702
-			throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) );
701
+		if ( ! $template_pack instanceof EE_Messages_Template_Pack) {
702
+			throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
703 703
 		}
704 704
 
705 705
 		$this->_tmp_pack = $template_pack;
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 
709 709
 		$template_fields = $this->get_template_fields();
710 710
 
711
-		foreach ( $template_fields as $template => $value ) {
712
-			if ( $template !== 'extra' ) {
713
-				$column_value = $message->get_field_or_extra_meta( 'MSG_' . $template );
711
+		foreach ($template_fields as $template => $value) {
712
+			if ($template !== 'extra') {
713
+				$column_value = $message->get_field_or_extra_meta('MSG_'.$template);
714 714
 				$message_template_value = $column_value ? $column_value : null;
715
-				$this->_set_template_value( $template, $message_template_value );
715
+				$this->_set_template_value($template, $message_template_value);
716 716
 			}
717 717
 		}
718 718
 	}
@@ -727,19 +727,19 @@  discard block
 block discarded – undo
727 727
 	 * @return string
728 728
 	 * @throws \EE_Error
729 729
 	 */
730
-	protected function _get_main_template( $preview = FALSE ) {
730
+	protected function _get_main_template($preview = FALSE) {
731 731
 		$type = $preview ? 'preview' : 'main';
732 732
 
733
-		$wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type );
733
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
734 734
 
735 735
 		//check file exists and is readable
736
-		if ( !is_readable( $wrapper_template ) )
737
-			throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) );
736
+		if ( ! is_readable($wrapper_template))
737
+			throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
738 738
 
739 739
 		//add message type to template args
740 740
 		$this->_template_args['message_type'] = $this->_incoming_message_type;
741 741
 
742
-		return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE );
742
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE);
743 743
 	}
744 744
 
745 745
 
@@ -775,9 +775,9 @@  discard block
 block discarded – undo
775 775
 	 */
776 776
 	public function get_existing_test_settings() {
777 777
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
778
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
778
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
779 779
 		$settings = $Message_Resource_Manager->get_active_messengers_option();
780
-		return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array();
780
+		return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array();
781 781
 	}
782 782
 
783 783
 
@@ -789,12 +789,12 @@  discard block
 block discarded – undo
789 789
 	 * @param $settings
790 790
 	 * @return bool success/fail
791 791
 	 */
792
-	public function set_existing_test_settings( $settings ) {
792
+	public function set_existing_test_settings($settings) {
793 793
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
794
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
794
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
795 795
 		$existing = $Message_Resource_Manager->get_active_messengers_option();
796
-		$existing[ $this->name ]['test_settings'] = $settings;
797
-		return $Message_Resource_Manager->update_active_messengers_option( $existing );
796
+		$existing[$this->name]['test_settings'] = $settings;
797
+		return $Message_Resource_Manager->update_active_messengers_option($existing);
798 798
 	}
799 799
 
800 800
 
@@ -807,21 +807,21 @@  discard block
 block discarded – undo
807 807
 	 * @param string $field The field to retrieve the label for
808 808
 	 * @return string        	  The label
809 809
 	 */
810
-	public function get_field_label( $field ) {
810
+	public function get_field_label($field) {
811 811
 		//first let's see if the field requests is in the top level array.
812
-		if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) )
812
+		if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label']))
813 813
 			return $this->_template[$field]['label'];
814 814
 
815 815
 		//nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
816
-		if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] )  )
816
+		if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label']))
817 817
 			return $this->_template_fields['extra'][$field]['main']['label'];
818 818
 
819 819
 		//now it's possible this field may just be existing in any of the extra array items.
820
-		if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) {
821
-			foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) {
822
-				if ( !is_array( $subfields ) )
820
+		if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
821
+			foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
822
+				if ( ! is_array($subfields))
823 823
 					continue;
824
-				if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) )
824
+				if (isset($subfields[$field]) && ! empty($subfields[$field]['label']))
825 825
 					return $subfields[$field]['label'];
826 826
 			}
827 827
 		}
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 	 *
843 843
 	 * @return void
844 844
 	 */
845
-	public function do_secondary_messenger_hooks( $sending_messenger_name ) {
845
+	public function do_secondary_messenger_hooks($sending_messenger_name) {
846 846
 		return;
847 847
 	}
848 848
 
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 	 * This just returns whatever is set as the _event object property
1322 1322
 	 *
1323 1323
 	 * //todo this will become obsolete once the models are in place
1324
-	 * @return object
1324
+	 * @return EE_Event
1325 1325
 	 */
1326 1326
 	public function get_event_object() {
1327 1327
 		return $this->_cpt_model_obj;
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
 
2199 2199
 
2200 2200
 	/**
2201
-	 * @return mixed
2201
+	 * @return string
2202 2202
 	 */
2203 2203
 	protected function _category_details_content() {
2204 2204
 		$editor_args['category_desc'] = array(
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -829,11 +829,11 @@  discard block
 block discarded – undo
829 829
 		if ( ! empty( $id ) ) {
830 830
 			$post = get_post( $id );
831 831
 			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
832
-			           . esc_html__( 'Shortcode', 'event_espresso' )
833
-			           . '</a> ';
832
+					   . esc_html__( 'Shortcode', 'event_espresso' )
833
+					   . '</a> ';
834 834
 			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
835
-			           . $post->ID
836
-			           . ']">';
835
+					   . $post->ID
836
+					   . ']">';
837 837
 		}
838 838
 		return $return;
839 839
 	}
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 			//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.
1046 1046
 			if ( ! empty( $dtt['DTT_ID'] ) ) {
1047 1047
 				$DTM = EE_Registry::instance()
1048
-				                  ->load_model( 'Datetime', array( $evtobj->get_timezone() ) )
1049
-				                  ->get_one_by_ID( $dtt['DTT_ID'] );
1048
+								  ->load_model( 'Datetime', array( $evtobj->get_timezone() ) )
1049
+								  ->get_one_by_ID( $dtt['DTT_ID'] );
1050 1050
 				$DTM->set_date_format( $incoming_date_formats[0] );
1051 1051
 				$DTM->set_time_format( $incoming_date_formats[1] );
1052 1052
 				foreach ( $datetime_values as $field => $value ) {
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 					) > 0 ? true : false;
1145 1145
 					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1146 1146
 					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' )
1147
-					                  && ! $TKT->get(
1147
+									  && ! $TKT->get(
1148 1148
 						'TKT_deleted'
1149 1149
 					) ? true : false;
1150 1150
 					$TKT->set_date_format( $incoming_date_formats[0] );
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 		$first_datetime = reset( $times );
1455 1455
 		//do we get related tickets?
1456 1456
 		if ( $first_datetime instanceof EE_Datetime
1457
-		     && $first_datetime->ID() !== 0
1457
+			 && $first_datetime->ID() !== 0
1458 1458
 		) {
1459 1459
 			$existing_datetime_ids[] = $first_datetime->get( 'DTT_ID' );
1460 1460
 			$template_args['time'] = $first_datetime;
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1530 1530
 			'TKT_sold'            => $skeleton ? 0 : $ticket->get( 'TKT_sold' ),
1531 1531
 			'trash_icon'          => ( $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) )
1532
-			                         && ( ! empty( $ticket ) && $ticket->get( 'TKT_sold' ) === 0 )
1532
+									 && ( ! empty( $ticket ) && $ticket->get( 'TKT_sold' ) === 0 )
1533 1533
 				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1534 1534
 			'disabled'            => $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ? ''
1535 1535
 				: ' disabled=disabled',
@@ -1695,8 +1695,8 @@  discard block
 block discarded – undo
1695 1695
 			$DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1696 1696
 			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1697 1697
 			$end = $DateTime->setDate( date( 'Y' ), date( 'm' ), $DateTime->format( 't' ) )
1698
-			                ->setTime( 23, 59, 59 )
1699
-			                ->format( implode( ' ', $start_formats ) );
1698
+							->setTime( 23, 59, 59 )
1699
+							->format( implode( ' ', $start_formats ) );
1700 1700
 			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1701 1701
 		}
1702 1702
 		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
 		}
1717 1717
 		if ( isset( $this->_req_data['EVT_wp_user'] ) ) {
1718 1718
 			if ( $this->_req_data['EVT_wp_user'] != get_current_user_id()
1719
-			     && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' )
1719
+				 && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' )
1720 1720
 			) {
1721 1721
 				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1722 1722
 			}
@@ -2213,13 +2213,13 @@  discard block
 block discarded – undo
2213 2213
 	protected function _template_settings() {
2214 2214
 		$this->_admin_page_title = esc_html__( 'Template Settings (Preview)', 'event_espresso' );
2215 2215
 		$this->_template_args['preview_img'] = '<img src="'
2216
-		                                       . EVENTS_ASSETS_URL
2217
-		                                       . DS
2218
-		                                       . 'images'
2219
-		                                       . DS
2220
-		                                       . 'caffeinated_template_features.jpg" alt="'
2221
-		                                       . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' )
2222
-		                                       . '" />';
2216
+											   . EVENTS_ASSETS_URL
2217
+											   . DS
2218
+											   . 'images'
2219
+											   . DS
2220
+											   . 'caffeinated_template_features.jpg" alt="'
2221
+											   . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' )
2222
+											   . '" />';
2223 2223
 		$this->_template_args['preview_text'] = '<strong>' . esc_html__(
2224 2224
 				'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2225 2225
 				'event_espresso'
Please login to merge, or discard this patch.
Spacing   +595 added lines, -595 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'NO direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		);
64 64
 		add_action(
65 65
 			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
66
-			array( $this, 'verify_event_edit' )
66
+			array($this, 'verify_event_edit')
67 67
 		);
68 68
 	}
69 69
 
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
 		$this->_admin_page_title = EVENTS_LABEL;
80 80
 		$this->_labels = array(
81 81
 			'buttons'      => array(
82
-				'add'             => esc_html__( 'Add New Event', 'event_espresso' ),
83
-				'edit'            => esc_html__( 'Edit Event', 'event_espresso' ),
84
-				'delete'          => esc_html__( 'Delete Event', 'event_espresso' ),
85
-				'add_category'    => esc_html__( 'Add New Category', 'event_espresso' ),
86
-				'edit_category'   => esc_html__( 'Edit Category', 'event_espresso' ),
87
-				'delete_category' => esc_html__( 'Delete Category', 'event_espresso' ),
82
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
83
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
84
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
85
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
86
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
87
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
88 88
 			),
89 89
 			'editor_title' => array(
90
-				'espresso_events' => esc_html__( 'Enter event title here', 'event_espresso' ),
90
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
91 91
 			),
92 92
 			'publishbox'   => array(
93
-				'create_new'        => esc_html__( 'Save New Event', 'event_espresso' ),
94
-				'edit'              => esc_html__( 'Update Event', 'event_espresso' ),
95
-				'add_category'      => esc_html__( 'Save New Category', 'event_espresso' ),
96
-				'edit_category'     => esc_html__( 'Update Category', 'event_espresso' ),
97
-				'template_settings' => esc_html__( 'Update Settings', 'event_espresso' ),
93
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
94
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
95
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
96
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
97
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
98 98
 			),
99 99
 		);
100 100
 	}
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 		//load formatter helper
106 106
 		//load field generator helper
107 107
 		//is there a evt_id in the request?
108
-		$evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] )
108
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
109 109
 			? $this->_req_data['EVT_ID'] : 0;
110
-		$evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id;
110
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
111 111
 		$this->_page_routes = array(
112 112
 			'default'                       => array(
113 113
 				'func'       => '_events_overview_list_table',
@@ -130,27 +130,27 @@  discard block
 block discarded – undo
130 130
 			),
131 131
 			'trash_event'                   => array(
132 132
 				'func'       => '_trash_or_restore_event',
133
-				'args'       => array( 'event_status' => 'trash' ),
133
+				'args'       => array('event_status' => 'trash'),
134 134
 				'capability' => 'ee_delete_event',
135 135
 				'obj_id'     => $evt_id,
136 136
 				'noheader'   => true,
137 137
 			),
138 138
 			'trash_events'                  => array(
139 139
 				'func'       => '_trash_or_restore_events',
140
-				'args'       => array( 'event_status' => 'trash' ),
140
+				'args'       => array('event_status' => 'trash'),
141 141
 				'capability' => 'ee_delete_events',
142 142
 				'noheader'   => true,
143 143
 			),
144 144
 			'restore_event'                 => array(
145 145
 				'func'       => '_trash_or_restore_event',
146
-				'args'       => array( 'event_status' => 'draft' ),
146
+				'args'       => array('event_status' => 'draft'),
147 147
 				'capability' => 'ee_delete_event',
148 148
 				'obj_id'     => $evt_id,
149 149
 				'noheader'   => true,
150 150
 			),
151 151
 			'restore_events'                => array(
152 152
 				'func'       => '_trash_or_restore_events',
153
-				'args'       => array( 'event_status' => 'draft' ),
153
+				'args'       => array('event_status' => 'draft'),
154 154
 				'capability' => 'ee_delete_events',
155 155
 				'noheader'   => true,
156 156
 			),
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 			'add_category'                  => array(
187 187
 				'func'       => '_category_details',
188 188
 				'capability' => 'ee_edit_event_category',
189
-				'args'       => array( 'add' ),
189
+				'args'       => array('add'),
190 190
 			),
191 191
 			'edit_category'                 => array(
192 192
 				'func'       => '_category_details',
193 193
 				'capability' => 'ee_edit_event_category',
194
-				'args'       => array( 'edit' ),
194
+				'args'       => array('edit'),
195 195
 			),
196 196
 			'delete_categories'             => array(
197 197
 				'func'       => '_delete_categories',
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 			),
206 206
 			'insert_category' => array(
207 207
 				'func'       => '_insert_or_update_category',
208
-				'args'       => array( 'new_category' => true ),
208
+				'args'       => array('new_category' => true),
209 209
 				'capability' => 'ee_edit_event_category',
210 210
 				'noheader'   => true,
211 211
 			),
212 212
 			'update_category' => array(
213 213
 				'func'       => '_insert_or_update_category',
214
-				'args'       => array( 'new_category' => false ),
214
+				'args'       => array('new_category' => false),
215 215
 				'capability' => 'ee_edit_event_category',
216 216
 				'noheader'   => true,
217 217
 			),
@@ -228,29 +228,29 @@  discard block
 block discarded – undo
228 228
 		$this->_page_config = array(
229 229
 			'default'                => array(
230 230
 				'nav'           => array(
231
-					'label' => esc_html__( 'Overview', 'event_espresso' ),
231
+					'label' => esc_html__('Overview', 'event_espresso'),
232 232
 					'order' => 10,
233 233
 				),
234 234
 				'list_table'    => 'Events_Admin_List_Table',
235 235
 				'help_tabs'     => array(
236 236
 					'events_overview_help_tab'                       => array(
237
-						'title'    => esc_html__( 'Events Overview', 'event_espresso' ),
237
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
238 238
 						'filename' => 'events_overview',
239 239
 					),
240 240
 					'events_overview_table_column_headings_help_tab' => array(
241
-						'title'    => esc_html__( 'Events Overview Table Column Headings', 'event_espresso' ),
241
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
242 242
 						'filename' => 'events_overview_table_column_headings',
243 243
 					),
244 244
 					'events_overview_filters_help_tab'               => array(
245
-						'title'    => esc_html__( 'Events Overview Filters', 'event_espresso' ),
245
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
246 246
 						'filename' => 'events_overview_filters',
247 247
 					),
248 248
 					'events_overview_view_help_tab'                  => array(
249
-						'title'    => esc_html__( 'Events Overview Views', 'event_espresso' ),
249
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
250 250
 						'filename' => 'events_overview_views',
251 251
 					),
252 252
 					'events_overview_other_help_tab'                 => array(
253
-						'title'    => esc_html__( 'Events Overview Other', 'event_espresso' ),
253
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
254 254
 						'filename' => 'events_overview_other',
255 255
 					),
256 256
 				),
@@ -265,218 +265,218 @@  discard block
 block discarded – undo
265 265
 			),
266 266
 			'create_new'             => array(
267 267
 				'nav'           => array(
268
-					'label'      => esc_html__( 'Add Event', 'event_espresso' ),
268
+					'label'      => esc_html__('Add Event', 'event_espresso'),
269 269
 					'order'      => 5,
270 270
 					'persistent' => false,
271 271
 				),
272
-				'metaboxes'     => array( '_register_event_editor_meta_boxes' ),
272
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
273 273
 				'help_tabs'     => array(
274 274
 					'event_editor_help_tab'                            => array(
275
-						'title'    => esc_html__( 'Event Editor', 'event_espresso' ),
275
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
276 276
 						'filename' => 'event_editor',
277 277
 					),
278 278
 					'event_editor_title_richtexteditor_help_tab'       => array(
279
-						'title'    => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ),
279
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
280 280
 						'filename' => 'event_editor_title_richtexteditor',
281 281
 					),
282 282
 					'event_editor_venue_details_help_tab'              => array(
283
-						'title'    => esc_html__( 'Event Venue Details', 'event_espresso' ),
283
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
284 284
 						'filename' => 'event_editor_venue_details',
285 285
 					),
286 286
 					'event_editor_event_datetimes_help_tab'            => array(
287
-						'title'    => esc_html__( 'Event Datetimes', 'event_espresso' ),
287
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
288 288
 						'filename' => 'event_editor_event_datetimes',
289 289
 					),
290 290
 					'event_editor_event_tickets_help_tab'              => array(
291
-						'title'    => esc_html__( 'Event Tickets', 'event_espresso' ),
291
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
292 292
 						'filename' => 'event_editor_event_tickets',
293 293
 					),
294 294
 					'event_editor_event_registration_options_help_tab' => array(
295
-						'title'    => esc_html__( 'Event Registration Options', 'event_espresso' ),
295
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
296 296
 						'filename' => 'event_editor_event_registration_options',
297 297
 					),
298 298
 					'event_editor_tags_categories_help_tab'            => array(
299
-						'title'    => esc_html__( 'Event Tags & Categories', 'event_espresso' ),
299
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
300 300
 						'filename' => 'event_editor_tags_categories',
301 301
 					),
302 302
 					'event_editor_questions_registrants_help_tab'      => array(
303
-						'title'    => esc_html__( 'Questions for Registrants', 'event_espresso' ),
303
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
304 304
 						'filename' => 'event_editor_questions_registrants',
305 305
 					),
306 306
 					'event_editor_save_new_event_help_tab'             => array(
307
-						'title'    => esc_html__( 'Save New Event', 'event_espresso' ),
307
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
308 308
 						'filename' => 'event_editor_save_new_event',
309 309
 					),
310 310
 					'event_editor_other_help_tab'                      => array(
311
-						'title'    => esc_html__( 'Event Other', 'event_espresso' ),
311
+						'title'    => esc_html__('Event Other', 'event_espresso'),
312 312
 						'filename' => 'event_editor_other',
313 313
 					),
314 314
 				),
315 315
 				'help_tour'     => array(
316 316
 					'Event_Editor_Help_Tour',
317 317
 				),
318
-				'qtips'         => array( 'EE_Event_Editor_Decaf_Tips' ),
318
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
319 319
 				'require_nonce' => false,
320 320
 			),
321 321
 			'edit'                   => array(
322 322
 				'nav'           => array(
323
-					'label'      => esc_html__( 'Edit Event', 'event_espresso' ),
323
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
324 324
 					'order'      => 5,
325 325
 					'persistent' => false,
326
-					'url'        => isset( $this->_req_data['post'] )
326
+					'url'        => isset($this->_req_data['post'])
327 327
 						? EE_Admin_Page::add_query_args_and_nonce(
328
-							array( 'post' => $this->_req_data['post'], 'action' => 'edit' ),
328
+							array('post' => $this->_req_data['post'], 'action' => 'edit'),
329 329
 							$this->_current_page_view_url
330 330
 						)
331 331
 						: $this->_admin_base_url,
332 332
 				),
333
-				'metaboxes'     => array( '_register_event_editor_meta_boxes' ),
333
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
334 334
 				'help_tabs'     => array(
335 335
 					'event_editor_help_tab'                            => array(
336
-						'title'    => esc_html__( 'Event Editor', 'event_espresso' ),
336
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
337 337
 						'filename' => 'event_editor',
338 338
 					),
339 339
 					'event_editor_title_richtexteditor_help_tab'       => array(
340
-						'title'    => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ),
340
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
341 341
 						'filename' => 'event_editor_title_richtexteditor',
342 342
 					),
343 343
 					'event_editor_venue_details_help_tab'              => array(
344
-						'title'    => esc_html__( 'Event Venue Details', 'event_espresso' ),
344
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
345 345
 						'filename' => 'event_editor_venue_details',
346 346
 					),
347 347
 					'event_editor_event_datetimes_help_tab'            => array(
348
-						'title'    => esc_html__( 'Event Datetimes', 'event_espresso' ),
348
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
349 349
 						'filename' => 'event_editor_event_datetimes',
350 350
 					),
351 351
 					'event_editor_event_tickets_help_tab'              => array(
352
-						'title'    => esc_html__( 'Event Tickets', 'event_espresso' ),
352
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
353 353
 						'filename' => 'event_editor_event_tickets',
354 354
 					),
355 355
 					'event_editor_event_registration_options_help_tab' => array(
356
-						'title'    => esc_html__( 'Event Registration Options', 'event_espresso' ),
356
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
357 357
 						'filename' => 'event_editor_event_registration_options',
358 358
 					),
359 359
 					'event_editor_tags_categories_help_tab'            => array(
360
-						'title'    => esc_html__( 'Event Tags & Categories', 'event_espresso' ),
360
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
361 361
 						'filename' => 'event_editor_tags_categories',
362 362
 					),
363 363
 					'event_editor_questions_registrants_help_tab'      => array(
364
-						'title'    => esc_html__( 'Questions for Registrants', 'event_espresso' ),
364
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
365 365
 						'filename' => 'event_editor_questions_registrants',
366 366
 					),
367 367
 					'event_editor_save_new_event_help_tab'             => array(
368
-						'title'    => esc_html__( 'Save New Event', 'event_espresso' ),
368
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
369 369
 						'filename' => 'event_editor_save_new_event',
370 370
 					),
371 371
 					'event_editor_other_help_tab'                      => array(
372
-						'title'    => esc_html__( 'Event Other', 'event_espresso' ),
372
+						'title'    => esc_html__('Event Other', 'event_espresso'),
373 373
 						'filename' => 'event_editor_other',
374 374
 					),
375 375
 				),
376 376
 				/*'help_tour' => array(
377 377
 					'Event_Edit_Help_Tour'
378 378
 				),*/
379
-				'qtips'         => array( 'EE_Event_Editor_Decaf_Tips' ),
379
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
380 380
 				'require_nonce' => false,
381 381
 			),
382 382
 			'default_event_settings' => array(
383 383
 				'nav'           => array(
384
-					'label' => esc_html__( 'Default Settings', 'event_espresso' ),
384
+					'label' => esc_html__('Default Settings', 'event_espresso'),
385 385
 					'order' => 40,
386 386
 				),
387
-				'metaboxes'     => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
387
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
388 388
 				'labels'        => array(
389
-					'publishbox' => esc_html__( 'Update Settings', 'event_espresso' ),
389
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
390 390
 				),
391 391
 				'help_tabs'     => array(
392 392
 					'default_settings_help_tab'        => array(
393
-						'title'    => esc_html__( 'Default Event Settings', 'event_espresso' ),
393
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
394 394
 						'filename' => 'events_default_settings',
395 395
 					),
396 396
 					'default_settings_status_help_tab' => array(
397
-						'title'    => esc_html__( 'Default Registration Status', 'event_espresso' ),
397
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
398 398
 						'filename' => 'events_default_settings_status',
399 399
 					),
400 400
 				),
401
-				'help_tour'     => array( 'Event_Default_Settings_Help_Tour' ),
401
+				'help_tour'     => array('Event_Default_Settings_Help_Tour'),
402 402
 				'require_nonce' => false,
403 403
 			),
404 404
 			//template settings
405 405
 			'template_settings'      => array(
406 406
 				'nav'           => array(
407
-					'label' => esc_html__( 'Templates', 'event_espresso' ),
407
+					'label' => esc_html__('Templates', 'event_espresso'),
408 408
 					'order' => 30,
409 409
 				),
410 410
 				'metaboxes'     => $this->_default_espresso_metaboxes,
411 411
 				'help_tabs'     => array(
412 412
 					'general_settings_templates_help_tab' => array(
413
-						'title'    => esc_html__( 'Templates', 'event_espresso' ),
413
+						'title'    => esc_html__('Templates', 'event_espresso'),
414 414
 						'filename' => 'general_settings_templates',
415 415
 					),
416 416
 				),
417
-				'help_tour'     => array( 'Templates_Help_Tour' ),
417
+				'help_tour'     => array('Templates_Help_Tour'),
418 418
 				'require_nonce' => false,
419 419
 			),
420 420
 			//event category stuff
421 421
 			'add_category'           => array(
422 422
 				'nav'           => array(
423
-					'label'      => esc_html__( 'Add Category', 'event_espresso' ),
423
+					'label'      => esc_html__('Add Category', 'event_espresso'),
424 424
 					'order'      => 15,
425 425
 					'persistent' => false,
426 426
 				),
427 427
 				'help_tabs'     => array(
428 428
 					'add_category_help_tab' => array(
429
-						'title'    => esc_html__( 'Add New Event Category', 'event_espresso' ),
429
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
430 430
 						'filename' => 'events_add_category',
431 431
 					),
432 432
 				),
433
-				'help_tour'     => array( 'Event_Add_Category_Help_Tour' ),
434
-				'metaboxes'     => array( '_publish_post_box' ),
433
+				'help_tour'     => array('Event_Add_Category_Help_Tour'),
434
+				'metaboxes'     => array('_publish_post_box'),
435 435
 				'require_nonce' => false,
436 436
 			),
437 437
 			'edit_category'          => array(
438 438
 				'nav'           => array(
439
-					'label'      => esc_html__( 'Edit Category', 'event_espresso' ),
439
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
440 440
 					'order'      => 15,
441 441
 					'persistent' => false,
442
-					'url'        => isset( $this->_req_data['EVT_CAT_ID'] )
442
+					'url'        => isset($this->_req_data['EVT_CAT_ID'])
443 443
 						? add_query_arg(
444
-							array( 'EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ),
444
+							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
445 445
 							$this->_current_page_view_url
446 446
 						)
447 447
 						: $this->_admin_base_url,
448 448
 				),
449 449
 				'help_tabs'     => array(
450 450
 					'edit_category_help_tab' => array(
451
-						'title'    => esc_html__( 'Edit Event Category', 'event_espresso' ),
451
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
452 452
 						'filename' => 'events_edit_category',
453 453
 					),
454 454
 				),
455 455
 				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
456
-				'metaboxes'     => array( '_publish_post_box' ),
456
+				'metaboxes'     => array('_publish_post_box'),
457 457
 				'require_nonce' => false,
458 458
 			),
459 459
 			'category_list'          => array(
460 460
 				'nav'           => array(
461
-					'label' => esc_html__( 'Categories', 'event_espresso' ),
461
+					'label' => esc_html__('Categories', 'event_espresso'),
462 462
 					'order' => 20,
463 463
 				),
464 464
 				'list_table'    => 'Event_Categories_Admin_List_Table',
465 465
 				'help_tabs'     => array(
466 466
 					'events_categories_help_tab'                       => array(
467
-						'title'    => esc_html__( 'Event Categories', 'event_espresso' ),
467
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
468 468
 						'filename' => 'events_categories',
469 469
 					),
470 470
 					'events_categories_table_column_headings_help_tab' => array(
471
-						'title'    => esc_html__( 'Event Categories Table Column Headings', 'event_espresso' ),
471
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
472 472
 						'filename' => 'events_categories_table_column_headings',
473 473
 					),
474 474
 					'events_categories_view_help_tab'                  => array(
475
-						'title'    => esc_html__( 'Event Categories Views', 'event_espresso' ),
475
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
476 476
 						'filename' => 'events_categories_views',
477 477
 					),
478 478
 					'events_categories_other_help_tab'                 => array(
479
-						'title'    => esc_html__( 'Event Categories Other', 'event_espresso' ),
479
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
480 480
 						'filename' => 'events_categories_other',
481 481
 					),
482 482
 				),
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
 	protected function _add_screen_options_category_list() {
507 507
 		$page_title = $this->_admin_page_title;
508
-		$this->_admin_page_title = esc_html__( 'Categories', 'event_espresso' );
508
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
509 509
 		$this->_per_page_screen_option();
510 510
 		$this->_admin_page_title = $page_title;
511 511
 	}
@@ -521,20 +521,20 @@  discard block
 block discarded – undo
521 521
 	public function load_scripts_styles() {
522 522
 		wp_register_style(
523 523
 			'events-admin-css',
524
-			EVENTS_ASSETS_URL . 'events-admin-page.css',
524
+			EVENTS_ASSETS_URL.'events-admin-page.css',
525 525
 			array(),
526 526
 			EVENT_ESPRESSO_VERSION
527 527
 		);
528
-		wp_register_style( 'ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION );
529
-		wp_enqueue_style( 'events-admin-css' );
530
-		wp_enqueue_style( 'ee-cat-admin' );
528
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
529
+		wp_enqueue_style('events-admin-css');
530
+		wp_enqueue_style('ee-cat-admin');
531 531
 		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
532 532
 		//registers for all views
533 533
 		//scripts
534 534
 		wp_register_script(
535 535
 			'event_editor_js',
536
-			EVENTS_ASSETS_URL . 'event_editor.js',
537
-			array( 'ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon' ),
536
+			EVENTS_ASSETS_URL.'event_editor.js',
537
+			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
538 538
 			EVENT_ESPRESSO_VERSION,
539 539
 			true
540 540
 		);
@@ -560,22 +560,22 @@  discard block
 block discarded – undo
560 560
 	 */
561 561
 	public function load_scripts_styles_edit() {
562 562
 		//styles
563
-		wp_enqueue_style( 'espresso-ui-theme' );
563
+		wp_enqueue_style('espresso-ui-theme');
564 564
 		wp_register_style(
565 565
 			'event-editor-css',
566
-			EVENTS_ASSETS_URL . 'event-editor.css',
567
-			array( 'ee-admin-css' ),
566
+			EVENTS_ASSETS_URL.'event-editor.css',
567
+			array('ee-admin-css'),
568 568
 			EVENT_ESPRESSO_VERSION
569 569
 		);
570
-		wp_enqueue_style( 'event-editor-css' );
570
+		wp_enqueue_style('event-editor-css');
571 571
 		//scripts
572 572
 		wp_register_script(
573 573
 			'event-datetime-metabox',
574
-			EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
575
-			array( 'event_editor_js', 'ee-datepicker' ),
574
+			EVENTS_ASSETS_URL.'event-datetime-metabox.js',
575
+			array('event_editor_js', 'ee-datepicker'),
576 576
 			EVENT_ESPRESSO_VERSION
577 577
 		);
578
-		wp_enqueue_script( 'event-datetime-metabox' );
578
+		wp_enqueue_script('event-datetime-metabox');
579 579
 	}
580 580
 
581 581
 
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 		$this->_views = array(
596 596
 			'all' => array(
597 597
 				'slug'        => 'all',
598
-				'label'       => esc_html__( 'All', 'event_espresso' ),
598
+				'label'       => esc_html__('All', 'event_espresso'),
599 599
 				'count'       => 0,
600 600
 				'bulk_action' => array(
601
-					'delete_categories' => esc_html__( 'Delete Permanently', 'event_espresso' ),
601
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
602 602
 				),
603 603
 			),
604 604
 		);
@@ -634,14 +634,14 @@  discard block
 block discarded – undo
634 634
 	 * @access public
635 635
 	 * @return void
636 636
 	 */
637
-	public function verify_event_edit( $event = null ) {
637
+	public function verify_event_edit($event = null) {
638 638
 		// no event?
639
-		if ( empty( $event ) ) {
639
+		if (empty($event)) {
640 640
 			// set event
641 641
 			$event = $this->_cpt_model_obj;
642 642
 		}
643 643
 		// STILL no event?
644
-		if ( empty ( $event ) ) {
644
+		if (empty ($event)) {
645 645
 			return;
646 646
 		}
647 647
 		$orig_status = $event->status();
@@ -655,32 +655,32 @@  discard block
 block discarded – undo
655 655
 			return;
656 656
 		}
657 657
 		//made it here so it IS active... next check that any of the tickets are sold.
658
-		if ( $event->is_sold_out( true ) ) {
659
-			if ( $orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status ) {
658
+		if ($event->is_sold_out(true)) {
659
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
660 660
 				EE_Error::add_attention(
661 661
 					sprintf(
662 662
 						esc_html__(
663 663
 							'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
664 664
 							'event_espresso'
665 665
 						),
666
-						EEH_Template::pretty_status( EEM_Event::sold_out, false, 'sentence' )
666
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
667 667
 					)
668 668
 				);
669 669
 			}
670 670
 			return;
671
-		} else if ( $orig_status === EEM_Event::sold_out ) {
671
+		} else if ($orig_status === EEM_Event::sold_out) {
672 672
 			EE_Error::add_attention(
673 673
 				sprintf(
674 674
 					esc_html__(
675 675
 						'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
676 676
 						'event_espresso'
677 677
 					),
678
-					EEH_Template::pretty_status( $event->status(), false, 'sentence' )
678
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
679 679
 				)
680 680
 			);
681 681
 		}
682 682
 		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
683
-		if ( ! $event->tickets_on_sale() ) {
683
+		if ( ! $event->tickets_on_sale()) {
684 684
 			return;
685 685
 		}
686 686
 		//made it here so show warning
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	 */
699 699
 	protected function _edit_event_warning() {
700 700
 		// we don't want to add warnings during these requests
701
-		if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] === 'editpost' ) {
701
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
702 702
 			return;
703 703
 		}
704 704
 		EE_Error::add_attention(
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
 	 * @return string
718 718
 	 */
719 719
 	protected function _create_new_cpt_item() {
720
-		$gmt_offset = get_option( 'gmt_offset' );
720
+		$gmt_offset = get_option('gmt_offset');
721 721
 		//only nag them about setting their timezone if it's their first event, and they haven't already done it
722
-		if( $gmt_offset === '0' && ! EEM_Event::instance()->exists(array()) ) {
722
+		if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) {
723 723
 			EE_Error::add_attention(
724 724
 				sprintf(
725
-					__( 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city
725
+					__('Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city
726 726
 			        or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.'),
727
-					'<a href="' . admin_url( 'options-general.php' ) . '">',
727
+					'<a href="'.admin_url('options-general.php').'">',
728 728
 					'</a>'
729 729
 				),
730 730
 				__FILE__,
@@ -741,29 +741,29 @@  discard block
 block discarded – undo
741 741
 		$this->_views = array(
742 742
 			'all'   => array(
743 743
 				'slug'        => 'all',
744
-				'label'       => esc_html__( 'View All Events', 'event_espresso' ),
744
+				'label'       => esc_html__('View All Events', 'event_espresso'),
745 745
 				'count'       => 0,
746 746
 				'bulk_action' => array(
747
-					'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ),
747
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
748 748
 				),
749 749
 			),
750 750
 			'draft' => array(
751 751
 				'slug'        => 'draft',
752
-				'label'       => esc_html__( 'Draft', 'event_espresso' ),
752
+				'label'       => esc_html__('Draft', 'event_espresso'),
753 753
 				'count'       => 0,
754 754
 				'bulk_action' => array(
755
-					'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ),
755
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
756 756
 				),
757 757
 			),
758 758
 		);
759
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
759
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
760 760
 			$this->_views['trash'] = array(
761 761
 				'slug'        => 'trash',
762
-				'label'       => esc_html__( 'Trash', 'event_espresso' ),
762
+				'label'       => esc_html__('Trash', 'event_espresso'),
763 763
 				'count'       => 0,
764 764
 				'bulk_action' => array(
765
-					'restore_events' => esc_html__( 'Restore From Trash', 'event_espresso' ),
766
-					'delete_events'  => esc_html__( 'Delete Permanently', 'event_espresso' ),
765
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
766
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
767 767
 				),
768 768
 			);
769 769
 		}
@@ -778,50 +778,50 @@  discard block
 block discarded – undo
778 778
 		$items = array(
779 779
 			'view_details'   => array(
780 780
 				'class' => 'dashicons dashicons-search',
781
-				'desc'  => esc_html__( 'View Event', 'event_espresso' ),
781
+				'desc'  => esc_html__('View Event', 'event_espresso'),
782 782
 			),
783 783
 			'edit_event'     => array(
784 784
 				'class' => 'ee-icon ee-icon-calendar-edit',
785
-				'desc'  => esc_html__( 'Edit Event Details', 'event_espresso' ),
785
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
786 786
 			),
787 787
 			'view_attendees' => array(
788 788
 				'class' => 'dashicons dashicons-groups',
789
-				'desc'  => esc_html__( 'View Registrations for Event', 'event_espresso' ),
789
+				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
790 790
 			),
791 791
 		);
792
-		$items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items );
792
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
793 793
 		$statuses = array(
794 794
 			'sold_out_status'  => array(
795
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
796
-				'desc'  => EEH_Template::pretty_status( EE_Datetime::sold_out, false, 'sentence' ),
795
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
796
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
797 797
 			),
798 798
 			'active_status'    => array(
799
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
800
-				'desc'  => EEH_Template::pretty_status( EE_Datetime::active, false, 'sentence' ),
799
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
800
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
801 801
 			),
802 802
 			'upcoming_status'  => array(
803
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
804
-				'desc'  => EEH_Template::pretty_status( EE_Datetime::upcoming, false, 'sentence' ),
803
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
804
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
805 805
 			),
806 806
 			'postponed_status' => array(
807
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
808
-				'desc'  => EEH_Template::pretty_status( EE_Datetime::postponed, false, 'sentence' ),
807
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
808
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
809 809
 			),
810 810
 			'cancelled_status' => array(
811
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
812
-				'desc'  => EEH_Template::pretty_status( EE_Datetime::cancelled, false, 'sentence' ),
811
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
812
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
813 813
 			),
814 814
 			'expired_status'   => array(
815
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
816
-				'desc'  => EEH_Template::pretty_status( EE_Datetime::expired, false, 'sentence' ),
815
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
816
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
817 817
 			),
818 818
 			'inactive_status'  => array(
819
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
820
-				'desc'  => EEH_Template::pretty_status( EE_Datetime::inactive, false, 'sentence' ),
819
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
820
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
821 821
 			),
822 822
 		);
823
-		$statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses );
824
-		return array_merge( $items, $statuses );
823
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
824
+		return array_merge($items, $statuses);
825 825
 	}
826 826
 
827 827
 
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 	 * @return EEM_Event
833 833
 	 */
834 834
 	private function _event_model() {
835
-		if ( ! $this->_event_model instanceof EEM_Event ) {
836
-			$this->_event_model = EE_Registry::instance()->load_model( 'Event' );
835
+		if ( ! $this->_event_model instanceof EEM_Event) {
836
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
837 837
 		}
838 838
 		return $this->_event_model;
839 839
 	}
@@ -850,12 +850,12 @@  discard block
 block discarded – undo
850 850
 	 * @param  string $new_slug  what the slug is
851 851
 	 * @return string            The new html string for the permalink area
852 852
 	 */
853
-	public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) {
853
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) {
854 854
 		//make sure this is only when editing
855
-		if ( ! empty( $id ) ) {
856
-			$post = get_post( $id );
855
+		if ( ! empty($id)) {
856
+			$post = get_post($id);
857 857
 			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
858
-			           . esc_html__( 'Shortcode', 'event_espresso' )
858
+			           . esc_html__('Shortcode', 'event_espresso')
859 859
 			           . '</a> ';
860 860
 			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
861 861
 			           . $post->ID
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
 	 * @return void
875 875
 	 */
876 876
 	protected function _events_overview_list_table() {
877
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
877
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
878 878
 		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
879
-			get_post_type_archive_link( 'espresso_events' ),
880
-			esc_html__( "View Event Archive Page", "event_espresso" ),
879
+			get_post_type_archive_link('espresso_events'),
880
+			esc_html__("View Event Archive Page", "event_espresso"),
881 881
 			'button'
882 882
 		);
883
-		$this->_template_args['after_list_table'] .= $this->_display_legend( $this->_event_legend_items() );
884
-		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
883
+		$this->_template_args['after_list_table'] .= $this->_display_legend($this->_event_legend_items());
884
+		$this->_admin_page_title .= ' '.$this->get_action_link_or_button(
885 885
 				'create_new',
886 886
 				'add',
887 887
 				array(),
@@ -907,48 +907,48 @@  discard block
 block discarded – undo
907 907
 	 * @param string $post_id
908 908
 	 * @param object $post
909 909
 	 */
910
-	protected function _insert_update_cpt_item( $post_id, $post ) {
911
-		if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) {
910
+	protected function _insert_update_cpt_item($post_id, $post) {
911
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
912 912
 			//get out we're not processing an event save.
913 913
 			return;
914 914
 		}
915 915
 		$event_values = array(
916
-			'EVT_display_desc'                => ! empty( $this->_req_data['display_desc'] ) ? 1 : 0,
917
-			'EVT_display_ticket_selector'     => ! empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0,
916
+			'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
917
+			'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
918 918
 			'EVT_additional_limit'            => min(
919
-				apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ),
920
-				! empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : null
919
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
920
+				! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
921 921
 			),
922
-			'EVT_default_registration_status' => ! empty( $this->_req_data['EVT_default_registration_status'] )
922
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
923 923
 				? $this->_req_data['EVT_default_registration_status']
924 924
 				: EE_Registry::instance()->CFG->registration->default_STS_ID,
925
-			'EVT_member_only'                 => ! empty( $this->_req_data['member_only'] ) ? 1 : 0,
926
-			'EVT_allow_overflow'              => ! empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0,
927
-			'EVT_timezone_string'             => ! empty( $this->_req_data['timezone_string'] )
925
+			'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
926
+			'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
927
+			'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
928 928
 				? $this->_req_data['timezone_string'] : null,
929
-			'EVT_external_URL'                => ! empty( $this->_req_data['externalURL'] )
929
+			'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
930 930
 				? $this->_req_data['externalURL'] : null,
931
-			'EVT_phone'                       => ! empty( $this->_req_data['event_phone'] )
931
+			'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
932 932
 				? $this->_req_data['event_phone'] : null,
933 933
 		);
934 934
 		//update event
935
-		$success = $this->_event_model()->update_by_ID( $event_values, $post_id );
935
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
936 936
 		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
937
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status );
938
-		$event = $this->_event_model()->get_one( array( $get_one_where ) );
937
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
938
+		$event = $this->_event_model()->get_one(array($get_one_where));
939 939
 		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
940 940
 		$event_update_callbacks = apply_filters(
941 941
 			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
942
-			array( array( $this, '_default_venue_update' ), array( $this, '_default_tickets_update' ) )
942
+			array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))
943 943
 		);
944 944
 		$att_success = true;
945
-		foreach ( $event_update_callbacks as $e_callback ) {
946
-			$_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) );
945
+		foreach ($event_update_callbacks as $e_callback) {
946
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
947 947
 			$att_success = ! $att_success ? $att_success
948 948
 				: $_succ; //if ANY of these updates fail then we want the appropriate global error message
949 949
 		}
950 950
 		//any errors?
951
-		if ( $success && false === $att_success ) {
951
+		if ($success && false === $att_success) {
952 952
 			EE_Error::add_error(
953 953
 				esc_html__(
954 954
 					'Event Details saved successfully but something went wrong with saving attachments.',
@@ -958,9 +958,9 @@  discard block
 block discarded – undo
958 958
 				__FUNCTION__,
959 959
 				__LINE__
960 960
 			);
961
-		} else if ( $success === false ) {
961
+		} else if ($success === false) {
962 962
 			EE_Error::add_error(
963
-				esc_html__( 'Event Details did not save successfully.', 'event_espresso' ),
963
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
964 964
 				__FILE__,
965 965
 				__FUNCTION__,
966 966
 				__LINE__
@@ -975,14 +975,14 @@  discard block
 block discarded – undo
975 975
 	 * @param int $post_id
976 976
 	 * @param int $revision_id
977 977
 	 */
978
-	protected function _restore_cpt_item( $post_id, $revision_id ) {
978
+	protected function _restore_cpt_item($post_id, $revision_id) {
979 979
 		//copy existing event meta to new post
980
-		$post_evt = $this->_event_model()->get_one_by_ID( $post_id );
981
-		if ( $post_evt instanceof EE_Event ) {
980
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
981
+		if ($post_evt instanceof EE_Event) {
982 982
 			//meta revision restore
983
-			$post_evt->restore_revision( $revision_id );
983
+			$post_evt->restore_revision($revision_id);
984 984
 			//related objs restore
985
-			$post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) );
985
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
986 986
 		}
987 987
 	}
988 988
 
@@ -995,49 +995,49 @@  discard block
 block discarded – undo
995 995
 	 * @param  array     $data   The request data from the form
996 996
 	 * @return bool           Success or fail.
997 997
 	 */
998
-	protected function _default_venue_update( \EE_Event $evtobj, $data ) {
999
-		require_once( EE_MODELS . 'EEM_Venue.model.php' );
1000
-		$venue_model = EE_Registry::instance()->load_model( 'Venue' );
998
+	protected function _default_venue_update(\EE_Event $evtobj, $data) {
999
+		require_once(EE_MODELS.'EEM_Venue.model.php');
1000
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1001 1001
 		$rows_affected = null;
1002
-		$venue_id = ! empty( $data['venue_id'] ) ? $data['venue_id'] : null;
1002
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1003 1003
 		// very important.  If we don't have a venue name...
1004 1004
 		// then we'll get out because not necessary to create empty venue
1005
-		if ( empty( $data['venue_title'] ) ) {
1005
+		if (empty($data['venue_title'])) {
1006 1006
 			return false;
1007 1007
 		}
1008 1008
 		$venue_array = array(
1009
-			'VNU_wp_user'         => $evtobj->get( 'EVT_wp_user' ),
1010
-			'VNU_name'            => ! empty( $data['venue_title'] ) ? $data['venue_title'] : null,
1011
-			'VNU_desc'            => ! empty( $data['venue_description'] ) ? $data['venue_description'] : null,
1012
-			'VNU_identifier'      => ! empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : null,
1013
-			'VNU_short_desc'      => ! empty( $data['venue_short_description'] ) ? $data['venue_short_description']
1009
+			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1010
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1011
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1012
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1013
+			'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1014 1014
 				: null,
1015
-			'VNU_address'         => ! empty( $data['address'] ) ? $data['address'] : null,
1016
-			'VNU_address2'        => ! empty( $data['address2'] ) ? $data['address2'] : null,
1017
-			'VNU_city'            => ! empty( $data['city'] ) ? $data['city'] : null,
1018
-			'STA_ID'              => ! empty( $data['state'] ) ? $data['state'] : null,
1019
-			'CNT_ISO'             => ! empty( $data['countries'] ) ? $data['countries'] : null,
1020
-			'VNU_zip'             => ! empty( $data['zip'] ) ? $data['zip'] : null,
1021
-			'VNU_phone'           => ! empty( $data['venue_phone'] ) ? $data['venue_phone'] : null,
1022
-			'VNU_capacity'        => ! empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : null,
1023
-			'VNU_url'             => ! empty( $data['venue_url'] ) ? $data['venue_url'] : null,
1024
-			'VNU_virtual_phone'   => ! empty( $data['virtual_phone'] ) ? $data['virtual_phone'] : null,
1025
-			'VNU_virtual_url'     => ! empty( $data['virtual_url'] ) ? $data['virtual_url'] : null,
1026
-			'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0,
1015
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1016
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1017
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1018
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1019
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1020
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1021
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1022
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1023
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1024
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1025
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1026
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1027 1027
 			'status'              => 'publish',
1028 1028
 		);
1029 1029
 		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1030
-		if ( ! empty( $venue_id ) ) {
1031
-			$update_where = array( $venue_model->primary_key_name() => $venue_id );
1032
-			$rows_affected = $venue_model->update( $venue_array, array( $update_where ) );
1030
+		if ( ! empty($venue_id)) {
1031
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
1032
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
1033 1033
 			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1034
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
1034
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1035 1035
 			return $rows_affected > 0 ? true : false;
1036 1036
 		} else {
1037 1037
 			//we insert the venue
1038
-			$venue_id = $venue_model->insert( $venue_array );
1039
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
1040
-			return ! empty( $venue_id ) ? true : false;
1038
+			$venue_id = $venue_model->insert($venue_array);
1039
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1040
+			return ! empty($venue_id) ? true : false;
1041 1041
 		}
1042 1042
 		//when we have the ancestor come in it's already been handled by the revision save.
1043 1043
 	}
@@ -1051,51 +1051,51 @@  discard block
 block discarded – undo
1051 1051
 	 * @param  array    $data   The request data from the form
1052 1052
 	 * @return array
1053 1053
 	 */
1054
-	protected function _default_tickets_update( EE_Event $evtobj, $data ) {
1054
+	protected function _default_tickets_update(EE_Event $evtobj, $data) {
1055 1055
 		$success = true;
1056 1056
 		$saved_dtt = null;
1057 1057
 		$saved_tickets = array();
1058
-		$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
1059
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
1058
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
1059
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1060 1060
 			//trim all values to ensure any excess whitespace is removed.
1061
-			$dtt = array_map( 'trim', $dtt );
1062
-			$dtt['DTT_EVT_end'] = isset( $dtt['DTT_EVT_end'] ) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end']
1061
+			$dtt = array_map('trim', $dtt);
1062
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1063 1063
 				: $dtt['DTT_EVT_start'];
1064 1064
 			$datetime_values = array(
1065
-				'DTT_ID'        => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : null,
1065
+				'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1066 1066
 				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1067 1067
 				'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1068
-				'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'],
1068
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1069 1069
 				'DTT_order'     => $row,
1070 1070
 			);
1071 1071
 			//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.
1072
-			if ( ! empty( $dtt['DTT_ID'] ) ) {
1072
+			if ( ! empty($dtt['DTT_ID'])) {
1073 1073
 				$DTM = EE_Registry::instance()
1074
-				                  ->load_model( 'Datetime', array( $evtobj->get_timezone() ) )
1075
-				                  ->get_one_by_ID( $dtt['DTT_ID'] );
1076
-				$DTM->set_date_format( $incoming_date_formats[0] );
1077
-				$DTM->set_time_format( $incoming_date_formats[1] );
1078
-				foreach ( $datetime_values as $field => $value ) {
1079
-					$DTM->set( $field, $value );
1074
+				                  ->load_model('Datetime', array($evtobj->get_timezone()))
1075
+				                  ->get_one_by_ID($dtt['DTT_ID']);
1076
+				$DTM->set_date_format($incoming_date_formats[0]);
1077
+				$DTM->set_time_format($incoming_date_formats[1]);
1078
+				foreach ($datetime_values as $field => $value) {
1079
+					$DTM->set($field, $value);
1080 1080
 				}
1081 1081
 				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1082
-				$saved_dtts[ $DTM->ID() ] = $DTM;
1082
+				$saved_dtts[$DTM->ID()] = $DTM;
1083 1083
 			} else {
1084
-				$DTM = EE_Registry::instance()->load_class( 'Datetime', array( $datetime_values ), false, false );
1085
-				$DTM->set_date_format( $incoming_date_formats[0] );
1086
-				$DTM->set_time_format( $incoming_date_formats[1] );
1087
-				$DTM->set_timezone( $evtobj->get_timezone() );
1088
-				foreach ( $datetime_values as $field => $value ) {
1089
-					$DTM->set( $field, $value );
1084
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), false, false);
1085
+				$DTM->set_date_format($incoming_date_formats[0]);
1086
+				$DTM->set_time_format($incoming_date_formats[1]);
1087
+				$DTM->set_timezone($evtobj->get_timezone());
1088
+				foreach ($datetime_values as $field => $value) {
1089
+					$DTM->set($field, $value);
1090 1090
 				}
1091 1091
 			}
1092 1092
 			$DTM->save();
1093
-			$DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' );
1093
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1094 1094
 			//load DTT helper
1095 1095
 			//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.
1096
-			if ( $DTT->get_raw( 'DTT_EVT_start' ) > $DTT->get_raw( 'DTT_EVT_end' ) ) {
1097
-				$DTT->set( 'DTT_EVT_end', $DTT->get( 'DTT_EVT_start' ) );
1098
-				$DTT = EEH_DTT_Helper::date_time_add( $DTT, 'DTT_EVT_end', 'days' );
1096
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1097
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1098
+				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1099 1099
 				$DTT->save();
1100 1100
 			}
1101 1101
 			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
@@ -1106,20 +1106,20 @@  discard block
 block discarded – undo
1106 1106
 		}
1107 1107
 		//no dtts get deleted so we don't do any of that logic here.
1108 1108
 		//update tickets next
1109
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode( ',', $data['ticket_IDs'] ) : array();
1110
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
1111
-			$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
1109
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1110
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1111
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1112 1112
 			$update_prices = false;
1113
-			$ticket_price = isset( $data['edit_prices'][ $row ][1]['PRC_amount'] )
1114
-				? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1113
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1114
+				? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1115 1115
 			// trim inputs to ensure any excess whitespace is removed.
1116
-			$tkt = array_map( 'trim', $tkt );
1117
-			if ( empty( $tkt['TKT_start_date'] ) ) {
1116
+			$tkt = array_map('trim', $tkt);
1117
+			if (empty($tkt['TKT_start_date'])) {
1118 1118
 				//let's use now in the set timezone.
1119
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
1120
-				$tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] );
1119
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1120
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1121 1121
 			}
1122
-			if ( empty( $tkt['TKT_end_date'] ) ) {
1122
+			if (empty($tkt['TKT_end_date'])) {
1123 1123
 				//use the start date of the first datetime
1124 1124
 				$dtt = $evtobj->first_datetime();
1125 1125
 				$tkt['TKT_end_date'] = $dtt->start_date_and_time(
@@ -1128,22 +1128,22 @@  discard block
 block discarded – undo
1128 1128
 				);
1129 1129
 			}
1130 1130
 			$TKT_values = array(
1131
-				'TKT_ID'          => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : null,
1132
-				'TTM_ID'          => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
1133
-				'TKT_name'        => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
1134
-				'TKT_description' => ! empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '',
1131
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1132
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1133
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1134
+				'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1135 1135
 				'TKT_start_date'  => $tkt['TKT_start_date'],
1136 1136
 				'TKT_end_date'    => $tkt['TKT_end_date'],
1137
-				'TKT_qty'         => ! isset( $tkt['TKT_qty'] ) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1138
-				'TKT_uses'        => ! isset( $tkt['TKT_uses'] ) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1139
-				'TKT_min'         => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
1140
-				'TKT_max'         => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
1137
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1138
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1139
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1140
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1141 1141
 				'TKT_row'         => $row,
1142
-				'TKT_order'       => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row,
1142
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1143 1143
 				'TKT_price'       => $ticket_price,
1144 1144
 			);
1145 1145
 			//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.
1146
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
1146
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1147 1147
 				$TKT_values['TKT_ID'] = 0;
1148 1148
 				$TKT_values['TKT_is_default'] = 0;
1149 1149
 				$TKT_values['TKT_price'] = $ticket_price;
@@ -1152,110 +1152,110 @@  discard block
 block discarded – undo
1152 1152
 			//if we have a TKT_ID then we need to get that existing TKT_obj and update it
1153 1153
 			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1154 1154
 			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1155
-			if ( ! empty( $tkt['TKT_ID'] ) ) {
1155
+			if ( ! empty($tkt['TKT_ID'])) {
1156 1156
 				$TKT = EE_Registry::instance()
1157
-						->load_model( 'Ticket', array( $evtobj->get_timezone() ) )
1158
-						->get_one_by_ID( $tkt['TKT_ID'] );
1159
-				if ( $TKT instanceof EE_Ticket ) {
1157
+						->load_model('Ticket', array($evtobj->get_timezone()))
1158
+						->get_one_by_ID($tkt['TKT_ID']);
1159
+				if ($TKT instanceof EE_Ticket) {
1160 1160
 					$ticket_sold = $TKT->count_related(
1161 1161
 						'Registration',
1162 1162
 						array(
1163 1163
 							array(
1164 1164
 								'STS_ID' => array(
1165 1165
 									'NOT IN',
1166
-									array( EEM_Registration::status_id_incomplete ),
1166
+									array(EEM_Registration::status_id_incomplete),
1167 1167
 								),
1168 1168
 							),
1169 1169
 						)
1170 1170
 					) > 0 ? true : false;
1171 1171
 					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1172
-					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' )
1172
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1173 1173
 					                  && ! $TKT->get(
1174 1174
 						'TKT_deleted'
1175 1175
 					) ? true : false;
1176
-					$TKT->set_date_format( $incoming_date_formats[0] );
1177
-					$TKT->set_time_format( $incoming_date_formats[1] );
1176
+					$TKT->set_date_format($incoming_date_formats[0]);
1177
+					$TKT->set_time_format($incoming_date_formats[1]);
1178 1178
 					//set new values
1179
-					foreach ( $TKT_values as $field => $value ) {
1180
-						if ( $field == 'TKT_qty' ) {
1181
-							$TKT->set_qty( $value );
1179
+					foreach ($TKT_values as $field => $value) {
1180
+						if ($field == 'TKT_qty') {
1181
+							$TKT->set_qty($value);
1182 1182
 						} else {
1183
-							$TKT->set( $field, $value );
1183
+							$TKT->set($field, $value);
1184 1184
 						}
1185 1185
 					}
1186 1186
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1187
-					if ( $create_new_TKT ) {
1187
+					if ($create_new_TKT) {
1188 1188
 						//archive the old ticket first
1189
-						$TKT->set( 'TKT_deleted', 1 );
1189
+						$TKT->set('TKT_deleted', 1);
1190 1190
 						$TKT->save();
1191 1191
 						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1192
-						$saved_tickets[ $TKT->ID() ] = $TKT;
1192
+						$saved_tickets[$TKT->ID()] = $TKT;
1193 1193
 						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1194 1194
 						$TKT = clone $TKT;
1195
-						$TKT->set( 'TKT_ID', 0 );
1196
-						$TKT->set( 'TKT_deleted', 0 );
1197
-						$TKT->set( 'TKT_price', $ticket_price );
1198
-						$TKT->set( 'TKT_sold', 0 );
1195
+						$TKT->set('TKT_ID', 0);
1196
+						$TKT->set('TKT_deleted', 0);
1197
+						$TKT->set('TKT_price', $ticket_price);
1198
+						$TKT->set('TKT_sold', 0);
1199 1199
 						//now we need to make sure that $new prices are created as well and attached to new ticket.
1200 1200
 						$update_prices = true;
1201 1201
 					}
1202 1202
 					//make sure price is set if it hasn't been already
1203
-					$TKT->set( 'TKT_price', $ticket_price );
1203
+					$TKT->set('TKT_price', $ticket_price);
1204 1204
 				}
1205 1205
 			} else {
1206 1206
 				//no TKT_id so a new TKT
1207 1207
 				$TKT_values['TKT_price'] = $ticket_price;
1208
-				$TKT = EE_Registry::instance()->load_class( 'Ticket', array( $TKT_values ), false, false );
1209
-				if ( $TKT instanceof EE_Ticket ) {
1208
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1209
+				if ($TKT instanceof EE_Ticket) {
1210 1210
 					//need to reset values to properly account for the date formats
1211
-					$TKT->set_date_format( $incoming_date_formats[0] );
1212
-					$TKT->set_time_format( $incoming_date_formats[1] );
1213
-					$TKT->set_timezone( $evtobj->get_timezone() );
1211
+					$TKT->set_date_format($incoming_date_formats[0]);
1212
+					$TKT->set_time_format($incoming_date_formats[1]);
1213
+					$TKT->set_timezone($evtobj->get_timezone());
1214 1214
 					//set new values
1215
-					foreach ( $TKT_values as $field => $value ) {
1216
-						if ( $field == 'TKT_qty' ) {
1217
-							$TKT->set_qty( $value );
1215
+					foreach ($TKT_values as $field => $value) {
1216
+						if ($field == 'TKT_qty') {
1217
+							$TKT->set_qty($value);
1218 1218
 						} else {
1219
-							$TKT->set( $field, $value );
1219
+							$TKT->set($field, $value);
1220 1220
 						}
1221 1221
 					}
1222 1222
 					$update_prices = true;
1223 1223
 				}
1224 1224
 			}
1225 1225
 			// cap ticket qty by datetime reg limits
1226
-			$TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) );
1226
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1227 1227
 			//update ticket.
1228 1228
 			$TKT->save();
1229 1229
 			//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.
1230
-			if ( $TKT->get_raw( 'TKT_start_date' ) > $TKT->get_raw( 'TKT_end_date' ) ) {
1231
-				$TKT->set( 'TKT_end_date', $TKT->get( 'TKT_start_date' ) );
1232
-				$TKT = EEH_DTT_Helper::date_time_add( $TKT, 'TKT_end_date', 'days' );
1230
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1231
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1232
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1233 1233
 				$TKT->save();
1234 1234
 			}
1235 1235
 			//initially let's add the ticket to the dtt
1236
-			$saved_dtt->_add_relation_to( $TKT, 'Ticket' );
1237
-			$saved_tickets[ $TKT->ID() ] = $TKT;
1236
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1237
+			$saved_tickets[$TKT->ID()] = $TKT;
1238 1238
 			//add prices to ticket
1239
-			$this->_add_prices_to_ticket( $data['edit_prices'][ $row ], $TKT, $update_prices );
1239
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1240 1240
 		}
1241 1241
 		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1242
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
1243
-		$tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) );
1244
-		foreach ( $tickets_removed as $id ) {
1245
-			$id = absint( $id );
1242
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1243
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1244
+		foreach ($tickets_removed as $id) {
1245
+			$id = absint($id);
1246 1246
 			//get the ticket for this id
1247
-			$tkt_to_remove = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $id );
1247
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1248 1248
 			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1249
-			$dtts = $tkt_to_remove->get_many_related( 'Datetime' );
1250
-			foreach ( $dtts as $dtt ) {
1251
-				$tkt_to_remove->_remove_relation_to( $dtt, 'Datetime' );
1249
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
1250
+			foreach ($dtts as $dtt) {
1251
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1252 1252
 			}
1253 1253
 			//need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1254
-			$tkt_to_remove->delete_related_permanently( 'Price' );
1254
+			$tkt_to_remove->delete_related_permanently('Price');
1255 1255
 			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1256 1256
 			$tkt_to_remove->delete_permanently();
1257 1257
 		}
1258
-		return array( $saved_dtt, $saved_tickets );
1258
+		return array($saved_dtt, $saved_tickets);
1259 1259
 	}
1260 1260
 
1261 1261
 
@@ -1272,29 +1272,29 @@  discard block
 block discarded – undo
1272 1272
 	 * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1273 1273
 	 * @return  void
1274 1274
 	 */
1275
-	private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = false ) {
1276
-		foreach ( $prices as $row => $prc ) {
1275
+	private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) {
1276
+		foreach ($prices as $row => $prc) {
1277 1277
 			$PRC_values = array(
1278
-				'PRC_ID'         => ! empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : null,
1279
-				'PRT_ID'         => ! empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : null,
1280
-				'PRC_amount'     => ! empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
1281
-				'PRC_name'       => ! empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
1282
-				'PRC_desc'       => ! empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
1278
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1279
+				'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1280
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1281
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1282
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1283 1283
 				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1284 1284
 				'PRC_order'      => $row,
1285 1285
 			);
1286
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
1286
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1287 1287
 				$PRC_values['PRC_ID'] = 0;
1288
-				$PRC = EE_Registry::instance()->load_class( 'Price', array( $PRC_values ), false, false );
1288
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1289 1289
 			} else {
1290
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
1290
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1291 1291
 				//update this price with new values
1292
-				foreach ( $PRC_values as $field => $newprc ) {
1293
-					$PRC->set( $field, $newprc );
1292
+				foreach ($PRC_values as $field => $newprc) {
1293
+					$PRC->set($field, $newprc);
1294 1294
 				}
1295 1295
 				$PRC->save();
1296 1296
 			}
1297
-			$ticket->_add_relation_to( $PRC, 'Price' );
1297
+			$ticket->_add_relation_to($PRC, 'Price');
1298 1298
 		}
1299 1299
 	}
1300 1300
 
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 	private function _generate_publish_box_extra_content() {
1327 1327
 		//load formatter helper
1328 1328
 		//args for getting related registrations
1329
-		$approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) );
1329
+		$approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved));
1330 1330
 		$not_approved_query_args = array(
1331 1331
 			array(
1332 1332
 				'REG_deleted' => 0,
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1398 1398
 		// load template
1399 1399
 		EEH_Template::display_template(
1400
-			EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1400
+			EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php',
1401 1401
 			$publish_box_extra_args
1402 1402
 		);
1403 1403
 	}
@@ -1431,16 +1431,16 @@  discard block
 block discarded – undo
1431 1431
 		$this->verify_cpt_object();
1432 1432
 		add_meta_box(
1433 1433
 			'espresso_event_editor_tickets',
1434
-			esc_html__( 'Event Datetime & Ticket', 'event_espresso' ),
1435
-			array( $this, 'ticket_metabox' ),
1434
+			esc_html__('Event Datetime & Ticket', 'event_espresso'),
1435
+			array($this, 'ticket_metabox'),
1436 1436
 			$this->page_slug,
1437 1437
 			'normal',
1438 1438
 			'high'
1439 1439
 		);
1440 1440
 		add_meta_box(
1441 1441
 			'espresso_event_editor_event_options',
1442
-			esc_html__( 'Event Registration Options', 'event_espresso' ),
1443
-			array( $this, 'registration_options_meta_box' ),
1442
+			esc_html__('Event Registration Options', 'event_espresso'),
1443
+			array($this, 'registration_options_meta_box'),
1444 1444
 			$this->page_slug,
1445 1445
 			'side',
1446 1446
 			'default'
@@ -1468,65 +1468,65 @@  discard block
 block discarded – undo
1468 1468
 			'trash_icon'               => 'ee-lock-icon',
1469 1469
 			'disabled'                 => '',
1470 1470
 		);
1471
-		$event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : null;
1472
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1471
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1472
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1473 1473
 		/**
1474 1474
 		 * 1. Start with retrieving Datetimes
1475 1475
 		 * 2. Fore each datetime get related tickets
1476 1476
 		 * 3. For each ticket get related prices
1477 1477
 		 */
1478
-		$times = EE_Registry::instance()->load_model( 'Datetime' )->get_all_event_dates( $event_id );
1478
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1479 1479
 		/** @type EE_Datetime $first_datetime */
1480
-		$first_datetime = reset( $times );
1480
+		$first_datetime = reset($times);
1481 1481
 		//do we get related tickets?
1482
-		if ( $first_datetime instanceof EE_Datetime
1482
+		if ($first_datetime instanceof EE_Datetime
1483 1483
 		     && $first_datetime->ID() !== 0
1484 1484
 		) {
1485
-			$existing_datetime_ids[] = $first_datetime->get( 'DTT_ID' );
1485
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1486 1486
 			$template_args['time'] = $first_datetime;
1487 1487
 			$related_tickets = $first_datetime->tickets(
1488 1488
 				array(
1489
-					array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ),
1489
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1490 1490
 					'default_where_conditions' => 'none',
1491 1491
 				)
1492 1492
 			);
1493
-			if ( ! empty( $related_tickets ) ) {
1494
-				$template_args['total_ticket_rows'] = count( $related_tickets );
1493
+			if ( ! empty($related_tickets)) {
1494
+				$template_args['total_ticket_rows'] = count($related_tickets);
1495 1495
 				$row = 0;
1496
-				foreach ( $related_tickets as $ticket ) {
1497
-					$existing_ticket_ids[] = $ticket->get( 'TKT_ID' );
1498
-					$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket, false, $row );
1496
+				foreach ($related_tickets as $ticket) {
1497
+					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1498
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1499 1499
 					$row++;
1500 1500
 				}
1501 1501
 			} else {
1502 1502
 				$template_args['total_ticket_rows'] = 1;
1503 1503
 				/** @type EE_Ticket $ticket */
1504
-				$ticket = EE_Registry::instance()->load_model( 'Ticket' )->create_default_object();
1505
-				$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket );
1504
+				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1505
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1506 1506
 			}
1507 1507
 		} else {
1508 1508
 			$template_args['time'] = $times[0];
1509 1509
 			/** @type EE_Ticket $ticket */
1510
-			$ticket = EE_Registry::instance()->load_model( 'Ticket' )->get_all_default_tickets();
1511
-			$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] );
1510
+			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1511
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1512 1512
 			// NOTE: we're just sending the first default row
1513 1513
 			// (decaf can't manage default tickets so this should be sufficient);
1514 1514
 		}
1515 1515
 		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1516 1516
 			'event_editor_event_datetimes_help_tab'
1517 1517
 		);
1518
-		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link( 'ticket_options_info' );
1519
-		$template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids );
1520
-		$template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids );
1518
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1519
+		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1520
+		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1521 1521
 		$template_args['ticket_js_structure'] = $this->_get_ticket_row(
1522
-			EE_Registry::instance()->load_model( 'Ticket' )->create_default_object(),
1522
+			EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1523 1523
 			true
1524 1524
 		);
1525 1525
 		$template = apply_filters(
1526 1526
 			'FHEE__Events_Admin_Page__ticket_metabox__template',
1527
-			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1527
+			EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'
1528 1528
 		);
1529
-		EEH_Template::display_template( $template, $template_args );
1529
+		EEH_Template::display_template($template, $template_args);
1530 1530
 	}
1531 1531
 
1532 1532
 
@@ -1540,74 +1540,74 @@  discard block
 block discarded – undo
1540 1540
 	 * @param int        $row
1541 1541
 	 * @return string generated html for the ticket row.
1542 1542
 	 */
1543
-	private function _get_ticket_row( $ticket, $skeleton = false, $row = 0 ) {
1543
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0) {
1544 1544
 		$template_args = array(
1545
-			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1545
+			'tkt_status_class'    => ' tkt-status-'.$ticket->ticket_status(),
1546 1546
 			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1547 1547
 				: '',
1548 1548
 			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1549
-			'TKT_ID'              => $ticket->get( 'TKT_ID' ),
1550
-			'TKT_name'            => $ticket->get( 'TKT_name' ),
1551
-			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date( 'TKT_start_date', 'Y-m-d h:i a' ),
1552
-			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date( 'TKT_end_date', 'Y-m-d h:i a' ),
1553
-			'TKT_is_default'      => $ticket->get( 'TKT_is_default' ),
1554
-			'TKT_qty'             => $ticket->get_pretty( 'TKT_qty', 'input' ),
1549
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1550
+			'TKT_name'            => $ticket->get('TKT_name'),
1551
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1552
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1553
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1554
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1555 1555
 			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1556
-			'TKT_sold'            => $skeleton ? 0 : $ticket->get( 'TKT_sold' ),
1557
-			'trash_icon'          => ( $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) )
1558
-			                         && ( ! empty( $ticket ) && $ticket->get( 'TKT_sold' ) === 0 )
1556
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1557
+			'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1558
+			                         && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1559 1559
 				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1560
-			'disabled'            => $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ? ''
1560
+			'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1561 1561
 				: ' disabled=disabled',
1562 1562
 		);
1563 1563
 		$price = $ticket->ID() !== 0
1564
-			? $ticket->get_first_related( 'Price', array( 'default_where_conditions' => 'none' ) )
1565
-			: EE_Registry::instance()->load_model( 'Price' )->create_default_object();
1564
+			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1565
+			: EE_Registry::instance()->load_model('Price')->create_default_object();
1566 1566
 		$price_args = array(
1567 1567
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1568
-			'PRC_amount'            => $price->get( 'PRC_amount' ),
1569
-			'PRT_ID'                => $price->get( 'PRT_ID' ),
1570
-			'PRC_ID'                => $price->get( 'PRC_ID' ),
1571
-			'PRC_is_default'        => $price->get( 'PRC_is_default' ),
1568
+			'PRC_amount'            => $price->get('PRC_amount'),
1569
+			'PRT_ID'                => $price->get('PRT_ID'),
1570
+			'PRC_ID'                => $price->get('PRC_ID'),
1571
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1572 1572
 		);
1573 1573
 		//make sure we have default start and end dates if skeleton
1574 1574
 		//handle rows that should NOT be empty
1575
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1575
+		if (empty($template_args['TKT_start_date'])) {
1576 1576
 			//if empty then the start date will be now.
1577
-			$template_args['TKT_start_date'] = date( 'Y-m-d h:i a', current_time( 'timestamp' ) );
1577
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1578 1578
 		}
1579
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1579
+		if (empty($template_args['TKT_end_date'])) {
1580 1580
 			//get the earliest datetime (if present);
1581 1581
 			$earliest_dtt = $this->_cpt_model_obj->ID() > 0
1582 1582
 				? $this->_cpt_model_obj->get_first_related(
1583 1583
 					'Datetime',
1584
-					array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) )
1584
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1585 1585
 				)
1586 1586
 				: null;
1587
-			if ( ! empty( $earliest_dtt ) ) {
1588
-				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime( 'DTT_EVT_start', 'Y-m-d', 'h:i a' );
1587
+			if ( ! empty($earliest_dtt)) {
1588
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1589 1589
 			} else {
1590 1590
 				$template_args['TKT_end_date'] = date(
1591 1591
 					'Y-m-d h:i a',
1592
-					mktime( 0, 0, 0, date( "m" ), date( "d" ) + 7, date( "Y" ) )
1592
+					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1593 1593
 				);
1594 1594
 			}
1595 1595
 		}
1596
-		$template_args = array_merge( $template_args, $price_args );
1596
+		$template_args = array_merge($template_args, $price_args);
1597 1597
 		$template = apply_filters(
1598 1598
 			'FHEE__Events_Admin_Page__get_ticket_row__template',
1599
-			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1599
+			EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php',
1600 1600
 			$ticket
1601 1601
 		);
1602
-		return EEH_Template::display_template( $template, $template_args, true );
1602
+		return EEH_Template::display_template($template, $template_args, true);
1603 1603
 	}
1604 1604
 
1605 1605
 
1606 1606
 
1607 1607
 	public function registration_options_meta_box() {
1608 1608
 		$yes_no_values = array(
1609
-			array( 'id' => true, 'text' => esc_html__( 'Yes', 'event_espresso' ) ),
1610
-			array( 'id' => false, 'text' => esc_html__( 'No', 'event_espresso' ) ),
1609
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1610
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1611 1611
 		);
1612 1612
 		$default_reg_status_values = EEM_Registration::reg_status_array(
1613 1613
 			array(
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 		);
1620 1620
 		//$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1621 1621
 		$template_args['_event'] = $this->_cpt_model_obj;
1622
-		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status( false );
1622
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1623 1623
 		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1624 1624
 		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1625 1625
 			'default_reg_status',
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 			$default_reg_status_values
1648 1648
 		);
1649 1649
 		EEH_Template::display_template(
1650
-			EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1650
+			EVENTS_TEMPLATE_PATH.'event_registration_options.template.php',
1651 1651
 			$template_args
1652 1652
 		);
1653 1653
 	}
@@ -1666,97 +1666,97 @@  discard block
 block discarded – undo
1666 1666
 	 *                           that match the given _view and paging parameters.
1667 1667
 	 * @return array an array of event objects.
1668 1668
 	 */
1669
-	public function get_events( $per_page = 10, $current_page = 1, $count = false ) {
1669
+	public function get_events($per_page = 10, $current_page = 1, $count = false) {
1670 1670
 		$EEME = $this->_event_model();
1671
-		$offset = ( $current_page - 1 ) * $per_page;
1672
-		$limit = $count ? null : $offset . ',' . $per_page;
1673
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'EVT_ID';
1674
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : "DESC";
1675
-		if ( isset( $this->_req_data['month_range'] ) ) {
1676
-			$pieces = explode( ' ', $this->_req_data['month_range'], 3 );
1677
-			$month_r = ! empty( $pieces[0] ) ? date( 'm', strtotime( $pieces[0] ) ) : '';
1678
-			$year_r = ! empty( $pieces[1] ) ? $pieces[1] : '';
1671
+		$offset = ($current_page - 1) * $per_page;
1672
+		$limit = $count ? null : $offset.','.$per_page;
1673
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1674
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1675
+		if (isset($this->_req_data['month_range'])) {
1676
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1677
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1678
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1679 1679
 		}
1680 1680
 		$where = array();
1681
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : null;
1681
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1682 1682
 		//determine what post_status our condition will have for the query.
1683
-		switch ( $status ) {
1683
+		switch ($status) {
1684 1684
 			case 'month' :
1685 1685
 			case 'today' :
1686 1686
 			case null :
1687 1687
 			case 'all' :
1688 1688
 				break;
1689 1689
 			case 'draft' :
1690
-				$where['status'] = array( 'IN', array( 'draft', 'auto-draft' ) );
1690
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1691 1691
 				break;
1692 1692
 			default :
1693 1693
 				$where['status'] = $status;
1694 1694
 		}
1695 1695
 		//categories?
1696
-		$category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0
1696
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1697 1697
 			? $this->_req_data['EVT_CAT'] : null;
1698
-		if ( ! empty ( $category ) ) {
1698
+		if ( ! empty ($category)) {
1699 1699
 			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1700 1700
 			$where['Term_Taxonomy.term_id'] = $category;
1701 1701
 		}
1702 1702
 		//date where conditions
1703
-		$start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' );
1704
-		if ( isset( $this->_req_data['month_range'] ) && $this->_req_data['month_range'] != '' ) {
1703
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1704
+		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1705 1705
 			$DateTime = new DateTime(
1706
-				$year_r . '-' . $month_r . '-01 00:00:00',
1707
-				new DateTimeZone( EEM_Datetime::instance()->get_timezone() )
1706
+				$year_r.'-'.$month_r.'-01 00:00:00',
1707
+				new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1708 1708
 			);
1709
-			$start = $DateTime->format( implode( ' ', $start_formats ) );
1710
-			$end = $DateTime->setDate( $year_r, $month_r, $DateTime->format( 't' ) )->setTime( 23, 59, 59 )->format(
1711
-				implode( ' ', $start_formats )
1709
+			$start = $DateTime->format(implode(' ', $start_formats));
1710
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(
1711
+				implode(' ', $start_formats)
1712 1712
 			);
1713
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1714
-		} else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'today' ) {
1715
-			$DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1716
-			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1717
-			$end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1718
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1719
-		} else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'month' ) {
1720
-			$now = date( 'Y-m-01' );
1721
-			$DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1722
-			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1723
-			$end = $DateTime->setDate( date( 'Y' ), date( 'm' ), $DateTime->format( 't' ) )
1724
-			                ->setTime( 23, 59, 59 )
1725
-			                ->format( implode( ' ', $start_formats ) );
1726
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1713
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1714
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1715
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1716
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1717
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1718
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1719
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1720
+			$now = date('Y-m-01');
1721
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1722
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1723
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1724
+			                ->setTime(23, 59, 59)
1725
+			                ->format(implode(' ', $start_formats));
1726
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1727 1727
 		}
1728
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1728
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1729 1729
 			$where['EVT_wp_user'] = get_current_user_id();
1730 1730
 		} else {
1731
-			if ( ! isset( $where['status'] ) ) {
1732
-				if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
1731
+			if ( ! isset($where['status'])) {
1732
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1733 1733
 					$where['OR'] = array(
1734
-						'status*restrict_private' => array( '!=', 'private' ),
1734
+						'status*restrict_private' => array('!=', 'private'),
1735 1735
 						'AND'                     => array(
1736
-							'status*inclusive' => array( '=', 'private' ),
1736
+							'status*inclusive' => array('=', 'private'),
1737 1737
 							'EVT_wp_user'      => get_current_user_id(),
1738 1738
 						),
1739 1739
 					);
1740 1740
 				}
1741 1741
 			}
1742 1742
 		}
1743
-		if ( isset( $this->_req_data['EVT_wp_user'] ) ) {
1744
-			if ( $this->_req_data['EVT_wp_user'] != get_current_user_id()
1745
-			     && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' )
1743
+		if (isset($this->_req_data['EVT_wp_user'])) {
1744
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1745
+			     && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1746 1746
 			) {
1747 1747
 				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1748 1748
 			}
1749 1749
 		}
1750 1750
 		//search query handling
1751
-		if ( isset( $this->_req_data['s'] ) ) {
1752
-			$search_string = '%' . $this->_req_data['s'] . '%';
1751
+		if (isset($this->_req_data['s'])) {
1752
+			$search_string = '%'.$this->_req_data['s'].'%';
1753 1753
 			$where['OR'] = array(
1754
-				'EVT_name'       => array( 'LIKE', $search_string ),
1755
-				'EVT_desc'       => array( 'LIKE', $search_string ),
1756
-				'EVT_short_desc' => array( 'LIKE', $search_string ),
1754
+				'EVT_name'       => array('LIKE', $search_string),
1755
+				'EVT_desc'       => array('LIKE', $search_string),
1756
+				'EVT_short_desc' => array('LIKE', $search_string),
1757 1757
 			);
1758 1758
 		}
1759
-		$where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data );
1759
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1760 1760
 		$query_params = apply_filters(
1761 1761
 			'FHEE__Events_Admin_Page__get_events__query_params',
1762 1762
 			array(
@@ -1769,23 +1769,23 @@  discard block
 block discarded – undo
1769 1769
 			$this->_req_data
1770 1770
 		);
1771 1771
 		//let's first check if we have special requests coming in.
1772
-		if ( isset( $this->_req_data['active_status'] ) ) {
1773
-			switch ( $this->_req_data['active_status'] ) {
1772
+		if (isset($this->_req_data['active_status'])) {
1773
+			switch ($this->_req_data['active_status']) {
1774 1774
 				case 'upcoming' :
1775
-					return $EEME->get_upcoming_events( $query_params, $count );
1775
+					return $EEME->get_upcoming_events($query_params, $count);
1776 1776
 					break;
1777 1777
 				case 'expired' :
1778
-					return $EEME->get_expired_events( $query_params, $count );
1778
+					return $EEME->get_expired_events($query_params, $count);
1779 1779
 					break;
1780 1780
 				case 'active' :
1781
-					return $EEME->get_active_events( $query_params, $count );
1781
+					return $EEME->get_active_events($query_params, $count);
1782 1782
 					break;
1783 1783
 				case 'inactive' :
1784
-					return $EEME->get_inactive_events( $query_params, $count );
1784
+					return $EEME->get_inactive_events($query_params, $count);
1785 1785
 					break;
1786 1786
 			}
1787 1787
 		}
1788
-		$events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params );
1788
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1789 1789
 		return $events;
1790 1790
 	}
1791 1791
 
@@ -1796,9 +1796,9 @@  discard block
 block discarded – undo
1796 1796
 	 *
1797 1797
 	 * @param string $post_id
1798 1798
 	 */
1799
-	public function trash_cpt_item( $post_id ) {
1799
+	public function trash_cpt_item($post_id) {
1800 1800
 		$this->_req_data['EVT_ID'] = $post_id;
1801
-		$this->_trash_or_restore_event( 'trash', false );
1801
+		$this->_trash_or_restore_event('trash', false);
1802 1802
 	}
1803 1803
 
1804 1804
 
@@ -1806,9 +1806,9 @@  discard block
 block discarded – undo
1806 1806
 	/**
1807 1807
 	 * @param string $post_id
1808 1808
 	 */
1809
-	public function restore_cpt_item( $post_id ) {
1809
+	public function restore_cpt_item($post_id) {
1810 1810
 		$this->_req_data['EVT_ID'] = $post_id;
1811
-		$this->_trash_or_restore_event( 'draft', false );
1811
+		$this->_trash_or_restore_event('draft', false);
1812 1812
 	}
1813 1813
 
1814 1814
 
@@ -1816,9 +1816,9 @@  discard block
 block discarded – undo
1816 1816
 	/**
1817 1817
 	 * @param string $post_id
1818 1818
 	 */
1819
-	public function delete_cpt_item( $post_id ) {
1819
+	public function delete_cpt_item($post_id) {
1820 1820
 		$this->_req_data['EVT_ID'] = $post_id;
1821
-		$this->_delete_event( false );
1821
+		$this->_delete_event(false);
1822 1822
 	}
1823 1823
 
1824 1824
 
@@ -1830,23 +1830,23 @@  discard block
 block discarded – undo
1830 1830
 	 * @param  string $event_status
1831 1831
 	 * @param bool    $redirect_after
1832 1832
 	 */
1833
-	protected function _trash_or_restore_event( $event_status = 'trash', $redirect_after = true ) {
1833
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) {
1834 1834
 		//determine the event id and set to array.
1835
-		$EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : false;
1835
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1836 1836
 		// loop thru events
1837
-		if ( $EVT_ID ) {
1837
+		if ($EVT_ID) {
1838 1838
 			// clean status
1839
-			$event_status = sanitize_key( $event_status );
1839
+			$event_status = sanitize_key($event_status);
1840 1840
 			// grab status
1841
-			if ( ! empty( $event_status ) ) {
1842
-				$success = $this->_change_event_status( $EVT_ID, $event_status );
1841
+			if ( ! empty($event_status)) {
1842
+				$success = $this->_change_event_status($EVT_ID, $event_status);
1843 1843
 			} else {
1844 1844
 				$success = false;
1845 1845
 				$msg = esc_html__(
1846 1846
 					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1847 1847
 					'event_espresso'
1848 1848
 				);
1849
-				EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1849
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1850 1850
 			}
1851 1851
 		} else {
1852 1852
 			$success = false;
@@ -1854,11 +1854,11 @@  discard block
 block discarded – undo
1854 1854
 				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1855 1855
 				'event_espresso'
1856 1856
 			);
1857
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1857
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1858 1858
 		}
1859 1859
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1860
-		if ( $redirect_after ) {
1861
-			$this->_redirect_after_action( $success, 'Event', $action, array( 'action' => 'default' ) );
1860
+		if ($redirect_after) {
1861
+			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1862 1862
 		}
1863 1863
 	}
1864 1864
 
@@ -1871,18 +1871,18 @@  discard block
 block discarded – undo
1871 1871
 	 * @param  string $event_status
1872 1872
 	 * @return void
1873 1873
 	 */
1874
-	protected function _trash_or_restore_events( $event_status = 'trash' ) {
1874
+	protected function _trash_or_restore_events($event_status = 'trash') {
1875 1875
 		// clean status
1876
-		$event_status = sanitize_key( $event_status );
1876
+		$event_status = sanitize_key($event_status);
1877 1877
 		// grab status
1878
-		if ( ! empty( $event_status ) ) {
1878
+		if ( ! empty($event_status)) {
1879 1879
 			$success = true;
1880 1880
 			//determine the event id and set to array.
1881
-			$EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array();
1881
+			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1882 1882
 			// loop thru events
1883
-			foreach ( $EVT_IDs as $EVT_ID ) {
1884
-				if ( $EVT_ID = absint( $EVT_ID ) ) {
1885
-					$results = $this->_change_event_status( $EVT_ID, $event_status );
1883
+			foreach ($EVT_IDs as $EVT_ID) {
1884
+				if ($EVT_ID = absint($EVT_ID)) {
1885
+					$results = $this->_change_event_status($EVT_ID, $event_status);
1886 1886
 					$success = $results !== false ? $success : false;
1887 1887
 				} else {
1888 1888
 					$msg = sprintf(
@@ -1892,7 +1892,7 @@  discard block
 block discarded – undo
1892 1892
 						),
1893 1893
 						$EVT_ID
1894 1894
 					);
1895
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1895
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1896 1896
 					$success = false;
1897 1897
 				}
1898 1898
 			}
@@ -1902,12 +1902,12 @@  discard block
 block discarded – undo
1902 1902
 				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1903 1903
 				'event_espresso'
1904 1904
 			);
1905
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1905
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1906 1906
 		}
1907 1907
 		// in order to force a pluralized result message we need to send back a success status greater than 1
1908 1908
 		$success = $success ? 2 : false;
1909 1909
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1910
-		$this->_redirect_after_action( $success, 'Events', $action, array( 'action' => 'default' ) );
1910
+		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1911 1911
 	}
1912 1912
 
1913 1913
 
@@ -1920,30 +1920,30 @@  discard block
 block discarded – undo
1920 1920
 	 * @param  string $event_status
1921 1921
 	 * @return bool
1922 1922
 	 */
1923
-	private function _change_event_status( $EVT_ID = 0, $event_status = '' ) {
1923
+	private function _change_event_status($EVT_ID = 0, $event_status = '') {
1924 1924
 		// grab event id
1925
-		if ( ! $EVT_ID ) {
1925
+		if ( ! $EVT_ID) {
1926 1926
 			$msg = esc_html__(
1927 1927
 				'An error occurred. No Event ID or an invalid Event ID was received.',
1928 1928
 				'event_espresso'
1929 1929
 			);
1930
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1930
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1931 1931
 			return false;
1932 1932
 		}
1933
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1933
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1934 1934
 		// clean status
1935
-		$event_status = sanitize_key( $event_status );
1935
+		$event_status = sanitize_key($event_status);
1936 1936
 		// grab status
1937
-		if ( empty( $event_status ) ) {
1937
+		if (empty($event_status)) {
1938 1938
 			$msg = esc_html__(
1939 1939
 				'An error occurred. No Event Status or an invalid Event Status was received.',
1940 1940
 				'event_espresso'
1941 1941
 			);
1942
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1942
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1943 1943
 			return false;
1944 1944
 		}
1945 1945
 		// was event trashed or restored ?
1946
-		switch ( $event_status ) {
1946
+		switch ($event_status) {
1947 1947
 			case 'draft' :
1948 1948
 				$action = 'restored from the trash';
1949 1949
 				$hook = 'AHEE_event_restored_from_trash';
@@ -1957,15 +1957,15 @@  discard block
 block discarded – undo
1957 1957
 				$hook = false;
1958 1958
 		}
1959 1959
 		//use class to change status
1960
-		$this->_cpt_model_obj->set_status( $event_status );
1960
+		$this->_cpt_model_obj->set_status($event_status);
1961 1961
 		$success = $this->_cpt_model_obj->save();
1962
-		if ( $success === false ) {
1963
-			$msg = sprintf( esc_html__( 'An error occurred. The event could not be %s.', 'event_espresso' ), $action );
1964
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1962
+		if ($success === false) {
1963
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
1964
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1965 1965
 			return false;
1966 1966
 		}
1967
-		if ( $hook ) {
1968
-			do_action( $hook );
1967
+		if ($hook) {
1968
+			do_action($hook);
1969 1969
 		}
1970 1970
 		return true;
1971 1971
 	}
@@ -1978,34 +1978,34 @@  discard block
 block discarded – undo
1978 1978
 	 * @access protected
1979 1979
 	 * @param bool $redirect_after
1980 1980
 	 */
1981
-	protected function _delete_event( $redirect_after = true ) {
1981
+	protected function _delete_event($redirect_after = true) {
1982 1982
 		//determine the event id and set to array.
1983
-		$EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : null;
1984
-		$EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID;
1983
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
1984
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
1985 1985
 		// loop thru events
1986
-		if ( $EVT_ID ) {
1987
-			$success = $this->_permanently_delete_event( $EVT_ID );
1986
+		if ($EVT_ID) {
1987
+			$success = $this->_permanently_delete_event($EVT_ID);
1988 1988
 			// get list of events with no prices
1989
-			$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() );
1989
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
1990 1990
 			// remove this event from the list of events with no prices
1991
-			if ( isset( $espresso_no_ticket_prices[ $EVT_ID ] ) ) {
1992
-				unset( $espresso_no_ticket_prices[ $EVT_ID ] );
1991
+			if (isset($espresso_no_ticket_prices[$EVT_ID])) {
1992
+				unset($espresso_no_ticket_prices[$EVT_ID]);
1993 1993
 			}
1994
-			update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices );
1994
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
1995 1995
 		} else {
1996 1996
 			$success = false;
1997 1997
 			$msg = esc_html__(
1998 1998
 				'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
1999 1999
 				'event_espresso'
2000 2000
 			);
2001
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2001
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2002 2002
 		}
2003
-		if ( $redirect_after ) {
2003
+		if ($redirect_after) {
2004 2004
 			$this->_redirect_after_action(
2005 2005
 				$success,
2006 2006
 				'Event',
2007 2007
 				'deleted',
2008
-				array( 'action' => 'default', 'status' => 'trash' )
2008
+				array('action' => 'default', 'status' => 'trash')
2009 2009
 			);
2010 2010
 		}
2011 2011
 	}
@@ -2021,30 +2021,30 @@  discard block
 block discarded – undo
2021 2021
 	protected function _delete_events() {
2022 2022
 		$success = true;
2023 2023
 		// get list of events with no prices
2024
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() );
2024
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2025 2025
 		//determine the event id and set to array.
2026
-		$EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array();
2026
+		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2027 2027
 		// loop thru events
2028
-		foreach ( $EVT_IDs as $EVT_ID ) {
2029
-			$EVT_ID = absint( $EVT_ID );
2030
-			if ( $EVT_ID ) {
2031
-				$results = $this->_permanently_delete_event( $EVT_ID );
2028
+		foreach ($EVT_IDs as $EVT_ID) {
2029
+			$EVT_ID = absint($EVT_ID);
2030
+			if ($EVT_ID) {
2031
+				$results = $this->_permanently_delete_event($EVT_ID);
2032 2032
 				$success = $results !== false ? $success : false;
2033 2033
 				// remove this event from the list of events with no prices
2034
-				unset( $espresso_no_ticket_prices[ $EVT_ID ] );
2034
+				unset($espresso_no_ticket_prices[$EVT_ID]);
2035 2035
 			} else {
2036 2036
 				$success = false;
2037 2037
 				$msg = esc_html__(
2038 2038
 					'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2039 2039
 					'event_espresso'
2040 2040
 				);
2041
-				EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2041
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2042 2042
 			}
2043 2043
 		}
2044
-		update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices );
2044
+		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2045 2045
 		// in order to force a pluralized result message we need to send back a success status greater than 1
2046 2046
 		$success = $success ? 2 : false;
2047
-		$this->_redirect_after_action( $success, 'Events', 'deleted', array( 'action' => 'default' ) );
2047
+		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2048 2048
 	}
2049 2049
 
2050 2050
 
@@ -2056,70 +2056,70 @@  discard block
 block discarded – undo
2056 2056
 	 * @param  int $EVT_ID
2057 2057
 	 * @return bool
2058 2058
 	 */
2059
-	private function _permanently_delete_event( $EVT_ID = 0 ) {
2059
+	private function _permanently_delete_event($EVT_ID = 0) {
2060 2060
 		// grab event id
2061
-		if ( ! $EVT_ID ) {
2061
+		if ( ! $EVT_ID) {
2062 2062
 			$msg = esc_html__(
2063 2063
 				'An error occurred. No Event ID or an invalid Event ID was received.',
2064 2064
 				'event_espresso'
2065 2065
 			);
2066
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2066
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2067 2067
 			return false;
2068 2068
 		}
2069 2069
 		if (
2070 2070
 			! $this->_cpt_model_obj instanceof EE_Event
2071 2071
 			|| $this->_cpt_model_obj->ID() !== $EVT_ID
2072 2072
 		) {
2073
-			$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
2073
+			$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2074 2074
 		}
2075
-		if ( ! $this->_cpt_model_obj instanceof EE_Event ) {
2075
+		if ( ! $this->_cpt_model_obj instanceof EE_Event) {
2076 2076
 			return false;
2077 2077
 		}
2078 2078
 		//need to delete related tickets and prices first.
2079
-		$datetimes = $this->_cpt_model_obj->get_many_related( 'Datetime' );
2080
-		foreach ( $datetimes as $datetime ) {
2081
-			$this->_cpt_model_obj->_remove_relation_to( $datetime, 'Datetime' );
2082
-			$tickets = $datetime->get_many_related( 'Ticket' );
2083
-			foreach ( $tickets as $ticket ) {
2084
-				$ticket->_remove_relation_to( $datetime, 'Datetime' );
2085
-				$ticket->delete_related_permanently( 'Price' );
2079
+		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2080
+		foreach ($datetimes as $datetime) {
2081
+			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2082
+			$tickets = $datetime->get_many_related('Ticket');
2083
+			foreach ($tickets as $ticket) {
2084
+				$ticket->_remove_relation_to($datetime, 'Datetime');
2085
+				$ticket->delete_related_permanently('Price');
2086 2086
 				$ticket->delete_permanently();
2087 2087
 			}
2088 2088
 			$datetime->delete();
2089 2089
 		}
2090 2090
 		//what about related venues or terms?
2091
-		$venues = $this->_cpt_model_obj->get_many_related( 'Venue' );
2092
-		foreach ( $venues as $venue ) {
2093
-			$this->_cpt_model_obj->_remove_relation_to( $venue, 'Venue' );
2091
+		$venues = $this->_cpt_model_obj->get_many_related('Venue');
2092
+		foreach ($venues as $venue) {
2093
+			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2094 2094
 		}
2095 2095
 		//any attached question groups?
2096
-		$question_groups = $this->_cpt_model_obj->get_many_related( 'Question_Group' );
2097
-		if ( ! empty( $question_groups ) ) {
2098
-			foreach ( $question_groups as $question_group ) {
2099
-				$this->_cpt_model_obj->_remove_relation_to( $question_group, 'Question_Group' );
2096
+		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2097
+		if ( ! empty($question_groups)) {
2098
+			foreach ($question_groups as $question_group) {
2099
+				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2100 2100
 			}
2101 2101
 		}
2102 2102
 		//Message Template Groups
2103
-		$this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' );
2103
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2104 2104
 		/** @type EE_Term_Taxonomy[] $term_taxonomies */
2105 2105
 		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2106
-		foreach ( $term_taxonomies as $term_taxonomy ) {
2107
-			$this->_cpt_model_obj->remove_relation_to_term_taxonomy( $term_taxonomy );
2106
+		foreach ($term_taxonomies as $term_taxonomy) {
2107
+			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2108 2108
 		}
2109 2109
 		$success = $this->_cpt_model_obj->delete_permanently();
2110 2110
 		// did it all go as planned ?
2111
-		if ( $success ) {
2112
-			$msg = sprintf( esc_html__( 'Event ID # %d has been deleted.', 'event_espresso' ), $EVT_ID );
2113
-			EE_Error::add_success( $msg );
2111
+		if ($success) {
2112
+			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2113
+			EE_Error::add_success($msg);
2114 2114
 		} else {
2115 2115
 			$msg = sprintf(
2116
-				esc_html__( 'An error occurred. Event ID # %d could not be deleted.', 'event_espresso' ),
2116
+				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2117 2117
 				$EVT_ID
2118 2118
 			);
2119
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2119
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2120 2120
 			return false;
2121 2121
 		}
2122
-		do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID );
2122
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2123 2123
 		return true;
2124 2124
 	}
2125 2125
 
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
 	 * @return int
2133 2133
 	 */
2134 2134
 	public function total_events() {
2135
-		$count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true );
2135
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2136 2136
 		return $count;
2137 2137
 	}
2138 2138
 
@@ -2146,9 +2146,9 @@  discard block
 block discarded – undo
2146 2146
 	 */
2147 2147
 	public function total_events_draft() {
2148 2148
 		$where = array(
2149
-			'status' => array( 'IN', array( 'draft', 'auto-draft' ) ),
2149
+			'status' => array('IN', array('draft', 'auto-draft')),
2150 2150
 		);
2151
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2151
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2152 2152
 		return $count;
2153 2153
 	}
2154 2154
 
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
 		$where = array(
2165 2165
 			'status' => 'trash',
2166 2166
 		);
2167
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2167
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2168 2168
 		return $count;
2169 2169
 	}
2170 2170
 
@@ -2195,12 +2195,12 @@  discard block
 block discarded – undo
2195 2195
 			EE_Registry::instance()->CFG->registration->default_STS_ID,
2196 2196
 			$this->_template_args['reg_status_array']
2197 2197
 		)
2198
-			? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID )
2198
+			? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID)
2199 2199
 			: EEM_Registration::status_id_pending_payment;
2200
-		$this->_set_add_edit_form_tags( 'update_default_event_settings' );
2201
-		$this->_set_publish_post_box_vars( null, false, false, null, false );
2200
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2201
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2202 2202
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2203
-			EVENTS_TEMPLATE_PATH . 'event_settings.template.php',
2203
+			EVENTS_TEMPLATE_PATH.'event_settings.template.php',
2204 2204
 			$this->_template_args,
2205 2205
 			true
2206 2206
 		);
@@ -2216,8 +2216,8 @@  discard block
 block discarded – undo
2216 2216
 	 * @return void
2217 2217
 	 */
2218 2218
 	protected function _update_default_event_settings() {
2219
-		EE_Config::instance()->registration->default_STS_ID = isset( $this->_req_data['default_reg_status'] )
2220
-			? sanitize_text_field( $this->_req_data['default_reg_status'] )
2219
+		EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status'])
2220
+			? sanitize_text_field($this->_req_data['default_reg_status'])
2221 2221
 			: EEM_Registration::status_id_pending_payment;
2222 2222
 		$what = 'Default Event Settings';
2223 2223
 		$success = $this->_update_espresso_configuration(
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
 			__FUNCTION__,
2228 2228
 			__LINE__
2229 2229
 		);
2230
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default_event_settings' ) );
2230
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings'));
2231 2231
 	}
2232 2232
 
2233 2233
 
@@ -2237,20 +2237,20 @@  discard block
 block discarded – undo
2237 2237
 
2238 2238
 
2239 2239
 	protected function _template_settings() {
2240
-		$this->_admin_page_title = esc_html__( 'Template Settings (Preview)', 'event_espresso' );
2240
+		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2241 2241
 		$this->_template_args['preview_img'] = '<img src="'
2242 2242
 		                                       . EVENTS_ASSETS_URL
2243 2243
 		                                       . DS
2244 2244
 		                                       . 'images'
2245 2245
 		                                       . DS
2246 2246
 		                                       . 'caffeinated_template_features.jpg" alt="'
2247
-		                                       . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' )
2247
+		                                       . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2248 2248
 		                                       . '" />';
2249
-		$this->_template_args['preview_text'] = '<strong>' . esc_html__(
2249
+		$this->_template_args['preview_text'] = '<strong>'.esc_html__(
2250 2250
 				'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2251 2251
 				'event_espresso'
2252
-			) . '</strong>';
2253
-		$this->display_admin_caf_preview_page( 'template_settings_tab' );
2252
+			).'</strong>';
2253
+		$this->display_admin_caf_preview_page('template_settings_tab');
2254 2254
 	}
2255 2255
 
2256 2256
 
@@ -2262,18 +2262,18 @@  discard block
 block discarded – undo
2262 2262
 	 * @return void
2263 2263
 	 */
2264 2264
 	private function _set_category_object() {
2265
-		if ( isset( $this->_category->id ) && ! empty( $this->_category->id ) ) {
2265
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2266 2266
 			return;
2267 2267
 		} //already have the category object so get out.
2268 2268
 		//set default category object
2269 2269
 		$this->_set_empty_category_object();
2270 2270
 		//only set if we've got an id
2271
-		if ( ! isset( $this->_req_data['EVT_CAT_ID'] ) ) {
2271
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2272 2272
 			return;
2273 2273
 		}
2274
-		$category_id = absint( $this->_req_data['EVT_CAT_ID'] );
2275
-		$term = get_term( $category_id, 'espresso_event_categories' );
2276
-		if ( ! empty( $term ) ) {
2274
+		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2275
+		$term = get_term($category_id, 'espresso_event_categories');
2276
+		if ( ! empty($term)) {
2277 2277
 			$this->_category->category_name = $term->name;
2278 2278
 			$this->_category->category_identifier = $term->slug;
2279 2279
 			$this->_category->category_desc = $term->description;
@@ -2293,9 +2293,9 @@  discard block
 block discarded – undo
2293 2293
 
2294 2294
 
2295 2295
 	protected function _category_list_table() {
2296
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2297
-		$this->_search_btn_label = esc_html__( 'Categories', 'event_espresso' );
2298
-		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2296
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2297
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2298
+		$this->_admin_page_title .= ' '.$this->get_action_link_or_button(
2299 2299
 				'add_category',
2300 2300
 				'add_category',
2301 2301
 				array(),
@@ -2309,20 +2309,20 @@  discard block
 block discarded – undo
2309 2309
 	/**
2310 2310
 	 * @param $view
2311 2311
 	 */
2312
-	protected function _category_details( $view ) {
2312
+	protected function _category_details($view) {
2313 2313
 		//load formatter helper
2314 2314
 		//load field generator helper
2315 2315
 		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2316
-		$this->_set_add_edit_form_tags( $route );
2316
+		$this->_set_add_edit_form_tags($route);
2317 2317
 		$this->_set_category_object();
2318
-		$id = ! empty( $this->_category->id ) ? $this->_category->id : '';
2318
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2319 2319
 		$delete_action = 'delete_category';
2320 2320
 		//custom redirect
2321 2321
 		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2322
-			array( 'action' => 'category_list' ),
2322
+			array('action' => 'category_list'),
2323 2323
 			$this->_admin_base_url
2324 2324
 		);
2325
-		$this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect );
2325
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2326 2326
 		//take care of contents
2327 2327
 		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2328 2328
 		$this->display_admin_page_with_sidebar();
@@ -2336,21 +2336,21 @@  discard block
 block discarded – undo
2336 2336
 	protected function _category_details_content() {
2337 2337
 		$editor_args['category_desc'] = array(
2338 2338
 			'type'          => 'wp_editor',
2339
-			'value'         => EEH_Formatter::admin_format_content( $this->_category->category_desc ),
2339
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2340 2340
 			'class'         => 'my_editor_custom',
2341
-			'wpeditor_args' => array( 'media_buttons' => false ),
2341
+			'wpeditor_args' => array('media_buttons' => false),
2342 2342
 		);
2343
-		$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' );
2343
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2344 2344
 		$all_terms = get_terms(
2345
-			array( 'espresso_event_categories' ),
2346
-			array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) )
2345
+			array('espresso_event_categories'),
2346
+			array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2347 2347
 		);
2348 2348
 		//setup category select for term parents.
2349 2349
 		$category_select_values[] = array(
2350
-			'text' => esc_html__( 'No Parent', 'event_espresso' ),
2350
+			'text' => esc_html__('No Parent', 'event_espresso'),
2351 2351
 			'id'   => 0,
2352 2352
 		);
2353
-		foreach ( $all_terms as $term ) {
2353
+		foreach ($all_terms as $term) {
2354 2354
 			$category_select_values[] = array(
2355 2355
 				'text' => $term->name,
2356 2356
 				'id'   => $term->term_id,
@@ -2364,28 +2364,28 @@  discard block
 block discarded – undo
2364 2364
 		$template_args = array(
2365 2365
 			'category'                 => $this->_category,
2366 2366
 			'category_select'          => $category_select,
2367
-			'unique_id_info_help_link' => $this->_get_help_tab_link( 'unique_id_info' ),
2367
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2368 2368
 			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2369 2369
 			'disable'                  => '',
2370 2370
 			'disabled_message'         => false,
2371 2371
 		);
2372
-		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2373
-		return EEH_Template::display_template( $template, $template_args, true );
2372
+		$template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2373
+		return EEH_Template::display_template($template, $template_args, true);
2374 2374
 	}
2375 2375
 
2376 2376
 
2377 2377
 
2378 2378
 	protected function _delete_categories() {
2379
-		$cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID']
2379
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2380 2380
 			: (array) $this->_req_data['category_id'];
2381
-		foreach ( $cat_ids as $cat_id ) {
2382
-			$this->_delete_category( $cat_id );
2381
+		foreach ($cat_ids as $cat_id) {
2382
+			$this->_delete_category($cat_id);
2383 2383
 		}
2384 2384
 		//doesn't matter what page we're coming from... we're going to the same place after delete.
2385 2385
 		$query_args = array(
2386 2386
 			'action' => 'category_list',
2387 2387
 		);
2388
-		$this->_redirect_after_action( 0, '', '', $query_args );
2388
+		$this->_redirect_after_action(0, '', '', $query_args);
2389 2389
 	}
2390 2390
 
2391 2391
 
@@ -2393,9 +2393,9 @@  discard block
 block discarded – undo
2393 2393
 	/**
2394 2394
 	 * @param $cat_id
2395 2395
 	 */
2396
-	protected function _delete_category( $cat_id ) {
2397
-		$cat_id = absint( $cat_id );
2398
-		wp_delete_term( $cat_id, 'espresso_event_categories' );
2396
+	protected function _delete_category($cat_id) {
2397
+		$cat_id = absint($cat_id);
2398
+		wp_delete_term($cat_id, 'espresso_event_categories');
2399 2399
 	}
2400 2400
 
2401 2401
 
@@ -2403,18 +2403,18 @@  discard block
 block discarded – undo
2403 2403
 	/**
2404 2404
 	 * @param $new_category
2405 2405
 	 */
2406
-	protected function _insert_or_update_category( $new_category ) {
2407
-		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( true );
2406
+	protected function _insert_or_update_category($new_category) {
2407
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2408 2408
 		$success = 0; //we already have a success message so lets not send another.
2409
-		if ( $cat_id ) {
2409
+		if ($cat_id) {
2410 2410
 			$query_args = array(
2411 2411
 				'action'     => 'edit_category',
2412 2412
 				'EVT_CAT_ID' => $cat_id,
2413 2413
 			);
2414 2414
 		} else {
2415
-			$query_args = array( 'action' => 'add_category' );
2415
+			$query_args = array('action' => 'add_category');
2416 2416
 		}
2417
-		$this->_redirect_after_action( $success, '', '', $query_args, true );
2417
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2418 2418
 	}
2419 2419
 
2420 2420
 
@@ -2423,14 +2423,14 @@  discard block
 block discarded – undo
2423 2423
 	 * @param bool $update
2424 2424
 	 * @return bool|mixed|string
2425 2425
 	 */
2426
-	private function _insert_category( $update = false ) {
2426
+	private function _insert_category($update = false) {
2427 2427
 		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2428
-		$category_name = isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : '';
2429
-		$category_desc = isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : '';
2430
-		$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0;
2431
-		if ( empty( $category_name ) ) {
2432
-			$msg = esc_html__( 'You must add a name for the category.', 'event_espresso' );
2433
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2428
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2429
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2430
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2431
+		if (empty($category_name)) {
2432
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
2433
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2434 2434
 			return false;
2435 2435
 		}
2436 2436
 		$term_args = array(
@@ -2439,22 +2439,22 @@  discard block
 block discarded – undo
2439 2439
 			'parent'      => $category_parent,
2440 2440
 		);
2441 2441
 		//was the category_identifier input disabled?
2442
-		if ( isset( $this->_req_data['category_identifier'] ) ) {
2442
+		if (isset($this->_req_data['category_identifier'])) {
2443 2443
 			$term_args['slug'] = $this->_req_data['category_identifier'];
2444 2444
 		}
2445 2445
 		$insert_ids = $update
2446
-			? wp_update_term( $cat_id, 'espresso_event_categories', $term_args )
2447
-			: wp_insert_term( $category_name, 'espresso_event_categories', $term_args );
2448
-		if ( ! is_array( $insert_ids ) ) {
2446
+			? wp_update_term($cat_id, 'espresso_event_categories', $term_args)
2447
+			: wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2448
+		if ( ! is_array($insert_ids)) {
2449 2449
 			$msg = esc_html__(
2450 2450
 				'An error occurred and the category has not been saved to the database.',
2451 2451
 				'event_espresso'
2452 2452
 			);
2453
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2453
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2454 2454
 		} else {
2455 2455
 			$cat_id = $insert_ids['term_id'];
2456
-			$msg = sprintf( esc_html__( 'The category %s was successfully saved', 'event_espresso' ), $category_name );
2457
-			EE_Error::add_success( $msg );
2456
+			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2457
+			EE_Error::add_success($msg);
2458 2458
 		}
2459 2459
 		return $cat_id;
2460 2460
 	}
@@ -2467,28 +2467,28 @@  discard block
 block discarded – undo
2467 2467
 	 * @param bool $count
2468 2468
 	 * @return \EE_Base_Class[]|int
2469 2469
 	 */
2470
-	public function get_categories( $per_page = 10, $current_page = 1, $count = false ) {
2470
+	public function get_categories($per_page = 10, $current_page = 1, $count = false) {
2471 2471
 		//testing term stuff
2472
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id';
2473
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC';
2474
-		$limit = ( $current_page - 1 ) * $per_page;
2475
-		$where = array( 'taxonomy' => 'espresso_event_categories' );
2476
-		if ( isset( $this->_req_data['s'] ) ) {
2477
-			$sstr = '%' . $this->_req_data['s'] . '%';
2472
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2473
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2474
+		$limit = ($current_page - 1) * $per_page;
2475
+		$where = array('taxonomy' => 'espresso_event_categories');
2476
+		if (isset($this->_req_data['s'])) {
2477
+			$sstr = '%'.$this->_req_data['s'].'%';
2478 2478
 			$where['OR'] = array(
2479
-				'Term.name'   => array( 'LIKE', $sstr ),
2480
-				'description' => array( 'LIKE', $sstr ),
2479
+				'Term.name'   => array('LIKE', $sstr),
2480
+				'description' => array('LIKE', $sstr),
2481 2481
 			);
2482 2482
 		}
2483 2483
 		$query_params = array(
2484 2484
 			$where,
2485
-			'order_by'   => array( $orderby => $order ),
2486
-			'limit'      => $limit . ',' . $per_page,
2487
-			'force_join' => array( 'Term' ),
2485
+			'order_by'   => array($orderby => $order),
2486
+			'limit'      => $limit.','.$per_page,
2487
+			'force_join' => array('Term'),
2488 2488
 		);
2489 2489
 		$categories = $count
2490
-			? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' )
2491
-			: EEM_Term_Taxonomy::instance()->get_all( $query_params );
2490
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2491
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2492 2492
 		return $categories;
2493 2493
 	}
2494 2494
 
Please login to merge, or discard this patch.