@@ -295,23 +295,23 @@ discard block |
||
295 | 295 | * @param float $amount |
296 | 296 | * @param string $name |
297 | 297 | * @param string $description |
298 | - * @param string $code |
|
299 | - * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
300 | - * the same code is found, $amount will be added onto it; otherwise will simply |
|
301 | - * set the taxes to match $amount |
|
298 | + * @param string $code |
|
299 | + * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
300 | + * the same code is found, $amount will be added onto it; otherwise will simply |
|
301 | + * set the taxes to match $amount |
|
302 | 302 | * @return EE_Line_Item the new tax created |
303 | 303 | */ |
304 | 304 | public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
305 | 305 | |
306 | - /** |
|
307 | - * Makes all the line items which are children of $line_item taxable (or not). |
|
308 | - * Does NOT save the line items |
|
309 | - * @param EE_Line_Item $line_item |
|
310 | - * @param boolean $taxable |
|
311 | - * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
312 | - * it will be whitelisted (ie, except from becoming taxable) |
|
313 | - */ |
|
314 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
306 | + /** |
|
307 | + * Makes all the line items which are children of $line_item taxable (or not). |
|
308 | + * Does NOT save the line items |
|
309 | + * @param EE_Line_Item $line_item |
|
310 | + * @param boolean $taxable |
|
311 | + * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
312 | + * it will be whitelisted (ie, except from becoming taxable) |
|
313 | + */ |
|
314 | + public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | */ |
342 | 342 | interface EEHI_Money{ |
343 | 343 | /** |
344 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
345 | - * This should be used to compare floats instead of normal '==' because floats |
|
346 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
347 | - * but actually differ by 0.00000001. |
|
348 | - * @param float $float1 |
|
349 | - * @param float $float2 |
|
350 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
351 | - * @return boolean whether the equation is true or false |
|
352 | - */ |
|
344 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
345 | + * This should be used to compare floats instead of normal '==' because floats |
|
346 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
347 | + * but actually differ by 0.00000001. |
|
348 | + * @param float $float1 |
|
349 | + * @param float $float2 |
|
350 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
351 | + * @return boolean whether the equation is true or false |
|
352 | + */ |
|
353 | 353 | function compare_floats( $float1, $float2, $operator='=' ); |
354 | 354 | } |
355 | 355 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Interface EEI_Base |
7 | 7 | */ |
8 | -interface EEI_Base{ |
|
8 | +interface EEI_Base { |
|
9 | 9 | /** |
10 | 10 | * gets the unique ID of the model object. If it hasn't been saved yet |
11 | 11 | * to the database, this should be 0 or NULL |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
33 | 33 | * NOTE: if the values haven't changed, returns 0 |
34 | 34 | */ |
35 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL); |
|
35 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param boolean $unique |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function add_extra_meta($meta_key,$meta_value,$unique = false); |
|
46 | + public function add_extra_meta($meta_key, $meta_value, $unique = false); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deletes all the extra meta rows for this record as specified by key. If $meta_value |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $meta_value |
53 | 53 | * @return int number of extra meta rows deleted |
54 | 54 | */ |
55 | - public function delete_extra_meta($meta_key,$meta_value = NULL); |
|
55 | + public function delete_extra_meta($meta_key, $meta_value = NULL); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $default if we don't find anything, what should we return? |
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
|
66 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param EE_Response $response |
91 | 91 | * @return EE_Response |
92 | 92 | */ |
93 | - public function handle_request( EE_Request $request, EE_Response $response ); |
|
93 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param EE_Request $request |
107 | 107 | * @param EE_Response $response |
108 | 108 | */ |
109 | - public function handle_response( EE_Request $request, EE_Response $response ); |
|
109 | + public function handle_response(EE_Request $request, EE_Response $response); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param string $country |
272 | 272 | * @param string $CNT_ISO |
273 | 273 | */ |
274 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
|
274 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | /** |
282 | 282 | * Interface EEHI_Line_Item |
283 | 283 | */ |
284 | -interface EEHI_Line_Item{ |
|
284 | +interface EEHI_Line_Item { |
|
285 | 285 | /** |
286 | 286 | * Adds an item to the purchase in the right spot |
287 | 287 | * @param EE_Line_Item $total_line_item |
288 | 288 | * @param EE_Line_Item $line_item |
289 | 289 | */ |
290 | - public function add_item( EE_line_Item $total_line_item, EE_Line_Item $line_item ); |
|
290 | + public function add_item(EE_line_Item $total_line_item, EE_Line_Item $line_item); |
|
291 | 291 | /** |
292 | 292 | * Overwrites the previous tax by clearing out the old taxes, and creates a new |
293 | 293 | * tax and updates the total line item accordingly |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * set the taxes to match $amount |
302 | 302 | * @return EE_Line_Item the new tax created |
303 | 303 | */ |
304 | - public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
|
304 | + public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Makes all the line items which are children of $line_item taxable (or not). |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param string $code_substring_for_whitelist if this string is part of the line item's code |
312 | 312 | * it will be whitelisted (ie, except from becoming taxable) |
313 | 313 | */ |
314 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
314 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -325,21 +325,21 @@ discard block |
||
325 | 325 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
326 | 326 | * @return boolean success |
327 | 327 | */ |
328 | - public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null ); |
|
328 | + public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null); |
|
329 | 329 | |
330 | 330 | /** |
331 | 331 | * Gets the line item for the taxes subtotal |
332 | 332 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
333 | 333 | * @return \EE_Line_Item |
334 | 334 | */ |
335 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ); |
|
335 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
339 | 339 | /** |
340 | 340 | * Money-related helper |
341 | 341 | */ |
342 | -interface EEHI_Money{ |
|
342 | +interface EEHI_Money { |
|
343 | 343 | /** |
344 | 344 | * For comparing floats. Default operator is '=', but see the $operator below for all options. |
345 | 345 | * This should be used to compare floats instead of normal '==' because floats |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
351 | 351 | * @return boolean whether the equation is true or false |
352 | 352 | */ |
353 | - function compare_floats( $float1, $float2, $operator='=' ); |
|
353 | + function compare_floats($float1, $float2, $operator = '='); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Interface EEHI_Template |
358 | 358 | */ |
359 | -interface EEHI_Template{ |
|
359 | +interface EEHI_Template { |
|
360 | 360 | |
361 | 361 | /** |
362 | 362 | * EEH_Template::format_currency |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @param string $cur_code_span_class |
370 | 370 | * @return string the html output for the formatted money value |
371 | 371 | */ |
372 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ); |
|
372 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code'); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param array $options |
385 | 385 | * @return mixed |
386 | 386 | */ |
387 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
387 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
388 | 388 | |
389 | 389 | } |
390 | 390 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @throws EE_Error |
397 | 397 | * @return bool |
398 | 398 | */ |
399 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ); |
|
399 | + public static function ensure_file_exists_and_is_writable($full_file_path = ''); |
|
400 | 400 | |
401 | 401 | /** |
402 | 402 | * ensure_folder_exists_and_is_writable |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @throws EE_Error |
406 | 406 | * @return bool |
407 | 407 | */ |
408 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ); |
|
408 | + public static function ensure_folder_exists_and_is_writable($folder = ''); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | // End of file EEI_Interfaces.php |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -21,37 +21,37 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @param EE_PMT_Paypal_Standard $payment_method_type |
23 | 23 | */ |
24 | - public function __construct( $payment_method_type ){ |
|
24 | + public function __construct($payment_method_type) { |
|
25 | 25 | parent::__construct( |
26 | 26 | array( |
27 | 27 | 'payment_method_type' => $payment_method_type, |
28 | 28 | 'extra_meta_inputs' => array( |
29 | - 'paypal_id' => new EE_Text_Input( array( |
|
30 | - 'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
31 | - 'html_help_text' => __( "Typically [email protected]", 'event_espresso' ), |
|
29 | + 'paypal_id' => new EE_Text_Input(array( |
|
30 | + 'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
31 | + 'html_help_text' => __("Typically [email protected]", 'event_espresso'), |
|
32 | 32 | 'required' => true |
33 | - ) ), |
|
34 | - 'image_url' => new EE_Admin_File_Uploader_Input( array( |
|
35 | - 'html_help_text' => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ), |
|
36 | - 'html_label_text' => __( 'Image URL', 'event_espresso' ) |
|
37 | - ) ), |
|
38 | - 'paypal_taxes' => new EE_Yes_No_Input( array( |
|
39 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
40 | - 'html_help_text' => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ), |
|
33 | + )), |
|
34 | + 'image_url' => new EE_Admin_File_Uploader_Input(array( |
|
35 | + 'html_help_text' => __("Used for your business/personal logo on the PayPal page", 'event_espresso'), |
|
36 | + 'html_label_text' => __('Image URL', 'event_espresso') |
|
37 | + )), |
|
38 | + 'paypal_taxes' => new EE_Yes_No_Input(array( |
|
39 | + 'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
40 | + 'html_help_text' => __('Whether Paypal should add taxes to the order', 'event_espresso'), |
|
41 | 41 | 'default' => false |
42 | - ) ), |
|
43 | - 'paypal_shipping' => new EE_Yes_No_Input( array( |
|
44 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
45 | - 'html_help_text' => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ), |
|
42 | + )), |
|
43 | + 'paypal_shipping' => new EE_Yes_No_Input(array( |
|
44 | + 'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
45 | + 'html_help_text' => __('Whether Paypal should add shipping surcharges', 'event_espresso'), |
|
46 | 46 | 'default' => false |
47 | - ) ), |
|
48 | - 'shipping_details' => new EE_Select_Input( array( |
|
49 | - EE_PMT_Paypal_Standard::shipping_info_none => __( "Do not prompt for an address", 'event_espresso' ), |
|
50 | - EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ), |
|
51 | - EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' ) |
|
52 | - ) ), |
|
47 | + )), |
|
48 | + 'shipping_details' => new EE_Select_Input(array( |
|
49 | + EE_PMT_Paypal_Standard::shipping_info_none => __("Do not prompt for an address", 'event_espresso'), |
|
50 | + EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'), |
|
51 | + EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso') |
|
52 | + )), |
|
53 | 53 | ), |
54 | - 'before_form_content_template' => $payment_method_type->file_folder() . DS . 'templates' . DS . 'paypal_standard_settings_before_form.template.php', |
|
54 | + 'before_form_content_template' => $payment_method_type->file_folder().DS.'templates'.DS.'paypal_standard_settings_before_form.template.php', |
|
55 | 55 | ) |
56 | 56 | ); |
57 | 57 | } |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @param array $req_data |
63 | 63 | */ |
64 | - protected function _normalize( $req_data ) { |
|
65 | - parent::_normalize( $req_data ); |
|
66 | - $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
|
67 | - $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
|
68 | - $paypal_requests_address_info = $this->get_input_value( 'shipping_details' ); |
|
64 | + protected function _normalize($req_data) { |
|
65 | + parent::_normalize($req_data); |
|
66 | + $paypal_calculates_shipping = $this->get_input_value('paypal_shipping'); |
|
67 | + $paypal_calculates_taxes = $this->get_input_value('paypal_taxes'); |
|
68 | + $paypal_requests_address_info = $this->get_input_value('shipping_details'); |
|
69 | 69 | if ( |
70 | - ( $paypal_calculates_shipping || $paypal_calculates_taxes ) && |
|
70 | + ($paypal_calculates_shipping || $paypal_calculates_taxes) && |
|
71 | 71 | $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none |
72 | 72 | ) { |
73 | 73 | //they want paypal to calculate taxes or shipping. They need to ask for |
74 | 74 | //address info, otherwise paypal can't calculate taxes or shipping |
75 | 75 | /** @type EE_Select_Input $shipping_details_input */ |
76 | - $shipping_details_input = $this->get_input( 'shipping_details' ); |
|
77 | - $shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional ); |
|
76 | + $shipping_details_input = $this->get_input('shipping_details'); |
|
77 | + $shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional); |
|
78 | 78 | $shipping_details_input_options = $shipping_details_input->options(); |
79 | 79 | EE_Error::add_attention( |
80 | 80 | sprintf( |
81 | - __( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ), |
|
82 | - strip_tags( $shipping_details_input->html_label_text() ), |
|
83 | - isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] ) |
|
84 | - ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] |
|
85 | - : __( 'Unknown', 'event_espresso' ) |
|
81 | + __('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'), |
|
82 | + strip_tags($shipping_details_input->html_label_text()), |
|
83 | + isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]) |
|
84 | + ? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional] |
|
85 | + : __('Unknown', 'event_espresso') |
|
86 | 86 | ), |
87 | 87 | __FILE__, __FUNCTION__, __LINE__ |
88 | 88 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | parent::set_settings($settings_array); |
78 | 78 | if($this->_debug_mode){ |
79 | 79 | $this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
80 | - }else{ |
|
80 | + } else{ |
|
81 | 81 | $this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr'; |
82 | 82 | } |
83 | 83 | } |
@@ -340,8 +340,9 @@ discard block |
||
340 | 340 | $update_info = array(); |
341 | 341 | foreach ( $raw_post_array as $keyval ) { |
342 | 342 | $keyval = explode( '=', $keyval ); |
343 | - if ( count( $keyval ) == 2 ) |
|
344 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
343 | + if ( count( $keyval ) == 2 ) { |
|
344 | + $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
345 | + } |
|
345 | 346 | } |
346 | 347 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
347 | 348 | $req = 'cmd=_notify-validate'; |
@@ -456,16 +456,16 @@ |
||
456 | 456 | |
457 | 457 | //might paypal have changed the taxes? |
458 | 458 | if( $this->_paypal_taxes && $payment_was_itemized ){ |
459 | - //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
|
460 | - $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
461 | - $this->_line_item->set_total_tax_to( |
|
462 | - $transaction->total_line_item(), |
|
463 | - floatval( $update_info['tax'] ), |
|
464 | - __( 'Taxes', 'event_espresso' ), |
|
465 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
466 | - 'paypal_tax' |
|
467 | - ); |
|
468 | - $grand_total_needs_resaving = TRUE; |
|
459 | + //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
|
460 | + $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
461 | + $this->_line_item->set_total_tax_to( |
|
462 | + $transaction->total_line_item(), |
|
463 | + floatval( $update_info['tax'] ), |
|
464 | + __( 'Taxes', 'event_espresso' ), |
|
465 | + __( 'Calculated by Paypal', 'event_espresso' ), |
|
466 | + 'paypal_tax' |
|
467 | + ); |
|
468 | + $grand_total_needs_resaving = TRUE; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | $shipping_amount = floatval( $update_info[ 'mc_shipping' ] ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return EEG_Paypal_Standard |
69 | 69 | */ |
70 | 70 | public function __construct() { |
71 | - $this->set_uses_separate_IPN_request( true ) ; |
|
71 | + $this->set_uses_separate_IPN_request(true); |
|
72 | 72 | parent::__construct(); |
73 | 73 | } |
74 | 74 | |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | * Also sets the gateway url class variable based on whether debug mode is enabled or not |
79 | 79 | * @param array $settings_array |
80 | 80 | */ |
81 | - public function set_settings($settings_array){ |
|
81 | + public function set_settings($settings_array) { |
|
82 | 82 | parent::set_settings($settings_array); |
83 | - if($this->_debug_mode){ |
|
83 | + if ($this->_debug_mode) { |
|
84 | 84 | $this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
85 | - }else{ |
|
85 | + } else { |
|
86 | 86 | $this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr'; |
87 | 87 | } |
88 | 88 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string $cancel_url URL to send the user to after a cancelled payment attempt on teh payment provider's website |
98 | 98 | * @return EEI_Payment |
99 | 99 | */ |
100 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ){ |
|
100 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
101 | 101 | $redirect_args = array(); |
102 | 102 | $transaction = $payment->transaction(); |
103 | 103 | $primary_registrant = $transaction->primary_registration(); |
@@ -107,42 +107,42 @@ discard block |
||
107 | 107 | |
108 | 108 | $total_discounts_to_cart_total = $transaction->paid(); |
109 | 109 | //only itemize the order if we're paying for the rest of the order's amount |
110 | - if( $payment->amount() == $transaction->total() ) { |
|
111 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true ); |
|
110 | + if ($payment->amount() == $transaction->total()) { |
|
111 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true); |
|
112 | 112 | //this payment is for the remaining transaction amount, |
113 | 113 | //keep track of exactly how much the itemized order amount equals |
114 | 114 | $itemized_sum = 0; |
115 | 115 | $shipping_previously_added = 0; |
116 | 116 | //so let's show all the line items |
117 | - foreach($total_line_item->get_items() as $line_item){ |
|
118 | - if ( $line_item instanceof EE_Line_Item ) { |
|
117 | + foreach ($total_line_item->get_items() as $line_item) { |
|
118 | + if ($line_item instanceof EE_Line_Item) { |
|
119 | 119 | //it's some kind of discount |
120 | - if( $line_item->total() < 0 ) { |
|
121 | - $total_discounts_to_cart_total += abs( $line_item->total() ); |
|
120 | + if ($line_item->total() < 0) { |
|
121 | + $total_discounts_to_cart_total += abs($line_item->total()); |
|
122 | 122 | $itemized_sum += $line_item->total(); |
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | //dont include shipping again. |
126 | - if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) { |
|
126 | + if (strpos($line_item->code(), 'paypal_shipping_') === 0) { |
|
127 | 127 | $shipping_previously_added = $line_item->total(); |
128 | 128 | continue; |
129 | 129 | } |
130 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
131 | - sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), |
|
130 | + $redirect_args['item_name_'.$item_num] = substr( |
|
131 | + sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), |
|
132 | 132 | 0, 127 |
133 | 133 | ); |
134 | - $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price(); |
|
135 | - $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity(); |
|
134 | + $redirect_args['amount_'.$item_num] = $line_item->unit_price(); |
|
135 | + $redirect_args['quantity_'.$item_num] = $line_item->quantity(); |
|
136 | 136 | //if we're not letting PayPal calculate shipping, tell them its 0 |
137 | - if ( ! $this->_paypal_shipping ) { |
|
138 | - $redirect_args[ 'shipping_' . $item_num ] = '0'; |
|
139 | - $redirect_args[ 'shipping2_' . $item_num ] = '0'; |
|
137 | + if ( ! $this->_paypal_shipping) { |
|
138 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
139 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
140 | 140 | } |
141 | 141 | $item_num++; |
142 | 142 | $itemized_sum += $line_item->total(); |
143 | 143 | } |
144 | 144 | } |
145 | - $taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item ); |
|
145 | + $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item); |
|
146 | 146 | //ideally itemized sum equals the transaction total. but if not (which is weird) |
147 | 147 | //and the itemized sum is LESS than the transaction total |
148 | 148 | //add another line item |
@@ -152,47 +152,47 @@ discard block |
||
152 | 152 | $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added, |
153 | 153 | 2 |
154 | 154 | ); |
155 | - if( $itemized_sum_diff_from_txn_total < 0 ) { |
|
155 | + if ($itemized_sum_diff_from_txn_total < 0) { |
|
156 | 156 | //itemized sum is too big |
157 | - $total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total ); |
|
158 | - } elseif( $itemized_sum_diff_from_txn_total > 0 ) { |
|
159 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
160 | - __( 'Other charges', 'event_espresso' ), 0, 127 ); |
|
161 | - $redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
162 | - $redirect_args[ 'quantity_' . $item_num ] = 1; |
|
157 | + $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total); |
|
158 | + } elseif ($itemized_sum_diff_from_txn_total > 0) { |
|
159 | + $redirect_args['item_name_'.$item_num] = substr( |
|
160 | + __('Other charges', 'event_espresso'), 0, 127 ); |
|
161 | + $redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
162 | + $redirect_args['quantity_'.$item_num] = 1; |
|
163 | 163 | $item_num++; |
164 | 164 | } |
165 | - if( $total_discounts_to_cart_total > 0 ) { |
|
166 | - $redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total ); |
|
165 | + if ($total_discounts_to_cart_total > 0) { |
|
166 | + $redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total); |
|
167 | 167 | } |
168 | 168 | //add our taxes to the order if we're NOT using PayPal's |
169 | - if( ! $this->_paypal_taxes ){ |
|
169 | + if ( ! $this->_paypal_taxes) { |
|
170 | 170 | $redirect_args['tax_cart'] = $total_line_item->get_total_tax(); |
171 | 171 | } |
172 | 172 | } else { |
173 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false ); |
|
173 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false); |
|
174 | 174 | //partial payment that's not for the remaining amount, so we can't send an itemized list |
175 | - $redirect_args['item_name_' . $item_num] = substr( |
|
176 | - sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ), |
|
175 | + $redirect_args['item_name_'.$item_num] = substr( |
|
176 | + sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()), |
|
177 | 177 | 0, 127 |
178 | 178 | ); |
179 | - $redirect_args['amount_' . $item_num] = $payment->amount(); |
|
180 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
181 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
179 | + $redirect_args['amount_'.$item_num] = $payment->amount(); |
|
180 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
181 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
182 | 182 | $redirect_args['tax_cart'] = '0'; |
183 | 183 | $item_num++; |
184 | 184 | } |
185 | 185 | |
186 | - if($this->_debug_mode){ |
|
187 | - $redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
188 | - $redirect_args['amount_' . $item_num] = 0; |
|
186 | + if ($this->_debug_mode) { |
|
187 | + $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
188 | + $redirect_args['amount_'.$item_num] = 0; |
|
189 | 189 | $redirect_args['on0_'.$item_num] = 'NOTIFY URL'; |
190 | - $redirect_args['os0_' . $item_num] = $notify_url; |
|
190 | + $redirect_args['os0_'.$item_num] = $notify_url; |
|
191 | 191 | $redirect_args['on1_'.$item_num] = 'RETURN URL'; |
192 | - $redirect_args['os1_' . $item_num] = $return_url; |
|
192 | + $redirect_args['os1_'.$item_num] = $return_url; |
|
193 | 193 | // $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ? |
194 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
195 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
194 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
195 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $redirect_args['business'] = $this->_paypal_id; |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | $redirect_args['cmd'] = '_cart'; |
203 | 203 | $redirect_args['upload'] = 1; |
204 | 204 | $redirect_args['currency_code'] = $payment->currency_code(); |
205 | - $redirect_args['rm'] = 2;//makes the user return with method=POST |
|
206 | - if($this->_image_url){ |
|
205 | + $redirect_args['rm'] = 2; //makes the user return with method=POST |
|
206 | + if ($this->_image_url) { |
|
207 | 207 | $redirect_args['image_url'] = $this->_image_url; |
208 | 208 | } |
209 | 209 | $redirect_args['no_shipping'] = $this->_shipping_details; |
210 | - $redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this |
|
210 | + $redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this |
|
211 | 211 | |
212 | - $redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this ); |
|
212 | + $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this); |
|
213 | 213 | |
214 | 214 | $payment->set_redirect_url($this->_gateway_url); |
215 | 215 | $payment->set_redirect_args($redirect_args); |
@@ -230,55 +230,55 @@ discard block |
||
230 | 230 | * @return \EEI_Payment updated |
231 | 231 | * @throws \EE_Error |
232 | 232 | */ |
233 | - public function handle_payment_update( $update_info, $transaction ){ |
|
233 | + public function handle_payment_update($update_info, $transaction) { |
|
234 | 234 | //verify there's payment data that's been sent |
235 | - if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) { |
|
235 | + if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) { |
|
236 | 236 | // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/) |
237 | 237 | // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes |
238 | - if ( isset( $update_info[ 'tx' ] ) ) { |
|
238 | + if (isset($update_info['tx'])) { |
|
239 | 239 | return $transaction->last_payment(); |
240 | 240 | } else { |
241 | 241 | return null; |
242 | 242 | } |
243 | 243 | } |
244 | - $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
245 | - if ( ! $payment instanceof EEI_Payment ) { |
|
244 | + $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']); |
|
245 | + if ( ! $payment instanceof EEI_Payment) { |
|
246 | 246 | $payment = $transaction->last_payment(); |
247 | 247 | } |
248 | 248 | // ok, then validate the IPN. Even if we've already processed this payment, |
249 | 249 | // let PayPal know we don't want to hear from them anymore! |
250 | - if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
|
250 | + if ( ! $this->validate_ipn($update_info, $payment)) { |
|
251 | 251 | return $payment; |
252 | 252 | } |
253 | 253 | //ok, well let's process this payment then! |
254 | - switch ( $update_info[ 'payment_status' ] ) { |
|
254 | + switch ($update_info['payment_status']) { |
|
255 | 255 | |
256 | 256 | case 'Completed' : |
257 | 257 | $status = $this->_pay_model->approved_status(); |
258 | - $gateway_response = __( 'The payment is approved.', 'event_espresso' ); |
|
258 | + $gateway_response = __('The payment is approved.', 'event_espresso'); |
|
259 | 259 | break; |
260 | 260 | |
261 | 261 | case 'Pending' : |
262 | 262 | $status = $this->_pay_model->pending_status(); |
263 | - $gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' ); |
|
263 | + $gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso'); |
|
264 | 264 | break; |
265 | 265 | |
266 | 266 | case 'Denied' : |
267 | 267 | $status = $this->_pay_model->declined_status(); |
268 | - $gateway_response = __( 'The payment has been declined.', 'event_espresso' ); |
|
268 | + $gateway_response = __('The payment has been declined.', 'event_espresso'); |
|
269 | 269 | break; |
270 | 270 | |
271 | 271 | case 'Expired' : |
272 | 272 | case 'Failed' : |
273 | 273 | $status = $this->_pay_model->failed_status(); |
274 | - $gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' ); |
|
274 | + $gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso'); |
|
275 | 275 | break; |
276 | 276 | |
277 | 277 | case 'Refunded' : |
278 | 278 | case 'Partially_Refunded' : |
279 | 279 | // even though it's a refund, we consider the payment as approved, it just has a negative value |
280 | 280 | $status = $this->_pay_model->approved_status(); |
281 | - $gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' ); |
|
281 | + $gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso'); |
|
282 | 282 | break; |
283 | 283 | |
284 | 284 | case 'Voided' : |
@@ -286,25 +286,25 @@ discard block |
||
286 | 286 | case 'Canceled_Reversal' : |
287 | 287 | default : |
288 | 288 | $status = $this->_pay_model->cancelled_status(); |
289 | - $gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' ); |
|
289 | + $gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso'); |
|
290 | 290 | break; |
291 | 291 | |
292 | 292 | } |
293 | 293 | |
294 | 294 | //check if we've already processed this payment |
295 | - if ( $payment instanceof EEI_Payment ) { |
|
295 | + if ($payment instanceof EEI_Payment) { |
|
296 | 296 | //payment exists. if this has the exact same status and amount, don't bother updating. just return |
297 | - if ( $payment->status() == $status && $payment->amount() == $update_info[ 'mc_gross' ] ) { |
|
297 | + if ($payment->status() == $status && $payment->amount() == $update_info['mc_gross']) { |
|
298 | 298 | // DUPLICATED IPN! dont bother updating transaction foo!; |
299 | - $message_log = sprintf( __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), $payment->ID() ); |
|
299 | + $message_log = sprintf(__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), $payment->ID()); |
|
300 | 300 | } else { |
301 | 301 | // new payment yippee !!! |
302 | - $payment->set_status( $status ); |
|
303 | - $payment->set_amount( floatval( $update_info[ 'mc_gross' ] ) ); |
|
304 | - $payment->set_gateway_response( $gateway_response ); |
|
305 | - $payment->set_details( $update_info ); |
|
306 | - $payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
307 | - $message_log = sprintf( __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ) ); |
|
302 | + $payment->set_status($status); |
|
303 | + $payment->set_amount(floatval($update_info['mc_gross'])); |
|
304 | + $payment->set_gateway_response($gateway_response); |
|
305 | + $payment->set_details($update_info); |
|
306 | + $payment->set_txn_id_chq_nmbr($update_info['txn_id']); |
|
307 | + $message_log = sprintf(__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso')); |
|
308 | 308 | } |
309 | 309 | $this->log( |
310 | 310 | array( |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | $payment |
317 | 317 | ); |
318 | 318 | } |
319 | - do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this ); |
|
319 | + do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this); |
|
320 | 320 | // kill request here if this is a refund |
321 | - if ( $update_info[ 'payment_status' ] == 'Refunded' || $update_info[ 'payment_status' ] == 'Partially_Refunded' ) { |
|
322 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) ) { |
|
323 | - status_header( 200 ); |
|
321 | + if ($update_info['payment_status'] == 'Refunded' || $update_info['payment_status'] == 'Partially_Refunded') { |
|
322 | + if (apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)) { |
|
323 | + status_header(200); |
|
324 | 324 | exit(); |
325 | 325 | } |
326 | 326 | } |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * @param EE_Payment|EEI_Payment $payment |
337 | 337 | * @return boolean |
338 | 338 | */ |
339 | - public function validate_ipn( $update_info, $payment ) { |
|
339 | + public function validate_ipn($update_info, $payment) { |
|
340 | 340 | //allow us to skip validating IPNs with PayPal (useful for testing) |
341 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) { |
|
341 | + if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) { |
|
342 | 342 | return true; |
343 | 343 | } |
344 | 344 | //...otherwise, we actually don't care what the $update_info is, we need to look |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. |
347 | 347 | // Instead, read raw POST data from the input stream. |
348 | 348 | // @see https://gist.github.com/xcommerce-gists/3440401 |
349 | - $raw_post_data = file_get_contents( 'php://input' ); |
|
350 | - $raw_post_array = explode( '&', $raw_post_data ); |
|
349 | + $raw_post_data = file_get_contents('php://input'); |
|
350 | + $raw_post_array = explode('&', $raw_post_data); |
|
351 | 351 | $update_info = array(); |
352 | - foreach ( $raw_post_array as $keyval ) { |
|
353 | - $keyval = explode( '=', $keyval ); |
|
354 | - if ( count( $keyval ) == 2 ) |
|
355 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
352 | + foreach ($raw_post_array as $keyval) { |
|
353 | + $keyval = explode('=', $keyval); |
|
354 | + if (count($keyval) == 2) |
|
355 | + $update_info[$keyval[0]] = urldecode($keyval[1]); |
|
356 | 356 | } |
357 | 357 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
358 | 358 | $req = 'cmd=_notify-validate'; |
359 | - $get_magic_quotes_exists = function_exists( 'get_magic_quotes_gpc' ) ? true : false; |
|
360 | - foreach ( $update_info as $key => $value ) { |
|
361 | - if ( $get_magic_quotes_exists && get_magic_quotes_gpc() == 1 ) { |
|
362 | - $value = urlencode( stripslashes( $value ) ); |
|
359 | + $get_magic_quotes_exists = function_exists('get_magic_quotes_gpc') ? true : false; |
|
360 | + foreach ($update_info as $key => $value) { |
|
361 | + if ($get_magic_quotes_exists && get_magic_quotes_gpc() == 1) { |
|
362 | + $value = urlencode(stripslashes($value)); |
|
363 | 363 | } else { |
364 | - $value = urlencode( $value ); |
|
364 | + $value = urlencode($value); |
|
365 | 365 | } |
366 | 366 | $req .= "&$key=$value"; |
367 | 367 | } |
@@ -371,21 +371,21 @@ discard block |
||
371 | 371 | array( |
372 | 372 | 'body' => $req, |
373 | 373 | 'sslverify' => false, |
374 | - 'timeout' => 60 , |
|
374 | + 'timeout' => 60, |
|
375 | 375 | // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal |
376 | 376 | // plz see: https://github.com/websharks/s2member/issues/610 |
377 | - 'user-agent' => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(), |
|
377 | + 'user-agent' => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(), |
|
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | // then check the response |
381 | - if ( ! is_wp_error( $response ) && array_key_exists( 'body', $response ) && strcmp( $response[ 'body' ], "VERIFIED" ) == 0 ) { |
|
381 | + if ( ! is_wp_error($response) && array_key_exists('body', $response) && strcmp($response['body'], "VERIFIED") == 0) { |
|
382 | 382 | return true; |
383 | 383 | } else { |
384 | 384 | // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly, |
385 | 385 | // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html |
386 | - $payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $response[ 'body' ] ) ); |
|
387 | - $payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) ); |
|
388 | - $payment->set_status( EEM_Payment::status_id_failed ); |
|
386 | + $payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $response['body'])); |
|
387 | + $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response)); |
|
388 | + $payment->set_status(EEM_Payment::status_id_failed); |
|
389 | 389 | // log the results |
390 | 390 | $this->log( |
391 | 391 | array( |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | */ |
408 | 408 | protected function _process_response_url() { |
409 | 409 | EE_Registry::instance()->load_helper('URL'); |
410 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
410 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
411 | 411 | $url = is_ssl() ? 'https://' : 'http://'; |
412 | - $url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
412 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
413 | 413 | $url .= EEH_URL::filter_input_server_url(); |
414 | 414 | } else { |
415 | 415 | $url = 'unknown'; |
@@ -425,30 +425,30 @@ discard block |
||
425 | 425 | * like the taxes or shipping |
426 | 426 | * @param EEI_Payment $payment |
427 | 427 | */ |
428 | - public function update_txn_based_on_payment( $payment ) { |
|
428 | + public function update_txn_based_on_payment($payment) { |
|
429 | 429 | $update_info = $payment->details(); |
430 | 430 | $transaction = $payment->transaction(); |
431 | - $payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false ); |
|
432 | - if( ! $transaction ){ |
|
433 | - $this->log( __( 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso' ), $payment ); |
|
431 | + $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false); |
|
432 | + if ( ! $transaction) { |
|
433 | + $this->log(__('Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso'), $payment); |
|
434 | 434 | return; |
435 | 435 | } |
436 | - if( ! is_array( $update_info ) || ! isset( $update_info[ 'mc_shipping' ] ) || ! isset( $update_info[ 'tax' ] ) ) { |
|
436 | + if ( ! is_array($update_info) || ! isset($update_info['mc_shipping']) || ! isset($update_info['tax'])) { |
|
437 | 437 | $this->log( |
438 | 438 | array( |
439 | 439 | 'url' => $this->_process_response_url(), |
440 | - 'message' => __( 'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso' ), |
|
440 | + 'message' => __('Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso'), |
|
441 | 441 | 'payment' => $payment->model_field_array() |
442 | 442 | ), |
443 | 443 | $payment |
444 | 444 | ); |
445 | 445 | return; |
446 | 446 | } |
447 | - if( $payment->status() !== $this->_pay_model->approved_status() ) { |
|
447 | + if ($payment->status() !== $this->_pay_model->approved_status()) { |
|
448 | 448 | $this->log( |
449 | 449 | array( |
450 | 450 | 'url' => $this->_process_response_url(), |
451 | - 'message' => __( 'We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso' ), |
|
451 | + 'message' => __('We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso'), |
|
452 | 452 | 'payment' => $payment->model_field_array() |
453 | 453 | ), |
454 | 454 | $payment |
@@ -458,43 +458,43 @@ discard block |
||
458 | 458 | $grand_total_needs_resaving = false; |
459 | 459 | |
460 | 460 | //might paypal have changed the taxes? |
461 | - if( $this->_paypal_taxes && $payment_was_itemized ){ |
|
461 | + if ($this->_paypal_taxes && $payment_was_itemized) { |
|
462 | 462 | //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
463 | - $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
463 | + $this->_line_item->set_line_items_taxable($transaction->total_line_item(), true, 'paypal_shipping'); |
|
464 | 464 | $this->_line_item->set_total_tax_to( |
465 | 465 | $transaction->total_line_item(), |
466 | - floatval( $update_info['tax'] ), |
|
467 | - __( 'Taxes', 'event_espresso' ), |
|
468 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
466 | + floatval($update_info['tax']), |
|
467 | + __('Taxes', 'event_espresso'), |
|
468 | + __('Calculated by Paypal', 'event_espresso'), |
|
469 | 469 | 'paypal_tax' |
470 | 470 | ); |
471 | 471 | $grand_total_needs_resaving = TRUE; |
472 | 472 | } |
473 | 473 | |
474 | - $shipping_amount = floatval( $update_info[ 'mc_shipping' ] ); |
|
474 | + $shipping_amount = floatval($update_info['mc_shipping']); |
|
475 | 475 | //might paypal have added shipping? |
476 | - if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){ |
|
476 | + if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) { |
|
477 | 477 | $this->_line_item->add_unrelated_item( |
478 | 478 | $transaction->total_line_item(), |
479 | - sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ), |
|
479 | + sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()), |
|
480 | 480 | $shipping_amount, |
481 | 481 | __('Shipping charges calculated by Paypal', 'event_espresso'), |
482 | 482 | 1, |
483 | 483 | false, |
484 | - 'paypal_shipping_' . $transaction->ID() |
|
484 | + 'paypal_shipping_'.$transaction->ID() |
|
485 | 485 | ); |
486 | 486 | $grand_total_needs_resaving = true; |
487 | 487 | } |
488 | 488 | |
489 | - if( $grand_total_needs_resaving ){ |
|
490 | - $transaction->total_line_item()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
491 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
492 | - $registration_processor->update_registration_final_prices( $transaction ); |
|
489 | + if ($grand_total_needs_resaving) { |
|
490 | + $transaction->total_line_item()->save_this_and_descendants_to_txn($transaction->ID()); |
|
491 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
492 | + $registration_processor->update_registration_final_prices($transaction); |
|
493 | 493 | } |
494 | 494 | $this->log( |
495 | 495 | array( |
496 | 496 | 'url' => $this->_process_response_url(), |
497 | - 'message' => __( 'Updated transaction related to payment', 'event_espresso' ), |
|
497 | + 'message' => __('Updated transaction related to payment', 'event_espresso'), |
|
498 | 498 | 'transaction (updated)' => $transaction->model_field_array(), |
499 | 499 | 'payment (updated)' => $payment->model_field_array(), |
500 | 500 | 'use_paypal_shipping' => $this->_paypal_shipping, |
@@ -595,8 +595,6 @@ |
||
595 | 595 | * converts it into a "remote" filepath (the filepath the currently-in-use |
596 | 596 | * $wp_filesystem needs to use access the folder or file). |
597 | 597 | * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins |
598 | - * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one |
|
599 | - * is in use, so you need to provide it |
|
600 | 598 | * @param string $local_filepath the filepath to the folder/file locally |
601 | 599 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
602 | 600 | * ftp or ssh, will use to access the folder |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @ version 4.0 |
13 | 13 | * |
14 | 14 | */ |
15 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
16 | -require_once( EE_INTERFACES . 'EEI_Interfaces.php' ); |
|
15 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
16 | +require_once(EE_INTERFACES.'EEI_Interfaces.php'); |
|
17 | 17 | /** |
18 | 18 | * |
19 | 19 | * Class EEH_File |
@@ -42,30 +42,30 @@ discard block |
||
42 | 42 | * @throws EE_Error |
43 | 43 | * @return WP_Filesystem_Base |
44 | 44 | */ |
45 | - private static function _get_wp_filesystem( $filepath = null) { |
|
46 | - if( apply_filters( |
|
45 | + private static function _get_wp_filesystem($filepath = null) { |
|
46 | + if (apply_filters( |
|
47 | 47 | 'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', |
48 | - $filepath && EEH_File::is_in_uploads_folder( $filepath ), |
|
49 | - $filepath ) ) { |
|
50 | - if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) { |
|
51 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
48 | + $filepath && EEH_File::is_in_uploads_folder($filepath), |
|
49 | + $filepath )) { |
|
50 | + if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) { |
|
51 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
52 | 52 | $method = 'direct'; |
53 | - $wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
53 | + $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
54 | 54 | //check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem() |
55 | - if ( ! defined('FS_CHMOD_DIR') ) { |
|
56 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
55 | + if ( ! defined('FS_CHMOD_DIR')) { |
|
56 | + define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755)); |
|
57 | 57 | } |
58 | - if ( ! defined('FS_CHMOD_FILE') ) { |
|
59 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
58 | + if ( ! defined('FS_CHMOD_FILE')) { |
|
59 | + define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644)); |
|
60 | 60 | } |
61 | - require_once( $wp_filesystem_direct_file ); |
|
62 | - EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() ); |
|
61 | + require_once($wp_filesystem_direct_file); |
|
62 | + EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array()); |
|
63 | 63 | } |
64 | 64 | return EEH_File::$_wp_filesystem_direct; |
65 | 65 | } |
66 | 66 | global $wp_filesystem; |
67 | 67 | // no filesystem setup ??? |
68 | - if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { |
|
68 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base) { |
|
69 | 69 | // if some eager beaver's just trying to get in there too early... |
70 | 70 | // let them do it, because we are one of those eager beavers! :P |
71 | 71 | /** |
@@ -78,34 +78,34 @@ discard block |
||
78 | 78 | * and there may be troubles if the WP files are owned by a different user |
79 | 79 | * than the server user. But both of these issues should exist in 4.4 and earlier too |
80 | 80 | */ |
81 | - if ( FALSE && ! did_action( 'wp_loaded' )) { |
|
81 | + if (FALSE && ! did_action('wp_loaded')) { |
|
82 | 82 | $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'); |
83 | - if ( WP_DEBUG ) { |
|
84 | - $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
83 | + if (WP_DEBUG) { |
|
84 | + $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
85 | 85 | } |
86 | - throw new EE_Error( $msg ); |
|
86 | + throw new EE_Error($msg); |
|
87 | 87 | } else { |
88 | 88 | // should be loaded if we are past the wp_loaded hook... |
89 | - if ( ! function_exists( 'WP_Filesystem' )) { |
|
90 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
91 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
89 | + if ( ! function_exists('WP_Filesystem')) { |
|
90 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
91 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
92 | 92 | } |
93 | 93 | // turn on output buffering so that we can capture the credentials form |
94 | 94 | ob_start(); |
95 | - $credentials = request_filesystem_credentials( '' ); |
|
95 | + $credentials = request_filesystem_credentials(''); |
|
96 | 96 | // store credentials form for the time being |
97 | 97 | EEH_File::$_credentials_form = ob_get_clean(); |
98 | 98 | // basically check for direct or previously configured access |
99 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
99 | + if ( ! WP_Filesystem($credentials)) { |
|
100 | 100 | // if credentials do NOT exist |
101 | - if ( $credentials === FALSE ) { |
|
102 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
103 | - throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
104 | - } elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
105 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
101 | + if ($credentials === FALSE) { |
|
102 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
103 | + throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
104 | + } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
105 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
106 | 106 | throw new EE_Error( |
107 | 107 | sprintf( |
108 | - __( 'WP Filesystem Error: $1%s', 'event_espresso' ), |
|
108 | + __('WP Filesystem Error: $1%s', 'event_espresso'), |
|
109 | 109 | $wp_filesystem->errors->get_error_message() ) ); |
110 | 110 | } |
111 | 111 | } |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * display_request_filesystem_credentials_form |
119 | 119 | */ |
120 | 120 | public static function display_request_filesystem_credentials_form() { |
121 | - if ( ! empty( EEH_File::$_credentials_form )) { |
|
122 | - echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>'; |
|
121 | + if ( ! empty(EEH_File::$_credentials_form)) { |
|
122 | + echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>'; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -137,29 +137,29 @@ discard block |
||
137 | 137 | * @throws EE_Error |
138 | 138 | * @return bool |
139 | 139 | */ |
140 | - public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) { |
|
140 | + public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') { |
|
141 | 141 | // load WP_Filesystem and set file permissions |
142 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
143 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
144 | - if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) { |
|
145 | - $file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name; |
|
146 | - $file_name .= ! empty( $file_ext ) ? ' file' : ' folder'; |
|
142 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
143 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
144 | + if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
145 | + $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name; |
|
146 | + $file_name .= ! empty($file_ext) ? ' file' : ' folder'; |
|
147 | 147 | $msg = sprintf( |
148 | - __( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ), |
|
148 | + __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'), |
|
149 | 149 | $file_name, |
150 | 150 | '<br />' |
151 | 151 | ); |
152 | - if ( EEH_File::exists( $full_file_path )) { |
|
153 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file ); |
|
152 | + if (EEH_File::exists($full_file_path)) { |
|
153 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file); |
|
154 | 154 | } else { |
155 | 155 | // no file permissions means the file was not found |
156 | 156 | $msg .= sprintf( |
157 | - __( 'Please ensure the following path is correct: "%s".', 'event_espresso' ), |
|
157 | + __('Please ensure the following path is correct: "%s".', 'event_espresso'), |
|
158 | 158 | $full_file_path |
159 | 159 | ); |
160 | 160 | } |
161 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
162 | - throw new EE_Error( $msg . '||' . $msg ); |
|
161 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
162 | + throw new EE_Error($msg.'||'.$msg); |
|
163 | 163 | } |
164 | 164 | return FALSE; |
165 | 165 | } |
@@ -176,24 +176,24 @@ discard block |
||
176 | 176 | * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages |
177 | 177 | * @return string |
178 | 178 | */ |
179 | - private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){ |
|
179 | + private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') { |
|
180 | 180 | // load WP_Filesystem and set file permissions |
181 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
181 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
182 | 182 | // check file permissions |
183 | - $perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
184 | - if ( $perms ) { |
|
183 | + $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
184 | + if ($perms) { |
|
185 | 185 | // file permissions exist, but way be set incorrectly |
186 | - $type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : ''; |
|
187 | - $type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder'; |
|
186 | + $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : ''; |
|
187 | + $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder'; |
|
188 | 188 | return sprintf( |
189 | - __( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ), |
|
189 | + __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'), |
|
190 | 190 | $type_of_file, |
191 | 191 | $perms |
192 | 192 | ); |
193 | 193 | } else { |
194 | 194 | // file exists but file permissions could not be read ?!?! |
195 | 195 | return sprintf( |
196 | - __( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ), |
|
196 | + __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'), |
|
197 | 197 | $full_file_path |
198 | 198 | ); |
199 | 199 | } |
@@ -211,35 +211,35 @@ discard block |
||
211 | 211 | * can't write to it |
212 | 212 | * @return bool false if folder isn't writable; true if it exists and is writeable, |
213 | 213 | */ |
214 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ){ |
|
215 | - if ( empty( $folder )) { |
|
214 | + public static function ensure_folder_exists_and_is_writable($folder = '') { |
|
215 | + if (empty($folder)) { |
|
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | // remove ending DS |
219 | - $folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' )); |
|
220 | - $parent_folder = EEH_File::get_parent_folder( $folder ); |
|
219 | + $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\')); |
|
220 | + $parent_folder = EEH_File::get_parent_folder($folder); |
|
221 | 221 | // add DS to folder |
222 | - $folder = EEH_File::end_with_directory_separator( $folder ); |
|
223 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $folder ); |
|
224 | - if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
222 | + $folder = EEH_File::end_with_directory_separator($folder); |
|
223 | + $wp_filesystem = EEH_File::_get_wp_filesystem($folder); |
|
224 | + if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
225 | 225 | //ok so it doesn't exist. Does its parent? Can we write to it? |
226 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
226 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | - if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) { |
|
229 | + if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) { |
|
230 | 230 | return false; |
231 | 231 | } else { |
232 | - if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
233 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
234 | - $msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder ); |
|
235 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder ); |
|
236 | - throw new EE_Error( $msg ); |
|
232 | + if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
233 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
234 | + $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder); |
|
235 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder); |
|
236 | + throw new EE_Error($msg); |
|
237 | 237 | } |
238 | 238 | return false; |
239 | 239 | } |
240 | - EEH_File::add_index_file( $folder ); |
|
240 | + EEH_File::add_index_file($folder); |
|
241 | 241 | } |
242 | - } elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
242 | + } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | return true; |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | * @throws EE_Error |
255 | 255 | * @return bool |
256 | 256 | */ |
257 | - public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){ |
|
257 | + public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') { |
|
258 | 258 | // load WP_Filesystem and set file permissions |
259 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_path ); |
|
260 | - $full_path = EEH_File::standardise_directory_separators( $full_path ); |
|
261 | - if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) { |
|
262 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
263 | - $msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder ); |
|
264 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path ); |
|
265 | - throw new EE_Error( $msg ); |
|
259 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_path); |
|
260 | + $full_path = EEH_File::standardise_directory_separators($full_path); |
|
261 | + if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) { |
|
262 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
263 | + $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder); |
|
264 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path); |
|
265 | + throw new EE_Error($msg); |
|
266 | 266 | } |
267 | 267 | return FALSE; |
268 | 268 | } |
@@ -279,25 +279,25 @@ discard block |
||
279 | 279 | * @throws EE_Error |
280 | 280 | * @return bool |
281 | 281 | */ |
282 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) { |
|
282 | + public static function ensure_file_exists_and_is_writable($full_file_path = '') { |
|
283 | 283 | // load WP_Filesystem and set file permissions |
284 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
285 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
286 | - $parent_folder = EEH_File::get_parent_folder( $full_file_path ); |
|
287 | - if ( ! EEH_File::exists( $full_file_path )) { |
|
288 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
284 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
285 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
286 | + $parent_folder = EEH_File::get_parent_folder($full_file_path); |
|
287 | + if ( ! EEH_File::exists($full_file_path)) { |
|
288 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
289 | 289 | return false; |
290 | 290 | } |
291 | - if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
292 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
293 | - $msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path ); |
|
294 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
295 | - throw new EE_Error( $msg ); |
|
291 | + if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
292 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
293 | + $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path); |
|
294 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
295 | + throw new EE_Error($msg); |
|
296 | 296 | } |
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | } |
300 | - if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) { |
|
300 | + if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) { |
|
301 | 301 | return false; |
302 | 302 | } |
303 | 303 | return true; |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | * @param string $file_or_folder_path |
310 | 310 | * @return string parent folder, ENDING with a directory separator |
311 | 311 | */ |
312 | - public static function get_parent_folder( $file_or_folder_path ) { |
|
312 | + public static function get_parent_folder($file_or_folder_path) { |
|
313 | 313 | //find the last DS, ignoring a DS on the very end |
314 | 314 | //eg if given "/var/something/somewhere/", we want to get "somewhere"'s |
315 | 315 | //parent folder, "/var/something/" |
316 | - $ds = strrpos( $file_or_folder_path, DS, -2 ); |
|
317 | - return substr( $file_or_folder_path, 0, $ds + 1 ); |
|
316 | + $ds = strrpos($file_or_folder_path, DS, -2); |
|
317 | + return substr($file_or_folder_path, 0, $ds + 1); |
|
318 | 318 | } |
319 | 319 | |
320 | - public static function ensure_folder_exists_recursively( $folder ) { |
|
320 | + public static function ensure_folder_exists_recursively($folder) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | * @param string $full_file_path |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public static function get_file_contents( $full_file_path = '' ){ |
|
332 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
333 | - if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) { |
|
331 | + public static function get_file_contents($full_file_path = '') { |
|
332 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
333 | + if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { |
|
334 | 334 | // load WP_Filesystem and set file permissions |
335 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
336 | - return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
335 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
336 | + return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
337 | 337 | } |
338 | 338 | return ''; |
339 | 339 | } |
@@ -348,26 +348,26 @@ discard block |
||
348 | 348 | * @throws EE_Error |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){ |
|
352 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
353 | - $file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : ''; |
|
354 | - $folder = EEH_File::remove_filename_from_filepath( $full_file_path ); |
|
355 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
356 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
357 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path ); |
|
358 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
359 | - throw new EE_Error( $msg ); |
|
351 | + public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') { |
|
352 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
353 | + $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : ''; |
|
354 | + $folder = EEH_File::remove_filename_from_filepath($full_file_path); |
|
355 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
356 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
357 | + $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path); |
|
358 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
359 | + throw new EE_Error($msg); |
|
360 | 360 | } |
361 | 361 | return FALSE; |
362 | 362 | } |
363 | 363 | // load WP_Filesystem and set file permissions |
364 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
364 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
365 | 365 | // write the file |
366 | - if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) { |
|
367 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
368 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path ); |
|
369 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' ); |
|
370 | - throw new EE_Error( $msg ); |
|
366 | + if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) { |
|
367 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
368 | + $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path); |
|
369 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f'); |
|
370 | + throw new EE_Error($msg); |
|
371 | 371 | } |
372 | 372 | return FALSE; |
373 | 373 | } |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | * @param boolean|string $type 'd' for directory, 'f' for file |
383 | 383 | * @return boolean |
384 | 384 | */ |
385 | - public static function delete( $filepath, $recursive = false, $type = false ) { |
|
385 | + public static function delete($filepath, $recursive = false, $type = false) { |
|
386 | 386 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
387 | - return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE; |
|
387 | + return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @param string $full_file_path |
397 | 397 | * @return bool |
398 | 398 | */ |
399 | - public static function exists( $full_file_path = '' ) { |
|
400 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
401 | - return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE; |
|
399 | + public static function exists($full_file_path = '') { |
|
400 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
401 | + return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | * @param string $full_file_path |
411 | 411 | * @return bool |
412 | 412 | */ |
413 | - public static function is_readable( $full_file_path = '' ) { |
|
414 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
415 | - if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
413 | + public static function is_readable($full_file_path = '') { |
|
414 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
415 | + if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
416 | 416 | return true; |
417 | 417 | } else { |
418 | 418 | return false; |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @param string $full_file_path |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public static function remove_filename_from_filepath( $full_file_path = '' ) { |
|
432 | - return pathinfo( $full_file_path, PATHINFO_DIRNAME ); |
|
431 | + public static function remove_filename_from_filepath($full_file_path = '') { |
|
432 | + return pathinfo($full_file_path, PATHINFO_DIRNAME); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | * @param string $full_file_path |
440 | 440 | * @return string |
441 | 441 | */ |
442 | - public static function get_filename_from_filepath( $full_file_path = '' ) { |
|
443 | - return pathinfo( $full_file_path, PATHINFO_BASENAME ); |
|
442 | + public static function get_filename_from_filepath($full_file_path = '') { |
|
443 | + return pathinfo($full_file_path, PATHINFO_BASENAME); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | * @param string $full_file_path |
451 | 451 | * @return string |
452 | 452 | */ |
453 | - public static function get_file_extension( $full_file_path = '' ) { |
|
454 | - return pathinfo( $full_file_path, PATHINFO_EXTENSION ); |
|
453 | + public static function get_file_extension($full_file_path = '') { |
|
454 | + return pathinfo($full_file_path, PATHINFO_EXTENSION); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | * @param string $folder |
462 | 462 | * @return bool |
463 | 463 | */ |
464 | - public static function add_htaccess_deny_from_all( $folder = '' ) { |
|
465 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
466 | - if ( ! EEH_File::exists( $folder . '.htaccess' ) ) { |
|
467 | - if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) { |
|
464 | + public static function add_htaccess_deny_from_all($folder = '') { |
|
465 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
466 | + if ( ! EEH_File::exists($folder.'.htaccess')) { |
|
467 | + if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) { |
|
468 | 468 | return FALSE; |
469 | 469 | } |
470 | 470 | } |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | * @param string $folder |
478 | 478 | * @return boolean |
479 | 479 | */ |
480 | - public static function add_index_file( $folder ) { |
|
481 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
482 | - if ( ! EEH_File::exists( $folder . 'index.php' ) ) { |
|
483 | - if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) { |
|
480 | + public static function add_index_file($folder) { |
|
481 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
482 | + if ( ! EEH_File::exists($folder.'index.php')) { |
|
483 | + if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) { |
|
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | } |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | * @param string $file_path |
496 | 496 | * @return string |
497 | 497 | */ |
498 | - public static function get_classname_from_filepath_with_standard_filename( $file_path ){ |
|
498 | + public static function get_classname_from_filepath_with_standard_filename($file_path) { |
|
499 | 499 | //extract file from path |
500 | - $filename = basename( $file_path ); |
|
500 | + $filename = basename($file_path); |
|
501 | 501 | //now remove the first period and everything after |
502 | - $pos_of_first_period = strpos( $filename,'.' ); |
|
502 | + $pos_of_first_period = strpos($filename, '.'); |
|
503 | 503 | return substr($filename, 0, $pos_of_first_period); |
504 | 504 | } |
505 | 505 | |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | * @param string $file_path |
512 | 512 | * @return string |
513 | 513 | */ |
514 | - public static function standardise_directory_separators( $file_path ){ |
|
515 | - return str_replace( array( '\\', '/' ), DS, $file_path ); |
|
514 | + public static function standardise_directory_separators($file_path) { |
|
515 | + return str_replace(array('\\', '/'), DS, $file_path); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | * @param string $file_path |
524 | 524 | * @return string |
525 | 525 | */ |
526 | - public static function end_with_directory_separator( $file_path ){ |
|
527 | - return rtrim( $file_path, '/\\' ) . DS; |
|
526 | + public static function end_with_directory_separator($file_path) { |
|
527 | + return rtrim($file_path, '/\\').DS; |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | * @param $file_path |
535 | 535 | * @return string |
536 | 536 | */ |
537 | - public static function standardise_and_end_with_directory_separator( $file_path ){ |
|
538 | - return self::end_with_directory_separator( self::standardise_directory_separators( $file_path )); |
|
537 | + public static function standardise_and_end_with_directory_separator($file_path) { |
|
538 | + return self::end_with_directory_separator(self::standardise_directory_separators($file_path)); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | |
@@ -552,21 +552,21 @@ discard block |
||
552 | 552 | * if $index_numerically == FALSE (Default) keys are what the class names SHOULD be; |
553 | 553 | * and values are their filepaths |
554 | 554 | */ |
555 | - public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){ |
|
555 | + public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) { |
|
556 | 556 | $class_to_folder_path = array(); |
557 | - foreach( $folder_paths as $folder_path ){ |
|
558 | - $folder_path = self::standardise_and_end_with_directory_separator( $folder_path ); |
|
557 | + foreach ($folder_paths as $folder_path) { |
|
558 | + $folder_path = self::standardise_and_end_with_directory_separator($folder_path); |
|
559 | 559 | // load WP_Filesystem and set file permissions |
560 | - $files_in_folder = glob( $folder_path . '*' ); |
|
560 | + $files_in_folder = glob($folder_path.'*'); |
|
561 | 561 | $class_to_folder_path = array(); |
562 | - if ( $files_in_folder ) { |
|
563 | - foreach( $files_in_folder as $file_path ){ |
|
562 | + if ($files_in_folder) { |
|
563 | + foreach ($files_in_folder as $file_path) { |
|
564 | 564 | //only add files, not folders |
565 | - if ( ! is_dir( $file_path )) { |
|
566 | - if ( $index_numerically ) { |
|
565 | + if ( ! is_dir($file_path)) { |
|
566 | + if ($index_numerically) { |
|
567 | 567 | $class_to_folder_path[] = $file_path; |
568 | 568 | } else { |
569 | - $classname = self::get_classname_from_filepath_with_standard_filename( $file_path ); |
|
569 | + $classname = self::get_classname_from_filepath_with_standard_filename($file_path); |
|
570 | 570 | $class_to_folder_path[$classname] = $file_path; |
571 | 571 | } |
572 | 572 | } |
@@ -586,39 +586,39 @@ discard block |
||
586 | 586 | * @return boolean success |
587 | 587 | * @throws EE_Error |
588 | 588 | */ |
589 | - public static function copy( $source_file, $destination_file, $overwrite = FALSE ){ |
|
590 | - $full_source_path = EEH_File::standardise_directory_separators( $source_file ); |
|
591 | - if( ! EEH_File::exists( $full_source_path ) ){ |
|
592 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
593 | - $msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path ); |
|
594 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path ); |
|
595 | - throw new EE_Error( $msg ); |
|
589 | + public static function copy($source_file, $destination_file, $overwrite = FALSE) { |
|
590 | + $full_source_path = EEH_File::standardise_directory_separators($source_file); |
|
591 | + if ( ! EEH_File::exists($full_source_path)) { |
|
592 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
593 | + $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path); |
|
594 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path); |
|
595 | + throw new EE_Error($msg); |
|
596 | 596 | } |
597 | 597 | return FALSE; |
598 | 598 | } |
599 | 599 | |
600 | - $full_dest_path = EEH_File::standardise_directory_separators( $destination_file ); |
|
601 | - $folder = EEH_File::remove_filename_from_filepath( $full_dest_path ); |
|
602 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
603 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
604 | - $msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path ); |
|
605 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path ); |
|
606 | - throw new EE_Error( $msg ); |
|
600 | + $full_dest_path = EEH_File::standardise_directory_separators($destination_file); |
|
601 | + $folder = EEH_File::remove_filename_from_filepath($full_dest_path); |
|
602 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
603 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
604 | + $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path); |
|
605 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path); |
|
606 | + throw new EE_Error($msg); |
|
607 | 607 | } |
608 | 608 | return FALSE; |
609 | 609 | } |
610 | 610 | |
611 | 611 | // load WP_Filesystem and set file permissions |
612 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file ); |
|
612 | + $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file); |
|
613 | 613 | // write the file |
614 | 614 | if ( ! $wp_filesystem->copy( |
615 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), |
|
616 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), |
|
615 | + EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), |
|
616 | + EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), |
|
617 | 617 | $overwrite )) { |
618 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
619 | - $msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path ); |
|
620 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' ); |
|
621 | - throw new EE_Error( $msg ); |
|
618 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
619 | + $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path); |
|
620 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f'); |
|
621 | + throw new EE_Error($msg); |
|
622 | 622 | } |
623 | 623 | return FALSE; |
624 | 624 | } |
@@ -630,9 +630,9 @@ discard block |
||
630 | 630 | * @param string $filepath |
631 | 631 | * @return boolean |
632 | 632 | */ |
633 | - public static function is_in_uploads_folder( $filepath ) { |
|
633 | + public static function is_in_uploads_folder($filepath) { |
|
634 | 634 | $uploads = wp_upload_dir(); |
635 | - return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false; |
|
635 | + return strpos($filepath, $uploads['basedir']) === 0 ? true : false; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
647 | 647 | * ftp or ssh, will use to access the folder |
648 | 648 | */ |
649 | - public static function convert_local_filepath_to_remote_filepath( $local_filepath ) { |
|
650 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath ); |
|
651 | - return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath ); |
|
649 | + public static function convert_local_filepath_to_remote_filepath($local_filepath) { |
|
650 | + $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath); |
|
651 | + return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath); |
|
652 | 652 | } |
653 | 653 | } |
654 | 654 | // End of file EEH_File.helper.php |
@@ -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 | /** |
@@ -32,30 +32,30 @@ discard block |
||
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - public function __construct( $routing = TRUE ) { |
|
36 | - parent::__construct( $routing ); |
|
37 | - define( 'GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/' ); |
|
35 | + public function __construct($routing = TRUE) { |
|
36 | + parent::__construct($routing); |
|
37 | + define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'general_settings/templates/'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | 42 | protected function _extend_page_config() { |
43 | 43 | |
44 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings'; |
|
44 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'general_settings'; |
|
45 | 45 | |
46 | 46 | //filters and action hooks here |
47 | - add_action('AHEE__admin_option_settings__template__before', array( $this, 'use_venue_and_staff_manager_settings'), 10 ); |
|
48 | - add_action( 'AHEE__admin_option_settings__template__before', array( $this, 'debug_logging_options' ), 9 ); |
|
49 | - add_filter( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', array( $this, 'update_debug_logging_options' ), 10, 1 ); |
|
47 | + add_action('AHEE__admin_option_settings__template__before', array($this, 'use_venue_and_staff_manager_settings'), 10); |
|
48 | + add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9); |
|
49 | + add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', array($this, 'update_debug_logging_options'), 10, 1); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - public function use_venue_and_staff_manager_settings( $template_args ) { |
|
56 | - $_args['use_personnel_manager_select'] = EEH_Form_Fields::select_input('use_personnel_manager', $template_args['values'], $template_args['use_personnel_manager'] ); |
|
57 | - $template = GEN_SET_CAF_TEMPLATE_PATH . 'use_venue_and_staff_manager_settings.template.php'; |
|
58 | - EEH_Template::display_template( $template, $_args ); |
|
55 | + public function use_venue_and_staff_manager_settings($template_args) { |
|
56 | + $_args['use_personnel_manager_select'] = EEH_Form_Fields::select_input('use_personnel_manager', $template_args['values'], $template_args['use_personnel_manager']); |
|
57 | + $template = GEN_SET_CAF_TEMPLATE_PATH.'use_venue_and_staff_manager_settings.template.php'; |
|
58 | + EEH_Template::display_template($template, $_args); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param array $template_args |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public function debug_logging_options( $template_args = array() ) { |
|
71 | + public function debug_logging_options($template_args = array()) { |
|
72 | 72 | $template_args['use_full_logging'] = EE_Registry::instance()->CFG->admin->use_full_logging; |
73 | - $template_args['use_remote_logging'] = isset( EE_Registry::instance()->CFG->admin->use_remote_logging ) ? absint( EE_Registry::instance()->CFG->admin->use_remote_logging ) : FALSE; |
|
74 | - $template_args['remote_logging_url'] = isset( EE_Registry::instance()->CFG->admin->remote_logging_url ) && ! empty( EE_Registry::instance()->CFG->admin->remote_logging_url ) ? stripslashes( EE_Registry::instance()->CFG->admin->remote_logging_url ) : ''; |
|
75 | - $template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php'; |
|
76 | - EEH_Template::display_template( $template, $template_args ); |
|
73 | + $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : FALSE; |
|
74 | + $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : ''; |
|
75 | + $template = GEN_SET_CAF_TEMPLATE_PATH.'debug_log_settings.template.php'; |
|
76 | + EEH_Template::display_template($template, $template_args); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | * @param array $admin_options |
85 | 85 | * @return array |
86 | 86 | */ |
87 | - public function update_debug_logging_options( $admin_options = array() ) { |
|
88 | - $use_full_logging = isset( $this->_req_data['use_full_logging'] ) ? (bool)absint( $this->_req_data['use_full_logging'] ) : $admin_options->use_full_logging; |
|
87 | + public function update_debug_logging_options($admin_options = array()) { |
|
88 | + $use_full_logging = isset($this->_req_data['use_full_logging']) ? (bool) absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging; |
|
89 | 89 | $admin_options->use_full_logging = $use_full_logging; |
90 | 90 | |
91 | - if ( $use_full_logging === FALSE ) { |
|
92 | - EE_Error::get_notices( FALSE ); |
|
91 | + if ($use_full_logging === FALSE) { |
|
92 | + EE_Error::get_notices(FALSE); |
|
93 | 93 | EE_Error::reset_notices(); |
94 | 94 | } |
95 | 95 | |
96 | - $admin_options->use_remote_logging = isset( $this->_req_data['use_remote_logging'] ) ? absint( $this->_req_data['use_remote_logging'] ) : $admin_options->use_remote_logging; |
|
97 | - $admin_options->remote_logging_url = isset( $this->_req_data['remote_logging_url'] ) ? esc_url_raw( $this->_req_data['remote_logging_url'] ) : $admin_options->remote_logging_url; |
|
96 | + $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging; |
|
97 | + $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url; |
|
98 | 98 | return $admin_options; |
99 | 99 | } |
100 | 100 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.0 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEH_Debug_Tools{ |
|
11 | +class EEH_Debug_Tools { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
45 | 45 | self::$_instance = new self(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function __construct() { |
59 | 59 | // load Kint PHP debugging library |
60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
67 | 67 | } |
68 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
68 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
70 | 70 | } |
71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public static function show_db_name() { |
85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function espresso_session_footer_dump() { |
98 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
99 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
100 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
98 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
99 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
100 | + Kint::dump(EE_Registry::instance()->SSN); |
|
101 | 101 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
102 | 102 | $this->espresso_list_hooked_functions(); |
103 | 103 | $this->show_times(); |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | * @param bool $tag |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
117 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
118 | 118 | global $wp_filter; |
119 | 119 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
120 | - if ( $tag ) { |
|
121 | - $hook[$tag]=$wp_filter[$tag]; |
|
122 | - if ( ! is_array( $hook[$tag] )) { |
|
123 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
120 | + if ($tag) { |
|
121 | + $hook[$tag] = $wp_filter[$tag]; |
|
122 | + if ( ! is_array($hook[$tag])) { |
|
123 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
124 | 124 | return; |
125 | 125 | } |
126 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
126 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
127 | 127 | } |
128 | 128 | else { |
129 | - $hook=$wp_filter; |
|
130 | - ksort( $hook ); |
|
129 | + $hook = $wp_filter; |
|
130 | + ksort($hook); |
|
131 | 131 | } |
132 | - foreach( $hook as $tag => $priorities ) { |
|
132 | + foreach ($hook as $tag => $priorities) { |
|
133 | 133 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
134 | - ksort( $priorities ); |
|
135 | - foreach( $priorities as $priority => $function ){ |
|
134 | + ksort($priorities); |
|
135 | + foreach ($priorities as $priority => $function) { |
|
136 | 136 | echo $priority; |
137 | - foreach( $function as $name => $properties ) { |
|
137 | + foreach ($function as $name => $properties) { |
|
138 | 138 | echo "\t$name<br />"; |
139 | 139 | } |
140 | 140 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @param string $hook_name |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
153 | + public static function registered_filter_callbacks($hook_name = '') { |
|
154 | 154 | $filters = array(); |
155 | 155 | global $wp_filter; |
156 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
157 | - $filters[ $hook_name ] = array(); |
|
158 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
159 | - $filters[ $hook_name ][ $priority ] = array(); |
|
160 | - foreach ( $callbacks as $callback ) { |
|
161 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
156 | + if (isset($wp_filter[$hook_name])) { |
|
157 | + $filters[$hook_name] = array(); |
|
158 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
159 | + $filters[$hook_name][$priority] = array(); |
|
160 | + foreach ($callbacks as $callback) { |
|
161 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * start_timer |
172 | 172 | * @param null $timer_name |
173 | 173 | */ |
174 | - public function start_timer( $timer_name = NULL ){ |
|
175 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
174 | + public function start_timer($timer_name = NULL) { |
|
175 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * stop_timer |
182 | 182 | * @param string $timer_name |
183 | 183 | */ |
184 | - public function stop_timer($timer_name = 'default'){ |
|
185 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
186 | - $start_time = $this->_start_times[ $timer_name ]; |
|
187 | - unset( $this->_start_times[ $timer_name ] ); |
|
188 | - }else{ |
|
189 | - $start_time = array_pop( $this->_start_times ); |
|
184 | + public function stop_timer($timer_name = 'default') { |
|
185 | + if (isset($this->_start_times[$timer_name])) { |
|
186 | + $start_time = $this->_start_times[$timer_name]; |
|
187 | + unset($this->_start_times[$timer_name]); |
|
188 | + } else { |
|
189 | + $start_time = array_pop($this->_start_times); |
|
190 | 190 | } |
191 | - $total_time = microtime( TRUE ) - $start_time; |
|
192 | - switch ( $total_time ) { |
|
191 | + $total_time = microtime(TRUE) - $start_time; |
|
192 | + switch ($total_time) { |
|
193 | 193 | case $total_time < 0.00001 : |
194 | 194 | $color = '#8A549A'; |
195 | 195 | $bold = 'normal'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $bold = 'bold'; |
216 | 216 | break; |
217 | 217 | } |
218 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
218 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
219 | 219 | } |
220 | 220 | /** |
221 | 221 | * Measure the memory usage by PHP so far. |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function measure_memory( $label, $output_now = false ) { |
|
227 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
228 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
229 | - if( $output_now ) { |
|
226 | + public function measure_memory($label, $output_now = false) { |
|
227 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
228 | + $this->_memory_usage_points[$label] = $memory_used; |
|
229 | + if ($output_now) { |
|
230 | 230 | echo "\r\n<br>$label : $memory_used"; |
231 | 231 | } |
232 | 232 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param int $size |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function convert( $size ) { |
|
240 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
241 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ]; |
|
239 | + public function convert($size) { |
|
240 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
241 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param bool $output_now |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function show_times($output_now=true){ |
|
252 | - $output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points ); |
|
253 | - if($output_now){ |
|
251 | + public function show_times($output_now = true) { |
|
252 | + $output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points); |
|
253 | + if ($output_now) { |
|
254 | 254 | echo $output; |
255 | 255 | return ''; |
256 | 256 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | * @return void |
266 | 266 | */ |
267 | 267 | public static function ee_plugin_activation_errors() { |
268 | - if ( WP_DEBUG ) { |
|
268 | + if (WP_DEBUG) { |
|
269 | 269 | $activation_errors = ob_get_contents(); |
270 | - if ( ! empty( $activation_errors ) ) { |
|
271 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
270 | + if ( ! empty($activation_errors)) { |
|
271 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
272 | 272 | } |
273 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
274 | - if ( class_exists( 'EEH_File' )) { |
|
273 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
274 | + if (class_exists('EEH_File')) { |
|
275 | 275 | try { |
276 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
277 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
278 | - } catch( EE_Error $e ){ |
|
279 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
276 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
277 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
278 | + } catch (EE_Error $e) { |
|
279 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | // old school attempt |
283 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
283 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
284 | 284 | } |
285 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
286 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
285 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
286 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | * @param int $error_type |
300 | 300 | * @uses trigger_error() |
301 | 301 | */ |
302 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
303 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
305 | - trigger_error( sprintf( __('%1$s was called <strong>incorrectly</strong>. %2$s %3$s','event_espresso' ), $function, $message, $version ), $error_type ); |
|
302 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
303 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
305 | + trigger_error(sprintf(__('%1$s was called <strong>incorrectly</strong>. %2$s %3$s', 'event_espresso'), $function, $message, $version), $error_type); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -323,22 +323,22 @@ discard block |
||
323 | 323 | * @param string $debug_index |
324 | 324 | * @param string $debug_key |
325 | 325 | */ |
326 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
327 | - if ( WP_DEBUG && false ) { |
|
328 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
329 | - $debug_data = get_option( $debug_key, array() ); |
|
326 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
327 | + if (WP_DEBUG && false) { |
|
328 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
329 | + $debug_data = get_option($debug_key, array()); |
|
330 | 330 | $default_data = array( |
331 | - $class => $func . '() : ' . $line, |
|
331 | + $class => $func.'() : '.$line, |
|
332 | 332 | 'REQ' => $display_request ? $_REQUEST : '', |
333 | 333 | ); |
334 | 334 | // don't serialize objects |
335 | - $info = self::strip_objects( $info ); |
|
336 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
337 | - if ( ! isset( $debug_data[$index] ) ) { |
|
335 | + $info = self::strip_objects($info); |
|
336 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
337 | + if ( ! isset($debug_data[$index])) { |
|
338 | 338 | $debug_data[$index] = array(); |
339 | 339 | } |
340 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
341 | - update_option( $debug_key, $debug_data ); |
|
340 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
341 | + update_option($debug_key, $debug_data); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
@@ -350,26 +350,26 @@ discard block |
||
350 | 350 | * @param array $info |
351 | 351 | * @return array |
352 | 352 | */ |
353 | - public static function strip_objects( $info = array() ) { |
|
354 | - foreach ( $info as $key => $value ) { |
|
355 | - if ( is_array( $value ) ) { |
|
356 | - $info[ $key ] = self::strip_objects( $value ); |
|
357 | - } else if ( is_object( $value ) ) { |
|
358 | - $object_class = get_class( $value ); |
|
359 | - $info[ $object_class ] = array(); |
|
360 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
361 | - if ( method_exists( $value, 'ID' ) ) { |
|
362 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
353 | + public static function strip_objects($info = array()) { |
|
354 | + foreach ($info as $key => $value) { |
|
355 | + if (is_array($value)) { |
|
356 | + $info[$key] = self::strip_objects($value); |
|
357 | + } else if (is_object($value)) { |
|
358 | + $object_class = get_class($value); |
|
359 | + $info[$object_class] = array(); |
|
360 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
361 | + if (method_exists($value, 'ID')) { |
|
362 | + $info[$object_class]['ID'] = $value->ID(); |
|
363 | 363 | } |
364 | - if ( method_exists( $value, 'status' ) ) { |
|
365 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
366 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
367 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
364 | + if (method_exists($value, 'status')) { |
|
365 | + $info[$object_class]['status'] = $value->status(); |
|
366 | + } else if (method_exists($value, 'status_ID')) { |
|
367 | + $info[$object_class]['status'] = $value->status_ID(); |
|
368 | 368 | } |
369 | - unset( $info[ $key ] ); |
|
369 | + unset($info[$key]); |
|
370 | 370 | } |
371 | 371 | } |
372 | - return (array)$info; |
|
372 | + return (array) $info; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -386,31 +386,31 @@ discard block |
||
386 | 386 | * @param string $height |
387 | 387 | * @param bool $die |
388 | 388 | */ |
389 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false ) { |
|
389 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false) { |
|
390 | 390 | //$print_r = false; |
391 | - if ( is_object( $var ) ) { |
|
391 | + if (is_object($var)) { |
|
392 | 392 | $var_name = ! $var_name ? 'object' : $var_name; |
393 | 393 | //$print_r = true; |
394 | - } else if ( is_array( $var ) ) { |
|
394 | + } else if (is_array($var)) { |
|
395 | 395 | $var_name = ! $var_name ? 'array' : $var_name; |
396 | 396 | //$print_r = true; |
397 | - } else if ( is_numeric( $var ) ) { |
|
397 | + } else if (is_numeric($var)) { |
|
398 | 398 | $var_name = ! $var_name ? 'numeric' : $var_name; |
399 | - } else if ( is_string( $var ) ) { |
|
399 | + } else if (is_string($var)) { |
|
400 | 400 | $var_name = ! $var_name ? 'string' : $var_name; |
401 | - } else if ( is_null( $var ) ) { |
|
401 | + } else if (is_null($var)) { |
|
402 | 402 | $var_name = ! $var_name ? 'null' : $var_name; |
403 | 403 | } |
404 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
404 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
405 | 405 | ob_start(); |
406 | - echo '<pre style="display:block; width:100%; height:' . $height . '; border:2px solid light-blue;">'; |
|
407 | - echo '<h5 style="color:#2EA2CC;"><b>' . $var_name . '</b></h5><span style="color:#E76700">'; |
|
406 | + echo '<pre style="display:block; width:100%; height:'.$height.'; border:2px solid light-blue;">'; |
|
407 | + echo '<h5 style="color:#2EA2CC;"><b>'.$var_name.'</b></h5><span style="color:#E76700">'; |
|
408 | 408 | //$print_r ? print_r( $var ) : var_dump( $var ); |
409 | - var_dump( $var ); |
|
410 | - echo '</span><br /><span style="font-size:10px;font-weight:normal;">' . $file . '<br />line no: ' . $line . '</span></pre>'; |
|
409 | + var_dump($var); |
|
410 | + echo '</span><br /><span style="font-size:10px;font-weight:normal;">'.$file.'<br />line no: '.$line.'</span></pre>'; |
|
411 | 411 | $result = ob_get_clean(); |
412 | - if ( $die ) { |
|
413 | - die( $result ); |
|
412 | + if ($die) { |
|
413 | + die($result); |
|
414 | 414 | } else { |
415 | 415 | echo $result; |
416 | 416 | } |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * borrowed from Kint Debugger |
428 | 428 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
429 | 429 | */ |
430 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
431 | - function dump_wp_query(){ |
|
430 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
431 | + function dump_wp_query() { |
|
432 | 432 | global $wp_query; |
433 | 433 | d($wp_query); |
434 | 434 | } |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * borrowed from Kint Debugger |
439 | 439 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
440 | 440 | */ |
441 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
442 | - function dump_wp(){ |
|
441 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
442 | + function dump_wp() { |
|
443 | 443 | global $wp; |
444 | 444 | d($wp); |
445 | 445 | } |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * borrowed from Kint Debugger |
450 | 450 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
451 | 451 | */ |
452 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
453 | - function dump_post(){ |
|
452 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
453 | + function dump_post() { |
|
454 | 454 | global $post; |
455 | 455 | d($post); |
456 | 456 | } |
@@ -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 | /** |
@@ -30,25 +30,25 @@ discard block |
||
30 | 30 | class Extend_Events_Admin_Page extends Events_Admin_Page { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $routing = TRUE ) { |
|
34 | - parent::__construct( $routing ); |
|
35 | - define( 'EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
36 | - define( 'EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
37 | - define( 'EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
33 | + public function __construct($routing = TRUE) { |
|
34 | + parent::__construct($routing); |
|
35 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
36 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
37 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | protected function _extend_page_config() { |
42 | 42 | |
43 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
43 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
44 | 44 | $default_espresso_boxes = $this->_default_espresso_metaboxes; |
45 | 45 | |
46 | 46 | //is there a evt_id in the request? |
47 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
48 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
47 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
48 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
49 | 49 | |
50 | 50 | //tkt_id? |
51 | - $tkt_id = !empty( $this->_req_data['TKT_ID'] ) && ! is_array( $this->_req_data['TKT_ID'] ) ? $this->_req_data['TKT_ID'] : 0; |
|
51 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) ? $this->_req_data['TKT_ID'] : 0; |
|
52 | 52 | |
53 | 53 | $new_page_routes = array( |
54 | 54 | 'duplicate_event' => array( |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | 'capability' => 'ee_delete_default_ticket', |
67 | 67 | 'obj_id' => $tkt_id, |
68 | 68 | 'noheader' => TRUE, |
69 | - 'args' => array( 'trash' => TRUE ) |
|
69 | + 'args' => array('trash' => TRUE) |
|
70 | 70 | ), |
71 | 71 | 'trash_tickets' => array( |
72 | 72 | 'func' => '_trash_or_restore_ticket', |
73 | 73 | 'capability' => 'ee_delete_default_tickets', |
74 | 74 | 'noheader' => TRUE, |
75 | - 'args' => array( 'trash' => TRUE ) |
|
75 | + 'args' => array('trash' => TRUE) |
|
76 | 76 | ), |
77 | 77 | 'restore_ticket' => array( |
78 | 78 | 'func' => '_trash_or_restore_ticket', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ) |
133 | 133 | ); |
134 | 134 | |
135 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
135 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
136 | 136 | |
137 | 137 | |
138 | 138 | //partial route/config override |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
145 | 145 | |
146 | 146 | //add tickets tab but only if there are more than one default ticket! |
147 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array( array('TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ); |
|
148 | - if ( $tkt_count > 1 ) { |
|
147 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE); |
|
148 | + if ($tkt_count > 1) { |
|
149 | 149 | $new_page_config = array( |
150 | 150 | 'ticket_list_table' => array( |
151 | 151 | 'nav' => array( |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | 'label' => __('Templates'), |
165 | 165 | 'order' => 30 |
166 | 166 | ), |
167 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
167 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
168 | 168 | 'help_tabs' => array( |
169 | 169 | 'general_settings_templates_help_tab' => array( |
170 | 170 | 'title' => __('Templates', 'event_espresso'), |
171 | 171 | 'filename' => 'general_settings_templates' |
172 | 172 | ) |
173 | 173 | ), |
174 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
174 | + 'help_tour' => array('Templates_Help_Tour'), |
|
175 | 175 | 'require_nonce' => FALSE |
176 | 176 | ); |
177 | 177 | |
@@ -190,26 +190,26 @@ discard block |
||
190 | 190 | // 'metaboxes' => $default_espresso_boxes, |
191 | 191 | // 'require_nonce' => FALSE |
192 | 192 | // ); |
193 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
193 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
194 | 194 | |
195 | 195 | //add filters and actions |
196 | 196 | //modifying _views |
197 | - add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array( $this, 'add_additional_datetime_button' ), 10, 2 ); |
|
198 | - add_filter('FHEE_event_datetime_metabox_clone_button_template', array( $this, 'add_datetime_clone_button' ), 10, 2 ); |
|
199 | - add_filter('FHEE_event_datetime_metabox_timezones_template', array( $this, 'datetime_timezones_template'), 10, 2 ); |
|
197 | + add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array($this, 'add_additional_datetime_button'), 10, 2); |
|
198 | + add_filter('FHEE_event_datetime_metabox_clone_button_template', array($this, 'add_datetime_clone_button'), 10, 2); |
|
199 | + add_filter('FHEE_event_datetime_metabox_timezones_template', array($this, 'datetime_timezones_template'), 10, 2); |
|
200 | 200 | |
201 | 201 | |
202 | 202 | //filters for event list table |
203 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array( $this, 'list_table_filters'), 10, 2); |
|
204 | - add_filter('FHEE__Extend_Events_Admin_List_Table__column_actions__action_links', array( $this, 'extra_list_table_actions'), 10, 2 ); |
|
203 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
204 | + add_filter('FHEE__Extend_Events_Admin_List_Table__column_actions__action_links', array($this, 'extra_list_table_actions'), 10, 2); |
|
205 | 205 | |
206 | 206 | //legend item |
207 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array( $this, 'additional_legend_items') ); |
|
207 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
208 | 208 | |
209 | - add_action('admin_init', array( $this, 'admin_init') ); |
|
209 | + add_action('admin_init', array($this, 'admin_init')); |
|
210 | 210 | |
211 | 211 | //heartbeat stuff |
212 | - add_filter( 'heartbeat_received', array( $this, 'heartbeat_response' ), 10, 2 ); |
|
212 | + add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | EE_Registry::$i18n_js_strings = array_merge( |
223 | 223 | EE_Registry::$i18n_js_strings, |
224 | 224 | array( |
225 | - 'image_confirm' => __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ), |
|
226 | - 'event_starts_on' => __( 'Event Starts on', 'event_espresso' ), |
|
227 | - 'event_ends_on' => __( 'Event Ends on', 'event_espresso' ), |
|
228 | - 'event_datetime_actions' => __( 'Actions', 'event_espresso' ), |
|
229 | - 'event_clone_dt_msg' => __( 'Clone this Event Date and Time', 'event_espresso' ), |
|
230 | - 'remove_event_dt_msg' => __( 'Remove this Event Time', 'event_espresso' ) |
|
225 | + 'image_confirm' => __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'), |
|
226 | + 'event_starts_on' => __('Event Starts on', 'event_espresso'), |
|
227 | + 'event_ends_on' => __('Event Ends on', 'event_espresso'), |
|
228 | + 'event_datetime_actions' => __('Actions', 'event_espresso'), |
|
229 | + 'event_clone_dt_msg' => __('Clone this Event Date and Time', 'event_espresso'), |
|
230 | + 'remove_event_dt_msg' => __('Remove this Event Time', 'event_espresso') |
|
231 | 231 | ) |
232 | 232 | ); |
233 | 233 | } |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return array possibly appended response. |
244 | 244 | */ |
245 | - public function heartbeat_response( $response, $data ) { |
|
245 | + public function heartbeat_response($response, $data) { |
|
246 | 246 | /** |
247 | 247 | * check whether count of tickets is approaching the potential |
248 | 248 | * limits for the server. |
249 | 249 | */ |
250 | - if ( ! empty( $data['input_count'] ) ) { |
|
250 | + if ( ! empty($data['input_count'])) { |
|
251 | 251 | $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check($data['input_count']); |
252 | 252 | } |
253 | 253 | |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | |
263 | 263 | |
264 | 264 | |
265 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
266 | - $return = parent::extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ); |
|
265 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
266 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
267 | 267 | //make sure this is only when editing |
268 | - if ( !empty( $id ) ) { |
|
269 | - $href = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url ); |
|
268 | + if ( ! empty($id)) { |
|
269 | + $href = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url); |
|
270 | 270 | $title = esc_attr__('Duplicate Event', 'event_espresso'); |
271 | - $return .= '<a href="' . $href . '" title="' . $title . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' . $title . '</button>'; |
|
271 | + $return .= '<a href="'.$href.'" title="'.$title.'" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">'.$title.'</button>'; |
|
272 | 272 | } |
273 | 273 | return $return; |
274 | 274 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | 'label' => __('Trash', 'event_espresso'), |
292 | 292 | 'count' => 0, |
293 | 293 | 'bulk_action' => array( |
294 | - 'restore_tickets' => __('Restore from Trash' , 'event_espresso'), |
|
294 | + 'restore_tickets' => __('Restore from Trash', 'event_espresso'), |
|
295 | 295 | 'delete_tickets' => __('Delete Permanently', 'event_espresso') |
296 | 296 | ) |
297 | 297 | ) |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | |
303 | 303 | public function load_scripts_styles_edit() { |
304 | - wp_register_script( 'ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', array( 'ee_admin_js', 'heartbeat' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
304 | + wp_register_script('ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', array('ee_admin_js', 'heartbeat'), EVENT_ESPRESSO_VERSION, TRUE); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * load accounting js. |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | - public function add_additional_datetime_button( $template, $template_args ) { |
|
324 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', $template_args, TRUE); |
|
323 | + public function add_additional_datetime_button($template, $template_args) { |
|
324 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', $template_args, TRUE); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
328 | 328 | |
329 | - public function add_datetime_clone_button( $template, $template_args ) { |
|
330 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', $template_args, TRUE ); |
|
329 | + public function add_datetime_clone_button($template, $template_args) { |
|
330 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', $template_args, TRUE); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
334 | 334 | |
335 | - public function datetime_timezones_template( $template, $template_args ) { |
|
336 | - return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', $template_args, TRUE ); |
|
335 | + public function datetime_timezones_template($template, $template_args) { |
|
336 | + return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', $template_args, TRUE); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | protected function _set_list_table_views_default() { |
343 | 343 | parent::_set_list_table_views_default(); |
344 | 344 | $export_label = __('Export Events', 'event_espresso'); |
345 | - if ( EE_Registry::instance()->CAP->current_user_can( 'export', 'espresso_events_export' ) ) { |
|
345 | + if (EE_Registry::instance()->CAP->current_user_can('export', 'espresso_events_export')) { |
|
346 | 346 | // $this->_views['all']['bulk_action']['export_events'] = $export_label; |
347 | 347 | // $this->_views['draft']['bulk_action']['export_events'] = $export_label; |
348 | 348 | |
349 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
349 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
350 | 350 | // $this->_views['trash']['bulk_action']['export_events'] = $export_label; |
351 | 351 | } |
352 | 352 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | ) |
373 | 373 | ); |
374 | 374 | |
375 | - $this->_views = array_merge( $this->_views, $new_views); |
|
375 | + $this->_views = array_merge($this->_views, $new_views); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | |
387 | 387 | |
388 | 388 | |
389 | - public function extra_list_table_actions( $actionlinks, $event ) { |
|
390 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports', $event->ID() ) ) { |
|
389 | + public function extra_list_table_actions($actionlinks, $event) { |
|
390 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports', $event->ID())) { |
|
391 | 391 | $reports_query_args = array( |
392 | 392 | 'action' => 'reports', |
393 | 393 | 'EVT_ID' => $event->ID() |
394 | 394 | ); |
395 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce( $reports_query_args, REG_ADMIN_URL ); |
|
396 | - $actionlinks[] = '<a href="' . $reports_link . '" title="' . esc_attr__('View Report', 'event_espresso') . '"><div class="dashicons dashicons-chart-bar"></div></a>' . "\n\t"; |
|
395 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
396 | + $actionlinks[] = '<a href="'.$reports_link.'" title="'.esc_attr__('View Report', 'event_espresso').'"><div class="dashicons dashicons-chart-bar"></div></a>'."\n\t"; |
|
397 | 397 | } |
398 | 398 | return $actionlinks; |
399 | 399 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | |
402 | 402 | |
403 | 403 | public function additional_legend_items($items) { |
404 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports' ) ) { |
|
404 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports')) { |
|
405 | 405 | $items['reports'] = array( |
406 | 406 | 'class' => 'dashicons dashicons-chart-bar', |
407 | 407 | 'desc' => __('Event Reports', 'event_espresso') |
@@ -426,17 +426,17 @@ discard block |
||
426 | 426 | */ |
427 | 427 | protected function _duplicate_event() { |
428 | 428 | //first make sure the ID for the event is in the request. If it isnt' then we need to bail and redirect back to overview list table (cause how did we get here?) |
429 | - if ( !isset( $this->_req_data['EVT_ID'] ) ) { |
|
430 | - EE_Error::add_error( __('In order to duplicate an event an Event ID is required. None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
431 | - $this->_redirect_after_action( FALSE, '', '', array(), TRUE ); |
|
429 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
430 | + EE_Error::add_error(__('In order to duplicate an event an Event ID is required. None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
431 | + $this->_redirect_after_action(FALSE, '', '', array(), TRUE); |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | //k we've got EVT_ID so let's use that to get the event we'll duplicate |
436 | - $orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] ); |
|
436 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
437 | 437 | |
438 | - if ( ! $orig_event instanceof EE_Event ) |
|
439 | - throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'] ) ); |
|
438 | + if ( ! $orig_event instanceof EE_Event) |
|
439 | + throw new EE_Error(sprintf(__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'])); |
|
440 | 440 | |
441 | 441 | //k now let's clone the $orig_event before getting relations |
442 | 442 | $new_event = clone $orig_event; |
@@ -449,43 +449,43 @@ discard block |
||
449 | 449 | |
450 | 450 | |
451 | 451 | //reset the ID and modify other details to make it clear this is a dupe |
452 | - $new_event->set( 'EVT_ID', 0 ); |
|
453 | - $new_name = $new_event->name() . ' ' . __('**DUPLICATE**', 'event_espresso'); |
|
454 | - $new_event->set( 'EVT_name', $new_name ); |
|
455 | - $new_event->set( 'EVT_slug', wp_unique_post_slug( sanitize_title( $orig_event->name() ), 0, 'publish', 'espresso_events', 0 ) ); |
|
456 | - $new_event->set( 'status', 'draft' ); |
|
452 | + $new_event->set('EVT_ID', 0); |
|
453 | + $new_name = $new_event->name().' '.__('**DUPLICATE**', 'event_espresso'); |
|
454 | + $new_event->set('EVT_name', $new_name); |
|
455 | + $new_event->set('EVT_slug', wp_unique_post_slug(sanitize_title($orig_event->name()), 0, 'publish', 'espresso_events', 0)); |
|
456 | + $new_event->set('status', 'draft'); |
|
457 | 457 | |
458 | 458 | //duplicate discussion settings |
459 | - $new_event->set( 'comment_status', $orig_event->get('comment_status') ); |
|
460 | - $new_event->set( 'ping_status', $orig_event->get( 'ping_status' ) ); |
|
459 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
460 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
461 | 461 | |
462 | 462 | //save the new event |
463 | 463 | $new_event->save(); |
464 | 464 | |
465 | 465 | //venues |
466 | - foreach( $orig_ven as $ven ) { |
|
467 | - $new_event->_add_relation_to( $ven, 'Venue' ); |
|
466 | + foreach ($orig_ven as $ven) { |
|
467 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
468 | 468 | } |
469 | 469 | $new_event->save(); |
470 | 470 | |
471 | 471 | |
472 | 472 | //now we need to get the question group relations and handle that |
473 | 473 | //first primary question groups |
474 | - $orig_primary_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 1 ) ) ); |
|
475 | - if ( !empty( $orig_primary_qgs ) ) { |
|
476 | - foreach ( $orig_primary_qgs as $id => $obj ) { |
|
477 | - if ( $obj instanceof EE_Question_Group ) { |
|
478 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 1 ) ); |
|
474 | + $orig_primary_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 1))); |
|
475 | + if ( ! empty($orig_primary_qgs)) { |
|
476 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
477 | + if ($obj instanceof EE_Question_Group) { |
|
478 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | 483 | //next additional attendee question groups |
484 | - $orig_additional_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 0 ) ) ); |
|
485 | - if ( !empty( $orig_additional_qgs ) ) { |
|
486 | - foreach ( $orig_additional_qgs as $id => $obj ) { |
|
487 | - if ( $obj instanceof EE_Question_Group ) { |
|
488 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 0 ) ); |
|
484 | + $orig_additional_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0))); |
|
485 | + if ( ! empty($orig_additional_qgs)) { |
|
486 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
487 | + if ($obj instanceof EE_Question_Group) { |
|
488 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
498 | 498 | $cloned_tickets = array(); |
499 | - foreach ( $orig_datetimes as $orig_dtt ) { |
|
499 | + foreach ($orig_datetimes as $orig_dtt) { |
|
500 | 500 | $new_dtt = clone $orig_dtt; |
501 | 501 | $orig_tkts = $orig_dtt->tickets(); |
502 | 502 | |
@@ -504,22 +504,22 @@ discard block |
||
504 | 504 | $new_dtt->set('DTT_ID', 0); |
505 | 505 | $new_dtt->set('DTT_sold', 0); |
506 | 506 | $new_dtt->save(); |
507 | - $new_event->_add_relation_to( $new_dtt, 'Datetime'); |
|
507 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
508 | 508 | $new_event->save(); |
509 | 509 | |
510 | 510 | //now let's get the ticket relations setup. |
511 | - foreach ( (array) $orig_tkts as $orig_tkt ) { |
|
511 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
512 | 512 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
513 | - if ( ! $orig_tkt instanceof EE_Ticket ) |
|
513 | + if ( ! $orig_tkt instanceof EE_Ticket) |
|
514 | 514 | continue; |
515 | 515 | |
516 | 516 | //is this ticket archived? If it is then let's skip |
517 | - if ( $orig_tkt->get( 'TKT_deleted' ) ) { |
|
517 | + if ($orig_tkt->get('TKT_deleted')) { |
|
518 | 518 | continue; |
519 | 519 | } |
520 | 520 | |
521 | 521 | //does this original ticket already exist in the clone_tickets cache? If so we'll just use the new ticket from it. |
522 | - if ( isset( $cloned_tickets[$orig_tkt->ID()] ) ) { |
|
522 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
523 | 523 | $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
524 | 524 | } else { |
525 | 525 | $new_tkt = clone $orig_tkt; |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | $new_tkt->save(); //make sure new ticket has ID. |
532 | 532 | |
533 | 533 | //price relations on new ticket need to be setup. |
534 | - foreach ( $orig_prices as $orig_price ) { |
|
534 | + foreach ($orig_prices as $orig_price) { |
|
535 | 535 | $new_price = clone $orig_price; |
536 | 536 | $new_price->set('PRC_ID', 0); |
537 | 537 | $new_price->save(); |
@@ -548,39 +548,39 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | //clone taxonomy information |
551 | - $taxonomies_to_clone_with = apply_filters( 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array( 'espresso_event_categories', 'espresso_event_type', 'post_tag' ) ); |
|
551 | + $taxonomies_to_clone_with = apply_filters('FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array('espresso_event_categories', 'espresso_event_type', 'post_tag')); |
|
552 | 552 | |
553 | 553 | //get terms for original event (notice) |
554 | - $orig_terms = wp_get_object_terms( $orig_event->ID(), $taxonomies_to_clone_with ); |
|
554 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
555 | 555 | |
556 | 556 | //loop through terms and add them to new event. |
557 | - foreach ( $orig_terms as $term ) { |
|
558 | - wp_set_object_terms( $new_event->ID(), $term->term_id, $term->taxonomy, true ); |
|
557 | + foreach ($orig_terms as $term) { |
|
558 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | |
562 | - do_action( 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event ); |
|
562 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
563 | 563 | |
564 | 564 | //now let's redirect to the edit page for this duplicated event if we have a new event id. |
565 | - if ( $new_event->ID() ) { |
|
565 | + if ($new_event->ID()) { |
|
566 | 566 | $redirect_args = array( |
567 | 567 | 'post' => $new_event->ID(), |
568 | 568 | 'action' => 'edit' |
569 | 569 | ); |
570 | - EE_Error::add_success( __('Event successfully duplicated. Please review the details below and make any necessary edits', 'event_espresso') ); |
|
570 | + EE_Error::add_success(__('Event successfully duplicated. Please review the details below and make any necessary edits', 'event_espresso')); |
|
571 | 571 | } else { |
572 | 572 | $redirect_args = array( |
573 | 573 | 'action' => 'default' |
574 | 574 | ); |
575 | - EE_Error::add_error( __('Not able to duplicate event. Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
575 | + EE_Error::add_error(__('Not able to duplicate event. Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
576 | 576 | } |
577 | 577 | |
578 | - $this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE ); |
|
578 | + $this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
582 | 582 | |
583 | - protected function _import_page(){ |
|
583 | + protected function _import_page() { |
|
584 | 584 | |
585 | 585 | $title = __('Import', 'event_espresso'); |
586 | 586 | $intro = __('If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', 'event_espresso'); |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | $action = 'import_events'; |
589 | 589 | $type = 'csv'; |
590 | 590 | $this->_template_args['form'] = EE_Import::instance()->upload_form($title, $intro, $form_url, $action, $type); |
591 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'),$this->_admin_base_url); |
|
592 | - $content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',$this->_template_args,true); |
|
591 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'), $this->_admin_base_url); |
|
592 | + $content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', $this->_template_args, true); |
|
593 | 593 | |
594 | 594 | |
595 | 595 | $this->_template_args['admin_page_content'] = $content; |
@@ -602,9 +602,9 @@ discard block |
||
602 | 602 | * @return string html |
603 | 603 | */ |
604 | 604 | protected function _import_events() { |
605 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
605 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
606 | 606 | $success = EE_Import::instance()->import(); |
607 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'),true); |
|
607 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
608 | 608 | |
609 | 609 | } |
610 | 610 | |
@@ -618,24 +618,24 @@ discard block |
||
618 | 618 | * @return file |
619 | 619 | */ |
620 | 620 | protected function _events_export() { |
621 | - if(isset($this->_req_data['EVT_ID'])){ |
|
621 | + if (isset($this->_req_data['EVT_ID'])) { |
|
622 | 622 | $event_ids = $this->_req_data['EVT_ID']; |
623 | - }elseif(isset($this->_req_data['EVT_IDs'])){ |
|
623 | + }elseif (isset($this->_req_data['EVT_IDs'])) { |
|
624 | 624 | $event_ids = $this->_req_data['EVT_IDs']; |
625 | - }else{ |
|
625 | + } else { |
|
626 | 626 | $event_ids = NULL; |
627 | 627 | } |
628 | 628 | //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
629 | 629 | $new_request_args = array( |
630 | 630 | 'export' => 'report', |
631 | 631 | 'action' => 'all_event_data', |
632 | - 'EVT_ID' => $event_ids , |
|
632 | + 'EVT_ID' => $event_ids, |
|
633 | 633 | ); |
634 | 634 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
635 | 635 | |
636 | - EE_Registry::instance()->load_helper( 'File' ); |
|
637 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
638 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
636 | + EE_Registry::instance()->load_helper('File'); |
|
637 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
638 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
639 | 639 | $EE_Export = EE_Export::instance($this->_req_data); |
640 | 640 | $EE_Export->export(); |
641 | 641 | } |
@@ -657,12 +657,12 @@ discard block |
||
657 | 657 | 'category_ids' => $this->_req_data['EVT_CAT_ID'] |
658 | 658 | ); |
659 | 659 | |
660 | - $this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
660 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
661 | 661 | |
662 | - EE_Registry::instance()->load_helper( 'File' ); |
|
663 | - if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) { |
|
664 | - require_once( EE_CLASSES . 'EE_Export.class.php'); |
|
665 | - $EE_Export = EE_Export::instance( $this->_req_data ); |
|
662 | + EE_Registry::instance()->load_helper('File'); |
|
663 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
664 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
665 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
666 | 666 | $EE_Export->export(); |
667 | 667 | } |
668 | 668 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | /** |
674 | 674 | * Creates a sample CSV file for importing |
675 | 675 | */ |
676 | - protected function _sample_export_file(){ |
|
676 | + protected function _sample_export_file() { |
|
677 | 677 | // require_once(EE_CLASSES . 'EE_Export.class.php'); |
678 | 678 | EE_Export::instance()->export_sample(); |
679 | 679 | } |
@@ -690,10 +690,10 @@ discard block |
||
690 | 690 | * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
691 | 691 | * from General_Settings_Admin_Page to here. |
692 | 692 | */ |
693 | - $this->_template_args = apply_filters( 'FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args ); |
|
694 | - $this->_set_add_edit_form_tags( 'update_template_settings' ); |
|
695 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
696 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', $this->_template_args, TRUE ); |
|
693 | + $this->_template_args = apply_filters('FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args); |
|
694 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
695 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
696 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', $this->_template_args, TRUE); |
|
697 | 697 | $this->display_admin_page_with_sidebar(); |
698 | 698 | } |
699 | 699 | |
@@ -705,24 +705,24 @@ discard block |
||
705 | 705 | * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
706 | 706 | * from General_Settings_Admin_Page to here. |
707 | 707 | */ |
708 | - EE_Registry::instance()->CFG->template_settings = apply_filters( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data ); |
|
708 | + EE_Registry::instance()->CFG->template_settings = apply_filters('FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data); |
|
709 | 709 | |
710 | 710 | |
711 | 711 | //update custom post type slugs and detect if we need to flush rewrite rules |
712 | 712 | $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
713 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty( $this->_req_data['event_cpt_slug'] ) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes( $this->_req_data['event_cpt_slug'] ); |
|
713 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
714 | 714 | |
715 | 715 | |
716 | 716 | $what = 'Template Settings'; |
717 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__ ); |
|
717 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__); |
|
718 | 718 | |
719 | 719 | |
720 | - if ( EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug ) { |
|
721 | - update_option( 'ee_flush_rewrite_rules', true ); |
|
720 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
721 | + update_option('ee_flush_rewrite_rules', true); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | |
725 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'template_settings' ) ); |
|
725 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
726 | 726 | |
727 | 727 | } |
728 | 728 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | |
741 | 741 | $this->verify_cpt_object(); |
742 | 742 | |
743 | - add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array( $this, 'registration_options_meta_box' ), $this->page_slug, 'side', 'core'); |
|
743 | + add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array($this, 'registration_options_meta_box'), $this->page_slug, 'side', 'core'); |
|
744 | 744 | //add_meta_box('espresso_event_types', __('Event Type', 'event_espresso'), array( $this, 'event_type_meta_box' ), $this->page_slug, 'side', 'default' ); //add this back in when the feature is ready. |
745 | 745 | |
746 | 746 | //todo feature in progress |
@@ -764,16 +764,16 @@ discard block |
||
764 | 764 | array('id' => true, 'text' => __('Yes', 'event_espresso')), |
765 | 765 | array('id' => false, 'text' => __('No', 'event_espresso')) |
766 | 766 | ); |
767 | - $default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete ), TRUE); |
|
767 | + $default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete), TRUE); |
|
768 | 768 | $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(FALSE); |
769 | 769 | $template_args['_event'] = $this->_cpt_model_obj; |
770 | 770 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
771 | 771 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
772 | 772 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
773 | 773 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
774 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status() ); |
|
775 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
776 | - $templatepath = EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
774 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
|
775 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
776 | + $templatepath = EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
777 | 777 | EEH_Template::display_template($templatepath, $template_args); |
778 | 778 | } |
779 | 779 | |
@@ -786,9 +786,9 @@ discard block |
||
786 | 786 | * @param array $box metabox args |
787 | 787 | * @return string metabox contents |
788 | 788 | */ |
789 | - public function event_type_meta_box( $post, $box ) { |
|
790 | - $template_args['radio_list'] = $this->wp_terms_radio($post->ID, array( 'taxonomy' => 'espresso_event_type' ) ); |
|
791 | - $template = EVENTS_CAF_TEMPLATE_PATH . 'event_type_metabox_contents.template.php'; |
|
789 | + public function event_type_meta_box($post, $box) { |
|
790 | + $template_args['radio_list'] = $this->wp_terms_radio($post->ID, array('taxonomy' => 'espresso_event_type')); |
|
791 | + $template = EVENTS_CAF_TEMPLATE_PATH.'event_type_metabox_contents.template.php'; |
|
792 | 792 | EEH_Template::display_template($template, $template_args); |
793 | 793 | } |
794 | 794 | |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | |
799 | 799 | |
800 | 800 | |
801 | - public function wp_terms_radio( $post_id = 0, $args = array() ) { |
|
801 | + public function wp_terms_radio($post_id = 0, $args = array()) { |
|
802 | 802 | $defaults = array( |
803 | 803 | 'descendants_and_self' => 0, |
804 | 804 | 'selected_cats' => false, |
@@ -807,11 +807,11 @@ discard block |
||
807 | 807 | 'taxonomy' => 'category', |
808 | 808 | 'checked_ontop' => true |
809 | 809 | ); |
810 | - $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); |
|
810 | + $args = apply_filters('wp_terms_checklist_args', $args, $post_id); |
|
811 | 811 | |
812 | - extract( wp_parse_args($args, $defaults), EXTR_SKIP ); |
|
812 | + extract(wp_parse_args($args, $defaults), EXTR_SKIP); |
|
813 | 813 | |
814 | - if ( empty($walker) || !is_a($walker, 'Walker') ) |
|
814 | + if (empty($walker) || ! is_a($walker, 'Walker')) |
|
815 | 815 | $walker = new Walker_Radio_Checklist; |
816 | 816 | |
817 | 817 | $descendants_and_self = (int) $descendants_and_self; |
@@ -819,37 +819,37 @@ discard block |
||
819 | 819 | $args = array('taxonomy' => $taxonomy); |
820 | 820 | |
821 | 821 | $tax = get_taxonomy($taxonomy); |
822 | - $args['disabled'] = !current_user_can($tax->cap->assign_terms); |
|
822 | + $args['disabled'] = ! current_user_can($tax->cap->assign_terms); |
|
823 | 823 | |
824 | - if ( is_array( $selected_cats ) ) |
|
824 | + if (is_array($selected_cats)) |
|
825 | 825 | $args['selected_cats'] = $selected_cats; |
826 | - elseif ( $post_id ) |
|
826 | + elseif ($post_id) |
|
827 | 827 | $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
828 | 828 | else |
829 | 829 | $args['selected_cats'] = array(); |
830 | 830 | |
831 | - if ( is_array( $popular_cats ) ) |
|
831 | + if (is_array($popular_cats)) |
|
832 | 832 | $args['popular_cats'] = $popular_cats; |
833 | 833 | else |
834 | - $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
834 | + $args['popular_cats'] = get_terms($taxonomy, array('fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false)); |
|
835 | 835 | |
836 | - if ( $descendants_and_self ) { |
|
837 | - $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); |
|
838 | - $self = get_term( $descendants_and_self, $taxonomy ); |
|
839 | - array_unshift( $categories, $self ); |
|
836 | + if ($descendants_and_self) { |
|
837 | + $categories = (array) get_terms($taxonomy, array('child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0)); |
|
838 | + $self = get_term($descendants_and_self, $taxonomy); |
|
839 | + array_unshift($categories, $self); |
|
840 | 840 | } else { |
841 | 841 | $categories = (array) get_terms($taxonomy, array('get' => 'all')); |
842 | 842 | } |
843 | 843 | |
844 | - if ( $checked_ontop ) { |
|
844 | + if ($checked_ontop) { |
|
845 | 845 | // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) |
846 | 846 | $checked_categories = array(); |
847 | - $keys = array_keys( $categories ); |
|
847 | + $keys = array_keys($categories); |
|
848 | 848 | |
849 | - foreach( $keys as $k ) { |
|
850 | - if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { |
|
849 | + foreach ($keys as $k) { |
|
850 | + if (in_array($categories[$k]->term_id, $args['selected_cats'])) { |
|
851 | 851 | $checked_categories[] = $categories[$k]; |
852 | - unset( $categories[$k] ); |
|
852 | + unset($categories[$k]); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -874,18 +874,18 @@ discard block |
||
874 | 874 | * @param array $list_table_obj the list table object |
875 | 875 | * @return array new filters |
876 | 876 | */ |
877 | - public function list_table_filters( $oldfilters, $list_table_obj ) { |
|
877 | + public function list_table_filters($oldfilters, $list_table_obj) { |
|
878 | 878 | $filters = array(); |
879 | 879 | |
880 | 880 | //first month/year filters |
881 | 881 | $filters[] = $this->espresso_event_months_dropdown(); |
882 | 882 | |
883 | 883 | |
884 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
884 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
885 | 885 | |
886 | 886 | //active status dropdown |
887 | - if ( $status !== 'draft' ) |
|
888 | - $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
887 | + if ($status !== 'draft') |
|
888 | + $filter[] = $this->active_status_dropdown(isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''); |
|
889 | 889 | |
890 | 890 | //category filter |
891 | 891 | $filters[] = $this->category_dropdown(); |
@@ -907,17 +907,17 @@ discard block |
||
907 | 907 | */ |
908 | 908 | public function espresso_event_months_dropdown() { |
909 | 909 | //what we need to do is get all PRIMARY datetimes for all events to filter on. Note we need to include any other filters that are set! |
910 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
910 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
911 | 911 | |
912 | 912 | //categories? |
913 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
913 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
914 | 914 | |
915 | 915 | //active status? |
916 | - $active_status = isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : NULL; |
|
916 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : NULL; |
|
917 | 917 | |
918 | 918 | $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
919 | 919 | |
920 | - return EEH_Form_Fields::generate_event_months_dropdown( $cur_date, $status, $category, $active_status ); |
|
920 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | |
@@ -928,12 +928,12 @@ discard block |
||
928 | 928 | * @param string $current_value whatever the ucrrent active status is |
929 | 929 | * @return string html dropdown. |
930 | 930 | */ |
931 | - public function active_status_dropdown( $current_value = '' ) { |
|
931 | + public function active_status_dropdown($current_value = '') { |
|
932 | 932 | $select_name = 'active_status'; |
933 | - $values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso') ); |
|
933 | + $values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso')); |
|
934 | 934 | $id = 'id="espresso-active-status-dropdown-filter"'; |
935 | 935 | $class = 'wide'; |
936 | - echo EEH_Form_Fields::select_input( $select_name, $values, $current_value, $id, $class ); |
|
936 | + echo EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | |
@@ -945,9 +945,9 @@ discard block |
||
945 | 945 | * @return string html |
946 | 946 | */ |
947 | 947 | public function category_dropdown() { |
948 | - $cur_cat = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1; |
|
948 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
949 | 949 | |
950 | - return EEH_Form_Fields::generate_event_category_dropdown( $cur_cat ); |
|
950 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | * @return int |
960 | 960 | */ |
961 | 961 | public function total_events_today() { |
962 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 00:00:00', 'Y-m-d H:i:s', 'UTC' ); |
|
963 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' ); |
|
962 | + $start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 00:00:00', 'Y-m-d H:i:s', 'UTC'); |
|
963 | + $end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 23:59:59', 'Y-m-d H:i:s', 'UTC'); |
|
964 | 964 | |
965 | 965 | $where = array( |
966 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) ) |
|
966 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)) |
|
967 | 967 | ); |
968 | 968 | |
969 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
969 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
970 | 970 | return $count; |
971 | 971 | } |
972 | 972 | |
@@ -981,14 +981,14 @@ discard block |
||
981 | 981 | $this_year_r = date('Y'); |
982 | 982 | $this_month_r = date('m'); |
983 | 983 | $days_this_month = date('t'); |
984 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-01 00:00:00', 'Y-m-d H:i:s', 'UTC' ); |
|
985 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' ); |
|
984 | + $start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-01 00:00:00', 'Y-m-d H:i:s', 'UTC'); |
|
985 | + $end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', 'Y-m-d H:i:s', 'UTC'); |
|
986 | 986 | |
987 | 987 | $where = array( |
988 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) ) |
|
988 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)) |
|
989 | 989 | ); |
990 | 990 | |
991 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
991 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
992 | 992 | return $count; |
993 | 993 | } |
994 | 994 | |
@@ -1005,53 +1005,53 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | |
1007 | 1007 | |
1008 | - public function get_default_tickets( $per_page = 10, $count = FALSE, $trashed = FALSE ) { |
|
1008 | + public function get_default_tickets($per_page = 10, $count = FALSE, $trashed = FALSE) { |
|
1009 | 1009 | |
1010 | - $orderby= empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1011 | - $order = empty( $this->_req_data['order'] ) ? 'ASC' : $this->_req_data['order']; |
|
1010 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1011 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1012 | 1012 | |
1013 | - switch ( $orderby ) { |
|
1013 | + switch ($orderby) { |
|
1014 | 1014 | case 'TKT_name' : |
1015 | - $orderby = array( 'TKT_name' => $order ); |
|
1015 | + $orderby = array('TKT_name' => $order); |
|
1016 | 1016 | break; |
1017 | 1017 | |
1018 | 1018 | case 'TKT_price' : |
1019 | - $orderby = array( 'TKT_price' => $order ); |
|
1019 | + $orderby = array('TKT_price' => $order); |
|
1020 | 1020 | break; |
1021 | 1021 | |
1022 | 1022 | case 'TKT_uses' : |
1023 | - $orderby = array( 'TKT_uses' => $order ); |
|
1023 | + $orderby = array('TKT_uses' => $order); |
|
1024 | 1024 | break; |
1025 | 1025 | |
1026 | 1026 | case 'TKT_min' : |
1027 | - $orderby = array( 'TKT_min' => $order ); |
|
1027 | + $orderby = array('TKT_min' => $order); |
|
1028 | 1028 | break; |
1029 | 1029 | |
1030 | 1030 | case 'TKT_max' : |
1031 | - $orderby = array( 'TKT_max' => $order ); |
|
1031 | + $orderby = array('TKT_max' => $order); |
|
1032 | 1032 | break; |
1033 | 1033 | |
1034 | 1034 | case 'TKT_qty' : |
1035 | - $orderby = array( 'TKT_qty' => $order ); |
|
1035 | + $orderby = array('TKT_qty' => $order); |
|
1036 | 1036 | break; |
1037 | 1037 | } |
1038 | 1038 | |
1039 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1040 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1039 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1040 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1041 | 1041 | |
1042 | 1042 | $_where = array( |
1043 | 1043 | 'TKT_is_default' => 1, |
1044 | 1044 | 'TKT_deleted' => $trashed |
1045 | 1045 | ); |
1046 | 1046 | |
1047 | - $offset = ($current_page-1)*$per_page; |
|
1048 | - $limit = array( $offset, $per_page ); |
|
1047 | + $offset = ($current_page - 1) * $per_page; |
|
1048 | + $limit = array($offset, $per_page); |
|
1049 | 1049 | |
1050 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1051 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1050 | + if (isset($this->_req_data['s'])) { |
|
1051 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1052 | 1052 | $_where['OR'] = array( |
1053 | - 'TKT_name' => array('LIKE',$sstr ), |
|
1054 | - 'TKT_description' => array('LIKE',$sstr ) |
|
1053 | + 'TKT_name' => array('LIKE', $sstr), |
|
1054 | + 'TKT_description' => array('LIKE', $sstr) |
|
1055 | 1055 | ); |
1056 | 1056 | } |
1057 | 1057 | |
@@ -1062,9 +1062,9 @@ discard block |
||
1062 | 1062 | 'group_by'=>'TKT_ID' |
1063 | 1063 | ); |
1064 | 1064 | |
1065 | - if($count){ |
|
1065 | + if ($count) { |
|
1066 | 1066 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
1067 | - }else{ |
|
1067 | + } else { |
|
1068 | 1068 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1074,35 +1074,35 @@ discard block |
||
1074 | 1074 | |
1075 | 1075 | |
1076 | 1076 | |
1077 | - protected function _trash_or_restore_ticket( $trash = FALSE ) { |
|
1077 | + protected function _trash_or_restore_ticket($trash = FALSE) { |
|
1078 | 1078 | $success = 1; |
1079 | 1079 | |
1080 | 1080 | $TKT = EEM_Ticket::instance(); |
1081 | 1081 | |
1082 | 1082 | //checkboxes? |
1083 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1083 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1084 | 1084 | //if array has more than one element then success message should be plural |
1085 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1085 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1086 | 1086 | |
1087 | 1087 | //cycle thru the boxes |
1088 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1089 | - if ( $trash ) { |
|
1090 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1088 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1089 | + if ($trash) { |
|
1090 | + if ( ! $TKT->delete_by_ID($TKT_ID)) |
|
1091 | 1091 | $success = 0; |
1092 | 1092 | } else { |
1093 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1093 | + if ( ! $TKT->restore_by_ID($TKT_ID)) |
|
1094 | 1094 | $success = 0; |
1095 | 1095 | } |
1096 | 1096 | } |
1097 | 1097 | } else { |
1098 | 1098 | //grab single id and trash |
1099 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1099 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1100 | 1100 | |
1101 | - if ( $trash ) { |
|
1102 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1101 | + if ($trash) { |
|
1102 | + if ( ! $TKT->delete_by_ID($TKT_ID)) |
|
1103 | 1103 | $success = 0; |
1104 | 1104 | } else { |
1105 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1105 | + if ( ! $TKT->restore_by_ID($TKT_ID)) |
|
1106 | 1106 | $success = 0; |
1107 | 1107 | } |
1108 | 1108 | } |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | 'action' => 'ticket_list_table', |
1113 | 1113 | 'status' => $trash ? '' : 'trashed' |
1114 | 1114 | ); |
1115 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1115 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | |
@@ -1125,21 +1125,21 @@ discard block |
||
1125 | 1125 | $TKT = EEM_Ticket::instance(); |
1126 | 1126 | |
1127 | 1127 | //checkboxes? |
1128 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1128 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1129 | 1129 | //if array has more than one element then success message should be plural |
1130 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1130 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1131 | 1131 | |
1132 | 1132 | //cycle thru the boxes |
1133 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1133 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1134 | 1134 | //delete |
1135 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1135 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1136 | 1136 | $success = 0; |
1137 | 1137 | } |
1138 | 1138 | } |
1139 | 1139 | } else { |
1140 | 1140 | //grab single id and trash |
1141 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1142 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1141 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1142 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1143 | 1143 | $success = 0; |
1144 | 1144 | } |
1145 | 1145 | } |
@@ -1151,16 +1151,16 @@ discard block |
||
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | //failsafe. If the default ticket count === 1 then we need to redirect to event overview. |
1154 | - if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) |
|
1154 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE)) |
|
1155 | 1155 | $query_args = array(); |
1156 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1156 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | |
1160 | 1160 | |
1161 | 1161 | |
1162 | - protected function _delete_the_ticket( $TKT_ID ) { |
|
1163 | - $tkt = EEM_Ticket::instance()->get_one_by_ID( $TKT_ID ); |
|
1162 | + protected function _delete_the_ticket($TKT_ID) { |
|
1163 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1164 | 1164 | $tkt->_remove_relations('Datetime'); |
1165 | 1165 | //delete all related prices first |
1166 | 1166 | $tkt->delete_related_permanently('Price'); |
@@ -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 |
@@ -435,8 +436,9 @@ discard block |
||
435 | 436 | //k we've got EVT_ID so let's use that to get the event we'll duplicate |
436 | 437 | $orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] ); |
437 | 438 | |
438 | - if ( ! $orig_event instanceof EE_Event ) |
|
439 | - throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'] ) ); |
|
439 | + if ( ! $orig_event instanceof EE_Event ) { |
|
440 | + throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'] ) ); |
|
441 | + } |
|
440 | 442 | |
441 | 443 | //k now let's clone the $orig_event before getting relations |
442 | 444 | $new_event = clone $orig_event; |
@@ -510,8 +512,9 @@ discard block |
||
510 | 512 | //now let's get the ticket relations setup. |
511 | 513 | foreach ( (array) $orig_tkts as $orig_tkt ) { |
512 | 514 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
513 | - if ( ! $orig_tkt instanceof EE_Ticket ) |
|
514 | - continue; |
|
515 | + if ( ! $orig_tkt instanceof EE_Ticket ) { |
|
516 | + continue; |
|
517 | + } |
|
515 | 518 | |
516 | 519 | //is this ticket archived? If it is then let's skip |
517 | 520 | if ( $orig_tkt->get( 'TKT_deleted' ) ) { |
@@ -620,9 +623,9 @@ discard block |
||
620 | 623 | protected function _events_export() { |
621 | 624 | if(isset($this->_req_data['EVT_ID'])){ |
622 | 625 | $event_ids = $this->_req_data['EVT_ID']; |
623 | - }elseif(isset($this->_req_data['EVT_IDs'])){ |
|
626 | + } elseif(isset($this->_req_data['EVT_IDs'])){ |
|
624 | 627 | $event_ids = $this->_req_data['EVT_IDs']; |
625 | - }else{ |
|
628 | + } else{ |
|
626 | 629 | $event_ids = NULL; |
627 | 630 | } |
628 | 631 | //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
@@ -811,8 +814,9 @@ discard block |
||
811 | 814 | |
812 | 815 | extract( wp_parse_args($args, $defaults), EXTR_SKIP ); |
813 | 816 | |
814 | - if ( empty($walker) || !is_a($walker, 'Walker') ) |
|
815 | - $walker = new Walker_Radio_Checklist; |
|
817 | + if ( empty($walker) || !is_a($walker, 'Walker') ) { |
|
818 | + $walker = new Walker_Radio_Checklist; |
|
819 | + } |
|
816 | 820 | |
817 | 821 | $descendants_and_self = (int) $descendants_and_self; |
818 | 822 | |
@@ -821,17 +825,19 @@ discard block |
||
821 | 825 | $tax = get_taxonomy($taxonomy); |
822 | 826 | $args['disabled'] = !current_user_can($tax->cap->assign_terms); |
823 | 827 | |
824 | - if ( is_array( $selected_cats ) ) |
|
825 | - $args['selected_cats'] = $selected_cats; |
|
826 | - elseif ( $post_id ) |
|
827 | - $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
|
828 | - else |
|
829 | - $args['selected_cats'] = array(); |
|
828 | + if ( is_array( $selected_cats ) ) { |
|
829 | + $args['selected_cats'] = $selected_cats; |
|
830 | + } elseif ( $post_id ) { |
|
831 | + $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
|
832 | + } else { |
|
833 | + $args['selected_cats'] = array(); |
|
834 | + } |
|
830 | 835 | |
831 | - if ( is_array( $popular_cats ) ) |
|
832 | - $args['popular_cats'] = $popular_cats; |
|
833 | - else |
|
834 | - $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
836 | + if ( is_array( $popular_cats ) ) { |
|
837 | + $args['popular_cats'] = $popular_cats; |
|
838 | + } else { |
|
839 | + $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
840 | + } |
|
835 | 841 | |
836 | 842 | if ( $descendants_and_self ) { |
837 | 843 | $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); |
@@ -884,8 +890,9 @@ discard block |
||
884 | 890 | $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
885 | 891 | |
886 | 892 | //active status dropdown |
887 | - if ( $status !== 'draft' ) |
|
888 | - $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
893 | + if ( $status !== 'draft' ) { |
|
894 | + $filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' ); |
|
895 | + } |
|
889 | 896 | |
890 | 897 | //category filter |
891 | 898 | $filters[] = $this->category_dropdown(); |
@@ -1064,7 +1071,7 @@ discard block |
||
1064 | 1071 | |
1065 | 1072 | if($count){ |
1066 | 1073 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
1067 | - }else{ |
|
1074 | + } else{ |
|
1068 | 1075 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
1069 | 1076 | } |
1070 | 1077 | |
@@ -1087,11 +1094,13 @@ discard block |
||
1087 | 1094 | //cycle thru the boxes |
1088 | 1095 | while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
1089 | 1096 | if ( $trash ) { |
1090 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1091 | - $success = 0; |
|
1097 | + if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1098 | + $success = 0; |
|
1099 | + } |
|
1092 | 1100 | } else { |
1093 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1094 | - $success = 0; |
|
1101 | + if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1102 | + $success = 0; |
|
1103 | + } |
|
1095 | 1104 | } |
1096 | 1105 | } |
1097 | 1106 | } else { |
@@ -1099,11 +1108,13 @@ discard block |
||
1099 | 1108 | $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
1100 | 1109 | |
1101 | 1110 | if ( $trash ) { |
1102 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) |
|
1103 | - $success = 0; |
|
1111 | + if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1112 | + $success = 0; |
|
1113 | + } |
|
1104 | 1114 | } else { |
1105 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) |
|
1106 | - $success = 0; |
|
1115 | + if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1116 | + $success = 0; |
|
1117 | + } |
|
1107 | 1118 | } |
1108 | 1119 | } |
1109 | 1120 | |
@@ -1151,8 +1162,9 @@ discard block |
||
1151 | 1162 | ); |
1152 | 1163 | |
1153 | 1164 | //failsafe. If the default ticket count === 1 then we need to redirect to event overview. |
1154 | - if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) |
|
1155 | - $query_args = array(); |
|
1165 | + if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) ) { |
|
1166 | + $query_args = array(); |
|
1167 | + } |
|
1156 | 1168 | $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
1157 | 1169 | } |
1158 | 1170 |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | * } |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public static function register( $config_class = NULL, $setup_args = array() ) { |
|
45 | + public static function register($config_class = NULL, $setup_args = array()) { |
|
46 | 46 | |
47 | - $setup_args['config_name'] = isset( $setup_args['config_name'] ) && ! empty( $setup_args['config_name'] ) ? $setup_args['config_name'] : $config_class; |
|
48 | - $setup_args['config_section'] = isset( $setup_args['config_section'] ) && ! empty( $setup_args['config_section'] ) ? $setup_args['config_section'] : 'addons'; |
|
47 | + $setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) ? $setup_args['config_name'] : $config_class; |
|
48 | + $setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) ? $setup_args['config_section'] : 'addons'; |
|
49 | 49 | |
50 | 50 | //required fields MUST be present, so let's make sure they are. |
51 | - if ( empty( $config_class ) || ! is_array( $setup_args ) || empty( $setup_args['config_name'] )) { |
|
52 | - throw new EE_Error( __( 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso' )); |
|
51 | + if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) { |
|
52 | + throw new EE_Error(__('In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //make sure we don't register twice |
56 | - if( isset( self::$_ee_config_registry[ $config_class ] ) ){ |
|
56 | + if (isset(self::$_ee_config_registry[$config_class])) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | //first find out if this happened too late. |
62 | - if ( did_action( 'AHEE__EE_System__load_core_configuration__begin' ) ) { |
|
62 | + if (did_action('AHEE__EE_System__load_core_configuration__begin')) { |
|
63 | 63 | EE_Error::doing_it_wrong( |
64 | 64 | __METHOD__, |
65 | 65 | sprintf( |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | ); |
71 | 71 | } |
72 | 72 | //add incoming stuff to our registry property |
73 | - self::$_ee_config_registry[ $config_class ] = array( |
|
73 | + self::$_ee_config_registry[$config_class] = array( |
|
74 | 74 | 'section' => $setup_args['config_section'], |
75 | 75 | 'name' => $setup_args['config_name'] |
76 | 76 | ); |
77 | 77 | |
78 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
79 | - add_action( 'AHEE__EE_Config__update_espresso_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
78 | + add_action('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
79 | + add_action('AHEE__EE_Config__update_espresso_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * @param \EE_Config $EE_Config |
91 | 91 | * @return \StdClass |
92 | 92 | */ |
93 | - public static function set_config( EE_Config $EE_Config ) { |
|
94 | - foreach ( self::$_ee_config_registry as $config_class => $settings ) { |
|
93 | + public static function set_config(EE_Config $EE_Config) { |
|
94 | + foreach (self::$_ee_config_registry as $config_class => $settings) { |
|
95 | 95 | //first some validation of our incoming class_name. We'll throw an error early if its' not registered correctly |
96 | - if ( ! class_exists( $config_class )) { |
|
96 | + if ( ! class_exists($config_class)) { |
|
97 | 97 | throw new EE_Error( |
98 | 98 | sprintf( |
99 | - __( 'The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso' ), |
|
99 | + __('The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso'), |
|
100 | 100 | $config_class |
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | } |
104 | - $EE_Config->get_config( $settings['section'], $settings['name'], $config_class ); |
|
104 | + $EE_Config->get_config($settings['section'], $settings['name'], $config_class); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * @param mixed $config_class_name |
113 | 113 | */ |
114 | - public static function deregister( $config_class_name = NULL ) { |
|
115 | - if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
|
116 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
114 | + public static function deregister($config_class_name = NULL) { |
|
115 | + if ( ! empty(self::$_ee_config_registry[$config_class_name])) |
|
116 | + unset(self::$_ee_config_registry[$config_class_name]); |
|
117 | 117 | } |
118 | 118 | } |
@@ -113,6 +113,6 @@ |
||
113 | 113 | */ |
114 | 114 | public static function deregister( $config_class_name = NULL ) { |
115 | 115 | if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
116 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
116 | + unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
117 | 117 | } |
118 | 118 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
106 | - * @return null |
|
106 | + * @return EE_Line_Item_Display |
|
107 | 107 | */ |
108 | 108 | public function line_item_display() { |
109 | 109 | return $this->line_item_display; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | |
114 | 114 | /** |
115 | - * @param null $line_item_display |
|
115 | + * @param EE_Line_Item_Display $line_item_display |
|
116 | 116 | */ |
117 | 117 | public function set_line_item_display( $line_item_display ) { |
118 | 118 | $this->line_item_display = $line_item_display; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | /** |
183 | - * @return bool |
|
183 | + * @return EE_Form_Section_Proper |
|
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | 186 | EE_Registry::instance()->load_helper( 'HTML' ); |
@@ -537,6 +537,7 @@ discard block |
||
537 | 537 | * _apply_registration_payments_to_amount_owing |
538 | 538 | * |
539 | 539 | * @access protected |
540 | + * @param EE_Base_Class[] $registrations |
|
540 | 541 | * @return void |
541 | 542 | */ |
542 | 543 | protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
@@ -754,7 +755,7 @@ discard block |
||
754 | 755 | * get_billing_form_html_for_payment_method |
755 | 756 | * |
756 | 757 | * @access public |
757 | - * @return string |
|
758 | + * @return boolean |
|
758 | 759 | */ |
759 | 760 | public function get_billing_form_html_for_payment_method() { |
760 | 761 | // how have they chosen to pay? |
@@ -874,7 +875,7 @@ discard block |
||
874 | 875 | * switch_payment_method |
875 | 876 | * |
876 | 877 | * @access public |
877 | - * @return string |
|
878 | + * @return boolean |
|
878 | 879 | */ |
879 | 880 | public function switch_payment_method() { |
880 | 881 | if ( ! $this->_verify_payment_method_is_set() ) { |
@@ -1041,7 +1042,7 @@ discard block |
||
1041 | 1042 | |
1042 | 1043 | /** |
1043 | 1044 | * process_reg_step |
1044 | - * @return boolean |
|
1045 | + * @return null|boolean |
|
1045 | 1046 | */ |
1046 | 1047 | public function process_reg_step() { |
1047 | 1048 | // how have they chosen to pay? |
@@ -1117,7 +1118,7 @@ discard block |
||
1117 | 1118 | * update_reg_step |
1118 | 1119 | * this is the final step after a user revisits the site to retry a payment |
1119 | 1120 | * |
1120 | - * @return boolean |
|
1121 | + * @return null|boolean |
|
1121 | 1122 | */ |
1122 | 1123 | public function update_reg_step() { |
1123 | 1124 | $success = TRUE; |
@@ -1399,7 +1400,7 @@ discard block |
||
1399 | 1400 | * |
1400 | 1401 | * @access private |
1401 | 1402 | * @type EE_Payment_Method $payment_method |
1402 | - * @return mixed EE_Payment | boolean |
|
1403 | + * @return EE_Payment|null EE_Payment | boolean |
|
1403 | 1404 | */ |
1404 | 1405 | private function _attempt_payment( EE_Payment_Method $payment_method ) { |
1405 | 1406 | $payment =NULL; |
@@ -1602,6 +1603,7 @@ discard block |
||
1602 | 1603 | * @access private |
1603 | 1604 | * @type EE_Payment $payment |
1604 | 1605 | * @param string $payment_occurs |
1606 | + * @param EE_Payment|null $payment |
|
1605 | 1607 | * @return bool |
1606 | 1608 | * @throws \EE_Error |
1607 | 1609 | */ |
@@ -1708,7 +1710,7 @@ discard block |
||
1708 | 1710 | * or present the payment options again |
1709 | 1711 | * |
1710 | 1712 | * @access private |
1711 | - * @return EE_Payment | FALSE |
|
1713 | + * @return boolean | FALSE |
|
1712 | 1714 | */ |
1713 | 1715 | public function process_gateway_response() { |
1714 | 1716 | $payment = null; |
@@ -1769,7 +1771,7 @@ discard block |
||
1769 | 1771 | * _validate_return |
1770 | 1772 | * |
1771 | 1773 | * @access private |
1772 | - * @return bool |
|
1774 | + * @return boolean|null |
|
1773 | 1775 | */ |
1774 | 1776 | private function _validate_offsite_return() { |
1775 | 1777 | $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
@@ -1836,7 +1838,7 @@ discard block |
||
1836 | 1838 | * |
1837 | 1839 | * @access private |
1838 | 1840 | * @param \EE_Registration $primary_registrant |
1839 | - * @return bool |
|
1841 | + * @return false|null |
|
1840 | 1842 | */ |
1841 | 1843 | private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
1842 | 1844 | if ( ! $primary_registrant instanceof EE_Registration ) { |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * @return void |
29 | 29 | */ |
30 | 30 | public static function set_hooks() { |
31 | - add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) ); |
|
32 | - add_action( 'wp_ajax_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
33 | - add_action( 'wp_ajax_nopriv_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
34 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
35 | - add_action( 'wp_ajax_nopriv_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
36 | - add_action( 'wp_ajax_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) ); |
|
37 | - add_action( 'wp_ajax_nopriv_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
31 | + add_filter('FHEE__SPCO__EE_Line_Item_Filter_Collection', array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')); |
|
32 | + add_action('wp_ajax_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
33 | + add_action('wp_ajax_nopriv_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
34 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
35 | + add_action('wp_ajax_nopriv_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
36 | + add_action('wp_ajax_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')); |
|
37 | + add_action('wp_ajax_nopriv_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
38 | 38 | ); |
39 | - add_filter( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), 10, 1 ); |
|
39 | + add_filter('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * ajax switch_spco_billing_form |
46 | 46 | */ |
47 | 47 | public static function switch_spco_billing_form() { |
48 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
48 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * ajax save_payer_details |
55 | 55 | */ |
56 | 56 | public static function save_payer_details() { |
57 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
57 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * ajax get_transaction_details |
64 | 64 | */ |
65 | 65 | public static function get_transaction_details() { |
66 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
66 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @param EE_Checkout $checkout |
92 | 92 | * @return \EE_SPCO_Reg_Step_Payment_Options |
93 | 93 | */ |
94 | - public function __construct( EE_Checkout $checkout ) { |
|
94 | + public function __construct(EE_Checkout $checkout) { |
|
95 | 95 | $this->_slug = 'payment_options'; |
96 | 96 | $this->_name = __('Payment Options', 'event_espresso'); |
97 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
97 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
98 | 98 | $this->checkout = $checkout; |
99 | 99 | $this->_reset_success_message(); |
100 | - $this->set_instructions( __('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
100 | + $this->set_instructions(__('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @param null $line_item_display |
116 | 116 | */ |
117 | - public function set_line_item_display( $line_item_display ) { |
|
117 | + public function set_line_item_display($line_item_display) { |
|
118 | 118 | $this->line_item_display = $line_item_display; |
119 | 119 | } |
120 | 120 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | public function translate_js_strings() { |
128 | - EE_Registry::$i18n_js_strings['no_payment_method'] = __( 'Please select a method of payment in order to continue.', 'event_espresso' ); |
|
129 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso' ); |
|
130 | - EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __( 'Forwarding to Secure Payment Provider.', 'event_espresso' ); |
|
128 | + EE_Registry::$i18n_js_strings['no_payment_method'] = __('Please select a method of payment in order to continue.', 'event_espresso'); |
|
129 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso'); |
|
130 | + EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __('Forwarding to Secure Payment Provider.', 'event_espresso'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | // $ 0.00 transactions (no payment required) |
157 | 157 | ! $this->checkout->payment_required() |
158 | 158 | // but do NOT remove if current action being called belongs to this reg step |
159 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
159 | + && ! is_callable(array($this, $this->checkout->action)) |
|
160 | 160 | && ! $this->completed() |
161 | 161 | ) { |
162 | 162 | // and if so, then we no longer need the Payment Options step |
163 | - if ( $this->is_current_step() ) { |
|
163 | + if ($this->is_current_step()) { |
|
164 | 164 | $this->checkout->generate_reg_form = false; |
165 | 165 | } |
166 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
166 | + $this->checkout->remove_reg_step($this->_slug); |
|
167 | 167 | // DEBUG LOG |
168 | 168 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | // load EEM_Payment_Method |
172 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
172 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
173 | 173 | // get all active payment methods |
174 | 174 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
175 | 175 | $this->checkout->transaction, EEM_Payment_Method::scope_cart |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return bool |
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
186 | + EE_Registry::instance()->load_helper('HTML'); |
|
187 | 187 | // reset in case someone changes their mind |
188 | 188 | $this->_reset_selected_method_of_payment(); |
189 | 189 | // set some defaults |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | $sold_out_events = array(); |
195 | 195 | $reg_count = 0; |
196 | 196 | // loop thru registrations to gather info |
197 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
198 | - foreach ( $registrations as $registration ) { |
|
197 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
198 | + foreach ($registrations as $registration) { |
|
199 | 199 | /** @var $registration EE_Registration */ |
200 | 200 | $reg_count++; |
201 | 201 | // if returning registrant is Approved then do NOT do this |
202 | - if ( ! ( $this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved )) { |
|
203 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true )) { |
|
202 | + if ( ! ($this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved)) { |
|
203 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
204 | 204 | // add event to list of events that are sold out |
205 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
205 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
206 | 206 | do_action( |
207 | 207 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
208 | 208 | $registration->event(), |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | ); |
211 | 211 | } |
212 | 212 | // event requires admin approval |
213 | - if ( $registration->status_ID() == EEM_Registration::status_id_not_approved ) { |
|
213 | + if ($registration->status_ID() == EEM_Registration::status_id_not_approved) { |
|
214 | 214 | // add event to list of events with pre-approval reg status |
215 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
215 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
216 | 216 | do_action( |
217 | 217 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
218 | 218 | $registration->event(), |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | // are they allowed to pay now and is there monies owing? |
224 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
225 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
224 | + if ($registration->owes_monies_and_can_pay()) { |
|
225 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
226 | 226 | do_action( |
227 | 227 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
228 | 228 | $registration->event(), |
229 | 229 | $this |
230 | 230 | ); |
231 | - } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free() ) { |
|
232 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
231 | + } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) { |
|
232 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | $subsections = array(); |
236 | 236 | // now decide which template to load |
237 | - if ( ! empty( $sold_out_events )) { |
|
238 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
237 | + if ( ! empty($sold_out_events)) { |
|
238 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
239 | 239 | } |
240 | - if ( ! empty( $registrations_requiring_pre_approval )) { |
|
241 | - $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval ); |
|
240 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
241 | + $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval); |
|
242 | 242 | } |
243 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
244 | - $subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events ); |
|
243 | + if ( ! empty($registrations_for_free_events)) { |
|
244 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
245 | 245 | } |
246 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
246 | + if ( ! empty($registrations_requiring_payment)) { |
|
247 | 247 | // autoload Line_Item_Display classes |
248 | 248 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
249 | 249 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | $this->checkout->cart->get_grand_total() |
255 | 255 | ); |
256 | 256 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
257 | - if ( $this->checkout->amount_owing > 0 ) { |
|
257 | + if ($this->checkout->amount_owing > 0) { |
|
258 | 258 | EEH_Autoloader::register_line_item_display_autoloaders(); |
259 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
260 | - $subsections[ 'payment_options' ] = $this->_display_payment_options( |
|
259 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
260 | + $subsections['payment_options'] = $this->_display_payment_options( |
|
261 | 261 | $this->line_item_display->display_line_item( |
262 | 262 | $filtered_line_item_tree, |
263 | - array( 'registrations' => $registrations ) |
|
263 | + array('registrations' => $registrations) |
|
264 | 264 | ) |
265 | 265 | ); |
266 | 266 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
267 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
267 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
268 | 268 | } |
269 | 269 | } else { |
270 | 270 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
298 | 298 | * @return \EE_Line_Item_Filter_Collection |
299 | 299 | */ |
300 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
300 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
301 | 301 | $line_item_filter_collection->add( |
302 | 302 | new EE_Billable_Line_Item_Filter( |
303 | 303 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ) |
306 | 306 | ) |
307 | 307 | ); |
308 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
308 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
309 | 309 | return $line_item_filter_collection; |
310 | 310 | } |
311 | 311 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @return void |
320 | 320 | */ |
321 | 321 | protected function _hide_reg_step_submit_button_if_revisit() { |
322 | - if ( $this->checkout->revisit ) { |
|
323 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
322 | + if ($this->checkout->revisit) { |
|
323 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * @param \EE_Event[] $sold_out_events_array |
332 | 332 | * @return \EE_Form_Section_Proper |
333 | 333 | */ |
334 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
334 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
335 | 335 | // set some defaults |
336 | 336 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
337 | 337 | $sold_out_events = ''; |
338 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
339 | - $sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )); |
|
338 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
339 | + $sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')); |
|
340 | 340 | } |
341 | 341 | return new EE_Form_Section_Proper( |
342 | 342 | array( |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | ), |
349 | 349 | 'layout_strategy' => new EE_Template_Layout( |
350 | 350 | array( |
351 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template |
|
351 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template |
|
352 | 352 | 'template_args' => apply_filters( |
353 | 353 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
354 | 354 | array( |
355 | 355 | 'sold_out_events' => $sold_out_events, |
356 | 356 | 'sold_out_events_msg' => apply_filters( |
357 | 357 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
358 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ) |
|
358 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso') |
|
359 | 359 | ) |
360 | 360 | ) |
361 | 361 | ) |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | * @param array $registrations_requiring_pre_approval |
373 | 373 | * @return \EE_Form_Section_Proper |
374 | 374 | */ |
375 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) { |
|
375 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
376 | 376 | $events_requiring_pre_approval = ''; |
377 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
378 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
379 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
380 | - EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
377 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
378 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
379 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
380 | + EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
381 | 381 | ) |
382 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
382 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | } |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | ), |
392 | 392 | 'layout_strategy' => new EE_Template_Layout( |
393 | 393 | array( |
394 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template |
|
394 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template |
|
395 | 395 | 'template_args' => apply_filters( |
396 | 396 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
397 | 397 | array( |
398 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
398 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
399 | 399 | 'events_requiring_pre_approval_msg' => apply_filters( |
400 | 400 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
401 | - __( 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso' ) |
|
401 | + __('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso') |
|
402 | 402 | ) |
403 | 403 | ) |
404 | 404 | ), |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @param \EE_Event[] $registrations_for_free_events |
417 | 417 | * @return \EE_Form_Section_Proper |
418 | 418 | */ |
419 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
419 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
420 | 420 | // set some defaults |
421 | 421 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
422 | 422 | // generate no_payment_required form |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | ), |
429 | 429 | 'layout_strategy' => new EE_Template_Layout( |
430 | 430 | array( |
431 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template |
|
431 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template |
|
432 | 432 | 'template_args' => apply_filters( |
433 | 433 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
434 | 434 | array( |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'registrations' => array(), |
437 | 437 | 'ticket_count' => array(), |
438 | 438 | 'registrations_for_free_events' => $registrations_for_free_events, |
439 | - 'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' )) |
|
439 | + 'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso')) |
|
440 | 440 | ) |
441 | 441 | ), |
442 | 442 | ) |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @param string $transaction_details |
454 | 454 | * @return \EE_Form_Section_Proper |
455 | 455 | */ |
456 | - private function _display_payment_options( $transaction_details = '' ) { |
|
456 | + private function _display_payment_options($transaction_details = '') { |
|
457 | 457 | // has method_of_payment been set by no-js user? |
458 | 458 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
459 | 459 | // build payment options form |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | 'before_payment_options' => apply_filters( |
466 | 466 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
467 | 467 | new EE_Form_Section_Proper( |
468 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
468 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
469 | 469 | ) |
470 | 470 | ), |
471 | 471 | 'payment_options' => $this->_setup_payment_options(), |
472 | 472 | 'after_payment_options' => apply_filters( |
473 | 473 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
474 | 474 | new EE_Form_Section_Proper( |
475 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
475 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
479 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( FALSE ) |
|
479 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(FALSE) |
|
480 | 480 | ), |
481 | - 'layout_strategy' => new EE_Template_Layout( array( |
|
481 | + 'layout_strategy' => new EE_Template_Layout(array( |
|
482 | 482 | 'layout_template_file' => $this->_template, |
483 | 483 | 'template_args' => apply_filters( |
484 | 484 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * @param bool $no_payment_required |
503 | 503 | * @return \EE_Form_Section_Proper |
504 | 504 | */ |
505 | - private function _extra_hidden_inputs( $no_payment_required = TRUE ) { |
|
505 | + private function _extra_hidden_inputs($no_payment_required = TRUE) { |
|
506 | 506 | |
507 | 507 | return new EE_Form_Section_Proper( |
508 | 508 | array( |
509 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
509 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
510 | 510 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
511 | 511 | 'subsections' => array( |
512 | 512 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -539,16 +539,16 @@ discard block |
||
539 | 539 | * @access protected |
540 | 540 | * @return void |
541 | 541 | */ |
542 | - protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
|
542 | + protected function _apply_registration_payments_to_amount_owing($registrations) { |
|
543 | 543 | $payments = array(); |
544 | - foreach ( $registrations as $registration ) { |
|
545 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
544 | + foreach ($registrations as $registration) { |
|
545 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
546 | 546 | $payments = $payments + $registration->registration_payments(); |
547 | 547 | } |
548 | 548 | } |
549 | - if ( ! empty( $payments ) ) { |
|
550 | - foreach ( $payments as $payment ) { |
|
551 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
549 | + if ( ! empty($payments)) { |
|
550 | + foreach ($payments as $payment) { |
|
551 | + if ($payment instanceof EE_Registration_Payment) { |
|
552 | 552 | $this->checkout->amount_owing -= $payment->amount(); |
553 | 553 | } |
554 | 554 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * @param bool $force_reset |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - private function _reset_selected_method_of_payment( $force_reset = FALSE ) { |
|
567 | - $reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE )); |
|
568 | - if ( $reset_payment_method ) { |
|
566 | + private function _reset_selected_method_of_payment($force_reset = FALSE) { |
|
567 | + $reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE)); |
|
568 | + if ($reset_payment_method) { |
|
569 | 569 | $this->checkout->selected_method_of_payment = NULL; |
570 | 570 | $this->checkout->payment_method = NULL; |
571 | 571 | $this->checkout->billing_form = NULL; |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * @param string $selected_method_of_payment |
585 | 585 | * @return EE_Billing_Info_Form |
586 | 586 | */ |
587 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
588 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | - EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment )); |
|
587 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
588 | + $selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | + EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment)); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -599,40 +599,40 @@ discard block |
||
599 | 599 | // load payment method classes |
600 | 600 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
601 | 601 | // switch up header depending on number of available payment methods |
602 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
603 | - ? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' )) |
|
604 | - : apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' )); |
|
602 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
603 | + ? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso')) |
|
604 | + : apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso')); |
|
605 | 605 | $available_payment_methods = array( |
606 | 606 | // display the "Payment Method" header |
607 | 607 | 'payment_method_header' => new EE_Form_Section_HTML( |
608 | - EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' ) |
|
608 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
609 | 609 | ) |
610 | 610 | ); |
611 | 611 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
612 | 612 | $available_payment_method_options = array(); |
613 | 613 | $default_payment_method_option = array(); |
614 | 614 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
615 | - $payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' ))); |
|
615 | + $payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;'))); |
|
616 | 616 | // loop through payment methods |
617 | - foreach( $this->checkout->available_payment_methods as $payment_method ) { |
|
618 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
619 | - $payment_method_button = EEH_HTML::img( $payment_method->button_url(), $payment_method->name(), 'spco-payment-method-' . $payment_method->slug() . '-btn-img', 'spco-payment-method-btn-img' ); |
|
617 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
618 | + if ($payment_method instanceof EE_Payment_Method) { |
|
619 | + $payment_method_button = EEH_HTML::img($payment_method->button_url(), $payment_method->name(), 'spco-payment-method-'.$payment_method->slug().'-btn-img', 'spco-payment-method-btn-img'); |
|
620 | 620 | // check if any payment methods are set as default |
621 | 621 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
622 | - if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) { |
|
622 | + if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) { |
|
623 | 623 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
624 | 624 | $this->_save_selected_method_of_payment(); |
625 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
625 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
626 | 626 | } else { |
627 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
627 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
628 | 628 | } |
629 | - $payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method ); |
|
629 | + $payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method); |
|
630 | 630 | } |
631 | 631 | } |
632 | 632 | // prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs |
633 | 633 | $available_payment_method_options = $default_payment_method_option + $available_payment_method_options; |
634 | 634 | // now generate the actual form inputs |
635 | - $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options ); |
|
635 | + $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options); |
|
636 | 636 | $available_payment_methods = $available_payment_methods + $payment_methods_billing_info; |
637 | 637 | |
638 | 638 | // build the available payment methods form |
@@ -652,19 +652,19 @@ discard block |
||
652 | 652 | * @return EE_Payment_Method[] |
653 | 653 | */ |
654 | 654 | protected function _get_available_payment_methods() { |
655 | - if ( ! empty( $this->checkout->available_payment_methods )) { |
|
655 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
656 | 656 | return $this->checkout->available_payment_methods; |
657 | 657 | } |
658 | 658 | $available_payment_methods = array(); |
659 | 659 | // load EEM_Payment_Method |
660 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
660 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
661 | 661 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
662 | 662 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
663 | 663 | // get all active payment methods |
664 | - $payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart ); |
|
665 | - foreach ( $payment_methods as $payment_method ) { |
|
666 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
667 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
664 | + $payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart); |
|
665 | + foreach ($payment_methods as $payment_method) { |
|
666 | + if ($payment_method instanceof EE_Payment_Method) { |
|
667 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | return $available_payment_methods; |
@@ -680,14 +680,14 @@ discard block |
||
680 | 680 | * @param array $available_payment_method_options |
681 | 681 | * @return \EE_Form_Section_Proper |
682 | 682 | */ |
683 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
683 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
684 | 684 | // generate inputs |
685 | 685 | return new EE_Form_Section_Proper( |
686 | 686 | array( |
687 | 687 | 'html_id' => 'ee-available-payment-method-inputs', |
688 | 688 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
689 | 689 | 'subsections' => array( |
690 | - '' => new EE_Radio_Button_Input ( |
|
690 | + '' => new EE_Radio_Button_Input( |
|
691 | 691 | $available_payment_method_options, |
692 | 692 | array( |
693 | 693 | 'html_name' => 'selected_method_of_payment', |
@@ -711,36 +711,36 @@ discard block |
||
711 | 711 | * @param EE_Payment_Method $payment_method |
712 | 712 | * @return \EE_Form_Section_Proper |
713 | 713 | */ |
714 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
714 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
715 | 715 | $currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE; |
716 | 716 | // generate the billing form for payment method |
717 | - $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML(); |
|
717 | + $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML(); |
|
718 | 718 | $this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form; |
719 | 719 | // it's all in the details |
720 | - $info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' ); |
|
720 | + $info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr'); |
|
721 | 721 | // add some info regarding the step, either from what's saved in the admin, or a default string depending on whether the PM has a billing form or not |
722 | - if ( $payment_method->description() ) { |
|
722 | + if ($payment_method->description()) { |
|
723 | 723 | $payment_method_info = $payment_method->description(); |
724 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
725 | - $payment_method_info = sprintf( __( 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
724 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
725 | + $payment_method_info = sprintf(__('Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
726 | 726 | } else { |
727 | - $payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
727 | + $payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
728 | 728 | } |
729 | - $info_html .= EEH_HTML::p ( |
|
730 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ), |
|
729 | + $info_html .= EEH_HTML::p( |
|
730 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info), |
|
731 | 731 | '', |
732 | 732 | 'spco-payment-method-desc ee-attention' |
733 | 733 | ); |
734 | 734 | |
735 | 735 | return new EE_Form_Section_Proper( |
736 | 736 | array( |
737 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
737 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
738 | 738 | 'html_class' => 'spco-payment-method-info-dv', |
739 | 739 | // only display the selected or default PM |
740 | 740 | 'html_style' => $currently_selected ? '' : 'display:none;', |
741 | 741 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
742 | 742 | 'subsections' => array( |
743 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
743 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
744 | 744 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
745 | 745 | ) |
746 | 746 | ) |
@@ -758,12 +758,12 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function get_billing_form_html_for_payment_method() { |
760 | 760 | // how have they chosen to pay? |
761 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
761 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
762 | 762 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
763 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
763 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
764 | 764 | return FALSE; |
765 | 765 | } |
766 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
766 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
767 | 767 | EE_Error::add_success( |
768 | 768 | apply_filters( |
769 | 769 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -772,20 +772,20 @@ discard block |
||
772 | 772 | ); |
773 | 773 | } |
774 | 774 | // now generate billing form for selected method of payment |
775 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
775 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
776 | 776 | // fill form with attendee info if applicable |
777 | - if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
778 | - $payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
777 | + if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
778 | + $payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
779 | 779 | } |
780 | 780 | // and debug content |
781 | - if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
782 | - $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form ); |
|
781 | + if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
782 | + $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form); |
|
783 | 783 | } |
784 | 784 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : ''; |
785 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info )); |
|
785 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
786 | 786 | // localize validation rules for main form |
787 | 787 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
788 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
788 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
789 | 789 | return TRUE; |
790 | 790 | } |
791 | 791 | |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | * @param EE_Payment_Method $payment_method |
799 | 799 | * @return \EE_Billing_Info_Form |
800 | 800 | */ |
801 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
802 | - $billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) ); |
|
803 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
804 | - if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) { |
|
805 | - if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) { |
|
801 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
802 | + $billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing)); |
|
803 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
804 | + if (EE_Registry::instance()->REQ->is_set('payment_method')) { |
|
805 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
806 | 806 | EE_Error::add_success( |
807 | 807 | apply_filters( |
808 | 808 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
809 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() ) |
|
809 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name()) |
|
810 | 810 | ) |
811 | 811 | ); |
812 | 812 | } |
@@ -831,27 +831,27 @@ discard block |
||
831 | 831 | * @param string $request_param |
832 | 832 | * @return NULL|string |
833 | 833 | */ |
834 | - private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) { |
|
834 | + private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') { |
|
835 | 835 | // is selected_method_of_payment set in the request ? |
836 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE ); |
|
837 | - if ( $selected_method_of_payment ) { |
|
836 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE); |
|
837 | + if ($selected_method_of_payment) { |
|
838 | 838 | // sanitize it |
839 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment; |
|
840 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
839 | + $selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment; |
|
840 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
841 | 841 | // store it in the session so that it's available for all subsequent requests including AJAX |
842 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
842 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
843 | 843 | } else { |
844 | 844 | // or is is set in the session ? |
845 | - $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' ); |
|
845 | + $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment'); |
|
846 | 846 | } |
847 | 847 | // do ya really really gotta have it? |
848 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
848 | + if (empty($selected_method_of_payment) && $required) { |
|
849 | 849 | EE_Error::add_error( |
850 | 850 | sprintf( |
851 | - __( 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso' ), |
|
851 | + __('The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso'), |
|
852 | 852 | '<br/>', |
853 | 853 | '<br/>', |
854 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
854 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
855 | 855 | ), |
856 | 856 | __FILE__, __FUNCTION__, __LINE__ |
857 | 857 | ); |
@@ -877,37 +877,37 @@ discard block |
||
877 | 877 | * @return string |
878 | 878 | */ |
879 | 879 | public function switch_payment_method() { |
880 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
880 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
881 | 881 | return FALSE; |
882 | 882 | } |
883 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
883 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
884 | 884 | EE_Error::add_success( |
885 | 885 | apply_filters( |
886 | 886 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
887 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $this->checkout->payment_method->name() ) |
|
887 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name()) |
|
888 | 888 | ) |
889 | 889 | ); |
890 | 890 | } |
891 | 891 | // generate billing form for selected method of payment if it hasn't been done already |
892 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
893 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
892 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
893 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
894 | 894 | } |
895 | 895 | // fill form with attendee info if applicable |
896 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
897 | - $this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
896 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
897 | + $this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
898 | 898 | } |
899 | 899 | // and debug content |
900 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
901 | - $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form ); |
|
900 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
901 | + $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form); |
|
902 | 902 | } |
903 | 903 | // get html and validation rules for form |
904 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
905 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() )); |
|
904 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
905 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html())); |
|
906 | 906 | // localize validation rules for main form |
907 | - $this->checkout->billing_form->localize_validation_rules( TRUE ); |
|
908 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
907 | + $this->checkout->billing_form->localize_validation_rules(TRUE); |
|
908 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
909 | 909 | } else { |
910 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' )); |
|
910 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
911 | 911 | } |
912 | 912 | //prevents advancement to next step |
913 | 913 | $this->checkout->continue_reg = FALSE; |
@@ -922,12 +922,12 @@ discard block |
||
922 | 922 | */ |
923 | 923 | protected function _verify_payment_method_is_set() { |
924 | 924 | // generate billing form for selected method of payment if it hasn't been done already |
925 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
925 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
926 | 926 | // how have they chosen to pay? |
927 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
927 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
928 | 928 | } |
929 | 929 | // verify payment method |
930 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
930 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
931 | 931 | // get payment method for selected method of payment |
932 | 932 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
933 | 933 | } |
@@ -947,23 +947,23 @@ discard block |
||
947 | 947 | * @return void |
948 | 948 | */ |
949 | 949 | public function save_payer_details_via_ajax() { |
950 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
950 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
951 | 951 | return; |
952 | 952 | } |
953 | 953 | // generate billing form for selected method of payment if it hasn't been done already |
954 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
955 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
954 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
955 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
956 | 956 | } |
957 | 957 | // generate primary attendee from payer info if applicable |
958 | 958 | if ( ! $this->checkout->transaction_has_primary_registrant()) { |
959 | 959 | $attendee = $this->_create_attendee_from_request_data(); |
960 | - if ( $attendee instanceof EE_Attendee ) { |
|
961 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
962 | - if ( $registration->is_primary_registrant() ) { |
|
960 | + if ($attendee instanceof EE_Attendee) { |
|
961 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
962 | + if ($registration->is_primary_registrant()) { |
|
963 | 963 | $this->checkout->primary_attendee_obj = $attendee; |
964 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
965 | - $registration->set_attendee_id( $attendee->ID() ); |
|
966 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
964 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
965 | + $registration->set_attendee_id($attendee->ID()); |
|
966 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | } |
@@ -976,56 +976,56 @@ discard block |
||
976 | 976 | * uses info from alternate GET or POST data (such as AJAX) to create a new attendee |
977 | 977 | * @return \EE_Attendee |
978 | 978 | */ |
979 | - protected function _create_attendee_from_request_data(){ |
|
979 | + protected function _create_attendee_from_request_data() { |
|
980 | 980 | // get State ID |
981 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
982 | - if ( ! empty( $STA_ID )) { |
|
981 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
982 | + if ( ! empty($STA_ID)) { |
|
983 | 983 | // can we get state object from name ? |
984 | - EE_Registry::instance()->load_model( 'State' ); |
|
985 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' ); |
|
986 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
984 | + EE_Registry::instance()->load_model('State'); |
|
985 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
986 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
987 | 987 | } |
988 | 988 | // get Country ISO |
989 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
990 | - if ( ! empty( $CNT_ISO )) { |
|
989 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
990 | + if ( ! empty($CNT_ISO)) { |
|
991 | 991 | // can we get country object from name ? |
992 | - EE_Registry::instance()->load_model( 'Country' ); |
|
993 | - $country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' ); |
|
994 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
992 | + EE_Registry::instance()->load_model('Country'); |
|
993 | + $country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO'); |
|
994 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
995 | 995 | } |
996 | 996 | // grab attendee data |
997 | 997 | $attendee_data = array( |
998 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
999 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1000 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1001 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1002 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1003 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
998 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
999 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1000 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1001 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1002 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1003 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1004 | 1004 | 'STA_ID' => $STA_ID, |
1005 | 1005 | 'CNT_ISO' => $CNT_ISO, |
1006 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1007 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1006 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1007 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1008 | 1008 | ); |
1009 | 1009 | // validate the email address since it is the most important piece of info |
1010 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) { |
|
1011 | - EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1010 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) { |
|
1011 | + EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1012 | 1012 | } |
1013 | 1013 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1014 | - if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) { |
|
1015 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array( |
|
1014 | + if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) { |
|
1015 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array( |
|
1016 | 1016 | 'ATT_fname' => $attendee_data['ATT_fname'], |
1017 | 1017 | 'ATT_lname' => $attendee_data['ATT_lname'], |
1018 | 1018 | 'ATT_email' => $attendee_data['ATT_email'] |
1019 | 1019 | )); |
1020 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1020 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1021 | 1021 | return $existing_attendee; |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | // no existing attendee? kk let's create a new one |
1025 | 1025 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1026 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1026 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | + return EE_Attendee::new_instance($attendee_data); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | |
@@ -1045,22 +1045,22 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | public function process_reg_step() { |
1047 | 1047 | // how have they chosen to pay? |
1048 | - $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE ); |
|
1048 | + $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE); |
|
1049 | 1049 | // choose your own adventure based on method_of_payment |
1050 | - switch( $this->checkout->selected_method_of_payment ) { |
|
1050 | + switch ($this->checkout->selected_method_of_payment) { |
|
1051 | 1051 | |
1052 | 1052 | case 'events_sold_out' : |
1053 | 1053 | $this->checkout->redirect = TRUE; |
1054 | 1054 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1055 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1055 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1056 | 1056 | // mark this reg step as completed |
1057 | 1057 | $this->set_completed(); |
1058 | 1058 | return FALSE; |
1059 | 1059 | break; |
1060 | 1060 | |
1061 | 1061 | case 'payments_closed' : |
1062 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) { |
|
1063 | - EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1062 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) { |
|
1063 | + EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1064 | 1064 | } |
1065 | 1065 | // mark this reg step as completed |
1066 | 1066 | $this->set_completed(); |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | break; |
1069 | 1069 | |
1070 | 1070 | case 'no_payment_required' : |
1071 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) { |
|
1072 | - EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1071 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) { |
|
1072 | + EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1073 | 1073 | } |
1074 | 1074 | // mark this reg step as completed |
1075 | 1075 | $this->set_completed(); |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | default: |
1080 | 1080 | $payment_successful = $this->_process_payment(); |
1081 | - if ( $payment_successful ) { |
|
1081 | + if ($payment_successful) { |
|
1082 | 1082 | $this->checkout->continue_reg = true; |
1083 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1083 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1084 | 1084 | } else { |
1085 | 1085 | $this->checkout->continue_reg = false; |
1086 | 1086 | } |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @param \EE_Payment_Method $payment_method |
1099 | 1099 | * @return void |
1100 | 1100 | */ |
1101 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1102 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1101 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1102 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1103 | 1103 | case EE_PMT_Base::offsite : |
1104 | 1104 | break; |
1105 | 1105 | case EE_PMT_Base::onsite : |
@@ -1122,15 +1122,15 @@ discard block |
||
1122 | 1122 | public function update_reg_step() { |
1123 | 1123 | $success = TRUE; |
1124 | 1124 | // if payment required |
1125 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1126 | - do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction ); |
|
1125 | + if ($this->checkout->transaction->total() > 0) { |
|
1126 | + do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction); |
|
1127 | 1127 | // attempt payment via payment method |
1128 | 1128 | $success = $this->process_reg_step(); |
1129 | 1129 | } |
1130 | - if ( $success && ! $this->checkout->redirect ) { |
|
1131 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() ); |
|
1130 | + if ($success && ! $this->checkout->redirect) { |
|
1131 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID()); |
|
1132 | 1132 | // set return URL |
1133 | - $this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url ); |
|
1133 | + $this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url); |
|
1134 | 1134 | } |
1135 | 1135 | return $success; |
1136 | 1136 | } |
@@ -1150,24 +1150,24 @@ discard block |
||
1150 | 1150 | // clear any previous errors related to not selecting a payment method |
1151 | 1151 | // EE_Error::overwrite_errors(); |
1152 | 1152 | // ya gotta make a choice man |
1153 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
1154 | - $this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' )); |
|
1153 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1154 | + $this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso')); |
|
1155 | 1155 | return FALSE; |
1156 | 1156 | } |
1157 | 1157 | // get EE_Payment_Method object |
1158 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1158 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1159 | 1159 | return FALSE; |
1160 | 1160 | } |
1161 | 1161 | // setup billing form |
1162 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1163 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1162 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1163 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1164 | 1164 | // bad billing form ? |
1165 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1165 | + if ( ! $this->_billing_form_is_valid()) { |
|
1166 | 1166 | return FALSE; |
1167 | 1167 | } |
1168 | 1168 | } |
1169 | 1169 | // ensure primary registrant has been fully processed |
1170 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1170 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1171 | 1171 | return FALSE; |
1172 | 1172 | } |
1173 | 1173 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1175,24 +1175,24 @@ discard block |
||
1175 | 1175 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1176 | 1176 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1177 | 1177 | // attempt payment |
1178 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1178 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1179 | 1179 | // process results |
1180 | - $payment = $this->_validate_payment( $payment ); |
|
1181 | - $payment = $this->_post_payment_processing( $payment ); |
|
1180 | + $payment = $this->_validate_payment($payment); |
|
1181 | + $payment = $this->_post_payment_processing($payment); |
|
1182 | 1182 | // verify payment |
1183 | - if ( $payment instanceof EE_Payment ) { |
|
1183 | + if ($payment instanceof EE_Payment) { |
|
1184 | 1184 | // store that for later |
1185 | 1185 | $this->checkout->payment = $payment; |
1186 | 1186 | /** @type EE_Transaction_Processor $transaction_processor */ |
1187 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1187 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1188 | 1188 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1189 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1190 | - if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) { |
|
1189 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1190 | + if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) { |
|
1191 | 1191 | return true; |
1192 | 1192 | } else { |
1193 | 1193 | return false; |
1194 | 1194 | } |
1195 | - } else if ( $payment === true ) { |
|
1195 | + } else if ($payment === true) { |
|
1196 | 1196 | // please note that offline payment methods will NOT make a payment, |
1197 | 1197 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1198 | 1198 | $this->checkout->payment = $payment; |
@@ -1211,10 +1211,10 @@ discard block |
||
1211 | 1211 | * @return bool |
1212 | 1212 | */ |
1213 | 1213 | public function redirect_form() { |
1214 | - $payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() ); |
|
1214 | + $payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment()); |
|
1215 | 1215 | $html = $payment_method_billing_info->get_html_and_js(); |
1216 | 1216 | $html .= $this->checkout->redirect_form; |
1217 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1217 | + EE_Registry::instance()->REQ->add_output($html); |
|
1218 | 1218 | return TRUE; |
1219 | 1219 | } |
1220 | 1220 | |
@@ -1227,36 +1227,36 @@ discard block |
||
1227 | 1227 | * @return bool |
1228 | 1228 | */ |
1229 | 1229 | private function _billing_form_is_valid() { |
1230 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1230 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1231 | 1231 | return TRUE; |
1232 | 1232 | } |
1233 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1234 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1233 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1234 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1235 | 1235 | $this->checkout->billing_form->receive_form_submission(); |
1236 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1236 | + if ($this->checkout->billing_form->is_valid()) { |
|
1237 | 1237 | return TRUE; |
1238 | 1238 | } |
1239 | 1239 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1240 | 1240 | $error_strings = array(); |
1241 | - foreach( $validation_errors as $validation_error ){ |
|
1242 | - if( $validation_error instanceof EE_Validation_Error ){ |
|
1241 | + foreach ($validation_errors as $validation_error) { |
|
1242 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1243 | 1243 | $form_section = $validation_error->get_form_section(); |
1244 | - if( $form_section instanceof EE_Form_Input_Base ){ |
|
1244 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1245 | 1245 | $label = $form_section->html_label_text(); |
1246 | - }elseif( $form_section instanceof EE_Form_Section_Base ){ |
|
1246 | + }elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1247 | 1247 | $label = $form_section->name(); |
1248 | - }else{ |
|
1249 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1248 | + } else { |
|
1249 | + $label = __('Validation Error', 'event_espresso'); |
|
1250 | 1250 | } |
1251 | - $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1251 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1252 | 1252 | } |
1253 | 1253 | } |
1254 | - EE_Error::add_error( sprintf( __( 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso' ), '<br/>', implode( '<br/>', $error_strings ) ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1254 | + EE_Error::add_error(sprintf(__('One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso'), '<br/>', implode('<br/>', $error_strings)), __FILE__, __FUNCTION__, __LINE__); |
|
1255 | 1255 | } else { |
1256 | - EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1256 | + EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1257 | 1257 | } |
1258 | 1258 | } else { |
1259 | - EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1259 | + EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1260 | 1260 | } |
1261 | 1261 | return FALSE; |
1262 | 1262 | } |
@@ -1274,9 +1274,9 @@ discard block |
||
1274 | 1274 | */ |
1275 | 1275 | private function _setup_primary_registrant_prior_to_payment() { |
1276 | 1276 | // check if transaction has a primary registrant and that it has a related Attendee object |
1277 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1277 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1278 | 1278 | // need to at least gather some primary registrant data before attempting payment |
1279 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) { |
|
1279 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) { |
|
1280 | 1280 | return FALSE; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1284,13 +1284,13 @@ discard block |
||
1284 | 1284 | // grab the primary_registration object |
1285 | 1285 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1286 | 1286 | /** @type EE_Transaction_Processor $transaction_processor */ |
1287 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1287 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1288 | 1288 | // at this point we'll consider a TXN to not have been failed |
1289 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1289 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1290 | 1290 | // save the TXN ( which clears cached copy of primary_registration) |
1291 | 1291 | $this->checkout->transaction->save(); |
1292 | 1292 | // grab TXN ID and save it to the primary_registration |
1293 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1293 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1294 | 1294 | // save what we have so far |
1295 | 1295 | $primary_registration->save(); |
1296 | 1296 | return TRUE; |
@@ -1307,41 +1307,41 @@ discard block |
||
1307 | 1307 | private function _capture_primary_registration_data_from_billing_form() { |
1308 | 1308 | // convert billing form data into an attendee |
1309 | 1309 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1310 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1310 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1311 | 1311 | EE_Error::add_error( |
1312 | 1312 | sprintf( |
1313 | - __( 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1313 | + __('The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1314 | 1314 | '<br/>', |
1315 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1315 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1316 | 1316 | ), __FILE__, __FUNCTION__, __LINE__ |
1317 | 1317 | ); |
1318 | 1318 | return FALSE; |
1319 | 1319 | } |
1320 | 1320 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1321 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1321 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1322 | 1322 | EE_Error::add_error( |
1323 | 1323 | sprintf( |
1324 | - __( 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1324 | + __('The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1325 | 1325 | '<br/>', |
1326 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1326 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1327 | 1327 | ), __FILE__, __FUNCTION__, __LINE__ |
1328 | 1328 | ); |
1329 | 1329 | return FALSE; |
1330 | 1330 | } |
1331 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) { |
|
1331 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) { |
|
1332 | 1332 | EE_Error::add_error( |
1333 | 1333 | sprintf( |
1334 | - __( 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1334 | + __('The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1335 | 1335 | '<br/>', |
1336 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1336 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1337 | 1337 | ), __FILE__, __FUNCTION__, __LINE__ |
1338 | 1338 | ); |
1339 | 1339 | return FALSE; |
1340 | 1340 | } |
1341 | 1341 | /** @type EE_Registration_Processor $registration_processor */ |
1342 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1342 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1343 | 1343 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1344 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1344 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1345 | 1345 | |
1346 | 1346 | return TRUE; |
1347 | 1347 | } |
@@ -1357,35 +1357,35 @@ discard block |
||
1357 | 1357 | */ |
1358 | 1358 | private function _get_payment_method_for_selected_method_of_payment() { |
1359 | 1359 | // get EE_Payment_Method object |
1360 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) { |
|
1361 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1360 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1361 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1362 | 1362 | } else { |
1363 | 1363 | // load EEM_Payment_Method |
1364 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1364 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1365 | 1365 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1366 | 1366 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1367 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1367 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1368 | 1368 | } |
1369 | 1369 | // verify $payment_method |
1370 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1370 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1371 | 1371 | // not a payment |
1372 | 1372 | EE_Error::add_error( |
1373 | 1373 | sprintf( |
1374 | - __( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1374 | + __('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1375 | 1375 | '<br/>', |
1376 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1376 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1377 | 1377 | ), __FILE__, __FUNCTION__, __LINE__ |
1378 | 1378 | ); |
1379 | 1379 | return NULL; |
1380 | 1380 | } |
1381 | 1381 | // and verify it has a valid Payment_Method Type object |
1382 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1382 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1383 | 1383 | // not a payment |
1384 | 1384 | EE_Error::add_error( |
1385 | 1385 | sprintf( |
1386 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1386 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1387 | 1387 | '<br/>', |
1388 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1388 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1389 | 1389 | ), __FILE__, __FUNCTION__, __LINE__ |
1390 | 1390 | ); |
1391 | 1391 | return NULL; |
@@ -1404,30 +1404,30 @@ discard block |
||
1404 | 1404 | * @type EE_Payment_Method $payment_method |
1405 | 1405 | * @return mixed EE_Payment | boolean |
1406 | 1406 | */ |
1407 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1408 | - $payment =NULL; |
|
1407 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1408 | + $payment = NULL; |
|
1409 | 1409 | $this->checkout->transaction->save(); |
1410 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1411 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1410 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1411 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1412 | 1412 | return FALSE; |
1413 | 1413 | } |
1414 | 1414 | try { |
1415 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1415 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1416 | 1416 | // generate payment object |
1417 | 1417 | $payment = $payment_processor->process_payment( |
1418 | 1418 | $payment_method, |
1419 | 1419 | $this->checkout->transaction, |
1420 | 1420 | $this->checkout->amount_owing, |
1421 | 1421 | $this->checkout->billing_form, |
1422 | - $this->_get_return_url( $payment_method ), |
|
1422 | + $this->_get_return_url($payment_method), |
|
1423 | 1423 | 'CART', |
1424 | 1424 | $this->checkout->admin_request, |
1425 | 1425 | TRUE, |
1426 | 1426 | $this->reg_step_url() |
1427 | 1427 | ); |
1428 | 1428 | |
1429 | - } catch( Exception $e ) { |
|
1430 | - $this->_handle_payment_processor_exception( $e ); |
|
1429 | + } catch (Exception $e) { |
|
1430 | + $this->_handle_payment_processor_exception($e); |
|
1431 | 1431 | } |
1432 | 1432 | return $payment; |
1433 | 1433 | } |
@@ -1441,12 +1441,12 @@ discard block |
||
1441 | 1441 | * @param \Exception $e |
1442 | 1442 | * @return void |
1443 | 1443 | */ |
1444 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1444 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1445 | 1445 | EE_Error::add_error( |
1446 | 1446 | sprintf( |
1447 | - __( 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso' ), |
|
1447 | + __('The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso'), |
|
1448 | 1448 | '<br/>', |
1449 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1449 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1450 | 1450 | $e->getMessage(), |
1451 | 1451 | $e->getFile(), |
1452 | 1452 | $e->getLine() |
@@ -1463,9 +1463,9 @@ discard block |
||
1463 | 1463 | * @param \EE_Payment_Method $payment_method |
1464 | 1464 | * @return string |
1465 | 1465 | */ |
1466 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1466 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1467 | 1467 | $return_url = ''; |
1468 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1468 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1469 | 1469 | |
1470 | 1470 | case EE_PMT_Base::offsite : |
1471 | 1471 | $return_url = add_query_arg( |
@@ -1496,27 +1496,27 @@ discard block |
||
1496 | 1496 | * @param EE_Payment $payment |
1497 | 1497 | * @return EE_Payment | FALSE |
1498 | 1498 | */ |
1499 | - private function _validate_payment( $payment = NULL ) { |
|
1500 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1499 | + private function _validate_payment($payment = NULL) { |
|
1500 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1501 | 1501 | return TRUE; |
1502 | 1502 | } |
1503 | 1503 | // verify payment object |
1504 | - if ( $payment instanceof EE_Payment ) { |
|
1504 | + if ($payment instanceof EE_Payment) { |
|
1505 | 1505 | if ( |
1506 | 1506 | $payment->status() != EEM_Payment::status_id_approved |
1507 | 1507 | && $payment->status() != EEM_Payment::status_id_pending |
1508 | 1508 | && $payment->status() != EEM_Payment::status_id_cancelled |
1509 | 1509 | && $payment->gateway_response() != '' |
1510 | 1510 | ) { |
1511 | - EE_Error::add_error( $payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1511 | + EE_Error::add_error($payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__); |
|
1512 | 1512 | } |
1513 | 1513 | } else { |
1514 | 1514 | // not a payment |
1515 | 1515 | EE_Error::add_error( |
1516 | 1516 | sprintf( |
1517 | - __( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1517 | + __('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1518 | 1518 | '<br/>', |
1519 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1519 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1520 | 1520 | ), __FILE__, __FUNCTION__, __LINE__ |
1521 | 1521 | ); |
1522 | 1522 | return FALSE; |
@@ -1533,23 +1533,23 @@ discard block |
||
1533 | 1533 | * @param EE_Payment $payment |
1534 | 1534 | * @return bool |
1535 | 1535 | */ |
1536 | - private function _post_payment_processing( $payment = NULL ) { |
|
1536 | + private function _post_payment_processing($payment = NULL) { |
|
1537 | 1537 | // On-Site payment? |
1538 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1539 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) { |
|
1538 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1539 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1540 | 1540 | //$this->_setup_redirect_for_next_step(); |
1541 | 1541 | $this->checkout->continue_reg = false; |
1542 | 1542 | } |
1543 | 1543 | // Off-Site payment? |
1544 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1544 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1545 | 1545 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1546 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ){ |
|
1547 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1546 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1547 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1548 | 1548 | $this->checkout->redirect = TRUE; |
1549 | 1549 | $this->checkout->redirect_form = $payment->redirect_form(); |
1550 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1550 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1551 | 1551 | // set JSON response |
1552 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1552 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1553 | 1553 | // set cron job for finalizing the TXN |
1554 | 1554 | // in case the user does not return from the off-site gateway |
1555 | 1555 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1557,21 +1557,21 @@ discard block |
||
1557 | 1557 | $this->checkout->transaction->ID() |
1558 | 1558 | ); |
1559 | 1559 | // and lastly, let's bump the payment status to pending |
1560 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1560 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1561 | 1561 | $payment->save(); |
1562 | 1562 | } else { |
1563 | 1563 | // not a payment |
1564 | 1564 | $this->checkout->continue_reg = false; |
1565 | 1565 | EE_Error::add_error( |
1566 | 1566 | sprintf( |
1567 | - __( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1567 | + __('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1568 | 1568 | '<br/>', |
1569 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1569 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1570 | 1570 | ), __FILE__, __FUNCTION__, __LINE__ |
1571 | 1571 | ); |
1572 | 1572 | } |
1573 | 1573 | // Off-Line payment? |
1574 | - } else if ( $payment === TRUE ) { |
|
1574 | + } else if ($payment === TRUE) { |
|
1575 | 1575 | //$this->_setup_redirect_for_next_step(); |
1576 | 1576 | return TRUE; |
1577 | 1577 | } else { |
@@ -1607,65 +1607,65 @@ discard block |
||
1607 | 1607 | * @return bool |
1608 | 1608 | * @throws \EE_Error |
1609 | 1609 | */ |
1610 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1610 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1611 | 1611 | // off-line payment? carry on |
1612 | - if ( $payment_occurs == EE_PMT_Base::offline ) { |
|
1612 | + if ($payment_occurs == EE_PMT_Base::offline) { |
|
1613 | 1613 | return true; |
1614 | 1614 | } |
1615 | 1615 | // verify payment validity |
1616 | - if ( $payment instanceof EE_Payment ) { |
|
1617 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1616 | + if ($payment instanceof EE_Payment) { |
|
1617 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1618 | 1618 | $msg = $payment->gateway_response(); |
1619 | 1619 | // check results |
1620 | - switch ( $payment->status() ) { |
|
1620 | + switch ($payment->status()) { |
|
1621 | 1621 | |
1622 | 1622 | // good payment |
1623 | 1623 | case EEM_Payment::status_id_approved : |
1624 | - EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1624 | + EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1625 | 1625 | return TRUE; |
1626 | 1626 | break; |
1627 | 1627 | |
1628 | 1628 | // slow payment |
1629 | 1629 | case EEM_Payment::status_id_pending : |
1630 | - if ( empty( $msg )) { |
|
1631 | - $msg = __( 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso' ); |
|
1630 | + if (empty($msg)) { |
|
1631 | + $msg = __('Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso'); |
|
1632 | 1632 | } |
1633 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1633 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1634 | 1634 | return TRUE; |
1635 | 1635 | break; |
1636 | 1636 | |
1637 | 1637 | // don't wanna payment |
1638 | 1638 | case EEM_Payment::status_id_cancelled : |
1639 | - if ( empty( $msg )) { |
|
1639 | + if (empty($msg)) { |
|
1640 | 1640 | $msg = _n( |
1641 | 1641 | 'Payment cancelled. Please try again.', |
1642 | 1642 | 'Payment cancelled. Please try again or select another method of payment.', |
1643 | - count( $this->checkout->available_payment_methods ), |
|
1643 | + count($this->checkout->available_payment_methods), |
|
1644 | 1644 | 'event_espresso' |
1645 | 1645 | ); |
1646 | 1646 | } |
1647 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1647 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1648 | 1648 | return FALSE; |
1649 | 1649 | break; |
1650 | 1650 | |
1651 | 1651 | // not enough payment |
1652 | 1652 | case EEM_Payment::status_id_declined : |
1653 | - if ( empty( $msg )) { |
|
1653 | + if (empty($msg)) { |
|
1654 | 1654 | $msg = _n( |
1655 | 1655 | 'We\'re sorry but your payment was declined. Please try again.', |
1656 | 1656 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
1657 | - count( $this->checkout->available_payment_methods ), |
|
1657 | + count($this->checkout->available_payment_methods), |
|
1658 | 1658 | 'event_espresso' |
1659 | 1659 | ); |
1660 | 1660 | } |
1661 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1661 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1662 | 1662 | return FALSE; |
1663 | 1663 | break; |
1664 | 1664 | |
1665 | 1665 | // bad payment |
1666 | 1666 | case EEM_Payment::status_id_failed : |
1667 | - if ( ! empty( $msg ) ) { |
|
1668 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1667 | + if ( ! empty($msg)) { |
|
1668 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1669 | 1669 | return false; |
1670 | 1670 | } |
1671 | 1671 | // default to error below |
@@ -1675,14 +1675,14 @@ discard block |
||
1675 | 1675 | } |
1676 | 1676 | // off-site payment gateway responses are too unreliable, so let's just assume that |
1677 | 1677 | // the payment processing is just running slower than the registrant's request |
1678 | - if ( $payment_occurs == EE_PMT_Base::offsite ) { |
|
1678 | + if ($payment_occurs == EE_PMT_Base::offsite) { |
|
1679 | 1679 | return true; |
1680 | 1680 | } |
1681 | 1681 | EE_Error::add_error( |
1682 | 1682 | sprintf( |
1683 | - __( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1683 | + __('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1684 | 1684 | '<br/>', |
1685 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1685 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1686 | 1686 | ), |
1687 | 1687 | __FILE__, __FUNCTION__, __LINE__ |
1688 | 1688 | ); |
@@ -1715,13 +1715,13 @@ discard block |
||
1715 | 1715 | public function process_gateway_response() { |
1716 | 1716 | $payment = null; |
1717 | 1717 | // how have they chosen to pay? |
1718 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1718 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1719 | 1719 | // get EE_Payment_Method object |
1720 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1720 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1721 | 1721 | $this->checkout->continue_reg = false; |
1722 | 1722 | return false; |
1723 | 1723 | } |
1724 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
1724 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
1725 | 1725 | return false; |
1726 | 1726 | } |
1727 | 1727 | $this->_validate_offsite_return(); |
@@ -1735,23 +1735,23 @@ discard block |
||
1735 | 1735 | // true |
1736 | 1736 | //); |
1737 | 1737 | // verify TXN |
1738 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1738 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1739 | 1739 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
1740 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
1740 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
1741 | 1741 | $this->checkout->continue_reg = false; |
1742 | 1742 | return false; |
1743 | 1743 | } |
1744 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
1745 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
1746 | - $payment = $this->_validate_payment( $payment ); |
|
1744 | + $payment = $this->_process_off_site_payment($gateway); |
|
1745 | + $payment = $this->_process_cancelled_payments($payment); |
|
1746 | + $payment = $this->_validate_payment($payment); |
|
1747 | 1747 | // if payment was not declined by the payment gateway or cancelled by the registrant |
1748 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
1748 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
1749 | 1749 | //$this->_setup_redirect_for_next_step(); |
1750 | 1750 | // store that for later |
1751 | 1751 | $this->checkout->payment = $payment; |
1752 | 1752 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
1753 | 1753 | // because we will complete this step during the IPN processing then |
1754 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) { |
|
1754 | + if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) { |
|
1755 | 1755 | $this->set_completed(); |
1756 | 1756 | } |
1757 | 1757 | return true; |
@@ -1774,19 +1774,19 @@ discard block |
||
1774 | 1774 | * @return bool |
1775 | 1775 | */ |
1776 | 1776 | private function _validate_offsite_return() { |
1777 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
1778 | - if ( $TXN_ID != $this->checkout->transaction->ID() ) { |
|
1777 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
1778 | + if ($TXN_ID != $this->checkout->transaction->ID()) { |
|
1779 | 1779 | // Houston... we might have a problem |
1780 | 1780 | $invalid_TXN = false; |
1781 | 1781 | // first gather some info |
1782 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1782 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1783 | 1783 | $primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null; |
1784 | 1784 | // let's start by retrieving the cart for this TXN |
1785 | - $cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction ); |
|
1786 | - if ( $cart instanceof EE_Cart ) { |
|
1785 | + $cart = EE_Cart::get_cart_from_txn($this->checkout->transaction); |
|
1786 | + if ($cart instanceof EE_Cart) { |
|
1787 | 1787 | // verify that the current cart has tickets |
1788 | 1788 | $tickets = $cart->get_tickets(); |
1789 | - if ( empty( $tickets ) ) { |
|
1789 | + if (empty($tickets)) { |
|
1790 | 1790 | $invalid_TXN = true; |
1791 | 1791 | } |
1792 | 1792 | } else { |
@@ -1794,39 +1794,39 @@ discard block |
||
1794 | 1794 | } |
1795 | 1795 | $valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null; |
1796 | 1796 | // validate current Session ID and compare against valid TXN session ID |
1797 | - if ( EE_Session::instance()->id() === null ) { |
|
1797 | + if (EE_Session::instance()->id() === null) { |
|
1798 | 1798 | $invalid_TXN = true; |
1799 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
1799 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
1800 | 1800 | // WARNING !!! |
1801 | 1801 | // this could be PayPal sending back duplicate requests (ya they do that) |
1802 | 1802 | // or it **could** mean someone is simply registering AGAIN after having just done so |
1803 | 1803 | // so now we need to determine if this current TXN looks valid or not |
1804 | 1804 | /** @type EE_Transaction_Processor $transaction_processor */ |
1805 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1805 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1806 | 1806 | // has this step even been started ? |
1807 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
1807 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
1808 | 1808 | ) { |
1809 | 1809 | // really? you're half way through this reg step, but you never started it ? |
1810 | 1810 | $invalid_TXN = true; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | - if ( $invalid_TXN ) { |
|
1813 | + if ($invalid_TXN) { |
|
1814 | 1814 | // is the valid TXN completed ? |
1815 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
1815 | + if ($valid_TXN instanceof EE_Transaction) { |
|
1816 | 1816 | /** @type EE_Transaction_Processor $transaction_processor */ |
1817 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1817 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1818 | 1818 | // has this step even been started ? |
1819 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
1820 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
1819 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
1820 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
1821 | 1821 | // so it **looks** like this is a double request from PayPal |
1822 | 1822 | // so let's try to pick up where we left off |
1823 | 1823 | $this->checkout->transaction = $valid_TXN; |
1824 | - $this->checkout->refresh_all_entities( true ); |
|
1824 | + $this->checkout->refresh_all_entities(true); |
|
1825 | 1825 | return; |
1826 | 1826 | } |
1827 | 1827 | } |
1828 | 1828 | // you appear to be lost? |
1829 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
1829 | + $this->_redirect_wayward_request($primary_registrant); |
|
1830 | 1830 | } |
1831 | 1831 | } |
1832 | 1832 | } |
@@ -1840,16 +1840,16 @@ discard block |
||
1840 | 1840 | * @param \EE_Registration $primary_registrant |
1841 | 1841 | * @return bool |
1842 | 1842 | */ |
1843 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
1844 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1843 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
1844 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1845 | 1845 | // try redirecting based on the current TXN |
1846 | 1846 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null; |
1847 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1847 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1848 | 1848 | EE_Error::add_error( |
1849 | 1849 | sprintf( |
1850 | - __( 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1850 | + __('Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1851 | 1851 | '<br/>', |
1852 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1852 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1853 | 1853 | ), |
1854 | 1854 | __FILE__, __FUNCTION__, __LINE__ |
1855 | 1855 | ); |
@@ -1877,16 +1877,16 @@ discard block |
||
1877 | 1877 | * @param \EE_Offsite_Gateway $gateway |
1878 | 1878 | * @return \EE_Payment |
1879 | 1879 | */ |
1880 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
1880 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
1881 | 1881 | try { |
1882 | 1882 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
1883 | - if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) { |
|
1883 | + if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) { |
|
1884 | 1884 | $payment = $this->checkout->transaction->last_payment(); |
1885 | 1885 | //$payment_source = 'last_payment'; |
1886 | 1886 | } else { |
1887 | 1887 | // get payment details and process results |
1888 | 1888 | /** @type EE_Payment_Processor $payment_processor */ |
1889 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1889 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1890 | 1890 | $payment = $payment_processor->process_ipn( |
1891 | 1891 | $_REQUEST, |
1892 | 1892 | $this->checkout->transaction, |
@@ -1896,14 +1896,14 @@ discard block |
||
1896 | 1896 | ); |
1897 | 1897 | //$payment_source = 'process_ipn'; |
1898 | 1898 | } |
1899 | - } catch ( Exception $e ) { |
|
1899 | + } catch (Exception $e) { |
|
1900 | 1900 | // let's just eat the exception and try to move on using any previously set payment info |
1901 | 1901 | $payment = $this->checkout->transaction->last_payment(); |
1902 | 1902 | //$payment_source = 'last_payment after Exception'; |
1903 | 1903 | // but if we STILL don't have a payment object |
1904 | - if ( ! $payment instanceof EE_Payment ) { |
|
1904 | + if ( ! $payment instanceof EE_Payment) { |
|
1905 | 1905 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
1906 | - $this->_handle_payment_processor_exception( $e ); |
|
1906 | + $this->_handle_payment_processor_exception($e); |
|
1907 | 1907 | } |
1908 | 1908 | } |
1909 | 1909 | // DEBUG LOG |
@@ -1927,13 +1927,13 @@ discard block |
||
1927 | 1927 | * @param EE_Payment $payment |
1928 | 1928 | * @return EE_Payment | FALSE |
1929 | 1929 | */ |
1930 | - private function _process_cancelled_payments( $payment = NULL ) { |
|
1930 | + private function _process_cancelled_payments($payment = NULL) { |
|
1931 | 1931 | if ( |
1932 | - isset( $_REQUEST[ 'ee_cancel_payment' ] ) |
|
1932 | + isset($_REQUEST['ee_cancel_payment']) |
|
1933 | 1933 | && $payment instanceof EE_Payment |
1934 | 1934 | && $payment->status() == EEM_Payment::status_id_failed |
1935 | 1935 | ) { |
1936 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
1936 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
1937 | 1937 | } |
1938 | 1938 | return $payment; |
1939 | 1939 | } |
@@ -1950,23 +1950,23 @@ discard block |
||
1950 | 1950 | public function get_transaction_details_for_gateways() { |
1951 | 1951 | $txn_details = array(); |
1952 | 1952 | // ya gotta make a choice man |
1953 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1953 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1954 | 1954 | $txn_details = array( |
1955 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1955 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1956 | 1956 | ); |
1957 | 1957 | } |
1958 | 1958 | // get EE_Payment_Method object |
1959 | 1959 | if ( |
1960 | - empty( $txn_details ) && |
|
1960 | + empty($txn_details) && |
|
1961 | 1961 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
1962 | 1962 | ) { |
1963 | 1963 | $txn_details = array( |
1964 | 1964 | 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
1965 | - 'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' ) |
|
1965 | + 'error' => __('A valid Payment Method could not be determined.', 'event_espresso') |
|
1966 | 1966 | ); |
1967 | 1967 | } |
1968 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
1969 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
1968 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
1969 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
1970 | 1970 | $txn_details = array( |
1971 | 1971 | 'TXN_ID' => $this->checkout->transaction->ID(), |
1972 | 1972 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
1978 | 1978 | 'payment_amount' => $this->checkout->amount_owing, |
1979 | 1979 | 'return_url' => $return_url, |
1980 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
1980 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
1981 | 1981 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
1982 | 1982 | array( |
1983 | 1983 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -1986,7 +1986,7 @@ discard block |
||
1986 | 1986 | ) |
1987 | 1987 | ); |
1988 | 1988 | } |
1989 | - echo json_encode( $txn_details ); |
|
1989 | + echo json_encode($txn_details); |
|
1990 | 1990 | exit(); |
1991 | 1991 | } |
1992 | 1992 |