Completed
Branch BUG-8957-add-countries (301f85)
by
unknown
32:21 queued 18:11
created
core/libraries/payment_methods/EE_Gateway.lib.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -282,7 +282,7 @@
 block discarded – undo
282 282
 	/**
283 283
 	 * Gets the first event for this payment (it's possible that it could be for multiple)
284 284
 	 * @param EEI_Payment $payment
285
-	 * @return EEI_Event|null
285
+	 * @return EE_Event|null
286 286
 	 */
287 287
 	protected function _get_first_event_for_payment( EEI_Payment $payment ) {
288 288
 		$transaction = $payment->transaction();
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @subpackage		core/libraries/payment_methods
16 16
  * @author			Mike Nelson
17 17
  */
18
-abstract class EE_Gateway{
18
+abstract class EE_Gateway {
19 19
 	/**
20 20
 	 * a constant used as a possible value for $_currencies_supported to indicate
21 21
 	 * that ALL currencies are supported by this gateway
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * @return EE_Gateway
95 95
 	 */
96
-	public function __construct(){
96
+	public function __construct() {
97 97
 	}
98 98
 
99 99
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * beginning again)
106 106
 	 * @return array
107 107
 	 */
108
-	public function __sleep(){
108
+	public function __sleep() {
109 109
 		$properties = get_object_vars($this);
110
-		unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] );
110
+		unset($properties['_pay_model'], $properties['_pay_log']);
111 111
 		return array_keys($properties);
112 112
 	}
113 113
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * see $_supports_sending_refunds
116 116
 	 * @return boolean
117 117
 	 */
118
-	public function supports_sending_refunds(){
118
+	public function supports_sending_refunds() {
119 119
 		return $this->_supports_sending_refunds;
120 120
 	}
121 121
 	/**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * see $_supports_receiving_refunds
124 124
 	 * @return boolean
125 125
 	 */
126
-	public function supports_receiving_refunds(){
126
+	public function supports_receiving_refunds() {
127 127
 		return $this->_supports_receiving_refunds;
128 128
 	}
129 129
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @return EE_Payment for the refund
139 139
 	 * @throws EE_Error
140 140
 	 */
141
-	public function do_direct_refund( EE_Payment $payment, $refund_info = null ) {
141
+	public function do_direct_refund(EE_Payment $payment, $refund_info = null) {
142 142
 		return NULL;
143 143
 	}
144 144
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * etc
150 150
 	 * @param array $settings_array
151 151
 	 */
152
-	public function set_settings($settings_array){
153
-		foreach($settings_array as $name => $value){
152
+	public function set_settings($settings_array) {
153
+		foreach ($settings_array as $name => $value) {
154 154
 			$property_name = "_".$name;
155 155
 			$this->{$property_name} = $value;
156 156
 		}
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
 	 * See this class description
160 160
 	 * @param EEMI_Payment $payment_model
161 161
 	 */
162
-	public function set_payment_model($payment_model){
162
+	public function set_payment_model($payment_model) {
163 163
 		$this->_pay_model = $payment_model;
164 164
 	}
165 165
 	/**
166 166
 	 * See this class description
167 167
 	 * @param EEMI_Payment_Log $payment_log_model
168 168
 	 */
169
-	public function set_payment_log($payment_log_model){
169
+	public function set_payment_log($payment_log_model) {
170 170
 		$this->_pay_log = $payment_log_model;
171 171
 	}
172 172
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * See this class description
175 175
 	 * @param EEHI_Template $template_helper
176 176
 	 */
177
-	public function set_template_helper($template_helper){
177
+	public function set_template_helper($template_helper) {
178 178
 		$this->_template = $template_helper;
179 179
 	}
180 180
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * See this class description
183 183
 	 * @param EEHI_Line_Item $line_item_helper
184 184
 	 */
185
-	public function set_line_item_helper( $line_item_helper ){
185
+	public function set_line_item_helper($line_item_helper) {
186 186
 		$this->_line_item = $line_item_helper;
187 187
 	}
188 188
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * See this class description
191 191
 	 * @param EEHI_Money $money_helper
192 192
 	 */
193
-	public function set_money_helper( $money_helper ){
193
+	public function set_money_helper($money_helper) {
194 194
 		$this->_money = $money_helper;
195 195
 	}
196 196
 
@@ -199,23 +199,23 @@  discard block
 block discarded – undo
199 199
 	 * @param $message
200 200
 	 * @param $payment
201 201
 	 */
202
-	public function log($message,$payment){
203
-		if($payment instanceof EEI_Payment){
204
-			$type='Payment';
202
+	public function log($message, $payment) {
203
+		if ($payment instanceof EEI_Payment) {
204
+			$type = 'Payment';
205 205
 			$id = $payment->ID();
206
-		}else{
206
+		} else {
207 207
 			$type = 'Payment_Method';
208 208
 			$id = $this->_ID;
209 209
 		}
210
-		$this->_pay_log->gateway_log($message,$id,$type);
210
+		$this->_pay_log->gateway_log($message, $id, $type);
211 211
 	}
212 212
 	/**
213 213
 	 * Formats the amount so it can generally be sent to gateways
214 214
 	 * @param float $amount
215 215
 	 * @return string
216 216
 	 */
217
-	public function format_currency($amount){
218
-		return number_format( $amount, 2, '.', '' );
217
+	public function format_currency($amount) {
218
+		return number_format($amount, 2, '.', '');
219 219
 //		return $this->_template->format_currency($amount, true);
220 220
 	}
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * or a string indicating they're all supported (EE_gateway::all_currencies_supported)
225 225
 	 * @return mixed array or string
226 226
 	 */
227
-	public function currencies_supported(){
227
+	public function currencies_supported() {
228 228
 		return $this->_currencies_supported;
229 229
 	}
230 230
 
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
 	 * @param EE_Transaction  $transaction
237 237
 	 * @return float
238 238
 	 */
239
-	protected function _sum_items_and_taxes( EE_Transaction  $transaction){
239
+	protected function _sum_items_and_taxes(EE_Transaction  $transaction) {
240 240
 		$total_line_item = $transaction->total_line_item();
241 241
 		$total = 0;
242
-		foreach($total_line_item->get_items() as $item_line_item ){
243
-			$total += max( $item_line_item->total(), 0 );
242
+		foreach ($total_line_item->get_items() as $item_line_item) {
243
+			$total += max($item_line_item->total(), 0);
244 244
 		}
245
-		foreach($total_line_item->tax_descendants() as $tax_line_item ){
246
-			$total += max( $tax_line_item->total(), 0 );
245
+		foreach ($total_line_item->tax_descendants() as $tax_line_item) {
246
+			$total += max($tax_line_item->total(), 0);
247 247
 		}
248 248
 		return $total;
249 249
 	}
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 	 * @param EEI_Payment $payment
255 255
 	 * @return boolean
256 256
 	 */
257
-	protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){
257
+	protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) {
258 258
 		return  $this->_money->compare_floats(
259
-					$this->_sum_items_and_taxes( $payment->transaction() ),
259
+					$this->_sum_items_and_taxes($payment->transaction()),
260 260
 					$payment->transaction()->total() ) &&
261 261
 				$this->_money->compare_floats(
262 262
 					$payment->amount(),
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @param EE_Payment $payment
275 275
 	 * @return void
276 276
 	 */
277
-	public function update_txn_based_on_payment( $payment ){
277
+	public function update_txn_based_on_payment($payment) {
278 278
 		//maybe update the transaction or line items or registrations
279 279
 		//but most gateways don't need to do this, because they only update the payment
280 280
 	}
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 	 * @param EEI_Payment $payment
285 285
 	 * @return EEI_Event|null
286 286
 	 */
287
-	protected function _get_first_event_for_payment( EEI_Payment $payment ) {
287
+	protected function _get_first_event_for_payment(EEI_Payment $payment) {
288 288
 		$transaction = $payment->transaction();
289
-		if( $transaction instanceof EEI_Transaction ) {
289
+		if ($transaction instanceof EEI_Transaction) {
290 290
 			$primary_registrant = $transaction->primary_registration();
291
-			if( $primary_registrant instanceof EE_Registration ) {
291
+			if ($primary_registrant instanceof EE_Registration) {
292 292
 				return $primary_registrant->event_obj();
293 293
 			}
294 294
 		}
@@ -300,19 +300,19 @@  discard block
 block discarded – undo
300 300
 	 * @param EEI_Payment $payment
301 301
 	 * @return string
302 302
 	 */
303
-	protected function _get_first_event_name_for_payment( EEI_Payment $payment ) {
304
-		$event = $this->_get_first_event_for_payment( $payment );
305
-		return $event instanceof EEI_Event ? $event->name() : __( 'Event', 'event_espresso' );
303
+	protected function _get_first_event_name_for_payment(EEI_Payment $payment) {
304
+		$event = $this->_get_first_event_for_payment($payment);
305
+		return $event instanceof EEI_Event ? $event->name() : __('Event', 'event_espresso');
306 306
 	}
307 307
 	/**
308 308
 	 * Gets the text to use for a gateway's line item name when this is a partial payment
309 309
 	 * @param EE_Payment $payment
310 310
 	 * @return string
311 311
 	 */
312
-	protected function _format_partial_payment_line_item_name( EEI_Payment $payment ){
312
+	protected function _format_partial_payment_line_item_name(EEI_Payment $payment) {
313 313
 		return apply_filters( 
314 314
 			'EEG_Paypal_Pro__do_direct_payment__partial_amount_line_item_name', 
315
-			$this->_get_first_event_name_for_payment( $payment ), 
315
+			$this->_get_first_event_name_for_payment($payment), 
316 316
 			$this,
317 317
 			$payment
318 318
 		);
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
 	 * @param EEI_Payment $payment
323 323
 	 * @return string
324 324
 	 */
325
-	protected function _format_partial_payment_line_item_desc( EEI_Payment $payment ) {
325
+	protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) {
326 326
 		return apply_filters(
327 327
 			'FHEE__EE_Gateway___partial_payment_desc',
328 328
 			sprintf(
329 329
 				__("Payment of %s for %s", "event_espresso"), 
330
-				$payment->get_pretty( 'PAY_amount', 'no_currency_code' ), 
331
-				$this->_get_first_event_name_for_payment( $payment ) ),
330
+				$payment->get_pretty('PAY_amount', 'no_currency_code'), 
331
+				$this->_get_first_event_name_for_payment($payment) ),
332 332
 			$this,
333 333
 			$payment
334 334
 		);
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 	 * @param EEI_Payment $payment
341 341
 	 * @return string
342 342
 	 */
343
-	protected function _format_line_item_name( EEI_Line_Item $line_item, EEI_Payment $payment ) {
343
+	protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) {
344 344
 		return apply_filters( 
345 345
 			'FHEE__EE_gateway___line_item_name', 
346
-			sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), 
346
+			sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), 
347 347
 			$this,
348 348
 			$line_item, 
349 349
 			$payment 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * @param EEI_Payment $payment
357 357
 	 * @return string
358 358
 	 */
359
-	protected function _format_line_item_desc( EEI_Line_Item $line_item, EEI_Payment $payment ) {
359
+	protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) {
360 360
 		return apply_filters( 
361 361
 			'FHEE__EE_Gateway___line_item_desc', 
362 362
 			$line_item->desc(), 
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
 	 * @param EEI_Payment $payment
372 372
 	 * @return type
373 373
 	 */
374
-	protected function _format_order_description( EEI_Payment $payment ) {
374
+	protected function _format_order_description(EEI_Payment $payment) {
375 375
 		return apply_filters( 
376 376
 			'FHEE__EE_Gateway___order_description',
377 377
 			sprintf(
378 378
 				__('Event Registrations from %1$s for %2$s', "event_espresso"),
379 379
 				get_bloginfo('name'),
380
-				$this->_get_first_event_name_for_payment( $payment ) ),
380
+				$this->_get_first_event_name_for_payment($payment) ),
381 381
 			$this,
382 382
 			$payment
383 383
 		);
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return EEG_Paypal_Standard
69 69
 	 */
70 70
 	public function __construct() {
71
-		$this->set_uses_separate_IPN_request( true ) ;
71
+		$this->set_uses_separate_IPN_request(true);
72 72
 		parent::__construct();
73 73
 	}
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Also sets the gateway url class variable based on whether debug mode is enabled or not
79 79
 	 * @param array $settings_array
80 80
 	 */
81
-	public function set_settings($settings_array){
81
+	public function set_settings($settings_array) {
82 82
 		parent::set_settings($settings_array);
83 83
 		$this->_gateway_url = $this->_debug_mode
84 84
 			? 'https://www.sandbox.paypal.com/cgi-bin/webscr'
@@ -112,42 +112,42 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$total_discounts_to_cart_total = $transaction->paid();
114 114
 		//only itemize the order if we're paying for the rest of the order's amount
115
-		if( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) {
116
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true );
115
+		if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) {
116
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
117 117
 			//this payment is for the remaining transaction amount,
118 118
 			//keep track of exactly how much the itemized order amount equals
119 119
 			$itemized_sum = 0;
120 120
 			$shipping_previously_added = 0;
121 121
 			//so let's show all the line items
122
-			foreach($total_line_item->get_items() as $line_item){
123
-				if ( $line_item instanceof EE_Line_Item ) {
122
+			foreach ($total_line_item->get_items() as $line_item) {
123
+				if ($line_item instanceof EE_Line_Item) {
124 124
 					//it's some kind of discount
125
-					if( $line_item->total() < 0 ) {
126
-						$total_discounts_to_cart_total += abs( $line_item->total() );
125
+					if ($line_item->total() < 0) {
126
+						$total_discounts_to_cart_total += abs($line_item->total());
127 127
 						$itemized_sum += $line_item->total();
128 128
 						continue;
129 129
 					}
130 130
 					//dont include shipping again.
131
-					if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) {
131
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
132 132
 						$shipping_previously_added = $line_item->total();
133 133
 						continue;
134 134
 					}
135
-					$redirect_args[ 'item_name_' . $item_num ] = substr(
136
-						$this->_format_line_item_name( $line_item, $payment ),
135
+					$redirect_args['item_name_'.$item_num] = substr(
136
+						$this->_format_line_item_name($line_item, $payment),
137 137
 						0, 127
138 138
 					);
139
-					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
140
-					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
139
+					$redirect_args['amount_'.$item_num] = $line_item->unit_price();
140
+					$redirect_args['quantity_'.$item_num] = $line_item->quantity();
141 141
 					//if we're not letting PayPal calculate shipping, tell them its 0
142
-					if ( ! $this->_paypal_shipping ) {
143
-						$redirect_args[ 'shipping_' . $item_num ] = '0';
144
-						$redirect_args[ 'shipping2_' . $item_num ] = '0';
142
+					if ( ! $this->_paypal_shipping) {
143
+						$redirect_args['shipping_'.$item_num] = '0';
144
+						$redirect_args['shipping2_'.$item_num] = '0';
145 145
 					}
146 146
 					$item_num++;
147 147
 					$itemized_sum += $line_item->total();
148 148
 				}
149 149
 			}
150
-			$taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item );
150
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
151 151
 			//ideally itemized sum equals the transaction total. but if not (which is weird)
152 152
 			//and the itemized sum is LESS than the transaction total
153 153
 			//add another line item
@@ -157,47 +157,47 @@  discard block
 block discarded – undo
157 157
 				$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
158 158
 				2
159 159
 			);
160
-			if( $itemized_sum_diff_from_txn_total < 0 ) {
160
+			if ($itemized_sum_diff_from_txn_total < 0) {
161 161
 				//itemized sum is too big
162
-				$total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total );
163
-			} elseif( $itemized_sum_diff_from_txn_total > 0 ) {
164
-				$redirect_args[ 'item_name_' . $item_num ] = substr(
165
-						__( 'Other charges', 'event_espresso' ), 0, 127 );
166
-				$redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total );
167
-				$redirect_args[ 'quantity_' . $item_num ] = 1;
162
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
163
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
164
+				$redirect_args['item_name_'.$item_num] = substr(
165
+						__('Other charges', 'event_espresso'), 0, 127 );
166
+				$redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
167
+				$redirect_args['quantity_'.$item_num] = 1;
168 168
 				$item_num++;
169 169
 			}
170
-			if( $total_discounts_to_cart_total > 0 ) {
171
-				$redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total );
170
+			if ($total_discounts_to_cart_total > 0) {
171
+				$redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total);
172 172
 			}
173 173
 			//add our taxes to the order if we're NOT using PayPal's
174
-			if( ! $this->_paypal_taxes ){
174
+			if ( ! $this->_paypal_taxes) {
175 175
 				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
176 176
 			}
177 177
 		} else {
178
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false );
178
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
179 179
 			//partial payment that's not for the remaining amount, so we can't send an itemized list
180
-			$redirect_args['item_name_' . $item_num] = substr(
181
-				$this->_format_partial_payment_line_item_name( $payment ),
180
+			$redirect_args['item_name_'.$item_num] = substr(
181
+				$this->_format_partial_payment_line_item_name($payment),
182 182
 				0, 127
183 183
 			);
184
-			$redirect_args['amount_' . $item_num] = $payment->amount();
185
-			$redirect_args['shipping_' . $item_num ] = '0';
186
-			$redirect_args['shipping2_' . $item_num ] = '0';
184
+			$redirect_args['amount_'.$item_num] = $payment->amount();
185
+			$redirect_args['shipping_'.$item_num] = '0';
186
+			$redirect_args['shipping2_'.$item_num] = '0';
187 187
 			$redirect_args['tax_cart'] = '0';
188 188
 			$item_num++;
189 189
 		}
190 190
 
191
-		if($this->_debug_mode){
192
-			$redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode';
193
-			$redirect_args['amount_' . $item_num] = 0;
191
+		if ($this->_debug_mode) {
192
+			$redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
193
+			$redirect_args['amount_'.$item_num] = 0;
194 194
 			$redirect_args['on0_'.$item_num] = 'NOTIFY URL';
195
-			$redirect_args['os0_' . $item_num] = $notify_url;
195
+			$redirect_args['os0_'.$item_num] = $notify_url;
196 196
 			$redirect_args['on1_'.$item_num] = 'RETURN URL';
197
-			$redirect_args['os1_' . $item_num] = $return_url;
197
+			$redirect_args['os1_'.$item_num] = $return_url;
198 198
 //			$redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
199
-			$redirect_args['shipping_' . $item_num ] = '0';
200
-			$redirect_args['shipping2_' . $item_num ] = '0';
199
+			$redirect_args['shipping_'.$item_num] = '0';
200
+			$redirect_args['shipping2_'.$item_num] = '0';
201 201
 		}
202 202
 
203 203
 		$redirect_args['business'] = $this->_paypal_id;
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 		$redirect_args['cmd'] = '_cart';
208 208
 		$redirect_args['upload'] = 1;
209 209
 		$redirect_args['currency_code'] = $payment->currency_code();
210
-		$redirect_args['rm'] = 2;//makes the user return with method=POST
211
-		if($this->_image_url){
210
+		$redirect_args['rm'] = 2; //makes the user return with method=POST
211
+		if ($this->_image_url) {
212 212
 			$redirect_args['image_url'] = $this->_image_url;
213 213
 		}
214 214
 		$redirect_args['no_shipping'] = $this->_shipping_details;
215
-		$redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this
215
+		$redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this
216 216
 
217
-		$redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this );
217
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
218 218
 
219 219
 		$payment->set_redirect_url($this->_gateway_url);
220 220
 		$payment->set_redirect_args($redirect_args);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$this->log(
223 223
 			array(
224 224
 				'message'     => sprintf(
225
-					__( 'PayPal payment request initiated.', 'event_espresso' )
225
+					__('PayPal payment request initiated.', 'event_espresso')
226 226
 				),
227 227
 				'transaction' => $transaction->model_field_array(),
228 228
 			),
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 	 * @return \EEI_Payment updated
243 243
 	 * @throws \EE_Error
244 244
 	 */
245
-	public function handle_payment_update( $update_info, $transaction ){
245
+	public function handle_payment_update($update_info, $transaction) {
246 246
 		// verify there's payment data that's been sent
247
-		if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) {
247
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
248 248
 			// log the results
249 249
 			$this->log(
250 250
 				array(
251 251
 					'message' => sprintf(
252
-						__( 'PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso' )
252
+						__('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso')
253 253
 					),
254 254
 					'update_info' => $update_info,
255 255
 				),
@@ -257,50 +257,50 @@  discard block
 block discarded – undo
257 257
 			);
258 258
 			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
259 259
 			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
260
-			if ( isset( $update_info[ 'tx' ] ) ) {
260
+			if (isset($update_info['tx'])) {
261 261
 				return $transaction->last_payment();
262 262
 			} else {
263 263
 				return null;
264 264
 			}
265 265
 		}
266
-		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
267
-		if ( ! $payment instanceof EEI_Payment ) {
266
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
267
+		if ( ! $payment instanceof EEI_Payment) {
268 268
 			$payment = $transaction->last_payment();
269 269
 		}
270 270
 		// ok, then validate the IPN. Even if we've already processed this payment,
271 271
 		// let PayPal know we don't want to hear from them anymore!
272
-		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
272
+		if ( ! $this->validate_ipn($update_info, $payment)) {
273 273
 			return $payment;
274 274
 		}
275 275
 		//ok, well let's process this payment then!
276
-		switch ( $update_info[ 'payment_status' ] ) {
276
+		switch ($update_info['payment_status']) {
277 277
 
278 278
 			case 'Completed' :
279 279
 				$status = $this->_pay_model->approved_status();
280
-				$gateway_response = __( 'The payment is approved.', 'event_espresso' );
280
+				$gateway_response = __('The payment is approved.', 'event_espresso');
281 281
 				break;
282 282
 
283 283
 			case 'Pending' :
284 284
 				$status = $this->_pay_model->pending_status();
285
-				$gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' );
285
+				$gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso');
286 286
 				break;
287 287
 
288 288
 			case 'Denied' :
289 289
 				$status = $this->_pay_model->declined_status();
290
-				$gateway_response = __( 'The payment has been declined.', 'event_espresso' );
290
+				$gateway_response = __('The payment has been declined.', 'event_espresso');
291 291
 				break;
292 292
 
293 293
 			case 'Expired' :
294 294
 			case 'Failed' :
295 295
 				$status = $this->_pay_model->failed_status();
296
-				$gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' );
296
+				$gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso');
297 297
 				break;
298 298
 
299 299
 			case 'Refunded' :
300 300
 			case 'Partially_Refunded' :
301 301
 				// even though it's a refund, we consider the payment as approved, it just has a negative value
302 302
 				$status = $this->_pay_model->approved_status();
303
-				$gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' );
303
+				$gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso');
304 304
 				break;
305 305
 
306 306
 			case 'Voided' :
@@ -308,28 +308,28 @@  discard block
 block discarded – undo
308 308
 			case 'Canceled_Reversal' :
309 309
 			default :
310 310
 				$status = $this->_pay_model->cancelled_status();
311
-				$gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' );
311
+				$gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso');
312 312
 				break;
313 313
 
314 314
 		}
315 315
 
316 316
 		//check if we've already processed this payment
317
-		if ( $payment instanceof EEI_Payment ) {
317
+		if ($payment instanceof EEI_Payment) {
318 318
 			//payment exists. if this has the exact same status and amount, don't bother updating. just return
319
-			if ( $payment->status() === $status && (float)$payment->amount() === (float)$update_info[ 'mc_gross' ] ) {
319
+			if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) {
320 320
 				// DUPLICATED IPN! dont bother updating transaction foo!;
321 321
 				$message_log = sprintf(
322
-					__( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ),
322
+					__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'),
323 323
 					$payment->ID()
324 324
 				);
325 325
 			} else {
326 326
 				// new payment yippee !!!
327
-				$payment->set_status( $status );
328
-				$payment->set_amount( (float)$update_info[ 'mc_gross' ] );
329
-				$payment->set_gateway_response( $gateway_response );
330
-				$payment->set_details( $update_info );
331
-				$payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
332
-				$message_log = __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' );
327
+				$payment->set_status($status);
328
+				$payment->set_amount((float) $update_info['mc_gross']);
329
+				$payment->set_gateway_response($gateway_response);
330
+				$payment->set_details($update_info);
331
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
332
+				$message_log = __('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso');
333 333
 			}
334 334
 			$this->log(
335 335
 				array(
@@ -341,16 +341,16 @@  discard block
 block discarded – undo
341 341
 				$payment
342 342
 			);
343 343
 		}
344
-		do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this );
344
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
345 345
 		// kill request here if this is a refund
346 346
 		if (
347 347
 			(
348
-				$update_info[ 'payment_status' ] === 'Refunded'
349
-				|| $update_info[ 'payment_status' ] === 'Partially_Refunded'
348
+				$update_info['payment_status'] === 'Refunded'
349
+				|| $update_info['payment_status'] === 'Partially_Refunded'
350 350
 			)
351
-			&& apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
351
+			&& apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)
352 352
 		) {
353
-			status_header( 200 );
353
+			status_header(200);
354 354
 			exit();
355 355
 		}
356 356
 		return $payment;
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
 	 * @return boolean
368 368
 	 * @throws \EE_Error
369 369
 	 */
370
-	public function validate_ipn( $update_info, $payment ) {
370
+	public function validate_ipn($update_info, $payment) {
371 371
 		//allow us to skip validating IPNs with PayPal (useful for testing)
372
-		if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) {
372
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
373 373
 			return true;
374 374
 		}
375 375
 		//...otherwise, we actually don't care what the $update_info is, we need to look
@@ -377,22 +377,22 @@  discard block
 block discarded – undo
377 377
 		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
378 378
 		// Instead, read raw POST data from the input stream.
379 379
 		// @see https://gist.github.com/xcommerce-gists/3440401
380
-		$raw_post_data = file_get_contents( 'php://input' );
381
-		$raw_post_array = explode( '&', $raw_post_data );
380
+		$raw_post_data = file_get_contents('php://input');
381
+		$raw_post_array = explode('&', $raw_post_data);
382 382
 		$update_info = array();
383
-		foreach ( $raw_post_array as $keyval ) {
384
-			$keyval = explode( '=', $keyval );
385
-			if ( count( $keyval ) === 2 ) {
386
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
383
+		foreach ($raw_post_array as $keyval) {
384
+			$keyval = explode('=', $keyval);
385
+			if (count($keyval) === 2) {
386
+				$update_info[$keyval[0]] = urldecode($keyval[1]);
387 387
 			}
388 388
 		}
389 389
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
390 390
 		$req = 'cmd=_notify-validate';
391
-		$uses_get_magic_quotes = function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1
391
+		$uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1
392 392
 			? true
393 393
 			: false;
394
-		foreach ( $update_info as $key => $value ) {
395
-			$value = $uses_get_magic_quotes ? urlencode( stripslashes( $value ) ) : urlencode( $value );
394
+		foreach ($update_info as $key => $value) {
395
+			$value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value);
396 396
 			$req .= "&$key=$value";
397 397
 		}
398 398
 		// HTTP POST the complete, unaltered IPN back to PayPal
@@ -401,38 +401,38 @@  discard block
 block discarded – undo
401 401
 			array(
402 402
 				'body' 				=> $req,
403 403
 				'sslverify' 		=> false,
404
-				'timeout' 		=> 60 ,
404
+				'timeout' 		=> 60,
405 405
 				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
406 406
 				// plz see: https://github.com/websharks/s2member/issues/610
407
-				'user-agent' 	=> 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
407
+				'user-agent' 	=> 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
408 408
 				'httpversion' => '1.1'
409 409
 			)
410 410
 		);
411 411
 		// then check the response
412 412
 		if (
413
-			array_key_exists( 'body', $response )
414
-			&& ! is_wp_error( $response )
415
-			&& strcmp( $response[ 'body' ], "VERIFIED" ) === 0
413
+			array_key_exists('body', $response)
414
+			&& ! is_wp_error($response)
415
+			&& strcmp($response['body'], "VERIFIED") === 0
416 416
 		) {
417 417
 			return true;
418 418
 		}
419 419
 		// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
420 420
 		// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
421
-		if( $response instanceof WP_Error ) {
421
+		if ($response instanceof WP_Error) {
422 422
 			$error_msg = sprintf(
423
-				__( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ),
423
+				__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
424 424
 				$response->get_error_code(),
425 425
 				$response->get_error_message(),
426
-				print_r( $response->get_error_data(), true )
426
+				print_r($response->get_error_data(), true)
427 427
 			);
428
-		} elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) {
429
-			$error_msg = $response[ 'body' ];
428
+		} elseif (is_array($response) && isset($response['body'])) {
429
+			$error_msg = $response['body'];
430 430
 		} else {
431
-			$error_msg = print_r( $response, true );
431
+			$error_msg = print_r($response, true);
432 432
 		}
433
-		$payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) );
434
-		$payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) );
435
-		$payment->set_status( EEM_Payment::status_id_failed );
433
+		$payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg));
434
+		$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
435
+		$payment->set_status(EEM_Payment::status_id_failed);
436 436
 		// log the results
437 437
 		$this->log(
438 438
 			array(
@@ -452,9 +452,9 @@  discard block
 block discarded – undo
452 452
 	 * @return string
453 453
 	 */
454 454
 	protected function _process_response_url() {
455
-		if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) {
455
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
456 456
 			$url = is_ssl() ? 'https://' : 'http://';
457
-			$url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' );
457
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
458 458
 			$url .= EEH_URL::filter_input_server_url();
459 459
 		} else {
460 460
 			$url = 'unknown';
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
 	 * @param EEI_Payment $payment
472 472
 	 * @throws \EE_Error
473 473
 	 */
474
-	public function update_txn_based_on_payment( $payment ) {
474
+	public function update_txn_based_on_payment($payment) {
475 475
 		$update_info = $payment->details();
476 476
 		/** @var EE_Transaction $transaction */
477 477
 		$transaction = $payment->transaction();
478
-		$payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false );
479
-		if( ! $transaction ){
478
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
479
+		if ( ! $transaction) {
480 480
 			$this->log(
481 481
 				__(
482 482
 					'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly',
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
 			);
487 487
 			return;
488 488
 		}
489
-		if(
490
-			! is_array( $update_info )
491
-			|| ! isset( $update_info[ 'mc_shipping' ] )
492
-			|| ! isset( $update_info[ 'tax' ] )
489
+		if (
490
+			! is_array($update_info)
491
+			|| ! isset($update_info['mc_shipping'])
492
+			|| ! isset($update_info['tax'])
493 493
 		) {
494 494
 			$this->log(
495 495
 				array(
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 			);
505 505
 			return;
506 506
 		}
507
-		if( $payment->status() !== $this->_pay_model->approved_status() ) {
507
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
508 508
 			$this->log(
509 509
 				array(
510 510
 					'message' => __(
@@ -523,44 +523,44 @@  discard block
 block discarded – undo
523 523
 		$transaction_total_line_item = $transaction->total_line_item();
524 524
 
525 525
 		//might paypal have changed the taxes?
526
-		if( $this->_paypal_taxes && $payment_was_itemized ) {
526
+		if ($this->_paypal_taxes && $payment_was_itemized) {
527 527
             // note that we're doing this BEFORE adding shipping;
528 528
 			// we actually want PayPal's shipping to remain non-taxable
529
-            $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
529
+            $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping');
530 530
             $this->_line_item->set_total_tax_to(
531 531
 	            $transaction_total_line_item,
532
-                (float)$update_info['tax'],
533
-                __( 'Taxes', 'event_espresso' ),
534
-                __( 'Calculated by Paypal', 'event_espresso' ),
532
+                (float) $update_info['tax'],
533
+                __('Taxes', 'event_espresso'),
534
+                __('Calculated by Paypal', 'event_espresso'),
535 535
                 'paypal_tax'
536 536
             );
537 537
             $grand_total_needs_resaving = TRUE;
538 538
 		}
539 539
 
540
-		$shipping_amount = (float)$update_info[ 'mc_shipping' ];
540
+		$shipping_amount = (float) $update_info['mc_shipping'];
541 541
 		//might paypal have added shipping?
542
-		if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){
542
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
543 543
 			$this->_line_item->add_unrelated_item(
544 544
 				$transaction_total_line_item,
545
-				sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ),
545
+				sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
546 546
 				$shipping_amount,
547 547
 				__('Shipping charges calculated by Paypal', 'event_espresso'),
548 548
 				1,
549 549
 				false,
550
-				'paypal_shipping_' . $transaction->ID()
550
+				'paypal_shipping_'.$transaction->ID()
551 551
 			);
552 552
 			$grand_total_needs_resaving = true;
553 553
 		}
554 554
 
555
-		if( $grand_total_needs_resaving ){
556
-			$transaction_total_line_item->save_this_and_descendants_to_txn( $transaction->ID() );
555
+		if ($grand_total_needs_resaving) {
556
+			$transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID());
557 557
 			/** @var EE_Registration_Processor $registration_processor */
558
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
559
-			$registration_processor->update_registration_final_prices( $transaction );
558
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
559
+			$registration_processor->update_registration_final_prices($transaction);
560 560
 		}
561 561
 		$this->log(
562 562
 			array(
563
-				'message'                     => __( 'Updated transaction related to payment', 'event_espresso' ),
563
+				'message'                     => __('Updated transaction related to payment', 'event_espresso'),
564 564
 				'url'                         => $this->_process_response_url(),
565 565
 				'transaction (updated)'       => $transaction->model_field_array(),
566 566
 				'payment (updated)'           => $payment->model_field_array(),
Please login to merge, or discard this patch.
caffeinated/payment_methods/Mijireh/EEG_Mijireh.gateway.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author				Mike Nelson
9 9
  *
10 10
  */
11
-class EEG_Mijireh extends EE_Offsite_Gateway{
11
+class EEG_Mijireh extends EE_Offsite_Gateway {
12 12
 
13 13
 	protected $_access_key;
14 14
 
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 		$primary_attendee = $primary_registrant->attendee();
38 38
 		$items = array();
39 39
 		//if we're are charging for the full amount, show the normal line items
40
-		if( $this->_can_easily_itemize_transaction_for( $payment )){
40
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
41 41
 			$total_line_item = $transaction->total_line_item();
42 42
 			$tax_total = $total_line_item->get_total_tax();
43
-			foreach($total_line_item->get_items() as $line_item){
43
+			foreach ($total_line_item->get_items() as $line_item) {
44 44
 				$items[] = array(
45 45
 					'name'=>apply_filters(
46 46
 						'FHEE__EEG_Mijireh__set_redirection_info__full_amount_line_item_name',
47
-						$this->_format_line_item_name( $line_item, $payment ),
47
+						$this->_format_line_item_name($line_item, $payment),
48 48
 						$line_item,
49 49
 						$payment,
50 50
 						$primary_registrant
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 					'quantity'=>$line_item->quantity()
55 55
 				);
56 56
 			}
57
-		}else{//its a partial payment
57
+		} else {//its a partial payment
58 58
 			$tax_total = 0;
59 59
 			//partial payment, so just add 1 item
60 60
 			$items[] = array(
61 61
 				'name'=> apply_filters(
62 62
 					'FHEE__EEG_Mijireh__set_redirection_info__partial_amount_line_item_name',
63
-					$this->_format_partial_payment_line_item_name( $payment ),
63
+					$this->_format_partial_payment_line_item_name($payment),
64 64
 					$payment,
65 65
 					$primary_registrant
66 66
 				),
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
 		$order = array(
73 73
 			'total'=>$this->format_currency($payment->amount()),
74 74
 			'return_url'=>$return_url,
75
-			'items'=>$this->_prepare_for_mijireh( $items ),
75
+			'items'=>$this->_prepare_for_mijireh($items),
76 76
 			'email'=>$primary_attendee->email(),
77 77
 			'first_name'=>$primary_attendee->fname(),
78 78
 			'last_name'=>$primary_attendee->lname(),
79 79
 			'tax'=>$this->format_currency($tax_total),
80 80
 			'partner_id'=>'ee');
81 81
 		//setup address?
82
-		if(		$primary_attendee->address()  &&
83
-				$primary_attendee->city()  &&
84
-				$primary_attendee->state_ID()  &&
85
-				$primary_attendee->country_ID()  &&
86
-				$primary_attendee->zip()  ){
82
+		if ($primary_attendee->address() &&
83
+				$primary_attendee->city() &&
84
+				$primary_attendee->state_ID() &&
85
+				$primary_attendee->country_ID() &&
86
+				$primary_attendee->zip()) {
87 87
 			$shipping_address = array(
88 88
 				'first_name'=>$primary_attendee->fname(),
89 89
 				'last_name'=>$primary_attendee->lname(),
@@ -93,62 +93,62 @@  discard block
 block discarded – undo
93 93
 				'zip_code' => $primary_attendee->zip(),
94 94
 				'country' => $primary_attendee->country_ID()
95 95
 			);
96
-			if( $primary_attendee->address2() ){
97
-				$shipping_address[ 'apt_suite' ] = $primary_attendee->address2();
96
+			if ($primary_attendee->address2()) {
97
+				$shipping_address['apt_suite'] = $primary_attendee->address2();
98 98
 			}
99
-			if( $primary_attendee->phone() ){
100
-				$shipping_address[ 'phone' ] = $primary_attendee->phone();
99
+			if ($primary_attendee->phone()) {
100
+				$shipping_address['phone'] = $primary_attendee->phone();
101 101
 			}
102
-			$order[ 'shipping_address' ] = $shipping_address;
102
+			$order['shipping_address'] = $shipping_address;
103 103
 		}
104
-		$order = apply_filters( 'FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant );
105
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)) );
104
+		$order = apply_filters('FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant);
105
+		do_action('AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)));
106 106
 		$args = array(
107 107
 			'headers' => array(
108
-				'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ),
108
+				'Authorization' => 'Basic '.base64_encode($this->_access_key.':'),
109 109
 				'Accept'=>'application/json'
110 110
 			),
111 111
 			'body'=>  json_encode($order)
112 112
 		);
113
-		$response = wp_remote_post( $this->_mijireh_api_orders_url, $args );
113
+		$response = wp_remote_post($this->_mijireh_api_orders_url, $args);
114 114
                 $problems_string = false;
115
-		$this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment);
116
-		if( ! $response instanceof WP_Error ){
115
+		$this->log(array('get checkout url request_args' => $args, 'response' => $response), $payment);
116
+		if ( ! $response instanceof WP_Error) {
117 117
 			$response_body = json_decode($response['body']);
118
-			if($response_body && isset($response_body->checkout_url)){
118
+			if ($response_body && isset($response_body->checkout_url)) {
119 119
                             $payment->set_redirect_url($response_body->checkout_url);
120 120
                             $payment->set_txn_id_chq_nmbr($response_body->order_number);
121 121
                             $payment->set_details($response['body']);
122 122
 			} else {
123
-                           if( is_array( $response_body ) || is_object( $response_body)){
124
-                                    $response_body_as_array = (array)$response_body;
125
-                                    foreach($response_body_as_array as $problem_parameter => $problems){
126
-                                            $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems));
123
+                           if (is_array($response_body) || is_object($response_body)) {
124
+                                    $response_body_as_array = (array) $response_body;
125
+                                    foreach ($response_body_as_array as $problem_parameter => $problems) {
126
+                                            $problems_string .= sprintf(__('\nProblems with %s: %s', 'event_espresso'), $problem_parameter, implode(", ", $problems));
127 127
                                     }
128
-                            }else{
128
+                            } else {
129 129
                                     $problems_string = $response['body'];
130 130
                             }
131
-                            if( ! $problems_string ) {
131
+                            if ( ! $problems_string) {
132 132
                                 //no message to show? wack
133
-                                if( isset( $response[ 'headers' ][ 'status' ] ) ){
134
-                                        $problems_string = $response[ 'headers' ][ 'status' ];
135
-                                }else{
136
-                                        $problems_string = __( 'No response from Mijireh', 'event_espresso' );
133
+                                if (isset($response['headers']['status'])) {
134
+                                        $problems_string = $response['headers']['status'];
135
+                                } else {
136
+                                        $problems_string = __('No response from Mijireh', 'event_espresso');
137 137
                                 }
138 138
                             }
139 139
                         }
140
-		}else{
141
-                    $problems_string = implode( ",", $response->get_error_messages() );
140
+		} else {
141
+                    $problems_string = implode(",", $response->get_error_messages());
142 142
 		}
143 143
                 
144
-                if( $problems_string ) {
145
-                    $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) );
146
-                    $payment->set_details( $response );
147
-                    $payment->set_redirect_url( null );
144
+                if ($problems_string) {
145
+                    $payment->set_gateway_response(sprintf(__('Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string));
146
+                    $payment->set_details($response);
147
+                    $payment->set_redirect_url(null);
148 148
                     //even though the payment's status is failed at this point anyways,
149 149
                     //let's be explicit about it. The fact that the redirect url is null
150 150
                     //should be enough to client code that they can't redirect the user
151
-                    $payment->set_status( $this->_pay_model->failed_status() );
151
+                    $payment->set_status($this->_pay_model->failed_status());
152 152
                 }
153 153
 		return $payment;
154 154
 	}
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 	 * @param mixed $data
162 162
 	 * @return mixed same type as $data
163 163
 	 */
164
-	private function _prepare_for_mijireh( $data ){
165
-		if( is_array( $data ) ){
164
+	private function _prepare_for_mijireh($data) {
165
+		if (is_array($data)) {
166 166
 			$prepared_data = array();
167
-			foreach($data as $key => $datum ){
168
-				$prepared_data[ $key ] = $this->_prepare_for_mijireh( $datum );
167
+			foreach ($data as $key => $datum) {
168
+				$prepared_data[$key] = $this->_prepare_for_mijireh($datum);
169 169
 			}
170 170
 			return $prepared_data;
171
-		}elseif(is_string( $data ) ){
172
-			return str_replace( '%', 'percent', $data );
173
-		}else{
171
+		}elseif (is_string($data)) {
172
+			return str_replace('%', 'percent', $data);
173
+		} else {
174 174
 			return $data;
175 175
 		}
176 176
 	}
@@ -191,30 +191,30 @@  discard block
 block discarded – undo
191 191
 
192 192
 		$payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL;
193 193
 
194
-		if ( ! $payment instanceof EEI_Payment ){
195
-			throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) );
194
+		if ( ! $payment instanceof EEI_Payment) {
195
+			throw new EE_Error(sprintf(__("Could not find Mijireh payment for transaction %s", 'event_espresso'), $transaction->ID()));
196 196
 		}
197 197
 
198 198
 		$request_args = array(
199 199
 			'headers' => array(
200
-				'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ),
200
+				'Authorization' => 'Basic '.base64_encode($this->_access_key.':'),
201 201
 				'Accept'=>'application/json'
202 202
 			)
203 203
 		);
204 204
 
205 205
 		$response = wp_remote_get(
206
-			$this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(),
206
+			$this->_mijireh_api_orders_url.'/'.$payment->txn_id_chq_nmbr(),
207 207
 			$request_args
208 208
 		);
209 209
 
210 210
 		$this->log(
211
-			array( 'get payment status request_args' => $request_args, 'response' => $response ),
211
+			array('get payment status request_args' => $request_args, 'response' => $response),
212 212
 			$payment
213 213
 		);
214 214
 		// validate response
215
-		$response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : '';
216
-		if( $response && $response_body ){
217
-			switch( $response_body->status ){
215
+		$response_body = isset($response['body']) ? json_decode($response['body']) : '';
216
+		if ($response && $response_body) {
217
+			switch ($response_body->status) {
218 218
 				case 'paid':
219 219
 					$payment->set_status($this->_pay_model->approved_status());
220 220
 					break;
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 			}
227 227
 
228 228
 		} else {
229
-			$payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) );
230
-			$payment->set_details( $response );
231
-			$payment->set_status( $this->_pay_model->failed_status() );
229
+			$payment->set_gateway_response(__('Response from Mijireh could not be understood.', 'event_espresso'));
230
+			$payment->set_details($response);
231
+			$payment->set_status($this->_pay_model->failed_status());
232 232
 		}
233 233
 		// the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage
234 234
 //		$payment->set_status( $this->_pay_model->pending_status() );
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 /**
6 7
  * Event Espresso
7 8
  *
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Aim extends EE_Onsite_Gateway{
28
+class EEG_Aim extends EE_Onsite_Gateway {
29 29
 
30 30
 	const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; //Authnet URL
31 31
 
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	 * @param EEG_Aim $gateway_object
158 158
 	 * @return string
159 159
 	 */
160
-	public function possibly_use_deprecated_aim_server( $url, EEG_Aim $gateway_object ) {
161
-		if(  $gateway_object->_server === 'authorize.net'
162
-			&& ! $gateway_object->_debug_mode ) {
160
+	public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) {
161
+		if ($gateway_object->_server === 'authorize.net'
162
+			&& ! $gateway_object->_debug_mode) {
163 163
 			return 'https://secure.authorize.net/gateway/transact.dll';
164 164
 		} else {
165 165
 			return $url;
@@ -182,33 +182,33 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 
184 184
 	public function do_direct_payment($payment, $billing_info = null) {
185
-			add_filter( 'FHEE__EEG_Aim___get_server_url', array( $this, 'possibly_use_deprecated_aim_server' ), 10, 2 );
185
+			add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2);
186 186
 			// Enable test mode if needed
187 187
 			//4007000000027  <-- test successful visa
188 188
 			//4222222222222  <-- test failure card number
189 189
 
190 190
 			$item_num = 1;
191 191
 			$transaction = $payment->transaction();
192
-			$order_description = $this->_format_order_description( $payment );
192
+			$order_description = $this->_format_order_description($payment);
193 193
 			$primary_registrant = $transaction->primary_registration();
194 194
 			//if we're are charging for the full amount, show the normal line items
195 195
 			//and the itemized total adds up properly
196
-			if( $this->_can_easily_itemize_transaction_for( $payment ) ){
196
+			if ($this->_can_easily_itemize_transaction_for($payment)) {
197 197
 				$total_line_item = $transaction->total_line_item();
198 198
 				foreach ($total_line_item->get_items() as $line_item) {
199
-					if( $line_item->quantity() == 0 ){
199
+					if ($line_item->quantity() == 0) {
200 200
 						continue;
201 201
 					}
202 202
 					$this->addLineItem(
203 203
 						$item_num++, 
204
-						$this->_format_line_item_name( $line_item, $payment ), 
205
-						$this->_format_line_item_desc( $line_item, $payment ), 
204
+						$this->_format_line_item_name($line_item, $payment), 
205
+						$this->_format_line_item_desc($line_item, $payment), 
206 206
 						$line_item->quantity(),
207 207
 						$line_item->unit_price(), 
208 208
 						'N');
209 209
 					$order_description .= $line_item->desc().', ';
210 210
 				}
211
-				foreach($total_line_item->tax_descendants() as $tax_line_item){
211
+				foreach ($total_line_item->tax_descendants() as $tax_line_item) {
212 212
 					$this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N');
213 213
 				}
214 214
 			}
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
 			//start transaction
220 220
 			//if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
221 221
 			$partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
222
-			$this->setField( 'solution_id', $partner_id );
222
+			$this->setField('solution_id', $partner_id);
223 223
 			$this->setField('amount', $this->format_currency($payment->amount()));
224
-			$this->setField('description',substr(rtrim($order_description, ', '), 0, 255));
225
-			$this->_set_sensitive_billing_data( $billing_info );
224
+			$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
225
+			$this->_set_sensitive_billing_data($billing_info);
226 226
 			$this->setField('first_name', $billing_info['first_name']);
227 227
 			$this->setField('last_name', $billing_info['last_name']);
228 228
 			$this->setField('email', $billing_info['email']);
229 229
 			$this->setField('company', $billing_info['company']);
230 230
 			$this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
231 231
 			$this->setField('city', $billing_info['city']);
232
-			$this->setField('state', $billing_info['state'] );
233
-			$this->setField('country', $billing_info['country'] );
232
+			$this->setField('state', $billing_info['state']);
233
+			$this->setField('country', $billing_info['country']);
234 234
 			$this->setField('zip', $billing_info['zip']);
235 235
 			$this->setField('fax', $billing_info['fax']);
236 236
 			$this->setField('cust_id', $primary_registrant->ID());
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 			//invoice_num would be nice to have it be unique per SPCO page-load, that way if users
239 239
 			//press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
240 240
 			//in which case, we need to generate teh invoice num per request right here...
241
-			$this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
241
+			$this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
242 242
 			//tell AIM that any duplicates sent in the next 5 minutes are to be ignored
243
-            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS );
243
+            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
244 244
 
245 245
 
246 246
 			if ($this->_test_transactions) {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			//Capture response
251 251
 			$this->type = "AUTH_CAPTURE";
252 252
 			$response = $this->_sendRequest($payment);
253
-			if (!empty($response)){
253
+			if ( ! empty($response)) {
254 254
 				if ($this->_debug_mode) {
255 255
 					$txn_id = $response->invoice_number;
256 256
 				} else {
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
 				$payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status();
260 260
 				$payment->set_status($payment_status);
261 261
 				//make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
262
-				$payment->set_amount( (float) $response->amount );
263
-				$payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code));
264
-				$payment->set_txn_id_chq_nmbr( $txn_id );
262
+				$payment->set_amount((float) $response->amount);
263
+				$payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code));
264
+				$payment->set_txn_id_chq_nmbr($txn_id);
265 265
 				$payment->set_extra_accntng($primary_registrant->reg_code());
266
-				$payment->set_details(print_r($response,true));
266
+				$payment->set_details(print_r($response, true));
267 267
 			} else {
268 268
 				$payment->set_status($this->_pay_model->failed_status());
269 269
 				$payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
270
-				$payment->set_details(print_r($response,true));
270
+				$payment->set_details(print_r($response, true));
271 271
 			}
272 272
 		return $payment;
273 273
 	}
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * what billing data gets sent
279 279
 	 * @param array $billing_info
280 280
 	 */
281
-	protected function _set_sensitive_billing_data( $billing_info ) {
281
+	protected function _set_sensitive_billing_data($billing_info) {
282 282
 		$this->setField('card_num', $billing_info['credit_card']);
283 283
 		$this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']);
284 284
 		$this->setField('card_code', $billing_info['cvv']);
@@ -337,22 +337,22 @@  discard block
 block discarded – undo
337 337
 		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
338 338
 		$x_keys = array();
339 339
 		foreach ($this->_x_post_fields as $key => $value) {
340
-			$x_keys[] = "x_$key=" . urlencode($value);
340
+			$x_keys[] = "x_$key=".urlencode($value);
341 341
 		}
342 342
 		// Add line items
343 343
 		foreach ($this->_additional_line_items as $key => $value) {
344
-			$x_keys[] =  "x_line_item=" . urlencode($value);
344
+			$x_keys[] = "x_line_item=".urlencode($value);
345 345
 		}
346 346
 		$this->_log_clean_request($x_keys, $payment);
347 347
 		$post_url = $this->_get_server_url();
348 348
 		$curl_request = curl_init($post_url);
349
-		curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys));
349
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys));
350 350
 		curl_setopt($curl_request, CURLOPT_HEADER, 0);
351 351
 		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
352 352
 		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
353 353
 		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
354 354
 		if ($this->VERIFY_PEER) {
355
-			curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem');
355
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem');
356 356
 		} else {
357 357
 			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
358 358
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		$response = curl_exec($curl_request);
365 365
 
366 366
 		curl_close($curl_request);
367
-		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
367
+		$response_obj = new EE_AuthorizeNetAIM_Response($response);
368 368
 
369 369
 		return $this->_log_and_clean_response($response_obj, $payment);
370 370
 	}
@@ -373,18 +373,18 @@  discard block
 block discarded – undo
373 373
 	 * @param array $request_array
374 374
 	 * @param EEI_Payment $payment
375 375
 	 */
376
-	protected function _log_clean_request($request_array,$payment){
377
-		$keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' );
378
-		foreach($request_array as $index => $keyvaltogether ) {
379
-			foreach( $keys_to_filter_out as $key ) {
380
-				if( strpos( $keyvaltogether, $key ) === 0 ){
376
+	protected function _log_clean_request($request_array, $payment) {
377
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
378
+		foreach ($request_array as $index => $keyvaltogether) {
379
+			foreach ($keys_to_filter_out as $key) {
380
+				if (strpos($keyvaltogether, $key) === 0) {
381 381
 					//found it at the first character
382 382
 					//so its one of them
383
-					unset( $request_array[ $index ] );
383
+					unset($request_array[$index]);
384 384
 				}
385 385
 			}
386 386
 		}
387
-		$this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment);
387
+		$this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment);
388 388
 	}
389 389
 
390 390
 
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
 	 * @param EE_Payment                  $payment
397 397
 	 * @return \EE_AuthorizeNetAIM_Response
398 398
 	 */
399
-	private function _log_and_clean_response($response_obj,$payment){
399
+	private function _log_and_clean_response($response_obj, $payment) {
400 400
 		$response_obj->account_number = '';
401
-		$this->log(array('AIM Response received:'=>$response_obj),$payment);
401
+		$this->log(array('AIM Response received:'=>$response_obj), $payment);
402 402
 		return $response_obj;
403 403
 	}
404 404
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 			// Split Array
498 498
 			$this->response = $response;
499 499
 			if ($encap_char) {
500
-				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
500
+				$this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
501 501
 			} else {
502 502
 				$this->_response_array = explode($delimiter, $response);
503 503
 			}
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 			$this->held = ($this->response_code === self::HELD);
568 568
 
569 569
 			if ($this->error || $this->declined || $this->held) {
570
-				$this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> ';
570
+				$this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> ';
571 571
 
572 572
 
573 573
 				/* $this->error_message = "AuthorizeNet Error:
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 
587 587
 }
588 588
 
589
-if ( ! class_exists( 'AuthorizeNetException' ) ) {
589
+if ( ! class_exists('AuthorizeNetException')) {
590 590
 	/**
591 591
 	 * Class AuthorizeNetException
592 592
 	 *
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
 		 * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
603 603
 		 * @since 5.1.0
604 604
 		 */
605
-		public function __construct( $message = "", $code = 0, Exception $previous = null ) {
606
-			parent::__construct( $message, $code, $previous );
605
+		public function __construct($message = "", $code = 0, Exception $previous = null) {
606
+			parent::__construct($message, $code, $previous);
607 607
 		}
608 608
 	}
609 609
 }
Please login to merge, or discard this patch.
core/EE_Payment_Processor.core.php 2 patches
Indentation   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class EE_Payment_Processor extends EE_Processor_Base {
15 15
 	/**
16
-     * 	@var EE_Payment_Processor $_instance
16
+	 * 	@var EE_Payment_Processor $_instance
17 17
 	 * 	@access 	private
18
-     */
18
+	 */
19 19
 	private static $_instance;
20 20
 
21 21
 
@@ -51,7 +51,6 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately.
53 53
 	 * Saves the payment that is generated
54
-
55 54
 	 *
56 55
 *@param EE_Payment_Method    $payment_method
57 56
 	 * @param EE_Transaction       $transaction
@@ -131,7 +130,6 @@  discard block
 block discarded – undo
131 130
 
132 131
 
133 132
 	/**
134
-
135 133
 	 * @param EE_Transaction|int $transaction
136 134
 	 * @param EE_Payment_Method $payment_method
137 135
 	 * @throws EE_Error
@@ -694,12 +692,12 @@  discard block
 block discarded – undo
694 692
 	}
695 693
 	
696 694
 	/**
697
- 	 * Force posts to PayPal to use TLS v1.2. See:
698
- 	 * https://core.trac.wordpress.org/ticket/36320
699
- 	 * https://core.trac.wordpress.org/ticket/34924#comment:15
700
- 	 * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
695
+	 * Force posts to PayPal to use TLS v1.2. See:
696
+	 * https://core.trac.wordpress.org/ticket/36320
697
+	 * https://core.trac.wordpress.org/ticket/34924#comment:15
698
+	 * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
701 699
 	 * This will affect paypal standard, pro, express, and payflow.
702
- 	 */
700
+	 */
703 701
  	public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) {
704 702
  		if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) {
705 703
 			//Use the value of the constant CURL_SSLVERSION_TLSv1 = 1
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 /**
4 4
  *
5 5
  * EE_Payment_Processor
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function instance() {
29 29
 		// check if class object is instantiated
30
-		if ( ! self::$_instance instanceof EE_Payment_Processor ) {
30
+		if ( ! self::$_instance instanceof EE_Payment_Processor) {
31 31
 			self::$_instance = new self();
32 32
 		}
33 33
 		return self::$_instance;
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 *@access private
42 42
 	 */
43 43
 	private function __construct() {
44
-		do_action( 'AHEE__EE_Payment_Processor__construct' );
45
-		add_action( 'http_api_curl', array( $this, '_curl_requests_to_paypal_use_tls' ), 10, 3 );
44
+		do_action('AHEE__EE_Payment_Processor__construct');
45
+		add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3);
46 46
 	}
47 47
 
48 48
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$update_txn = true,
82 82
 		$cancel_url = ''
83 83
 	) {
84
-		if( (float)$amount < 0 ) {
84
+		if ((float) $amount < 0) {
85 85
 			throw new EE_Error(
86 86
 				sprintf(
87 87
 					__(
@@ -94,33 +94,33 @@  discard block
 block discarded – undo
94 94
 			);
95 95
 		}
96 96
 		// verify payment method
97
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE );
97
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE);
98 98
 		// verify transaction
99
-		EEM_Transaction::instance()->ensure_is_obj( $transaction );
100
-		$transaction->set_payment_method_ID( $payment_method->ID() );
99
+		EEM_Transaction::instance()->ensure_is_obj($transaction);
100
+		$transaction->set_payment_method_ID($payment_method->ID());
101 101
 		// verify payment method type
102
-		if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
102
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
103 103
 			$payment = $payment_method->type_obj()->process_payment(
104 104
 				$transaction,
105
-				min( $amount, $transaction->remaining() ),//make sure we don't overcharge
105
+				min($amount, $transaction->remaining()), //make sure we don't overcharge
106 106
 				$billing_form,
107 107
 				$return_url,
108
-				add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ),
108
+				add_query_arg(array('ee_cancel_payment' => true), $cancel_url),
109 109
 				$method,
110 110
 				$by_admin
111 111
 			);
112 112
 			// check if payment method uses an off-site gateway
113
-			if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) {
113
+			if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) {
114 114
 				// don't process payments for off-site gateways yet because no payment has occurred yet
115
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
115
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
116 116
 			}
117 117
 			return $payment;
118 118
 		} else {
119 119
 			EE_Error::add_error(
120 120
 				sprintf(
121
-					__( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
121
+					__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
122 122
 					'<br/>',
123
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
123
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
124 124
 				), __FILE__, __FUNCTION__, __LINE__
125 125
 			);
126 126
 			return NULL;
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	 * @throws EE_Error
137 137
 	 * @return string
138 138
 	 */
139
-	public function get_ipn_url_for_payment_method( $transaction, $payment_method ){
139
+	public function get_ipn_url_for_payment_method($transaction, $payment_method) {
140 140
 		/** @type \EE_Transaction $transaction */
141
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
141
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
142 142
 		$primary_reg = $transaction->primary_registration();
143
-		if( ! $primary_reg instanceof EE_Registration ){
143
+		if ( ! $primary_reg instanceof EE_Registration) {
144 144
 			throw new EE_Error(
145 145
 				sprintf(
146 146
 					__(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 				)
152 152
 			);
153 153
 		}
154
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true);
154
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
155 155
 		$url = add_query_arg(
156 156
 			array(
157 157
 				'e_reg_url_link'=>$primary_reg->reg_url_link(),
@@ -188,92 +188,92 @@  discard block
 block discarded – undo
188 188
 		$update_txn = true,
189 189
 		$separate_IPN_request = true
190 190
 	) {
191
-		EE_Registry::instance()->load_model( 'Change_Log' );
192
-		$_req_data = $this->_remove_unusable_characters_from_array( (array)$_req_data );
193
-		EE_Processor_Base::set_IPN( $separate_IPN_request );
191
+		EE_Registry::instance()->load_model('Change_Log');
192
+		$_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data);
193
+		EE_Processor_Base::set_IPN($separate_IPN_request);
194 194
 		$obj_for_log = null;
195
-		if( $transaction instanceof EE_Transaction ){
195
+		if ($transaction instanceof EE_Transaction) {
196 196
 			$obj_for_log = $transaction;
197
-			if( $payment_method instanceof EE_Payment_Method ) {
197
+			if ($payment_method instanceof EE_Payment_Method) {
198 198
 				$obj_for_log = EEM_Payment::instance()->get_one(
199 199
 					array(
200
-						array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ),
201
-						'order_by' => array( 'PAY_timestamp' => 'desc' )
200
+						array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()),
201
+						'order_by' => array('PAY_timestamp' => 'desc')
202 202
 					)
203 203
 				);
204 204
 			}
205
-		} else if( $payment_method instanceof EE_Payment ) {
205
+		} else if ($payment_method instanceof EE_Payment) {
206 206
 			$obj_for_log = $payment_method;
207 207
 		}
208 208
 		$log = EEM_Change_Log::instance()->log(
209 209
 			EEM_Change_Log::type_gateway,
210
-			array( 'IPN data received' => $_req_data ),
210
+			array('IPN data received' => $_req_data),
211 211
 			$obj_for_log
212 212
 		);
213
-		try{
213
+		try {
214 214
 			/**
215 215
 			 * @var EE_Payment $payment
216 216
 			 */
217 217
 			$payment = NULL;
218
-			if($transaction && $payment_method){
218
+			if ($transaction && $payment_method) {
219 219
 				/** @type EE_Transaction $transaction */
220 220
 				$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
221 221
 				/** @type EE_Payment_Method $payment_method */
222 222
 				$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
223
-				if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
224
-						$payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction );
223
+				if ($payment_method->type_obj() instanceof EE_PMT_Base) {
224
+						$payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
225 225
 						$log->set_object($payment);
226 226
 				} else {
227 227
 					// not a payment
228 228
 					EE_Error::add_error(
229 229
 						sprintf(
230
-							__( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ),
230
+							__('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'),
231 231
 							'<br/>',
232
-							EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
232
+							EE_Registry::instance()->CFG->organization->get_pretty('email')
233 233
 						),
234 234
 						__FILE__, __FUNCTION__, __LINE__
235 235
 					);
236 236
 				}
237
-			}else{
237
+			} else {
238 238
 				//that's actually pretty ok. The IPN just wasn't able
239 239
 				//to identify which transaction or payment method this was for
240 240
 				// give all active payment methods a chance to claim it
241 241
 				$active_payment_methods = EEM_Payment_Method::instance()->get_all_active();
242
-				foreach( $active_payment_methods as $active_payment_method ){
243
-					try{
244
-						$payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data );
242
+				foreach ($active_payment_methods as $active_payment_method) {
243
+					try {
244
+						$payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data);
245 245
 						$payment_method = $active_payment_method;
246 246
 						EEM_Change_Log::instance()->log(
247 247
 							EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment
248 248
 						);
249 249
 						break;
250
-					} catch( EE_Error $e ) {
250
+					} catch (EE_Error $e) {
251 251
 						//that's fine- it apparently couldn't handle the IPN
252 252
 					}
253 253
 				}
254 254
 
255 255
 			}
256 256
 // 			EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method);
257
-			if( $payment instanceof EE_Payment){
257
+			if ($payment instanceof EE_Payment) {
258 258
 				$payment->save();
259 259
 				//  update the TXN
260
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request );
261
-			}else{
260
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request);
261
+			} else {
262 262
 				//we couldn't find the payment for this IPN... let's try and log at least SOMETHING
263
-				if($payment_method){
263
+				if ($payment_method) {
264 264
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method);
265
-				}elseif($transaction){
265
+				}elseif ($transaction) {
266 266
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction);
267 267
 				}
268 268
 			}
269 269
 			return $payment;
270 270
 
271
-		} catch( EE_Error $e ) {
271
+		} catch (EE_Error $e) {
272 272
 			do_action(
273 273
 				'AHEE__log', __FILE__, __FUNCTION__, sprintf(
274
-					__( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ),
275
-					print_r( $transaction, TRUE ),
276
-					print_r( $_req_data, TRUE ),
274
+					__('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'),
275
+					print_r($transaction, TRUE),
276
+					print_r($_req_data, TRUE),
277 277
 					$e->getMessage()
278 278
 				)
279 279
 			);
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 	 * @param  array $request_data
289 289
 	 * @return array
290 290
 	 */
291
-	protected function _remove_unusable_characters_from_array( array $request_data ) {
291
+	protected function _remove_unusable_characters_from_array(array $request_data) {
292 292
 		$return_data = array();
293
-		foreach( $request_data as $key => $value ) {
294
-			$return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value );
293
+		foreach ($request_data as $key => $value) {
294
+			$return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value);
295 295
 		}
296 296
 		return $return_data;
297 297
 	}
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param string $request_data
304 304
 	 * @return string
305 305
 	 */
306
-	protected function _remove_unusable_characters( $request_data ) {
307
-		return preg_replace( '/[^[:print:]]/', '', $request_data );
306
+	protected function _remove_unusable_characters($request_data) {
307
+		return preg_replace('/[^[:print:]]/', '', $request_data);
308 308
 	}
309 309
 
310 310
 
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 	 * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO,
327 327
 	 *                                      to call handle_ipn() for offsite gateways that don't receive separate IPNs
328 328
 	 */
329
-	public function finalize_payment_for( $transaction, $update_txn = TRUE ){
329
+	public function finalize_payment_for($transaction, $update_txn = TRUE) {
330 330
 		/** @var $transaction EE_Transaction */
331
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
331
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
332 332
 		$last_payment_method = $transaction->payment_method();
333
-		if ( $last_payment_method instanceof EE_Payment_Method ) {
334
-			$payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction );
335
-			$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
333
+		if ($last_payment_method instanceof EE_Payment_Method) {
334
+			$payment = $last_payment_method->type_obj()->finalize_payment_for($transaction);
335
+			$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
336 336
 			return $payment;
337 337
 		} else {
338 338
 			return NULL;
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 		EE_Payment $payment_to_refund,
356 356
 		$refund_info = array()
357 357
 	) {
358
-		if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) {
359
-			$payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info );
360
-			$this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund );
358
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) {
359
+			$payment_method->type_obj()->process_refund($payment_to_refund, $refund_info);
360
+			$this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund);
361 361
 		}
362 362
 		return $payment_to_refund;
363 363
 	}
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 	 *                        TXN is locked before updating
399 399
 	 * @throws \EE_Error
400 400
 	 */
401
-	public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){
401
+	public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) {
402 402
 		$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful';
403 403
 		/** @type EE_Transaction $transaction */
404
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
404
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
405 405
 		// can we freely update the TXN at this moment?
406
-		if ( $IPN && $transaction->is_locked() ) {
406
+		if ($IPN && $transaction->is_locked()) {
407 407
 			// don't update the transaction at this exact moment
408 408
 			// because the TXN is active in another request
409 409
 			EE_Cron_Tasks::schedule_update_transaction_with_payment(
@@ -413,38 +413,38 @@  discard block
 block discarded – undo
413 413
 			);
414 414
 		} else {
415 415
 			// verify payment and that it has been saved
416
-			if ( $payment instanceof EE_Payment && $payment->ID() ) {
417
-				if(
416
+			if ($payment instanceof EE_Payment && $payment->ID()) {
417
+				if (
418 418
 					$payment->payment_method() instanceof EE_Payment_Method
419 419
 					&& $payment->payment_method()->type_obj() instanceof EE_PMT_Base
420
-				){
421
-					$payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment );
420
+				) {
421
+					$payment->payment_method()->type_obj()->update_txn_based_on_payment($payment);
422 422
 					// update TXN registrations with payment info
423
-					$this->process_registration_payments( $transaction, $payment );
423
+					$this->process_registration_payments($transaction, $payment);
424 424
 				}
425 425
 				$do_action = $payment->just_approved()
426 426
 					? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful'
427 427
 					: $do_action;
428 428
 			} else {
429 429
 				// send out notifications
430
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
430
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
431 431
 				$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made';
432 432
 			}
433
-			if ( $payment->status() !== EEM_Payment::status_id_failed ) {
433
+			if ($payment->status() !== EEM_Payment::status_id_failed) {
434 434
 				/** @type EE_Transaction_Payments $transaction_payments */
435
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
435
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
436 436
 				// set new value for total paid
437
-				$transaction_payments->calculate_total_payments_and_update_status( $transaction );
437
+				$transaction_payments->calculate_total_payments_and_update_status($transaction);
438 438
 				// call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ???
439
-				if ( $update_txn ) {
440
-					$this->_post_payment_processing( $transaction, $payment, $IPN );
439
+				if ($update_txn) {
440
+					$this->_post_payment_processing($transaction, $payment, $IPN);
441 441
 				}
442 442
 			}
443 443
 			// granular hook for others to use.
444
-			do_action( $do_action, $transaction, $payment );
445
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' );
444
+			do_action($do_action, $transaction, $payment);
445
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action');
446 446
 			//global hook for others to use.
447
-			do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment );
447
+			do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment);
448 448
 		}
449 449
 	}
450 450
 
@@ -464,25 +464,25 @@  discard block
 block discarded – undo
464 464
 		$registrations = array()
465 465
 	) {
466 466
 		// only process if payment was successful
467
-		if ( $payment->status() !== EEM_Payment::status_id_approved ) {
467
+		if ($payment->status() !== EEM_Payment::status_id_approved) {
468 468
 			return;
469 469
 		}
470 470
 		//EEM_Registration::instance()->show_next_x_db_queries();
471
-		if ( empty( $registrations )) {
471
+		if (empty($registrations)) {
472 472
 			// find registrations with monies owing that can receive a payment
473 473
 			$registrations = $transaction->registrations(
474 474
 				array(
475 475
 					array(
476 476
 						// only these reg statuses can receive payments
477
-						'STS_ID'           => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ),
478
-						'REG_final_price'  => array( '!=', 0 ),
479
-						'REG_final_price*' => array( '!=', 'REG_paid', true ),
477
+						'STS_ID'           => array('IN', EEM_Registration::reg_statuses_that_allow_payment()),
478
+						'REG_final_price'  => array('!=', 0),
479
+						'REG_final_price*' => array('!=', 'REG_paid', true),
480 480
 					)
481 481
 				)
482 482
 			);
483 483
 		}
484 484
 		// still nothing ??!??
485
-		if ( empty( $registrations )) {
485
+		if (empty($registrations)) {
486 486
 			return;
487 487
 		}
488 488
 		// todo: break out the following logic into a separate strategy class
@@ -494,28 +494,28 @@  discard block
 block discarded – undo
494 494
 
495 495
 		$refund = $payment->is_a_refund();
496 496
 		// how much is available to apply to registrations?
497
-		$available_payment_amount = abs( $payment->amount() );
498
-		foreach ( $registrations as $registration ) {
499
-			if ( $registration instanceof EE_Registration ) {
497
+		$available_payment_amount = abs($payment->amount());
498
+		foreach ($registrations as $registration) {
499
+			if ($registration instanceof EE_Registration) {
500 500
 				// nothing left?
501
-				if ( $available_payment_amount <= 0 ) {
501
+				if ($available_payment_amount <= 0) {
502 502
 					break;
503 503
 				}
504
-				if ( $refund ) {
505
-					$available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount );
504
+				if ($refund) {
505
+					$available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount);
506 506
 				} else {
507
-					$available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount );
507
+					$available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount);
508 508
 				}
509 509
 			}
510 510
 		}
511
-		if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) {
511
+		if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) {
512 512
 			EE_Error::add_attention(
513 513
 				sprintf(
514
-					__( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ),
515
-					EEH_Template::format_currency( $available_payment_amount ),
516
-					implode( ', ',  array_keys( $registrations ) ),
514
+					__('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'),
515
+					EEH_Template::format_currency($available_payment_amount),
516
+					implode(', ', array_keys($registrations)),
517 517
 					'<br/>',
518
-					EEH_Template::format_currency( $payment->amount() )
518
+					EEH_Template::format_currency($payment->amount())
519 519
 				),
520 520
 				__FILE__, __FUNCTION__, __LINE__
521 521
 			);
@@ -533,17 +533,17 @@  discard block
 block discarded – undo
533 533
 	 * @return float
534 534
 	 * @throws \EE_Error
535 535
 	 */
536
-	public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) {
536
+	public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) {
537 537
 		$owing = $registration->final_price() - $registration->paid();
538
-		if ( $owing > 0 ) {
538
+		if ($owing > 0) {
539 539
 			// don't allow payment amount to exceed the available payment amount, OR the amount owing
540
-			$payment_amount = min( $available_payment_amount, $owing );
540
+			$payment_amount = min($available_payment_amount, $owing);
541 541
 			// update $available_payment_amount
542 542
 			$available_payment_amount -= $payment_amount;
543 543
 			//calculate and set new REG_paid
544
-			$registration->set_paid( $registration->paid() + $payment_amount );
544
+			$registration->set_paid($registration->paid() + $payment_amount);
545 545
 			// now save it
546
-			$this->_apply_registration_payment( $registration, $payment, $payment_amount );
546
+			$this->_apply_registration_payment($registration, $payment, $payment_amount);
547 547
 		}
548 548
 		return $available_payment_amount;
549 549
 	}
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
 	 * @return void
560 560
 	 * @throws \EE_Error
561 561
 	 */
562
-	protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) {
562
+	protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) {
563 563
 		// find any existing reg payment records for this registration and payment
564 564
 		$existing_reg_payment = EEM_Registration_Payment::instance()->get_one(
565
-			array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) )
565
+			array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID()))
566 566
 		);
567 567
 		// if existing registration payment exists
568
-		if ( $existing_reg_payment instanceof EE_Registration_Payment ) {
568
+		if ($existing_reg_payment instanceof EE_Registration_Payment) {
569 569
 			// then update that record
570
-			$existing_reg_payment->set_amount( $payment_amount );
570
+			$existing_reg_payment->set_amount($payment_amount);
571 571
 			$existing_reg_payment->save();
572 572
 		} else {
573 573
 			// or add new relation between registration and payment and set amount
574
-			$registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) );
574
+			$registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount));
575 575
 			// make it stick
576 576
 			$registration->save();
577 577
 		}
@@ -588,21 +588,21 @@  discard block
 block discarded – undo
588 588
 	 * @return float
589 589
 	 * @throws \EE_Error
590 590
 	 */
591
-	public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) {
591
+	public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) {
592 592
 		//EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ );
593
-		if ( $registration->paid() > 0 ) {
593
+		if ($registration->paid() > 0) {
594 594
 			// ensure $available_refund_amount is NOT negative
595
-			$available_refund_amount = (float)abs( $available_refund_amount );
595
+			$available_refund_amount = (float) abs($available_refund_amount);
596 596
 			// don't allow refund amount to exceed the available payment amount, OR the amount paid
597
-			$refund_amount = min( $available_refund_amount, (float)$registration->paid() );
597
+			$refund_amount = min($available_refund_amount, (float) $registration->paid());
598 598
 			// update $available_payment_amount
599 599
 			$available_refund_amount -= $refund_amount;
600 600
 			//calculate and set new REG_paid
601
-			$registration->set_paid( $registration->paid() - $refund_amount );
601
+			$registration->set_paid($registration->paid() - $refund_amount);
602 602
 			// convert payment amount back to a negative value for storage in the db
603
-			$refund_amount = (float)abs( $refund_amount ) * -1;
603
+			$refund_amount = (float) abs($refund_amount) * -1;
604 604
 			// now save it
605
-			$this->_apply_registration_payment( $registration, $payment, $refund_amount );
605
+			$this->_apply_registration_payment($registration, $payment, $refund_amount);
606 606
 		}
607 607
 		return $available_refund_amount;
608 608
 	}
@@ -621,53 +621,53 @@  discard block
 block discarded – undo
621 621
 	 * @param bool           $IPN
622 622
 	 * @throws \EE_Error
623 623
 	 */
624
-	protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) {
624
+	protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) {
625 625
 
626 626
 		/** @type EE_Transaction_Processor $transaction_processor */
627
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
627
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
628 628
 		// is the Payment Options Reg Step completed ?
629
-		$payment_options_step_completed = $transaction->reg_step_completed( 'payment_options' );
629
+		$payment_options_step_completed = $transaction->reg_step_completed('payment_options');
630 630
 		// if the Payment Options Reg Step is completed...
631 631
 		$revisit = $payment_options_step_completed === true ? true : false;
632 632
 		// then this is kinda sorta a revisit with regards to payments at least
633
-		$transaction_processor->set_revisit( $revisit );
633
+		$transaction_processor->set_revisit($revisit);
634 634
 		// if this is an IPN, let's consider the Payment Options Reg Step completed if not already
635 635
 		if (
636 636
 			$IPN &&
637 637
 			$payment_options_step_completed !== true &&
638
-			( $payment->is_approved() || $payment->is_pending() )
638
+			($payment->is_approved() || $payment->is_pending())
639 639
 		) {
640 640
 			$payment_options_step_completed = $transaction->set_reg_step_completed(
641 641
 				'payment_options'
642 642
 			);
643 643
 		}
644 644
 		// maybe update status, but don't save transaction just yet
645
-		$transaction->update_status_based_on_total_paid( false );
645
+		$transaction->update_status_based_on_total_paid(false);
646 646
 		// check if 'finalize_registration' step has been completed...
647
-		$finalized = $transaction->reg_step_completed( 'finalize_registration' );
647
+		$finalized = $transaction->reg_step_completed('finalize_registration');
648 648
 		//  if this is an IPN and the final step has not been initiated
649
-		if ( $IPN && $payment_options_step_completed && $finalized === false ) {
649
+		if ($IPN && $payment_options_step_completed && $finalized === false) {
650 650
 			// and if it hasn't already been set as being started...
651
-			$finalized = $transaction->set_reg_step_initiated( 'finalize_registration' );
651
+			$finalized = $transaction->set_reg_step_initiated('finalize_registration');
652 652
 		}
653 653
 		$transaction->save();
654 654
 		// because the above will return false if the final step was not fully completed, we need to check again...
655
-		if ( $IPN && $finalized !== false ) {
655
+		if ($IPN && $finalized !== false) {
656 656
 			// and if we are all good to go, then send out notifications
657
-			add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
657
+			add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
658 658
 			//ok, now process the transaction according to the payment
659
-			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment );
659
+			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment);
660 660
 		}
661 661
 		// DEBUG LOG
662 662
 		$payment_method = $payment->payment_method();
663
-		if ( $payment_method instanceof EE_Payment_Method ) {
663
+		if ($payment_method instanceof EE_Payment_Method) {
664 664
 			$payment_method_type_obj = $payment_method->type_obj();
665
-			if ( $payment_method_type_obj instanceof EE_PMT_Base ) {
665
+			if ($payment_method_type_obj instanceof EE_PMT_Base) {
666 666
 				$gateway = $payment_method_type_obj->get_gateway();
667
-				if ( $gateway instanceof EE_Gateway ){
667
+				if ($gateway instanceof EE_Gateway) {
668 668
 					$gateway->log(
669 669
 						array(
670
-							'message'               => __( 'Post Payment Transaction Details', 'event_espresso' ),
670
+							'message'               => __('Post Payment Transaction Details', 'event_espresso'),
671 671
 							'transaction'           => $transaction->model_field_array(),
672 672
 							'finalized'             => $finalized,
673 673
 							'IPN'                   => $IPN,
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
  	 * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
690 690
 	 * This will affect paypal standard, pro, express, and payflow.
691 691
  	 */
692
- 	public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) {
693
- 		if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) {
692
+ 	public static function _curl_requests_to_paypal_use_tls($handle, $r, $url) {
693
+ 		if (strstr($url, 'https://') && strstr($url, '.paypal.com')) {
694 694
 			//Use the value of the constant CURL_SSLVERSION_TLSv1 = 1
695 695
 			//instead of the constant because it might not be defined
696
- 			curl_setopt( $handle, CURLOPT_SSLVERSION, 1 );
696
+ 			curl_setopt($handle, CURLOPT_SSLVERSION, 1);
697 697
  		}
698 698
  	}
699 699
  }
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 *    finds and sets the EE_Event object for use throughout class
224 224
 	 *
225 225
 	 * @access 	public
226
-	 * @param 	mixed $event
226
+	 * @param 	EE_Event|null $event
227 227
 	 * @return 	bool
228 228
 	 */
229 229
 	protected static function set_event( $event = null ) {
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 	 * 	process_ticket_selections
585 585
 	 *
586 586
 	 *	@access public
587
-	 * 	@return array|boolean
587
+	 * 	@return boolean|null
588 588
 	 */
589 589
 	public function process_ticket_selections() {
590 590
         do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	 *
746 746
 	 * @access        private
747 747
 	 * @param int $id
748
-	 * @return array|FALSE
748
+	 * @return string
749 749
 	 */
750 750
 	private static function _validate_post_data( $id = 0 ) {
751 751
 		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 	 * @access   private
865 865
 	 * @param EE_Ticket $ticket
866 866
 	 * @param int       $qty
867
-	 * @return TRUE on success, FALSE on fail
867
+	 * @return boolean on success, FALSE on fail
868 868
 	 * @throws \EE_Error
869 869
 	 */
870 870
 	private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) {
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 	protected static $_event;
18 18
 
19 19
 	/**
20
-	* array of datetimes and the spaces available for them
21
-	*
22
-	* @access private
23
-	* @var array
24
-	*/
20
+	 * array of datetimes and the spaces available for them
21
+	 *
22
+	 * @access private
23
+	 * @var array
24
+	 */
25 25
 	private static $_available_spaces = array();
26 26
 
27 27
 	/**
28
-	* max attendees that can register for event at one time
29
-	*
30
-	* @access private
31
-	* @var int
32
-	*/
28
+	 * max attendees that can register for event at one time
29
+	 *
30
+	 * @access private
31
+	 * @var int
32
+	 */
33 33
 	private static $_max_atndz = EE_INF;
34 34
 
35 35
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 				return $permalink_string;
198 198
 			}
199 199
 			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'
200
-			                     . __( 'Embed', 'event_espresso' )
201
-			                     . '</a> ';
200
+								 . __( 'Embed', 'event_espresso' )
201
+								 . '</a> ';
202 202
 			$ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() );
203 203
 			$iframe_string = esc_html(
204 204
 				'<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>'
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @throws \EE_Error
420 420
 	 */
421 421
 	public static function display_ticket_selector_submit() {
422
-        $html = '';
422
+		$html = '';
423 423
 		if ( ! is_admin() ) {
424 424
 			// standard TS displayed with submit button, ie: "Register Now"
425 425
 			if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
 				$html .= EED_Ticket_Selector::display_view_details_btn();
479 479
 			} else {
480 480
 				// no submit or view details button, and no additional content
481
-                $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
481
+				$html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
482 482
 			}
483
-            if ( ! is_archive()) {
484
-	            $html .= \EEH_Template::powered_by_event_espresso();
485
-            }
486
-        }
487
-        return $html;
488
-    }
483
+			if ( ! is_archive()) {
484
+				$html .= \EEH_Template::powered_by_event_espresso();
485
+			}
486
+		}
487
+		return $html;
488
+	}
489 489
 
490 490
 
491 491
 
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	 * 	@return array|boolean
583 583
 	 */
584 584
 	public function process_ticket_selections() {
585
-        do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
585
+		do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
586 586
 		// do we have an event id?
587 587
 		if ( ! EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) {
588 588
 			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
@@ -1005,11 +1005,11 @@  discard block
 block discarded – undo
1005 1005
 
1006 1006
 
1007 1007
 	/**
1008
-	* 	load js
1009
-	*
1010
-	* 	@access 		public
1011
-	* 	@return 		void
1012
-	*/
1008
+	 * 	load js
1009
+	 *
1010
+	 * 	@access 		public
1011
+	 * 	@return 		void
1012
+	 */
1013 1013
 	public static function load_tckt_slctr_assets() {
1014 1014
 		// add some style
1015 1015
 		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
Please login to merge, or discard this patch.
Spacing   +214 added lines, -214 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
  * Ticket Selector  class
4 4
  *
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 	 * @return EED_Ticket_Selector
48 48
 	 */
49 49
 	public static function instance() {
50
-		return parent::get_instance( __CLASS__ );
50
+		return parent::get_instance(__CLASS__);
51 51
 	}
52 52
 
53 53
 
54 54
 
55
-	protected function set_config(){
56
-		$this->set_config_section( 'template_settings' );
57
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
58
-		$this->set_config_name( 'EED_Ticket_Selector' );
55
+	protected function set_config() {
56
+		$this->set_config_section('template_settings');
57
+		$this->set_config_class('EE_Ticket_Selector_Config');
58
+		$this->set_config_name('EED_Ticket_Selector');
59 59
 	}
60 60
 
61 61
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public static function set_hooks() {
72 72
 		// routing
73
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
74
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
75
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
76
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
77
-		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
73
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
74
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
75
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
76
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
77
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
78 78
 	}
79 79
 
80 80
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 *  @return 	void
87 87
 	 */
88 88
 	public static function set_hooks_admin() {
89
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
89
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
90 90
 		//add button for iframe code to event editor.
91
-		add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 );
92
-		add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 );
91
+		add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4);
92
+		add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10);
93 93
 	}
94 94
 
95 95
 
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 *  @return 	void
102 102
 	 */
103 103
 	public static function set_definitions() {
104
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
105
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
104
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
105
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
106 106
 
107 107
 		//if config is not set, initialize
108 108
 		//If config is not set, set it.
109
-		if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) {
109
+		if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) {
110 110
 			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
111 111
 		}
112
-		EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' );
112
+		EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso');
113 113
 	}
114 114
 
115 115
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * 	@param	WP $WP
121 121
 	 * 	@return void
122 122
 	 */
123
-	public function run( $WP ) {}
123
+	public function run($WP) {}
124 124
 
125 125
 
126 126
 
@@ -134,23 +134,23 @@  discard block
 block discarded – undo
134 134
 	public function ticket_selector_iframe() {
135 135
 		self::$_in_iframe = true;
136 136
 		/** @type EEM_Event $EEM_Event */
137
-		$EEM_Event = EE_Registry::instance()->load_model( 'Event' );
137
+		$EEM_Event = EE_Registry::instance()->load_model('Event');
138 138
 		$event = $EEM_Event->get_one_by_ID(
139
-			EE_Registry::instance()->REQ->get( 'event', 0 )
139
+			EE_Registry::instance()->REQ->get('event', 0)
140 140
 		);
141
-		EE_Registry::instance()->REQ->set_espresso_page( true );
142
-		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event );
141
+		EE_Registry::instance()->REQ->set_espresso_page(true);
142
+		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event);
143 143
 		$template_args['css'] = apply_filters(
144 144
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
145 145
 			array(
146
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
147
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
148
-				includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ),
149
-				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
146
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION,
147
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION,
148
+				includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']),
149
+				EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
150 150
 			)
151 151
 		);
152
-		EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true;
153
-		EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = esc_html__( 'Please choose at least one ticket before continuing.', 'event_espresso' );
152
+		EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
153
+		EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = esc_html__('Please choose at least one ticket before continuing.', 'event_espresso');
154 154
 		$template_args['eei18n'] = apply_filters(
155 155
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings',
156 156
 			EE_Registry::localize_i18n_js_strings()
@@ -158,18 +158,18 @@  discard block
 block discarded – undo
158 158
 		$template_args['js'] = apply_filters(
159 159
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
160 160
 			array(
161
-				includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ),
162
-				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
163
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION
161
+				includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']),
162
+				EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
163
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION
164 164
 			)
165 165
 		);
166
-		$template_args[ 'notices' ] = EEH_Template::display_template(
167
-			EE_TEMPLATES . 'espresso-ajax-notices.template.php',
166
+		$template_args['notices'] = EEH_Template::display_template(
167
+			EE_TEMPLATES.'espresso-ajax-notices.template.php',
168 168
 			array(),
169 169
 			true
170 170
 		);
171 171
 		EEH_Template::display_template(
172
-			TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
172
+			TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php',
173 173
 			$template_args
174 174
 		);
175 175
 		exit;
@@ -188,25 +188,25 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return string The new html string for the permalink area.
190 190
 	 */
191
-	public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) {
191
+	public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) {
192 192
 		//make sure this is ONLY when editing and the event id has been set.
193
-		if ( ! empty( $id ) ) {
194
-			$post = get_post( $id );
193
+		if ( ! empty($id)) {
194
+			$post = get_post($id);
195 195
 			//if NOT event then let's get out.
196
-			if ( $post->post_type !== 'espresso_events' ) {
196
+			if ($post->post_type !== 'espresso_events') {
197 197
 				return $permalink_string;
198 198
 			}
199 199
 			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'
200
-			                     . __( 'Embed', 'event_espresso' )
200
+			                     . __('Embed', 'event_espresso')
201 201
 			                     . '</a> ';
202
-			$ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() );
202
+			$ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
203 203
 			$iframe_string = esc_html(
204
-				'<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>'
204
+				'<iframe src="'.$ticket_selector_url.'" width="100%" height="100%"></iframe>'
205 205
 			);
206 206
 			$permalink_string .= '
207 207
 <div id="js-ts-iframe" style="display:none">
208 208
 	<div style="width:100%; height: 500px;">
209
-		' . $iframe_string . '
209
+		' . $iframe_string.'
210 210
 	</div>
211 211
 </div>';
212 212
 		}
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
 	 * @param 	mixed $event
226 226
 	 * @return 	bool
227 227
 	 */
228
-	protected static function set_event( $event = null ) {
229
-		if( $event === null ) {
228
+	protected static function set_event($event = null) {
229
+		if ($event === null) {
230 230
 			global $post;
231 231
 			$event = $post;
232 232
 		}
233
-		if ( $event instanceof EE_Event ) {
233
+		if ($event instanceof EE_Event) {
234 234
 			self::$_event = $event;
235
-		} else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
235
+		} else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
236 236
 			self::$_event = $event->EE_Event;
237
-		} else if ( $event instanceof WP_Post && $event->post_type === 'espresso_events' ) {
238
-			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
237
+		} else if ($event instanceof WP_Post && $event->post_type === 'espresso_events') {
238
+			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
239 239
 			self::$_event = $event->EE_Event;
240 240
 		} else {
241
-			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
242
-			$dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' );
243
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
241
+			$user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
242
+			$dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso');
243
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
244 244
 			return false;
245 245
 		}
246 246
 		return true;
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 	 * @return string
258 258
 	 * @throws \EE_Error
259 259
 	 */
260
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
260
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
261 261
 		// reset filter for displaying submit button
262
-		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
262
+		remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
263 263
 		// poke and prod incoming event till it tells us what it is
264
-		if ( ! EED_Ticket_Selector::set_event( $event )) {
264
+		if ( ! EED_Ticket_Selector::set_event($event)) {
265 265
 			return false;
266 266
 		}
267 267
 		$event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			&& (
273 273
 				! self::$_event->display_ticket_selector()
274 274
 				|| $view_details
275
-				|| post_password_required( $event_post )
275
+				|| post_password_required($event_post)
276 276
 				|| (
277 277
 					$_event_active_status !== EE_Datetime::active
278 278
 					&& $_event_active_status !== EE_Datetime::upcoming
@@ -290,34 +290,34 @@  discard block
 block discarded – undo
290 290
 		$template_args = array();
291 291
 		$template_args['event_status'] = $_event_active_status;
292 292
 
293
-		$template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) );
294
-		$template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) );
293
+		$template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format'));
294
+		$template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format'));
295 295
 
296 296
 		$template_args['EVT_ID'] = self::$_event->ID();
297 297
 		$template_args['event'] = self::$_event;
298 298
 
299 299
 		// is the event expired ?
300 300
 		$template_args['event_is_expired'] = self::$_event->is_expired();
301
-		if ( $template_args['event_is_expired'] ) {
302
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>';
301
+		if ($template_args['event_is_expired']) {
302
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>';
303 303
 		}
304 304
 
305 305
 		$ticket_query_args = array(
306
-			array( 'Datetime.EVT_ID' => self::$_event->ID() ),
307
-			'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' )
306
+			array('Datetime.EVT_ID' => self::$_event->ID()),
307
+			'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC')
308 308
 		);
309 309
 
310
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) {
310
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
311 311
 			//use the correct applicable time query depending on what version of core is being run.
312
-			$current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp');
313
-			$ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time );
312
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp');
313
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
314 314
 		}
315 315
 
316 316
 		// get all tickets for this event ordered by the datetime
317
-		$template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args );
317
+		$template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
318 318
 
319
-		if ( count( $template_args['tickets'] ) < 1 ) {
320
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>';
319
+		if (count($template_args['tickets']) < 1) {
320
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>';
321 321
 		}
322 322
 
323 323
 		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
@@ -326,41 +326,41 @@  discard block
 block discarded – undo
326 326
 			self::$_event->additional_limit()
327 327
 		);
328 328
 		$template_args['max_atndz'] = \EED_Ticket_Selector::$_max_atndz;
329
-		if ( $template_args['max_atndz'] < 1 ) {
330
-			$sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' );
331
-			if ( current_user_can( 'edit_post', self::$_event->ID() )) {
332
-				$sales_closed_msg .=  sprintf(
333
-					__( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ),
329
+		if ($template_args['max_atndz'] < 1) {
330
+			$sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso');
331
+			if (current_user_can('edit_post', self::$_event->ID())) {
332
+				$sales_closed_msg .= sprintf(
333
+					__('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'),
334 334
 					'<div class="ee-attention" style="text-align: left;"><b>',
335 335
 					'</b><br />',
336
-					$link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">',
336
+					$link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">',
337 337
 					'</a></span></div>'
338 338
 				);
339 339
 			}
340
-			return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
340
+			return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
341 341
 		}
342 342
 
343
-		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
344
-		$templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event );
343
+		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php';
344
+		$templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event);
345 345
 
346 346
 		// redirecting to another site for registration ??
347 347
 		$external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE;
348 348
 		// if not redirecting to another site for registration
349
-		if ( ! $external_url ) {
349
+		if ( ! $external_url) {
350 350
 			// then display the ticket selector
351
-			$ticket_selector = EEH_Template::locate_template( $templates['ticket_selector'], $template_args );
351
+			$ticket_selector = EEH_Template::locate_template($templates['ticket_selector'], $template_args);
352 352
 		} else {
353 353
 			// if not we still need to trigger the display of the submit button
354
-			add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
354
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
355 355
 			//display notice to admin that registration is external
356
-			$ticket_selector = ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' );
356
+			$ticket_selector = ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso');
357 357
 		}
358 358
 		// now set up the form (but not for the admin)
359 359
 		$ticket_selector = ! is_admin()
360 360
 			? EED_Ticket_Selector::ticket_selector_form_open(
361 361
 				self::$_event->ID(),
362 362
 				$external_url
363
-			) . $ticket_selector
363
+			).$ticket_selector
364 364
 			: $ticket_selector;
365 365
 		// submit button and form close tag
366 366
 		$ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : '';
@@ -380,31 +380,31 @@  discard block
 block discarded – undo
380 380
 	 * @param 		string $external_url
381 381
 	 * @return 		string
382 382
 	 */
383
-	public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) {
383
+	public static function ticket_selector_form_open($ID = 0, $external_url = '') {
384 384
 		// if redirecting, we don't need any anything else
385
-		if ( $external_url ) {
386
-			$html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">';
387
-			$query_args = (array) EEH_URL::get_query_string( $external_url );
388
-			foreach ( $query_args as $query_arg => $value ) {
385
+		if ($external_url) {
386
+			$html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">';
387
+			$query_args = (array) EEH_URL::get_query_string($external_url);
388
+			foreach ($query_args as $query_arg => $value) {
389 389
 				$html .= '
390
-				<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
390
+				<input type="hidden" name="' . $query_arg.'" value="'.$value.'">';
391 391
 			}
392 392
 			return $html;
393 393
 		}
394 394
 		// if there is no submit button, then don't start building a form
395 395
 		// because the "View Details" button will build its own form
396
-		if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
396
+		if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
397 397
 			return '';
398 398
 		}
399
-		$checkout_url = EEH_Event_View::event_link_url( $ID );
400
-		if ( ! $checkout_url ) {
401
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
399
+		$checkout_url = EEH_Event_View::event_link_url($ID);
400
+		if ( ! $checkout_url) {
401
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
402 402
 		}
403 403
 		$extra_params = self::$_in_iframe ? ' target="_blank"' : '';
404
-		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
405
-		$html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, TRUE, FALSE );
404
+		$html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
405
+		$html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, TRUE, FALSE);
406 406
 		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
407
-		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event );
407
+		$html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
408 408
 		return $html;
409 409
 	}
410 410
 
@@ -420,26 +420,26 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	public static function display_ticket_selector_submit() {
422 422
         $html = '';
423
-		if ( ! is_admin() ) {
423
+		if ( ! is_admin()) {
424 424
 			// standard TS displayed with submit button, ie: "Register Now"
425
-			if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
425
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
426 426
 				$btn_text = apply_filters(
427 427
 					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
428
-					__('Register Now', 'event_espresso' ),
428
+					__('Register Now', 'event_espresso'),
429 429
 					EED_Ticket_Selector::$_event
430 430
 				);
431 431
 				$external_url = EED_Ticket_Selector::$_event->external_url();
432
-				$html .= '<input id="ticket-selector-submit-'. EED_Ticket_Selector::$_event->ID() .'-btn"';
432
+				$html .= '<input id="ticket-selector-submit-'.EED_Ticket_Selector::$_event->ID().'-btn"';
433 433
 				$html .= ' class="ticket-selector-submit-btn ';
434
-				$html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"';
435
-				$html .= ' type="submit" value="' . $btn_text . '" />';
434
+				$html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
435
+				$html .= ' type="submit" value="'.$btn_text.'" />';
436 436
 				$html .= apply_filters(
437 437
 					'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
438 438
 					'',
439 439
 					EED_Ticket_Selector::$_event
440 440
 				);
441 441
 				$html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
442
-				$html .= '<br/>' . \EED_Ticket_Selector::ticket_selector_form_close();
442
+				$html .= '<br/>'.\EED_Ticket_Selector::ticket_selector_form_close();
443 443
 			} else if (
444 444
 				// a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
445 445
 				EED_Ticket_Selector::$_max_atndz === 1
@@ -465,14 +465,14 @@  discard block
 block discarded – undo
465 465
 				$html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
466 466
 			} else if (
467 467
 				EED_Ticket_Selector::$_max_atndz === 1
468
-				&& apply_filters( 'FHEE__EE_Ticket_Selector__hide_ticket_selector', false )
468
+				&& apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
469 469
 				&& ! is_single()
470 470
 			) {
471 471
 				// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
472 472
 				// but no tickets are available, so display event's "View Details" button.
473 473
 				// it is being viewed via somewhere other than a single post
474
-				$html .= EED_Ticket_Selector::display_view_details_btn( true );
475
-			} else if ( is_archive() ) {
474
+				$html .= EED_Ticket_Selector::display_view_details_btn(true);
475
+			} else if (is_archive()) {
476 476
 				// event list, no tickets available so display event's "View Details" button
477 477
 				$html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
478 478
 				$html .= EED_Ticket_Selector::display_view_details_btn();
@@ -543,22 +543,22 @@  discard block
 block discarded – undo
543 543
 	 * @return string
544 544
 	 * @throws \EE_Error
545 545
 	 */
546
-	public static function display_view_details_btn( $DWMTS = false) {
547
-		if ( ! self::$_event->get_permalink() ) {
546
+	public static function display_view_details_btn($DWMTS = false) {
547
+		if ( ! self::$_event->get_permalink()) {
548 548
 			EE_Error::add_error(
549
-				__('The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
549
+				__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
550 550
 				__FILE__, __FUNCTION__, __LINE__
551 551
 			);
552 552
 		}
553
-		$view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">';
553
+		$view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">';
554 554
 		$btn_text = apply_filters(
555 555
 			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
556
-			__( 'View Details', 'event_espresso' ),
556
+			__('View Details', 'event_espresso'),
557 557
 			self::$_event
558 558
 		);
559
-		$view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />';
560
-		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event );
561
-		if ( $DWMTS ) {
559
+		$view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />';
560
+		$view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event);
561
+		if ($DWMTS) {
562 562
 			$view_details_btn .= \EED_Ticket_Selector::ticket_selector_form_close();
563 563
 			$view_details_btn .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
564 564
 			$view_details_btn .= '<br/>';
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
 	 * 	@return array|boolean
583 583
 	 */
584 584
 	public function process_ticket_selections() {
585
-        do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
585
+        do_action('EED_Ticket_Selector__process_ticket_selections__before');
586 586
 		// do we have an event id?
587
-		if ( ! EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) {
587
+		if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
588 588
 			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
589 589
 			EE_Error::add_error(
590 590
 				sprintf(
@@ -600,17 +600,17 @@  discard block
 block discarded – undo
600 600
 			);
601 601
 		}
602 602
 		//if event id is valid
603
-		$id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' ) );
603
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
604 604
 		// check nonce
605 605
 		if (
606 606
 			! is_admin()
607 607
 			&& (
608
-				! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce_' . $id )
609
-				|| ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce_' . $id ), 'process_ticket_selections' )
608
+				! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce_'.$id)
609
+				|| ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce_'.$id), 'process_ticket_selections')
610 610
 			)
611 611
 		) {
612 612
 			EE_Error::add_error(
613
-				sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
613
+				sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
614 614
 				__FILE__, __FUNCTION__, __LINE__
615 615
 			);
616 616
 			return FALSE;
@@ -624,16 +624,16 @@  discard block
 block discarded – undo
624 624
 
625 625
 		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
626 626
 		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
627
-		EE_Registry::instance()->load_core( 'Session' );
627
+		EE_Registry::instance()->load_core('Session');
628 628
 		// unless otherwise requested, clear the session
629
-		if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) {
630
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
629
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) {
630
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
631 631
 		}
632 632
 		//d( EE_Registry::instance()->SSN );
633 633
 
634
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
634
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
635 635
 		// validate/sanitize data
636
-		$valid = self::_validate_post_data( $id );
636
+		$valid = self::_validate_post_data($id);
637 637
 
638 638
 		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
639 639
 		//EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
@@ -641,41 +641,41 @@  discard block
 block discarded – undo
641 641
 		//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
642 642
 
643 643
 		//check total tickets ordered vs max number of attendees that can register
644
-		if ( $valid['total_tickets'] > $valid['max_atndz'] ) {
644
+		if ($valid['total_tickets'] > $valid['max_atndz']) {
645 645
 
646 646
 			// ordering too many tickets !!!
647 647
 			$total_tickets_string = _n('You have attempted to purchase %s ticket.', 'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso');
648
-			$limit_error_1 = sprintf( $total_tickets_string, $valid['total_tickets'] );
648
+			$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
649 649
 			// dev only message
650 650
 			$max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', $valid['max_atndz'], 'event_espresso');
651
-			$limit_error_2 = sprintf( $max_atndz_string, $valid['max_atndz'], $valid['max_atndz'] );
652
-			EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ );
651
+			$limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
652
+			EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
653 653
 		} else {
654 654
 
655 655
 			// all data appears to be valid
656 656
 			$tckts_slctd = FALSE;
657 657
 			$success = TRUE;
658 658
 			// load cart
659
-			EE_Registry::instance()->load_core( 'Cart' );
659
+			EE_Registry::instance()->load_core('Cart');
660 660
 
661 661
 			// cycle thru the number of data rows sent from the event listing
662
-			for ( $x = 0; $x < $valid['rows']; $x++ ) {
662
+			for ($x = 0; $x < $valid['rows']; $x++) {
663 663
 				// does this row actually contain a ticket quantity?
664
-				if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) {
664
+				if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
665 665
 					// YES we have a ticket quantity
666 666
 					$tckts_slctd = TRUE;
667 667
 					//						d( $valid['ticket_obj'][$x] );
668
-					if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) {
668
+					if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
669 669
 						// then add ticket to cart
670
-						$ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] );
670
+						$ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
671 671
 						$success = ! $ticket_added ? FALSE : $success;
672
-						if ( EE_Error::has_error() ) {
672
+						if (EE_Error::has_error()) {
673 673
 							break;
674 674
 						}
675 675
 					} else {
676 676
 						// nothing added to cart retrieved
677 677
 						EE_Error::add_error(
678
-							sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
678
+							sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
679 679
 							__FILE__, __FUNCTION__, __LINE__
680 680
 						);
681 681
 					}
@@ -684,45 +684,45 @@  discard block
 block discarded – undo
684 684
 			//d( EE_Registry::instance()->CART );
685 685
 			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
686 686
 
687
-			if ( $tckts_slctd ) {
688
-				if ( $success ) {
689
-					do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this );
687
+			if ($tckts_slctd) {
688
+				if ($success) {
689
+					do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this);
690 690
 					EE_Registry::instance()->CART->recalculate_all_cart_totals();
691
-					EE_Registry::instance()->CART->save_cart( FALSE );
691
+					EE_Registry::instance()->CART->save_cart(FALSE);
692 692
 					EE_Registry::instance()->SSN->update();
693 693
 					//d( EE_Registry::instance()->CART );
694 694
 					//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
695 695
 					// just return TRUE for registrations being made from admin
696
-					if ( is_admin() ) {
696
+					if (is_admin()) {
697 697
 						return TRUE;
698 698
 					}
699
-					wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() ));
699
+					wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url()));
700 700
 					exit();
701 701
 
702 702
 				} else {
703
-					if ( ! EE_Error::has_error() ) {
703
+					if ( ! EE_Error::has_error()) {
704 704
 						// nothing added to cart
705
-						EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
705
+						EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
706 706
 					}
707 707
 				}
708 708
 
709 709
 			} else {
710 710
 				// no ticket quantities were selected
711
-				EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
711
+				EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
712 712
 			}
713 713
 		}
714 714
 		//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
715 715
 		// at this point, just return if registration is being made from admin
716
-		if ( is_admin() ) {
716
+		if (is_admin()) {
717 717
 			return FALSE;
718 718
 		}
719
-		if ( $valid['return_url'] ) {
720
-			EE_Error::get_notices( FALSE, TRUE );
721
-			wp_safe_redirect( $valid['return_url'] );
719
+		if ($valid['return_url']) {
720
+			EE_Error::get_notices(FALSE, TRUE);
721
+			wp_safe_redirect($valid['return_url']);
722 722
 			exit();
723
-		} elseif ( isset( $event_to_add['id'] )) {
724
-			EE_Error::get_notices( FALSE, TRUE );
725
-			wp_safe_redirect( get_permalink( $event_to_add['id'] ));
723
+		} elseif (isset($event_to_add['id'])) {
724
+			EE_Error::get_notices(FALSE, TRUE);
725
+			wp_safe_redirect(get_permalink($event_to_add['id']));
726 726
 			exit();
727 727
 		} else {
728 728
 			echo EE_Error::get_notices();
@@ -742,13 +742,13 @@  discard block
 block discarded – undo
742 742
 	 * @param int $id
743 743
 	 * @return array|FALSE
744 744
 	 */
745
-	private static function _validate_post_data( $id = 0 ) {
746
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
745
+	private static function _validate_post_data($id = 0) {
746
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
747 747
 
748 748
 		//		d( $_POST );
749
-		if ( ! $id ) {
749
+		if ( ! $id) {
750 750
 			EE_Error::add_error(
751
-				__( 'The event id provided was not valid.', 'event_espresso' ),
751
+				__('The event id provided was not valid.', 'event_espresso'),
752 752
 				__FILE__,
753 753
 				__FUNCTION__,
754 754
 				__LINE__
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 		// grab valid id
761 761
 		$valid_data['id'] = $id;
762 762
 		// grab and sanitize return-url
763
-		$valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id ));
763
+		$valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id));
764 764
 		// array of other form names
765 765
 		$inputs_to_clean = array(
766 766
 			'event_id' => 'tkt-slctr-event-id',
@@ -773,22 +773,22 @@  discard block
 block discarded – undo
773 773
 		// let's track the total number of tickets ordered.'
774 774
 		$valid_data['total_tickets'] = 0;
775 775
 		// cycle through $inputs_to_clean array
776
-		foreach ( $inputs_to_clean as $what => $input_to_clean ) {
776
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
777 777
 			// check for POST data
778
-			if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) {
778
+			if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
779 779
 				// grab value
780
-				$input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id );
780
+				$input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
781 781
 				switch ($what) {
782 782
 
783 783
 					// integers
784 784
 					case 'event_id':
785
-						$valid_data[$what] = absint( $input_value );
785
+						$valid_data[$what] = absint($input_value);
786 786
 						// get event via the event id we put in the form
787
-						$valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] );
787
+						$valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']);
788 788
 						break;
789 789
 					case 'rows':
790 790
 					case 'max_atndz':
791
-						$valid_data[$what] = absint( $input_value );
791
+						$valid_data[$what] = absint($input_value);
792 792
 						break;
793 793
 
794 794
 					// arrays of integers
@@ -796,27 +796,27 @@  discard block
 block discarded – undo
796 796
 						/** @var array $row_qty */
797 797
 						$row_qty = $input_value;
798 798
 						// if qty is coming from a radio button input, then we need to assemble an array of rows
799
-						if( ! is_array( $row_qty )) {
799
+						if ( ! is_array($row_qty)) {
800 800
 							// get number of rows
801
-							$rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1;
801
+							$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1;
802 802
 							//								d( $rows );
803 803
 							// explode ints by the dash
804
-							$row_qty = explode( '-', $row_qty );
805
-							$row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1;
806
-							$qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0;
807
-							$row_qty = array( $row => $qty );
804
+							$row_qty = explode('-', $row_qty);
805
+							$row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1;
806
+							$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
807
+							$row_qty = array($row => $qty);
808 808
 							//								 d( $row_qty );
809
-							for( $x = 1; $x <= $rows; $x++ ) {
810
-								if ( ! isset( $row_qty[$x] )) {
809
+							for ($x = 1; $x <= $rows; $x++) {
810
+								if ( ! isset($row_qty[$x])) {
811 811
 									$row_qty[$x] = 0;
812 812
 								}
813 813
 							}
814 814
 						}
815
-						ksort( $row_qty );
815
+						ksort($row_qty);
816 816
 						//							 d( $row_qty );
817 817
 						// cycle thru values
818
-						foreach ( $row_qty as $qty ) {
819
-							$qty = absint( $qty );
818
+						foreach ($row_qty as $qty) {
819
+							$qty = absint($qty);
820 820
 							// sanitize as integers
821 821
 							$valid_data[$what][] = $qty;
822 822
 							$valid_data['total_tickets'] += $qty;
@@ -827,19 +827,19 @@  discard block
 block discarded – undo
827 827
 					case 'ticket_id':
828 828
 						$value_array = array();
829 829
 						// cycle thru values
830
-						foreach ( (array) $input_value as $key => $value ) {
830
+						foreach ((array) $input_value as $key => $value) {
831 831
 							// allow only numbers, letters,  spaces, commas and dashes
832
-							$value_array[ $key ] = wp_strip_all_tags( $value );
832
+							$value_array[$key] = wp_strip_all_tags($value);
833 833
 							// get ticket via the ticket id we put in the form
834
-							$ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value );
835
-							$valid_data['ticket_obj'][ $key ] = $ticket_obj;
834
+							$ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
835
+							$valid_data['ticket_obj'][$key] = $ticket_obj;
836 836
 						}
837
-						$valid_data[ $what ] = $value_array;
837
+						$valid_data[$what] = $value_array;
838 838
 						break;
839 839
 
840 840
 					case 'return_url' :
841 841
 						// grab and sanitize return-url
842
-						$valid_data[$what] = esc_url_raw( $input_value );
842
+						$valid_data[$what] = esc_url_raw($input_value);
843 843
 						break;
844 844
 
845 845
 				} 	// end switch $what
@@ -862,28 +862,28 @@  discard block
 block discarded – undo
862 862
 	 * @return TRUE on success, FALSE on fail
863 863
 	 * @throws \EE_Error
864 864
 	 */
865
-	private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) {
866
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
865
+	private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) {
866
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
867 867
 		// get the number of spaces left for this datetime ticket
868
-		$available_spaces = self::_ticket_datetime_availability( $ticket );
868
+		$available_spaces = self::_ticket_datetime_availability($ticket);
869 869
 		// compare available spaces against the number of tickets being purchased
870
-		if ( $available_spaces >= $qty ) {
870
+		if ($available_spaces >= $qty) {
871 871
 			// allow addons to prevent a ticket from being added to cart
872
-			if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) {
872
+			if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) {
873 873
 				return false;
874 874
 			}
875 875
 			// add event to cart
876
-			if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) {
877
-				self::_recalculate_ticket_datetime_availability( $ticket, $qty );
876
+			if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
877
+				self::_recalculate_ticket_datetime_availability($ticket, $qty);
878 878
 				return true;
879 879
 			} else {
880 880
 				return false;
881 881
 			}
882 882
 		} else {
883 883
 			// tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets
884
-			$available_spaces = self::_ticket_datetime_availability( $ticket, true );
884
+			$available_spaces = self::_ticket_datetime_availability($ticket, true);
885 885
 			// greedy greedy greedy eh?
886
-			if ( $available_spaces > 0 ) {
886
+			if ($available_spaces > 0) {
887 887
 				// add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces
888 888
 				EE_Error::add_error(
889 889
 					sprintf(
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 					__FILE__, __FUNCTION__, __LINE__
900 900
 				);
901 901
 			} else {
902
-				EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
902
+				EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
903 903
 			}
904 904
 			return false;
905 905
 		}
@@ -918,22 +918,22 @@  discard block
 block discarded – undo
918 918
 	 * @return int
919 919
 	 * @throws \EE_Error
920 920
 	 */
921
-	private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) {
921
+	private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) {
922 922
 		// if the $_available_spaces array has not been set up yet...
923
-		if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
924
-				self::_set_initial_ticket_datetime_availability( $ticket );
923
+		if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
924
+				self::_set_initial_ticket_datetime_availability($ticket);
925 925
 		}
926 926
 		$available_spaces = $ticket->qty() - $ticket->sold();
927
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
927
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
928 928
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
929
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
929
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
930 930
 				// if we want the original datetime availability BEFORE we started subtracting tickets ?
931
-				if ( $get_original_ticket_spaces ) {
931
+				if ($get_original_ticket_spaces) {
932 932
 					// then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
933
-					$available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] );
933
+					$available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]);
934 934
 				} else {
935 935
 					// we want the updated ticket availability as stored in the "datetimes" array
936
-					$available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] );
936
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
937 937
 				}
938 938
 			}
939 939
 		}
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 	 * @return void
951 951
 	 * @throws \EE_Error
952 952
 	 */
953
-	private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) {
953
+	private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) {
954 954
 		// first, get all of the datetimes that are available to this ticket
955 955
 		$datetimes = $ticket->get_many_related(
956 956
 			'Datetime',
@@ -958,23 +958,23 @@  discard block
 block discarded – undo
958 958
 				array(
959 959
 					'DTT_EVT_end' => array(
960 960
 						'>=',
961
-						EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ),
961
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
962 962
 					),
963 963
 				),
964
-				'order_by' => array( 'DTT_EVT_start' => 'ASC' ),
964
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
965 965
 			)
966 966
 		);
967
-		if ( ! empty( $datetimes )) {
967
+		if ( ! empty($datetimes)) {
968 968
 			// now loop thru all of the datetimes
969
-			foreach ( $datetimes as $datetime  ) {
970
-				if ( $datetime instanceof EE_Datetime ) {
969
+			foreach ($datetimes as $datetime) {
970
+				if ($datetime instanceof EE_Datetime) {
971 971
 					// the number of spaces available for the datetime without considering individual ticket quantities
972 972
 					$spaces_remaining = $datetime->spaces_remaining();
973 973
 					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key
974
-					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining );
974
+					self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining);
975 975
 					// if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number,
976 976
 					// else just take the datetime spaces remaining, and assign to the datetimes array
977
-					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining;
977
+					self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining;
978 978
 				}
979 979
 			}
980 980
 		}
@@ -990,12 +990,12 @@  discard block
 block discarded – undo
990 990
 	 * @param 	int   $qty
991 991
 	 * @return 	void
992 992
 	 */
993
-	private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) {
994
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
993
+	private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) {
994
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
995 995
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
996
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
996
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
997 997
 				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
998
-				self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
998
+				self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
999 999
 			}
1000 1000
 		}
1001 1001
 	}
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 	*/
1013 1013
 	public static function load_tckt_slctr_assets() {
1014 1014
 		// add some style
1015
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
1016
-			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
1015
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
1016
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
1017 1017
 			wp_enqueue_style('ticket_selector');
1018 1018
 			// make it dance
1019 1019
 			// wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
@@ -1027,9 +1027,9 @@  discard block
 block discarded – undo
1027 1027
 
1028 1028
 	public static function load_tckt_slctr_assets_admin() {
1029 1029
 		//iframe button js on admin event editor page
1030
-		if ( EE_Registry::instance()->REQ->get('page') === 'espresso_events' && EE_Registry::instance()->REQ->get('action') === 'edit' ) {
1031
-			wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true );
1032
-			wp_enqueue_script( 'ticket_selector_embed' );
1030
+		if (EE_Registry::instance()->REQ->get('page') === 'espresso_events' && EE_Registry::instance()->REQ->get('action') === 'edit') {
1031
+			wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1032
+			wp_enqueue_script('ticket_selector_embed');
1033 1033
 		}
1034 1034
 	}
1035 1035
 
Please login to merge, or discard this patch.
modules/bot_trap/EED_Bot_Trap.module.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @return EED_Bot_Trap
19 19
 	 */
20 20
 	public static function instance() {
21
-		return parent::get_instance( __CLASS__ );
21
+		return parent::get_instance(__CLASS__);
22 22
 	}
23 23
 
24 24
 
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public static function set_hooks() {
33 33
         if (
34
-			apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) &&
34
+			apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
35 35
 			\EE_Registry::instance()->CFG->registration->use_bot_trap
36 36
 		) {
37 37
             \EED_Bot_Trap::set_trap();
38 38
 			// redirect bots to bogus success page
39
-			\EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' );
39
+			\EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success');
40 40
 		}
41 41
 	}
42 42
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 *  @return 	void
50 50
 	 */
51 51
 	public static function set_trap() {
52
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
52
+        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS);
53 53
         add_action(
54 54
             'AHEE__ticket_selector_chart__template__after_ticket_selector',
55 55
             array('EED_Bot_Trap', 'generate_bot_trap'),
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
         }
82 82
         add_action(
83 83
 			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
84
-			array( 'EED_Bot_Trap', 'bot_trap_settings_form' ),
84
+			array('EED_Bot_Trap', 'bot_trap_settings_form'),
85 85
 			10
86 86
 		);
87 87
 		add_filter(
88 88
 			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
89
-			array( 'EED_Bot_Trap', 'update_bot_trap_settings_form' ),
89
+			array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
90 90
 			10, 1
91 91
 		);
92 92
 	}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param    WP $WP
101 101
 	 * @return    void
102 102
 	 */
103
-	public function run( $WP ) {}
103
+	public function run($WP) {}
104 104
 
105 105
 
106 106
 
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 	 * @return    void
112 112
 	 */
113 113
 	public static function generate_bot_trap() {
114
-		$do_not_enter = esc_html__( 'please do not enter anything in this input', 'event_espresso' );
114
+		$do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
115 115
 		$time = microtime(true);
116 116
 		$html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
117
-		$html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter  . '</label>';
118
-		$html .= '<input type="email" id="tkt-slctr-request-processor-email-' . $time  .'" name="tkt-slctr-request-processor-email" value=""/>';
117
+		$html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>';
118
+		$html .= '<input type="email" id="tkt-slctr-request-processor-email-'.$time.'" name="tkt-slctr-request-processor-email" value=""/>';
119 119
 		$html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
120
-		if ( EE_Registry::instance()->CFG->registration->use_encryption ) {
121
-			EE_Registry::instance()->load_core( 'EE_Encryption' );
122
-			$html .= EE_Encryption::instance()->encrypt( $time );
120
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
121
+			EE_Registry::instance()->load_core('EE_Encryption');
122
+			$html .= EE_Encryption::instance()->encrypt($time);
123 123
 		} else {
124 124
 			$html .= $time;
125 125
 		}
@@ -137,38 +137,38 @@  discard block
 block discarded – undo
137 137
      *                                              It should receive one argument: a boolean indicating
138 138
      *                                              whether the trap was triggered by suspicious timing or not.
139 139
 	 */
140
-	public static function process_bot_trap( $triggered_trap_callback = array() ) {
140
+	public static function process_bot_trap($triggered_trap_callback = array()) {
141 141
         // what's your email address Mr. Bot ?
142
-		$empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] )
143
-                      && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === ''
142
+		$empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email'])
143
+                      && $_REQUEST['tkt-slctr-request-processor-email'] === ''
144 144
             ? true
145 145
             : false;
146 146
 		// get encrypted timestamp for when the form was originally displayed
147
-		$bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] )
148
-            ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] )
147
+		$bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token'])
148
+            ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token'])
149 149
             : '';
150 150
 		// decrypt and convert to absolute  integer
151
-		if ( EE_Registry::instance()->CFG->registration->use_encryption ) {
152
-			EE_Registry::instance()->load_core( 'EE_Encryption' );
153
-			$bot_trap_timestamp = absint( EE_Encryption::instance()->decrypt( $bot_trap_timestamp ) );
151
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
152
+			EE_Registry::instance()->load_core('EE_Encryption');
153
+			$bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp));
154 154
 		} else {
155
-			$bot_trap_timestamp = absint( $bot_trap_timestamp );
155
+			$bot_trap_timestamp = absint($bot_trap_timestamp);
156 156
 		}
157 157
 		// ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
158
-		$suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS )
158
+		$suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS)
159 159
             ? true
160 160
             : false;
161 161
 		// are we human ?
162
-		if ( $empty_trap && ! $suspicious_timing ) {
162
+		if ($empty_trap && ! $suspicious_timing) {
163 163
 		    do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164 164
 			return;
165 165
 		}
166 166
 		// check the given callback is valid first before executing
167
-		if ( ! is_callable($triggered_trap_callback ) ) {
167
+		if ( ! is_callable($triggered_trap_callback)) {
168 168
 			// invalid callback so lets just sub in our default.
169
-            $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' );
169
+            $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
170 170
 		}
171
-		call_user_func_array($triggered_trap_callback, array( $suspicious_timing ) );
171
+		call_user_func_array($triggered_trap_callback, array($suspicious_timing));
172 172
 	}
173 173
 
174 174
 
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @param bool  $suspicious_timing  If true, then the bot trap was triggered due to the suspicious timing test.
181 181
 	 */
182
-	public static function triggered_trap_response( $suspicious_timing ) {
182
+	public static function triggered_trap_response($suspicious_timing) {
183 183
 		// UH OH...
184 184
 		$redirect_url = add_query_arg(
185
-			array( 'ee' => 'ticket_selection_received' ),
185
+			array('ee' => 'ticket_selection_received'),
186 186
 			EE_Registry::instance()->CFG->core->reg_page_url()
187 187
 		);
188
-		if ( $suspicious_timing ) {
188
+		if ($suspicious_timing) {
189 189
 			$redirect_url = add_query_arg(
190
-				array( 'ee-notice' => urlencode( esc_html__( 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso' ) ) ),
190
+				array('ee-notice' => urlencode(esc_html__('We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso'))),
191 191
 				$redirect_url
192 192
 			);
193 193
 		}
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	 * @return    void
219 219
 	 */
220 220
 	public static function display_bot_trap_success() {
221
-		add_filter( 'FHEE__EED_Single_Page_Checkout__run', '__return_false' );
222
-		$bot_notice = esc_html__( 'Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso' );
223
-		$bot_notice = isset( $_REQUEST[ 'ee-notice' ] ) && $_REQUEST[ 'ee-notice' ] !== '' ? sanitize_text_field( stripslashes( $_REQUEST[ 'ee-notice' ] ) ) : $bot_notice;
224
-		EE_Registry::instance()->REQ->add_output( EEH_HTML::div( $bot_notice, '', 'ee-attention' ) );
221
+		add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
222
+		$bot_notice = esc_html__('Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso');
223
+		$bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) : $bot_notice;
224
+		EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
225 225
 	}
226 226
 
227 227
 
@@ -256,20 +256,20 @@  discard block
 block discarded – undo
256 256
 				'html_id'         			=> 'bot_trap_settings',
257 257
 				'layout_strategy' 	=> new EE_Admin_Two_Column_Layout(),
258 258
 				'subsections'     		=> array(
259
-					'bot_trap_hdr' 		=> new EE_Form_Section_HTML( EEH_HTML::h2( esc_html__( 'Bot Trap Settings', 'event_espresso' ) ) ),
259
+					'bot_trap_hdr' 		=> new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))),
260 260
 					'use_bot_trap' 		=> new EE_Yes_No_Input(
261 261
 						array(
262
-							'html_label_text' 	=> esc_html__( 'Enable Bot Trap', 'event_espresso' ),
263
-							'html_help_text' 		=>  esc_html__( 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso' ),
264
-							'default'        			=> isset( EE_Registry::instance()->CFG->registration->use_bot_trap ) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true,
262
+							'html_label_text' 	=> esc_html__('Enable Bot Trap', 'event_espresso'),
263
+							'html_help_text' 		=>  esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'),
264
+							'default'        			=> isset(EE_Registry::instance()->CFG->registration->use_bot_trap) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true,
265 265
 							'required'        		=> false
266 266
 						)
267 267
 					),
268 268
 					'use_encryption' 		=> new EE_Yes_No_Input(
269 269
 						array(
270
-							'html_label_text' 	=> esc_html__( 'Encrypt Bot Trap Data', 'event_espresso' ),
271
-							'html_help_text' 		=>  esc_html__( 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso' ),
272
-							'default'        			=> isset( EE_Registry::instance()->CFG->registration->use_encryption ) ? EE_Registry::instance()->CFG->registration->use_encryption : true,
270
+							'html_label_text' 	=> esc_html__('Encrypt Bot Trap Data', 'event_espresso'),
271
+							'html_help_text' 		=>  esc_html__('One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso'),
272
+							'default'        			=> isset(EE_Registry::instance()->CFG->registration->use_encryption) ? EE_Registry::instance()->CFG->registration->use_encryption : true,
273 273
 							'required'        		=> false
274 274
 						)
275 275
 					),
@@ -287,30 +287,30 @@  discard block
 block discarded – undo
287 287
 	 * @param \EE_Registration_Config $EE_Registration_Config
288 288
 	 * @return \EE_Registration_Config
289 289
 	 */
290
-	public static function update_bot_trap_settings_form( EE_Registration_Config $EE_Registration_Config ) {
290
+	public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) {
291 291
 		try {
292 292
 			$bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
293 293
 			// if not displaying a form, then check for form submission
294
-			if ( $bot_trap_settings_form->was_submitted() ) {
294
+			if ($bot_trap_settings_form->was_submitted()) {
295 295
 				// capture form data
296 296
 				$bot_trap_settings_form->receive_form_submission();
297 297
 				// validate form data
298
-				if ( $bot_trap_settings_form->is_valid() ) {
298
+				if ($bot_trap_settings_form->is_valid()) {
299 299
 					// grab validated data from form
300 300
 					$valid_data = $bot_trap_settings_form->valid_data();
301
-					if ( isset( $valid_data[ 'use_bot_trap' ], $valid_data[ 'use_encryption' ] ) ) {
302
-						$EE_Registration_Config->use_bot_trap = $valid_data[ 'use_bot_trap' ];
303
-						$EE_Registration_Config->use_encryption = $valid_data[ 'use_encryption' ];
301
+					if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) {
302
+						$EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
303
+						$EE_Registration_Config->use_encryption = $valid_data['use_encryption'];
304 304
 					} else {
305
-						EE_Error::add_error( esc_html__( 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
305
+						EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
306 306
 					}
307 307
 				} else {
308
-					if ( $bot_trap_settings_form->submission_error_message() != '' ) {
309
-						EE_Error::add_error( $bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ );
308
+					if ($bot_trap_settings_form->submission_error_message() != '') {
309
+						EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
310 310
 					}
311 311
 				}
312 312
 			}
313
-		} catch ( EE_Error $e ) {
313
+		} catch (EE_Error $e) {
314 314
 			$e->get_error();
315 315
 		}
316 316
 		return $EE_Registration_Config;
Please login to merge, or discard this patch.
espresso_ticket_selector/EES_Espresso_Ticket_Selector.shortcode.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @access    public
51 51
 	 * @param \WP $WP
52 52
 	 */
53
-	public function run( WP $WP ) {
54
-		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
53
+	public function run(WP $WP) {
54
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
55 55
 	}
56 56
 
57 57
 
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 	 *  @param		array 	$attributes
63 63
 	 *  @return 	string
64 64
 	 */
65
-	public function process_shortcode( $attributes = array() ) {
66
-		extract( $attributes );
67
-		$event_id = isset( $event_id ) ? $event_id : 0;
68
-		$event = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $event_id );
65
+	public function process_shortcode($attributes = array()) {
66
+		extract($attributes);
67
+		$event_id = isset($event_id) ? $event_id : 0;
68
+		$event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id);
69 69
 		ob_start();
70
-		do_action( 'AHEE_event_details_before_post', $event_id );
71
-		espresso_ticket_selector( $event );
72
-		do_action( 'AHEE_event_details_after_post' );
70
+		do_action('AHEE_event_details_before_post', $event_id);
71
+		espresso_ticket_selector($event);
72
+		do_action('AHEE_event_details_after_post');
73 73
 		return ob_get_clean();
74 74
 	}
75 75
 
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Paypal_Pro extends EE_Onsite_Gateway{
28
+class EEG_Paypal_Pro extends EE_Onsite_Gateway {
29 29
 	/**
30 30
 	 *
31 31
 	 * @var $_paypal_api_username string
@@ -88,30 +88,30 @@  discard block
 block discarded – undo
88 88
 	 * } @see parent::do_direct_payment for more info
89 89
 	 * @return \EE_Payment|\EEI_Payment
90 90
 	 */
91
-	public function do_direct_payment($payment,$billing_info = null){
91
+	public function do_direct_payment($payment, $billing_info = null) {
92 92
 		$transaction = $payment->transaction();
93 93
 		$primary_registrant = $transaction->primary_registration();
94
-		$order_description  = $this->_format_order_description( $payment );
94
+		$order_description  = $this->_format_order_description($payment);
95 95
 		//charge for the full amount. Show itemized list
96
-		if( $this->_can_easily_itemize_transaction_for( $payment ) ){
96
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
97 97
 			$item_num = 1;
98 98
 			$total_line_item = $transaction->total_line_item();
99 99
 			$order_items = array();
100 100
 			foreach ($total_line_item->get_items() as $line_item) {
101 101
 				//ignore line items with a quantity of 0
102
-				if( $line_item->quantity() == 0 ) {
102
+				if ($line_item->quantity() == 0) {
103 103
 					continue;
104 104
 				}
105 105
 				$item = array(
106 106
 						// Item Name.  127 char max.
107 107
 						'l_name' => substr(
108
-							$this->_format_line_item_name( $line_item, $payment ),
108
+							$this->_format_line_item_name($line_item, $payment),
109 109
 							0,
110 110
 							127
111 111
 						),
112 112
 						// Item description.  127 char max.
113 113
 						'l_desc' => substr( 
114
-							$this->_format_line_item_desc( $line_item, $payment ),
114
+							$this->_format_line_item_desc($line_item, $payment),
115 115
 							0,
116 116
 							127
117 117
 						),
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
 			}
136 136
 			$item_amount = $total_line_item->get_items_total();
137 137
 			$tax_amount = $total_line_item->get_total_tax();
138
-		}else{
138
+		} else {
139 139
 			$order_items = array();
140 140
 			$item_amount = $payment->amount();
141 141
 			$tax_amount = 0;
142
-			array_push($order_items,array(
142
+			array_push($order_items, array(
143 143
 				// Item Name.  127 char max.
144 144
 				'l_name' => substr(
145
-					$this->_format_partial_payment_line_item_name( $payment ),
145
+					$this->_format_partial_payment_line_item_name($payment),
146 146
 					0,
147 147
 					127
148 148
 				),
149 149
 				// Item description.  127 char max.
150 150
 				'l_desc' => substr( 
151
-					$this->_format_partial_payment_line_item_desc( $payment ),
151
+					$this->_format_partial_payment_line_item_desc($payment),
152 152
 					0,
153 153
 					127
154 154
 				),
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 			// Payer's salutation.  20 char max.
197 197
 			'salutation' => '',
198 198
 			// Payer's first name.  25 char max.
199
-			'firstname' => substr($billing_info['first_name'],0,25),
199
+			'firstname' => substr($billing_info['first_name'], 0, 25),
200 200
 			// Payer's middle name.  25 char max.
201 201
 			'middlename' => '',
202 202
 			// Payer's last name.  25 char max.
203
-			'lastname' => substr($billing_info['last_name'],0,25),
203
+			'lastname' => substr($billing_info['last_name'], 0, 25),
204 204
 			// Payer's suffix.  12 char max.
205 205
 			'suffix' => ''
206 206
 		);
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
 			// Required.  Name of City.
214 214
 			'city' => $billing_info['city'],
215 215
 			// Required. Name of State or Province.
216
-			'state' => substr( $billing_info['state'], 0, 40 ),
216
+			'state' => substr($billing_info['state'], 0, 40),
217 217
 			// Required.  Country code.
218 218
 			'countrycode' => $billing_info['country'],
219 219
 			// Required.  Postal code of payer.
220 220
 			'zip' => $billing_info['zip'],
221 221
 			// Phone Number of payer.  20 char max.
222
-			'shiptophonenum' => substr($billing_info['phone'],0,20)
222
+			'shiptophonenum' => substr($billing_info['phone'], 0, 20)
223 223
 		);
224 224
 
225 225
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 			// Required.  Three-letter currency code.  Default is USD.
230 230
 			'currencycode' => $payment->currency_code(),
231 231
 			// Required if you include itemized cart details. (L_AMTn, etc.)  Subtotal of items not including S&H, or tax.
232
-			'itemamt' => $this->format_currency($item_amount),//
232
+			'itemamt' => $this->format_currency($item_amount), //
233 233
 			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
234 234
 			'shippingamt' => '',
235 235
 			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 			// Free-form field for your own use.  256 char max.
242 242
 			'custom' => $primary_registrant ? $primary_registrant->ID() : '',
243 243
 			// Your own invoice or tracking number
244
-			'invnum' => wp_generate_password(12,false),//$transaction->ID(),
244
+			'invnum' => wp_generate_password(12, false), //$transaction->ID(),
245 245
 			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
246 246
 			'notifyurl' => '',
247
-			'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
247
+			'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this
248 248
 		);
249 249
 		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
250 250
 		$PayPalRequestData = array(
@@ -257,32 +257,32 @@  discard block
 block discarded – undo
257 257
 				'OrderItems' => $order_items,
258 258
 		);
259 259
 		$this->_log_clean_request($PayPalRequestData, $payment);
260
-		try{
260
+		try {
261 261
 			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
262 262
 			//remove PCI-sensitive data so it doesn't get stored
263
-			$PayPalResult = $this->_log_clean_response($PayPalResult,$payment);
263
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
264 264
 
265 265
 			$message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
266
-			if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) {
267
-				$payment->set_status( $this->_pay_model->failed_status() ) ;
268
-				$payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) );
266
+			if (empty($PayPalResult['RAWRESPONSE'])) {
267
+				$payment->set_status($this->_pay_model->failed_status());
268
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
269 269
 				$payment->set_details($PayPalResult);
270
-			}else{
271
-				if($this->_APICallSuccessful($PayPalResult)){
270
+			} else {
271
+				if ($this->_APICallSuccessful($PayPalResult)) {
272 272
 					$payment->set_status($this->_pay_model->approved_status());
273
-				}else{
273
+				} else {
274 274
 					$payment->set_status($this->_pay_model->declined_status());
275 275
 				}
276 276
 				//make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
277
-				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0);
277
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
278 278
 				$payment->set_gateway_response($message);
279
-				$payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null);
279
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null);
280 280
 
281 281
 				$primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : '';
282 282
 				$payment->set_extra_accntng($primary_registration_code);
283 283
 				$payment->set_details($PayPalResult);
284 284
 			}
285
-		}catch(Exception $e){
285
+		} catch (Exception $e) {
286 286
 			$payment->set_status($this->_pay_model->failed_status());
287 287
 			$payment->set_gateway_response($e->getMessage());
288 288
 		}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param EEI_Payment $payment
300 300
 	 * @return array
301 301
 	 */
302
-	private function _log_clean_request($request,$payment){
302
+	private function _log_clean_request($request, $payment) {
303 303
 		$cleaned_request_data = $request;
304 304
 		unset($cleaned_request_data['CCDetails']['acct']);
305 305
 		unset($cleaned_request_data['CCDetails']['cvv2']);
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 	 * @param EEI_Payment $payment
316 316
 	 * @return array cleaned
317 317
 	 */
318
-	private function _log_clean_response($response,$payment){
318
+	private function _log_clean_response($response, $payment) {
319 319
 		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
320 320
 		unset($response['REQUESTDATA']['ACCT']);
321 321
 		unset($response['REQUESTDATA']['EXPDATE']);
322 322
 		unset($response['REQUESTDATA']['CVV2']);
323 323
 		unset($response['RAWREQUEST']);
324
-		$this->log(array('Paypal Response'=>$response),$payment);
324
+		$this->log(array('Paypal Response'=>$response), $payment);
325 325
 		return $response;
326 326
 	}
327 327
 
@@ -346,32 +346,32 @@  discard block
 block discarded – undo
346 346
 		// DP Fields
347 347
 		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
348 348
 		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal)
349
-			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
349
+			$DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
350 350
 
351 351
 		// CC Details Fields
352 352
 		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
353 353
 		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal)
354
-			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
354
+			$CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
355 355
 
356 356
 		// PayerInfo Type Fields
357 357
 		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
358 358
 		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal)
359
-			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
359
+			$PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
360 360
 
361 361
 		// Payer Name Fields
362 362
 		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
363 363
 		foreach ($PayerName as $PayerNameVar => $PayerNameVal)
364
-			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
364
+			$PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
365 365
 
366 366
 		// Address Fields (Billing)
367 367
 		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
368 368
 		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal)
369
-			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
369
+			$BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
370 370
 
371 371
 		// Payment Details Type Fields
372 372
 		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
373 373
 		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal)
374
-			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
374
+			$PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
375 375
 
376 376
 		// Payment Details Item Type Fields
377 377
 		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
@@ -379,22 +379,22 @@  discard block
 block discarded – undo
379 379
 		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
380 380
 			$CurrentItem = $OrderItems[$OrderItemsVar];
381 381
 			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal)
382
-				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
382
+				$OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
383 383
 			$n++;
384 384
 		}
385 385
 
386 386
 		// Ship To Address Fields
387 387
 		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
388 388
 		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal)
389
-			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
389
+			$ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
390 390
 
391 391
 		// 3D Secure Fields
392 392
 		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
393 393
 		foreach ($Secure3D as $Secure3DVar => $Secure3DVal)
394
-			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
394
+			$Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
395 395
 
396 396
 		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
397
-		$NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP;
397
+		$NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP;
398 398
 		$NVPResponse = $this->_CURLRequest($NVPRequest);
399 399
 		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
400 400
 		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	private function _CURLRequest($Request) {
419 419
 		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
420 420
 		$curl = curl_init();
421
-		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) );
421
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE));
422 422
 		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
423 423
 		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
424 424
 		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
 	private function _APICallSuccessful($PayPalResult) {
469 469
 		$approved = false;
470 470
 		// check main response message from PayPal
471
-		if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) {
471
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
472 472
 			$ack = strtoupper($PayPalResult['ACK']);
473
-			$approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false;
473
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
474 474
 		}
475 475
 
476 476
 		return $approved;
@@ -486,11 +486,11 @@  discard block
 block discarded – undo
486 486
 
487 487
 		$Errors = array();
488 488
 		$n = 0;
489
-		while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
490
-			$LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
491
-			$LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : '';
492
-			$LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : '';
493
-			$LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : '';
489
+		while (isset($DataArray['L_ERRORCODE'.$n.''])) {
490
+			$LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
491
+			$LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : '';
492
+			$LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : '';
493
+			$LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : '';
494 494
 
495 495
 			$CurrentItem = array(
496 496
 					'L_ERRORCODE' => $LErrorCode,
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 				elseif ($CurrentErrorVar == 'L_SEVERITYCODE')
531 531
 					$CurrentVarName = 'Severity Code';
532 532
 
533
-				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
533
+				$error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
534 534
 			}
535 535
 		}
536 536
 		return $error;
Please login to merge, or discard this patch.