Completed
Branch FET-10693-composite-command-ha... (b0cb9b)
by
unknown
106:01 queued 94:25
created
payment_methods/Paypal_Express/EEG_Paypal_Express.gateway.php 2 patches
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); }
2 2
 
3 3
 /**
4 4
  * ----------------------------------------------
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 *@param array $settings_array
98 98
 	 */
99
-	public function set_settings( $settings_array ) {
99
+	public function set_settings($settings_array) {
100 100
 		parent::set_settings($settings_array);
101 101
 		// Redirect URL.
102 102
         $this->_base_gateway_url = $this->_debug_mode
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
      * @return \EE_Payment|\EEI_Payment
116 116
      * @throws \EE_Error
117 117
      */
118
-	public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) {
119
-		if ( ! $payment instanceof EEI_Payment ) {
120
-			$payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) );
121
-			$payment->set_status( $this->_pay_model->failed_status() );
118
+	public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) {
119
+		if ( ! $payment instanceof EEI_Payment) {
120
+			$payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso'));
121
+			$payment->set_status($this->_pay_model->failed_status());
122 122
 			return $payment;
123 123
 		}
124 124
 		$transaction = $payment->transaction();
125
-		if ( ! $transaction instanceof EEI_Transaction ) {
126
-			$payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) );
127
-			$payment->set_status( $this->_pay_model->failed_status() );
125
+		if ( ! $transaction instanceof EEI_Transaction) {
126
+			$payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso'));
127
+			$payment->set_status($this->_pay_model->failed_status());
128 128
 			return $payment;
129 129
 		}
130
-		$order_description = substr( $this->_format_order_description($payment), 0, 127 );
130
+		$order_description = substr($this->_format_order_description($payment), 0, 127);
131 131
 		$primary_registration = $transaction->primary_registration();
132 132
 		$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false;
133 133
 		$locale = explode('-', get_bloginfo('language'));
@@ -141,37 +141,37 @@  discard block
 block discarded – undo
141 141
 			'RETURNURL' => $return_url,
142 142
 			'CANCELURL' => $cancel_url,
143 143
 			'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
144
-			'SOLUTIONTYPE' => 'Sole',	// Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional.
145
-			'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this
144
+			'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional.
145
+			'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this
146 146
 			'LOCALECODE' => $locale[1]	// Locale of the pages displayed by PayPal during Express Checkout.
147 147
 		);
148 148
 
149 149
 		// Show itemized list.
150
-		if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) {
150
+		if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
151 151
 			$item_num = 0;
152 152
 			$itemized_sum = 0;
153 153
 			$total_line_items = $transaction->total_line_item();
154 154
 			// Go through each item in the list.
155
-			foreach ( $total_line_items->get_items() as $line_item ) {
156
-				if ( $line_item instanceof EE_Line_Item ) {
155
+			foreach ($total_line_items->get_items() as $line_item) {
156
+				if ($line_item instanceof EE_Line_Item) {
157 157
 					// PayPal doesn't like line items with 0.00 amount, so we may skip those.
158
-					if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) {
158
+					if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) {
159 159
 						continue;
160 160
 					}
161 161
 
162 162
 					$unit_price = $line_item->unit_price();
163 163
 					$line_item_quantity = $line_item->quantity();
164 164
 					// This is a discount.
165
-					if ( $line_item->is_percent() ) {
165
+					if ($line_item->is_percent()) {
166 166
 						$unit_price = $line_item->total();
167 167
 						$line_item_quantity = 1;
168 168
 					}
169 169
 					// Item Name.
170
-					$token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127);
170
+					$token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127);
171 171
 					// Item description.
172
-					$token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127);
172
+					$token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127);
173 173
 					// Cost of individual item.
174
-					$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price );
174
+					$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price);
175 175
 					// Item Number.
176 176
 					$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
177 177
 					// Item quantity.
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
189 189
 			$token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
190 190
 
191
-			$itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 );
191
+			$itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2);
192 192
 			// If we were not able to recognize some item like promotion, surcharge or cancellation,
193 193
 			// add the difference as an extra line item.
194
-			if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) {
194
+			if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) {
195 195
 				// Item Name.
196
-				$token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 );
196
+				$token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127);
197 197
 				// Item description.
198 198
 				$token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = '';
199 199
 				// Cost of individual item.
200
-				$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total );
200
+				$token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
201 201
 				// Item Number.
