@@ -392,7 +392,7 @@ |
||
392 | 392 | |
393 | 393 | |
394 | 394 | /** |
395 | - * @param $Request |
|
395 | + * @param string $Request |
|
396 | 396 | * @return mixed |
397 | 397 | */ |
398 | 398 | private function _CURLRequest($Request) { |
@@ -1,7 +1,8 @@ discard block |
||
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 | /** |
7 | 8 | * Event Espresso |
@@ -123,7 +124,7 @@ discard block |
||
123 | 124 | } |
124 | 125 | $item_amount = $total_line_item->get_items_total(); |
125 | 126 | $tax_amount = $total_line_item->get_total_tax(); |
126 | - }else{ |
|
127 | + } else{ |
|
127 | 128 | $order_items = array(); |
128 | 129 | $item_amount = $payment->amount(); |
129 | 130 | $single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code()); |
@@ -248,10 +249,10 @@ discard block |
||
248 | 249 | $payment->set_status( $this->_pay_model->failed_status() ) ; |
249 | 250 | $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
250 | 251 | $payment->set_details($PayPalResult); |
251 | - }else{ |
|
252 | + } else{ |
|
252 | 253 | if($this->_APICallSuccessful($PayPalResult)){ |
253 | 254 | $payment->set_status($this->_pay_model->approved_status()); |
254 | - }else{ |
|
255 | + } else{ |
|
255 | 256 | $payment->set_status($this->_pay_model->declined_status()); |
256 | 257 | } |
257 | 258 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
@@ -263,7 +264,7 @@ discard block |
||
263 | 264 | $payment->set_extra_accntng($primary_registration_code); |
264 | 265 | $payment->set_details($PayPalResult); |
265 | 266 | } |
266 | - }catch(Exception $e){ |
|
267 | + } catch(Exception $e){ |
|
267 | 268 | $payment->set_status($this->_pay_model->failed_status()); |
268 | 269 | $payment->set_gateway_response($e->getMessage()); |
269 | 270 | } |
@@ -325,53 +326,62 @@ discard block |
||
325 | 326 | |
326 | 327 | // DP Fields |
327 | 328 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
328 | - foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
|
329 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
329 | + foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) { |
|
330 | + $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
331 | + } |
|
330 | 332 | |
331 | 333 | // CC Details Fields |
332 | 334 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
333 | - foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
|
334 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
335 | + foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) { |
|
336 | + $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
337 | + } |
|
335 | 338 | |
336 | 339 | // PayerInfo Type Fields |
337 | 340 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
338 | - foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
|
339 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
341 | + foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) { |
|
342 | + $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
343 | + } |
|
340 | 344 | |
341 | 345 | // Payer Name Fields |
342 | 346 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
343 | - foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
|
344 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
347 | + foreach ($PayerName as $PayerNameVar => $PayerNameVal) { |
|
348 | + $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
349 | + } |
|
345 | 350 | |
346 | 351 | // Address Fields (Billing) |
347 | 352 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
348 | - foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
|
349 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
353 | + foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) { |
|
354 | + $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
355 | + } |
|
350 | 356 | |
351 | 357 | // Payment Details Type Fields |
352 | 358 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
353 | - foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
|
354 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
359 | + foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) { |
|
360 | + $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
361 | + } |
|
355 | 362 | |
356 | 363 | // Payment Details Item Type Fields |
357 | 364 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
358 | 365 | $n = 0; |
359 | 366 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
360 | 367 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
361 | - foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
|
362 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
368 | + foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) { |
|
369 | + $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
370 | + } |
|
363 | 371 | $n++; |
364 | 372 | } |
365 | 373 | |
366 | 374 | // Ship To Address Fields |
367 | 375 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
368 | - foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
|
369 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
376 | + foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) { |
|
377 | + $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
378 | + } |
|
370 | 379 | |
371 | 380 | // 3D Secure Fields |
372 | 381 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
373 | - foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
|
374 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
382 | + foreach ($Secure3D as $Secure3DVar => $Secure3DVal) { |
|
383 | + $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
384 | + } |
|
375 | 385 | |
376 | 386 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
377 | 387 | $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
@@ -500,14 +510,15 @@ discard block |
||
500 | 510 | $CurrentError = $Errors[$ErrorVar]; |
501 | 511 | foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) { |
502 | 512 | $CurrentVarName = ''; |
503 | - if ($CurrentErrorVar == 'L_ERRORCODE') |
|
504 | - $CurrentVarName = 'Error Code'; |
|
505 | - elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') |
|
506 | - $CurrentVarName = 'Short Message'; |
|
507 | - elseif ($CurrentErrorVar == 'L_LONGMESSAGE') |
|
508 | - $CurrentVarName = 'Long Message'; |
|
509 | - elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
|
510 | - $CurrentVarName = 'Severity Code'; |
|
513 | + if ($CurrentErrorVar == 'L_ERRORCODE') { |
|
514 | + $CurrentVarName = 'Error Code'; |
|
515 | + } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') { |
|
516 | + $CurrentVarName = 'Short Message'; |
|
517 | + } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') { |
|
518 | + $CurrentVarName = 'Long Message'; |
|
519 | + } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') { |
|
520 | + $CurrentVarName = 'Severity Code'; |
|
521 | + } |
|
511 | 522 | |
512 | 523 | $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
513 | 524 | } |
@@ -1,6 +1,6 @@ discard block |
||
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 |
||
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,21 +88,21 @@ discard block |
||
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 = sprintf(__("Event Registrations from %s", "event_espresso"),get_bloginfo('name')); |
|
94 | + $order_description = sprintf(__("Event Registrations from %s", "event_espresso"), get_bloginfo('name')); |
|
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 | $item = array( |
102 | 102 | // Item Name. 127 char max. |
103 | - 'l_name' => substr($line_item->name(),0,127), |
|
103 | + 'l_name' => substr($line_item->name(), 0, 127), |
|
104 | 104 | // Item description. 127 char max. |
105 | - 'l_desc' => substr($line_item->desc(),0,127), |
|
105 | + 'l_desc' => substr($line_item->desc(), 0, 127), |
|
106 | 106 | // Cost of individual item. |
107 | 107 | 'l_amt' => $line_item->unit_price(), |
108 | 108 | // Item Number. 127 char max. |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | } |
124 | 124 | $item_amount = $total_line_item->get_items_total(); |
125 | 125 | $tax_amount = $total_line_item->get_total_tax(); |
126 | - }else{ |
|
126 | + } else { |
|
127 | 127 | $order_items = array(); |
128 | 128 | $item_amount = $payment->amount(); |
129 | - $single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code()); |
|
129 | + $single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code()); |
|
130 | 130 | $tax_amount = 0; |
131 | - array_push($order_items,array( |
|
131 | + array_push($order_items, array( |
|
132 | 132 | // Item Name. 127 char max. |
133 | - 'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'),$primary_registrant->reg_code()), |
|
133 | + 'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'), $primary_registrant->reg_code()), |
|
134 | 134 | // Item description. 127 char max. |
135 | 135 | 'l_desc' => $single_item_desc, |
136 | 136 | // Cost of individual item. |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | // Payer's salutation. 20 char max. |
178 | 178 | 'salutation' => '', |
179 | 179 | // Payer's first name. 25 char max. |
180 | - 'firstname' => substr($billing_info['first_name'],0,25), |
|
180 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
181 | 181 | // Payer's middle name. 25 char max. |
182 | 182 | 'middlename' => '', |
183 | 183 | // Payer's last name. 25 char max. |
184 | - 'lastname' => substr($billing_info['last_name'],0,25), |
|
184 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
185 | 185 | // Payer's suffix. 12 char max. |
186 | 186 | 'suffix' => '' |
187 | 187 | ); |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | // Required. Name of City. |
195 | 195 | 'city' => $billing_info['city'], |
196 | 196 | // Required. Name of State or Province. |
197 | - 'state' => substr( $billing_info['state'], 0, 40 ), |
|
197 | + 'state' => substr($billing_info['state'], 0, 40), |
|
198 | 198 | // Required. Country code. |
199 | 199 | 'countrycode' => $billing_info['country'], |
200 | 200 | // Required. Postal code of payer. |
201 | 201 | 'zip' => $billing_info['zip'], |
202 | 202 | // Phone Number of payer. 20 char max. |
203 | - 'shiptophonenum' => substr($billing_info['phone'],0,20) |
|
203 | + 'shiptophonenum' => substr($billing_info['phone'], 0, 20) |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | // Required. Three-letter currency code. Default is USD. |
211 | 211 | 'currencycode' => $payment->currency_code(), |
212 | 212 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
213 | - 'itemamt' => $this->format_currency($item_amount),// |
|
213 | + 'itemamt' => $this->format_currency($item_amount), // |
|
214 | 214 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
215 | 215 | 'shippingamt' => '', |
216 | 216 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | // Free-form field for your own use. 256 char max. |
223 | 223 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
224 | 224 | // Your own invoice or tracking number |
225 | - 'invnum' => wp_generate_password(12,false),//$transaction->ID(), |
|
225 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
226 | 226 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
227 | 227 | 'notifyurl' => '', |
228 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
228 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
229 | 229 | ); |
230 | 230 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
231 | 231 | $PayPalRequestData = array( |
@@ -238,32 +238,32 @@ discard block |
||
238 | 238 | 'OrderItems' => $order_items, |
239 | 239 | ); |
240 | 240 | $this->_log_clean_request($PayPalRequestData, $payment); |
241 | - try{ |
|
241 | + try { |
|
242 | 242 | $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
243 | 243 | //remove PCI-sensitive data so it doesn't get stored |
244 | - $PayPalResult = $this->_log_clean_response($PayPalResult,$payment); |
|
244 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
245 | 245 | |
246 | 246 | $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
247 | - if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) { |
|
248 | - $payment->set_status( $this->_pay_model->failed_status() ) ; |
|
249 | - $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
|
247 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
248 | + $payment->set_status($this->_pay_model->failed_status()); |
|
249 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
250 | 250 | $payment->set_details($PayPalResult); |
251 | - }else{ |
|
252 | - if($this->_APICallSuccessful($PayPalResult)){ |
|
251 | + } else { |
|
252 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
253 | 253 | $payment->set_status($this->_pay_model->approved_status()); |
254 | - }else{ |
|
254 | + } else { |
|
255 | 255 | $payment->set_status($this->_pay_model->declined_status()); |
256 | 256 | } |
257 | 257 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
258 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0); |
|
258 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
259 | 259 | $payment->set_gateway_response($message); |
260 | - $payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null); |
|
260 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
261 | 261 | |
262 | 262 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
263 | 263 | $payment->set_extra_accntng($primary_registration_code); |
264 | 264 | $payment->set_details($PayPalResult); |
265 | 265 | } |
266 | - }catch(Exception $e){ |
|
266 | + } catch (Exception $e) { |
|
267 | 267 | $payment->set_status($this->_pay_model->failed_status()); |
268 | 268 | $payment->set_gateway_response($e->getMessage()); |
269 | 269 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param EEI_Payment $payment |
281 | 281 | * @return array |
282 | 282 | */ |
283 | - private function _log_clean_request($request,$payment){ |
|
283 | + private function _log_clean_request($request, $payment) { |
|
284 | 284 | $cleaned_request_data = $request; |
285 | 285 | unset($cleaned_request_data['CCDetails']['acct']); |
286 | 286 | unset($cleaned_request_data['CCDetails']['cvv2']); |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | * @param EEI_Payment $payment |
297 | 297 | * @return array cleaned |
298 | 298 | */ |
299 | - private function _log_clean_response($response,$payment){ |
|
299 | + private function _log_clean_response($response, $payment) { |
|
300 | 300 | unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
301 | 301 | unset($response['REQUESTDATA']['ACCT']); |
302 | 302 | unset($response['REQUESTDATA']['EXPDATE']); |
303 | 303 | unset($response['REQUESTDATA']['CVV2']); |
304 | 304 | unset($response['RAWREQUEST']); |
305 | - $this->log(array('Paypal Response'=>$response),$payment); |
|
305 | + $this->log(array('Paypal Response'=>$response), $payment); |
|
306 | 306 | return $response; |
307 | 307 | } |
308 | 308 | |
@@ -327,32 +327,32 @@ discard block |
||
327 | 327 | // DP Fields |
328 | 328 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
329 | 329 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
330 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
330 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
331 | 331 | |
332 | 332 | // CC Details Fields |
333 | 333 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
334 | 334 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
335 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
335 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
336 | 336 | |
337 | 337 | // PayerInfo Type Fields |
338 | 338 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
339 | 339 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
340 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
340 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
341 | 341 | |
342 | 342 | // Payer Name Fields |
343 | 343 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
344 | 344 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
345 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
345 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
346 | 346 | |
347 | 347 | // Address Fields (Billing) |
348 | 348 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
349 | 349 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
350 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
350 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
351 | 351 | |
352 | 352 | // Payment Details Type Fields |
353 | 353 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
354 | 354 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
355 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
355 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
356 | 356 | |
357 | 357 | // Payment Details Item Type Fields |
358 | 358 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -360,22 +360,22 @@ discard block |
||
360 | 360 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
361 | 361 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
362 | 362 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
363 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
363 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
364 | 364 | $n++; |
365 | 365 | } |
366 | 366 | |
367 | 367 | // Ship To Address Fields |
368 | 368 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
369 | 369 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
370 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
370 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
371 | 371 | |
372 | 372 | // 3D Secure Fields |
373 | 373 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
374 | 374 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
375 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
375 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
376 | 376 | |
377 | 377 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
378 | - $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
|
378 | + $NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP; |
|
379 | 379 | $NVPResponse = $this->_CURLRequest($NVPRequest); |
380 | 380 | $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
381 | 381 | $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | private function _CURLRequest($Request) { |
400 | 400 | $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
401 | 401 | $curl = curl_init(); |
402 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) ); |
|
402 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE)); |
|
403 | 403 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
404 | 404 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
405 | 405 | curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | private function _APICallSuccessful($PayPalResult) { |
450 | 450 | $approved = false; |
451 | 451 | // check main response message from PayPal |
452 | - if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) { |
|
452 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
453 | 453 | $ack = strtoupper($PayPalResult['ACK']); |
454 | - $approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false; |
|
454 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | return $approved; |
@@ -467,11 +467,11 @@ discard block |
||
467 | 467 | |
468 | 468 | $Errors = array(); |
469 | 469 | $n = 0; |
470 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
471 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
472 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
473 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
474 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
470 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
471 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
472 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
473 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
474 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
475 | 475 | |
476 | 476 | $CurrentItem = array( |
477 | 477 | 'L_ERRORCODE' => $LErrorCode, |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
512 | 512 | $CurrentVarName = 'Severity Code'; |
513 | 513 | |
514 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
514 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | return $error; |
@@ -207,7 +207,7 @@ |
||
207 | 207 | |
208 | 208 | /** |
209 | 209 | * constructor |
210 | - * @param EE_Admin_Page $admin_page the calling admin_page_object |
|
210 | + * @param EE_Admin_Page $adminpage the calling admin_page_object |
|
211 | 211 | */ |
212 | 212 | public function __construct( EE_Admin_Page $adminpage ) { |
213 | 213 |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -217,12 +218,15 @@ discard block |
||
217 | 218 | $this->_set_hooks_properties(); |
218 | 219 | |
219 | 220 | //first let's verify we're on the right page |
220 | - if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) |
|
221 | - return; //get out nothing more to be done here. |
|
221 | + if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) { |
|
222 | + return; |
|
223 | + } |
|
224 | + //get out nothing more to be done here. |
|
222 | 225 | |
223 | 226 | //allow for extends to modify properties |
224 | - if ( method_exists( $this, '_extend_properties' ) ) |
|
225 | - $this->_extend_properties(); |
|
227 | + if ( method_exists( $this, '_extend_properties' ) ) { |
|
228 | + $this->_extend_properties(); |
|
229 | + } |
|
226 | 230 | |
227 | 231 | $this->_set_page_object(); |
228 | 232 | $this->_init_hooks(); |
@@ -305,8 +309,10 @@ discard block |
||
305 | 309 | } |
306 | 310 | |
307 | 311 | //k now lets do the enqueues |
308 | - if( !isset( $this->_scripts_styles['enqueues'] ) ) |
|
309 | - return; //not sure if we should throw an error here or not. |
|
312 | + if( !isset( $this->_scripts_styles['enqueues'] ) ) { |
|
313 | + return; |
|
314 | + } |
|
315 | + //not sure if we should throw an error here or not. |
|
310 | 316 | foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) { |
311 | 317 | //make sure $routes is an array |
312 | 318 | $routes = (array) $routes; |
@@ -323,8 +329,9 @@ discard block |
||
323 | 329 | } |
324 | 330 | |
325 | 331 | //let's do the deregisters |
326 | - if ( !isset( $this->_scripts_styles['deregisters'] ) ) |
|
327 | - return; |
|
332 | + if ( !isset( $this->_scripts_styles['deregisters'] ) ) { |
|
333 | + return; |
|
334 | + } |
|
328 | 335 | foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) { |
329 | 336 | $defaults = array( |
330 | 337 | 'type' => 'js' |
@@ -376,8 +383,9 @@ discard block |
||
376 | 383 | |
377 | 384 | //first default file (if exists) |
378 | 385 | $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php'; |
379 | - if ( is_readable( $decaf_file ) ) |
|
380 | - require_once( $decaf_file ); |
|
386 | + if ( is_readable( $decaf_file ) ) { |
|
387 | + require_once( $decaf_file ); |
|
388 | + } |
|
381 | 389 | |
382 | 390 | //now we have to do require for extended file (if needed) |
383 | 391 | if ( $this->_extend ) { |
@@ -486,12 +494,14 @@ discard block |
||
486 | 494 | |
487 | 495 | foreach ( $hook_filter_array as $hook => $args ) { |
488 | 496 | if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) { |
489 | - if ( isset( $this->_wp_action_filters_priority[$hook] ) ) |
|
490 | - $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
|
491 | - if ( $args['type'] == 'action' ) |
|
492 | - add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
493 | - else |
|
494 | - add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
497 | + if ( isset( $this->_wp_action_filters_priority[$hook] ) ) { |
|
498 | + $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
|
499 | + } |
|
500 | + if ( $args['type'] == 'action' ) { |
|
501 | + add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
502 | + } else { |
|
503 | + add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
504 | + } |
|
495 | 505 | } |
496 | 506 | } |
497 | 507 | |
@@ -504,8 +514,10 @@ discard block |
||
504 | 514 | */ |
505 | 515 | private function _ajax_hooks() { |
506 | 516 | |
507 | - if ( empty( $this->_ajax_func) ) |
|
508 | - return; //get out there's nothing to take care of. |
|
517 | + if ( empty( $this->_ajax_func) ) { |
|
518 | + return; |
|
519 | + } |
|
520 | + //get out there's nothing to take care of. |
|
509 | 521 | |
510 | 522 | foreach ( $this->_ajax_func as $action => $method ) { |
511 | 523 | //make sure method exists |
@@ -528,8 +540,10 @@ discard block |
||
528 | 540 | * @return void |
529 | 541 | */ |
530 | 542 | protected function _init_hooks() { |
531 | - if ( empty( $this->_init_func) ) |
|
532 | - return; //get out there's nothing to take care of. |
|
543 | + if ( empty( $this->_init_func) ) { |
|
544 | + return; |
|
545 | + } |
|
546 | + //get out there's nothing to take care of. |
|
533 | 547 | |
534 | 548 | //We need to determine what page_route we are on! |
535 | 549 | $current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
@@ -541,8 +555,9 @@ discard block |
||
541 | 555 | $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
542 | 556 | throw new EE_Error( implode('||', $msg ) ); |
543 | 557 | } |
544 | - if ( $route == $this->_current_route ) |
|
545 | - add_action('admin_init', array( $this, $method ) ); |
|
558 | + if ( $route == $this->_current_route ) { |
|
559 | + add_action('admin_init', array( $this, $method ) ); |
|
560 | + } |
|
546 | 561 | } |
547 | 562 | |
548 | 563 | } |
@@ -557,8 +572,10 @@ discard block |
||
557 | 572 | * @return void |
558 | 573 | */ |
559 | 574 | public function add_metaboxes() { |
560 | - if ( empty( $this->_metaboxes ) ) |
|
561 | - return; //get out we don't have any metaboxes to set for this connection |
|
575 | + if ( empty( $this->_metaboxes ) ) { |
|
576 | + return; |
|
577 | + } |
|
578 | + //get out we don't have any metaboxes to set for this connection |
|
562 | 579 | |
563 | 580 | $this->_handle_metabox_array( $this->_metaboxes ); |
564 | 581 | |
@@ -569,19 +586,24 @@ discard block |
||
569 | 586 | private function _handle_metabox_array( $boxes, $add = TRUE ) { |
570 | 587 | |
571 | 588 | foreach ( $boxes as $box ) { |
572 | - if ( !isset($box['page_route']) ) |
|
573 | - continue; //we dont' have a valid array |
|
589 | + if ( !isset($box['page_route']) ) { |
|
590 | + continue; |
|
591 | + } |
|
592 | + //we dont' have a valid array |
|
574 | 593 | |
575 | 594 | //let's make sure $box['page_route'] is an array so the "foreach" will work. |
576 | 595 | $box['page_route'] = (array) $box['page_route']; |
577 | 596 | |
578 | 597 | foreach ( $box['page_route'] as $route ) { |
579 | - if ( $route != $this->_current_route ) |
|
580 | - continue; //get out we only add metaboxes for set route. |
|
581 | - if ( $add ) |
|
582 | - $this->_add_metabox($box); |
|
583 | - else |
|
584 | - $this->_remove_metabox($box); |
|
598 | + if ( $route != $this->_current_route ) { |
|
599 | + continue; |
|
600 | + } |
|
601 | + //get out we only add metaboxes for set route. |
|
602 | + if ( $add ) { |
|
603 | + $this->_add_metabox($box); |
|
604 | + } else { |
|
605 | + $this->_remove_metabox($box); |
|
606 | + } |
|
585 | 607 | } |
586 | 608 | } |
587 | 609 | } |
@@ -596,8 +618,10 @@ discard block |
||
596 | 618 | */ |
597 | 619 | public function remove_metaboxes() { |
598 | 620 | |
599 | - if ( empty( $this->_remove_metaboxes ) ) |
|
600 | - return; //get out there are no metaboxes to remove |
|
621 | + if ( empty( $this->_remove_metaboxes ) ) { |
|
622 | + return; |
|
623 | + } |
|
624 | + //get out there are no metaboxes to remove |
|
601 | 625 | |
602 | 626 | $this->_handle_metabox_array( $this->_remove_metaboxes, FALSE ); |
603 | 627 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * constructor |
210 | 210 | * @param EE_Admin_Page $admin_page the calling admin_page_object |
211 | 211 | */ |
212 | - public function __construct( EE_Admin_Page $adminpage ) { |
|
212 | + public function __construct(EE_Admin_Page $adminpage) { |
|
213 | 213 | |
214 | 214 | $this->_adminpage_obj = $adminpage; |
215 | 215 | $this->_req_data = array_merge($_GET, $_POST); |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | $this->_set_hooks_properties(); |
218 | 218 | |
219 | 219 | //first let's verify we're on the right page |
220 | - if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) |
|
220 | + if ( ! isset($this->_req_data['page']) || (isset($this->_req_data['page']) && $this->_adminpage_obj->page_slug != $this->_req_data['page'])) |
|
221 | 221 | return; //get out nothing more to be done here. |
222 | 222 | |
223 | 223 | //allow for extends to modify properties |
224 | - if ( method_exists( $this, '_extend_properties' ) ) |
|
224 | + if (method_exists($this, '_extend_properties')) |
|
225 | 225 | $this->_extend_properties(); |
226 | 226 | |
227 | 227 | $this->_set_page_object(); |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | $this->_load_custom_methods(); |
230 | 230 | $this->_load_routed_hooks(); |
231 | 231 | |
232 | - add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts_styles' ) ); |
|
233 | - add_action( 'admin_enqueue_scripts', array($this, 'add_metaboxes'), 20 ); |
|
234 | - add_action( 'admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15 ); |
|
232 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
233 | + add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20); |
|
234 | + add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15); |
|
235 | 235 | |
236 | 236 | $this->_ajax_hooks(); |
237 | 237 | |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function enqueue_scripts_styles() { |
274 | 274 | |
275 | - if ( !empty( $this->_scripts_styles ) ) { |
|
275 | + if ( ! empty($this->_scripts_styles)) { |
|
276 | 276 | //first let's do all the registrations |
277 | - if ( !isset($this->_scripts_styles['registers'] ) ) { |
|
277 | + if ( ! isset($this->_scripts_styles['registers'])) { |
|
278 | 278 | $msg[] = __('There is no "registers" index in the <code>$this->_scripts_styles</code> property.', 'event_espresso'); |
279 | - $msg[] = sprintf ( __('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>' . $this->caller . '</strong>' ); |
|
280 | - throw new EE_Error( implode( '||', $msg ) ); |
|
279 | + $msg[] = sprintf(__('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>'.$this->caller.'</strong>'); |
|
280 | + throw new EE_Error(implode('||', $msg)); |
|
281 | 281 | } |
282 | 282 | |
283 | - foreach( $this->_scripts_styles['registers'] as $ref => $details ) { |
|
283 | + foreach ($this->_scripts_styles['registers'] as $ref => $details) { |
|
284 | 284 | $defaults = array( |
285 | 285 | 'type' => 'js', |
286 | 286 | 'url' => '', |
@@ -289,48 +289,48 @@ discard block |
||
289 | 289 | 'footer' => TRUE |
290 | 290 | ); |
291 | 291 | $details = wp_parse_args($details, $defaults); |
292 | - extract( $details ); |
|
292 | + extract($details); |
|
293 | 293 | |
294 | 294 | //let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do |
295 | 295 | $this->_scripts_styles['registers'][$ref]['type'] = $type; |
296 | 296 | |
297 | 297 | //let's make sure we're not missing any REQUIRED parameters |
298 | - if ( empty($url) ) { |
|
299 | - $msg[] = sprintf( __('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet' ); |
|
300 | - $msg[] = sprintf( __('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>' . $this->caller . '</strong>', $ref ); |
|
301 | - throw new EE_Error( implode( '||', $msg ) ); |
|
298 | + if (empty($url)) { |
|
299 | + $msg[] = sprintf(__('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet'); |
|
300 | + $msg[] = sprintf(__('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>'.$this->caller.'</strong>', $ref); |
|
301 | + throw new EE_Error(implode('||', $msg)); |
|
302 | 302 | } |
303 | 303 | //made it here so let's do the appropriate registration |
304 | - $type == 'js' ? wp_register_script( $ref, $url, $depends, $version, $footer ) : wp_register_style( $ref, $url, $depends, $version ); |
|
304 | + $type == 'js' ? wp_register_script($ref, $url, $depends, $version, $footer) : wp_register_style($ref, $url, $depends, $version); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | //k now lets do the enqueues |
308 | - if( !isset( $this->_scripts_styles['enqueues'] ) ) |
|
309 | - return; //not sure if we should throw an error here or not. |
|
310 | - foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) { |
|
308 | + if ( ! isset($this->_scripts_styles['enqueues'])) |
|
309 | + return; //not sure if we should throw an error here or not. |
|
310 | + foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) { |
|
311 | 311 | //make sure $routes is an array |
312 | 312 | $routes = (array) $routes; |
313 | 313 | |
314 | - if ( in_array($this->_current_route, $routes ) ) { |
|
314 | + if (in_array($this->_current_route, $routes)) { |
|
315 | 315 | $this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref) : wp_enqueue_style($ref); |
316 | 316 | //if we have a localization for the script let's do that too. |
317 | - if ( isset( $this->_scripts_styles['localize'][$ref] ) ) { |
|
318 | - foreach ( $this->_scripts_styles['localize'][$ref] as $object_name => $indexes ) { |
|
319 | - wp_localize_script($ref, $object_name , $this->_scripts_styles['localize'][$ref][$object_name] ); |
|
317 | + if (isset($this->_scripts_styles['localize'][$ref])) { |
|
318 | + foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) { |
|
319 | + wp_localize_script($ref, $object_name, $this->_scripts_styles['localize'][$ref][$object_name]); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | 325 | //let's do the deregisters |
326 | - if ( !isset( $this->_scripts_styles['deregisters'] ) ) |
|
326 | + if ( ! isset($this->_scripts_styles['deregisters'])) |
|
327 | 327 | return; |
328 | - foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) { |
|
328 | + foreach ($this->_scripts_styles['deregisters'] as $ref => $details) { |
|
329 | 329 | $defaults = array( |
330 | 330 | 'type' => 'js' |
331 | 331 | ); |
332 | - $details = wp_parse_args( $details, $defaults ); |
|
333 | - extract( $details ); |
|
332 | + $details = wp_parse_args($details, $defaults); |
|
333 | + extract($details); |
|
334 | 334 | |
335 | 335 | $type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref); |
336 | 336 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | private function _set_defaults() { |
351 | 351 | $this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array(); |
352 | - $this->_current_route = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
|
352 | + $this->_current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
353 | 353 | $this->caller = get_class($this); |
354 | 354 | $this->_extend = stripos($this->caller, 'Extend') ? TRUE : FALSE; |
355 | 355 | } |
@@ -364,34 +364,34 @@ discard block |
||
364 | 364 | */ |
365 | 365 | protected function _set_page_object() { |
366 | 366 | //first make sure $this->_name is set |
367 | - if ( empty( $this->_name ) ) { |
|
367 | + if (empty($this->_name)) { |
|
368 | 368 | $msg[] = __('We can\'t load the page object', 'event_espresso'); |
369 | - $msg[] = sprintf( __("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller ); |
|
370 | - throw new EE_Error( implode( '||', $msg ) ); |
|
369 | + $msg[] = sprintf(__("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller); |
|
370 | + throw new EE_Error(implode('||', $msg)); |
|
371 | 371 | } |
372 | 372 | |
373 | - $ref = str_replace('_' , ' ', $this->_name); //take the_message -> the message |
|
374 | - $ref = str_replace(' ', '_', ucwords($ref) ) . '_Admin_Page'; //take the message -> The_Message |
|
373 | + $ref = str_replace('_', ' ', $this->_name); //take the_message -> the message |
|
374 | + $ref = str_replace(' ', '_', ucwords($ref)).'_Admin_Page'; //take the message -> The_Message |
|
375 | 375 | |
376 | 376 | //first default file (if exists) |
377 | - $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php'; |
|
378 | - if ( is_readable( $decaf_file ) ) |
|
379 | - require_once( $decaf_file ); |
|
377 | + $decaf_file = EE_ADMIN_PAGES.$this->_name.DS.$ref.'.core.php'; |
|
378 | + if (is_readable($decaf_file)) |
|
379 | + require_once($decaf_file); |
|
380 | 380 | |
381 | 381 | //now we have to do require for extended file (if needed) |
382 | - if ( $this->_extend ) { |
|
383 | - require_once( EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php' ); |
|
382 | + if ($this->_extend) { |
|
383 | + require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.DS.'Extend_'.$ref.'.core.php'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | //if we've got an extended class we use that! |
388 | - $ref = $this->_extend ? 'Extend_' . $ref : $ref; |
|
388 | + $ref = $this->_extend ? 'Extend_'.$ref : $ref; |
|
389 | 389 | |
390 | 390 | //let's make sure the class exists |
391 | - if ( !class_exists( $ref ) ) { |
|
391 | + if ( ! class_exists($ref)) { |
|
392 | 392 | $msg[] = __('We can\'t load the page object', 'event_espresso'); |
393 | - $msg[] = sprintf( __('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref ); |
|
394 | - throw new EE_Error( implode( '||', $msg ) ); |
|
393 | + $msg[] = sprintf(__('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref); |
|
394 | + throw new EE_Error(implode('||', $msg)); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | $a = new ReflectionClass($ref); |
@@ -416,27 +416,27 @@ discard block |
||
416 | 416 | $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route; |
417 | 417 | |
418 | 418 | //these run before the Admin_Page route executes. |
419 | - if ( method_exists( $this, $method_callback ) ) { |
|
420 | - call_user_func( array( $this, $method_callback) ); |
|
419 | + if (method_exists($this, $method_callback)) { |
|
420 | + call_user_func(array($this, $method_callback)); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
424 | 424 | //these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes. There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens. |
425 | 425 | //first the actions |
426 | 426 | //note that these action hooks will have the $query_args value available. |
427 | - $admin_class_name = get_class( $this->_adminpage_obj ); |
|
427 | + $admin_class_name = get_class($this->_adminpage_obj); |
|
428 | 428 | |
429 | - if ( method_exists( $this, '_redirect_action_early_' . $this->_current_route ) ) { |
|
430 | - add_action( 'AHEE__' . $admin_class_name . '___redirect_after_action__before_redirect_modification_' . $this->_current_route, array( $this, '_redirect_action_early_' . $this->_current_route ), 10 ); |
|
429 | + if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) { |
|
430 | + add_action('AHEE__'.$admin_class_name.'___redirect_after_action__before_redirect_modification_'.$this->_current_route, array($this, '_redirect_action_early_'.$this->_current_route), 10); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( method_exists( $this, '_redirect_action_' . $this->_current_route ) ) { |
|
434 | - add_action( 'AHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_action_' . $this->_current_route ), 10 ); |
|
433 | + if (method_exists($this, '_redirect_action_'.$this->_current_route)) { |
|
434 | + add_action('AHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_action_'.$this->_current_route), 10); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | //let's hook into the _redirect itself and allow for changing where the user goes after redirect. This will have $query_args and $redirect_url available. |
438 | - if ( method_exists( $this, '_redirect_filter_' . $this->_current_route ) ) { |
|
439 | - add_filter( 'FHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_filter_' . $this->_current_route ), 10, 2 ); |
|
438 | + if (method_exists($this, '_redirect_filter_'.$this->_current_route)) { |
|
439 | + add_filter('FHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_filter_'.$this->_current_route), 10, 2); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | } |
@@ -459,12 +459,12 @@ discard block |
||
459 | 459 | 'argnum' => 1, |
460 | 460 | 'priority' => 10 |
461 | 461 | ), |
462 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array( |
|
462 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array( |
|
463 | 463 | 'type' => 'filter', |
464 | 464 | 'argnum' => 1, |
465 | 465 | 'priority' => 10 |
466 | 466 | ), |
467 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array( |
|
467 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug => array( |
|
468 | 468 | 'type' => 'filter', |
469 | 469 | 'argnum' => 1, |
470 | 470 | 'priority' => 10 |
@@ -483,14 +483,14 @@ discard block |
||
483 | 483 | |
484 | 484 | |
485 | 485 | |
486 | - foreach ( $hook_filter_array as $hook => $args ) { |
|
487 | - if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) { |
|
488 | - if ( isset( $this->_wp_action_filters_priority[$hook] ) ) |
|
486 | + foreach ($hook_filter_array as $hook => $args) { |
|
487 | + if (method_exists($this, $this->_current_route.'_'.$hook)) { |
|
488 | + if (isset($this->_wp_action_filters_priority[$hook])) |
|
489 | 489 | $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
490 | - if ( $args['type'] == 'action' ) |
|
491 | - add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
490 | + if ($args['type'] == 'action') |
|
491 | + add_action($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']); |
|
492 | 492 | else |
493 | - add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
493 | + add_filter($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -503,18 +503,18 @@ discard block |
||
503 | 503 | */ |
504 | 504 | private function _ajax_hooks() { |
505 | 505 | |
506 | - if ( empty( $this->_ajax_func) ) |
|
506 | + if (empty($this->_ajax_func)) |
|
507 | 507 | return; //get out there's nothing to take care of. |
508 | 508 | |
509 | - foreach ( $this->_ajax_func as $action => $method ) { |
|
509 | + foreach ($this->_ajax_func as $action => $method) { |
|
510 | 510 | //make sure method exists |
511 | - if ( !method_exists($this, $method) ) { |
|
512 | - $msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso') . '<br />'; |
|
513 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
|
514 | - throw new EE_Error( implode('||', $msg ) ); |
|
511 | + if ( ! method_exists($this, $method)) { |
|
512 | + $msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso').'<br />'; |
|
513 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller); |
|
514 | + throw new EE_Error(implode('||', $msg)); |
|
515 | 515 | } |
516 | 516 | |
517 | - add_action('wp_ajax_' . $action, array( $this, $method ) ); |
|
517 | + add_action('wp_ajax_'.$action, array($this, $method)); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | } |
@@ -527,21 +527,21 @@ discard block |
||
527 | 527 | * @return void |
528 | 528 | */ |
529 | 529 | protected function _init_hooks() { |
530 | - if ( empty( $this->_init_func) ) |
|
530 | + if (empty($this->_init_func)) |
|
531 | 531 | return; //get out there's nothing to take care of. |
532 | 532 | |
533 | 533 | //We need to determine what page_route we are on! |
534 | - $current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
|
534 | + $current_route = isset ($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
535 | 535 | |
536 | - foreach ( $this->_init_func as $route => $method ) { |
|
536 | + foreach ($this->_init_func as $route => $method) { |
|
537 | 537 | //make sure method exists |
538 | - if ( !method_exists($this, $method) ) { |
|
539 | - $msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso') . '<br />'; |
|
540 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
|
541 | - throw new EE_Error( implode('||', $msg ) ); |
|
538 | + if ( ! method_exists($this, $method)) { |
|
539 | + $msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso').'<br />'; |
|
540 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller); |
|
541 | + throw new EE_Error(implode('||', $msg)); |
|
542 | 542 | } |
543 | - if ( $route == $this->_current_route ) |
|
544 | - add_action('admin_init', array( $this, $method ) ); |
|
543 | + if ($route == $this->_current_route) |
|
544 | + add_action('admin_init', array($this, $method)); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | } |
@@ -556,28 +556,28 @@ discard block |
||
556 | 556 | * @return void |
557 | 557 | */ |
558 | 558 | public function add_metaboxes() { |
559 | - if ( empty( $this->_metaboxes ) ) |
|
559 | + if (empty($this->_metaboxes)) |
|
560 | 560 | return; //get out we don't have any metaboxes to set for this connection |
561 | 561 | |
562 | - $this->_handle_metabox_array( $this->_metaboxes ); |
|
562 | + $this->_handle_metabox_array($this->_metaboxes); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
566 | 566 | |
567 | 567 | |
568 | - private function _handle_metabox_array( $boxes, $add = TRUE ) { |
|
568 | + private function _handle_metabox_array($boxes, $add = TRUE) { |
|
569 | 569 | |
570 | - foreach ( $boxes as $box ) { |
|
571 | - if ( !isset($box['page_route']) ) |
|
570 | + foreach ($boxes as $box) { |
|
571 | + if ( ! isset($box['page_route'])) |
|
572 | 572 | continue; //we dont' have a valid array |
573 | 573 | |
574 | 574 | //let's make sure $box['page_route'] is an array so the "foreach" will work. |
575 | 575 | $box['page_route'] = (array) $box['page_route']; |
576 | 576 | |
577 | - foreach ( $box['page_route'] as $route ) { |
|
578 | - if ( $route != $this->_current_route ) |
|
577 | + foreach ($box['page_route'] as $route) { |
|
578 | + if ($route != $this->_current_route) |
|
579 | 579 | continue; //get out we only add metaboxes for set route. |
580 | - if ( $add ) |
|
580 | + if ($add) |
|
581 | 581 | $this->_add_metabox($box); |
582 | 582 | else |
583 | 583 | $this->_remove_metabox($box); |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function remove_metaboxes() { |
597 | 597 | |
598 | - if ( empty( $this->_remove_metaboxes ) ) |
|
598 | + if (empty($this->_remove_metaboxes)) |
|
599 | 599 | return; //get out there are no metaboxes to remove |
600 | 600 | |
601 | - $this->_handle_metabox_array( $this->_remove_metaboxes, FALSE ); |
|
601 | + $this->_handle_metabox_array($this->_remove_metaboxes, FALSE); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -608,53 +608,53 @@ discard block |
||
608 | 608 | * @access private |
609 | 609 | * @param array $args an array of args that have been set for this metabox by the child class |
610 | 610 | */ |
611 | - private function _add_metabox( $args ) { |
|
611 | + private function _add_metabox($args) { |
|
612 | 612 | $current_screen = get_current_screen(); |
613 | - $screen_id = is_object( $current_screen ) ? $current_screen->id : NULL; |
|
614 | - $func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback'; |
|
613 | + $screen_id = is_object($current_screen) ? $current_screen->id : NULL; |
|
614 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
615 | 615 | |
616 | 616 | //set defaults |
617 | 617 | $defaults = array( |
618 | 618 | 'func' => $func, |
619 | - 'id' => $this->caller . '_' . $func . '_metabox', |
|
619 | + 'id' => $this->caller.'_'.$func.'_metabox', |
|
620 | 620 | 'priority' => 'default', |
621 | 621 | 'label' => $this->caller, |
622 | 622 | 'context' => 'advanced', |
623 | 623 | 'callback_args' => array(), |
624 | - 'page' => isset( $args['page'] ) ? $args['page'] : $screen_id |
|
624 | + 'page' => isset($args['page']) ? $args['page'] : $screen_id |
|
625 | 625 | ); |
626 | 626 | |
627 | - $args = wp_parse_args( $args, $defaults ); |
|
627 | + $args = wp_parse_args($args, $defaults); |
|
628 | 628 | extract($args); |
629 | 629 | |
630 | 630 | |
631 | 631 | //make sure method exists |
632 | - if ( !method_exists($this, $func) ) { |
|
633 | - $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />'; |
|
634 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $func, $this->caller ); |
|
635 | - throw new EE_Error( implode('||', $msg ) ); |
|
632 | + if ( ! method_exists($this, $func)) { |
|
633 | + $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />'; |
|
634 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $func, $this->caller); |
|
635 | + throw new EE_Error(implode('||', $msg)); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | //everything checks out so lets add the metabox |
639 | - add_meta_box( $id, $label, array( $this, $func ), $page, $context, $priority, $callback_args); |
|
639 | + add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | |
643 | 643 | |
644 | - private function _remove_metabox( $args ) { |
|
644 | + private function _remove_metabox($args) { |
|
645 | 645 | $current_screen = get_current_screen(); |
646 | - $screen_id = is_object( $current_screen ) ? $current_screen->id : NULL; |
|
647 | - $func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback'; |
|
646 | + $screen_id = is_object($current_screen) ? $current_screen->id : NULL; |
|
647 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
648 | 648 | |
649 | 649 | //set defaults |
650 | 650 | $defaults = array( |
651 | - 'id' => isset( $args['id'] ) ? $args['id'] : $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox', |
|
651 | + 'id' => isset($args['id']) ? $args['id'] : $this->_current_route.'_'.$this->caller.'_'.$func.'_metabox', |
|
652 | 652 | 'context' => 'default', |
653 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : $screen_id |
|
653 | + 'screen' => isset($args['screen']) ? $args['screen'] : $screen_id |
|
654 | 654 | ); |
655 | 655 | |
656 | - $args = wp_parse_args( $args, $defaults ); |
|
657 | - extract( $args ); |
|
656 | + $args = wp_parse_args($args, $defaults); |
|
657 | + extract($args); |
|
658 | 658 | |
659 | 659 | //everything checks out so lets remove the box! |
660 | 660 | remove_meta_box($id, $screen, $context); |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | /** |
305 | 305 | * _get_hidden_fields |
306 | 306 | * returns a html string of hidden fields so if any table filters are used the current view will be respected. |
307 | - * @return html string |
|
307 | + * @return string string |
|
308 | 308 | */ |
309 | 309 | protected function _get_hidden_fields() { |
310 | 310 | $action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : ''; |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @since 4.1 |
513 | 513 | * @access public |
514 | 514 | * |
515 | - * @param object $item The current item |
|
515 | + * @param EE_Message_Template_Group $item The current item |
|
516 | 516 | */ |
517 | 517 | public function single_row( $item ) { |
518 | 518 | $row_class = $this->_get_row_class( $item ); |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | |
34 | 34 | if ( ! class_exists( 'WP_List_Table' )) { |
35 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
35 | + require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | abstract class EE_Admin_List_Table extends WP_List_Table { |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | |
6 | 7 | /** |
@@ -362,8 +363,9 @@ discard block |
||
362 | 363 | |
363 | 364 | $sortable = array(); |
364 | 365 | foreach ( $_sortable as $id => $data ) { |
365 | - if ( empty( $data ) ) |
|
366 | - continue; |
|
366 | + if ( empty( $data ) ) { |
|
367 | + continue; |
|
368 | + } |
|
367 | 369 | |
368 | 370 | //fix for offset errors with WP_List_Table default get_columninfo() |
369 | 371 | if ( is_array($data) ) { |
@@ -375,8 +377,9 @@ discard block |
||
375 | 377 | |
376 | 378 | $data = (array) $data; |
377 | 379 | |
378 | - if ( !isset( $data[1] ) ) |
|
379 | - $_data[1] = false; |
|
380 | + if ( !isset( $data[1] ) ) { |
|
381 | + $_data[1] = false; |
|
382 | + } |
|
380 | 383 | |
381 | 384 | |
382 | 385 | $sortable[$id] = $_data; |
@@ -399,11 +402,12 @@ discard block |
||
399 | 402 | $actions = array(); |
400 | 403 | //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
401 | 404 | foreach ( $this->_views as $view => $args) { |
402 | - if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) |
|
403 | - //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
|
405 | + if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) { |
|
406 | + //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
|
404 | 407 | foreach ( $args['bulk_action'] as $route =>$label ) { |
405 | 408 | if ( $this->_admin_page->check_user_access( $route, true ) ) { |
406 | 409 | $actions[$route] = $label; |
410 | + } |
|
407 | 411 | } |
408 | 412 | } |
409 | 413 | } |
@@ -633,14 +637,12 @@ discard block |
||
633 | 637 | echo '<th scope="row" class="check-column">'; |
634 | 638 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
635 | 639 | echo '</th>'; |
636 | - } |
|
637 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
640 | + } elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
638 | 641 | echo "<td $attributes>"; |
639 | 642 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this ); |
640 | 643 | echo $this->handle_row_actions( $item, $column_name, $primary ); |
641 | 644 | echo "</td>"; |
642 | - } |
|
643 | - else { |
|
645 | + } else { |
|
644 | 646 | echo "<td $attributes>"; |
645 | 647 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this ); |
646 | 648 | echo $this->handle_row_actions( $item, $column_name, $primary ); |
@@ -656,7 +658,7 @@ discard block |
||
656 | 658 | $this->_filters(); |
657 | 659 | echo $this->_get_hidden_fields(); |
658 | 660 | echo '<br class="clear">'; |
659 | - }else{ |
|
661 | + } else{ |
|
660 | 662 | echo '<div class="list-table-bottom-buttons alignleft actions">'; |
661 | 663 | foreach($this->_bottom_buttons as $type => $action){ |
662 | 664 | $route = isset( $action['route'] ) ? $action['route'] : ''; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * ------------------------------------------------------------------------ |
32 | 32 | */ |
33 | 33 | |
34 | -if ( ! class_exists( 'WP_List_Table' )) { |
|
35 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
34 | +if ( ! class_exists('WP_List_Table')) { |
|
35 | + require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | abstract class EE_Admin_List_Table extends WP_List_Table { |
@@ -234,16 +234,16 @@ discard block |
||
234 | 234 | * constructor |
235 | 235 | * @param EE_Admin_Page object $admin_page we use this for obtaining everything we need in the list table. |
236 | 236 | */ |
237 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
237 | + public function __construct(EE_Admin_Page $admin_page) { |
|
238 | 238 | $this->_admin_page = $admin_page; |
239 | 239 | $this->_req_data = $this->_admin_page->get_request_data(); |
240 | 240 | $this->_view = $this->_admin_page->get_view(); |
241 | - $this->_views = empty( $this->_views ) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
241 | + $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
242 | 242 | $this->_current_page = $this->get_pagenum(); |
243 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
244 | - $this->_yes_no = array( __('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
243 | + $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view(); |
|
244 | + $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
245 | 245 | |
246 | - $this->_per_page = $this->get_items_per_page( $this->_screen . '_per_page', 10 ); |
|
246 | + $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10); |
|
247 | 247 | |
248 | 248 | $this->_setup_data(); |
249 | 249 | $this->_add_view_counts(); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $this->_set_properties(); |
254 | 254 | |
255 | 255 | //set primary column |
256 | - add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ) ); |
|
256 | + add_filter('list_table_primary_column', array($this, 'set_primary_column')); |
|
257 | 257 | |
258 | 258 | //set parent defaults |
259 | 259 | parent::__construct($this->_wp_list_args); |
@@ -329,17 +329,17 @@ discard block |
||
329 | 329 | * @return html string |
330 | 330 | */ |
331 | 331 | protected function _get_hidden_fields() { |
332 | - $action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : ''; |
|
333 | - $action = empty( $action ) && isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : $action; |
|
332 | + $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
333 | + $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
334 | 334 | //if action is STILL empty, then we set it to default |
335 | - $action = empty( $action ) ? 'default' : $action; |
|
336 | - $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
337 | - $field .= '<input type="hidden" name="route" value="'. $action .'" />' . "\n";/**/ |
|
338 | - $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
335 | + $action = empty($action) ? 'default' : $action; |
|
336 | + $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n"; |
|
337 | + $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/ |
|
338 | + $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n"; |
|
339 | 339 | |
340 | 340 | $bulk_actions = $this->_get_bulk_actions(); |
341 | - foreach ( $bulk_actions as $bulk_action => $label ) { |
|
342 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce ( $bulk_action . '_nonce' ) . '" />' . "\n"; |
|
341 | + foreach ($bulk_actions as $bulk_action => $label) { |
|
342 | + $field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n"; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | return $field; |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @var array |
371 | 371 | */ |
372 | - $_sortable = apply_filters( "FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen ); |
|
372 | + $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
373 | 373 | |
374 | 374 | $sortable = array(); |
375 | - foreach ( $_sortable as $id => $data ) { |
|
376 | - if ( empty( $data ) ) |
|
375 | + foreach ($_sortable as $id => $data) { |
|
376 | + if (empty($data)) |
|
377 | 377 | continue; |
378 | 378 | |
379 | 379 | //fix for offset errors with WP_List_Table default get_columninfo() |
380 | - if ( is_array($data) ) { |
|
380 | + if (is_array($data)) { |
|
381 | 381 | $_data[0] = key($data); |
382 | 382 | $_data[1] = isset($data[1]) ? $data[1] : false; |
383 | 383 | } else { |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | |
387 | 387 | $data = (array) $data; |
388 | 388 | |
389 | - if ( !isset( $data[1] ) ) |
|
389 | + if ( ! isset($data[1])) |
|
390 | 390 | $_data[1] = false; |
391 | 391 | |
392 | 392 | |
393 | 393 | $sortable[$id] = $_data; |
394 | 394 | } |
395 | 395 | $primary = $this->get_primary_column_name(); |
396 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
396 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * @return string |
403 | 403 | */ |
404 | 404 | protected function get_primary_column_name() { |
405 | - foreach( class_parents( $this ) as $parent ) { |
|
406 | - if ( method_exists( $parent, 'get_primary_column_name' ) && $parent == 'WP_List_Table' ) { |
|
405 | + foreach (class_parents($this) as $parent) { |
|
406 | + if (method_exists($parent, 'get_primary_column_name') && $parent == 'WP_List_Table') { |
|
407 | 407 | return parent::get_primary_column_name(); |
408 | 408 | } |
409 | 409 | } |
@@ -415,10 +415,10 @@ discard block |
||
415 | 415 | * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
419 | - foreach( class_parents( $this ) as $parent ) { |
|
420 | - if ( method_exists( $parent, 'handle_row_actions' ) && $parent == 'WP_List_Table' ) { |
|
421 | - return parent::handle_row_actions( $item, $column_name, $primary ); |
|
418 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
419 | + foreach (class_parents($this) as $parent) { |
|
420 | + if (method_exists($parent, 'handle_row_actions') && $parent == 'WP_List_Table') { |
|
421 | + return parent::handle_row_actions($item, $column_name, $primary); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | ''; |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | protected function _get_bulk_actions() { |
437 | 437 | $actions = array(); |
438 | 438 | //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
439 | - foreach ( $this->_views as $view => $args) { |
|
440 | - if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) |
|
439 | + foreach ($this->_views as $view => $args) { |
|
440 | + if (isset($args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view) |
|
441 | 441 | //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
442 | - foreach ( $args['bulk_action'] as $route =>$label ) { |
|
443 | - if ( $this->_admin_page->check_user_access( $route, true ) ) { |
|
442 | + foreach ($args['bulk_action'] as $route =>$label) { |
|
443 | + if ($this->_admin_page->check_user_access($route, true)) { |
|
444 | 444 | $actions[$route] = $label; |
445 | 445 | } |
446 | 446 | } |
@@ -458,18 +458,18 @@ discard block |
||
458 | 458 | */ |
459 | 459 | private function _filters() { |
460 | 460 | $classname = get_class($this); |
461 | - $filters = apply_filters( "FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen ); |
|
461 | + $filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen); |
|
462 | 462 | |
463 | - if ( empty( $filters )) { |
|
463 | + if (empty($filters)) { |
|
464 | 464 | return; |
465 | 465 | } |
466 | - foreach ( $filters as $filter ) { |
|
466 | + foreach ($filters as $filter) { |
|
467 | 467 | echo $filter; |
468 | 468 | } |
469 | 469 | //add filter button at end |
470 | - echo '<input type="submit" class="button-secondary" value="' . __('Filter', 'event_espresso') . '" id="post-query-submit" />'; |
|
470 | + echo '<input type="submit" class="button-secondary" value="'.__('Filter', 'event_espresso').'" id="post-query-submit" />'; |
|
471 | 471 | //add reset filters button at end |
472 | - echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', 'event_espresso') . '</a>'; |
|
472 | + echo '<a class="button button-secondary" href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', 'event_espresso').'</a>'; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | * @param string $column_name |
484 | 484 | * @return string |
485 | 485 | */ |
486 | - public function set_primary_column( $column_name ) { |
|
487 | - return ! empty( $this->_primary_column ) ? $this->_primary_column : $column_name; |
|
486 | + public function set_primary_column($column_name) { |
|
487 | + return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | array( |
504 | 504 | 'total_items' => $total_items, |
505 | 505 | 'per_page' => $this->_per_page, |
506 | - 'total_pages' => ceil($total_items / $this->_per_page ) |
|
506 | + 'total_pages' => ceil($total_items / $this->_per_page) |
|
507 | 507 | ) |
508 | 508 | ); |
509 | 509 | } |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return string html content for the column |
521 | 521 | */ |
522 | - public function column_default( $item, $column_name ) { |
|
522 | + public function column_default($item, $column_name) { |
|
523 | 523 | /** |
524 | 524 | * Dynamic hook allowing for adding additional column content in this list table. |
525 | 525 | * Note that $this->screen->id is in the format |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * hook prefix ("event-espresso") will be different. |
530 | 530 | * |
531 | 531 | */ |
532 | - do_action( 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, $this->_screen ); |
|
532 | + do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, $this->_screen); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * |
546 | 546 | * @var array |
547 | 547 | */ |
548 | - $columns = apply_filters( 'FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen ); |
|
548 | + $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen); |
|
549 | 549 | return $columns; |
550 | 550 | } |
551 | 551 | |
@@ -557,18 +557,18 @@ discard block |
||
557 | 557 | $views = $this->get_views(); |
558 | 558 | $assembled_views = ''; |
559 | 559 | |
560 | - if ( empty( $views )) { |
|
560 | + if (empty($views)) { |
|
561 | 561 | return; |
562 | 562 | } |
563 | 563 | echo "<ul class='subsubsub'>\n"; |
564 | - foreach ( $views as $view ) { |
|
565 | - $count = isset($view['count'] ) && !empty($view['count']) ? absint( $view['count'] ) : 0; |
|
566 | - if ( isset( $view['slug'] ) && isset( $view['class'] ) && isset( $view['url'] ) && isset( $view['label']) ) { |
|
567 | - $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
564 | + foreach ($views as $view) { |
|
565 | + $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
566 | + if (isset($view['slug']) && isset($view['class']) && isset($view['url']) && isset($view['label'])) { |
|
567 | + $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>'; |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | - echo is_array( $assembled_views) && ! empty( $assembled_views ) ? implode( " |</li>\n", $assembled_views ) . "</li>\n" : ''; |
|
571 | + echo is_array($assembled_views) && ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : ''; |
|
572 | 572 | echo "</ul>"; |
573 | 573 | } |
574 | 574 | |
@@ -581,10 +581,10 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @param object $item The current item |
583 | 583 | */ |
584 | - public function single_row( $item ) { |
|
585 | - $row_class = $this->_get_row_class( $item ); |
|
586 | - echo '<tr class="' . esc_attr( $row_class ) . '">'; |
|
587 | - $this->single_row_columns( $item ); |
|
584 | + public function single_row($item) { |
|
585 | + $row_class = $this->_get_row_class($item); |
|
586 | + echo '<tr class="'.esc_attr($row_class).'">'; |
|
587 | + $this->single_row_columns($item); |
|
588 | 588 | echo '</tr>'; |
589 | 589 | } |
590 | 590 | |
@@ -595,13 +595,13 @@ discard block |
||
595 | 595 | * @param object $item the current item |
596 | 596 | * @return string |
597 | 597 | */ |
598 | - protected function _get_row_class( $item ) { |
|
598 | + protected function _get_row_class($item) { |
|
599 | 599 | static $row_class = ''; |
600 | - $row_class = ( $row_class == '' ? 'alternate' : '' ); |
|
600 | + $row_class = ($row_class == '' ? 'alternate' : ''); |
|
601 | 601 | |
602 | 602 | $new_row_class = $row_class; |
603 | 603 | |
604 | - if ( !empty($this->_ajax_sorting_callback) ) { |
|
604 | + if ( ! empty($this->_ajax_sorting_callback)) { |
|
605 | 605 | $new_row_class .= ' rowsortable'; |
606 | 606 | } |
607 | 607 | |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | |
621 | 621 | public function get_hidden_columns() { |
622 | 622 | $user_id = get_current_user_id(); |
623 | - $has_default = get_user_option('default'. $this->screen->id . 'columnshidden', $user_id); |
|
624 | - if ( empty( $has_default ) && !empty($this->_hidden_columns ) ) { |
|
625 | - update_user_option($user_id, 'default'.$this->screen->id . 'columnshidden', TRUE); |
|
626 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, TRUE ); |
|
623 | + $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id); |
|
624 | + if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
625 | + update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', TRUE); |
|
626 | + update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, TRUE); |
|
627 | 627 | } |
628 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
629 | - $saved_columns = (array) get_user_option( $ref, $user_id ); |
|
628 | + $ref = 'manage'.$this->screen->id.'columnshidden'; |
|
629 | + $saved_columns = (array) get_user_option($ref, $user_id); |
|
630 | 630 | return $saved_columns; |
631 | 631 | } |
632 | 632 | |
@@ -641,47 +641,47 @@ discard block |
||
641 | 641 | * |
642 | 642 | * @param object $item The current item |
643 | 643 | */ |
644 | - public function single_row_columns( $item ) { |
|
645 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
644 | + public function single_row_columns($item) { |
|
645 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
646 | 646 | |
647 | 647 | global $wp_version; |
648 | - $use_hidden_class = version_compare( $wp_version, '4.3-RC', '>=' ); |
|
648 | + $use_hidden_class = version_compare($wp_version, '4.3-RC', '>='); |
|
649 | 649 | |
650 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
650 | + foreach ($columns as $column_name => $column_display_name) { |
|
651 | 651 | |
652 | 652 | /** |
653 | 653 | * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are |
654 | 654 | * hidden or not instead of using "display:none;". This bit of code provides backward compat. |
655 | 655 | */ |
656 | - $hidden_class = $use_hidden_class && in_array( $column_name, $hidden ) ? ' hidden' : ''; |
|
657 | - $style = ! $use_hidden_class && in_array( $column_name, $hidden ) ? ' style="display:none;"' : ''; |
|
656 | + $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
|
657 | + $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
|
658 | 658 | |
659 | - $classes = $column_name . ' column-' . $column_name.$hidden_class; |
|
660 | - if ( $primary == $column_name ) { |
|
659 | + $classes = $column_name.' column-'.$column_name.$hidden_class; |
|
660 | + if ($primary == $column_name) { |
|
661 | 661 | $classes .= ' has-row-actions column-primary'; |
662 | 662 | } |
663 | 663 | |
664 | - $data = ' data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
664 | + $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
665 | 665 | |
666 | 666 | $class = "class='$classes'"; |
667 | 667 | |
668 | 668 | $attributes = "$class$style$data"; |
669 | 669 | |
670 | - if ( 'cb' === $column_name ) { |
|
670 | + if ('cb' === $column_name) { |
|
671 | 671 | echo '<th scope="row" class="check-column">'; |
672 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
|
672 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb($item), $item, $this); |
|
673 | 673 | echo '</th>'; |
674 | 674 | } |
675 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
675 | + elseif (method_exists($this, 'column_'.$column_name)) { |
|
676 | 676 | echo "<td $attributes>"; |
677 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this ); |
|
678 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
677 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content', call_user_func(array($this, 'column_'.$column_name), $item), $item, $this); |
|
678 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
679 | 679 | echo "</td>"; |
680 | 680 | } |
681 | 681 | else { |
682 | 682 | echo "<td $attributes>"; |
683 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this ); |
|
684 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
683 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default($item, $column_name), $item, $column_name, $this); |
|
684 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
685 | 685 | echo "</td>"; |
686 | 686 | } |
687 | 687 | } |
@@ -689,19 +689,19 @@ discard block |
||
689 | 689 | |
690 | 690 | |
691 | 691 | |
692 | - public function extra_tablenav( $which ) { |
|
693 | - if ( $which == 'top' ) { |
|
692 | + public function extra_tablenav($which) { |
|
693 | + if ($which == 'top') { |
|
694 | 694 | $this->_filters(); |
695 | 695 | echo $this->_get_hidden_fields(); |
696 | 696 | echo '<br class="clear">'; |
697 | - }else{ |
|
697 | + } else { |
|
698 | 698 | echo '<div class="list-table-bottom-buttons alignleft actions">'; |
699 | - foreach($this->_bottom_buttons as $type => $action){ |
|
700 | - $route = isset( $action['route'] ) ? $action['route'] : ''; |
|
701 | - $extra_request = isset( $action['extra_request'] ) ? $action['extra_request'] : ''; |
|
699 | + foreach ($this->_bottom_buttons as $type => $action) { |
|
700 | + $route = isset($action['route']) ? $action['route'] : ''; |
|
701 | + $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
702 | 702 | echo $this->_admin_page->get_action_link_or_button($route, $type, $extra_request); |
703 | 703 | } |
704 | - do_action( 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen ); |
|
704 | + do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
705 | 705 | echo '</div>'; |
706 | 706 | } |
707 | 707 | //echo $this->_entries_per_page_dropdown; |
@@ -751,13 +751,13 @@ discard block |
||
751 | 751 | * |
752 | 752 | * @return string The assembled action elements container. |
753 | 753 | */ |
754 | - protected function _action_string( $action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '' ) { |
|
754 | + protected function _action_string($action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '') { |
|
755 | 755 | $content = ''; |
756 | - $action_class = ! empty( $action_class ) ? ' class="' . $action_class . '"' : ''; |
|
757 | - $action_id = ! empty( $action_id ) ? ' id="' . $action_id . '"' : ''; |
|
758 | - $content .= ! empty( $action_container ) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
759 | - $content .= apply_filters( 'FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this ); |
|
760 | - $content .= ! empty( $container ) ? '</' . $container . '>' : ''; |
|
756 | + $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : ''; |
|
757 | + $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : ''; |
|
758 | + $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : ''; |
|
759 | + $content .= apply_filters('FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this); |
|
760 | + $content .= ! empty($container) ? '</'.$container.'>' : ''; |
|
761 | 761 | return $content; |
762 | 762 | } |
763 | 763 | } |
@@ -150,7 +150,7 @@ |
||
150 | 150 | * |
151 | 151 | * @param array $menu_args An array of arguments used to setup the menu |
152 | 152 | * properties on construct. |
153 | - * @param array $required An array of keys that should be in the $menu_args, this |
|
153 | + * @param string[] $required An array of keys that should be in the $menu_args, this |
|
154 | 154 | * is used to validate that the items that should be defined |
155 | 155 | * are present. |
156 | 156 | * @return void |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @package Event Espresso |
16 | 16 | * @subpackage admin |
17 | 17 | */ |
18 | -abstract class EE_Admin_Page_Menu_Map { |
|
18 | +abstract class EE_Admin_Page_Menu_Map { |
|
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
@@ -155,28 +155,28 @@ discard block |
||
155 | 155 | * are present. |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public function __construct( $menu_args, $required ) { |
|
158 | + public function __construct($menu_args, $required) { |
|
159 | 159 | //filter all args before processing so plugins can manipulate various settings for menus. |
160 | - $menu_args = apply_filters( 'FHEE__EE_Admin_Page_Menu_Map__construct__menu_args', $menu_args, $required, get_class( $this ) ); |
|
160 | + $menu_args = apply_filters('FHEE__EE_Admin_Page_Menu_Map__construct__menu_args', $menu_args, $required, get_class($this)); |
|
161 | 161 | |
162 | 162 | |
163 | 163 | //verify that required keys are present in the incoming array. |
164 | - $missing = array_diff( (array) $required, array_keys( (array) $menu_args ) ); |
|
164 | + $missing = array_diff((array) $required, array_keys((array) $menu_args)); |
|
165 | 165 | |
166 | - if ( !empty( $missing ) ) { |
|
167 | - throw new EE_Error( sprintf( __('%s is missing some expected keys in the argument array. The following keys are missing: %s', 'event_espresso'), get_class( $this ), implode(', ', $missing ) ) ); |
|
166 | + if ( ! empty($missing)) { |
|
167 | + throw new EE_Error(sprintf(__('%s is missing some expected keys in the argument array. The following keys are missing: %s', 'event_espresso'), get_class($this), implode(', ', $missing))); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | //made it here okay, so let's set the properties! |
171 | - foreach ( $menu_args as $prop => $value ) { |
|
171 | + foreach ($menu_args as $prop => $value) { |
|
172 | 172 | |
173 | - switch ( $prop ) { |
|
173 | + switch ($prop) { |
|
174 | 174 | case 'show_on_menu' : |
175 | 175 | $value = (int) $value; |
176 | 176 | break; |
177 | 177 | case 'admin_init_page' : |
178 | - if ( in_array( 'admin_init_page', $required ) && ! $value instanceof EE_Admin_Page_Init ) { |
|
179 | - throw new EE_Error( sprintf( __('The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object. Instead %s was given as the value.', 'event_espresso'), print_r($value, TRUE) ) ); |
|
178 | + if (in_array('admin_init_page', $required) && ! $value instanceof EE_Admin_Page_Init) { |
|
179 | + throw new EE_Error(sprintf(__('The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object. Instead %s was given as the value.', 'event_espresso'), print_r($value, TRUE))); |
|
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case 'menu_callback' : |
@@ -187,24 +187,24 @@ discard block |
||
187 | 187 | break; |
188 | 188 | |
189 | 189 | } |
190 | - if ( ! EEH_Class_Tools::has_property( $this, $prop ) ) |
|
191 | - throw new EE_Error( sprintf( __('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class( $this ), $prop ) ); |
|
190 | + if ( ! EEH_Class_Tools::has_property($this, $prop)) |
|
191 | + throw new EE_Error(sprintf(__('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class($this), $prop)); |
|
192 | 192 | $this->{$prop} = $value; |
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | 196 | //filter capabilities (both static and dynamic) |
197 | - $this->capability = apply_filters( 'FHEE_management_capability', $this->capability, NULL ); |
|
198 | - $this->capability = apply_filters( 'FHEE_' . $this->menu_slug . '_capability', $this->capability, NULL ); |
|
197 | + $this->capability = apply_filters('FHEE_management_capability', $this->capability, NULL); |
|
198 | + $this->capability = apply_filters('FHEE_'.$this->menu_slug.'_capability', $this->capability, NULL); |
|
199 | 199 | |
200 | 200 | //Might need to change parent slug depending on maintenance mode. |
201 | - if ( ! empty( $this->maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
201 | + if ( ! empty($this->maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
202 | 202 | $this->parent_slug = $this->maintenance_mode_parent; |
203 | 203 | } |
204 | 204 | |
205 | 205 | //if empty menu_callback let's set default (but only if we have admin page init object) |
206 | - if ( empty( $this->menu_callback ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) |
|
207 | - $this->menu_callback = array( $this->admin_init_page, 'initialize_admin_page' ); |
|
206 | + if (empty($this->menu_callback) && $this->admin_init_page instanceof EE_Admin_Page_Init) |
|
207 | + $this->menu_callback = array($this->admin_init_page, 'initialize_admin_page'); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -226,21 +226,21 @@ discard block |
||
226 | 226 | * @param boolean $network_admin whether this is being added to the network admin page or not |
227 | 227 | * @since 4.4.0 |
228 | 228 | */ |
229 | - public function add_menu_page( $network_admin = FALSE ) { |
|
229 | + public function add_menu_page($network_admin = FALSE) { |
|
230 | 230 | |
231 | 231 | $show_on_menu_int = (int) $this->show_on_menu; |
232 | - if( ( $network_admin && in_array( $show_on_menu_int, array( self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY ), TRUE ) ) |
|
232 | + if (($network_admin && in_array($show_on_menu_int, array(self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY), TRUE)) |
|
233 | 233 | || |
234 | - ( ! $network_admin && in_array( $show_on_menu_int, array( self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY ), TRUE )) ){ |
|
234 | + ( ! $network_admin && in_array($show_on_menu_int, array(self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY), TRUE))) { |
|
235 | 235 | $wp_page_slug = $this->_add_menu_page(); |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | $wp_page_slug = ''; |
238 | 238 | } |
239 | 239 | |
240 | - if ( !empty( $wp_page_slug ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) { |
|
240 | + if ( ! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
241 | 241 | try { |
242 | - $this->admin_init_page->set_page_dependencies( $wp_page_slug ); |
|
243 | - } catch( EE_Error $e ) { |
|
242 | + $this->admin_init_page->set_page_dependencies($wp_page_slug); |
|
243 | + } catch (EE_Error $e) { |
|
244 | 244 | $e->get_error(); |
245 | 245 | } |
246 | 246 | } |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | public $position; |
294 | 294 | |
295 | 295 | |
296 | - public function __construct( $menu_args ) { |
|
297 | - $required = array( 'menu_label', 'parent_slug', 'menu_slug', 'menu_group', 'menu_order', 'admin_init_page'); |
|
296 | + public function __construct($menu_args) { |
|
297 | + $required = array('menu_label', 'parent_slug', 'menu_slug', 'menu_group', 'menu_order', 'admin_init_page'); |
|
298 | 298 | |
299 | - parent::__construct( $menu_args, $required ); |
|
299 | + parent::__construct($menu_args, $required); |
|
300 | 300 | |
301 | - $this->position = ! empty( $this->position ) ? (int) $this->position : $this->position; |
|
301 | + $this->position = ! empty($this->position) ? (int) $this->position : $this->position; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * Uses the proper WP utility for registering a menu page for the main WP pages. |
307 | 307 | */ |
308 | 308 | protected function _add_menu_page() { |
309 | - $main = add_menu_page( $this->title, $this->menu_label, $this->capability, $this->parent_slug, $this->menu_callback, $this->icon_url, $this->position ); |
|
310 | - if ( ! empty( $this->subtitle ) ) { |
|
311 | - add_submenu_page( $this->parent_slug, $this->subtitle, $this->subtitle, $this->capability, $this->menu_slug, $this->menu_callback ); |
|
309 | + $main = add_menu_page($this->title, $this->menu_label, $this->capability, $this->parent_slug, $this->menu_callback, $this->icon_url, $this->position); |
|
310 | + if ( ! empty($this->subtitle)) { |
|
311 | + add_submenu_page($this->parent_slug, $this->subtitle, $this->subtitle, $this->capability, $this->menu_slug, $this->menu_callback); |
|
312 | 312 | } |
313 | 313 | return $main; |
314 | 314 | } |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | */ |
326 | 326 | class EE_Admin_Page_Sub_Menu extends EE_Admin_Page_Main_Menu { |
327 | 327 | |
328 | - public function __construct( $menu_args ) { |
|
329 | - parent::__construct( $menu_args ); |
|
328 | + public function __construct($menu_args) { |
|
329 | + parent::__construct($menu_args); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | 333 | protected function _add_menu_page() { |
334 | - return add_submenu_page( $this->parent_slug, $this->title, $this->menu_label, $this->capability, $this->menu_slug, $this->menu_callback ); |
|
334 | + return add_submenu_page($this->parent_slug, $this->title, $this->menu_label, $this->capability, $this->menu_slug, $this->menu_callback); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | } //end class EE_Admin_Page_Menu_Map |
@@ -352,18 +352,18 @@ discard block |
||
352 | 352 | |
353 | 353 | |
354 | 354 | |
355 | - public function __construct( $menu_args = array() ) { |
|
356 | - $required = array( 'menu_label', 'menu_slug', 'menu_order', 'parent_slug' ); |
|
357 | - parent::__construct( $menu_args, $required ); |
|
355 | + public function __construct($menu_args = array()) { |
|
356 | + $required = array('menu_label', 'menu_slug', 'menu_order', 'parent_slug'); |
|
357 | + parent::__construct($menu_args, $required); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
361 | 361 | protected function _add_menu_page() { |
362 | - return add_submenu_page( $this->parent_slug, $this->menu_label, $this->_group_link(), $this->capability, $this->menu_slug, '__return_false' ); |
|
362 | + return add_submenu_page($this->parent_slug, $this->menu_label, $this->_group_link(), $this->capability, $this->menu_slug, '__return_false'); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
366 | 366 | private function _group_link() { |
367 | - return '<span class="ee_menu_group" onclick="return false;">' . $this->menu_label . '</span>'; |
|
367 | + return '<span class="ee_menu_group" onclick="return false;">'.$this->menu_label.'</span>'; |
|
368 | 368 | } |
369 | 369 | } //end EE_Admin_Page_Menu_Group |
@@ -187,8 +187,9 @@ discard block |
||
187 | 187 | break; |
188 | 188 | |
189 | 189 | } |
190 | - if ( ! EEH_Class_Tools::has_property( $this, $prop ) ) |
|
191 | - throw new EE_Error( sprintf( __('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class( $this ), $prop ) ); |
|
190 | + if ( ! EEH_Class_Tools::has_property( $this, $prop ) ) { |
|
191 | + throw new EE_Error( sprintf( __('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class( $this ), $prop ) ); |
|
192 | + } |
|
192 | 193 | $this->{$prop} = $value; |
193 | 194 | |
194 | 195 | } |
@@ -203,8 +204,9 @@ discard block |
||
203 | 204 | } |
204 | 205 | |
205 | 206 | //if empty menu_callback let's set default (but only if we have admin page init object) |
206 | - if ( empty( $this->menu_callback ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) |
|
207 | - $this->menu_callback = array( $this->admin_init_page, 'initialize_admin_page' ); |
|
207 | + if ( empty( $this->menu_callback ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) { |
|
208 | + $this->menu_callback = array( $this->admin_init_page, 'initialize_admin_page' ); |
|
209 | + } |
|
208 | 210 | |
209 | 211 | } |
210 | 212 | |
@@ -233,7 +235,7 @@ discard block |
||
233 | 235 | || |
234 | 236 | ( ! $network_admin && in_array( $show_on_menu_int, array( self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY ), TRUE )) ){ |
235 | 237 | $wp_page_slug = $this->_add_menu_page(); |
236 | - }else{ |
|
238 | + } else{ |
|
237 | 239 | $wp_page_slug = ''; |
238 | 240 | } |
239 | 241 |
@@ -111,7 +111,7 @@ |
||
111 | 111 | * |
112 | 112 | * @access public |
113 | 113 | * @param boolean $caf used to indicate if this tour is happening on caf install or not. |
114 | - * @return void |
|
114 | + * @return EE_Help_Tour |
|
115 | 115 | */ |
116 | 116 | public function __construct($caf = FALSE) { |
117 | 117 | $this->_is_caf = $caf; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function __construct($caf = FALSE) { |
117 | 117 | $this->_is_caf = $caf; |
118 | - $this->_req_data = array_merge( $_GET, $_POST ); |
|
118 | + $this->_req_data = array_merge($_GET, $_POST); |
|
119 | 119 | $this->_set_tour_properties(); |
120 | 120 | $this->_set_tour_stops(); |
121 | 121 | $this->_set_tour_options(); |
@@ -158,36 +158,36 @@ discard block |
||
158 | 158 | * @access protected |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - protected function _set_tour_options( $options = array() ) { |
|
161 | + protected function _set_tour_options($options = array()) { |
|
162 | 162 | $defaults = array( |
163 | - 'tipLocation' => 'bottom', // 'top', 'bottom', 'right', 'left' in relation to parent |
|
164 | - 'nubPosition' => 'auto', // override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left" |
|
165 | - 'tipAdjustmentY' => 0, //allow for adjustment of tip |
|
166 | - 'tipAdjustmentX' => 0, //allow for adjustment of tip |
|
163 | + 'tipLocation' => 'bottom', // 'top', 'bottom', 'right', 'left' in relation to parent |
|
164 | + 'nubPosition' => 'auto', // override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left" |
|
165 | + 'tipAdjustmentY' => 0, //allow for adjustment of tip |
|
166 | + 'tipAdjustmentX' => 0, //allow for adjustment of tip |
|
167 | 167 | 'scroll' => true, //whether to scrollTo the next step or not |
168 | - 'scrollSpeed' => 300, // Page scrolling speed in ms |
|
169 | - 'timer' => 0, // 0 = off, all other numbers = time(ms) |
|
170 | - 'autoStart' => true, // true or false - false tour starts when restart called |
|
171 | - 'startTimerOnClick' => true, // true/false to start timer on first click |
|
172 | - 'nextButton' => true, // true/false for next button visibility |
|
168 | + 'scrollSpeed' => 300, // Page scrolling speed in ms |
|
169 | + 'timer' => 0, // 0 = off, all other numbers = time(ms) |
|
170 | + 'autoStart' => true, // true or false - false tour starts when restart called |
|
171 | + 'startTimerOnClick' => true, // true/false to start timer on first click |
|
172 | + 'nextButton' => true, // true/false for next button visibility |
|
173 | 173 | 'button_text' => __('Next', 'event_espresso'), |
174 | - 'tipAnimation' => 'fade', // 'pop' or 'fade' in each tip |
|
175 | - 'pauseAfter' => array(), // array of indexes where to pause the tour after |
|
176 | - 'tipAnimationFadeSpeed' => 300, // if 'fade'- speed in ms of transition |
|
177 | - 'cookieMonster' => true, // true/false for whether cookies are used |
|
178 | - 'cookieName' => $this->get_slug(), // choose your own cookie name (setup will add the prefix for the specific page joyride) |
|
179 | - 'cookieDomain' => false, // set to false or yoursite.com |
|
174 | + 'tipAnimation' => 'fade', // 'pop' or 'fade' in each tip |
|
175 | + 'pauseAfter' => array(), // array of indexes where to pause the tour after |
|
176 | + 'tipAnimationFadeSpeed' => 300, // if 'fade'- speed in ms of transition |
|
177 | + 'cookieMonster' => true, // true/false for whether cookies are used |
|
178 | + 'cookieName' => $this->get_slug(), // choose your own cookie name (setup will add the prefix for the specific page joyride) |
|
179 | + 'cookieDomain' => false, // set to false or yoursite.com |
|
180 | 180 | //'tipContainer' => 'body', // Where the tip be attached if not inline |
181 | - 'modal' => false, // Whether to cover page with modal during the tour |
|
182 | - 'expose' => false, // Whether to expose the elements at each step in the tour (requires modal:true), |
|
183 | - 'postExposeCallback' => 'EEHelpTour.postExposeCallback', // A method to call after an element has been exposed |
|
184 | - 'preRideCallback' => 'EEHelpTour_preRideCallback', // A method to call before the tour starts (passed index, tip, and cloned exposed element) |
|
185 | - 'postRideCallback' => 'EEHelpTour_postRideCallback', // a method to call once the tour closes. This will correspond to the name of a js method that will have to be defined in loaded js. |
|
186 | - 'preStepCallback' => 'EEHelpTour_preStepCallback', // A method to call before each step |
|
187 | - 'postStepCallback' => 'EEHelpTour_postStepCallback', // A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/ |
|
181 | + 'modal' => false, // Whether to cover page with modal during the tour |
|
182 | + 'expose' => false, // Whether to expose the elements at each step in the tour (requires modal:true), |
|
183 | + 'postExposeCallback' => 'EEHelpTour.postExposeCallback', // A method to call after an element has been exposed |
|
184 | + 'preRideCallback' => 'EEHelpTour_preRideCallback', // A method to call before the tour starts (passed index, tip, and cloned exposed element) |
|
185 | + 'postRideCallback' => 'EEHelpTour_postRideCallback', // a method to call once the tour closes. This will correspond to the name of a js method that will have to be defined in loaded js. |
|
186 | + 'preStepCallback' => 'EEHelpTour_preStepCallback', // A method to call before each step |
|
187 | + 'postStepCallback' => 'EEHelpTour_postStepCallback', // A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/ |
|
188 | 188 | ); |
189 | 189 | |
190 | - $options = !empty( $options ) && is_array($options) ? array_merge( $defaults, $options ) : $defaults; |
|
190 | + $options = ! empty($options) && is_array($options) ? array_merge($defaults, $options) : $defaults; |
|
191 | 191 | $this->_options = $options; |
192 | 192 | } |
193 | 193 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | * @return string slug for the tour |
203 | 203 | */ |
204 | 204 | public function get_slug() { |
205 | - if ( empty( $this->_slug ) ) |
|
206 | - throw new EE_Error( sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
205 | + if (empty($this->_slug)) |
|
206 | + throw new EE_Error(sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this))); |
|
207 | 207 | return $this->_slug; |
208 | 208 | } |
209 | 209 | |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @return string |
216 | 216 | */ |
217 | 217 | public function get_label() { |
218 | - if ( empty( $this->_label ) ) |
|
219 | - throw new EE_Error( sprintf( __('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
218 | + if (empty($this->_label)) |
|
219 | + throw new EE_Error(sprintf(__('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this))); |
|
220 | 220 | return $this->_label; |
221 | 221 | } |
222 | 222 | |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * @return array |
228 | 228 | */ |
229 | 229 | public function get_stops() { |
230 | - foreach( $this->_stops as $ind => $stop ) { |
|
231 | - if ( ! isset( $stop['button_text'] ) ) { |
|
230 | + foreach ($this->_stops as $ind => $stop) { |
|
231 | + if ( ! isset($stop['button_text'])) { |
|
232 | 232 | $this->_stops[$ind]['button_text'] = $this->_options['button_text']; |
233 | 233 | } |
234 | 234 | } |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function get_options() { |
245 | 245 | //let's make sure there are not pauses set |
246 | - foreach ( $this->_stops as $ind => $stop ) { |
|
247 | - if ( isset( $stop['pause_after'] ) && $stop['pause_after'] ) { |
|
246 | + foreach ($this->_stops as $ind => $stop) { |
|
247 | + if (isset($stop['pause_after']) && $stop['pause_after']) { |
|
248 | 248 | $this->_options['pauseAfter'][] = $ind; |
249 | 249 | } |
250 | 250 | } |
251 | - return apply_filters( 'FHEE__' . get_class($this) . '__get_options', $this->_options, $this ); |
|
251 | + return apply_filters('FHEE__'.get_class($this).'__get_options', $this->_options, $this); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -202,8 +203,9 @@ discard block |
||
202 | 203 | * @return string slug for the tour |
203 | 204 | */ |
204 | 205 | public function get_slug() { |
205 | - if ( empty( $this->_slug ) ) |
|
206 | - throw new EE_Error( sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
206 | + if ( empty( $this->_slug ) ) { |
|
207 | + throw new EE_Error( sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
208 | + } |
|
207 | 209 | return $this->_slug; |
208 | 210 | } |
209 | 211 | |
@@ -215,8 +217,9 @@ discard block |
||
215 | 217 | * @return string |
216 | 218 | */ |
217 | 219 | public function get_label() { |
218 | - if ( empty( $this->_label ) ) |
|
219 | - throw new EE_Error( sprintf( __('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
220 | + if ( empty( $this->_label ) ) { |
|
221 | + throw new EE_Error( sprintf( __('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
222 | + } |
|
220 | 223 | return $this->_label; |
221 | 224 | } |
222 | 225 |
@@ -161,6 +161,7 @@ |
||
161 | 161 | * |
162 | 162 | * @param int $att_nmbr |
163 | 163 | * @param EE_Line_Item | string $item |
164 | + * @param EE_Line_Item $item |
|
164 | 165 | * @return string |
165 | 166 | */ |
166 | 167 | public function generate_reg_url_link( $att_nmbr, $item ) { |
@@ -1,5 +1,5 @@ discard block |
||
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 | * Class EE_Registration_Processor |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function instance() { |
62 | 62 | // check if class object is instantiated |
63 | - if ( ! self::$_instance instanceof EE_Registration_Processor ) { |
|
63 | + if ( ! self::$_instance instanceof EE_Registration_Processor) { |
|
64 | 64 | self::$_instance = new self(); |
65 | 65 | } |
66 | 66 | return self::$_instance; |
@@ -96,37 +96,37 @@ discard block |
||
96 | 96 | * @return \EE_Registration | null |
97 | 97 | * @throws \EE_Error |
98 | 98 | */ |
99 | - public function generate_ONE_registration_from_line_item( EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1 ) { |
|
99 | + public function generate_ONE_registration_from_line_item(EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1) { |
|
100 | 100 | // grab the related ticket object for this line_item |
101 | 101 | $ticket = $line_item->ticket(); |
102 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
103 | - EE_Error::add_error( sprintf( __( "Line item %s did not contain a valid ticket", "event_espresso" ), $line_item->ID() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
102 | + if ( ! $ticket instanceof EE_Ticket) { |
|
103 | + EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $line_item->ID()), __FILE__, __FUNCTION__, __LINE__); |
|
104 | 104 | return null; |
105 | 105 | } |
106 | - $first_datetime = $ticket->get_first_related( 'Datetime' ); |
|
107 | - if ( ! $first_datetime instanceof EE_Datetime ) { |
|
108 | - EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with any valid datetimes.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
106 | + $first_datetime = $ticket->get_first_related('Datetime'); |
|
107 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
108 | + EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__); |
|
109 | 109 | return null; |
110 | 110 | } |
111 | - $event = $first_datetime->get_first_related( 'Event' ); |
|
112 | - if ( ! $event instanceof EE_Event ) { |
|
113 | - EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with a valid event.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + $event = $first_datetime->get_first_related('Event'); |
|
112 | + if ( ! $event instanceof EE_Event) { |
|
113 | + EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__); |
|
114 | 114 | return null; |
115 | 115 | } |
116 | - $reg_url_link = $this->generate_reg_url_link( $att_nmbr, $line_item ); |
|
116 | + $reg_url_link = $this->generate_reg_url_link($att_nmbr, $line_item); |
|
117 | 117 | |
118 | - if( $this->_reg_final_price_per_tkt_line_item === null ) { |
|
119 | - $this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
118 | + if ($this->_reg_final_price_per_tkt_line_item === null) { |
|
119 | + $this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
120 | 120 | } |
121 | 121 | //ok now find this new registration's final price |
122 | - if( isset( $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ) ) { |
|
123 | - $final_price = $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ; |
|
124 | - }else{ |
|
125 | - $message = sprintf( __( 'The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso' ), $line_item->ID() ); |
|
126 | - if( WP_DEBUG ){ |
|
127 | - throw new EE_Error( $message ); |
|
128 | - }else{ |
|
129 | - EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message ); |
|
122 | + if (isset($this->_reg_final_price_per_tkt_line_item[$line_item->ID()])) { |
|
123 | + $final_price = $this->_reg_final_price_per_tkt_line_item[$line_item->ID()]; |
|
124 | + } else { |
|
125 | + $message = sprintf(__('The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso'), $line_item->ID()); |
|
126 | + if (WP_DEBUG) { |
|
127 | + throw new EE_Error($message); |
|
128 | + } else { |
|
129 | + EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message); |
|
130 | 130 | } |
131 | 131 | $final_price = $ticket->get_ticket_total_with_taxes(); |
132 | 132 | |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | 'REG_url_link' => $reg_url_link |
147 | 147 | ) |
148 | 148 | ); |
149 | - $registration->set_reg_code( $this->generate_reg_code( $registration ) ); |
|
149 | + $registration->set_reg_code($this->generate_reg_code($registration)); |
|
150 | 150 | $registration->save(); |
151 | - $registration->_add_relation_to( $event, 'Event', array(), $event->ID() ); |
|
152 | - $registration->_add_relation_to( $line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID() ); |
|
153 | - $transaction->_add_relation_to( $registration, 'Registration' ); |
|
151 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
152 | + $registration->_add_relation_to($line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID()); |
|
153 | + $transaction->_add_relation_to($registration, 'Registration'); |
|
154 | 154 | return $registration; |
155 | 155 | } |
156 | 156 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * @param EE_Line_Item | string $item |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function generate_reg_url_link( $att_nmbr, $item ) { |
|
166 | + public function generate_reg_url_link($att_nmbr, $item) { |
|
167 | 167 | $reg_url_link = $item instanceof EE_Line_Item ? $item->code() : $item; |
168 | - $reg_url_link = $att_nmbr . '-' . md5( $reg_url_link . microtime() ); |
|
168 | + $reg_url_link = $att_nmbr.'-'.md5($reg_url_link.microtime()); |
|
169 | 169 | return $reg_url_link; |
170 | 170 | } |
171 | 171 | |
@@ -177,18 +177,18 @@ discard block |
||
177 | 177 | * @param \EE_Registration $registration |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public function generate_reg_code( EE_Registration $registration ) { |
|
180 | + public function generate_reg_code(EE_Registration $registration) { |
|
181 | 181 | // figure out where to start parsing the reg code |
182 | - $chars = strpos( $registration->reg_url_link(), '-' ) + 5; |
|
182 | + $chars = strpos($registration->reg_url_link(), '-') + 5; |
|
183 | 183 | // TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link |
184 | 184 | $new_reg_code = array( |
185 | 185 | $registration->transaction_ID(), |
186 | 186 | $registration->ticket_ID(), |
187 | - substr( $registration->reg_url_link(), 0, $chars ) |
|
187 | + substr($registration->reg_url_link(), 0, $chars) |
|
188 | 188 | ); |
189 | 189 | // now put it all together |
190 | - $new_reg_code = implode( '-', $new_reg_code ); |
|
191 | - return apply_filters( 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration ); |
|
190 | + $new_reg_code = implode('-', $new_reg_code); |
|
191 | + return apply_filters('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param int $REG_ID |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - public function old_reg_status( $REG_ID ) { |
|
201 | - return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null; |
|
200 | + public function old_reg_status($REG_ID) { |
|
201 | + return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | * @param int $REG_ID |
208 | 208 | * @param string $old_reg_status |
209 | 209 | */ |
210 | - public function set_old_reg_status( $REG_ID, $old_reg_status ) { |
|
210 | + public function set_old_reg_status($REG_ID, $old_reg_status) { |
|
211 | 211 | // only set the first time |
212 | - if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) { |
|
213 | - $this->_old_reg_status[ $REG_ID ] = $old_reg_status; |
|
212 | + if ( ! isset($this->_old_reg_status[$REG_ID])) { |
|
213 | + $this->_old_reg_status[$REG_ID] = $old_reg_status; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param int $REG_ID |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function new_reg_status( $REG_ID ) { |
|
224 | - return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null; |
|
223 | + public function new_reg_status($REG_ID) { |
|
224 | + return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param int $REG_ID |
231 | 231 | * @param string $new_reg_status |
232 | 232 | */ |
233 | - public function set_new_reg_status( $REG_ID, $new_reg_status ) { |
|
234 | - $this->_new_reg_status[ $REG_ID ] = $new_reg_status; |
|
233 | + public function set_new_reg_status($REG_ID, $new_reg_status) { |
|
234 | + $this->_new_reg_status[$REG_ID] = $new_reg_status; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * @param int $REG_ID |
243 | 243 | * @return bool |
244 | 244 | */ |
245 | - public function reg_status_updated( $REG_ID ) { |
|
246 | - return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false; |
|
245 | + public function reg_status_updated($REG_ID) { |
|
246 | + return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | * @param bool $save TRUE will save the registration if the status is updated, FALSE will leave that up to client code |
258 | 258 | * @return boolean |
259 | 259 | */ |
260 | - public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) { |
|
260 | + public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) { |
|
261 | 261 | // set initial REG_Status |
262 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
262 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
263 | 263 | // set incoming REG_Status |
264 | - $this->set_new_reg_status( $registration->ID(), $new_reg_status ); |
|
264 | + $this->set_new_reg_status($registration->ID(), $new_reg_status); |
|
265 | 265 | // toggle reg status but only if it has changed and the user can do so |
266 | 266 | if ( |
267 | - $this->reg_status_updated( $registration->ID() ) && |
|
268 | - EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() ) |
|
267 | + $this->reg_status_updated($registration->ID()) && |
|
268 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID()) |
|
269 | 269 | ) { |
270 | 270 | // change status to new value |
271 | - if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) )) { |
|
272 | - if ( $save ) { |
|
271 | + if ($registration->set_status($this->new_reg_status($registration->ID()))) { |
|
272 | + if ($save) { |
|
273 | 273 | $registration->save(); |
274 | 274 | } |
275 | 275 | } |
@@ -290,27 +290,27 @@ discard block |
||
290 | 290 | * @param bool $save TRUE will save the registration if the status is updated, FALSE will leave that up to client code |
291 | 291 | * @return void |
292 | 292 | */ |
293 | - public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) { |
|
293 | + public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) { |
|
294 | 294 | // set initial REG_Status |
295 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
295 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
296 | 296 | // is the registration currently incomplete ? |
297 | - if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) { |
|
297 | + if ($registration->status_ID() === EEM_Registration::status_id_incomplete) { |
|
298 | 298 | // grab default reg status for the event, if set |
299 | 299 | $event_default_registration_status = $registration->event()->default_registration_status(); |
300 | 300 | // if no default reg status is set for the event, then use the global value |
301 | - $STS_ID = ! empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
301 | + $STS_ID = ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
302 | 302 | // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered |
303 | 303 | $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID; |
304 | 304 | // set incoming REG_Status |
305 | - $this->set_new_reg_status( $registration->ID(), $STS_ID ); |
|
306 | - $registration->set_status( $STS_ID ); |
|
307 | - if ( $save ) { |
|
305 | + $this->set_new_reg_status($registration->ID(), $STS_ID); |
|
306 | + $registration->set_status($STS_ID); |
|
307 | + if ($save) { |
|
308 | 308 | $registration->save(); |
309 | 309 | } |
310 | 310 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
311 | - if ( ! EE_Processor_Base::$IPN ) { |
|
311 | + if ( ! EE_Processor_Base::$IPN) { |
|
312 | 312 | // otherwise, send out notifications |
313 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
313 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
314 | 314 | } |
315 | 315 | // DEBUG LOG |
316 | 316 | //$this->log( |
@@ -334,25 +334,25 @@ discard block |
||
334 | 334 | * @param bool $save TRUE will save the registration if the status is updated, FALSE will leave that up to client code |
335 | 335 | * @return boolean |
336 | 336 | */ |
337 | - public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) { |
|
337 | + public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) { |
|
338 | 338 | // set initial REG_Status |
339 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
339 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
340 | 340 | // if not already, toggle reg status to approved IF the event default reg status is approved |
341 | 341 | if ( |
342 | 342 | $registration->status_ID() !== EEM_Registration::status_id_approved && |
343 | 343 | $registration->event()->default_registration_status() == EEM_Registration::status_id_approved |
344 | 344 | ) { |
345 | 345 | // set incoming REG_Status |
346 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
346 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
347 | 347 | // toggle status to approved |
348 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
349 | - if ( $save ) { |
|
348 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
349 | + if ($save) { |
|
350 | 350 | $registration->save(); |
351 | 351 | } |
352 | 352 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
353 | - if ( ! EE_Processor_Base::$IPN ) { |
|
353 | + if ( ! EE_Processor_Base::$IPN) { |
|
354 | 354 | // otherwise, send out notifications |
355 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
355 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
356 | 356 | } |
357 | 357 | // DEBUG LOG |
358 | 358 | //$this->log( |
@@ -380,19 +380,19 @@ discard block |
||
380 | 380 | * @return bool |
381 | 381 | * @throws \EE_Error |
382 | 382 | */ |
383 | - public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) { |
|
383 | + public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) { |
|
384 | 384 | // set initial REG_Status |
385 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
385 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
386 | 386 | //EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ ); |
387 | 387 | // was a payment just made ? |
388 | 388 | if ( |
389 | - isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) && |
|
390 | - $additional_details[ 'payment_updates' ] && |
|
391 | - $additional_details[ 'last_payment' ] instanceof EE_Payment |
|
389 | + isset($additional_details['payment_updates'], $additional_details['last_payment']) && |
|
390 | + $additional_details['payment_updates'] && |
|
391 | + $additional_details['last_payment'] instanceof EE_Payment |
|
392 | 392 | ) { |
393 | - $payment = $additional_details[ 'last_payment' ]; |
|
393 | + $payment = $additional_details['last_payment']; |
|
394 | 394 | $total_paid = 0; |
395 | - foreach ( self::$_amount_paid as $reg => $amount_paid ) { |
|
395 | + foreach (self::$_amount_paid as $reg => $amount_paid) { |
|
396 | 396 | $total_paid += $amount_paid; |
397 | 397 | } |
398 | 398 | } else { |
@@ -416,30 +416,30 @@ discard block |
||
416 | 416 | $registration->transaction()->is_completed() || |
417 | 417 | $registration->transaction()->is_overpaid() || |
418 | 418 | $registration->transaction()->is_free() || |
419 | - apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration ) |
|
419 | + apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration) |
|
420 | 420 | ) || ( |
421 | 421 | $payment instanceof EE_Payment && |
422 | 422 | $payment->is_approved() && |
423 | 423 | // this specific registration has not yet been paid for |
424 | - ! isset( self::$_amount_paid[ $registration->ID() ] ) && |
|
424 | + ! isset(self::$_amount_paid[$registration->ID()]) && |
|
425 | 425 | // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price |
426 | 426 | $payment->amount() - $total_paid >= $registration->final_price() |
427 | 427 | ) |
428 | 428 | ) |
429 | 429 | ) { |
430 | 430 | // mark as paid |
431 | - self::$_amount_paid[ $registration->ID() ] = $registration->final_price(); |
|
431 | + self::$_amount_paid[$registration->ID()] = $registration->final_price(); |
|
432 | 432 | // track new REG_Status |
433 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
433 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
434 | 434 | // toggle status to approved |
435 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
436 | - if ( $save ) { |
|
435 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
436 | + if ($save) { |
|
437 | 437 | $registration->save(); |
438 | 438 | } |
439 | 439 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
440 | - if ( ! EE_Processor_Base::$IPN ) { |
|
440 | + if ( ! EE_Processor_Base::$IPN) { |
|
441 | 441 | // otherwise, send out notifications |
442 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
442 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
443 | 443 | } |
444 | 444 | // DEBUG LOG |
445 | 445 | //$this->log( |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | * @param array $additional_details |
466 | 466 | * @return void |
467 | 467 | */ |
468 | - public function trigger_registration_update_notifications( $registration, $additional_details = array() ) { |
|
468 | + public function trigger_registration_update_notifications($registration, $additional_details = array()) { |
|
469 | 469 | try { |
470 | - if ( ! $registration instanceof EE_Registration ) { |
|
471 | - throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) ); |
|
470 | + if ( ! $registration instanceof EE_Registration) { |
|
471 | + throw new EE_Error(__('An invalid registration was received.', 'event_espresso')); |
|
472 | 472 | } |
473 | - EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
|
474 | - EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $registration->transaction(), $additional_details ), false, 'EE_Transaction: ' . $registration->transaction()->ID() ); |
|
473 | + EE_Registry::instance()->load_helper('Debug_Tools'); |
|
474 | + EEH_Debug_Tools::log(__CLASS__, __FUNCTION__, __LINE__, array($registration->transaction(), $additional_details), false, 'EE_Transaction: '.$registration->transaction()->ID()); |
|
475 | 475 | do_action( |
476 | 476 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
477 | 477 | $registration, |
478 | 478 | $additional_details |
479 | 479 | ); |
480 | - } catch( Exception $e ) { |
|
481 | - EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() ); |
|
480 | + } catch (Exception $e) { |
|
481 | + EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine()); |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
@@ -491,18 +491,18 @@ discard block |
||
491 | 491 | * @param array $additional_details |
492 | 492 | * @return bool |
493 | 493 | */ |
494 | - public function update_registration_after_checkout_or_payment( EE_Registration $registration, $additional_details = array() ) { |
|
494 | + public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) { |
|
495 | 495 | // set initial REG_Status |
496 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
496 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
497 | 497 | |
498 | 498 | // if the registration status gets updated, then save the registration |
499 | - if ( $this->toggle_registration_status_for_default_approved_events( $registration, false ) || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )) { |
|
499 | + if ($this->toggle_registration_status_for_default_approved_events($registration, false) || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)) { |
|
500 | 500 | $registration->save(); |
501 | 501 | } |
502 | 502 | |
503 | 503 | // set new REG_Status |
504 | - $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
|
505 | - return $this->reg_status_updated( $registration->ID() ) && $this->new_reg_status( $registration->ID() ) == EEM_Registration::status_id_approved ? true : false; |
|
504 | + $this->set_new_reg_status($registration->ID(), $registration->status_ID()); |
|
505 | + return $this->reg_status_updated($registration->ID()) && $this->new_reg_status($registration->ID()) == EEM_Registration::status_id_approved ? true : false; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -512,19 +512,19 @@ discard block |
||
512 | 512 | * @param boolean $save_regs whether to immediately save registrations in this function or not |
513 | 513 | * @return void |
514 | 514 | */ |
515 | - public function update_registration_final_prices( $transaction, $save_regs = true ) { |
|
516 | - $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
517 | - foreach( $transaction->registrations() as $registration ) { |
|
518 | - $line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration ); |
|
519 | - if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) { |
|
520 | - $registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ); |
|
521 | - if( $save_regs ) { |
|
515 | + public function update_registration_final_prices($transaction, $save_regs = true) { |
|
516 | + $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
517 | + foreach ($transaction->registrations() as $registration) { |
|
518 | + $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration); |
|
519 | + if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) { |
|
520 | + $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]); |
|
521 | + if ($save_regs) { |
|
522 | 522 | $registration->save(); |
523 | 523 | } |
524 | 524 | } |
525 | 525 | } |
526 | 526 | //and make sure there's no rounding problem |
527 | - $this->fix_reg_final_price_rounding_issue( $transaction ); |
|
527 | + $this->fix_reg_final_price_rounding_issue($transaction); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | /** |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * @param EE_Transaction $transaction |
541 | 541 | * @return boolean success verifying that there is NO difference after this method is done |
542 | 542 | */ |
543 | - public function fix_reg_final_price_rounding_issue( $transaction ) { |
|
543 | + public function fix_reg_final_price_rounding_issue($transaction) { |
|
544 | 544 | $reg_final_price_sum = EEM_Registration::instance()->sum( |
545 | 545 | array( |
546 | 546 | array( |
@@ -549,9 +549,9 @@ discard block |
||
549 | 549 | ), |
550 | 550 | 'REG_final_price' |
551 | 551 | ); |
552 | - $diff = $transaction->total() - floatval( $reg_final_price_sum ); |
|
552 | + $diff = $transaction->total() - floatval($reg_final_price_sum); |
|
553 | 553 | //ok then, just grab one of the registrations |
554 | - if( $diff != 0 ) { |
|
554 | + if ($diff != 0) { |
|
555 | 555 | $a_reg = EEM_Registration::instance()->get_one( |
556 | 556 | array( |
557 | 557 | array( |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | )); |
561 | 561 | $success = $a_reg instanceof EE_Registration ? $a_reg->save( |
562 | 562 | array( |
563 | - 'REG_final_price' => ( $a_reg->final_price() + $diff ) |
|
563 | + 'REG_final_price' => ($a_reg->final_price() + $diff) |
|
564 | 564 | ) |
565 | 565 | ) : false; |
566 | 566 | return $success ? true : false; |
@@ -742,11 +742,11 @@ |
||
742 | 742 | $pm = $this->get_first_related('Payment_Method'); |
743 | 743 | if( $pm instanceof EE_Payment_Method ){ |
744 | 744 | return $pm; |
745 | - }else{ |
|
745 | + } else{ |
|
746 | 746 | $last_payment = $this->last_payment(); |
747 | 747 | if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){ |
748 | 748 | return $last_payment->payment_method(); |
749 | - }else{ |
|
749 | + } else{ |
|
750 | 750 | return NULL; |
751 | 751 | } |
752 | 752 | } |
@@ -120,7 +120,6 @@ discard block |
||
120 | 120 | * then client code needs to take responsibility for saving the TXN |
121 | 121 | * regardless of what happens within EE_Transaction_Payments; |
122 | 122 | * |
123 | - * @param EE_Transaction/int $transaction_obj_or_id EE_Transaction or its ID |
|
124 | 123 | * @param boolean $update_txn whether to save the TXN |
125 | 124 | * @return boolean whether the TXN was saved |
126 | 125 | */ |
@@ -158,7 +157,7 @@ discard block |
||
158 | 157 | * @access public |
159 | 158 | * @param EE_Transaction $transaction |
160 | 159 | * @param string $payment_status, one of EEM_Payment's statuses, like 'PAP' (Approved). By default, searches for approved payments |
161 | - * @return mixed float on success, false on fail |
|
160 | + * @return double float on success, false on fail |
|
162 | 161 | */ |
163 | 162 | public function recalculate_total_payments_for_transaction( EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved ) { |
164 | 163 | // verify transaction |
@@ -1,5 +1,5 @@ discard block |
||
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 | * Class EE_Transaction_Payments |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function instance() { |
46 | 46 | // check if class object is instantiated |
47 | - if ( ! self::$_instance instanceof EE_Transaction_Payments ) { |
|
47 | + if ( ! self::$_instance instanceof EE_Transaction_Payments) { |
|
48 | 48 | self::$_instance = new self(); |
49 | 49 | } |
50 | 50 | return self::$_instance; |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @param string $old_txn_status |
74 | 74 | */ |
75 | - public function set_old_txn_status( $old_txn_status ) { |
|
75 | + public function set_old_txn_status($old_txn_status) { |
|
76 | 76 | // only set the first time |
77 | - if ( $this->_old_txn_status === null ) { |
|
77 | + if ($this->_old_txn_status === null) { |
|
78 | 78 | $this->_old_txn_status = $old_txn_status; |
79 | 79 | } |
80 | 80 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @param string $new_txn_status |
95 | 95 | */ |
96 | - public function set_new_txn_status( $new_txn_status ) { |
|
96 | + public function set_new_txn_status($new_txn_status) { |
|
97 | 97 | $this->_new_txn_status = $new_txn_status; |
98 | 98 | } |
99 | 99 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return bool |
106 | 106 | */ |
107 | 107 | public function txn_status_updated() { |
108 | - return $this->_new_txn_status !== $this->_old_txn_status && $this->_old_txn_status !== null ? true : false; |
|
108 | + return $this->_new_txn_status !== $this->_old_txn_status && $this->_old_txn_status !== null ? true : false; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -124,22 +124,22 @@ discard block |
||
124 | 124 | * @param boolean $update_txn whether to save the TXN |
125 | 125 | * @return boolean whether the TXN was saved |
126 | 126 | */ |
127 | - public function calculate_total_payments_and_update_status( EE_Transaction $transaction, $update_txn = true ){ |
|
127 | + public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) { |
|
128 | 128 | // verify transaction |
129 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
130 | - EE_Error::add_error( __( 'Please provide a valid EE_Transaction object.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
129 | + if ( ! $transaction instanceof EE_Transaction) { |
|
130 | + EE_Error::add_error(__('Please provide a valid EE_Transaction object.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | // set incoming TXN_Status |
134 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
134 | + $this->set_old_txn_status($transaction->status_ID()); |
|
135 | 135 | // calculate total paid |
136 | - $total_paid = $this->recalculate_total_payments_for_transaction( $transaction ); |
|
136 | + $total_paid = $this->recalculate_total_payments_for_transaction($transaction); |
|
137 | 137 | // if total paid has changed |
138 | - if ( $total_paid != $transaction->paid() ) { |
|
139 | - $transaction->set_paid( $total_paid ); |
|
138 | + if ($total_paid != $transaction->paid()) { |
|
139 | + $transaction->set_paid($total_paid); |
|
140 | 140 | // maybe update status, and make sure to save transaction if not done already |
141 | - if ( ! $this->update_transaction_status_based_on_total_paid( $transaction, $update_txn )) { |
|
142 | - if ( $update_txn ) { |
|
141 | + if ( ! $this->update_transaction_status_based_on_total_paid($transaction, $update_txn)) { |
|
142 | + if ($update_txn) { |
|
143 | 143 | return $transaction->save() ? true : false; |
144 | 144 | } |
145 | 145 | } else { |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | * @param string $payment_status, one of EEM_Payment's statuses, like 'PAP' (Approved). By default, searches for approved payments |
161 | 161 | * @return mixed float on success, false on fail |
162 | 162 | */ |
163 | - public function recalculate_total_payments_for_transaction( EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved ) { |
|
163 | + public function recalculate_total_payments_for_transaction(EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved) { |
|
164 | 164 | // verify transaction |
165 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
166 | - EE_Error::add_error( __( 'Please provide a valid EE_Transaction object.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
165 | + if ( ! $transaction instanceof EE_Transaction) { |
|
166 | + EE_Error::add_error(__('Please provide a valid EE_Transaction object.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | // ensure Payment model is loaded |
170 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
170 | + EE_Registry::instance()->load_model('Payment'); |
|
171 | 171 | // calls EEM_Base::sum() |
172 | 172 | return EEM_Payment::instance()->sum( |
173 | 173 | // query params |
174 | - array( array( 'TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status )), |
|
174 | + array(array('TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status)), |
|
175 | 175 | // field to sum |
176 | 176 | 'PAY_amount' |
177 | 177 | ); |
@@ -187,37 +187,37 @@ discard block |
||
187 | 187 | * @return boolean whether the TXN was saved |
188 | 188 | * @throws \EE_Error |
189 | 189 | */ |
190 | - public function update_transaction_status_based_on_total_paid( EE_Transaction $transaction, $update_txn = TRUE ) { |
|
190 | + public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = TRUE) { |
|
191 | 191 | // verify transaction |
192 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
192 | + if ( ! $transaction instanceof EE_Transaction) { |
|
193 | 193 | EE_Error::add_error( |
194 | - __( 'Please provide a valid EE_Transaction object.', 'event_espresso' ), |
|
194 | + __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
195 | 195 | __FILE__, __FUNCTION__, __LINE__ |
196 | 196 | ); |
197 | 197 | return FALSE; |
198 | 198 | } |
199 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
199 | + EE_Registry::instance()->load_helper('Money'); |
|
200 | 200 | // set incoming TXN_Status |
201 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
201 | + $this->set_old_txn_status($transaction->status_ID()); |
|
202 | 202 | // set transaction status based on comparison of TXN_paid vs TXN_total |
203 | - if ( EEH_Money::compare_floats( $transaction->paid(), $transaction->total(), '>' ) ){ |
|
203 | + if (EEH_Money::compare_floats($transaction->paid(), $transaction->total(), '>')) { |
|
204 | 204 | $new_txn_status = EEM_Transaction::overpaid_status_code; |
205 | - } else if ( EEH_Money::compare_floats( $transaction->paid(), $transaction->total() ) ) { |
|
205 | + } else if (EEH_Money::compare_floats($transaction->paid(), $transaction->total())) { |
|
206 | 206 | $new_txn_status = EEM_Transaction::complete_status_code; |
207 | - } else if ( EEH_Money::compare_floats( $transaction->paid(), $transaction->total(), '<' ) ) { |
|
207 | + } else if (EEH_Money::compare_floats($transaction->paid(), $transaction->total(), '<')) { |
|
208 | 208 | $new_txn_status = EEM_Transaction::incomplete_status_code; |
209 | 209 | } else { |
210 | 210 | EE_Error::add_error( |
211 | - __( 'The total paid calculation for this transaction is inaccurate.', 'event_espresso' ), |
|
211 | + __('The total paid calculation for this transaction is inaccurate.', 'event_espresso'), |
|
212 | 212 | __FILE__, __FUNCTION__, __LINE__ |
213 | 213 | ); |
214 | 214 | return FALSE; |
215 | 215 | } |
216 | - if ( $new_txn_status !== $transaction->status_ID() ) { |
|
216 | + if ($new_txn_status !== $transaction->status_ID()) { |
|
217 | 217 | // set incoming TXN_Status |
218 | - $this->set_new_txn_status( $new_txn_status ); |
|
219 | - $transaction->set_status( $new_txn_status ); |
|
220 | - if ( $update_txn ) { |
|
218 | + $this->set_new_txn_status($new_txn_status); |
|
219 | + $transaction->set_status($new_txn_status); |
|
220 | + if ($update_txn) { |
|
221 | 221 | return $transaction->save() ? TRUE : FALSE; |
222 | 222 | } |
223 | 223 | } |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | * @param EE_Payment $payment |
237 | 237 | * @return boolean |
238 | 238 | */ |
239 | - public function delete_payment_and_update_transaction( EE_Payment $payment ) { |
|
239 | + public function delete_payment_and_update_transaction(EE_Payment $payment) { |
|
240 | 240 | // verify payment |
241 | - if ( ! $payment instanceof EE_Payment ) { |
|
242 | - EE_Error::add_error( __( 'A valid Payment object was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
241 | + if ( ! $payment instanceof EE_Payment) { |
|
242 | + EE_Error::add_error(__('A valid Payment object was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
243 | 243 | return false; |
244 | 244 | } |
245 | - if ( ! $this->delete_registration_payments_and_update_registrations( $payment ) ) { |
|
245 | + if ( ! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | - if ( ! $payment->delete() ) { |
|
249 | - EE_Error::add_error( __( 'The payment could not be deleted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
248 | + if ( ! $payment->delete()) { |
|
249 | + EE_Error::add_error(__('The payment could not be deleted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | || $transaction->status_ID() === EEM_Transaction::failed_status_code |
258 | 258 | || $payment->amount() === 0 |
259 | 259 | ) { |
260 | - EE_Error::add_success( __( 'The Payment was successfully deleted.', 'event_espresso' ) ); |
|
260 | + EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso')); |
|
261 | 261 | return true; |
262 | 262 | } |
263 | 263 | |
264 | 264 | |
265 | 265 | //if this fails, that just means that the transaction didn't get its status changed and/or updated. |
266 | 266 | //however the payment was still deleted. |
267 | - if ( ! $this->calculate_total_payments_and_update_status( $transaction ) ) { |
|
267 | + if ( ! $this->calculate_total_payments_and_update_status($transaction)) { |
|
268 | 268 | |
269 | 269 | EE_Error::add_attention( |
270 | 270 | __( |
@@ -298,28 +298,28 @@ discard block |
||
298 | 298 | * @return bool |
299 | 299 | * @throws \EE_Error |
300 | 300 | */ |
301 | - public function delete_registration_payments_and_update_registrations( EE_Payment $payment, $reg_payment_query_params = array() ) { |
|
301 | + public function delete_registration_payments_and_update_registrations(EE_Payment $payment, $reg_payment_query_params = array()) { |
|
302 | 302 | $save_payment = false; |
303 | - $reg_payment_query_params = ! empty( $reg_payment_query_params ) ? $reg_payment_query_params : array( array( 'PAY_ID' => $payment->ID() ) ); |
|
304 | - $registration_payments = EEM_Registration_Payment::instance()->get_all( $reg_payment_query_params ); |
|
305 | - if ( ! empty( $registration_payments )) { |
|
306 | - foreach ( $registration_payments as $registration_payment ) { |
|
307 | - if ( $registration_payment instanceof EE_Registration_Payment ) { |
|
303 | + $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params : array(array('PAY_ID' => $payment->ID())); |
|
304 | + $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
|
305 | + if ( ! empty($registration_payments)) { |
|
306 | + foreach ($registration_payments as $registration_payment) { |
|
307 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
308 | 308 | $amount_paid = $registration_payment->amount(); |
309 | 309 | $registration = $registration_payment->registration(); |
310 | - if ( $registration instanceof EE_Registration ) { |
|
311 | - $registration->set_paid( $registration->paid() - $amount_paid ); |
|
312 | - if ( $registration->save() ) { |
|
313 | - if ( $registration_payment->delete() ) { |
|
314 | - $registration->_remove_relation_to( $payment, 'Payment' ); |
|
315 | - $payment->_remove_relation_to( $registration, 'Registration' ); |
|
310 | + if ($registration instanceof EE_Registration) { |
|
311 | + $registration->set_paid($registration->paid() - $amount_paid); |
|
312 | + if ($registration->save()) { |
|
313 | + if ($registration_payment->delete()) { |
|
314 | + $registration->_remove_relation_to($payment, 'Payment'); |
|
315 | + $payment->_remove_relation_to($registration, 'Registration'); |
|
316 | 316 | } |
317 | 317 | $save_payment = true; |
318 | 318 | } |
319 | 319 | } else { |
320 | 320 | EE_Error::add_error( |
321 | 321 | sprintf( |
322 | - __( 'An invalid Registration object was associated with Registration Payment ID# %1$d.', 'event_espresso' ), |
|
322 | + __('An invalid Registration object was associated with Registration Payment ID# %1$d.', 'event_espresso'), |
|
323 | 323 | $registration_payment->ID() |
324 | 324 | ), |
325 | 325 | __FILE__, __FUNCTION__, __LINE__ |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } else { |
330 | 330 | EE_Error::add_error( |
331 | 331 | sprintf( |
332 | - __( 'An invalid Registration Payment object was associated with payment ID# %1$d.', 'event_espresso' ), |
|
332 | + __('An invalid Registration Payment object was associated with payment ID# %1$d.', 'event_espresso'), |
|
333 | 333 | $payment->ID() |
334 | 334 | ), |
335 | 335 | __FILE__, __FUNCTION__, __LINE__ |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
341 | - if ( $save_payment ) { |
|
341 | + if ($save_payment) { |
|
342 | 342 | $payment->save(); |
343 | 343 | } |
344 | 344 | return true; |
@@ -503,6 +503,7 @@ |
||
503 | 503 | * @param EE_Transaction $transaction |
504 | 504 | * @param \EE_Payment | NULL $payment |
505 | 505 | * @param array $registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction |
506 | + * @param EE_Payment $payment |
|
506 | 507 | * @throws \EE_Error |
507 | 508 | * @return array |
508 | 509 | */ |
@@ -1,5 +1,5 @@ discard block |
||
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 | * Class EE_Transaction_Processor |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * @param array $registration_query_params |
51 | 51 | *@return EE_Transaction_Processor instance |
52 | 52 | */ |
53 | - public static function instance( $registration_query_params = array() ) { |
|
53 | + public static function instance($registration_query_params = array()) { |
|
54 | 54 | // check if class object is instantiated |
55 | - if ( ! self::$_instance instanceof EE_Transaction_Processor ) { |
|
56 | - self::$_instance = new self( $registration_query_params ); |
|
55 | + if ( ! self::$_instance instanceof EE_Transaction_Processor) { |
|
56 | + self::$_instance = new self($registration_query_params); |
|
57 | 57 | } |
58 | 58 | return self::$_instance; |
59 | 59 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param array $registration_query_params |
65 | 65 | * @return EE_Transaction_Processor |
66 | 66 | */ |
67 | - private function __construct( $registration_query_params = array() ) { |
|
67 | + private function __construct($registration_query_params = array()) { |
|
68 | 68 | // make sure some query params are set for retrieving registrations |
69 | - $this->_set_registration_query_params( $registration_query_params ); |
|
69 | + $this->_set_registration_query_params($registration_query_params); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @access private |
76 | 76 | * @param array $registration_query_params |
77 | 77 | */ |
78 | - private function _set_registration_query_params( $registration_query_params ) { |
|
79 | - $this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
78 | + private function _set_registration_query_params($registration_query_params) { |
|
79 | + $this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC')); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @param string $old_txn_status |
95 | 95 | */ |
96 | - public function set_old_txn_status( $old_txn_status ) { |
|
96 | + public function set_old_txn_status($old_txn_status) { |
|
97 | 97 | // only set the first time |
98 | - if ( $this->_old_txn_status === null ) { |
|
98 | + if ($this->_old_txn_status === null) { |
|
99 | 99 | $this->_old_txn_status = $old_txn_status; |
100 | 100 | } |
101 | 101 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @param string $new_txn_status |
116 | 116 | */ |
117 | - public function set_new_txn_status( $new_txn_status ) { |
|
117 | + public function set_new_txn_status($new_txn_status) { |
|
118 | 118 | $this->_new_txn_status = $new_txn_status; |
119 | 119 | } |
120 | 120 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | * @param bool $check_all |
146 | 146 | * @return boolean | int |
147 | 147 | */ |
148 | - private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) { |
|
148 | + private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) { |
|
149 | 149 | $reg_steps = $transaction->reg_steps(); |
150 | - if ( ! is_array( $reg_steps ) || empty( $reg_steps )) { |
|
150 | + if ( ! is_array($reg_steps) || empty($reg_steps)) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | // loop thru reg steps array) |
154 | - foreach ( $reg_steps as $slug => $reg_step_completed ) { |
|
154 | + foreach ($reg_steps as $slug => $reg_step_completed) { |
|
155 | 155 | // if NOT checking ALL steps (only checking one step) |
156 | - if ( ! $check_all ) { |
|
156 | + if ( ! $check_all) { |
|
157 | 157 | // and this is the one |
158 | - if ( $slug == $reg_step_slug ) { |
|
158 | + if ($slug == $reg_step_slug) { |
|
159 | 159 | return $reg_step_completed; |
160 | 160 | } else { |
161 | 161 | // skip to next reg step in loop |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | // if any reg step is NOT completed (ignoring any specific steps), then just leave |
166 | - if ( $reg_step_completed !== true && $slug != $reg_step_slug ) { |
|
166 | + if ($reg_step_completed !== true && $slug != $reg_step_slug) { |
|
167 | 167 | return false; |
168 | - } else if ( $slug == $reg_step_slug ) { |
|
168 | + } else if ($slug == $reg_step_slug) { |
|
169 | 169 | // if we reach this point, then we are testing either: |
170 | 170 | // all_reg_steps_completed_except() or |
171 | 171 | // all_reg_steps_completed_except_final_step(), |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param EE_Transaction $transaction |
191 | 191 | * @return boolean |
192 | 192 | */ |
193 | - public function all_reg_steps_completed( EE_Transaction $transaction ) { |
|
194 | - return $this->_reg_steps_completed( $transaction ); |
|
193 | + public function all_reg_steps_completed(EE_Transaction $transaction) { |
|
194 | + return $this->_reg_steps_completed($transaction); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param string $exception |
209 | 209 | * @return boolean |
210 | 210 | */ |
211 | - public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) { |
|
212 | - return $this->_reg_steps_completed( $transaction, $exception ); |
|
211 | + public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') { |
|
212 | + return $this->_reg_steps_completed($transaction, $exception); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * @param EE_Transaction $transaction |
226 | 226 | * @return boolean |
227 | 227 | */ |
228 | - public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) { |
|
229 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration' ); |
|
228 | + public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) { |
|
229 | + return $this->_reg_steps_completed($transaction, 'finalize_registration'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @param string $reg_step_slug |
244 | 244 | * @return boolean | int |
245 | 245 | */ |
246 | - public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
247 | - return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE ); |
|
246 | + public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
247 | + return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | * @param EE_Transaction $transaction |
261 | 261 | * @return boolean | int |
262 | 262 | */ |
263 | - public function final_reg_step_completed( EE_Transaction $transaction ) { |
|
264 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE ); |
|
263 | + public function final_reg_step_completed(EE_Transaction $transaction) { |
|
264 | + return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @param string $reg_step_slug |
276 | 276 | * @return boolean |
277 | 277 | */ |
278 | - public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) { |
|
278 | + public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) { |
|
279 | 279 | $current_time = time(); |
280 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, $current_time ); |
|
280 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, $current_time); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param string $reg_step_slug |
292 | 292 | * @return boolean |
293 | 293 | */ |
294 | - public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
295 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, TRUE ); |
|
294 | + public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
295 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, TRUE); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @param string $reg_step_slug |
307 | 307 | * @return boolean |
308 | 308 | */ |
309 | - public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
310 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, FALSE ); |
|
309 | + public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
310 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, FALSE); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -323,36 +323,36 @@ discard block |
||
323 | 323 | * @param boolean | int $status |
324 | 324 | * @return boolean |
325 | 325 | */ |
326 | - private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) { |
|
326 | + private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) { |
|
327 | 327 | // validate status |
328 | - $status = is_bool( $status ) || is_numeric( $status ) ? $status : false; |
|
328 | + $status = is_bool($status) || is_numeric($status) ? $status : false; |
|
329 | 329 | // get reg steps array |
330 | 330 | $txn_reg_steps = $transaction->reg_steps(); |
331 | 331 | // if reg step does NOT exist |
332 | - if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) { |
|
332 | + if ( ! isset($txn_reg_steps[$reg_step_slug])) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | // if we're trying to complete a step that is already completed |
336 | - if ( $txn_reg_steps[ $reg_step_slug ] === true ) { |
|
336 | + if ($txn_reg_steps[$reg_step_slug] === true) { |
|
337 | 337 | return true; |
338 | 338 | } |
339 | 339 | // if we're trying to complete a step that hasn't even started |
340 | - if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) { |
|
340 | + if ($status === true && $txn_reg_steps[$reg_step_slug] === false) { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | // if current status value matches the incoming value (no change) |
344 | - if ( $txn_reg_steps[ $reg_step_slug ] === $status ) { |
|
344 | + if ($txn_reg_steps[$reg_step_slug] === $status) { |
|
345 | 345 | // this will happen in cases where multiple AJAX requests occur during the same step |
346 | 346 | return true; |
347 | 347 | } |
348 | 348 | // if we're trying to set a start time |
349 | - if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) { |
|
349 | + if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) { |
|
350 | 350 | // skip the update below, but don't return FALSE so that errors won't be displayed |
351 | 351 | return true; |
352 | 352 | } |
353 | 353 | // update completed status |
354 | - $txn_reg_steps[ $reg_step_slug ] = $status; |
|
355 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
354 | + $txn_reg_steps[$reg_step_slug] = $status; |
|
355 | + $transaction->set_reg_steps($txn_reg_steps); |
|
356 | 356 | $transaction->save(); |
357 | 357 | // DEBUG LOG |
358 | 358 | //$this->log( |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | * @param string $reg_step_slug |
379 | 379 | * @return void |
380 | 380 | */ |
381 | - public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) { |
|
381 | + public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) { |
|
382 | 382 | // get reg steps array |
383 | 383 | $txn_reg_steps = $transaction->reg_steps(); |
384 | - unset( $txn_reg_steps[ $reg_step_slug ] ); |
|
385 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
384 | + unset($txn_reg_steps[$reg_step_slug]); |
|
385 | + $transaction->set_reg_steps($txn_reg_steps); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | * @param EE_Transaction $transaction |
397 | 397 | * @return boolean |
398 | 398 | */ |
399 | - public function toggle_failed_transaction_status( EE_Transaction $transaction ) { |
|
399 | + public function toggle_failed_transaction_status(EE_Transaction $transaction) { |
|
400 | 400 | // set incoming TXN_Status |
401 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
401 | + $this->set_old_txn_status($transaction->status_ID()); |
|
402 | 402 | // if TXN status is still set as "failed"... |
403 | - if ( $transaction->status_ID() == EEM_Transaction::failed_status_code ) { |
|
403 | + if ($transaction->status_ID() == EEM_Transaction::failed_status_code) { |
|
404 | 404 | // set incoming TXN_Status |
405 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
406 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
405 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
406 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
407 | 407 | return TRUE; |
408 | 408 | } |
409 | 409 | return FALSE; |
@@ -419,20 +419,20 @@ discard block |
||
419 | 419 | * @param EE_Transaction $transaction |
420 | 420 | * @return boolean |
421 | 421 | */ |
422 | - public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) { |
|
422 | + public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { |
|
423 | 423 | // set incoming TXN_Status |
424 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
424 | + $this->set_old_txn_status($transaction->status_ID()); |
|
425 | 425 | // if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"... |
426 | - if ( $transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code ) { |
|
427 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
426 | + if ($transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code) { |
|
427 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
428 | 428 | // if a contact record for the primary registrant has been created |
429 | - if ( $transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee ) { |
|
430 | - $transaction->set_status( EEM_Transaction::incomplete_status_code ); |
|
431 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
429 | + if ($transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee) { |
|
430 | + $transaction->set_status(EEM_Transaction::incomplete_status_code); |
|
431 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
432 | 432 | } else { |
433 | 433 | // no contact record? yer abandoned! |
434 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
435 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
434 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
435 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
436 | 436 | } |
437 | 437 | return TRUE; |
438 | 438 | } |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | * @param array $registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction |
451 | 451 | * @return boolean |
452 | 452 | */ |
453 | - public function manually_update_registration_statuses( EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array() ) { |
|
454 | - $status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status ); |
|
453 | + public function manually_update_registration_statuses(EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array()) { |
|
454 | + $status_updates = $this->_call_method_on_registrations_via_Registration_Processor('manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status); |
|
455 | 455 | // send messages |
456 | 456 | /** @type EE_Registration_Processor $registration_processor */ |
457 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
457 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
458 | 458 | $registration_processor->trigger_registration_update_notifications( |
459 | 459 | $transaction->primary_registration(), |
460 | - array( 'manually_updated' => true ) |
|
460 | + array('manually_updated' => true) |
|
461 | 461 | ); |
462 | - do_action( 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates ); |
|
462 | + do_action('AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates); |
|
463 | 463 | return $status_updates; |
464 | 464 | } |
465 | 465 | |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | * @param array $registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction |
474 | 474 | * @return boolean |
475 | 475 | */ |
476 | - public function toggle_registration_statuses_for_default_approved_events( EE_Transaction $transaction, $registration_query_params = array() ) { |
|
477 | - $status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params ); |
|
478 | - do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates ); |
|
476 | + public function toggle_registration_statuses_for_default_approved_events(EE_Transaction $transaction, $registration_query_params = array()) { |
|
477 | + $status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params); |
|
478 | + do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates); |
|
479 | 479 | return $status_updates; |
480 | 480 | } |
481 | 481 | |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | * @param array $registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction |
490 | 490 | * @return boolean |
491 | 491 | */ |
492 | - public function toggle_registration_statuses_if_no_monies_owing( EE_Transaction $transaction, $registration_query_params = array() ) { |
|
493 | - $status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params ); |
|
494 | - do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates ); |
|
492 | + public function toggle_registration_statuses_if_no_monies_owing(EE_Transaction $transaction, $registration_query_params = array()) { |
|
493 | + $status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params); |
|
494 | + do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates); |
|
495 | 495 | return $status_updates; |
496 | 496 | } |
497 | 497 | |
@@ -507,17 +507,17 @@ discard block |
||
507 | 507 | * @throws \EE_Error |
508 | 508 | * @return array |
509 | 509 | */ |
510 | - public function update_transaction_and_registrations_after_checkout_or_payment( EE_Transaction $transaction, $payment = NULL, $registration_query_params = array() ) { |
|
510 | + public function update_transaction_and_registrations_after_checkout_or_payment(EE_Transaction $transaction, $payment = NULL, $registration_query_params = array()) { |
|
511 | 511 | // set incoming TXN_Status, and consider it new since old status should have been set |
512 | - $this->set_new_txn_status( $transaction->status_ID() ); |
|
513 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' ); |
|
512 | + $this->set_new_txn_status($transaction->status_ID()); |
|
513 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()'); |
|
514 | 514 | // make sure some query params are set for retrieving registrations |
515 | - $this->_set_registration_query_params( $registration_query_params ); |
|
515 | + $this->_set_registration_query_params($registration_query_params); |
|
516 | 516 | // get final reg step status |
517 | - $finalized = $this->final_reg_step_completed( $transaction ); |
|
517 | + $finalized = $this->final_reg_step_completed($transaction); |
|
518 | 518 | // if the 'finalize_registration' step has been initiated (has a timestamp) but has not yet been fully completed (TRUE) |
519 | - if ( is_numeric( $finalized ) && $finalized !== true ) { |
|
520 | - $this->set_reg_step_completed( $transaction, 'finalize_registration' ); |
|
519 | + if (is_numeric($finalized) && $finalized !== true) { |
|
520 | + $this->set_reg_step_completed($transaction, 'finalize_registration'); |
|
521 | 521 | $finalized = true; |
522 | 522 | } |
523 | 523 | $transaction->save(); |
@@ -540,13 +540,13 @@ discard block |
||
540 | 540 | |
541 | 541 | // send messages |
542 | 542 | /** @type EE_Registration_Processor $registration_processor */ |
543 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
543 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
544 | 544 | $registration_processor->trigger_registration_update_notifications( |
545 | 545 | $transaction->primary_registration(), |
546 | 546 | $update_params |
547 | 547 | ); |
548 | 548 | |
549 | - do_action( 'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params ); |
|
549 | + do_action('AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params); |
|
550 | 550 | return $update_params; |
551 | 551 | } |
552 | 552 | |
@@ -564,23 +564,23 @@ discard block |
||
564 | 564 | * @throws \EE_Error |
565 | 565 | * @return boolean |
566 | 566 | */ |
567 | - private function _call_method_on_registrations_via_Registration_Processor( $method_name, EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL ) { |
|
567 | + private function _call_method_on_registrations_via_Registration_Processor($method_name, EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL) { |
|
568 | 568 | $response = FALSE; |
569 | 569 | /** @type EE_Registration_Processor $registration_processor */ |
570 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
570 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
571 | 571 | // check that method exists |
572 | - if ( ! method_exists( $registration_processor, $method_name )) { |
|
573 | - throw new EE_Error( __( 'Method does not exist.', 'event_espresso' )); |
|
572 | + if ( ! method_exists($registration_processor, $method_name)) { |
|
573 | + throw new EE_Error(__('Method does not exist.', 'event_espresso')); |
|
574 | 574 | } |
575 | 575 | // make sure some query params are set for retrieving registrations |
576 | - $this->_set_registration_query_params( $registration_query_params ); |
|
576 | + $this->_set_registration_query_params($registration_query_params); |
|
577 | 577 | // loop through cached registrations |
578 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
579 | - if ( $registration instanceof EE_Registration ) { |
|
580 | - if ( $additional_param ) { |
|
581 | - $response = $registration_processor->{$method_name}( $registration, $additional_param ) ? TRUE : $response; |
|
578 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
579 | + if ($registration instanceof EE_Registration) { |
|
580 | + if ($additional_param) { |
|
581 | + $response = $registration_processor->{$method_name}($registration, $additional_param) ? TRUE : $response; |
|
582 | 582 | } else { |
583 | - $response = $registration_processor->{$method_name}( $registration ) ? TRUE : $response; |
|
583 | + $response = $registration_processor->{$method_name}($registration) ? TRUE : $response; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | } |
@@ -605,46 +605,46 @@ discard block |
||
605 | 605 | public function set_transaction_payment_method_based_on_registration_statuses( |
606 | 606 | EE_Registration $edited_registration |
607 | 607 | ) { |
608 | - if ( $edited_registration instanceof EE_Registration ) { |
|
608 | + if ($edited_registration instanceof EE_Registration) { |
|
609 | 609 | $transaction = $edited_registration->transaction(); |
610 | - if ( $transaction instanceof EE_Transaction ) { |
|
610 | + if ($transaction instanceof EE_Transaction) { |
|
611 | 611 | $all_not_approved = true; |
612 | - foreach ( $transaction->registrations() as $registration ) { |
|
613 | - if ( $registration instanceof EE_Registration ) { |
|
612 | + foreach ($transaction->registrations() as $registration) { |
|
613 | + if ($registration instanceof EE_Registration) { |
|
614 | 614 | // if any REG != "Not Approved" then toggle to false |
615 | 615 | $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false; |
616 | 616 | } |
617 | 617 | } |
618 | 618 | // if ALL Registrations are "Not Approved" |
619 | - if ( $all_not_approved ) { |
|
620 | - $transaction->set_payment_method_ID( null ); |
|
619 | + if ($all_not_approved) { |
|
620 | + $transaction->set_payment_method_ID(null); |
|
621 | 621 | $transaction->save(); |
622 | 622 | } else { |
623 | - $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ); |
|
624 | - if ( ! empty( $available_payment_methods ) ) { |
|
623 | + $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart); |
|
624 | + if ( ! empty($available_payment_methods)) { |
|
625 | 625 | $PMD_ID = 0; |
626 | - foreach ( $available_payment_methods as $available_payment_method ) { |
|
627 | - if ( $available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default() ) { |
|
626 | + foreach ($available_payment_methods as $available_payment_method) { |
|
627 | + if ($available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default()) { |
|
628 | 628 | $PMD_ID = $available_payment_method->ID(); |
629 | 629 | break; |
630 | 630 | } |
631 | 631 | } |
632 | - if ( ! $PMD_ID ) { |
|
633 | - $first_payment_method = reset( $available_payment_methods ); |
|
634 | - if ( $first_payment_method instanceof EE_Payment_Method ) { |
|
632 | + if ( ! $PMD_ID) { |
|
633 | + $first_payment_method = reset($available_payment_methods); |
|
634 | + if ($first_payment_method instanceof EE_Payment_Method) { |
|
635 | 635 | $PMD_ID = $first_payment_method->ID(); |
636 | 636 | } else { |
637 | 637 | EE_Error::add_error( |
638 | - __( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ), |
|
638 | + __('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), |
|
639 | 639 | __FILE__, __LINE__, __FUNCTION__ |
640 | 640 | ); |
641 | 641 | } |
642 | 642 | } |
643 | - $transaction->set_payment_method_ID( $PMD_ID ); |
|
643 | + $transaction->set_payment_method_ID($PMD_ID); |
|
644 | 644 | $transaction->save(); |
645 | 645 | } else { |
646 | 646 | EE_Error::add_error( |
647 | - __( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ), |
|
647 | + __('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), |
|
648 | 648 | __FILE__, __LINE__, __FUNCTION__ |
649 | 649 | ); |
650 | 650 | } |
@@ -59,7 +59,6 @@ |
||
59 | 59 | /** |
60 | 60 | * Creates a 4.1 price base type |
61 | 61 | * @global type $wpdb |
62 | - * @param array $old_price |
|
63 | 62 | * @param int $new_reg_id |
64 | 63 | * @return int |
65 | 64 | */ |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | )); |
31 | 31 | */ |
32 | 32 | |
33 | -class EE_DMS_4_1_0_answers extends EE_Data_Migration_Script_Stage_Table{ |
|
33 | +class EE_DMS_4_1_0_answers extends EE_Data_Migration_Script_Stage_Table { |
|
34 | 34 | private $_new_answer_table; |
35 | 35 | private $_new_question_table; |
36 | 36 | function __construct() { |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | $old_attendee_table = $wpdb->prefix."events_attendee"; |
48 | 48 | $new_reg_table = $wpdb->prefix."esp_registration"; |
49 | 49 | $regs = $this->get_migration_script()->get_mapping_new_pk($old_attendee_table, $old_row['attendee_id'], $new_reg_table); |
50 | - if( ! $regs){ |
|
51 | - $this->add_error(sprintf(__("Could not find new registrations for old attendee %d when creating answer %s", "event_espresso"),$old_row['attendee_id'], $this->_json_encode($old_row))); |
|
50 | + if ( ! $regs) { |
|
51 | + $this->add_error(sprintf(__("Could not find new registrations for old attendee %d when creating answer %s", "event_espresso"), $old_row['attendee_id'], $this->_json_encode($old_row))); |
|
52 | 52 | return false; |
53 | 53 | } |
54 | 54 | //as inefficient as this sounds, we create an answer per REGISTRATION, (even if the registrations use the same attendee) |
55 | - foreach($regs as $new_reg_id){ |
|
56 | - $new_answer_id = $this->_insert_new_answer($old_row,$new_reg_id); |
|
55 | + foreach ($regs as $new_reg_id) { |
|
56 | + $new_answer_id = $this->_insert_new_answer($old_row, $new_reg_id); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | /** |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | * @param int $new_reg_id |
64 | 64 | * @return int |
65 | 65 | */ |
66 | - private function _insert_new_answer($old_answer,$new_reg_id){ |
|
66 | + private function _insert_new_answer($old_answer, $new_reg_id) { |
|
67 | 67 | global $wpdb; |
68 | 68 | $old_question_table = $wpdb->prefix."events_question"; |
69 | 69 | $new_question_id = $this->get_migration_script()->get_mapping_new_pk($old_question_table, $old_answer['question_id'], $this->_new_question_table); |
70 | 70 | |
71 | 71 | $question_type = $this->_get_question_type($new_question_id); |
72 | - if(in_array($question_type,array('MULTIPLE'))){ |
|
73 | - $ans_value = serialize(explode(",",stripslashes($old_answer['answer']))); |
|
74 | - }else{ |
|
72 | + if (in_array($question_type, array('MULTIPLE'))) { |
|
73 | + $ans_value = serialize(explode(",", stripslashes($old_answer['answer']))); |
|
74 | + } else { |
|
75 | 75 | $ans_value = stripslashes($old_answer['answer']); |
76 | 76 | } |
77 | 77 | $cols_n_values = array( |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | 'ANS_value'=>$ans_value |
81 | 81 | ); |
82 | 82 | $datatypes = array( |
83 | - '%d',//REG_ID |
|
84 | - '%d',//QST_ID |
|
85 | - '%s',//ANS_value |
|
83 | + '%d', //REG_ID |
|
84 | + '%d', //QST_ID |
|
85 | + '%s', //ANS_value |
|
86 | 86 | ); |
87 | - $success = $wpdb->insert($this->_new_answer_table,$cols_n_values,$datatypes); |
|
88 | - if ( ! $success){ |
|
87 | + $success = $wpdb->insert($this->_new_answer_table, $cols_n_values, $datatypes); |
|
88 | + if ( ! $success) { |
|
89 | 89 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_answer, $this->_new_answer_table, $cols_n_values, $datatypes)); |
90 | 90 | return 0; |
91 | 91 | } |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * @param type $question_id |
100 | 100 | * @return string |
101 | 101 | */ |
102 | - private function _get_question_type($question_id){ |
|
102 | + private function _get_question_type($question_id) { |
|
103 | 103 | global $wpdb; |
104 | - $type = $wpdb->get_var($wpdb->prepare("SELECT QST_type FROM ".$this->_new_question_table." WHERE QST_ID=%d LIMIT 1",$question_id)); |
|
104 | + $type = $wpdb->get_var($wpdb->prepare("SELECT QST_type FROM ".$this->_new_question_table." WHERE QST_ID=%d LIMIT 1", $question_id)); |
|
105 | 105 | return $type; |
106 | 106 | } |
107 | 107 |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |