@@ -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 |
@@ -1,30 +1,30 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + */ |
|
15 | 15 | require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
16 | 16 | /** |
17 | - * |
|
18 | - * Class EEH_File |
|
19 | - * |
|
20 | - * Description |
|
21 | - * |
|
22 | - * @package Event Espresso |
|
23 | - * @subpackage core |
|
24 | - * @author Brent Christensen |
|
25 | - * @since $VID:$ |
|
26 | - * |
|
27 | - */ |
|
17 | + * |
|
18 | + * Class EEH_File |
|
19 | + * |
|
20 | + * Description |
|
21 | + * |
|
22 | + * @package Event Espresso |
|
23 | + * @subpackage core |
|
24 | + * @author Brent Christensen |
|
25 | + * @since $VID:$ |
|
26 | + * |
|
27 | + */ |
|
28 | 28 | class EEH_File extends EEH_Base { |
29 | 29 | |
30 | 30 | /** |
@@ -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 |
@@ -1301,8 +1301,8 @@ discard block |
||
1301 | 1301 | * verifies user access for this admin page |
1302 | 1302 | * @param string $route_to_check if present then the capability for the route matching this string is checked. |
1303 | 1303 | * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
1304 | - * @return BOOL|wp_die() |
|
1305 | - */ |
|
1304 | + * @return BOOL|wp_die() |
|
1305 | + */ |
|
1306 | 1306 | public function check_user_access( $route_to_check = '', $verify_only = FALSE ) { |
1307 | 1307 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1308 | 1308 | $route_to_check = empty( $route_to_check ) ? $this->_req_action : $route_to_check; |
@@ -1703,11 +1703,11 @@ discard block |
||
1703 | 1703 | |
1704 | 1704 | |
1705 | 1705 | /** |
1706 | - * admin_footer_scripts_eei18n_js_strings |
|
1707 | - * |
|
1708 | - * @access public |
|
1709 | - * @return void |
|
1710 | - */ |
|
1706 | + * admin_footer_scripts_eei18n_js_strings |
|
1707 | + * |
|
1708 | + * @access public |
|
1709 | + * @return void |
|
1710 | + */ |
|
1711 | 1711 | public function admin_footer_scripts_eei18n_js_strings() { |
1712 | 1712 | |
1713 | 1713 | EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
@@ -1763,11 +1763,11 @@ discard block |
||
1763 | 1763 | |
1764 | 1764 | |
1765 | 1765 | /** |
1766 | - * load enhanced xdebug styles for ppl with failing eyesight |
|
1767 | - * |
|
1768 | - * @access public |
|
1769 | - * @return void |
|
1770 | - */ |
|
1766 | + * load enhanced xdebug styles for ppl with failing eyesight |
|
1767 | + * |
|
1768 | + * @access public |
|
1769 | + * @return void |
|
1770 | + */ |
|
1771 | 1771 | public function add_xdebug_style() { |
1772 | 1772 | echo '<style>.xdebug-error { font-size:1.5em; }</style>'; |
1773 | 1773 | } |
@@ -1824,9 +1824,9 @@ discard block |
||
1824 | 1824 | |
1825 | 1825 | /** |
1826 | 1826 | * set current view for List Table |
1827 | - * @access public |
|
1828 | - * @return array |
|
1829 | - */ |
|
1827 | + * @access public |
|
1828 | + * @return array |
|
1829 | + */ |
|
1830 | 1830 | protected function _set_list_table_view() { |
1831 | 1831 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1832 | 1832 | |
@@ -1903,7 +1903,7 @@ discard block |
||
1903 | 1903 | * @access protected |
1904 | 1904 | * @param int $max_entries total number of rows in the table |
1905 | 1905 | * @return string |
1906 | - */ |
|
1906 | + */ |
|
1907 | 1907 | protected function _entries_per_page_dropdown( $max_entries = FALSE ) { |
1908 | 1908 | |
1909 | 1909 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -1948,9 +1948,9 @@ discard block |
||
1948 | 1948 | |
1949 | 1949 | /** |
1950 | 1950 | * _set_search_attributes |
1951 | - * @access protected |
|
1952 | - * @return void |
|
1953 | - */ |
|
1951 | + * @access protected |
|
1952 | + * @return void |
|
1953 | + */ |
|
1954 | 1954 | public function _set_search_attributes() { |
1955 | 1955 | $this->_template_args['search']['btn_label'] = sprintf( __( 'Search %s', 'event_espresso' ), empty( $this->_search_btn_label ) ? $this->page_label : $this->_search_btn_label ); |
1956 | 1956 | $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
@@ -1970,7 +1970,7 @@ discard block |
||
1970 | 1970 | * @link http://codex.wordpress.org/Function_Reference/add_meta_box |
1971 | 1971 | * @access private |
1972 | 1972 | * @return void |
1973 | - */ |
|
1973 | + */ |
|
1974 | 1974 | private function _add_registered_meta_boxes() { |
1975 | 1975 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1976 | 1976 | |
@@ -2230,9 +2230,9 @@ discard block |
||
2230 | 2230 | |
2231 | 2231 | /** |
2232 | 2232 | * displays an error message to ppl who have javascript disabled |
2233 | - * @access private |
|
2234 | - * @return string |
|
2235 | - */ |
|
2233 | + * @access private |
|
2234 | + * @return string |
|
2235 | + */ |
|
2236 | 2236 | private function _display_no_javascript_warning() { |
2237 | 2237 | ?> |
2238 | 2238 | <noscript> |
@@ -2255,9 +2255,9 @@ discard block |
||
2255 | 2255 | |
2256 | 2256 | /** |
2257 | 2257 | * displays espresso success and/or error notices |
2258 | - * @access private |
|
2259 | - * @return string |
|
2260 | - */ |
|
2258 | + * @access private |
|
2259 | + * @return string |
|
2260 | + */ |
|
2261 | 2261 | private function _display_espresso_notices() { |
2262 | 2262 | $notices = $this->_get_transient( TRUE ); |
2263 | 2263 | echo stripslashes($notices); |
@@ -2269,10 +2269,10 @@ discard block |
||
2269 | 2269 | |
2270 | 2270 | |
2271 | 2271 | /** |
2272 | - * spinny things pacify the masses |
|
2273 | - * @access private |
|
2274 | - * @return string |
|
2275 | - */ |
|
2272 | + * spinny things pacify the masses |
|
2273 | + * @access private |
|
2274 | + * @return string |
|
2275 | + */ |
|
2276 | 2276 | protected function _add_admin_page_ajax_loading_img() { |
2277 | 2277 | ?> |
2278 | 2278 | <div id="espresso-ajax-loading" class="ajax-loading-grey"> |
@@ -2286,10 +2286,10 @@ discard block |
||
2286 | 2286 | |
2287 | 2287 | |
2288 | 2288 | /** |
2289 | - * add admin page overlay for modal boxes |
|
2290 | - * @access private |
|
2291 | - * @return string |
|
2292 | - */ |
|
2289 | + * add admin page overlay for modal boxes |
|
2290 | + * @access private |
|
2291 | + * @return string |
|
2292 | + */ |
|
2293 | 2293 | protected function _add_admin_page_overlay() { |
2294 | 2294 | ?> |
2295 | 2295 | <div id="espresso-admin-page-overlay-dv" class=""></div> |
@@ -2351,10 +2351,10 @@ discard block |
||
2351 | 2351 | |
2352 | 2352 | |
2353 | 2353 | /** |
2354 | - * generates HTML wrapper for an admin details page |
|
2355 | - * @access public |
|
2356 | - * @return void |
|
2357 | - */ |
|
2354 | + * generates HTML wrapper for an admin details page |
|
2355 | + * @access public |
|
2356 | + * @return void |
|
2357 | + */ |
|
2358 | 2358 | public function display_admin_page_with_sidebar() { |
2359 | 2359 | |
2360 | 2360 | $this->_display_admin_page(TRUE); |
@@ -2364,10 +2364,10 @@ discard block |
||
2364 | 2364 | |
2365 | 2365 | |
2366 | 2366 | /** |
2367 | - * generates HTML wrapper for an admin details page (except no sidebar) |
|
2368 | - * @access public |
|
2369 | - * @return void |
|
2370 | - */ |
|
2367 | + * generates HTML wrapper for an admin details page (except no sidebar) |
|
2368 | + * @access public |
|
2369 | + * @return void |
|
2370 | + */ |
|
2371 | 2371 | public function display_admin_page_with_no_sidebar() { |
2372 | 2372 | $this->_display_admin_page(); |
2373 | 2373 | } |
@@ -2591,11 +2591,11 @@ discard block |
||
2591 | 2591 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
2592 | 2592 | if ( NULL === error_get_last() || ! headers_sent() ) |
2593 | 2593 | header('Content-Type: application/json; charset=UTF-8'); |
2594 | - if( function_exists( 'wp_json_encode' ) ) { |
|
2595 | - echo wp_json_encode( $json ); |
|
2596 | - } else { |
|
2597 | - echo json_encode( $json ); |
|
2598 | - } |
|
2594 | + if( function_exists( 'wp_json_encode' ) ) { |
|
2595 | + echo wp_json_encode( $json ); |
|
2596 | + } else { |
|
2597 | + echo json_encode( $json ); |
|
2598 | + } |
|
2599 | 2599 | exit(); |
2600 | 2600 | } |
2601 | 2601 | |
@@ -2634,11 +2634,11 @@ discard block |
||
2634 | 2634 | |
2635 | 2635 | |
2636 | 2636 | /** |
2637 | - * generates HTML wrapper with Tabbed nav for an admin page |
|
2638 | - * @access public |
|
2639 | - * @param boolean $about whether to use the special about page wrapper or default. |
|
2640 | - * @return void |
|
2641 | - */ |
|
2637 | + * generates HTML wrapper with Tabbed nav for an admin page |
|
2638 | + * @access public |
|
2639 | + * @param boolean $about whether to use the special about page wrapper or default. |
|
2640 | + * @return void |
|
2641 | + */ |
|
2642 | 2642 | public function admin_page_wrapper($about = FALSE) { |
2643 | 2643 | |
2644 | 2644 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -2692,15 +2692,15 @@ discard block |
||
2692 | 2692 | |
2693 | 2693 | |
2694 | 2694 | /** |
2695 | - * sort nav tabs |
|
2696 | - * @access public |
|
2697 | - * @return void |
|
2698 | - */ |
|
2695 | + * sort nav tabs |
|
2696 | + * @access public |
|
2697 | + * @return void |
|
2698 | + */ |
|
2699 | 2699 | private function _sort_nav_tabs( $a, $b ) { |
2700 | 2700 | if ($a['order'] == $b['order']) { |
2701 | - return 0; |
|
2702 | - } |
|
2703 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
2701 | + return 0; |
|
2702 | + } |
|
2703 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
2704 | 2704 | } |
2705 | 2705 | |
2706 | 2706 |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | * @access public |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - public function __construct( $routing = TRUE ) { |
|
147 | + public function __construct($routing = TRUE) { |
|
148 | 148 | |
149 | - if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) |
|
149 | + if (strpos($this->_get_dir(), 'caffeinated') !== false) |
|
150 | 150 | $this->_is_caf = TRUE; |
151 | 151 | |
152 | 152 | $this->_yes_no_values = array( |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | |
159 | 159 | //set the _req_data property. |
160 | - $this->_req_data = array_merge( $_GET, $_POST ); |
|
160 | + $this->_req_data = array_merge($_GET, $_POST); |
|
161 | 161 | |
162 | 162 | |
163 | 163 | //routing enabled? |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->_do_other_page_hooks(); |
179 | 179 | |
180 | 180 | //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
181 | - if ( method_exists( $this, '_before_page_setup' ) ) |
|
181 | + if (method_exists($this, '_before_page_setup')) |
|
182 | 182 | $this->_before_page_setup(); |
183 | 183 | |
184 | 184 | //set up page dependencies |
@@ -448,16 +448,16 @@ discard block |
||
448 | 448 | */ |
449 | 449 | protected function _global_ajax_hooks() { |
450 | 450 | //for lazy loading of metabox content |
451 | - add_action( 'wp_ajax_espresso-ajax-content', array( $this, 'ajax_metabox_content'), 10 ); |
|
451 | + add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | |
455 | 455 | |
456 | 456 | public function ajax_metabox_content() { |
457 | - $contentid = isset( $this->_req_data['contentid'] ) ? $this->_req_data['contentid'] : ''; |
|
458 | - $url = isset( $this->_req_data['contenturl'] ) ? $this->_req_data['contenturl'] : ''; |
|
457 | + $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : ''; |
|
458 | + $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : ''; |
|
459 | 459 | |
460 | - self::cached_rss_display( $contentid, $url ); |
|
460 | + self::cached_rss_display($contentid, $url); |
|
461 | 461 | wp_die(); |
462 | 462 | } |
463 | 463 | |
@@ -478,87 +478,87 @@ discard block |
||
478 | 478 | |
479 | 479 | |
480 | 480 | //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can. But keep in mind, not everything is available from the EE_Admin Page object at this point. |
481 | - add_action( 'admin_init', array( $this, 'admin_init_global' ), 5 ); |
|
481 | + add_action('admin_init', array($this, 'admin_init_global'), 5); |
|
482 | 482 | |
483 | 483 | |
484 | 484 | //next verify if we need to load anything... |
485 | - $this->_current_page = !empty( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : FALSE; |
|
486 | - $this->page_folder = strtolower( str_replace( '_Admin_Page', '', str_replace( 'Extend_', '', get_class($this) ) ) ); |
|
485 | + $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : FALSE; |
|
486 | + $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
|
487 | 487 | |
488 | 488 | global $ee_menu_slugs; |
489 | 489 | $ee_menu_slugs = (array) $ee_menu_slugs; |
490 | 490 | |
491 | - if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) return FALSE; |
|
491 | + if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) return FALSE; |
|
492 | 492 | |
493 | 493 | |
494 | 494 | // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
495 | - if ( isset( $this->_req_data['action2'] ) && $this->_req_data['action'] == -1 ) { |
|
496 | - $this->_req_data['action'] = ! empty( $this->_req_data['action2'] ) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
495 | + if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) { |
|
496 | + $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
497 | 497 | } |
498 | 498 | // then set blank or -1 action values to 'default' |
499 | - $this->_req_action = isset( $this->_req_data['action'] ) && ! empty( $this->_req_data['action'] ) && $this->_req_data['action'] != -1 ? sanitize_key( $this->_req_data['action'] ) : 'default'; |
|
499 | + $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default'; |
|
500 | 500 | |
501 | 501 | //if action is 'default' after the above BUT we have 'route' var set, then let's use the route as the action. This covers cases where we're coming in from a list table that isn't on the default route. |
502 | - $this->_req_action = $this->_req_action == 'default' && isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : $this->_req_action; |
|
502 | + $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
503 | 503 | |
504 | 504 | //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
505 | 505 | $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
506 | 506 | |
507 | 507 | $this->_current_view = $this->_req_action; |
508 | - $this->_req_nonce = $this->_req_action . '_nonce'; |
|
508 | + $this->_req_nonce = $this->_req_action.'_nonce'; |
|
509 | 509 | $this->_define_page_props(); |
510 | 510 | |
511 | - $this->_current_page_view_url = add_query_arg( array( 'page' => $this->_current_page, 'action' => $this->_current_view ), $this->_admin_base_url ); |
|
511 | + $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
|
512 | 512 | |
513 | 513 | //default things |
514 | - $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box' ); |
|
514 | + $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box'); |
|
515 | 515 | |
516 | 516 | //set page configs |
517 | 517 | $this->_set_page_routes(); |
518 | 518 | $this->_set_page_config(); |
519 | 519 | |
520 | 520 | //let's include any referrer data in our default_query_args for this route for "stickiness". |
521 | - if ( isset( $this->_req_data['wp_referer'] ) ) { |
|
521 | + if (isset($this->_req_data['wp_referer'])) { |
|
522 | 522 | $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer']; |
523 | 523 | } |
524 | 524 | |
525 | 525 | //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
526 | - if ( method_exists( $this, '_extend_page_config' ) ) |
|
526 | + if (method_exists($this, '_extend_page_config')) |
|
527 | 527 | $this->_extend_page_config(); |
528 | 528 | |
529 | 529 | //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
530 | - if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) |
|
530 | + if (method_exists($this, '_extend_page_config_for_cpt')) |
|
531 | 531 | $this->_extend_page_config_for_cpt(); |
532 | 532 | |
533 | 533 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
534 | - $this->_page_routes = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this ); |
|
535 | - $this->_page_config = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this ); |
|
534 | + $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this); |
|
535 | + $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this); |
|
536 | 536 | |
537 | 537 | |
538 | 538 | //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
539 | - if ( method_exists( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ) ) { |
|
540 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ), 10, 2 ); |
|
539 | + if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) { |
|
540 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
544 | 544 | //next route only if routing enabled |
545 | - if ( $this->_routing && !defined('DOING_AJAX') ) { |
|
545 | + if ($this->_routing && ! defined('DOING_AJAX')) { |
|
546 | 546 | |
547 | 547 | $this->_verify_routes(); |
548 | 548 | |
549 | 549 | //next let's just check user_access and kill if no access |
550 | 550 | $this->check_user_access(); |
551 | 551 | |
552 | - if ( $this->_is_UI_request ) { |
|
552 | + if ($this->_is_UI_request) { |
|
553 | 553 | //admin_init stuff - global, all views for this page class, specific view |
554 | - add_action( 'admin_init', array( $this, 'admin_init' ), 10 ); |
|
555 | - if ( method_exists( $this, 'admin_init_' . $this->_current_view )) { |
|
556 | - add_action( 'admin_init', array( $this, 'admin_init_' . $this->_current_view ), 15 ); |
|
554 | + add_action('admin_init', array($this, 'admin_init'), 10); |
|
555 | + if (method_exists($this, 'admin_init_'.$this->_current_view)) { |
|
556 | + add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | } else { |
560 | 560 | //hijack regular WP loading and route admin request immediately |
561 | - @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
561 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
562 | 562 | $this->route_admin_request(); |
563 | 563 | } |
564 | 564 | } |
@@ -575,18 +575,18 @@ discard block |
||
575 | 575 | * @return void |
576 | 576 | */ |
577 | 577 | private function _do_other_page_hooks() { |
578 | - $registered_pages = apply_filters( 'FHEE_do_other_page_hooks_' . $this->page_slug, array() ); |
|
578 | + $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array()); |
|
579 | 579 | |
580 | - foreach ( $registered_pages as $page ) { |
|
580 | + foreach ($registered_pages as $page) { |
|
581 | 581 | |
582 | 582 | //now let's setup the file name and class that should be present |
583 | 583 | $classname = str_replace('.class.php', '', $page); |
584 | 584 | |
585 | 585 | //autoloaders should take care of loading file |
586 | - if ( !class_exists( $classname ) ) { |
|
587 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s admin hooks page.', 'event_espresso' ), $page); |
|
588 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname ); |
|
589 | - throw new EE_Error( implode( '||', $error_msg )); |
|
586 | + if ( ! class_exists($classname)) { |
|
587 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
588 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname); |
|
589 | + throw new EE_Error(implode('||', $error_msg)); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | $a = new ReflectionClass($classname); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | public function load_page_dependencies() { |
602 | 602 | try { |
603 | 603 | $this->_load_page_dependencies(); |
604 | - } catch ( EE_Error $e ) { |
|
604 | + } catch (EE_Error $e) { |
|
605 | 605 | $e->get_error(); |
606 | 606 | } |
607 | 607 | } |
@@ -619,16 +619,16 @@ discard block |
||
619 | 619 | $this->_current_screen = get_current_screen(); |
620 | 620 | |
621 | 621 | //load admin_notices - global, page class, and view specific |
622 | - add_action( 'admin_notices', array( $this, 'admin_notices_global'), 5 ); |
|
623 | - add_action( 'admin_notices', array( $this, 'admin_notices' ), 10 ); |
|
624 | - if ( method_exists( $this, 'admin_notices_' . $this->_current_view ) ) { |
|
625 | - add_action( 'admin_notices', array( $this, 'admin_notices_' . $this->_current_view ), 15 ); |
|
622 | + add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
|
623 | + add_action('admin_notices', array($this, 'admin_notices'), 10); |
|
624 | + if (method_exists($this, 'admin_notices_'.$this->_current_view)) { |
|
625 | + add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | //load network admin_notices - global, page class, and view specific |
629 | - add_action( 'network_admin_notices', array( $this, 'network_admin_notices_global'), 5 ); |
|
630 | - if ( method_exists( $this, 'network_admin_notices_' . $this->_current_view ) ) { |
|
631 | - add_action( 'network_admin_notices', array( $this, 'network_admin_notices_' . $this->_current_view ) ); |
|
629 | + add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
|
630 | + if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) { |
|
631 | + add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view)); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | //this will save any per_page screen options if they are present |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | //add screen options - global, page child class, and view specific |
645 | 645 | $this->_add_global_screen_options(); |
646 | 646 | $this->_add_screen_options(); |
647 | - if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) |
|
648 | - call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
647 | + if (method_exists($this, '_add_screen_options_'.$this->_current_view)) |
|
648 | + call_user_func(array($this, '_add_screen_options_'.$this->_current_view)); |
|
649 | 649 | |
650 | 650 | |
651 | 651 | //add help tab(s) and tours- set via page_config and qtips. |
@@ -656,33 +656,33 @@ discard block |
||
656 | 656 | //add feature_pointers - global, page child class, and view specific |
657 | 657 | $this->_add_feature_pointers(); |
658 | 658 | $this->_add_global_feature_pointers(); |
659 | - if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) |
|
660 | - call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
659 | + if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) |
|
660 | + call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view)); |
|
661 | 661 | |
662 | 662 | //enqueue scripts/styles - global, page class, and view specific |
663 | - add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5 ); |
|
664 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10 ); |
|
665 | - if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) |
|
666 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
663 | + add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
|
664 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
|
665 | + if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) |
|
666 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15); |
|
667 | 667 | |
668 | - add_action('admin_enqueue_scripts', array( $this, 'admin_footer_scripts_eei18n_js_strings' ), 100 ); |
|
668 | + add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
|
669 | 669 | |
670 | 670 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
671 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_global' ), 99 ); |
|
672 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), 100 ); |
|
673 | - if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) |
|
674 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
671 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
|
672 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
|
673 | + if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) |
|
674 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101); |
|
675 | 675 | |
676 | 676 | //admin footer scripts |
677 | - add_action('admin_footer', array( $this, 'admin_footer_global' ), 99 ); |
|
678 | - add_action('admin_footer', array( $this, 'admin_footer'), 100 ); |
|
679 | - if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) |
|
680 | - add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
677 | + add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
|
678 | + add_action('admin_footer', array($this, 'admin_footer'), 100); |
|
679 | + if (method_exists($this, 'admin_footer_'.$this->_current_view)) |
|
680 | + add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101); |
|
681 | 681 | |
682 | 682 | |
683 | - do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug ); |
|
683 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
|
684 | 684 | //targeted hook |
685 | - do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action ); |
|
685 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action); |
|
686 | 686 | |
687 | 687 | } |
688 | 688 | |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | private function _set_defaults() { |
698 | 698 | $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = NULL; |
699 | 699 | |
700 | - $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
700 | + $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
701 | 701 | |
702 | 702 | $this->default_nav_tab_name = 'overview'; |
703 | 703 | |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | public function route_admin_request() { |
725 | 725 | try { |
726 | 726 | $this->_route_admin_request(); |
727 | - } catch ( EE_Error $e ) { |
|
727 | + } catch (EE_Error $e) { |
|
728 | 728 | $e->get_error(); |
729 | 729 | } |
730 | 730 | } |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $this->_wp_page_slug = $wp_page_slug; |
736 | 736 | |
737 | 737 | //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls... |
738 | - if ( is_network_admin() ) { |
|
738 | + if (is_network_admin()) { |
|
739 | 739 | $this->_wp_page_slug .= '-network'; |
740 | 740 | } |
741 | 741 | } |
@@ -748,53 +748,53 @@ discard block |
||
748 | 748 | * @return void |
749 | 749 | */ |
750 | 750 | protected function _verify_routes() { |
751 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
751 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
752 | 752 | |
753 | - if ( !$this->_current_page && !defined( 'DOING_AJAX')) return FALSE; |
|
753 | + if ( ! $this->_current_page && ! defined('DOING_AJAX')) return FALSE; |
|
754 | 754 | |
755 | 755 | $this->_route = FALSE; |
756 | 756 | $func = FALSE; |
757 | 757 | $args = array(); |
758 | 758 | |
759 | 759 | // check that the page_routes array is not empty |
760 | - if ( empty( $this->_page_routes )) { |
|
760 | + if (empty($this->_page_routes)) { |
|
761 | 761 | // user error msg |
762 | - $error_msg = sprintf( __('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title ); |
|
762 | + $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
763 | 763 | // developer error msg |
764 | - $error_msg .= '||' . $error_msg . __( ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso' ); |
|
765 | - throw new EE_Error( $error_msg ); |
|
764 | + $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
765 | + throw new EE_Error($error_msg); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | // and that the requested page route exists |
769 | - if ( array_key_exists( $this->_req_action, $this->_page_routes )) { |
|
770 | - $this->_route = $this->_page_routes[ $this->_req_action ]; |
|
769 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
770 | + $this->_route = $this->_page_routes[$this->_req_action]; |
|
771 | 771 | $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array(); |
772 | 772 | } else { |
773 | 773 | // user error msg |
774 | - $error_msg = sprintf( __( 'The requested page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
774 | + $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
775 | 775 | // developer error msg |
776 | - $error_msg .= '||' . $error_msg . sprintf( __( ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso' ), $this->_req_action ); |
|
777 | - throw new EE_Error( $error_msg ); |
|
776 | + $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
777 | + throw new EE_Error($error_msg); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | // and that a default route exists |
781 | - if ( ! array_key_exists( 'default', $this->_page_routes )) { |
|
781 | + if ( ! array_key_exists('default', $this->_page_routes)) { |
|
782 | 782 | // user error msg |
783 | - $error_msg = sprintf( __( 'A default page route has not been set for the % admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
783 | + $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
|
784 | 784 | // developer error msg |
785 | - $error_msg .= '||' . $error_msg . __( ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso' ); |
|
786 | - throw new EE_Error( $error_msg ); |
|
785 | + $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
786 | + throw new EE_Error($error_msg); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | |
790 | 790 | //first lets' catch if the UI request has EVER been set. |
791 | - if ( $this->_is_UI_request === NULL ) { |
|
791 | + if ($this->_is_UI_request === NULL) { |
|
792 | 792 | //lets set if this is a UI request or not. |
793 | - $this->_is_UI_request = ( ! isset( $this->_req_data['noheader'] ) || $this->_req_data['noheader'] !== TRUE ) ? TRUE : FALSE; |
|
793 | + $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== TRUE) ? TRUE : FALSE; |
|
794 | 794 | |
795 | 795 | |
796 | 796 | //wait a minute... we might have a noheader in the route array |
797 | - $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader'] ) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request; |
|
797 | + $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request; |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | $this->_set_current_labels(); |
@@ -809,15 +809,15 @@ discard block |
||
809 | 809 | * @param string $route the route name we're verifying |
810 | 810 | * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
811 | 811 | */ |
812 | - protected function _verify_route( $route ) { |
|
813 | - if ( array_key_exists( $this->_req_action, $this->_page_routes )) { |
|
812 | + protected function _verify_route($route) { |
|
813 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
814 | 814 | return true; |
815 | 815 | } else { |
816 | 816 | // user error msg |
817 | - $error_msg = sprintf( __( 'The given page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
817 | + $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
818 | 818 | // developer error msg |
819 | - $error_msg .= '||' . $error_msg . sprintf( __( ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso' ), $route ); |
|
820 | - throw new EE_Error( $error_msg ); |
|
819 | + $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
820 | + throw new EE_Error($error_msg); |
|
821 | 821 | } |
822 | 822 | } |
823 | 823 | |
@@ -831,18 +831,18 @@ discard block |
||
831 | 831 | * @param string $nonce_ref The nonce reference string (name0) |
832 | 832 | * @return mixed (bool|die) |
833 | 833 | */ |
834 | - protected function _verify_nonce( $nonce, $nonce_ref ) { |
|
834 | + protected function _verify_nonce($nonce, $nonce_ref) { |
|
835 | 835 | // verify nonce against expected value |
836 | - if ( ! wp_verify_nonce( $nonce, $nonce_ref) ) { |
|
836 | + if ( ! wp_verify_nonce($nonce, $nonce_ref)) { |
|
837 | 837 | // these are not the droids you are looking for !!! |
838 | - $msg = sprintf(__('%sNonce Fail.%s' , 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>' ); |
|
839 | - if ( WP_DEBUG ) { |
|
840 | - $msg .= "\n " . sprintf( __('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso' ), __CLASS__ ); |
|
838 | + $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
|
839 | + if (WP_DEBUG) { |
|
840 | + $msg .= "\n ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
841 | 841 | } |
842 | - if ( ! defined( 'DOING_AJAX' )) { |
|
843 | - wp_die( $msg ); |
|
842 | + if ( ! defined('DOING_AJAX')) { |
|
843 | + wp_die($msg); |
|
844 | 844 | } else { |
845 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
845 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
846 | 846 | $this->_return_json(); |
847 | 847 | } |
848 | 848 | } |
@@ -860,63 +860,63 @@ discard block |
||
860 | 860 | * @return void |
861 | 861 | */ |
862 | 862 | protected function _route_admin_request() { |
863 | - if ( ! $this->_is_UI_request ) |
|
863 | + if ( ! $this->_is_UI_request) |
|
864 | 864 | $this->_verify_routes(); |
865 | 865 | |
866 | - $nonce_check = isset( $this->_route_config['require_nonce'] ) ? $this->_route_config['require_nonce'] : TRUE; |
|
866 | + $nonce_check = isset($this->_route_config['require_nonce']) ? $this->_route_config['require_nonce'] : TRUE; |
|
867 | 867 | |
868 | - if ( $this->_req_action != 'default' && $nonce_check ) { |
|
868 | + if ($this->_req_action != 'default' && $nonce_check) { |
|
869 | 869 | // set nonce from post data |
870 | - $nonce = isset($this->_req_data[ $this->_req_nonce ]) ? sanitize_text_field( $this->_req_data[ $this->_req_nonce ] ) : ''; |
|
871 | - $this->_verify_nonce( $nonce, $this->_req_nonce ); |
|
870 | + $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
871 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
872 | 872 | } |
873 | 873 | //set the nav_tabs array but ONLY if this is UI_request |
874 | - if ( $this->_is_UI_request ) |
|
874 | + if ($this->_is_UI_request) |
|
875 | 875 | $this->_set_nav_tabs(); |
876 | 876 | |
877 | 877 | // grab callback function |
878 | - $func = is_array( $this->_route ) ? $this->_route['func'] : $this->_route; |
|
878 | + $func = is_array($this->_route) ? $this->_route['func'] : $this->_route; |
|
879 | 879 | |
880 | 880 | // check if callback has args |
881 | - $args = is_array( $this->_route ) && isset( $this->_route['args'] ) ? $this->_route['args'] : array(); |
|
881 | + $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array(); |
|
882 | 882 | |
883 | 883 | $error_msg = ''; |
884 | 884 | |
885 | 885 | //action right before calling route (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request') |
886 | - if ( !did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
887 | - do_action( 'AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this ); |
|
886 | + if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
887 | + do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | //right before calling the route, let's remove _wp_http_referer from the $_SERVER[REQUEST_URI] global (its now in _req_data for route processing). |
891 | - $_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
891 | + $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI'])); |
|
892 | 892 | |
893 | - if ( ! empty( $func )) { |
|
893 | + if ( ! empty($func)) { |
|
894 | 894 | $base_call = $addon_call = FALSE; |
895 | 895 | //try to access page route via this class |
896 | - if ( ! is_array( $func ) && method_exists( $this, $func ) && ( $base_call = call_user_func_array( array( $this, &$func ), $args ) ) === FALSE ) { |
|
896 | + if ( ! is_array($func) && method_exists($this, $func) && ($base_call = call_user_func_array(array($this, &$func), $args)) === FALSE) { |
|
897 | 897 | // user error msg |
898 | - $error_msg = __( 'An error occurred. The requested page route could not be found.', 'event_espresso' ); |
|
898 | + $error_msg = __('An error occurred. The requested page route could not be found.', 'event_espresso'); |
|
899 | 899 | // developer error msg |
900 | - $error_msg .= '||' . sprintf( __( 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso' ), $func ); |
|
900 | + $error_msg .= '||'.sprintf(__('Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso'), $func); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | //for pluggability by addons first let's see if just the function exists (this will also work in the case where $func is an array indicating class/method) |
904 | 904 | $args['admin_page_object'] = $this; //send along this admin page object for access by addons. |
905 | 905 | |
906 | - if ( $base_call === FALSE && ( $addon_call = call_user_func_array( $func, $args ) )=== FALSE ) { |
|
907 | - $error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso' ); |
|
908 | - $error_msg .= '||' . sprintf( __('Page route "%s" could not be called. Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func ); |
|
906 | + if ($base_call === FALSE && ($addon_call = call_user_func_array($func, $args)) === FALSE) { |
|
907 | + $error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso'); |
|
908 | + $error_msg .= '||'.sprintf(__('Page route "%s" could not be called. Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | |
912 | - if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) |
|
913 | - throw new EE_Error( $error_msg ); |
|
912 | + if ( ! empty($error_msg) && $base_call === FALSE && $addon_call === FALSE) |
|
913 | + throw new EE_Error($error_msg); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
917 | 917 | //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent. |
918 | - if ( $this->_is_UI_request === FALSE && is_array( $this->_route) && ! empty( $this->_route['headers_sent_route'] ) ) { |
|
919 | - $this->_reset_routing_properties( $this->_route['headers_sent_route'] ); |
|
918 | + if ($this->_is_UI_request === FALSE && is_array($this->_route) && ! empty($this->_route['headers_sent_route'])) { |
|
919 | + $this->_reset_routing_properties($this->_route['headers_sent_route']); |
|
920 | 920 | } |
921 | 921 | } |
922 | 922 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @param string $new_route New (non header) route to redirect to. |
933 | 933 | * @return void |
934 | 934 | */ |
935 | - protected function _reset_routing_properties( $new_route ) { |
|
935 | + protected function _reset_routing_properties($new_route) { |
|
936 | 936 | $this->_is_UI_request = TRUE; |
937 | 937 | //now we set the current route to whatever the headers_sent_route is set at |
938 | 938 | $this->_req_data['action'] = $new_route; |
@@ -978,24 +978,24 @@ discard block |
||
978 | 978 | * @param bool $exclude_nonce If true, the the nonce will be excluded from the generated nonce. |
979 | 979 | * @return string |
980 | 980 | */ |
981 | - public static function add_query_args_and_nonce( $args = array(), $url = false, $sticky = false, $exclude_nonce = false ) { |
|
981 | + public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) { |
|
982 | 982 | EE_Registry::instance()->load_helper('URL'); |
983 | 983 | |
984 | 984 | //if there is a _wp_http_referer include the values from the request but only if sticky = true |
985 | - if ( $sticky ) { |
|
985 | + if ($sticky) { |
|
986 | 986 | $request = $_REQUEST; |
987 | - unset( $request['_wp_http_referer'] ); |
|
988 | - unset( $request['wp_referer'] ); |
|
989 | - foreach ( $request as $key => $value ) { |
|
987 | + unset($request['_wp_http_referer']); |
|
988 | + unset($request['wp_referer']); |
|
989 | + foreach ($request as $key => $value) { |
|
990 | 990 | //do not add nonces |
991 | - if ( strpos( $key, 'nonce' ) !== false ) { |
|
991 | + if (strpos($key, 'nonce') !== false) { |
|
992 | 992 | continue; |
993 | 993 | } |
994 | - $args['wp_referer[' . $key . ']'] = $value; |
|
994 | + $args['wp_referer['.$key.']'] = $value; |
|
995 | 995 | } |
996 | 996 | } |
997 | 997 | |
998 | - return EEH_URL::add_query_args_and_nonce( $args, $url, $exclude_nonce ); |
|
998 | + return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | * @uses EEH_Template::get_help_tab_link() |
1012 | 1012 | * @return string generated link |
1013 | 1013 | */ |
1014 | - protected function _get_help_tab_link( $help_tab_id, $icon_style = FALSE, $help_text = FALSE ) { |
|
1015 | - return EEH_Template::get_help_tab_link( $help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text ); |
|
1014 | + protected function _get_help_tab_link($help_tab_id, $icon_style = FALSE, $help_text = FALSE) { |
|
1015 | + return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | |
@@ -1029,30 +1029,30 @@ discard block |
||
1029 | 1029 | */ |
1030 | 1030 | protected function _add_help_tabs() { |
1031 | 1031 | $tour_buttons = ''; |
1032 | - if ( isset( $this->_page_config[$this->_req_action] ) ) { |
|
1032 | + if (isset($this->_page_config[$this->_req_action])) { |
|
1033 | 1033 | $config = $this->_page_config[$this->_req_action]; |
1034 | 1034 | |
1035 | 1035 | //is there a help tour for the current route? if there is let's setup the tour buttons |
1036 | - if ( isset( $this->_help_tour[$this->_req_action]) ) { |
|
1036 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
1037 | 1037 | $tb = array(); |
1038 | 1038 | $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
1039 | - foreach ( $this->_help_tour['tours'] as $tour ) { |
|
1039 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
1040 | 1040 | //if this is the end tour then we don't need to setup a button |
1041 | - if ( $tour instanceof EE_Help_Tour_final_stop ) |
|
1041 | + if ($tour instanceof EE_Help_Tour_final_stop) |
|
1042 | 1042 | continue; |
1043 | - $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
1043 | + $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>'; |
|
1044 | 1044 | } |
1045 | 1045 | $tour_buttons .= implode('<br />', $tb); |
1046 | 1046 | $tour_buttons .= '</div></div>'; |
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
1050 | - if ( is_array( $config ) && isset( $config['help_sidebar'] ) ) { |
|
1050 | + if (is_array($config) && isset($config['help_sidebar'])) { |
|
1051 | 1051 | //check that the callback given is valid |
1052 | - if ( !method_exists($this, $config['help_sidebar'] ) ) |
|
1053 | - throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
1052 | + if ( ! method_exists($this, $config['help_sidebar'])) |
|
1053 | + throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this))); |
|
1054 | 1054 | |
1055 | - $content = apply_filters( 'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func( array( $this, $config['help_sidebar'] ) ) ); |
|
1055 | + $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
1056 | 1056 | |
1057 | 1057 | $content .= $tour_buttons; //add help tour buttons. |
1058 | 1058 | |
@@ -1061,49 +1061,49 @@ discard block |
||
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar. |
1064 | - if ( !isset( $config['help_sidebar'] ) && !empty( $tour_buttons ) ) { |
|
1064 | + if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) { |
|
1065 | 1065 | $this->_current_screen->set_help_sidebar($tour_buttons); |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | //handle if no help_tabs are set so the sidebar will still show for the help tour buttons |
1069 | - if ( !isset( $config['help_tabs'] ) && !empty($tour_buttons) ) { |
|
1069 | + if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
|
1070 | 1070 | $_ht['id'] = $this->page_slug; |
1071 | 1071 | $_ht['title'] = __('Help Tours', 'event_espresso'); |
1072 | - $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
1072 | + $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>'; |
|
1073 | 1073 | $this->_current_screen->add_help_tab($_ht); |
1074 | 1074 | }/**/ |
1075 | 1075 | |
1076 | 1076 | |
1077 | - if ( !isset( $config['help_tabs'] ) ) return; //no help tabs for this route |
|
1077 | + if ( ! isset($config['help_tabs'])) return; //no help tabs for this route |
|
1078 | 1078 | |
1079 | - foreach ( (array) $config['help_tabs'] as $tab_id => $cfg ) { |
|
1079 | + foreach ((array) $config['help_tabs'] as $tab_id => $cfg) { |
|
1080 | 1080 | //we're here so there ARE help tabs! |
1081 | 1081 | |
1082 | 1082 | //make sure we've got what we need |
1083 | - if ( !isset( $cfg['title'] ) ) |
|
1084 | - throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
1083 | + if ( ! isset($cfg['title'])) |
|
1084 | + throw new EE_Error(__('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso')); |
|
1085 | 1085 | |
1086 | 1086 | |
1087 | - if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) |
|
1088 | - throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
1087 | + if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) |
|
1088 | + throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso')); |
|
1089 | 1089 | |
1090 | 1090 | |
1091 | 1091 | |
1092 | 1092 | //first priority goes to content. |
1093 | - if ( !empty($cfg['content'] ) ) { |
|
1094 | - $content = !empty($cfg['content']) ? $cfg['content'] : NULL; |
|
1093 | + if ( ! empty($cfg['content'])) { |
|
1094 | + $content = ! empty($cfg['content']) ? $cfg['content'] : NULL; |
|
1095 | 1095 | |
1096 | 1096 | //second priority goes to filename |
1097 | - } else if ( !empty($cfg['filename'] ) ) { |
|
1098 | - $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
1097 | + } else if ( ! empty($cfg['filename'])) { |
|
1098 | + $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php'; |
|
1099 | 1099 | |
1100 | 1100 | |
1101 | 1101 | //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
1102 | - $file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
1102 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path; |
|
1103 | 1103 | |
1104 | 1104 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
1105 | - if ( !is_readable($file_path) && !isset($cfg['callback']) ) { |
|
1106 | - EE_Error::add_error( sprintf( __('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1105 | + if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
|
1106 | + EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__); |
|
1107 | 1107 | return; |
1108 | 1108 | } |
1109 | 1109 | $template_args['admin_page_obj'] = $this; |
@@ -1114,21 +1114,21 @@ discard block |
||
1114 | 1114 | |
1115 | 1115 | |
1116 | 1116 | //check if callback is valid |
1117 | - if ( empty($content) && ( !isset($cfg['callback']) || !method_exists( $this, $cfg['callback'] ) ) ) { |
|
1118 | - EE_Error::add_error( sprintf( __('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1117 | + if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) { |
|
1118 | + EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__); |
|
1119 | 1119 | return; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | //setup config array for help tab method |
1123 | - $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
1123 | + $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id; |
|
1124 | 1124 | $_ht = array( |
1125 | 1125 | 'id' => $id, |
1126 | 1126 | 'title' => $cfg['title'], |
1127 | - 'callback' => isset( $cfg['callback'] ) && empty($content) ? array( $this, $cfg['callback'] ) : NULL, |
|
1127 | + 'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : NULL, |
|
1128 | 1128 | 'content' => $content |
1129 | 1129 | ); |
1130 | 1130 | |
1131 | - $this->_current_screen->add_help_tab( $_ht ); |
|
1131 | + $this->_current_screen->add_help_tab($_ht); |
|
1132 | 1132 | } |
1133 | 1133 | } |
1134 | 1134 | } |
@@ -1148,49 +1148,49 @@ discard block |
||
1148 | 1148 | $this->_help_tour = array(); |
1149 | 1149 | |
1150 | 1150 | //exit early if help tours are turned off globally |
1151 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) |
|
1151 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) |
|
1152 | 1152 | return; |
1153 | 1153 | |
1154 | 1154 | //loop through _page_config to find any help_tour defined |
1155 | - foreach ( $this->_page_config as $route => $config ) { |
|
1155 | + foreach ($this->_page_config as $route => $config) { |
|
1156 | 1156 | //we're only going to set things up for this route |
1157 | - if ( $route !== $this->_req_action ) |
|
1157 | + if ($route !== $this->_req_action) |
|
1158 | 1158 | continue; |
1159 | 1159 | |
1160 | - if ( isset( $config['help_tour'] ) ) { |
|
1160 | + if (isset($config['help_tour'])) { |
|
1161 | 1161 | |
1162 | - foreach( $config['help_tour'] as $tour ) { |
|
1163 | - $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
1162 | + foreach ($config['help_tour'] as $tour) { |
|
1163 | + $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php'; |
|
1164 | 1164 | //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
1165 | - $file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
1165 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path; |
|
1166 | 1166 | |
1167 | 1167 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
1168 | - if ( !is_readable($file_path) ) { |
|
1169 | - EE_Error::add_error( sprintf( __('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1168 | + if ( ! is_readable($file_path)) { |
|
1169 | + EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour), __FILE__, __FUNCTION__, __LINE__); |
|
1170 | 1170 | return; |
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | require_once $file_path; |
1174 | - if ( !class_exists( $tour ) ) { |
|
1175 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso' ), $tour); |
|
1176 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this) ); |
|
1177 | - throw new EE_Error( implode( '||', $error_msg )); |
|
1174 | + if ( ! class_exists($tour)) { |
|
1175 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
|
1176 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
|
1177 | + throw new EE_Error(implode('||', $error_msg)); |
|
1178 | 1178 | } |
1179 | 1179 | $a = new ReflectionClass($tour); |
1180 | 1180 | $tour_obj = $a->newInstance($this->_is_caf); |
1181 | 1181 | |
1182 | 1182 | $tours[] = $tour_obj; |
1183 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $tour_obj ); |
|
1183 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | //let's inject the end tour stop element common to all pages... this will only get seen once per machine. |
1187 | 1187 | $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf); |
1188 | 1188 | $tours[] = $end_stop_tour; |
1189 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $end_stop_tour ); |
|
1189 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour); |
|
1190 | 1190 | } |
1191 | 1191 | } |
1192 | 1192 | |
1193 | - if ( !empty( $tours ) ) |
|
1193 | + if ( ! empty($tours)) |
|
1194 | 1194 | $this->_help_tour['tours'] = $tours; |
1195 | 1195 | |
1196 | 1196 | //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
@@ -1206,13 +1206,13 @@ discard block |
||
1206 | 1206 | * @return void |
1207 | 1207 | */ |
1208 | 1208 | protected function _add_qtips() { |
1209 | - if ( isset( $this->_route_config['qtips'] ) ) { |
|
1209 | + if (isset($this->_route_config['qtips'])) { |
|
1210 | 1210 | $qtips = (array) $this->_route_config['qtips']; |
1211 | 1211 | //load qtip loader |
1212 | 1212 | EE_Registry::instance()->load_helper('Qtip_Loader', array(), TRUE); |
1213 | 1213 | $path = array( |
1214 | - $this->_get_dir() . '/qtips/', |
|
1215 | - EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/' |
|
1214 | + $this->_get_dir().'/qtips/', |
|
1215 | + EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/' |
|
1216 | 1216 | ); |
1217 | 1217 | EEH_Qtip_Loader::instance()->register($qtips, $path); |
1218 | 1218 | } |
@@ -1229,41 +1229,41 @@ discard block |
||
1229 | 1229 | * @return void |
1230 | 1230 | */ |
1231 | 1231 | protected function _set_nav_tabs() { |
1232 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1232 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1233 | 1233 | $i = 0; |
1234 | - foreach ( $this->_page_config as $slug => $config ) { |
|
1235 | - if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) |
|
1234 | + foreach ($this->_page_config as $slug => $config) { |
|
1235 | + if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) |
|
1236 | 1236 | continue; //no nav tab for this config |
1237 | 1237 | |
1238 | 1238 | //check for persistent flag |
1239 | - if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) |
|
1239 | + if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) |
|
1240 | 1240 | continue; //nav tab is only to appear when route requested. |
1241 | 1241 | |
1242 | - if ( ! $this->check_user_access( $slug, TRUE ) ) |
|
1242 | + if ( ! $this->check_user_access($slug, TRUE)) |
|
1243 | 1243 | continue; //no nav tab becasue current user does not have access. |
1244 | 1244 | |
1245 | - $css_class = isset( $config['css_class'] ) ? $config['css_class'] . ' ' : ''; |
|
1245 | + $css_class = isset($config['css_class']) ? $config['css_class'].' ' : ''; |
|
1246 | 1246 | $this->_nav_tabs[$slug] = array( |
1247 | - 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce( array( 'action'=>$slug ), $this->_admin_base_url ), |
|
1248 | - 'link_text' => isset( $config['nav']['label'] ) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug ) ), |
|
1249 | - 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
1250 | - 'order' => isset( $config['nav']['order'] ) ? $config['nav']['order'] : $i |
|
1247 | + 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action'=>$slug), $this->_admin_base_url), |
|
1248 | + 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
|
1249 | + 'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class, |
|
1250 | + 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i |
|
1251 | 1251 | ); |
1252 | 1252 | $i++; |
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | //if $this->_nav_tabs is empty then lets set the default |
1256 | - if ( empty( $this->_nav_tabs ) ) { |
|
1256 | + if (empty($this->_nav_tabs)) { |
|
1257 | 1257 | $this->_nav_tabs[$this->default_nav_tab_name] = array( |
1258 | 1258 | 'url' => $this->admin_base_url, |
1259 | - 'link_text' => ucwords( str_replace( '_', ' ', $this->default_nav_tab_name ) ), |
|
1259 | + 'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)), |
|
1260 | 1260 | 'css_class' => 'nav-tab-active', |
1261 | 1261 | 'order' => 10 |
1262 | 1262 | ); |
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | //now let's sort the tabs according to order |
1266 | - usort( $this->_nav_tabs, array($this, '_sort_nav_tabs' )); |
|
1266 | + usort($this->_nav_tabs, array($this, '_sort_nav_tabs')); |
|
1267 | 1267 | |
1268 | 1268 | } |
1269 | 1269 | |
@@ -1279,10 +1279,10 @@ discard block |
||
1279 | 1279 | * @return void |
1280 | 1280 | */ |
1281 | 1281 | private function _set_current_labels() { |
1282 | - if ( is_array($this->_route_config) && isset($this->_route_config['labels']) ) { |
|
1283 | - foreach ( $this->_route_config['labels'] as $label => $text ) { |
|
1284 | - if ( is_array($text) ) { |
|
1285 | - foreach ( $text as $sublabel => $subtext ) { |
|
1282 | + if (is_array($this->_route_config) && isset($this->_route_config['labels'])) { |
|
1283 | + foreach ($this->_route_config['labels'] as $label => $text) { |
|
1284 | + if (is_array($text)) { |
|
1285 | + foreach ($text as $sublabel => $subtext) { |
|
1286 | 1286 | $this->_labels[$label][$sublabel] = $subtext; |
1287 | 1287 | } |
1288 | 1288 | } else { |
@@ -1303,24 +1303,24 @@ discard block |
||
1303 | 1303 | * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
1304 | 1304 | * @return BOOL|wp_die() |
1305 | 1305 | */ |
1306 | - public function check_user_access( $route_to_check = '', $verify_only = FALSE ) { |
|
1307 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1308 | - $route_to_check = empty( $route_to_check ) ? $this->_req_action : $route_to_check; |
|
1309 | - $capability = ! empty( $route_to_check ) && isset( $this->_page_routes[$route_to_check] ) && is_array( $this->_page_routes[$route_to_check] ) && ! empty( $this->_page_routes[$route_to_check]['capability'] ) ? $this->_page_routes[$route_to_check]['capability'] : NULL; |
|
1306 | + public function check_user_access($route_to_check = '', $verify_only = FALSE) { |
|
1307 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1308 | + $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check; |
|
1309 | + $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) ? $this->_page_routes[$route_to_check]['capability'] : NULL; |
|
1310 | 1310 | |
1311 | - if ( empty( $capability ) && empty( $route_to_check ) ) { |
|
1312 | - $capability = is_array( $this->_route ) && empty( $this->_route['capability'] ) ? 'manage_options' : $this->_route['capability']; |
|
1311 | + if (empty($capability) && empty($route_to_check)) { |
|
1312 | + $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability']; |
|
1313 | 1313 | } else { |
1314 | - $capability = empty( $capability ) ? 'manage_options' : $capability; |
|
1314 | + $capability = empty($capability) ? 'manage_options' : $capability; |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | - $id = is_array( $this->_route ) && ! empty( $this->_route['obj_id'] ) ? $this->_route['obj_id'] : 0; |
|
1317 | + $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
|
1318 | 1318 | |
1319 | - if (( ! function_exists( 'is_admin' ) || ! EE_Registry::instance()->CAP->current_user_can( $capability, $this->page_slug . '_' . $route_to_check, $id ) ) && ! defined( 'DOING_AJAX')) { |
|
1320 | - if ( $verify_only ) { |
|
1319 | + if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
1320 | + if ($verify_only) { |
|
1321 | 1321 | return FALSE; |
1322 | 1322 | } else { |
1323 | - wp_die( __('You do not have access to this route.', 'event_espresso' ) ); |
|
1323 | + wp_die(__('You do not have access to this route.', 'event_espresso')); |
|
1324 | 1324 | } |
1325 | 1325 | } |
1326 | 1326 | return TRUE; |
@@ -1397,7 +1397,7 @@ discard block |
||
1397 | 1397 | $this->_add_admin_page_overlay(); |
1398 | 1398 | |
1399 | 1399 | //if metaboxes are present we need to add the nonce field |
1400 | - if ( ( isset($this->_route_config['metaboxes']) || ( isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'] ) || isset($this->_route_config['list_table']) ) ) { |
|
1400 | + if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) { |
|
1401 | 1401 | wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
1402 | 1402 | wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
1403 | 1403 | } |
@@ -1416,20 +1416,20 @@ discard block |
||
1416 | 1416 | */ |
1417 | 1417 | public function admin_footer_global() { |
1418 | 1418 | //dialog container for dialog helper |
1419 | - $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
1419 | + $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n"; |
|
1420 | 1420 | $d_cont .= '<div class="ee-notices"></div>'; |
1421 | 1421 | $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
1422 | 1422 | $d_cont .= '</div>'; |
1423 | 1423 | echo $d_cont; |
1424 | 1424 | |
1425 | 1425 | //help tour stuff? |
1426 | - if ( isset( $this->_help_tour[$this->_req_action] ) ) { |
|
1426 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
1427 | 1427 | echo implode('<br />', $this->_help_tour[$this->_req_action]); |
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | //current set timezone for timezone js |
1431 | 1431 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1432 | - echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
1432 | + echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>'; |
|
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | |
@@ -1453,18 +1453,18 @@ discard block |
||
1453 | 1453 | * @access protected |
1454 | 1454 | * @return string content |
1455 | 1455 | */ |
1456 | - protected function _set_help_popup_content( $help_array = array(), $display = FALSE ) { |
|
1456 | + protected function _set_help_popup_content($help_array = array(), $display = FALSE) { |
|
1457 | 1457 | $content = ''; |
1458 | 1458 | |
1459 | - $help_array = empty( $help_array ) ? $this->_get_help_content() : $help_array; |
|
1460 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
1459 | + $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
|
1460 | + $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php'; |
|
1461 | 1461 | |
1462 | 1462 | |
1463 | 1463 | //loop through the array and setup content |
1464 | - foreach ( $help_array as $trigger => $help ) { |
|
1464 | + foreach ($help_array as $trigger => $help) { |
|
1465 | 1465 | //make sure the array is setup properly |
1466 | - if ( !isset($help['title']) || !isset($help['content'] ) ) { |
|
1467 | - throw new EE_Error( __('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso') ); |
|
1466 | + if ( ! isset($help['title']) || ! isset($help['content'])) { |
|
1467 | + throw new EE_Error(__('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso')); |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | //we're good so let'd setup the template vars and then assign parsed template content to our content. |
@@ -1474,10 +1474,10 @@ discard block |
||
1474 | 1474 | 'help_popup_content' => $help['content'] |
1475 | 1475 | ); |
1476 | 1476 | |
1477 | - $content .= EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
1477 | + $content .= EEH_Template::display_template($template_path, $template_args, TRUE); |
|
1478 | 1478 | } |
1479 | 1479 | |
1480 | - if ( $display ) |
|
1480 | + if ($display) |
|
1481 | 1481 | echo $content; |
1482 | 1482 | else |
1483 | 1483 | return $content; |
@@ -1494,18 +1494,18 @@ discard block |
||
1494 | 1494 | */ |
1495 | 1495 | private function _get_help_content() { |
1496 | 1496 | //what is the method we're looking for? |
1497 | - $method_name = '_help_popup_content_' . $this->_req_action; |
|
1497 | + $method_name = '_help_popup_content_'.$this->_req_action; |
|
1498 | 1498 | |
1499 | 1499 | //if method doesn't exist let's get out. |
1500 | - if ( !method_exists( $this, $method_name ) ) |
|
1500 | + if ( ! method_exists($this, $method_name)) |
|
1501 | 1501 | return array(); |
1502 | 1502 | |
1503 | 1503 | //k we're good to go let's retrieve the help array |
1504 | - $help_array = call_user_func( array( $this, $method_name ) ); |
|
1504 | + $help_array = call_user_func(array($this, $method_name)); |
|
1505 | 1505 | |
1506 | 1506 | //make sure we've got an array! |
1507 | - if ( !is_array($help_array) ) { |
|
1508 | - throw new EE_Error( __('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso' ) ); |
|
1507 | + if ( ! is_array($help_array)) { |
|
1508 | + throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso')); |
|
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | return $help_array; |
@@ -1527,27 +1527,27 @@ discard block |
||
1527 | 1527 | * @param array $dimensions an array of dimensions for the box (array(h,w)) |
1528 | 1528 | * @return string |
1529 | 1529 | */ |
1530 | - protected function _set_help_trigger( $trigger_id, $display = TRUE, $dimensions = array( '400', '640') ) { |
|
1530 | + protected function _set_help_trigger($trigger_id, $display = TRUE, $dimensions = array('400', '640')) { |
|
1531 | 1531 | |
1532 | - if ( defined('DOING_AJAX') ) return; |
|
1532 | + if (defined('DOING_AJAX')) return; |
|
1533 | 1533 | |
1534 | 1534 | //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
1535 | 1535 | $help_array = $this->_get_help_content(); |
1536 | 1536 | $help_content = ''; |
1537 | 1537 | |
1538 | - if ( empty( $help_array ) || !isset( $help_array[$trigger_id] ) ) { |
|
1538 | + if (empty($help_array) || ! isset($help_array[$trigger_id])) { |
|
1539 | 1539 | $help_array[$trigger_id] = array( |
1540 | 1540 | 'title' => __('Missing Content', 'event_espresso'), |
1541 | 1541 | 'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', 'event_espresso') |
1542 | 1542 | ); |
1543 | - $help_content = $this->_set_help_popup_content( $help_array, FALSE ); |
|
1543 | + $help_content = $this->_set_help_popup_content($help_array, FALSE); |
|
1544 | 1544 | } |
1545 | 1545 | |
1546 | 1546 | //let's setup the trigger |
1547 | - $content = '<a class="ee-dialog" href="?height='. $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1548 | - $content = $content . $help_content; |
|
1547 | + $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1548 | + $content = $content.$help_content; |
|
1549 | 1549 | |
1550 | - if ( $display ) |
|
1550 | + if ($display) |
|
1551 | 1551 | echo $content; |
1552 | 1552 | else |
1553 | 1553 | return $content; |
@@ -1604,17 +1604,17 @@ discard block |
||
1604 | 1604 | public function load_global_scripts_styles() { |
1605 | 1605 | /** STYLES **/ |
1606 | 1606 | // add debugging styles |
1607 | - if ( WP_DEBUG ) { |
|
1608 | - add_action('admin_head', array( $this, 'add_xdebug_style' )); |
|
1607 | + if (WP_DEBUG) { |
|
1608 | + add_action('admin_head', array($this, 'add_xdebug_style')); |
|
1609 | 1609 | } |
1610 | 1610 | |
1611 | 1611 | //register all styles |
1612 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(),EVENT_ESPRESSO_VERSION ); |
|
1612 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1613 | 1613 | |
1614 | - wp_register_style('jquery-jq-plot-css', JQPLOT_URL . 'jquery.jqplot.min.css', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
1615 | - wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1614 | + wp_register_style('jquery-jq-plot-css', JQPLOT_URL.'jquery.jqplot.min.css', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
1615 | + wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1616 | 1616 | //helpers styles |
1617 | - wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1617 | + wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
1618 | 1618 | //enqueue global styles |
1619 | 1619 | wp_enqueue_style('ee-admin-css'); |
1620 | 1620 | |
@@ -1622,78 +1622,78 @@ discard block |
||
1622 | 1622 | /** SCRIPTS **/ |
1623 | 1623 | |
1624 | 1624 | //register all scripts |
1625 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1626 | - wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1627 | - wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array( 'espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true ); |
|
1625 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1626 | + wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1627 | + wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1628 | 1628 | |
1629 | - wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true ); |
|
1629 | + wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
1630 | 1630 | // register jQuery Validate - see /includes/functions/wp_hooks.php |
1631 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1631 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
1632 | 1632 | add_filter('FHEE_load_joyride', '__return_true'); |
1633 | 1633 | |
1634 | 1634 | //script for sorting tables |
1635 | - wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1635 | + wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1636 | 1636 | //script for parsing uri's |
1637 | - wp_register_script( 'ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1637 | + wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE); |
|
1638 | 1638 | //and parsing associative serialized form elements |
1639 | - wp_register_script( 'ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1639 | + wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1640 | 1640 | //helpers scripts |
1641 | - wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1642 | - wp_register_script( 'ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1643 | - wp_register_script( 'ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1644 | - wp_register_script( 'ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon','ee-moment'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1641 | + wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1642 | + wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE); |
|
1643 | + wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1644 | + wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1645 | 1645 | |
1646 | 1646 | //excanvas |
1647 | - wp_register_script('excanvas', JQPLOT_URL . 'excanvas.min.js', array(), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1647 | + wp_register_script('excanvas', JQPLOT_URL.'excanvas.min.js', array(), EVENT_ESPRESSO_VERSION, FALSE); |
|
1648 | 1648 | |
1649 | 1649 | //jqplot library |
1650 | - wp_register_script('jqplot', JQPLOT_URL . 'jquery.jqplot.min.js', array('jquery'), '', FALSE); |
|
1651 | - wp_register_script('jqplot-barRenderer', JQPLOT_URL . 'plugins/jqplot.barRenderer.min.js', array('jqplot'), '', FALSE); |
|
1652 | - wp_register_script('jqplot-canvasTextRenderer', JQPLOT_URL . 'plugins/jqplot.canvasTextRenderer.min.js', array('jqplot'), '', FALSE); |
|
1653 | - wp_register_script('jqplot-canvasAxisTickRenderer', JQPLOT_URL . 'plugins/jqplot.canvasAxisTickRenderer.min.js', array('jqplot'), '', FALSE); |
|
1654 | - wp_register_script('jqplot-categoryAxisRenderer', JQPLOT_URL . 'plugins/jqplot.categoryAxisRenderer.min.js', array('jqplot'), '', FALSE); |
|
1655 | - wp_register_script('jqplot-dateAxisRenderer', JQPLOT_URL . 'plugins/jqplot.dateAxisRenderer.min.js', array('jqplot'), '', FALSE); |
|
1656 | - wp_register_script('jqplot-highlighter', JQPLOT_URL . 'plugins/jqplot.highlighter.min.js', array('jqplot'), '', FALSE); |
|
1657 | - wp_register_script('jqplot-pointLabels', JQPLOT_URL . 'plugins/jqplot.pointLabels.min.js', array('jqplot'), '', FALSE); |
|
1658 | - wp_register_script('jqplot-all', EE_ADMIN_URL . 'assets/ee-admin-jqlot-all.js', array('jqplot-pointLabels', 'jqplot-highlighter', 'jqplot-dateAxisRenderer', 'jqplot-categoryAxisRenderer', 'jqplot-canvasAxisTickRenderer', 'jqplot-canvasTextRenderer', 'jqplot-barRenderer'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1650 | + wp_register_script('jqplot', JQPLOT_URL.'jquery.jqplot.min.js', array('jquery'), '', FALSE); |
|
1651 | + wp_register_script('jqplot-barRenderer', JQPLOT_URL.'plugins/jqplot.barRenderer.min.js', array('jqplot'), '', FALSE); |
|
1652 | + wp_register_script('jqplot-canvasTextRenderer', JQPLOT_URL.'plugins/jqplot.canvasTextRenderer.min.js', array('jqplot'), '', FALSE); |
|
1653 | + wp_register_script('jqplot-canvasAxisTickRenderer', JQPLOT_URL.'plugins/jqplot.canvasAxisTickRenderer.min.js', array('jqplot'), '', FALSE); |
|
1654 | + wp_register_script('jqplot-categoryAxisRenderer', JQPLOT_URL.'plugins/jqplot.categoryAxisRenderer.min.js', array('jqplot'), '', FALSE); |
|
1655 | + wp_register_script('jqplot-dateAxisRenderer', JQPLOT_URL.'plugins/jqplot.dateAxisRenderer.min.js', array('jqplot'), '', FALSE); |
|
1656 | + wp_register_script('jqplot-highlighter', JQPLOT_URL.'plugins/jqplot.highlighter.min.js', array('jqplot'), '', FALSE); |
|
1657 | + wp_register_script('jqplot-pointLabels', JQPLOT_URL.'plugins/jqplot.pointLabels.min.js', array('jqplot'), '', FALSE); |
|
1658 | + wp_register_script('jqplot-all', EE_ADMIN_URL.'assets/ee-admin-jqlot-all.js', array('jqplot-pointLabels', 'jqplot-highlighter', 'jqplot-dateAxisRenderer', 'jqplot-categoryAxisRenderer', 'jqplot-canvasAxisTickRenderer', 'jqplot-canvasTextRenderer', 'jqplot-barRenderer'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1659 | 1659 | |
1660 | 1660 | |
1661 | 1661 | //enqueue global scripts |
1662 | 1662 | |
1663 | 1663 | //taking care of metaboxes |
1664 | - if ( ( isset($this->_route_config['metaboxes'] ) || isset($this->_route_config['has_metaboxes']) ) && empty( $this->_cpt_route) ) { |
|
1664 | + if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) { |
|
1665 | 1665 | wp_enqueue_script('dashboard'); |
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | //enqueue thickbox for ee help popups. default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups |
1669 | - if ( ! isset( $this->_route_config['has_help_popups']) || ( isset( $this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'] ) ) { |
|
1669 | + if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) { |
|
1670 | 1670 | wp_enqueue_script('ee_admin_js'); |
1671 | 1671 | wp_enqueue_style('ee-admin-css'); |
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | |
1675 | 1675 | //localize script for ajax lazy loading |
1676 | - $lazy_loader_container_ids = apply_filters( 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content') ); |
|
1677 | - wp_localize_script( 'ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
1676 | + $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content')); |
|
1677 | + wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
1678 | 1678 | |
1679 | 1679 | |
1680 | 1680 | /** |
1681 | 1681 | * help tour stuff |
1682 | 1682 | */ |
1683 | - if ( !empty( $this->_help_tour ) ) { |
|
1683 | + if ( ! empty($this->_help_tour)) { |
|
1684 | 1684 | |
1685 | 1685 | //register the js for kicking things off |
1686 | - wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1686 | + wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1687 | 1687 | |
1688 | 1688 | //setup tours for the js tour object |
1689 | - foreach ( $this->_help_tour['tours'] as $tour ) { |
|
1689 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
1690 | 1690 | $tours[] = array( |
1691 | 1691 | 'id' => $tour->get_slug(), |
1692 | 1692 | 'options' => $tour->get_options() |
1693 | 1693 | ); |
1694 | 1694 | } |
1695 | 1695 | |
1696 | - wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours ) ); |
|
1696 | + wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours)); |
|
1697 | 1697 | |
1698 | 1698 | //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour |
1699 | 1699 | } |
@@ -1711,52 +1711,52 @@ discard block |
||
1711 | 1711 | public function admin_footer_scripts_eei18n_js_strings() { |
1712 | 1712 | |
1713 | 1713 | EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
1714 | - EE_Registry::$i18n_js_strings['confirm_delete'] = __( 'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso' ); |
|
1715 | - |
|
1716 | - EE_Registry::$i18n_js_strings['January'] = __( 'January', 'event_espresso' ); |
|
1717 | - EE_Registry::$i18n_js_strings['February'] = __( 'February', 'event_espresso' ); |
|
1718 | - EE_Registry::$i18n_js_strings['March'] = __( 'March', 'event_espresso' ); |
|
1719 | - EE_Registry::$i18n_js_strings['April'] = __( 'April', 'event_espresso' ); |
|
1720 | - EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' ); |
|
1721 | - EE_Registry::$i18n_js_strings['June'] = __( 'June', 'event_espresso' ); |
|
1722 | - EE_Registry::$i18n_js_strings['July'] = __( 'July', 'event_espresso' ); |
|
1723 | - EE_Registry::$i18n_js_strings['August'] = __( 'August', 'event_espresso' ); |
|
1724 | - EE_Registry::$i18n_js_strings['September'] = __( 'September', 'event_espresso' ); |
|
1725 | - EE_Registry::$i18n_js_strings['October'] = __( 'October', 'event_espresso' ); |
|
1726 | - EE_Registry::$i18n_js_strings['November'] = __( 'November', 'event_espresso' ); |
|
1727 | - EE_Registry::$i18n_js_strings['December'] = __( 'December', 'event_espresso' ); |
|
1728 | - EE_Registry::$i18n_js_strings['Jan'] = __( 'Jan', 'event_espresso' ); |
|
1729 | - EE_Registry::$i18n_js_strings['Feb'] = __( 'Feb', 'event_espresso' ); |
|
1730 | - EE_Registry::$i18n_js_strings['Mar'] = __( 'Mar', 'event_espresso' ); |
|
1731 | - EE_Registry::$i18n_js_strings['Apr'] = __( 'Apr', 'event_espresso' ); |
|
1732 | - EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' ); |
|
1733 | - EE_Registry::$i18n_js_strings['Jun'] = __( 'Jun', 'event_espresso' ); |
|
1734 | - EE_Registry::$i18n_js_strings['Jul'] = __( 'Jul', 'event_espresso' ); |
|
1735 | - EE_Registry::$i18n_js_strings['Aug'] = __( 'Aug', 'event_espresso' ); |
|
1736 | - EE_Registry::$i18n_js_strings['Sep'] = __( 'Sep', 'event_espresso' ); |
|
1737 | - EE_Registry::$i18n_js_strings['Oct'] = __( 'Oct', 'event_espresso' ); |
|
1738 | - EE_Registry::$i18n_js_strings['Nov'] = __( 'Nov', 'event_espresso' ); |
|
1739 | - EE_Registry::$i18n_js_strings['Dec'] = __( 'Dec', 'event_espresso' ); |
|
1740 | - |
|
1741 | - EE_Registry::$i18n_js_strings['Sunday'] = __( 'Sunday', 'event_espresso' ); |
|
1742 | - EE_Registry::$i18n_js_strings['Monday'] = __( 'Monday', 'event_espresso' ); |
|
1743 | - EE_Registry::$i18n_js_strings['Tuesday'] = __( 'Tuesday', 'event_espresso' ); |
|
1744 | - EE_Registry::$i18n_js_strings['Wednesday'] = __( 'Wednesday', 'event_espresso' ); |
|
1745 | - EE_Registry::$i18n_js_strings['Thursday'] = __( 'Thursday', 'event_espresso' ); |
|
1746 | - EE_Registry::$i18n_js_strings['Friday'] = __( 'Friday', 'event_espresso' ); |
|
1747 | - EE_Registry::$i18n_js_strings['Saturday'] = __( 'Saturday', 'event_espresso' ); |
|
1748 | - EE_Registry::$i18n_js_strings['Sun'] = __( 'Sun', 'event_espresso' ); |
|
1749 | - EE_Registry::$i18n_js_strings['Mon'] = __( 'Mon', 'event_espresso' ); |
|
1750 | - EE_Registry::$i18n_js_strings['Tue'] = __( 'Tue', 'event_espresso' ); |
|
1751 | - EE_Registry::$i18n_js_strings['Wed'] = __( 'Wed', 'event_espresso' ); |
|
1752 | - EE_Registry::$i18n_js_strings['Thu'] = __( 'Thu', 'event_espresso' ); |
|
1753 | - EE_Registry::$i18n_js_strings['Fri'] = __( 'Fri', 'event_espresso' ); |
|
1754 | - EE_Registry::$i18n_js_strings['Sat'] = __( 'Sat', 'event_espresso' ); |
|
1714 | + EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso'); |
|
1715 | + |
|
1716 | + EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso'); |
|
1717 | + EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso'); |
|
1718 | + EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso'); |
|
1719 | + EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso'); |
|
1720 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1721 | + EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso'); |
|
1722 | + EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso'); |
|
1723 | + EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso'); |
|
1724 | + EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso'); |
|
1725 | + EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso'); |
|
1726 | + EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso'); |
|
1727 | + EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso'); |
|
1728 | + EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso'); |
|
1729 | + EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso'); |
|
1730 | + EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso'); |
|
1731 | + EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso'); |
|
1732 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1733 | + EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso'); |
|
1734 | + EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso'); |
|
1735 | + EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso'); |
|
1736 | + EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso'); |
|
1737 | + EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso'); |
|
1738 | + EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso'); |
|
1739 | + EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso'); |
|
1740 | + |
|
1741 | + EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso'); |
|
1742 | + EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso'); |
|
1743 | + EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso'); |
|
1744 | + EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso'); |
|
1745 | + EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso'); |
|
1746 | + EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso'); |
|
1747 | + EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso'); |
|
1748 | + EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso'); |
|
1749 | + EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso'); |
|
1750 | + EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso'); |
|
1751 | + EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso'); |
|
1752 | + EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso'); |
|
1753 | + EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso'); |
|
1754 | + EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso'); |
|
1755 | 1755 | |
1756 | 1756 | //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance |
1757 | 1757 | //admin page when in maintenance mode and ee_admin_js is not loaded then. This works everywhere else because |
1758 | 1758 | //espresso_core is listed as a dependency of ee_admin_js. |
1759 | - wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
1759 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
1760 | 1760 | |
1761 | 1761 | } |
1762 | 1762 | |
@@ -1790,23 +1790,23 @@ discard block |
||
1790 | 1790 | protected function _set_list_table() { |
1791 | 1791 | |
1792 | 1792 | //first is this a list_table view? |
1793 | - if ( !isset($this->_route_config['list_table']) ) |
|
1793 | + if ( ! isset($this->_route_config['list_table'])) |
|
1794 | 1794 | return; //not a list_table view so get out. |
1795 | 1795 | |
1796 | 1796 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
1797 | 1797 | |
1798 | - if ( call_user_func( array( $this, '_set_list_table_views_' . $this->_req_action ) ) === FALSE ) { |
|
1798 | + if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === FALSE) { |
|
1799 | 1799 | //user error msg |
1800 | - $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso' ); |
|
1800 | + $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
|
1801 | 1801 | //developer error msg |
1802 | - $error_msg .= '||' . sprintf( __('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso' ), $this->_req_action, '_set_list_table_views_' . $this->_req_action ); |
|
1803 | - throw new EE_Error( $error_msg ); |
|
1802 | + $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), $this->_req_action, '_set_list_table_views_'.$this->_req_action); |
|
1803 | + throw new EE_Error($error_msg); |
|
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
1807 | - $this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views ); |
|
1808 | - $this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug, $this->_views ); |
|
1809 | - $this->_views = apply_filters( 'FHEE_list_table_views', $this->_views ); |
|
1807 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views); |
|
1808 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views); |
|
1809 | + $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
|
1810 | 1810 | |
1811 | 1811 | $this->_set_list_table_view(); |
1812 | 1812 | $this->_set_list_table_object(); |
@@ -1828,14 +1828,14 @@ discard block |
||
1828 | 1828 | * @return array |
1829 | 1829 | */ |
1830 | 1830 | protected function _set_list_table_view() { |
1831 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1831 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1832 | 1832 | |
1833 | 1833 | |
1834 | 1834 | // looking at active items or dumpster diving ? |
1835 | - if ( ! isset( $this->_req_data['status'] ) || ! array_key_exists( $this->_req_data['status'], $this->_views )) { |
|
1836 | - $this->_view = isset( $this->_views['in_use'] ) ? 'in_use' : 'all'; |
|
1835 | + if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) { |
|
1836 | + $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all'; |
|
1837 | 1837 | } else { |
1838 | - $this->_view = sanitize_key( $this->_req_data['status'] ); |
|
1838 | + $this->_view = sanitize_key($this->_req_data['status']); |
|
1839 | 1839 | } |
1840 | 1840 | } |
1841 | 1841 | |
@@ -1846,9 +1846,9 @@ discard block |
||
1846 | 1846 | * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of. |
1847 | 1847 | */ |
1848 | 1848 | protected function _set_list_table_object() { |
1849 | - if ( isset($this->_route_config['list_table'] ) ) { |
|
1850 | - if ( !class_exists( $this->_route_config['list_table'] ) ) |
|
1851 | - throw new EE_Error( sprintf( __('The %s class defined for the list table does not exist. Please check the spelling of the class ref in the $_page_config property on %s.', 'event_espresso'), $this->_route_config['list_table'], get_class($this) ) ); |
|
1849 | + if (isset($this->_route_config['list_table'])) { |
|
1850 | + if ( ! class_exists($this->_route_config['list_table'])) |
|
1851 | + throw new EE_Error(sprintf(__('The %s class defined for the list table does not exist. Please check the spelling of the class ref in the $_page_config property on %s.', 'event_espresso'), $this->_route_config['list_table'], get_class($this))); |
|
1852 | 1852 | $a = new ReflectionClass($this->_route_config['list_table']); |
1853 | 1853 | $this->_list_table_object = $a->newInstance($this); |
1854 | 1854 | } |
@@ -1867,27 +1867,27 @@ discard block |
||
1867 | 1867 | * |
1868 | 1868 | * @return array |
1869 | 1869 | */ |
1870 | - public function get_list_table_view_RLs( $extra_query_args = array() ) { |
|
1870 | + public function get_list_table_view_RLs($extra_query_args = array()) { |
|
1871 | 1871 | |
1872 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1872 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1873 | 1873 | |
1874 | - if ( empty( $this->_views )) { |
|
1874 | + if (empty($this->_views)) { |
|
1875 | 1875 | $this->_views = array(); |
1876 | 1876 | } |
1877 | 1877 | |
1878 | 1878 | // cycle thru views |
1879 | - foreach ( $this->_views as $key => $view ) { |
|
1879 | + foreach ($this->_views as $key => $view) { |
|
1880 | 1880 | $query_args = array(); |
1881 | 1881 | // check for current view |
1882 | - $this->_views[ $key ]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
1882 | + $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
1883 | 1883 | $query_args['action'] = $this->_req_action; |
1884 | - $query_args[$this->_req_action.'_nonce'] = wp_create_nonce( $query_args['action'] . '_nonce' ); |
|
1884 | + $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
1885 | 1885 | $query_args['status'] = $view['slug']; |
1886 | 1886 | //merge any other arguments sent in. |
1887 | - if ( isset( $extra_query_args[$view['slug']] ) ) { |
|
1888 | - $query_args = array_merge( $query_args, $extra_query_args[$view['slug']] ); |
|
1887 | + if (isset($extra_query_args[$view['slug']])) { |
|
1888 | + $query_args = array_merge($query_args, $extra_query_args[$view['slug']]); |
|
1889 | 1889 | } |
1890 | - $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1890 | + $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | return $this->_views; |
@@ -1904,15 +1904,15 @@ discard block |
||
1904 | 1904 | * @param int $max_entries total number of rows in the table |
1905 | 1905 | * @return string |
1906 | 1906 | */ |
1907 | - protected function _entries_per_page_dropdown( $max_entries = FALSE ) { |
|
1907 | + protected function _entries_per_page_dropdown($max_entries = FALSE) { |
|
1908 | 1908 | |
1909 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1910 | - $values = array( 10, 25, 50, 100 ); |
|
1911 | - $per_page = ( ! empty( $this->_req_data['per_page'] )) ? absint( $this->_req_data['per_page'] ) : 10; |
|
1909 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1910 | + $values = array(10, 25, 50, 100); |
|
1911 | + $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10; |
|
1912 | 1912 | |
1913 | - if ( $max_entries ) { |
|
1913 | + if ($max_entries) { |
|
1914 | 1914 | $values[] = $max_entries; |
1915 | - sort( $values ); |
|
1915 | + sort($values); |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | $entries_per_page_dropdown = ' |
@@ -1921,15 +1921,15 @@ discard block |
||
1921 | 1921 | Show |
1922 | 1922 | <select id="entries-per-page-slct" name="entries-per-page-slct">'; |
1923 | 1923 | |
1924 | - foreach ( $values as $value ) { |
|
1925 | - if ( $value < $max_entries ) { |
|
1926 | - $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1924 | + foreach ($values as $value) { |
|
1925 | + if ($value < $max_entries) { |
|
1926 | + $selected = $value == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
1927 | 1927 | $entries_per_page_dropdown .= ' |
1928 | 1928 | <option value="'.$value.'"'.$selected.'>'.$value.' </option>'; |
1929 | 1929 | } |
1930 | 1930 | } |
1931 | 1931 | |
1932 | - $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1932 | + $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
1933 | 1933 | $entries_per_page_dropdown .= ' |
1934 | 1934 | <option value="'.$max_entries.'"'.$selected.'>All </option>'; |
1935 | 1935 | |
@@ -1952,8 +1952,8 @@ discard block |
||
1952 | 1952 | * @return void |
1953 | 1953 | */ |
1954 | 1954 | public function _set_search_attributes() { |
1955 | - $this->_template_args['search']['btn_label'] = sprintf( __( 'Search %s', 'event_espresso' ), empty( $this->_search_btn_label ) ? $this->page_label : $this->_search_btn_label ); |
|
1956 | - $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
1955 | + $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
|
1956 | + $this->_template_args['search']['callback'] = 'search_'.$this->page_slug; |
|
1957 | 1957 | } |
1958 | 1958 | |
1959 | 1959 | /*** END LIST TABLE METHODS **/ |
@@ -1972,20 +1972,20 @@ discard block |
||
1972 | 1972 | * @return void |
1973 | 1973 | */ |
1974 | 1974 | private function _add_registered_meta_boxes() { |
1975 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1975 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1976 | 1976 | |
1977 | 1977 | //we only add meta boxes if the page_route calls for it |
1978 | - if ( is_array($this->_route_config) && isset( $this->_route_config['metaboxes'] ) && is_array($this->_route_config['metaboxes']) ) { |
|
1978 | + if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) && is_array($this->_route_config['metaboxes'])) { |
|
1979 | 1979 | |
1980 | 1980 | |
1981 | 1981 | //this simply loops through the callbacks provided and checks if there is a corresponding callback registered by the child - if there is then we go ahead and process the metabox loader. |
1982 | - foreach ( $this->_route_config['metaboxes'] as $metabox_callback ) { |
|
1983 | - if ( call_user_func( array($this, &$metabox_callback) ) === FALSE ) { |
|
1982 | + foreach ($this->_route_config['metaboxes'] as $metabox_callback) { |
|
1983 | + if (call_user_func(array($this, &$metabox_callback)) === FALSE) { |
|
1984 | 1984 | // user error msg |
1985 | - $error_msg = __( 'An error occurred. The requested metabox could not be found.', 'event_espresso' ); |
|
1985 | + $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
|
1986 | 1986 | // developer error msg |
1987 | - $error_msg .= '||' . sprintf( __( 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', 'event_espresso' ), $metabox_callback ); |
|
1988 | - throw new EE_Error( $error_msg ); |
|
1987 | + $error_msg .= '||'.sprintf(__('The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', 'event_espresso'), $metabox_callback); |
|
1988 | + throw new EE_Error($error_msg); |
|
1989 | 1989 | } |
1990 | 1990 | } |
1991 | 1991 | } |
@@ -2002,17 +2002,17 @@ discard block |
||
2002 | 2002 | * @return void |
2003 | 2003 | */ |
2004 | 2004 | private function _add_screen_columns() { |
2005 | - if ( is_array($this->_route_config) && isset( $this->_route_config['columns'] ) && is_array($this->_route_config['columns']) && count( $this->_route_config['columns'] == 2 ) ) { |
|
2005 | + if (is_array($this->_route_config) && isset($this->_route_config['columns']) && is_array($this->_route_config['columns']) && count($this->_route_config['columns'] == 2)) { |
|
2006 | 2006 | |
2007 | - add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1] ) ); |
|
2007 | + add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1])); |
|
2008 | 2008 | $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
2009 | 2009 | $screen_id = $this->_current_screen->id; |
2010 | 2010 | $screen_columns = (int) get_user_option("screen_layout_$screen_id"); |
2011 | - $total_columns = !empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
2012 | - $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
2011 | + $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
2012 | + $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns; |
|
2013 | 2013 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
2014 | 2014 | $this->_template_args['screen'] = $this->_current_screen; |
2015 | - $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
2015 | + $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php'; |
|
2016 | 2016 | |
2017 | 2017 | //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
2018 | 2018 | $this->_route_config['has_metaboxes'] = TRUE; |
@@ -2029,11 +2029,11 @@ discard block |
||
2029 | 2029 | */ |
2030 | 2030 | |
2031 | 2031 | private function _espresso_news_post_box() { |
2032 | - $news_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __( 'New @ Event Espresso', 'event_espresso' ) ); |
|
2033 | - add_meta_box( 'espresso_news_post_box', $news_box_title, array( |
|
2032 | + $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso')); |
|
2033 | + add_meta_box('espresso_news_post_box', $news_box_title, array( |
|
2034 | 2034 | $this, |
2035 | 2035 | 'espresso_news_post_box' |
2036 | - ), $this->_wp_page_slug, 'side' ); |
|
2036 | + ), $this->_wp_page_slug, 'side'); |
|
2037 | 2037 | } |
2038 | 2038 | |
2039 | 2039 | |
@@ -2041,14 +2041,14 @@ discard block |
||
2041 | 2041 | * Code for setting up espresso ratings request metabox. |
2042 | 2042 | */ |
2043 | 2043 | protected function _espresso_ratings_request() { |
2044 | - if ( ! apply_filters( 'FHEE_show_ratings_request_meta_box', true ) ) { |
|
2044 | + if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) { |
|
2045 | 2045 | return ''; |
2046 | 2046 | } |
2047 | - $ratings_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso') ); |
|
2048 | - add_meta_box( 'espresso_ratings_request', $ratings_box_title, array( |
|
2047 | + $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso')); |
|
2048 | + add_meta_box('espresso_ratings_request', $ratings_box_title, array( |
|
2049 | 2049 | $this, |
2050 | 2050 | 'espresso_ratings_request' |
2051 | - ), $this->_wp_page_slug, 'side' ); |
|
2051 | + ), $this->_wp_page_slug, 'side'); |
|
2052 | 2052 | } |
2053 | 2053 | |
2054 | 2054 | |
@@ -2056,35 +2056,35 @@ discard block |
||
2056 | 2056 | * Code for setting up espresso ratings request metabox content. |
2057 | 2057 | */ |
2058 | 2058 | public function espresso_ratings_request() { |
2059 | - $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
2060 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
2061 | - EEH_Template::display_template( $template_path, array() ); |
|
2059 | + $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php'; |
|
2060 | + EE_Registry::instance()->load_helper('Template'); |
|
2061 | + EEH_Template::display_template($template_path, array()); |
|
2062 | 2062 | } |
2063 | 2063 | |
2064 | 2064 | |
2065 | 2065 | |
2066 | 2066 | |
2067 | - public static function cached_rss_display( $rss_id, $url ) { |
|
2068 | - $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>'; |
|
2069 | - $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
2070 | - $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
2071 | - $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
2072 | - $post = '</div>' . "\n"; |
|
2067 | + public static function cached_rss_display($rss_id, $url) { |
|
2068 | + $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading…').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>'; |
|
2069 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
2070 | + $pre = '<div class="espresso-rss-display">'."\n\t"; |
|
2071 | + $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>'; |
|
2072 | + $post = '</div>'."\n"; |
|
2073 | 2073 | |
2074 | - $cache_key = 'ee_rss_' . md5( $rss_id ); |
|
2075 | - if ( FALSE != ( $output = get_transient( $cache_key ) ) ) { |
|
2076 | - echo $pre . $output . $post; |
|
2074 | + $cache_key = 'ee_rss_'.md5($rss_id); |
|
2075 | + if (FALSE != ($output = get_transient($cache_key))) { |
|
2076 | + echo $pre.$output.$post; |
|
2077 | 2077 | return TRUE; |
2078 | 2078 | } |
2079 | 2079 | |
2080 | - if ( ! $doing_ajax ) { |
|
2081 | - echo $pre . $loading . $post; |
|
2080 | + if ( ! $doing_ajax) { |
|
2081 | + echo $pre.$loading.$post; |
|
2082 | 2082 | return FALSE; |
2083 | 2083 | } |
2084 | 2084 | |
2085 | 2085 | ob_start(); |
2086 | - wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5) ); |
|
2087 | - set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); |
|
2086 | + wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5)); |
|
2087 | + set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); |
|
2088 | 2088 | return TRUE; |
2089 | 2089 | |
2090 | 2090 | } |
@@ -2096,13 +2096,13 @@ discard block |
||
2096 | 2096 | <div id="espresso_news_post_box_content" class="infolinks"> |
2097 | 2097 | <?php |
2098 | 2098 | // Get RSS Feed(s) |
2099 | - $feed_url = apply_filters( 'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/' ); |
|
2099 | + $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/'); |
|
2100 | 2100 | $url = urlencode($feed_url); |
2101 | - self::cached_rss_display( 'espresso_news_post_box_content', $url ); |
|
2101 | + self::cached_rss_display('espresso_news_post_box_content', $url); |
|
2102 | 2102 | |
2103 | 2103 | ?> |
2104 | 2104 | </div> |
2105 | - <?php do_action( 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
|
2105 | + <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
|
2106 | 2106 | </div> |
2107 | 2107 | <?php |
2108 | 2108 | } |
@@ -2123,32 +2123,32 @@ discard block |
||
2123 | 2123 | |
2124 | 2124 | protected function _espresso_sponsors_post_box() { |
2125 | 2125 | |
2126 | - $show_sponsors = apply_filters( 'FHEE_show_sponsors_meta_box', TRUE ); |
|
2127 | - if ( $show_sponsors ) |
|
2128 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2126 | + $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', TRUE); |
|
2127 | + if ($show_sponsors) |
|
2128 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2129 | 2129 | } |
2130 | 2130 | |
2131 | 2131 | |
2132 | 2132 | public function espresso_sponsors_post_box() { |
2133 | - $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2134 | - EEH_Template::display_template( $templatepath ); |
|
2133 | + $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2134 | + EEH_Template::display_template($templatepath); |
|
2135 | 2135 | } |
2136 | 2136 | |
2137 | 2137 | |
2138 | 2138 | |
2139 | 2139 | private function _publish_post_box() { |
2140 | - $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
2140 | + $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview'; |
|
2141 | 2141 | |
2142 | 2142 | //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
2143 | - if ( !empty( $this->_labels['publishbox'] ) ) { |
|
2144 | - $box_label = is_array( $this->_labels['publishbox'] ) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
2143 | + if ( ! empty($this->_labels['publishbox'])) { |
|
2144 | + $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
2145 | 2145 | } else { |
2146 | 2146 | $box_label = __('Publish', 'event_espresso'); |
2147 | 2147 | } |
2148 | 2148 | |
2149 | - $box_label = apply_filters( 'FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this ); |
|
2149 | + $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this); |
|
2150 | 2150 | |
2151 | - add_meta_box( $meta_box_ref, $box_label, array( $this, 'editor_overview' ), $this->_current_screen->id, 'side', 'high' ); |
|
2151 | + add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high'); |
|
2152 | 2152 | |
2153 | 2153 | } |
2154 | 2154 | |
@@ -2156,9 +2156,9 @@ discard block |
||
2156 | 2156 | |
2157 | 2157 | public function editor_overview() { |
2158 | 2158 | //if we have extra content set let's add it in if not make sure its empty |
2159 | - $this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2160 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
2161 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2159 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2160 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php'; |
|
2161 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2162 | 2162 | } |
2163 | 2163 | |
2164 | 2164 | |
@@ -2174,8 +2174,8 @@ discard block |
||
2174 | 2174 | * @see $this->_set_publish_post_box_vars for param details |
2175 | 2175 | * @since 4.6.0 |
2176 | 2176 | */ |
2177 | - public function set_publish_post_box_vars( $name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true ) { |
|
2178 | - $this->_set_publish_post_box_vars( $name, $id, $delete, $save_close_redirect_URL, $both_btns ); |
|
2177 | + public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) { |
|
2178 | + $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns); |
|
2179 | 2179 | } |
2180 | 2180 | |
2181 | 2181 | |
@@ -2194,24 +2194,24 @@ discard block |
||
2194 | 2194 | * @param string $post_save_redirect_URL custom URL to redirect to after Save & Close has been completed |
2195 | 2195 | * @param boolean $both_btns whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button |
2196 | 2196 | */ |
2197 | - protected function _set_publish_post_box_vars( $name = NULL, $id = FALSE, $delete = FALSE, $save_close_redirect_URL = NULL, $both_btns = TRUE ) { |
|
2197 | + protected function _set_publish_post_box_vars($name = NULL, $id = FALSE, $delete = FALSE, $save_close_redirect_URL = NULL, $both_btns = TRUE) { |
|
2198 | 2198 | |
2199 | 2199 | // if Save & Close, use a custom redirect URL or default to the main page? |
2200 | - $save_close_redirect_URL = ! empty( $save_close_redirect_URL ) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
2200 | + $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
2201 | 2201 | // create the Save & Close and Save buttons |
2202 | - $this->_set_save_buttons( $both_btns, array(), array(), $save_close_redirect_URL ); |
|
2202 | + $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL); |
|
2203 | 2203 | //if we have extra content set let's add it in if not make sure its empty |
2204 | - $this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2204 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2205 | 2205 | |
2206 | 2206 | |
2207 | - if ( $delete && ! empty( $id ) ) { |
|
2207 | + if ($delete && ! empty($id)) { |
|
2208 | 2208 | $delete = is_bool($delete) ? 'delete' : $delete; //make sure we have a default if just true is sent. |
2209 | - $delete_link_args = array( $name => $id ); |
|
2210 | - $delete = $this->get_action_link_or_button( $delete, $delete, $delete_link_args, 'submitdelete deletion'); |
|
2209 | + $delete_link_args = array($name => $id); |
|
2210 | + $delete = $this->get_action_link_or_button($delete, $delete, $delete_link_args, 'submitdelete deletion'); |
|
2211 | 2211 | } |
2212 | 2212 | |
2213 | - $this->_template_args['publish_delete_link'] = !empty( $id ) ? $delete : ''; |
|
2214 | - if ( ! empty( $name ) && ! empty( $id ) ) { |
|
2213 | + $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : ''; |
|
2214 | + if ( ! empty($name) && ! empty($id)) { |
|
2215 | 2215 | $hidden_field_arr[$name] = array( |
2216 | 2216 | 'type' => 'hidden', |
2217 | 2217 | 'value' => $id |
@@ -2221,7 +2221,7 @@ discard block |
||
2221 | 2221 | $hf = ''; |
2222 | 2222 | } |
2223 | 2223 | // add hidden field |
2224 | - $this->_template_args['publish_hidden_fields'] = ! empty( $hf ) ? $hf[$name]['field'] : $hf; |
|
2224 | + $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf; |
|
2225 | 2225 | |
2226 | 2226 | } |
2227 | 2227 | |
@@ -2238,8 +2238,8 @@ discard block |
||
2238 | 2238 | <noscript> |
2239 | 2239 | <div id="no-js-message" class="error"> |
2240 | 2240 | <p style="font-size:1.3em;"> |
2241 | - <span style="color:red;"><?php _e( 'Warning!', 'event_espresso' ); ?></span> |
|
2242 | - <?php _e( 'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso' ); ?> |
|
2241 | + <span style="color:red;"><?php _e('Warning!', 'event_espresso'); ?></span> |
|
2242 | + <?php _e('Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso'); ?> |
|
2243 | 2243 | </p> |
2244 | 2244 | </div> |
2245 | 2245 | </noscript> |
@@ -2259,7 +2259,7 @@ discard block |
||
2259 | 2259 | * @return string |
2260 | 2260 | */ |
2261 | 2261 | private function _display_espresso_notices() { |
2262 | - $notices = $this->_get_transient( TRUE ); |
|
2262 | + $notices = $this->_get_transient(TRUE); |
|
2263 | 2263 | echo stripslashes($notices); |
2264 | 2264 | } |
2265 | 2265 | |
@@ -2311,11 +2311,11 @@ discard block |
||
2311 | 2311 | * @param string $priority give this metabox a priority (using accepted priorities for wp meta boxes) |
2312 | 2312 | * @param boolean $create_func default is true. Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box. |
2313 | 2313 | */ |
2314 | - public function _add_admin_page_meta_box( $action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true ) { |
|
2315 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, $callback ); |
|
2314 | + public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) { |
|
2315 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $callback); |
|
2316 | 2316 | |
2317 | 2317 | //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated. |
2318 | - if ( empty( $callback_args ) && $create_func ) { |
|
2318 | + if (empty($callback_args) && $create_func) { |
|
2319 | 2319 | $callback_args = array( |
2320 | 2320 | 'template_path' => $this->_template_path, |
2321 | 2321 | 'template_args' => $this->_template_args, |
@@ -2325,7 +2325,7 @@ discard block |
||
2325 | 2325 | //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
2326 | 2326 | $call_back_func = $create_func ? create_function('$post, $metabox', 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
2327 | 2327 | |
2328 | - add_meta_box( str_replace( '_', '-', $action ) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args ); |
|
2328 | + add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
2329 | 2329 | } |
2330 | 2330 | |
2331 | 2331 | |
@@ -2338,7 +2338,7 @@ discard block |
||
2338 | 2338 | */ |
2339 | 2339 | public function display_admin_page_with_metabox_columns() { |
2340 | 2340 | $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content']; |
2341 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_column_template_path, $this->_template_args, TRUE); |
|
2341 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, TRUE); |
|
2342 | 2342 | |
2343 | 2343 | //the final wrapper |
2344 | 2344 | $this->admin_page_wrapper(); |
@@ -2381,7 +2381,7 @@ discard block |
||
2381 | 2381 | * @return void |
2382 | 2382 | */ |
2383 | 2383 | public function display_about_admin_page() { |
2384 | - $this->_display_admin_page( FALSE, TRUE ); |
|
2384 | + $this->_display_admin_page(FALSE, TRUE); |
|
2385 | 2385 | } |
2386 | 2386 | |
2387 | 2387 | |
@@ -2397,26 +2397,26 @@ discard block |
||
2397 | 2397 | * @return html admin_page |
2398 | 2398 | */ |
2399 | 2399 | private function _display_admin_page($sidebar = false, $about = FALSE) { |
2400 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2400 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2401 | 2401 | |
2402 | 2402 | //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages. |
2403 | - do_action( 'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes' ); |
|
2403 | + do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'); |
|
2404 | 2404 | |
2405 | 2405 | // set current wp page slug - looks like: event-espresso_page_event_categories |
2406 | 2406 | // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated. |
2407 | 2407 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
2408 | 2408 | |
2409 | - $template_path = $sidebar ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
2409 | + $template_path = $sidebar ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php'; |
|
2410 | 2410 | |
2411 | - if ( defined('DOING_AJAX' ) ) |
|
2412 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2411 | + if (defined('DOING_AJAX')) |
|
2412 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2413 | 2413 | |
2414 | - $template_path = !empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
2414 | + $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
2415 | 2415 | |
2416 | - $this->_template_args['post_body_content'] = isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : ''; |
|
2416 | + $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
|
2417 | 2417 | $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''; |
2418 | 2418 | $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''; |
2419 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2419 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2420 | 2420 | |
2421 | 2421 | |
2422 | 2422 | // the final template wrapper |
@@ -2436,7 +2436,7 @@ discard block |
||
2436 | 2436 | * @param bool $display_sidebar whether to use the sidebar template or the full template for the page. TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar. |
2437 | 2437 | * @return void |
2438 | 2438 | */ |
2439 | - public function display_admin_caf_preview_page( $utm_campaign_source = '', $display_sidebar = TRUE ) { |
|
2439 | + public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = TRUE) { |
|
2440 | 2440 | //let's generate a default preview action button if there isn't one already present. |
2441 | 2441 | $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso'); |
2442 | 2442 | $buy_now_url = add_query_arg( |
@@ -2449,10 +2449,10 @@ discard block |
||
2449 | 2449 | ), |
2450 | 2450 | 'http://eventespresso.com/pricing/' |
2451 | 2451 | ); |
2452 | - $this->_template_args['preview_action_button'] = ! isset( $this->_template_args['preview_action_button'] ) ? $this->get_action_link_or_button( '', 'buy_now', array(), 'button-primary button-large', $buy_now_url, true ) : $this->_template_args['preview_action_button']; |
|
2453 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
2454 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2455 | - $this->_display_admin_page( $display_sidebar ); |
|
2452 | + $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) ? $this->get_action_link_or_button('', 'buy_now', array(), 'button-primary button-large', $buy_now_url, true) : $this->_template_args['preview_action_button']; |
|
2453 | + $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php'; |
|
2454 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2455 | + $this->_display_admin_page($display_sidebar); |
|
2456 | 2456 | } |
2457 | 2457 | |
2458 | 2458 | |
@@ -2486,41 +2486,41 @@ discard block |
||
2486 | 2486 | * @param boolean $sidebar whether to display with sidebar or not. |
2487 | 2487 | * @return html |
2488 | 2488 | */ |
2489 | - private function _display_admin_list_table_page( $sidebar = false ) { |
|
2489 | + private function _display_admin_list_table_page($sidebar = false) { |
|
2490 | 2490 | //setup search attributes |
2491 | 2491 | $this->_set_search_attributes(); |
2492 | 2492 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
2493 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
2493 | + $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php'; |
|
2494 | 2494 | |
2495 | - $this->_template_args['table_url'] = defined( 'DOING_AJAX') ? add_query_arg( array( 'noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url ) : add_query_arg( array( 'route' => $this->_req_action), $this->_admin_base_url); |
|
2495 | + $this->_template_args['table_url'] = defined('DOING_AJAX') ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
|
2496 | 2496 | $this->_template_args['list_table'] = $this->_list_table_object; |
2497 | 2497 | $this->_template_args['current_route'] = $this->_req_action; |
2498 | - $this->_template_args['list_table_class'] = get_class( $this->_list_table_object ); |
|
2498 | + $this->_template_args['list_table_class'] = get_class($this->_list_table_object); |
|
2499 | 2499 | |
2500 | 2500 | $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
2501 | - if( ! empty( $ajax_sorting_callback )) { |
|
2502 | - $sortable_list_table_form_fields = wp_nonce_field( $ajax_sorting_callback . '_nonce', $ajax_sorting_callback . '_nonce', FALSE, FALSE ); |
|
2501 | + if ( ! empty($ajax_sorting_callback)) { |
|
2502 | + $sortable_list_table_form_fields = wp_nonce_field($ajax_sorting_callback.'_nonce', $ajax_sorting_callback.'_nonce', FALSE, FALSE); |
|
2503 | 2503 | // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
2504 | 2504 | // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
2505 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug .'" />'; |
|
2506 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
2505 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />'; |
|
2506 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />'; |
|
2507 | 2507 | } else { |
2508 | 2508 | $sortable_list_table_form_fields = ''; |
2509 | 2509 | } |
2510 | 2510 | |
2511 | 2511 | $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
2512 | - $hidden_form_fields = isset( $this->_template_args['list_table_hidden_fields'] ) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
2513 | - $nonce_ref = $this->_req_action . '_nonce'; |
|
2514 | - $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce( $nonce_ref ) . '">'; |
|
2512 | + $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
2513 | + $nonce_ref = $this->_req_action.'_nonce'; |
|
2514 | + $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">'; |
|
2515 | 2515 | $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
2516 | 2516 | |
2517 | 2517 | //display message about search results? |
2518 | - $this->_template_args['before_list_table'] .= apply_filters( 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', !empty( $this->_req_data['s'] ) ? '<p class="ee-search-results">' . sprintf( __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), trim($this->_req_data['s'], '%') ) . '</p>' : '', $this->page_slug, $this->_req_data, $this->_req_action ); |
|
2518 | + $this->_template_args['before_list_table'] .= apply_filters('FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', ! empty($this->_req_data['s']) ? '<p class="ee-search-results">'.sprintf(__('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), trim($this->_req_data['s'], '%')).'</p>' : '', $this->page_slug, $this->_req_data, $this->_req_action); |
|
2519 | 2519 | |
2520 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2520 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2521 | 2521 | |
2522 | 2522 | // the final template wrapper |
2523 | - if ( $sidebar ) |
|
2523 | + if ($sidebar) |
|
2524 | 2524 | $this->display_admin_page_with_sidebar(); |
2525 | 2525 | else |
2526 | 2526 | $this->display_admin_page_with_no_sidebar(); |
@@ -2543,9 +2543,9 @@ discard block |
||
2543 | 2543 | * @param array $items see above for format of array |
2544 | 2544 | * @return string html string of legend |
2545 | 2545 | */ |
2546 | - protected function _display_legend( $items ) { |
|
2547 | - $this->_template_args['items'] = apply_filters( 'FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this ); |
|
2548 | - $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
2546 | + protected function _display_legend($items) { |
|
2547 | + $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this); |
|
2548 | + $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php'; |
|
2549 | 2549 | return EEH_Template::display_template($legend_template, $this->_template_args, TRUE); |
2550 | 2550 | } |
2551 | 2551 | |
@@ -2570,31 +2570,31 @@ discard block |
||
2570 | 2570 | * |
2571 | 2571 | * @return json object |
2572 | 2572 | */ |
2573 | - protected function _return_json( $sticky_notices = FALSE ) { |
|
2573 | + protected function _return_json($sticky_notices = FALSE) { |
|
2574 | 2574 | |
2575 | 2575 | //make sure any EE_Error notices have been handled. |
2576 | - $this->_process_notices( array(), TRUE, $sticky_notices ); |
|
2576 | + $this->_process_notices(array(), TRUE, $sticky_notices); |
|
2577 | 2577 | |
2578 | 2578 | |
2579 | - $data = isset( $this->_template_args['data'] ) ? $this->_template_args['data'] : array(); |
|
2579 | + $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array(); |
|
2580 | 2580 | unset($this->_template_args['data']); |
2581 | 2581 | $json = array( |
2582 | - 'error' => isset( $this->_template_args['error'] ) ? $this->_template_args['error'] : FALSE, |
|
2583 | - 'success' => isset( $this->_template_args['success'] ) ? $this->_template_args['success'] : FALSE, |
|
2582 | + 'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : FALSE, |
|
2583 | + 'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : FALSE, |
|
2584 | 2584 | 'notices' => EE_Error::get_notices(), |
2585 | - 'content' => isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : '', |
|
2586 | - 'data' => array_merge( $data, array('template_args' => $this->_template_args ) ), |
|
2585 | + 'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '', |
|
2586 | + 'data' => array_merge($data, array('template_args' => $this->_template_args)), |
|
2587 | 2587 | 'isEEajax' => TRUE //special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
2588 | 2588 | ); |
2589 | 2589 | |
2590 | 2590 | |
2591 | 2591 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
2592 | - if ( NULL === error_get_last() || ! headers_sent() ) |
|
2592 | + if (NULL === error_get_last() || ! headers_sent()) |
|
2593 | 2593 | header('Content-Type: application/json; charset=UTF-8'); |
2594 | - if( function_exists( 'wp_json_encode' ) ) { |
|
2595 | - echo wp_json_encode( $json ); |
|
2594 | + if (function_exists('wp_json_encode')) { |
|
2595 | + echo wp_json_encode($json); |
|
2596 | 2596 | } else { |
2597 | - echo json_encode( $json ); |
|
2597 | + echo json_encode($json); |
|
2598 | 2598 | } |
2599 | 2599 | exit(); |
2600 | 2600 | } |
@@ -2606,11 +2606,11 @@ discard block |
||
2606 | 2606 | * @return json_obj|EE_Error |
2607 | 2607 | */ |
2608 | 2608 | public function return_json() { |
2609 | - if ( defined('DOING_AJAX') && DOING_AJAX ) |
|
2609 | + if (defined('DOING_AJAX') && DOING_AJAX) |
|
2610 | 2610 | $this->_return_json(); |
2611 | 2611 | |
2612 | 2612 | else { |
2613 | - throw new EE_Error( sprintf( __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__ ) ); |
|
2613 | + throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__)); |
|
2614 | 2614 | } |
2615 | 2615 | } |
2616 | 2616 | |
@@ -2625,7 +2625,7 @@ discard block |
||
2625 | 2625 | * @access public |
2626 | 2626 | * @return void |
2627 | 2627 | */ |
2628 | - public function set_hook_object( EE_Admin_Hooks $hook_obj ) { |
|
2628 | + public function set_hook_object(EE_Admin_Hooks $hook_obj) { |
|
2629 | 2629 | $this->_hook_obj = $hook_obj; |
2630 | 2630 | } |
2631 | 2631 | |
@@ -2641,33 +2641,33 @@ discard block |
||
2641 | 2641 | */ |
2642 | 2642 | public function admin_page_wrapper($about = FALSE) { |
2643 | 2643 | |
2644 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2644 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2645 | 2645 | |
2646 | 2646 | $this->_nav_tabs = $this->_get_main_nav_tabs(); |
2647 | 2647 | |
2648 | 2648 | $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
2649 | 2649 | $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
2650 | 2650 | |
2651 | - $this->_template_args['before_admin_page_content'] = apply_filters( 'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['before_admin_page_content'] ) ? $this->_template_args['before_admin_page_content'] : ''); |
|
2652 | - $this->_template_args['after_admin_page_content'] = apply_filters( 'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['after_admin_page_content'] ) ? $this->_template_args['after_admin_page_content'] : ''); |
|
2651 | + $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
|
2652 | + $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
|
2653 | 2653 | |
2654 | 2654 | $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
2655 | 2655 | |
2656 | 2656 | |
2657 | 2657 | |
2658 | 2658 | // load settings page wrapper template |
2659 | - $template_path = !defined( 'DOING_AJAX' ) ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
2659 | + $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php'; |
|
2660 | 2660 | |
2661 | 2661 | //about page? |
2662 | - $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
2662 | + $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path; |
|
2663 | 2663 | |
2664 | 2664 | |
2665 | - if ( defined( 'DOING_AJAX' ) ) { |
|
2666 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2665 | + if (defined('DOING_AJAX')) { |
|
2666 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2667 | 2667 | |
2668 | 2668 | $this->_return_json(); |
2669 | 2669 | } else { |
2670 | - EEH_Template::display_template( $template_path, $this->_template_args ); |
|
2670 | + EEH_Template::display_template($template_path, $this->_template_args); |
|
2671 | 2671 | } |
2672 | 2672 | |
2673 | 2673 | } |
@@ -2680,7 +2680,7 @@ discard block |
||
2680 | 2680 | */ |
2681 | 2681 | protected function _get_main_nav_tabs() { |
2682 | 2682 | //let's generate the html using the EEH_Tabbed_Content helper. We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array) |
2683 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
2683 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
2684 | 2684 | return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs); |
2685 | 2685 | } |
2686 | 2686 | |
@@ -2696,7 +2696,7 @@ discard block |
||
2696 | 2696 | * @access public |
2697 | 2697 | * @return void |
2698 | 2698 | */ |
2699 | - private function _sort_nav_tabs( $a, $b ) { |
|
2699 | + private function _sort_nav_tabs($a, $b) { |
|
2700 | 2700 | if ($a['order'] == $b['order']) { |
2701 | 2701 | return 0; |
2702 | 2702 | } |
@@ -2717,8 +2717,8 @@ discard block |
||
2717 | 2717 | * @uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php) |
2718 | 2718 | * @uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php) |
2719 | 2719 | */ |
2720 | - protected function _generate_admin_form_fields( $input_vars = array(), $generator = 'string', $id = FALSE ) { |
|
2721 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2720 | + protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = FALSE) { |
|
2721 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2722 | 2722 | $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars); |
2723 | 2723 | return $content; |
2724 | 2724 | } |
@@ -2740,25 +2740,25 @@ discard block |
||
2740 | 2740 | * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button). We can also use this to just dump default actions by submitting some other value. |
2741 | 2741 | * @param bool|string|null $referrer if false then we just do the default action on save and close. Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling). |
2742 | 2742 | */ |
2743 | - protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL ) { |
|
2743 | + protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL) { |
|
2744 | 2744 | //make sure $text and $actions are in an array |
2745 | 2745 | $text = (array) $text; |
2746 | 2746 | $actions = (array) $actions; |
2747 | 2747 | $referrer_url = empty($referrer) ? '' : $referrer; |
2748 | - $referrer_url = !$referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] .'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer .'" />'; |
|
2748 | + $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />'; |
|
2749 | 2749 | |
2750 | - $button_text = !empty($text) ? $text : array( __('Save', 'event_espresso'), __('Save and Close', 'event_espresso') ); |
|
2751 | - $default_names = array( 'save', 'save_and_close' ); |
|
2750 | + $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
|
2751 | + $default_names = array('save', 'save_and_close'); |
|
2752 | 2752 | |
2753 | 2753 | //add in a hidden index for the current page (so save and close redirects properly) |
2754 | 2754 | $this->_template_args['save_buttons'] = $referrer_url; |
2755 | 2755 | |
2756 | - foreach ( $button_text as $key => $button ) { |
|
2756 | + foreach ($button_text as $key => $button) { |
|
2757 | 2757 | $ref = $default_names[$key]; |
2758 | - $id = $this->_current_view . '_' . $ref; |
|
2759 | - $name = !empty($actions) ? $actions[$key] : $ref; |
|
2760 | - $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
2761 | - if ( !$both ) break; |
|
2758 | + $id = $this->_current_view.'_'.$ref; |
|
2759 | + $name = ! empty($actions) ? $actions[$key] : $ref; |
|
2760 | + $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />'; |
|
2761 | + if ( ! $both) break; |
|
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | } |
@@ -2771,8 +2771,8 @@ discard block |
||
2771 | 2771 | * @since 4.6.0 |
2772 | 2772 | * |
2773 | 2773 | */ |
2774 | - public function set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) { |
|
2775 | - $this->_set_add_edit_form_tags( $route, $additional_hidden_fields ); |
|
2774 | + public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) { |
|
2775 | + $this->_set_add_edit_form_tags($route, $additional_hidden_fields); |
|
2776 | 2776 | } |
2777 | 2777 | |
2778 | 2778 | |
@@ -2785,30 +2785,30 @@ discard block |
||
2785 | 2785 | * @param array $additional_hidden_fields any additional hidden fields required in the form header |
2786 | 2786 | * @return void |
2787 | 2787 | */ |
2788 | - protected function _set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) { |
|
2788 | + protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) { |
|
2789 | 2789 | |
2790 | - if ( empty( $route )) { |
|
2790 | + if (empty($route)) { |
|
2791 | 2791 | $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
2792 | - $dev_msg = $user_msg . "\n" . sprintf( __('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__ ); |
|
2793 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2792 | + $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
2793 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
2794 | 2794 | } |
2795 | 2795 | // open form |
2796 | - $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
2796 | + $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >'; |
|
2797 | 2797 | // add nonce |
2798 | - $nonce = wp_nonce_field( $route . '_nonce', $route . '_nonce', FALSE, FALSE ); |
|
2798 | + $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', FALSE, FALSE); |
|
2799 | 2799 | // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
2800 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
2800 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce; |
|
2801 | 2801 | // add REQUIRED form action |
2802 | 2802 | $hidden_fields = array( |
2803 | - 'action' => array( 'type' => 'hidden', 'value' => $route ), |
|
2803 | + 'action' => array('type' => 'hidden', 'value' => $route), |
|
2804 | 2804 | ); |
2805 | 2805 | // merge arrays |
2806 | - $hidden_fields = is_array( $additional_hidden_fields) ? array_merge( $hidden_fields, $additional_hidden_fields ) : $hidden_fields; |
|
2806 | + $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields; |
|
2807 | 2807 | // generate form fields |
2808 | - $form_fields = $this->_generate_admin_form_fields( $hidden_fields, 'array' ); |
|
2808 | + $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
|
2809 | 2809 | // add fields to form |
2810 | - foreach ( $form_fields as $field_name => $form_field ) { |
|
2811 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
2810 | + foreach ($form_fields as $field_name => $form_field) { |
|
2811 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field']; |
|
2812 | 2812 | } |
2813 | 2813 | |
2814 | 2814 | // close form |
@@ -2825,8 +2825,8 @@ discard block |
||
2825 | 2825 | * @see EE_Admin_Page::_redirect_after_action() for params. |
2826 | 2826 | * @since 4.5.0 |
2827 | 2827 | */ |
2828 | - public function redirect_after_action( $success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) { |
|
2829 | - $this->_redirect_after_action( $success, $what, $action_desc, $query_args, $override_overwrite ); |
|
2828 | + public function redirect_after_action($success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) { |
|
2829 | + $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite); |
|
2830 | 2830 | } |
2831 | 2831 | |
2832 | 2832 | |
@@ -2841,32 +2841,32 @@ discard block |
||
2841 | 2841 | * @access protected |
2842 | 2842 | * @return void |
2843 | 2843 | */ |
2844 | - protected function _redirect_after_action( $success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) { |
|
2844 | + protected function _redirect_after_action($success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) { |
|
2845 | 2845 | |
2846 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2846 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2847 | 2847 | |
2848 | 2848 | //class name for actions/filters. |
2849 | 2849 | $classname = get_class($this); |
2850 | 2850 | |
2851 | 2851 | //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url |
2852 | - $redirect_url = isset( $query_args['page'] ) ? admin_url('admin.php') : $this->_admin_base_url; |
|
2853 | - $notices = EE_Error::get_notices( FALSE ); |
|
2852 | + $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url; |
|
2853 | + $notices = EE_Error::get_notices(FALSE); |
|
2854 | 2854 | |
2855 | 2855 | // overwrite default success messages //BUT ONLY if overwrite not overridden |
2856 | - if ( ! $override_overwrite || ! empty( $notices['errors'] )) { |
|
2856 | + if ( ! $override_overwrite || ! empty($notices['errors'])) { |
|
2857 | 2857 | EE_Error::overwrite_success(); |
2858 | 2858 | } |
2859 | 2859 | // how many records affected ? more than one record ? or just one ? |
2860 | - if ( $success > 1 && empty( $notices['errors'] )) { |
|
2860 | + if ($success > 1 && empty($notices['errors'])) { |
|
2861 | 2861 | // set plural msg |
2862 | - EE_Error::add_success( sprintf( __('The "%s" have been successfully %s.', 'event_espresso'), $what, $action_desc ), __FILE__, __FUNCTION__, __LINE__); |
|
2863 | - } else if ( $success == 1 && empty( $notices['errors'] )) { |
|
2862 | + EE_Error::add_success(sprintf(__('The "%s" have been successfully %s.', 'event_espresso'), $what, $action_desc), __FILE__, __FUNCTION__, __LINE__); |
|
2863 | + } else if ($success == 1 && empty($notices['errors'])) { |
|
2864 | 2864 | // set singular msg |
2865 | - EE_Error::add_success( sprintf( __('The "%s" has been successfully %s.', 'event_espresso'), $what, $action_desc), __FILE__, __FUNCTION__, __LINE__ ); |
|
2865 | + EE_Error::add_success(sprintf(__('The "%s" has been successfully %s.', 'event_espresso'), $what, $action_desc), __FILE__, __FUNCTION__, __LINE__); |
|
2866 | 2866 | } |
2867 | 2867 | |
2868 | 2868 | // check that $query_args isn't something crazy |
2869 | - if ( ! is_array( $query_args )) { |
|
2869 | + if ( ! is_array($query_args)) { |
|
2870 | 2870 | $query_args = array(); |
2871 | 2871 | } |
2872 | 2872 | |
@@ -2879,36 +2879,36 @@ discard block |
||
2879 | 2879 | * @param array $query_args The original query_args array coming into the |
2880 | 2880 | * method. |
2881 | 2881 | */ |
2882 | - do_action( 'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args ); |
|
2882 | + do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args); |
|
2883 | 2883 | |
2884 | 2884 | //calculate where we're going (if we have a "save and close" button pushed) |
2885 | - if ( isset($this->_req_data['save_and_close'] ) && isset($this->_req_data['save_and_close_referrer'] ) ) { |
|
2885 | + if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
|
2886 | 2886 | // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
2887 | - $parsed_url = parse_url( $this->_req_data['save_and_close_referrer'] ); |
|
2887 | + $parsed_url = parse_url($this->_req_data['save_and_close_referrer']); |
|
2888 | 2888 | // regenerate query args array from refferer URL |
2889 | - parse_str( $parsed_url['query'], $query_args ); |
|
2889 | + parse_str($parsed_url['query'], $query_args); |
|
2890 | 2890 | // correct page and action will be in the query args now |
2891 | - $redirect_url = admin_url( 'admin.php' ); |
|
2891 | + $redirect_url = admin_url('admin.php'); |
|
2892 | 2892 | } |
2893 | 2893 | |
2894 | 2894 | //merge any default query_args set in _default_route_query_args property |
2895 | - if ( ! empty( $this->_default_route_query_args ) && ! $this->_is_UI_request ) { |
|
2895 | + if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) { |
|
2896 | 2896 | $args_to_merge = array(); |
2897 | - foreach ( $this->_default_route_query_args as $query_param => $query_value ) { |
|
2897 | + foreach ($this->_default_route_query_args as $query_param => $query_value) { |
|
2898 | 2898 | //is there a wp_referer array in our _default_route_query_args property? |
2899 | - if ( $query_param == 'wp_referer' ) { |
|
2899 | + if ($query_param == 'wp_referer') { |
|
2900 | 2900 | $query_value = (array) $query_value; |
2901 | - foreach ( $query_value as $reference => $value ) { |
|
2902 | - if ( strpos( $reference, 'nonce' ) !== false ) { |
|
2901 | + foreach ($query_value as $reference => $value) { |
|
2902 | + if (strpos($reference, 'nonce') !== false) { |
|
2903 | 2903 | continue; |
2904 | 2904 | } |
2905 | 2905 | |
2906 | 2906 | //finally we will override any arguments in the referer with |
2907 | 2907 | //what might be set on the _default_route_query_args array. |
2908 | - if ( isset( $this->_default_route_query_args[$reference] ) ) { |
|
2909 | - $args_to_merge[$reference] = urlencode( $this->_default_route_query_args[$reference] ); |
|
2908 | + if (isset($this->_default_route_query_args[$reference])) { |
|
2909 | + $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]); |
|
2910 | 2910 | } else { |
2911 | - $args_to_merge[$reference] = urlencode( $value ); |
|
2911 | + $args_to_merge[$reference] = urlencode($value); |
|
2912 | 2912 | } |
2913 | 2913 | } |
2914 | 2914 | continue; |
@@ -2919,7 +2919,7 @@ discard block |
||
2919 | 2919 | |
2920 | 2920 | //now let's merge these arguments but override with what was specifically sent in to the |
2921 | 2921 | //redirect. |
2922 | - $query_args = array_merge( $args_to_merge, $query_args ); |
|
2922 | + $query_args = array_merge($args_to_merge, $query_args); |
|
2923 | 2923 | } |
2924 | 2924 | |
2925 | 2925 | $this->_process_notices($query_args); |
@@ -2928,19 +2928,19 @@ discard block |
||
2928 | 2928 | // generate redirect url |
2929 | 2929 | |
2930 | 2930 | // if redirecting to anything other than the main page, add a nonce |
2931 | - if ( isset( $query_args['action'] )) { |
|
2931 | + if (isset($query_args['action'])) { |
|
2932 | 2932 | // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
2933 | - $query_args['_wpnonce'] = wp_create_nonce( $query_args['action'] . '_nonce' ); |
|
2933 | + $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
2934 | 2934 | } |
2935 | 2935 | |
2936 | 2936 | //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
2937 | - do_action( 'AHEE_redirect_' . $classname . $this->_req_action, $query_args ); |
|
2937 | + do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args); |
|
2938 | 2938 | |
2939 | - $redirect_url = apply_filters( 'FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce( $query_args, $redirect_url ), $query_args ); |
|
2939 | + $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
2940 | 2940 | |
2941 | 2941 | |
2942 | 2942 | // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
2943 | - if ( defined('DOING_AJAX' ) ) { |
|
2943 | + if (defined('DOING_AJAX')) { |
|
2944 | 2944 | $default_data = array( |
2945 | 2945 | 'close' => TRUE, |
2946 | 2946 | 'redirect_url' => $redirect_url, |
@@ -2949,11 +2949,11 @@ discard block |
||
2949 | 2949 | ); |
2950 | 2950 | |
2951 | 2951 | $this->_template_args['success'] = $success; |
2952 | - $this->_template_args['data'] = !empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data'] ): $default_data; |
|
2952 | + $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data; |
|
2953 | 2953 | $this->_return_json(); |
2954 | 2954 | } |
2955 | 2955 | |
2956 | - wp_safe_redirect( $redirect_url ); |
|
2956 | + wp_safe_redirect($redirect_url); |
|
2957 | 2957 | exit(); |
2958 | 2958 | } |
2959 | 2959 | |
@@ -2969,14 +2969,14 @@ discard block |
||
2969 | 2969 | * @param bool $sticky_notices This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice. |
2970 | 2970 | * @return void |
2971 | 2971 | */ |
2972 | - protected function _process_notices( $query_args = array(), $skip_route_verify = FALSE , $sticky_notices = TRUE ) { |
|
2972 | + protected function _process_notices($query_args = array(), $skip_route_verify = FALSE, $sticky_notices = TRUE) { |
|
2973 | 2973 | |
2974 | 2974 | $this->_template_args['notices'] = EE_Error::get_notices(); |
2975 | 2975 | |
2976 | 2976 | //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true) |
2977 | - if ( ! defined( 'DOING_AJAX' ) || $sticky_notices ) { |
|
2978 | - $route = isset( $query_args['action'] ) ? $query_args['action'] : 'default'; |
|
2979 | - $this->_add_transient( $route, $this->_template_args['notices'], TRUE, $skip_route_verify ); |
|
2977 | + if ( ! defined('DOING_AJAX') || $sticky_notices) { |
|
2978 | + $route = isset($query_args['action']) ? $query_args['action'] : 'default'; |
|
2979 | + $this->_add_transient($route, $this->_template_args['notices'], TRUE, $skip_route_verify); |
|
2980 | 2980 | } |
2981 | 2981 | } |
2982 | 2982 | |
@@ -2998,32 +2998,32 @@ discard block |
||
2998 | 2998 | * |
2999 | 2999 | * @return string html for button |
3000 | 3000 | */ |
3001 | - public function get_action_link_or_button($action, $type = 'add', $extra_request = array(), $class = 'button-primary', $base_url = FALSE, $exclude_nonce = false ) { |
|
3001 | + public function get_action_link_or_button($action, $type = 'add', $extra_request = array(), $class = 'button-primary', $base_url = FALSE, $exclude_nonce = false) { |
|
3002 | 3002 | //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along) |
3003 | - if ( !isset($this->_page_routes[$action]) && !$base_url ) |
|
3004 | - throw new EE_Error( sprintf( __('There is no page route for given action for the button. This action was given: %s', 'event_espresso'), $action) ); |
|
3003 | + if ( ! isset($this->_page_routes[$action]) && ! $base_url) |
|
3004 | + throw new EE_Error(sprintf(__('There is no page route for given action for the button. This action was given: %s', 'event_espresso'), $action)); |
|
3005 | 3005 | |
3006 | - if ( !isset( $this->_labels['buttons'][$type] ) ) |
|
3007 | - throw new EE_Error( sprintf( __('There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', 'event_espresso'), $type) ); |
|
3006 | + if ( ! isset($this->_labels['buttons'][$type])) |
|
3007 | + throw new EE_Error(sprintf(__('There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', 'event_espresso'), $type)); |
|
3008 | 3008 | |
3009 | 3009 | //finally check user access for this button. |
3010 | - $has_access = $this->check_user_access( $action, TRUE ); |
|
3011 | - if ( ! $has_access ) { |
|
3010 | + $has_access = $this->check_user_access($action, TRUE); |
|
3011 | + if ( ! $has_access) { |
|
3012 | 3012 | return ''; |
3013 | 3013 | } |
3014 | 3014 | |
3015 | - $_base_url = !$base_url ? $this->_admin_base_url : $base_url; |
|
3015 | + $_base_url = ! $base_url ? $this->_admin_base_url : $base_url; |
|
3016 | 3016 | |
3017 | 3017 | $query_args = array( |
3018 | 3018 | 'action' => $action ); |
3019 | 3019 | |
3020 | 3020 | //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten. |
3021 | - if ( !empty($extra_request) ) |
|
3022 | - $query_args = array_merge( $extra_request, $query_args ); |
|
3021 | + if ( ! empty($extra_request)) |
|
3022 | + $query_args = array_merge($extra_request, $query_args); |
|
3023 | 3023 | |
3024 | - $url = self::add_query_args_and_nonce( $query_args, $_base_url, false, $exclude_nonce ); |
|
3024 | + $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce); |
|
3025 | 3025 | |
3026 | - $button = EEH_Template::get_button_or_link( $url, $this->_labels['buttons'][$type], $class ); |
|
3026 | + $button = EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class); |
|
3027 | 3027 | |
3028 | 3028 | return $button; |
3029 | 3029 | } |
@@ -3043,11 +3043,11 @@ discard block |
||
3043 | 3043 | $args = array( |
3044 | 3044 | 'label' => $this->_admin_page_title, |
3045 | 3045 | 'default' => 10, |
3046 | - 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page' |
|
3046 | + 'option' => $this->_current_page.'_'.$this->_current_view.'_per_page' |
|
3047 | 3047 | ); |
3048 | 3048 | //ONLY add the screen option if the user has access to it. |
3049 | - if ( $this->check_user_access( $this->_current_view, true ) ) { |
|
3050 | - add_screen_option( $option, $args ); |
|
3049 | + if ($this->check_user_access($this->_current_view, true)) { |
|
3050 | + add_screen_option($option, $args); |
|
3051 | 3051 | } |
3052 | 3052 | } |
3053 | 3053 | |
@@ -3063,36 +3063,36 @@ discard block |
||
3063 | 3063 | * @return void |
3064 | 3064 | */ |
3065 | 3065 | private function _set_per_page_screen_options() { |
3066 | - if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
|
3067 | - check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
|
3066 | + if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
3067 | + check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
3068 | 3068 | |
3069 | - if ( !$user = wp_get_current_user() ) |
|
3069 | + if ( ! $user = wp_get_current_user()) |
|
3070 | 3070 | return; |
3071 | 3071 | $option = $_POST['wp_screen_options']['option']; |
3072 | 3072 | $value = $_POST['wp_screen_options']['value']; |
3073 | 3073 | |
3074 | - if ( $option != sanitize_key( $option ) ) |
|
3074 | + if ($option != sanitize_key($option)) |
|
3075 | 3075 | return; |
3076 | 3076 | |
3077 | 3077 | $map_option = $option; |
3078 | 3078 | |
3079 | 3079 | $option = str_replace('-', '_', $option); |
3080 | 3080 | |
3081 | - switch ( $map_option ) { |
|
3082 | - case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
3081 | + switch ($map_option) { |
|
3082 | + case $this->_current_page.'_'.$this->_current_view.'_per_page': |
|
3083 | 3083 | $value = (int) $value; |
3084 | - if ( $value < 1 || $value > 999 ) |
|
3084 | + if ($value < 1 || $value > 999) |
|
3085 | 3085 | return; |
3086 | 3086 | break; |
3087 | 3087 | default: |
3088 | - $value = apply_filters( 'FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value ); |
|
3089 | - if ( false === $value ) |
|
3088 | + $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value); |
|
3089 | + if (false === $value) |
|
3090 | 3090 | return; |
3091 | 3091 | break; |
3092 | 3092 | } |
3093 | 3093 | |
3094 | 3094 | update_user_meta($user->ID, $option, $value); |
3095 | - wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) ); |
|
3095 | + wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
3096 | 3096 | exit; |
3097 | 3097 | } |
3098 | 3098 | } |
@@ -3103,8 +3103,8 @@ discard block |
||
3103 | 3103 | * This just allows for setting the $_template_args property if it needs to be set outside the object |
3104 | 3104 | * @param array $data array that will be assigned to template args. |
3105 | 3105 | */ |
3106 | - public function set_template_args( $data ) { |
|
3107 | - $this->_template_args = array_merge( $this->_template_args, (array) $data ); |
|
3106 | + public function set_template_args($data) { |
|
3107 | + $this->_template_args = array_merge($this->_template_args, (array) $data); |
|
3108 | 3108 | } |
3109 | 3109 | |
3110 | 3110 | |
@@ -3120,26 +3120,26 @@ discard block |
||
3120 | 3120 | * @param bool $skip_route_verify Used to indicate we want to skip route verification. This is usually ONLY used when we are adding a transient before page_routes have been defined. |
3121 | 3121 | * @return void |
3122 | 3122 | */ |
3123 | - protected function _add_transient( $route, $data, $notices = FALSE, $skip_route_verify = FALSE ) { |
|
3123 | + protected function _add_transient($route, $data, $notices = FALSE, $skip_route_verify = FALSE) { |
|
3124 | 3124 | $user_id = get_current_user_id(); |
3125 | 3125 | |
3126 | - if ( !$skip_route_verify ) |
|
3126 | + if ( ! $skip_route_verify) |
|
3127 | 3127 | $this->_verify_route($route); |
3128 | 3128 | |
3129 | 3129 | |
3130 | 3130 | //now let's set the string for what kind of transient we're setting |
3131 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3132 | - $data = $notices ? array( 'notices' => $data ) : $data; |
|
3131 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
3132 | + $data = $notices ? array('notices' => $data) : $data; |
|
3133 | 3133 | //is there already a transient for this route? If there is then let's ADD to that transient |
3134 | - $existing = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient ); |
|
3135 | - if ( $existing ) { |
|
3136 | - $data = array_merge( (array) $data, (array) $existing ); |
|
3134 | + $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3135 | + if ($existing) { |
|
3136 | + $data = array_merge((array) $data, (array) $existing); |
|
3137 | 3137 | } |
3138 | 3138 | |
3139 | - if ( is_multisite() && is_network_admin() ) { |
|
3140 | - set_site_transient( $transient, $data, 8 ); |
|
3139 | + if (is_multisite() && is_network_admin()) { |
|
3140 | + set_site_transient($transient, $data, 8); |
|
3141 | 3141 | } else { |
3142 | - set_transient( $transient, $data, 8 ); |
|
3142 | + set_transient($transient, $data, 8); |
|
3143 | 3143 | } |
3144 | 3144 | } |
3145 | 3145 | |
@@ -3151,18 +3151,18 @@ discard block |
||
3151 | 3151 | * @param bool $notices true we get notices transient. False we just return normal route transient |
3152 | 3152 | * @return mixed data |
3153 | 3153 | */ |
3154 | - protected function _get_transient( $notices = FALSE, $route = FALSE ) { |
|
3154 | + protected function _get_transient($notices = FALSE, $route = FALSE) { |
|
3155 | 3155 | $user_id = get_current_user_id(); |
3156 | - $route = !$route ? $this->_req_action : $route; |
|
3157 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3158 | - $data = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient ); |
|
3156 | + $route = ! $route ? $this->_req_action : $route; |
|
3157 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
3158 | + $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3159 | 3159 | //delete transient after retrieval (just in case it hasn't expired); |
3160 | - if ( is_multisite() && is_network_admin() ) { |
|
3161 | - delete_site_transient( $transient ); |
|
3160 | + if (is_multisite() && is_network_admin()) { |
|
3161 | + delete_site_transient($transient); |
|
3162 | 3162 | } else { |
3163 | - delete_transient( $transient ); |
|
3163 | + delete_transient($transient); |
|
3164 | 3164 | } |
3165 | - return $notices && isset( $data['notices'] ) ? $data['notices'] : $data; |
|
3165 | + return $notices && isset($data['notices']) ? $data['notices'] : $data; |
|
3166 | 3166 | } |
3167 | 3167 | |
3168 | 3168 | |
@@ -3179,12 +3179,12 @@ discard block |
||
3179 | 3179 | |
3180 | 3180 | //retrieve all existing transients |
3181 | 3181 | $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'"; |
3182 | - if ( $results = $wpdb->get_results( $query ) ) { |
|
3183 | - foreach ( $results as $result ) { |
|
3184 | - $transient = str_replace( '_transient_', '', $result->option_name ); |
|
3185 | - get_transient( $transient ); |
|
3186 | - if ( is_multisite() && is_network_admin() ) { |
|
3187 | - get_site_transient( $transient ); |
|
3182 | + if ($results = $wpdb->get_results($query)) { |
|
3183 | + foreach ($results as $result) { |
|
3184 | + $transient = str_replace('_transient_', '', $result->option_name); |
|
3185 | + get_transient($transient); |
|
3186 | + if (is_multisite() && is_network_admin()) { |
|
3187 | + get_site_transient($transient); |
|
3188 | 3188 | } |
3189 | 3189 | } |
3190 | 3190 | } |
@@ -3308,23 +3308,23 @@ discard block |
||
3308 | 3308 | * @param string $line line no where error occurred |
3309 | 3309 | * @return boolean |
3310 | 3310 | */ |
3311 | - protected function _update_espresso_configuration( $tab, $config, $file = '', $func = '', $line = '' ) { |
|
3311 | + protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') { |
|
3312 | 3312 | |
3313 | 3313 | //remove any options that are NOT going to be saved with the config settings. |
3314 | - if ( isset( $config->core->ee_ueip_optin ) ) { |
|
3314 | + if (isset($config->core->ee_ueip_optin)) { |
|
3315 | 3315 | $config->core->ee_ueip_has_notified = TRUE; |
3316 | 3316 | // TODO: remove the following two lines and make sure values are migrated from 3.1 |
3317 | - update_option( 'ee_ueip_optin', $config->core->ee_ueip_optin); |
|
3318 | - update_option( 'ee_ueip_has_notified', TRUE ); |
|
3317 | + update_option('ee_ueip_optin', $config->core->ee_ueip_optin); |
|
3318 | + update_option('ee_ueip_has_notified', TRUE); |
|
3319 | 3319 | } |
3320 | 3320 | // and save it (note we're also doing the network save here) |
3321 | - $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config( FALSE, FALSE ) : TRUE; |
|
3322 | - $config_saved = EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
3323 | - if ( $config_saved && $net_saved ) { |
|
3324 | - EE_Error::add_success( sprintf( __('"%s" have been successfully updated.', 'event_espresso'), $tab )); |
|
3321 | + $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(FALSE, FALSE) : TRUE; |
|
3322 | + $config_saved = EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
3323 | + if ($config_saved && $net_saved) { |
|
3324 | + EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab)); |
|
3325 | 3325 | return TRUE; |
3326 | 3326 | } else { |
3327 | - EE_Error::add_error( sprintf( __('The "%s" were not updated.', 'event_espresso'), $tab ), $file, $func, $line ); |
|
3327 | + EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line); |
|
3328 | 3328 | return FALSE; |
3329 | 3329 | } |
3330 | 3330 | } |
@@ -3337,7 +3337,7 @@ discard block |
||
3337 | 3337 | * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument. |
3338 | 3338 | * @return array |
3339 | 3339 | */ |
3340 | - public function get_yes_no_values(){ |
|
3340 | + public function get_yes_no_values() { |
|
3341 | 3341 | return $this->_yes_no_values; |
3342 | 3342 | } |
3343 | 3343 | |
@@ -3359,8 +3359,8 @@ discard block |
||
3359 | 3359 | * |
3360 | 3360 | * @return string |
3361 | 3361 | */ |
3362 | - protected function _next_link( $url, $class = 'dashicons dashicons-arrow-right' ) { |
|
3363 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3362 | + protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') { |
|
3363 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
3364 | 3364 | } |
3365 | 3365 | |
3366 | 3366 | |
@@ -3374,8 +3374,8 @@ discard block |
||
3374 | 3374 | * |
3375 | 3375 | * @return string |
3376 | 3376 | */ |
3377 | - protected function _previous_link( $url, $class = 'dashicons dashicons-arrow-left' ) { |
|
3378 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3377 | + protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') { |
|
3378 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
3379 | 3379 | } |
3380 | 3380 | |
3381 | 3381 | |
@@ -3394,8 +3394,8 @@ discard block |
||
3394 | 3394 | * @return bool success/fail |
3395 | 3395 | */ |
3396 | 3396 | protected function _process_resend_registration() { |
3397 | - $this->_template_args['success'] = EED_Messages::process_resend( $this->_req_data ); |
|
3398 | - do_action( 'AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data ); |
|
3397 | + $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data); |
|
3398 | + do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data); |
|
3399 | 3399 | return $this->_template_args['success']; |
3400 | 3400 | } |
3401 | 3401 | |
@@ -3408,11 +3408,11 @@ discard block |
||
3408 | 3408 | * @param \EE_Payment $payment |
3409 | 3409 | * @return bool success/fail |
3410 | 3410 | */ |
3411 | - protected function _process_payment_notification( EE_Payment $payment ) { |
|
3412 | - add_filter( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true' ); |
|
3413 | - do_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', $payment ); |
|
3414 | - $this->_template_args['success'] = apply_filters( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment ); |
|
3415 | - return $this->_template_args[ 'success' ]; |
|
3411 | + protected function _process_payment_notification(EE_Payment $payment) { |
|
3412 | + add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true'); |
|
3413 | + do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment); |
|
3414 | + $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment); |
|
3415 | + return $this->_template_args['success']; |
|
3416 | 3416 | } |
3417 | 3417 | |
3418 | 3418 |
@@ -1092,14 +1092,14 @@ discard block |
||
1092 | 1092 | $QSG_ID = reset( $id_col ); |
1093 | 1093 | } else { |
1094 | 1094 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1095 | - EE_Log::instance()->log( |
|
1096 | - __FILE__, |
|
1097 | - __FUNCTION__, |
|
1098 | - sprintf( |
|
1099 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1100 | - $QST_ID ), |
|
1101 | - 'error' ); |
|
1102 | - continue; |
|
1095 | + EE_Log::instance()->log( |
|
1096 | + __FILE__, |
|
1097 | + __FUNCTION__, |
|
1098 | + sprintf( |
|
1099 | + __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1100 | + $QST_ID ), |
|
1101 | + 'error' ); |
|
1102 | + continue; |
|
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 | |
@@ -1629,8 +1629,8 @@ discard block |
||
1629 | 1629 | } |
1630 | 1630 | } |
1631 | 1631 | } |
1632 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1633 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1632 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1633 | + remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1634 | 1634 | |
1635 | 1635 | if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
1636 | 1636 | $db_update_sans_ee4 = array(); |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param $table_name |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
60 | + public static function ensure_table_name_has_prefix($table_name) { |
|
61 | 61 | global $wpdb; |
62 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
62 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * be called on plugin activation and reactivation |
86 | 86 | * @return boolean success, whether the database and folders are setup properly |
87 | 87 | */ |
88 | - public static function initialize_db_and_folders(){ |
|
88 | + public static function initialize_db_and_folders() { |
|
89 | 89 | $good_filesystem = EEH_Activation::create_upload_directories(); |
90 | 90 | $good_db = EEH_Activation::create_database_tables(); |
91 | 91 | return $good_filesystem && $good_db; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * upon activation of a new plugin, reactivation, and at the end |
100 | 100 | * of running migration scripts |
101 | 101 | */ |
102 | - public static function initialize_db_content(){ |
|
102 | + public static function initialize_db_content() { |
|
103 | 103 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
104 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
104 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | EEH_Activation::remove_cron_tasks(); |
119 | 119 | EEH_Activation::create_cron_tasks(); |
120 | 120 | //also, check for CAF default db content |
121 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
121 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
122 | 122 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
123 | 123 | //which users really won't care about on initial activation |
124 | 124 | EE_Error::overwrite_success(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return array |
138 | 138 | * @throws \EE_Error |
139 | 139 | */ |
140 | - public static function get_cron_tasks( $which_to_include ) { |
|
140 | + public static function get_cron_tasks($which_to_include) { |
|
141 | 141 | $cron_tasks = apply_filters( |
142 | 142 | 'FHEE__EEH_Activation__get_cron_tasks', |
143 | 143 | array( |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
147 | 147 | ) |
148 | 148 | ); |
149 | - if( $which_to_include === 'all' ) { |
|
149 | + if ($which_to_include === 'all') { |
|
150 | 150 | //leave as-is |
151 | - }elseif( $which_to_include === 'old' ) { |
|
152 | - $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
|
151 | + }elseif ($which_to_include === 'old') { |
|
152 | + $cron_tasks = array_filter($cron_tasks, function($value) { |
|
153 | 153 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
154 | 154 | }); |
155 | - }elseif( $which_to_include === 'current' ) { |
|
156 | - $cron_tasks = array_filter( $cron_tasks ); |
|
157 | - }elseif( WP_DEBUG ) { |
|
158 | - throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
|
159 | - }else{ |
|
155 | + }elseif ($which_to_include === 'current') { |
|
156 | + $cron_tasks = array_filter($cron_tasks); |
|
157 | + }elseif (WP_DEBUG) { |
|
158 | + throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include)); |
|
159 | + } else { |
|
160 | 160 | //leave as-is |
161 | 161 | } |
162 | 162 | return $cron_tasks; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public static function create_cron_tasks() { |
169 | 169 | |
170 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
171 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
172 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
170 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
171 | + if ( ! wp_next_scheduled($hook_name)) { |
|
172 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * Remove the currently-existing and now-removed cron tasks. |
180 | 180 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
181 | 181 | */ |
182 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
182 | + public static function remove_cron_tasks($remove_all = true) { |
|
183 | 183 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
184 | 184 | $crons = _get_cron_array(); |
185 | - $crons = is_array( $crons ) ? $crons : array(); |
|
185 | + $crons = is_array($crons) ? $crons : array(); |
|
186 | 186 | /* reminder that $crons looks like: top-level keys are timestamps, |
187 | 187 | * and their values are arrays. |
188 | 188 | * The 2nd level arrays have keys with each of the cron task hooknames to run at that time |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | * ... |
201 | 201 | * ... |
202 | 202 | */ |
203 | - foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) { |
|
204 | - foreach( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
205 | - if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) ) { |
|
206 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
203 | + foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) { |
|
204 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
205 | + if (array_key_exists($hook_name, $hooks_to_fire_at_time)) { |
|
206 | + unset($crons[$timestamp][$hook_name]); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
210 | - _set_cron_array( $crons ); |
|
210 | + _set_cron_array($crons); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public static function CPT_initialization() { |
224 | 224 | // register Custom Post Types |
225 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
225 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
226 | 226 | flush_rewrite_rules(); |
227 | 227 | } |
228 | 228 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @return void |
241 | 241 | */ |
242 | 242 | public static function reset_and_update_config() { |
243 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
244 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
243 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
244 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
245 | 245 | //EE_Config::reset(); |
246 | 246 | } |
247 | 247 | |
@@ -254,23 +254,23 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public static function load_calendar_config() { |
256 | 256 | // grab array of all plugin folders and loop thru it |
257 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
258 | - if ( empty( $plugins ) ) { |
|
257 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
258 | + if (empty($plugins)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | - foreach ( $plugins as $plugin_path ) { |
|
261 | + foreach ($plugins as $plugin_path) { |
|
262 | 262 | // grab plugin folder name from path |
263 | - $plugin = basename( $plugin_path ); |
|
263 | + $plugin = basename($plugin_path); |
|
264 | 264 | // drill down to Espresso plugins |
265 | - if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) { |
|
265 | + if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) { |
|
266 | 266 | // then to calendar related plugins |
267 | - if ( strpos( $plugin, 'calendar' ) !== FALSE ) { |
|
267 | + if (strpos($plugin, 'calendar') !== FALSE) { |
|
268 | 268 | // this is what we are looking for |
269 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
269 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
270 | 270 | // does it exist in this folder ? |
271 | - if ( is_readable( $calendar_config )) { |
|
271 | + if (is_readable($calendar_config)) { |
|
272 | 272 | // YEAH! let's load it |
273 | - require_once( $calendar_config ); |
|
273 | + require_once($calendar_config); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
@@ -287,21 +287,21 @@ discard block |
||
287 | 287 | * @param \EE_Config $EE_Config |
288 | 288 | * @return \stdClass |
289 | 289 | */ |
290 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
291 | - $convert_from_array = array( 'addons' ); |
|
290 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
291 | + $convert_from_array = array('addons'); |
|
292 | 292 | // in case old settings were saved as an array |
293 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
293 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
294 | 294 | // convert existing settings to an object |
295 | 295 | $config_array = $settings; |
296 | 296 | $settings = new stdClass(); |
297 | - foreach ( $config_array as $key => $value ){ |
|
298 | - if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
299 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
297 | + foreach ($config_array as $key => $value) { |
|
298 | + if ($key == 'calendar' && class_exists('EE_Calendar_Config')) { |
|
299 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
300 | 300 | } else { |
301 | 301 | $settings->$key = $value; |
302 | 302 | } |
303 | 303 | } |
304 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
304 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
305 | 305 | } |
306 | 306 | return $settings; |
307 | 307 | } |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public static function deactivate_event_espresso() { |
319 | 319 | // check permissions |
320 | - if ( current_user_can( 'activate_plugins' )) { |
|
321 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
320 | + if (current_user_can('activate_plugins')) { |
|
321 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -340,79 +340,79 @@ discard block |
||
340 | 340 | $critical_pages = array( |
341 | 341 | array( |
342 | 342 | 'id' =>'reg_page_id', |
343 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
343 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
344 | 344 | 'post' => NULL, |
345 | 345 | 'code' => 'ESPRESSO_CHECKOUT' |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'id' => 'txn_page_id', |
349 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
349 | + 'name' => __('Transactions', 'event_espresso'), |
|
350 | 350 | 'post' => NULL, |
351 | 351 | 'code' => 'ESPRESSO_TXN_PAGE' |
352 | 352 | ), |
353 | 353 | array( |
354 | 354 | 'id' => 'thank_you_page_id', |
355 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
355 | + 'name' => __('Thank You', 'event_espresso'), |
|
356 | 356 | 'post' => NULL, |
357 | 357 | 'code' => 'ESPRESSO_THANK_YOU' |
358 | 358 | ), |
359 | 359 | array( |
360 | 360 | 'id' => 'cancel_page_id', |
361 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
361 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
362 | 362 | 'post' => NULL, |
363 | 363 | 'code' => 'ESPRESSO_CANCELLED' |
364 | 364 | ), |
365 | 365 | ); |
366 | 366 | |
367 | - foreach ( $critical_pages as $critical_page ) { |
|
367 | + foreach ($critical_pages as $critical_page) { |
|
368 | 368 | // is critical page ID set in config ? |
369 | - if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) { |
|
369 | + if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) { |
|
370 | 370 | // attempt to find post by ID |
371 | - $critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] ); |
|
371 | + $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']); |
|
372 | 372 | } |
373 | 373 | // no dice? |
374 | - if ( $critical_page['post'] == NULL ) { |
|
374 | + if ($critical_page['post'] == NULL) { |
|
375 | 375 | // attempt to find post by title |
376 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
376 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
377 | 377 | // still nothing? |
378 | - if ( $critical_page['post'] == NULL ) { |
|
379 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
378 | + if ($critical_page['post'] == NULL) { |
|
379 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
380 | 380 | // REALLY? Still nothing ??!?!? |
381 | - if ( $critical_page['post'] == NULL ) { |
|
382 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
383 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
381 | + if ($critical_page['post'] == NULL) { |
|
382 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
383 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
384 | 384 | break; |
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
388 | 388 | // track post_shortcodes |
389 | - if ( $critical_page['post'] ) { |
|
390 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
389 | + if ($critical_page['post']) { |
|
390 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
391 | 391 | } |
392 | 392 | // check that Post ID matches critical page ID in config |
393 | - if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) { |
|
393 | + if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) { |
|
394 | 394 | //update Config with post ID |
395 | 395 | EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID; |
396 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
397 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
398 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
396 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
397 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
398 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | - $critical_page_problem = ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem; |
|
402 | + $critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem; |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
406 | - if ( $critical_page_problem ) { |
|
406 | + if ($critical_page_problem) { |
|
407 | 407 | $msg = sprintf( |
408 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
409 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
408 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
409 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
410 | 410 | ); |
411 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
411 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
412 | 412 | } |
413 | 413 | |
414 | - if ( EE_Error::has_notices() ) { |
|
415 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
414 | + if (EE_Error::has_notices()) { |
|
415 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | } |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | * parameter to the shortcode |
426 | 426 | * @return WP_Post or NULl |
427 | 427 | */ |
428 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
428 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
429 | 429 | global $wpdb; |
430 | 430 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
431 | 431 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
432 | - if($post_id){ |
|
432 | + if ($post_id) { |
|
433 | 433 | return get_post($post_id); |
434 | - }else{ |
|
434 | + } else { |
|
435 | 435 | return NULL; |
436 | 436 | } |
437 | 437 | |
@@ -448,32 +448,32 @@ discard block |
||
448 | 448 | * @param array $critical_page |
449 | 449 | * @return array |
450 | 450 | */ |
451 | - public static function create_critical_page( $critical_page ) { |
|
451 | + public static function create_critical_page($critical_page) { |
|
452 | 452 | |
453 | 453 | $post_args = array( |
454 | 454 | 'post_title' => $critical_page['name'], |
455 | 455 | 'post_status' => 'publish', |
456 | 456 | 'post_type' => 'page', |
457 | 457 | 'comment_status' => 'closed', |
458 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
458 | + 'post_content' => '['.$critical_page['code'].']' |
|
459 | 459 | ); |
460 | 460 | |
461 | - $post_id = wp_insert_post( $post_args ); |
|
462 | - if ( ! $post_id ) { |
|
461 | + $post_id = wp_insert_post($post_args); |
|
462 | + if ( ! $post_id) { |
|
463 | 463 | $msg = sprintf( |
464 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
464 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
465 | 465 | $critical_page['name'] |
466 | 466 | ); |
467 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
467 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
468 | 468 | return $critical_page; |
469 | 469 | } |
470 | 470 | // get newly created post's details |
471 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
471 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
472 | 472 | $msg = sprintf( |
473 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
473 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
474 | 474 | $critical_page['name'] |
475 | 475 | ); |
476 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
476 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | return $critical_page; |
@@ -492,34 +492,34 @@ discard block |
||
492 | 492 | * @param array $critical_page |
493 | 493 | * @return void |
494 | 494 | */ |
495 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
495 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
496 | 496 | // check the goods |
497 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
497 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
498 | 498 | $msg = sprintf( |
499 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
499 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
500 | 500 | $critical_page['name'] |
501 | 501 | ); |
502 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
502 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
503 | 503 | return; |
504 | 504 | } |
505 | 505 | // map shortcode to post |
506 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
506 | + EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
507 | 507 | // and make sure it's NOT added to the WP "Posts Page" |
508 | 508 | // name of the WP Posts Page |
509 | 509 | $posts_page = EE_Registry::instance()->CFG->get_page_for_posts(); |
510 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) { |
|
511 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
510 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) { |
|
511 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]); |
|
512 | 512 | } |
513 | - if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) { |
|
514 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
513 | + if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) { |
|
514 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]); |
|
515 | 515 | } |
516 | 516 | // update post_shortcode CFG |
517 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
517 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
518 | 518 | $msg = sprintf( |
519 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
519 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
520 | 520 | $critical_page['name'] |
521 | 521 | ); |
522 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
522 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
@@ -537,24 +537,24 @@ discard block |
||
537 | 537 | public static function get_default_creator_id() { |
538 | 538 | global $wpdb; |
539 | 539 | |
540 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
540 | + if ( ! empty(self::$_default_creator_id)) { |
|
541 | 541 | return self::$_default_creator_id; |
542 | 542 | }/**/ |
543 | 543 | |
544 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
544 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
545 | 545 | |
546 | 546 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
547 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
548 | - if ( $pre_filtered_id !== false ) { |
|
547 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
548 | + if ($pre_filtered_id !== false) { |
|
549 | 549 | return (int) $pre_filtered_id; |
550 | 550 | } |
551 | 551 | |
552 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
553 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
554 | - $user_id = $wpdb->get_var( $query ); |
|
555 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
556 | - if ( $user_id && intval( $user_id ) ) { |
|
557 | - self::$_default_creator_id = intval( $user_id ); |
|
552 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
553 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
554 | + $user_id = $wpdb->get_var($query); |
|
555 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
556 | + if ($user_id && intval($user_id)) { |
|
557 | + self::$_default_creator_id = intval($user_id); |
|
558 | 558 | return self::$_default_creator_id; |
559 | 559 | } else { |
560 | 560 | return NULL; |
@@ -581,29 +581,29 @@ discard block |
||
581 | 581 | * @return void |
582 | 582 | * @throws EE_Error if there are database errors |
583 | 583 | */ |
584 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
585 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
584 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
585 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
586 | 586 | return; |
587 | 587 | } |
588 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
589 | - if ( ! function_exists( 'dbDelta' )) { |
|
590 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
588 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
589 | + if ( ! function_exists('dbDelta')) { |
|
590 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
591 | 591 | } |
592 | 592 | /** @var WPDB $wpdb */ |
593 | 593 | global $wpdb; |
594 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
594 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
595 | 595 | // do we need to first delete an existing version of this table ? |
596 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
596 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
597 | 597 | // ok, delete the table... but ONLY if it's empty |
598 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
598 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
599 | 599 | // table is NOT empty, are you SURE you want to delete this table ??? |
600 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
601 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
602 | - } else if ( ! $deleted_safely ) { |
|
600 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
601 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
602 | + } else if ( ! $deleted_safely) { |
|
603 | 603 | // so we should be more cautious rather than just dropping tables so easily |
604 | 604 | EE_Error::add_persistent_admin_notice( |
605 | - 'bad_table_' . $wp_table_name . '_detected', |
|
606 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
605 | + 'bad_table_'.$wp_table_name.'_detected', |
|
606 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
607 | 607 | $wp_table_name, |
608 | 608 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
609 | 609 | '<b>wp-config.php</b>', |
@@ -612,25 +612,25 @@ discard block |
||
612 | 612 | } |
613 | 613 | } |
614 | 614 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
615 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
615 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
616 | 616 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
617 | 617 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
618 | 618 | //happened. And then we can choose to tell the end user |
619 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
620 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
619 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
620 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
621 | 621 | ob_start(); |
622 | - dbDelta( $SQL ); |
|
622 | + dbDelta($SQL); |
|
623 | 623 | $output = ob_get_contents(); |
624 | 624 | ob_end_clean(); |
625 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
626 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
627 | - if( ! empty( $output ) ){ |
|
628 | - throw new EE_Error( $output ); |
|
625 | + $wpdb->show_errors($old_show_errors_policy); |
|
626 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
627 | + if ( ! empty($output)) { |
|
628 | + throw new EE_Error($output); |
|
629 | 629 | } |
630 | 630 | } else { |
631 | 631 | throw new EE_Error( |
632 | 632 | sprintf( |
633 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
633 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
634 | 634 | '<br />', |
635 | 635 | $sql |
636 | 636 | ) |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)' |
653 | 653 | * @return bool|int |
654 | 654 | */ |
655 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
656 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
655 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
656 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
657 | 657 | return FALSE; |
658 | 658 | } |
659 | 659 | global $wpdb; |
660 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
660 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
661 | 661 | $fields = self::get_fields_on_table($table_name); |
662 | - if (!in_array($column_name, $fields)){ |
|
663 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
662 | + if ( ! in_array($column_name, $fields)) { |
|
663 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
664 | 664 | //echo "alter query:$alter_query"; |
665 | 665 | return $wpdb->query($alter_query); |
666 | 666 | } |
@@ -679,15 +679,15 @@ discard block |
||
679 | 679 | * @param string $table_name, without prefixed $wpdb->prefix |
680 | 680 | * @return array of database column names |
681 | 681 | */ |
682 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
682 | + public static function get_fields_on_table($table_name = NULL) { |
|
683 | 683 | global $wpdb; |
684 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
685 | - if ( ! empty( $table_name )) { |
|
684 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
685 | + if ( ! empty($table_name)) { |
|
686 | 686 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
687 | 687 | if ($columns !== FALSE) { |
688 | 688 | $field_array = array(); |
689 | - foreach($columns as $column ){ |
|
690 | - $field_array[] = $column->Field;; |
|
689 | + foreach ($columns as $column) { |
|
690 | + $field_array[] = $column->Field; ; |
|
691 | 691 | } |
692 | 692 | return $field_array; |
693 | 693 | } |
@@ -705,12 +705,12 @@ discard block |
||
705 | 705 | * @param string $table_name |
706 | 706 | * @return bool |
707 | 707 | */ |
708 | - public static function db_table_is_empty( $table_name ) { |
|
708 | + public static function db_table_is_empty($table_name) { |
|
709 | 709 | global $wpdb; |
710 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
711 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
712 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
713 | - return absint( $count ) === 0 ? true : false; |
|
710 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
711 | + if (EEH_Activation::table_exists($table_name)) { |
|
712 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
713 | + return absint($count) === 0 ? true : false; |
|
714 | 714 | } |
715 | 715 | return false; |
716 | 716 | } |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | * @param string $table_name |
726 | 726 | * @return bool | int |
727 | 727 | */ |
728 | - public static function delete_db_table_if_empty( $table_name ) { |
|
729 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
730 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
728 | + public static function delete_db_table_if_empty($table_name) { |
|
729 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
730 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
731 | 731 | } |
732 | 732 | return false; |
733 | 733 | } |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | * @param string $table_name |
743 | 743 | * @return bool | int |
744 | 744 | */ |
745 | - public static function delete_unused_db_table( $table_name ) { |
|
745 | + public static function delete_unused_db_table($table_name) { |
|
746 | 746 | global $wpdb; |
747 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
748 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
749 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
747 | + if (EEH_Activation::table_exists($table_name)) { |
|
748 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
749 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
750 | 750 | } |
751 | 751 | return false; |
752 | 752 | } |
@@ -762,18 +762,18 @@ discard block |
||
762 | 762 | * @param string $index_name |
763 | 763 | * @return bool | int |
764 | 764 | */ |
765 | - public static function drop_index( $table_name, $index_name ) { |
|
766 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
765 | + public static function drop_index($table_name, $index_name) { |
|
766 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
767 | 767 | return FALSE; |
768 | 768 | } |
769 | 769 | global $wpdb; |
770 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
770 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
771 | 771 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
772 | 772 | if ( |
773 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name |
|
774 | - && $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
773 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name |
|
774 | + && $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
775 | 775 | ) { |
776 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
776 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
777 | 777 | } |
778 | 778 | return TRUE; |
779 | 779 | } |
@@ -789,27 +789,27 @@ discard block |
||
789 | 789 | * @return boolean success (whether database is setup properly or not) |
790 | 790 | */ |
791 | 791 | public static function create_database_tables() { |
792 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
792 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
793 | 793 | //find the migration script that sets the database to be compatible with the code |
794 | 794 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
795 | - if( $dms_name ){ |
|
796 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
797 | - $current_data_migration_script->set_migrating( false ); |
|
795 | + if ($dms_name) { |
|
796 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
797 | + $current_data_migration_script->set_migrating(false); |
|
798 | 798 | $current_data_migration_script->schema_changes_before_migration(); |
799 | 799 | $current_data_migration_script->schema_changes_after_migration(); |
800 | - if( $current_data_migration_script->get_errors() ){ |
|
801 | - if( WP_DEBUG ){ |
|
802 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
803 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
800 | + if ($current_data_migration_script->get_errors()) { |
|
801 | + if (WP_DEBUG) { |
|
802 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
803 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
804 | 804 | } |
805 | - }else{ |
|
806 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
805 | + } else { |
|
806 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
807 | 807 | } |
808 | 808 | return false; |
809 | 809 | } |
810 | 810 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
811 | - }else{ |
|
812 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
811 | + } else { |
|
812 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | return true; |
@@ -829,27 +829,27 @@ discard block |
||
829 | 829 | public static function initialize_system_questions() { |
830 | 830 | // QUESTION GROUPS |
831 | 831 | global $wpdb; |
832 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
832 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
833 | 833 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
834 | 834 | // what we have |
835 | - $question_groups = $wpdb->get_col( $SQL ); |
|
835 | + $question_groups = $wpdb->get_col($SQL); |
|
836 | 836 | // check the response |
837 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
837 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
838 | 838 | // what we should have |
839 | - $QSG_systems = array( 1, 2 ); |
|
839 | + $QSG_systems = array(1, 2); |
|
840 | 840 | // loop thru what we should have and compare to what we have |
841 | - foreach ( $QSG_systems as $QSG_system ) { |
|
841 | + foreach ($QSG_systems as $QSG_system) { |
|
842 | 842 | // reset values array |
843 | 843 | $QSG_values = array(); |
844 | 844 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
845 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
845 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
846 | 846 | // add it |
847 | - switch ( $QSG_system ) { |
|
847 | + switch ($QSG_system) { |
|
848 | 848 | |
849 | 849 | case 1: |
850 | 850 | $QSG_values = array( |
851 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
852 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
851 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
852 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
853 | 853 | 'QSG_desc' => '', |
854 | 854 | 'QSG_order' => 1, |
855 | 855 | 'QSG_show_group_name' => 1, |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | |
862 | 862 | case 2: |
863 | 863 | $QSG_values = array( |
864 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
865 | - 'QSG_identifier' => 'address-information-' . time(), |
|
864 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
865 | + 'QSG_identifier' => 'address-information-'.time(), |
|
866 | 866 | 'QSG_desc' => '', |
867 | 867 | 'QSG_order' => 2, |
868 | 868 | 'QSG_show_group_name' => 1, |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | |
875 | 875 | } |
876 | 876 | // make sure we have some values before inserting them |
877 | - if ( ! empty( $QSG_values )) { |
|
877 | + if ( ! empty($QSG_values)) { |
|
878 | 878 | // insert system question |
879 | 879 | $wpdb->insert( |
880 | 880 | $table_name, |
881 | 881 | $QSG_values, |
882 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
882 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
883 | 883 | ); |
884 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
884 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | } |
@@ -890,10 +890,10 @@ discard block |
||
890 | 890 | |
891 | 891 | // QUESTIONS |
892 | 892 | global $wpdb; |
893 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
893 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
894 | 894 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
895 | 895 | // what we have |
896 | - $questions = $wpdb->get_col( $SQL ); |
|
896 | + $questions = $wpdb->get_col($SQL); |
|
897 | 897 | // what we should have |
898 | 898 | $QST_systems = array( |
899 | 899 | 'fname', |
@@ -910,25 +910,25 @@ discard block |
||
910 | 910 | $order_for_group_1 = 1; |
911 | 911 | $order_for_group_2 = 1; |
912 | 912 | // loop thru what we should have and compare to what we have |
913 | - foreach ( $QST_systems as $QST_system ) { |
|
913 | + foreach ($QST_systems as $QST_system) { |
|
914 | 914 | // reset values array |
915 | 915 | $QST_values = array(); |
916 | 916 | // if we don't have what we should have |
917 | - if ( ! in_array( $QST_system, $questions )) { |
|
917 | + if ( ! in_array($QST_system, $questions)) { |
|
918 | 918 | // add it |
919 | - switch ( $QST_system ) { |
|
919 | + switch ($QST_system) { |
|
920 | 920 | |
921 | 921 | case 'fname': |
922 | 922 | $QST_values = array( |
923 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
924 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
923 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
924 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
925 | 925 | 'QST_system' => 'fname', |
926 | 926 | 'QST_type' => 'TEXT', |
927 | 927 | 'QST_required' => 1, |
928 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
928 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
929 | 929 | 'QST_order' => 1, |
930 | 930 | 'QST_admin_only' => 0, |
931 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
931 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
932 | 932 | 'QST_wp_user' => self::get_default_creator_id(), |
933 | 933 | 'QST_deleted' => 0 |
934 | 934 | ); |
@@ -936,15 +936,15 @@ discard block |
||
936 | 936 | |
937 | 937 | case 'lname': |
938 | 938 | $QST_values = array( |
939 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
940 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
939 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
940 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
941 | 941 | 'QST_system' => 'lname', |
942 | 942 | 'QST_type' => 'TEXT', |
943 | 943 | 'QST_required' => 1, |
944 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
944 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
945 | 945 | 'QST_order' => 2, |
946 | 946 | 'QST_admin_only' => 0, |
947 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
947 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
948 | 948 | 'QST_wp_user' => self::get_default_creator_id(), |
949 | 949 | 'QST_deleted' => 0 |
950 | 950 | ); |
@@ -952,15 +952,15 @@ discard block |
||
952 | 952 | |
953 | 953 | case 'email': |
954 | 954 | $QST_values = array( |
955 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
956 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
955 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
956 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
957 | 957 | 'QST_system' => 'email', |
958 | 958 | 'QST_type' => 'TEXT', |
959 | 959 | 'QST_required' => 1, |
960 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
960 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
961 | 961 | 'QST_order' => 3, |
962 | 962 | 'QST_admin_only' => 0, |
963 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
963 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
964 | 964 | 'QST_wp_user' => self::get_default_creator_id(), |
965 | 965 | 'QST_deleted' => 0 |
966 | 966 | ); |
@@ -968,15 +968,15 @@ discard block |
||
968 | 968 | |
969 | 969 | case 'address': |
970 | 970 | $QST_values = array( |
971 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
972 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
971 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
972 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
973 | 973 | 'QST_system' => 'address', |
974 | 974 | 'QST_type' => 'TEXT', |
975 | 975 | 'QST_required' => 0, |
976 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
976 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
977 | 977 | 'QST_order' => 4, |
978 | 978 | 'QST_admin_only' => 0, |
979 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
979 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
980 | 980 | 'QST_wp_user' => self::get_default_creator_id(), |
981 | 981 | 'QST_deleted' => 0 |
982 | 982 | ); |
@@ -984,15 +984,15 @@ discard block |
||
984 | 984 | |
985 | 985 | case 'address2': |
986 | 986 | $QST_values = array( |
987 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
988 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
987 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
988 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
989 | 989 | 'QST_system' => 'address2', |
990 | 990 | 'QST_type' => 'TEXT', |
991 | 991 | 'QST_required' => 0, |
992 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
992 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
993 | 993 | 'QST_order' => 5, |
994 | 994 | 'QST_admin_only' => 0, |
995 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
995 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
996 | 996 | 'QST_wp_user' => self::get_default_creator_id(), |
997 | 997 | 'QST_deleted' => 0 |
998 | 998 | ); |
@@ -1000,15 +1000,15 @@ discard block |
||
1000 | 1000 | |
1001 | 1001 | case 'city': |
1002 | 1002 | $QST_values = array( |
1003 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1004 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1003 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1004 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1005 | 1005 | 'QST_system' => 'city', |
1006 | 1006 | 'QST_type' => 'TEXT', |
1007 | 1007 | 'QST_required' => 0, |
1008 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1008 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1009 | 1009 | 'QST_order' => 6, |
1010 | 1010 | 'QST_admin_only' => 0, |
1011 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1011 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1012 | 1012 | 'QST_wp_user' => self::get_default_creator_id(), |
1013 | 1013 | 'QST_deleted' => 0 |
1014 | 1014 | ); |
@@ -1016,12 +1016,12 @@ discard block |
||
1016 | 1016 | |
1017 | 1017 | case 'state': |
1018 | 1018 | $QST_values = array( |
1019 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1020 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1019 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1020 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1021 | 1021 | 'QST_system' => 'state', |
1022 | 1022 | 'QST_type' => 'STATE', |
1023 | 1023 | 'QST_required' => 0, |
1024 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1024 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1025 | 1025 | 'QST_order' => 7, |
1026 | 1026 | 'QST_admin_only' => 0, |
1027 | 1027 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1031,12 +1031,12 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | case 'country' : |
1033 | 1033 | $QST_values = array( |
1034 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1035 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1034 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1035 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1036 | 1036 | 'QST_system' => 'country', |
1037 | 1037 | 'QST_type' => 'COUNTRY', |
1038 | 1038 | 'QST_required' => 0, |
1039 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1039 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1040 | 1040 | 'QST_order' => 8, |
1041 | 1041 | 'QST_admin_only' => 0, |
1042 | 1042 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1046,15 +1046,15 @@ discard block |
||
1046 | 1046 | |
1047 | 1047 | case 'zip': |
1048 | 1048 | $QST_values = array( |
1049 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1050 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1049 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1050 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1051 | 1051 | 'QST_system' => 'zip', |
1052 | 1052 | 'QST_type' => 'TEXT', |
1053 | 1053 | 'QST_required' => 0, |
1054 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1054 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1055 | 1055 | 'QST_order' => 9, |
1056 | 1056 | 'QST_admin_only' => 0, |
1057 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1057 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1058 | 1058 | 'QST_wp_user' => self::get_default_creator_id(), |
1059 | 1059 | 'QST_deleted' => 0 |
1060 | 1060 | ); |
@@ -1062,49 +1062,49 @@ discard block |
||
1062 | 1062 | |
1063 | 1063 | case 'phone': |
1064 | 1064 | $QST_values = array( |
1065 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1066 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1065 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1066 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1067 | 1067 | 'QST_system' => 'phone', |
1068 | 1068 | 'QST_type' => 'TEXT', |
1069 | 1069 | 'QST_required' => 0, |
1070 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1070 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1071 | 1071 | 'QST_order' => 10, |
1072 | 1072 | 'QST_admin_only' => 0, |
1073 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1073 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1074 | 1074 | 'QST_wp_user' => self::get_default_creator_id(), |
1075 | 1075 | 'QST_deleted' => 0 |
1076 | 1076 | ); |
1077 | 1077 | break; |
1078 | 1078 | |
1079 | 1079 | } |
1080 | - if ( ! empty( $QST_values )) { |
|
1080 | + if ( ! empty($QST_values)) { |
|
1081 | 1081 | // insert system question |
1082 | 1082 | $wpdb->insert( |
1083 | 1083 | $table_name, |
1084 | 1084 | $QST_values, |
1085 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1085 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1086 | 1086 | ); |
1087 | 1087 | $QST_ID = $wpdb->insert_id; |
1088 | 1088 | |
1089 | 1089 | // QUESTION GROUP QUESTIONS |
1090 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1090 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1091 | 1091 | $system_question_we_want = EEM_Question_Group::system_personal; |
1092 | 1092 | } else { |
1093 | 1093 | $system_question_we_want = EEM_Question_Group::system_address; |
1094 | 1094 | } |
1095 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1096 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1095 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1096 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1097 | 1097 | } else { |
1098 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1099 | - if( is_array( $id_col ) ) { |
|
1100 | - $QSG_ID = reset( $id_col ); |
|
1098 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1099 | + if (is_array($id_col)) { |
|
1100 | + $QSG_ID = reset($id_col); |
|
1101 | 1101 | } else { |
1102 | 1102 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1103 | 1103 | EE_Log::instance()->log( |
1104 | 1104 | __FILE__, |
1105 | 1105 | __FUNCTION__, |
1106 | 1106 | sprintf( |
1107 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1107 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1108 | 1108 | $QST_ID ), |
1109 | 1109 | 'error' ); |
1110 | 1110 | continue; |
@@ -1113,9 +1113,9 @@ discard block |
||
1113 | 1113 | |
1114 | 1114 | // add system questions to groups |
1115 | 1115 | $wpdb->insert( |
1116 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1117 | - array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ), |
|
1118 | - array( '%d', '%d','%d' ) |
|
1116 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1117 | + array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++), |
|
1118 | + array('%d', '%d', '%d') |
|
1119 | 1119 | ); |
1120 | 1120 | } |
1121 | 1121 | } |
@@ -1127,11 +1127,11 @@ discard block |
||
1127 | 1127 | * Makes sure the default payment method (Invoice) is active. |
1128 | 1128 | * This used to be done automatically as part of constructing the old gateways config |
1129 | 1129 | */ |
1130 | - public static function insert_default_payment_methods(){ |
|
1131 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1132 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1133 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1134 | - }else{ |
|
1130 | + public static function insert_default_payment_methods() { |
|
1131 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1132 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1133 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1134 | + } else { |
|
1135 | 1135 | EEM_Payment_Method::instance()->verify_button_urls(); |
1136 | 1136 | } |
1137 | 1137 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | global $wpdb; |
1149 | 1149 | |
1150 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1150 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1151 | 1151 | |
1152 | 1152 | $table_name = EEM_Status::instance()->table(); |
1153 | 1153 | |
@@ -1213,38 +1213,38 @@ discard block |
||
1213 | 1213 | * @return boolean success of verifying upload directories exist |
1214 | 1214 | */ |
1215 | 1215 | public static function create_upload_directories() { |
1216 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1216 | + EE_Registry::instance()->load_helper('File'); |
|
1217 | 1217 | // Create the required folders |
1218 | 1218 | $folders = array( |
1219 | 1219 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1220 | 1220 | EVENT_ESPRESSO_GATEWAY_DIR, |
1221 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1222 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1223 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1221 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1222 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1223 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1224 | 1224 | ); |
1225 | - foreach ( $folders as $folder ) { |
|
1225 | + foreach ($folders as $folder) { |
|
1226 | 1226 | try { |
1227 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1228 | - @ chmod( $folder, 0755 ); |
|
1229 | - } catch( EE_Error $e ){ |
|
1227 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1228 | + @ chmod($folder, 0755); |
|
1229 | + } catch (EE_Error $e) { |
|
1230 | 1230 | EE_Error::add_error( |
1231 | 1231 | sprintf( |
1232 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1232 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1233 | 1233 | $folder, |
1234 | - '<br />' . $e->getMessage() |
|
1234 | + '<br />'.$e->getMessage() |
|
1235 | 1235 | ), |
1236 | 1236 | __FILE__, __FUNCTION__, __LINE__ |
1237 | 1237 | ); |
1238 | 1238 | //indicate we'll need to fix this later |
1239 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1239 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1240 | 1240 | return FALSE; |
1241 | 1241 | } |
1242 | 1242 | } |
1243 | 1243 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1244 | 1244 | //is disabled, there might be activation errors recorded in there |
1245 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1245 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1246 | 1246 | //remember EE's folders are all good |
1247 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1247 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1248 | 1248 | return TRUE; |
1249 | 1249 | } |
1250 | 1250 | |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | * @return boolean |
1258 | 1258 | */ |
1259 | 1259 | public static function upload_directories_incomplete() { |
1260 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1260 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | |
@@ -1276,16 +1276,16 @@ discard block |
||
1276 | 1276 | $installed_messengers = $default_messengers = array(); |
1277 | 1277 | |
1278 | 1278 | //include our helper |
1279 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1279 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1280 | 1280 | |
1281 | 1281 | //get all installed messenger objects |
1282 | 1282 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1283 | 1283 | |
1284 | 1284 | //let's setup the $installed messengers in an array AND the messengers that are set to be activated on install. |
1285 | - foreach ( $installed['messengers'] as $msgr ) { |
|
1286 | - if ( $msgr instanceof EE_messenger ) { |
|
1285 | + foreach ($installed['messengers'] as $msgr) { |
|
1286 | + if ($msgr instanceof EE_messenger) { |
|
1287 | 1287 | $installed_messengers[$msgr->name] = $msgr; |
1288 | - if ( $msgr->activate_on_install ) { |
|
1288 | + if ($msgr->activate_on_install) { |
|
1289 | 1289 | $default_messengers[] = $msgr->name; |
1290 | 1290 | } |
1291 | 1291 | } |
@@ -1295,36 +1295,36 @@ discard block |
||
1295 | 1295 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1296 | 1296 | |
1297 | 1297 | //things that have already been activated before |
1298 | - $has_activated = get_option( 'ee_has_activated_messenger' ); |
|
1298 | + $has_activated = get_option('ee_has_activated_messenger'); |
|
1299 | 1299 | |
1300 | 1300 | //do an initial loop to determine if we need to continue |
1301 | 1301 | $def_ms = array(); |
1302 | - foreach ( $default_messengers as $msgr ) { |
|
1303 | - if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue; |
|
1302 | + foreach ($default_messengers as $msgr) { |
|
1303 | + if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue; |
|
1304 | 1304 | $def_ms[] = $msgr; |
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | //setup the $installed_mts in an array |
1308 | - foreach ( $installed['message_types'] as $imt ) { |
|
1309 | - if ( $imt instanceof EE_message_type ) { |
|
1308 | + foreach ($installed['message_types'] as $imt) { |
|
1309 | + if ($imt instanceof EE_message_type) { |
|
1310 | 1310 | $installed_mts[$imt->name] = $imt; |
1311 | 1311 | } |
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | //loop through default array for default messengers (if present) |
1315 | - if ( ! empty( $def_ms ) ) { |
|
1316 | - foreach ( $def_ms as $messenger ) { |
|
1315 | + if ( ! empty($def_ms)) { |
|
1316 | + foreach ($def_ms as $messenger) { |
|
1317 | 1317 | //all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger. |
1318 | - if ( ! isset( $installed_messengers[$messenger] )) { |
|
1318 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1319 | 1319 | continue; |
1320 | 1320 | } |
1321 | 1321 | /** @var EE_messenger[] $installed_messengers */ |
1322 | 1322 | $default_mts = $installed_messengers[$messenger]->get_default_message_types(); |
1323 | 1323 | $active_messengers[$messenger]['obj'] = $installed_messengers[$messenger]; |
1324 | - foreach ( $default_mts as $index => $mt ) { |
|
1324 | + foreach ($default_mts as $index => $mt) { |
|
1325 | 1325 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1326 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1327 | - unset( $default_mts[$index] ); |
|
1326 | + if ( ! isset($installed_mts[$mt])) { |
|
1327 | + unset($default_mts[$index]); |
|
1328 | 1328 | continue; |
1329 | 1329 | } |
1330 | 1330 | |
@@ -1333,41 +1333,41 @@ discard block |
||
1333 | 1333 | /** @var EE_message_type[] $installed_mts */ |
1334 | 1334 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1335 | 1335 | $settings = array(); |
1336 | - if ( is_array( $settings_fields ) ) { |
|
1337 | - foreach ( $settings_fields as $field => $values ) { |
|
1338 | - if ( isset( $values['default'] ) ) { |
|
1336 | + if (is_array($settings_fields)) { |
|
1337 | + foreach ($settings_fields as $field => $values) { |
|
1338 | + if (isset($values['default'])) { |
|
1339 | 1339 | $settings[$field] = $values['default']; |
1340 | 1340 | } |
1341 | 1341 | } |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1344 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1345 | 1345 | $has_activated[$messenger][] = $mt; |
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | //setup any initial settings for the messenger |
1349 | 1349 | $msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields(); |
1350 | 1350 | |
1351 | - if ( !empty( $msgr_settings ) ) { |
|
1352 | - foreach ( $msgr_settings as $field => $value ) { |
|
1351 | + if ( ! empty($msgr_settings)) { |
|
1352 | + foreach ($msgr_settings as $field => $value) { |
|
1353 | 1353 | $active_messengers[$messenger]['settings'][$field] = $value; |
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | //now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate. |
1358 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1358 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1359 | 1359 | |
1360 | 1360 | //let's generate all the templates but only if the messenger has default_mts (otherwise its just activated). |
1361 | - if ( !empty( $default_mts ) ) { |
|
1362 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE ); |
|
1361 | + if ( ! empty($default_mts)) { |
|
1362 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE); |
|
1363 | 1363 | } |
1364 | 1364 | } |
1365 | 1365 | } //end check for empty( $def_ms ) |
1366 | 1366 | |
1367 | 1367 | //still need to see if there are any message types to activate for active messengers |
1368 | - foreach ( $active_messengers as $messenger => $settings ) { |
|
1368 | + foreach ($active_messengers as $messenger => $settings) { |
|
1369 | 1369 | $msg_obj = $settings['obj']; |
1370 | - if ( ! $msg_obj instanceof EE_messenger ) { |
|
1370 | + if ( ! $msg_obj instanceof EE_messenger) { |
|
1371 | 1371 | continue; |
1372 | 1372 | } |
1373 | 1373 | |
@@ -1375,45 +1375,45 @@ discard block |
||
1375 | 1375 | $new_default_mts = array(); |
1376 | 1376 | |
1377 | 1377 | //loop through each default mt reported by the messenger and make sure its set in its active db entry. |
1378 | - foreach( $all_default_mts as $index => $mt ) { |
|
1378 | + foreach ($all_default_mts as $index => $mt) { |
|
1379 | 1379 | //already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated). |
1380 | - if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) || EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) { |
|
1380 | + if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) { |
|
1381 | 1381 | continue; |
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1385 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1386 | - unset( $all_default_mts[$mt] ); |
|
1385 | + if ( ! isset($installed_mts[$mt])) { |
|
1386 | + unset($all_default_mts[$mt]); |
|
1387 | 1387 | continue; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1391 | 1391 | $settings = array(); |
1392 | - if ( is_array( $settings_fields ) ) { |
|
1393 | - foreach ( $settings_fields as $field => $values ) { |
|
1394 | - if ( isset( $values['default'] ) ) { |
|
1392 | + if (is_array($settings_fields)) { |
|
1393 | + foreach ($settings_fields as $field => $values) { |
|
1394 | + if (isset($values['default'])) { |
|
1395 | 1395 | $settings[$field] = $values['default']; |
1396 | 1396 | } |
1397 | 1397 | } |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1400 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1401 | 1401 | $new_default_mts[] = $mt; |
1402 | 1402 | $has_activated[$messenger][] = $mt; |
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | |
1406 | - if ( ! empty( $new_default_mts ) ) { |
|
1407 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE ); |
|
1406 | + if ( ! empty($new_default_mts)) { |
|
1407 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE); |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | //now let's save the settings for this messenger! |
1413 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1413 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1414 | 1414 | |
1415 | 1415 | //update $has_activated record |
1416 | - update_option( 'ee_has_activated_messenger', $has_activated ); |
|
1416 | + update_option('ee_has_activated_messenger', $has_activated); |
|
1417 | 1417 | |
1418 | 1418 | //that's it! |
1419 | 1419 | return $success; |
@@ -1433,47 +1433,47 @@ discard block |
||
1433 | 1433 | */ |
1434 | 1434 | public static function validate_messages_system() { |
1435 | 1435 | //include our helper |
1436 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1436 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1437 | 1437 | |
1438 | 1438 | //get active and installed messengers/message types. |
1439 | 1439 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1440 | 1440 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1441 | 1441 | $installed_messengers = $installed_mts = array(); |
1442 | 1442 | //set up the arrays so they can be handled easier. |
1443 | - foreach( $installed['messengers'] as $im ) { |
|
1444 | - if ( $im instanceof EE_messenger ) { |
|
1443 | + foreach ($installed['messengers'] as $im) { |
|
1444 | + if ($im instanceof EE_messenger) { |
|
1445 | 1445 | $installed_messengers[$im->name] = $im; |
1446 | 1446 | } |
1447 | 1447 | } |
1448 | - foreach( $installed['message_types'] as $imt ) { |
|
1449 | - if ( $imt instanceof EE_message_type ) { |
|
1448 | + foreach ($installed['message_types'] as $imt) { |
|
1449 | + if ($imt instanceof EE_message_type) { |
|
1450 | 1450 | $installed_mts[$imt->name] = $imt; |
1451 | 1451 | } |
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | //now let's loop through the active array and validate |
1455 | - foreach( $active_messengers as $messenger => $active_details ) { |
|
1455 | + foreach ($active_messengers as $messenger => $active_details) { |
|
1456 | 1456 | //first let's see if this messenger is installed. |
1457 | - if ( ! isset( $installed_messengers[$messenger] ) ) { |
|
1457 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1458 | 1458 | //not set so let's just remove from actives and make sure templates are inactive. |
1459 | - unset( $active_messengers[$messenger] ); |
|
1460 | - EEH_MSG_Template::update_to_inactive( $messenger ); |
|
1459 | + unset($active_messengers[$messenger]); |
|
1460 | + EEH_MSG_Template::update_to_inactive($messenger); |
|
1461 | 1461 | continue; |
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | //messenger is active, so let's just make sure that any active message types not installed are deactivated. |
1465 | - $mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array(); |
|
1466 | - foreach ( $mts as $mt_name => $mt ) { |
|
1467 | - if ( ! isset( $installed_mts[$mt_name] ) ) { |
|
1468 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] ); |
|
1469 | - EEH_MSG_Template::update_to_inactive( $messenger, $mt_name ); |
|
1465 | + $mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array(); |
|
1466 | + foreach ($mts as $mt_name => $mt) { |
|
1467 | + if ( ! isset($installed_mts[$mt_name])) { |
|
1468 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]); |
|
1469 | + EEH_MSG_Template::update_to_inactive($messenger, $mt_name); |
|
1470 | 1470 | } |
1471 | 1471 | } |
1472 | 1472 | } |
1473 | 1473 | |
1474 | 1474 | //all done! let's update the active_messengers. |
1475 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1476 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1475 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1476 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1477 | 1477 | return; |
1478 | 1478 | } |
1479 | 1479 | |
@@ -1487,12 +1487,12 @@ discard block |
||
1487 | 1487 | * @static |
1488 | 1488 | * @return void |
1489 | 1489 | */ |
1490 | - public static function create_no_ticket_prices_array(){ |
|
1490 | + public static function create_no_ticket_prices_array() { |
|
1491 | 1491 | // this creates an array for tracking events that have no active ticket prices created |
1492 | 1492 | // this allows us to warn admins of the situation so that it can be corrected |
1493 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1494 | - if ( ! $espresso_no_ticket_prices ) { |
|
1495 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1493 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1494 | + if ( ! $espresso_no_ticket_prices) { |
|
1495 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1496 | 1496 | } |
1497 | 1497 | } |
1498 | 1498 | |
@@ -1514,24 +1514,24 @@ discard block |
||
1514 | 1514 | * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/ |
1515 | 1515 | * @global wpdb $wpdb |
1516 | 1516 | */ |
1517 | - public static function delete_all_espresso_cpt_data(){ |
|
1517 | + public static function delete_all_espresso_cpt_data() { |
|
1518 | 1518 | global $wpdb; |
1519 | 1519 | //get all the CPT post_types |
1520 | 1520 | $ee_post_types = array(); |
1521 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1522 | - if ( method_exists( $model_name, 'instance' )) { |
|
1523 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1524 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1525 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1521 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1522 | + if (method_exists($model_name, 'instance')) { |
|
1523 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1524 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1525 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | } |
1529 | 1529 | //get all our CPTs |
1530 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1530 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1531 | 1531 | $cpt_ids = $wpdb->get_col($query); |
1532 | 1532 | //delete each post meta and term relations too |
1533 | - foreach($cpt_ids as $post_id){ |
|
1534 | - wp_delete_post($post_id,true); |
|
1533 | + foreach ($cpt_ids as $post_id) { |
|
1534 | + wp_delete_post($post_id, true); |
|
1535 | 1535 | } |
1536 | 1536 | } |
1537 | 1537 | |
@@ -1545,18 +1545,18 @@ discard block |
||
1545 | 1545 | * @param bool $remove_all |
1546 | 1546 | * @return void |
1547 | 1547 | */ |
1548 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1548 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1549 | 1549 | global $wpdb; |
1550 | 1550 | $undeleted_tables = array(); |
1551 | 1551 | |
1552 | 1552 | // load registry |
1553 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1554 | - if ( method_exists( $model_name, 'instance' )) { |
|
1555 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1556 | - if ( $model_obj instanceof EEM_Base ) { |
|
1557 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1558 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1559 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1553 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1554 | + if (method_exists($model_name, 'instance')) { |
|
1555 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1556 | + if ($model_obj instanceof EEM_Base) { |
|
1557 | + foreach ($model_obj->get_tables() as $table) { |
|
1558 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1559 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1560 | 1560 | case false : |
1561 | 1561 | $undeleted_tables[] = $table->get_table_name(); |
1562 | 1562 | break; |
@@ -1581,8 +1581,8 @@ discard block |
||
1581 | 1581 | 'esp_promotion_rule', |
1582 | 1582 | 'esp_rule' |
1583 | 1583 | ); |
1584 | - foreach( $tables_without_models as $table ){ |
|
1585 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1584 | + foreach ($tables_without_models as $table) { |
|
1585 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1586 | 1586 | } |
1587 | 1587 | |
1588 | 1588 | |
@@ -1619,58 +1619,58 @@ discard block |
||
1619 | 1619 | 'ee_pers_admin_notices' => true, |
1620 | 1620 | 'ee_upload_directories_incomplete' => true, |
1621 | 1621 | ); |
1622 | - if( is_main_site() ) { |
|
1623 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1622 | + if (is_main_site()) { |
|
1623 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | $undeleted_options = array(); |
1627 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1627 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1628 | 1628 | |
1629 | - if( $no_wildcard ){ |
|
1630 | - if( ! delete_option( $option_name ) ){ |
|
1629 | + if ($no_wildcard) { |
|
1630 | + if ( ! delete_option($option_name)) { |
|
1631 | 1631 | $undeleted_options[] = $option_name; |
1632 | 1632 | } |
1633 | - }else{ |
|
1634 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1635 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1636 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1633 | + } else { |
|
1634 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1635 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1636 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1637 | 1637 | $undeleted_options[] = $option_name_from_wildcard; |
1638 | 1638 | } |
1639 | 1639 | } |
1640 | 1640 | } |
1641 | 1641 | } |
1642 | 1642 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1643 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1643 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1644 | 1644 | |
1645 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1645 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1646 | 1646 | $db_update_sans_ee4 = array(); |
1647 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1648 | - if( $version[0] =='3'){//if its NON EE4 |
|
1647 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1648 | + if ($version[0] == '3') {//if its NON EE4 |
|
1649 | 1649 | $db_update_sans_ee4[$version] = $times_activated; |
1650 | 1650 | } |
1651 | 1651 | } |
1652 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1652 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | $errors = ''; |
1656 | - if ( ! empty( $undeleted_tables )) { |
|
1656 | + if ( ! empty($undeleted_tables)) { |
|
1657 | 1657 | $errors .= sprintf( |
1658 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1658 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1659 | 1659 | '<br/>', |
1660 | - implode( ',<br/>', $undeleted_tables ) |
|
1660 | + implode(',<br/>', $undeleted_tables) |
|
1661 | 1661 | ); |
1662 | 1662 | } |
1663 | - if ( ! empty( $undeleted_options )) { |
|
1664 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1663 | + if ( ! empty($undeleted_options)) { |
|
1664 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1665 | 1665 | $errors .= sprintf( |
1666 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1666 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1667 | 1667 | '<br/>', |
1668 | - implode( ',<br/>', $undeleted_options ) |
|
1668 | + implode(',<br/>', $undeleted_options) |
|
1669 | 1669 | ); |
1670 | 1670 | |
1671 | 1671 | } |
1672 | - if ( $errors != '' ) { |
|
1673 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1672 | + if ($errors != '') { |
|
1673 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1674 | 1674 | } |
1675 | 1675 | } |
1676 | 1676 | |
@@ -1680,23 +1680,23 @@ discard block |
||
1680 | 1680 | * @param string $table_name with or without $wpdb->prefix |
1681 | 1681 | * @return boolean |
1682 | 1682 | */ |
1683 | - public static function table_exists( $table_name ){ |
|
1683 | + public static function table_exists($table_name) { |
|
1684 | 1684 | global $wpdb, $EZSQL_ERROR; |
1685 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1685 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1686 | 1686 | //ignore if this causes an sql error |
1687 | 1687 | $old_error = $wpdb->last_error; |
1688 | 1688 | $old_suppress_errors = $wpdb->suppress_errors(); |
1689 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1689 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1690 | 1690 | $ezsql_error_cache = $EZSQL_ERROR; |
1691 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1692 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1693 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1691 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1692 | + $wpdb->show_errors($old_show_errors_value); |
|
1693 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1694 | 1694 | $new_error = $wpdb->last_error; |
1695 | 1695 | $wpdb->last_error = $old_error; |
1696 | 1696 | $EZSQL_ERROR = $ezsql_error_cache; |
1697 | - if( empty( $new_error ) ){ |
|
1697 | + if (empty($new_error)) { |
|
1698 | 1698 | return TRUE; |
1699 | - }else{ |
|
1699 | + } else { |
|
1700 | 1700 | return FALSE; |
1701 | 1701 | } |
1702 | 1702 | } |
@@ -1704,7 +1704,7 @@ discard block |
||
1704 | 1704 | /** |
1705 | 1705 | * Resets the cache on EEH_Activation |
1706 | 1706 | */ |
1707 | - public static function reset(){ |
|
1707 | + public static function reset() { |
|
1708 | 1708 | self::$_default_creator_id = NULL; |
1709 | 1709 | self::$_initialized_db_content_already_in_this_request = false; |
1710 | 1710 | } |