202 202
 				$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
203 203
 				// Item quantity.
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 		} else {
210 210
 			// Just one Item.
211 211
 			// Item Name.
212
-			$token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 );
212
+			$token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127);
213 213
 			// Item description.
214
-			$token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 );
214
+			$token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127);
215 215
 			// Cost of individual item.
216
-			$token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() );
216
+			$token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount());
217 217
 			// Item Number.
218 218
 			$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1;
219 219
 			// Item quantity.
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 			// Digital item is sold.
222 222
 			$token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical';
223 223
 			// Item's sales S/H and tax amount.
224
-			$token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() );
224
+			$token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount());
225 225
 			$token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0';
226 226
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
227 227
 			$token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
228 228
 		}
229 229
 		// Automatically filling out shipping and contact information.
230
-		if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) {
231
-			$token_request_dtls['NOSHIPPING'] = '2';	//  If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
230
+		if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) {
231
+			$token_request_dtls['NOSHIPPING'] = '2'; //  If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
232 232
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address();
233 233
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2();
234 234
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city();
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
238 238
 			$token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
239 239
 			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
240
-		} elseif ( ! $this->_request_shipping_addr ) {
240
+		} elseif ( ! $this->_request_shipping_addr) {
241 241
 			// Do not request shipping details on the PP Checkout page.
242 242
 			$token_request_dtls['NOSHIPPING'] = '1';
243 243
 			$token_request_dtls['REQCONFIRMSHIPPING'] = '0';
244 244
 
245 245
 		}
246 246
 		// Used a business/personal logo on the PayPal page.
247
-		if ( ! empty($this->_image_url) ) {
247
+		if ( ! empty($this->_image_url)) {
248 248
 			$token_request_dtls['LOGOIMG'] = $this->_image_url;
249 249
 		}
250 250
 		$token_request_dtls = apply_filters( 
@@ -253,23 +253,23 @@  discard block
 block discarded – undo
253 253
 			$this 
254 254
 		);
255 255
 		// Request PayPal token.
256
-		$token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment );
257
-		$token_rstatus = $this->_ppExpress_check_response( $token_request_response );
258
-		$response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array();
259
-		if ( $token_rstatus['status'] ) {
256
+		$token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment);
257
+		$token_rstatus = $this->_ppExpress_check_response($token_request_response);
258
+		$response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array();
259
+		if ($token_rstatus['status']) {
260 260
 			// We got the Token so we may continue with the payment and redirect the client.
261
-			$payment->set_details( $response_args );
261
+			$payment->set_details($response_args);
262 262
 
263 263
 			$gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
264
-			$payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] );
264
+			$payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']);
265 265
 		} else {
266
-			if ( isset($response_args['L_ERRORCODE']) ) {
267
-				$payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] );
266
+			if (isset($response_args['L_ERRORCODE'])) {
267
+				$payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']);
268 268
 			} else {
269
-				$payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) );
269
+				$payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso'));
270 270
 			}
271
-			$payment->set_details( $response_args );
272
-			$payment->set_status( $this->_pay_model->failed_status() );
271
+			$payment->set_details($response_args);
272
+			$payment->set_status($this->_pay_model->failed_status());
273 273
 		}
274 274
 
275 275
 		return $payment;
@@ -285,22 +285,22 @@  discard block
 block discarded – undo
285 285
 	 *  @param EEI_Transaction $transaction
286 286
 	 *  @return EEI_Payment
287 287
 	 */
288
-	public function handle_payment_update( $update_info, $transaction ) {
288
+	public function handle_payment_update($update_info, $transaction) {
289 289
 		$payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null;
290 290
 
291
-		if ( $payment instanceof EEI_Payment ) {
292
-			$this->log( array( 'Return from Authorization' => $update_info ), $payment );
291
+		if ($payment instanceof EEI_Payment) {
292
+			$this->log(array('Return from Authorization' => $update_info), $payment);
293 293
 			$transaction = $payment->transaction();
294
-			if ( ! $transaction instanceof EEI_Transaction ) {
295
-				$payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) );
296
-				$payment->set_status( $this->_pay_model->failed_status() );
294
+			if ( ! $transaction instanceof EEI_Transaction) {
295
+				$payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso'));
296
+				$payment->set_status($this->_pay_model->failed_status());
297 297
 				return $payment;
298 298
 			}
299 299
 			$primary_registrant = $transaction->primary_registration();
300 300
             $payment_details = $payment->details();
301 301
             // Check if we still have the token.
302
-			if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) {
303
-				$payment->set_status( $this->_pay_model->failed_status() );
302
+			if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
303
+				$payment->set_status($this->_pay_model->failed_status());
304 304
 				return $payment;
305 305
 			}
306 306
 
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 				'TOKEN' => $payment_details['TOKEN']
310 310
 			);
311 311
 			// Request Customer Details.
312
-			$cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment );
313
-			$cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response );
314
-			$cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array();
315
-			if ( $cdetails_rstatus['status'] ) {
312
+			$cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment);
313
+			$cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response);
314
+			$cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array();
315
+			if ($cdetails_rstatus['status']) {
316 316
 				// We got the PayerID so now we can Complete the transaction.
317 317
 				$docheckout_request_dtls = array(
318 318
 					'METHOD' => 'DoExpressCheckoutPayment',
@@ -323,39 +323,39 @@  discard block
 block discarded – undo
323 323
 					'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code()
324 324
 				);
325 325
 				// Payment Checkout/Capture.
326
-				$docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment );
327
-				$docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response );
328
-				$docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array();
329
-				if ( $docheckout_rstatus['status'] ) {
326
+				$docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment);
327
+				$docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response);
328
+				$docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array();
329
+				if ($docheckout_rstatus['status']) {
330 330
 					// All is well, payment approved.
331 331
 					$primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : '';
332
-					$payment->set_extra_accntng( $primary_registration_code );
333
-					$payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 );
334
-					$payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null );
335
-					$payment->set_details( $cdata_response_args );
336
-					$payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' );
337
-					$payment->set_status( $this->_pay_model->approved_status() );
332
+					$payment->set_extra_accntng($primary_registration_code);
333
+					$payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0);
334
+					$payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null);
335
+					$payment->set_details($cdata_response_args);
336
+					$payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '');
337
+					$payment->set_status($this->_pay_model->approved_status());
338 338
 				} else {
339
-					if ( isset($docheckout_response_args['L_ERRORCODE']) ) {
340
-						$payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] );
339
+					if (isset($docheckout_response_args['L_ERRORCODE'])) {
340
+						$payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']);
341 341
 					} else {
342
-						$payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) );
342
+						$payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso'));
343 343
 					}
344
-					$payment->set_details( $docheckout_response_args );
345
-					$payment->set_status( $this->_pay_model->declined_status() );
344
+					$payment->set_details($docheckout_response_args);
345
+					$payment->set_status($this->_pay_model->declined_status());
346 346
 				}
347 347
 			} else {
348
-				if ( isset($cdata_response_args['L_ERRORCODE']) ) {
349
-					$payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] );
348
+				if (isset($cdata_response_args['L_ERRORCODE'])) {
349
+					$payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']);
350 350
 				} else {
351
-					$payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) );
351
+					$payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso'));
352 352
 				}
353
-				$payment->set_details( $cdata_response_args );
354
-				$payment->set_status( $this->_pay_model->failed_status() );
353
+				$payment->set_details($cdata_response_args);
354
+				$payment->set_status($this->_pay_model->failed_status());
355 355
 			}
356 356
 		} else {
357
-			$payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) );
358
-			$payment->set_status( $this->_pay_model->failed_status() );
357
+			$payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso'));
358
+			$payment->set_status($this->_pay_model->failed_status());
359 359
 		}
360 360
 
361 361
 		return $payment;
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
 	 *  @param EEI_Payment  $payment
371 371
 	 *	@return mixed
372 372
 	 */
373
-	public function _ppExpress_request( $request_params, $request_text, $payment ) {
373
+	public function _ppExpress_request($request_params, $request_text, $payment) {
374 374
 		$request_dtls = array(
375 375
 			'VERSION' => '204.0',
376
-			'USER' => urlencode( $this->_api_username ),
377
-			'PWD' => urlencode( $this->_api_password ),
378
-			'SIGNATURE' => urlencode( $this->_api_signature )
376
+			'USER' => urlencode($this->_api_username),
377
+			'PWD' => urlencode($this->_api_password),
378
+			'SIGNATURE' => urlencode($this->_api_signature)
379 379
 		);
380
-		$dtls = array_merge( $request_dtls, $request_params );
380
+		$dtls = array_merge($request_dtls, $request_params);
381 381
 
382
-		$this->_log_clean_request( $dtls, $payment, $request_text . ' Request' );
382
+		$this->_log_clean_request($dtls, $payment, $request_text.' Request');
383 383
 		// Request Customer Details.
384 384
 		$request_response = wp_remote_post(
385 385
 			$this->_base_gateway_url,
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 				'httpversion' => '1.1',
390 390
 				'cookies' => array(),
391 391
 				'headers' => array(),
392
-				'body' => http_build_query( $dtls )
392
+				'body' => http_build_query($dtls)
393 393
 			)
394 394
 		);
395 395
 		// Log the response.
396
-		$this->log( array( $request_text . ' Response' => $request_response), $payment );
396
+		$this->log(array($request_text.' Response' => $request_response), $payment);
397 397
 
398 398
 		return $request_response;
399 399
 	}
@@ -405,13 +405,13 @@  discard block
 block discarded – undo
405 405
 	 *	@param mixed        $request_response
406 406
 	 *	@return array
407 407
 	 */
408
-	public function _ppExpress_check_response( $request_response ) {
409
-		if ( is_wp_error( $request_response ) || empty($request_response['body']) ) {
408
+	public function _ppExpress_check_response($request_response) {
409
+		if (is_wp_error($request_response) || empty($request_response['body'])) {
410 410
             // If we got here then there was an error in this request.
411 411
             return array('status' => false, 'args' => $request_response);
412 412
         }
413 413
         $response_args = array();
414
-        parse_str( urldecode($request_response['body']), $response_args );
414
+        parse_str(urldecode($request_response['body']), $response_args);
415 415
         if ( ! isset($response_args['ACK'])) {
416 416
             return array('status' => false, 'args' => $request_response);
417 417
         }
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
 	 * @param string  		$info
442 442
 	 * @return void
443 443
 	 */
444
-	private function _log_clean_request($request, $payment, $info ) {
444
+	private function _log_clean_request($request, $payment, $info) {
445 445
 		$cleaned_request_data = $request;
446 446
 		unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']);
447
-		$this->log( array($info => $cleaned_request_data), $payment );
447
+		$this->log(array($info => $cleaned_request_data), $payment);
448 448
 	}
449 449
 
450 450
 
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
 	 *  @param array	$data_array
455 455
 	 *  @return array
456 456
 	 */
457
-	private function _get_errors( $data_array ) {
457
+	private function _get_errors($data_array) {
458 458
 		$errors = array();
459 459
 		$n = 0;
460
-		while ( isset($data_array["L_ERRORCODE{$n}"]) ) {
460
+		while (isset($data_array["L_ERRORCODE{$n}"])) {
461 461
 			$l_error_code = isset($data_array["L_ERRORCODE{$n}"])
462 462
                 ? $data_array["L_ERRORCODE{$n}"]
463 463
                 : '';
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
                 ? $data_array["L_LONGMESSAGE{$n}"]
472 472
                 : '';
473 473
 
474
-			if ( $n === 0 ) {
474
+			if ($n === 0) {
475 475
 				$errors = array(
476 476
 					'L_ERRORCODE' => $l_error_code,
477 477
 					'L_SHORTMESSAGE' => $l_short_message,
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
 					'L_SEVERITYCODE' => $l_severity_code
480 480
 				);
481 481
 			} else {
482
-				$errors['L_ERRORCODE'] .= ', ' . $l_error_code;
483
-				$errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
484
-				$errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
485
-				$errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
482
+				$errors['L_ERRORCODE'] .= ', '.$l_error_code;
483
+				$errors['L_SHORTMESSAGE'] .= ', '.$l_short_message;
484
+				$errors['L_LONGMESSAGE'] .= ', '.$l_long_message;
485
+				$errors['L_SEVERITYCODE'] .= ', '.$l_severity_code;
486 486
 			}
487 487
 
488 488
 			$n++;
Please login to merge, or discard this patch.
Indentation   +98 added lines, -100 removed lines patch added patch discarded remove patch
@@ -44,77 +44,76 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	protected $_image_url;
46 46
 
47
-    /**
48
-     * gateway URL variable
49
-     *
50
-     * @var string
51
-     */
52
-    protected $_base_gateway_url = '';
53
-
54
-
55
-
56
-    /**
57
-     * EEG_Paypal_Express constructor.
58
-     */
59
-    public function __construct()
60
-    {
61
-        $this->_currencies_supported = array(
62
-            'USD',
63
-            'AUD',
64
-            'BRL',
65
-            'CAD',
66
-            'CZK',
67
-            'DKK',
68
-            'EUR',
69
-            'HKD',
70
-            'HUF',
71
-            'ILS',
72
-            'JPY',
73
-            'MYR',
74
-            'MXN',
75
-            'NOK',
76
-            'NZD',
77
-            'PHP',
78
-            'PLN',
79
-            'GBP',
80
-            'RUB',
81
-            'SGD',
82
-            'SEK',
83
-            'CHF',
84
-            'TWD',
85
-            'THB',
86
-            'TRY'
87
-        );
88
-        parent::__construct();
89
-    }
90
-
91
-
92
-
93
-    /**
94
-	 * Sets the gateway URL variable based on whether debug mode is enabled or not.
47
+	/**
48
+	 * gateway URL variable
49
+	 *
50
+	 * @var string
51
+	 */
52
+	protected $_base_gateway_url = '';
53
+
54
+
55
+
56
+	/**
57
+	 * EEG_Paypal_Express constructor.
58
+	 */
59
+	public function __construct()
60
+	{
61
+		$this->_currencies_supported = array(
62
+			'USD',
63
+			'AUD',
64
+			'BRL',
65
+			'CAD',
66
+			'CZK',
67
+			'DKK',
68
+			'EUR',
69
+			'HKD',
70
+			'HUF',
71
+			'ILS',
72
+			'JPY',
73
+			'MYR',
74
+			'MXN',
75
+			'NOK',
76
+			'NZD',
77
+			'PHP',
78
+			'PLN',
79
+			'GBP',
80
+			'RUB',
81
+			'SGD',
82
+			'SEK',
83
+			'CHF',
84
+			'TWD',
85
+			'THB',
86
+			'TRY'
87
+		);
88
+		parent::__construct();
89
+	}
90
+
95 91
 
92
+
93
+	/**
94
+	 * Sets the gateway URL variable based on whether debug mode is enabled or not.
96 95
 	 *
97 96
 *@param array $settings_array
98 97
 	 */
99 98
 	public function set_settings( $settings_array ) {
100 99
 		parent::set_settings($settings_array);
101 100
 		// Redirect URL.
102
-        $this->_base_gateway_url = $this->_debug_mode
103
-            ? 'https://api-3t.sandbox.paypal.com/nvp'
104
-            : 'https://api-3t.paypal.com/nvp';
101
+		$this->_base_gateway_url = $this->_debug_mode
102
+			? 'https://api-3t.sandbox.paypal.com/nvp'
103
+			: 'https://api-3t.paypal.com/nvp';
105 104
 	}
106 105
 
107 106
 
108 107
 
109
-    /**
110
-     * @param EEI_Payment $payment
111
-     * @param array       $billing_info
112
-     * @param string      $return_url
113
-     * @param string      $notify_url
114
-     * @param string      $cancel_url
115
-     * @return \EE_Payment|\EEI_Payment
116
-     * @throws \EE_Error
117
-     */
108
+	/**
109
+	 * @param EEI_Payment $payment
110
+	 * @param array       $billing_info
111
+	 * @param string      $return_url
112
+	 * @param string      $notify_url
113
+	 * @param string      $cancel_url
114
+	 * @return \EE_Payment|\EEI_Payment
115
+	 * @throws \EE_Error
116
+	 */
118 117
 	public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) {
119 118
 		if ( ! $payment instanceof EEI_Payment ) {
120 119
 			$payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) );
@@ -202,9 +201,9 @@  discard block
 block discarded – undo
202 201
 				$token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
203 202
 				// Item quantity.
204 203
 				$token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1;
205
-                // Digital item is sold.
206
-                $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical';
207
-                $item_num++;
204
+				// Digital item is sold.
205
+				$token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical';
206
+				$item_num++;
208 207
 			}
209 208
 		} else {
210 209
 			// Just one Item.
@@ -277,7 +276,6 @@  discard block
 block discarded – undo
277 276
 
278 277
 
279 278
 	/**
280
-
281 279
 	 *  @param array $update_info {
282 280
 	 *	  @type string $gateway_txn_id
283 281
 	 *	  @type string status an EEMI_Payment status
@@ -297,8 +295,8 @@  discard block
 block discarded – undo
297 295
 				return $payment;
298 296
 			}
299 297
 			$primary_registrant = $transaction->primary_registration();
300
-            $payment_details = $payment->details();
301
-            // Check if we still have the token.
298
+			$payment_details = $payment->details();
299
+			// Check if we still have the token.
302 300
 			if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) {
303 301
 				$payment->set_status( $this->_pay_model->failed_status() );
304 302
 				return $payment;
@@ -407,36 +405,36 @@  discard block
 block discarded – undo
407 405
 	 */
408 406
 	public function _ppExpress_check_response( $request_response ) {
409 407
 		if ( is_wp_error( $request_response ) || empty($request_response['body']) ) {
410
-            // If we got here then there was an error in this request.
411
-            return array('status' => false, 'args' => $request_response);
412
-        }
413
-        $response_args = array();
414
-        parse_str( urldecode($request_response['body']), $response_args );
415
-        if ( ! isset($response_args['ACK'])) {
416
-            return array('status' => false, 'args' => $request_response);
417
-        }
418
-        if (
419
-            $response_args['ACK'] === 'Success'
420
-            && (
421
-                isset($response_args['PAYERID'])
422
-                || isset($response_args['PAYMENTINFO_0_TRANSACTIONID'])
423
-                || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed')
424
-                || isset($response_args['TOKEN'])
425
-            )
426
-        ) {
427
-            // Response status OK, return response parameters for further processing.
428
-            return array('status' => true, 'args' => $response_args);
429
-        } else {
430
-            $errors = $this->_get_errors($response_args);
431
-            return array('status' => false, 'args' => $errors);
432
-        }
408
+			// If we got here then there was an error in this request.
409
+			return array('status' => false, 'args' => $request_response);
410
+		}
411
+		$response_args = array();
412
+		parse_str( urldecode($request_response['body']), $response_args );
413
+		if ( ! isset($response_args['ACK'])) {
414
+			return array('status' => false, 'args' => $request_response);
415
+		}
416
+		if (
417
+			$response_args['ACK'] === 'Success'
418
+			&& (
419
+				isset($response_args['PAYERID'])
420
+				|| isset($response_args['PAYMENTINFO_0_TRANSACTIONID'])
421
+				|| (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed')
422
+				|| isset($response_args['TOKEN'])
423
+			)
424
+		) {
425
+			// Response status OK, return response parameters for further processing.
426
+			return array('status' => true, 'args' => $response_args);
427
+		} else {
428
+			$errors = $this->_get_errors($response_args);
429
+			return array('status' => false, 'args' => $errors);
430
+		}
433 431
 	}
434 432
 
435 433
 
436 434
 	/**
437
-     *  Log a "Cleared" request.
438
-     *
439
-     * @param array $request
435
+	 *  Log a "Cleared" request.
436
+	 *
437
+	 * @param array $request
440 438
 	 * @param EEI_Payment  $payment
441 439
 	 * @param string  		$info
442 440
 	 * @return void
@@ -459,17 +457,17 @@  discard block
 block discarded – undo
459 457
 		$n = 0;
460 458
 		while ( isset($data_array["L_ERRORCODE{$n}"]) ) {
461 459
 			$l_error_code = isset($data_array["L_ERRORCODE{$n}"])
462
-                ? $data_array["L_ERRORCODE{$n}"]
463
-                : '';
460
+				? $data_array["L_ERRORCODE{$n}"]
461
+				: '';
464 462
 			$l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"])
465
-                ? $data_array["L_SEVERITYCODE{$n}"]
466
-                : '';
463
+				? $data_array["L_SEVERITYCODE{$n}"]
464
+				: '';
467 465
 			$l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"])
468
-                ? $data_array["L_SHORTMESSAGE{$n}"]
469
-                : '';
466
+				? $data_array["L_SHORTMESSAGE{$n}"]
467
+				: '';
470 468
 			$l_long_message = isset($data_array["L_LONGMESSAGE{$n}"])
471
-                ? $data_array["L_LONGMESSAGE{$n}"]
472
-                : '';
469
+				? $data_array["L_LONGMESSAGE{$n}"]
470
+				: '';
473 471
 
474 472
 			if ( $n === 0 ) {
475 473
 				$errors = array(
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.043');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.043');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.