@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | <?php _e('Adjust the settings for the PayPal Standard payment gateway.', 'event_espresso'); ?> |
4 | 4 | </p> |
5 | 5 | <p> |
6 | -<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso' ), "<a href='https://www.paypal.com/multicurrency' target='_blank'>","</a>" ); ?> |
|
6 | +<?php printf(__('See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso'), "<a href='https://www.paypal.com/multicurrency' target='_blank'>", "</a>"); ?> |
|
7 | 7 | </p> |
8 | 8 | <h3><?php _e('PayPal Standard Settings', 'event_espresso'); ?></h3> |
9 | 9 | <ul> |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | </li> |
22 | 22 | <li> |
23 | 23 | <strong><?php _e('PayPal Calculates Taxes', 'event_espresso'); ?></strong><br /> |
24 | -<?php printf( __('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>' ); ?><br/> |
|
25 | -<?php _e( 'Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso' );?> |
|
24 | +<?php printf(__('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>'); ?><br/> |
|
25 | +<?php _e('Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso'); ?> |
|
26 | 26 | </li> |
27 | 27 | <li> |
28 | 28 | <strong><?php _e('PayPal Calculates Shipping', 'event_espresso'); ?></strong><br /> |
29 | 29 | <?php _e('Similar to the "PayPal Calculates Taxes" setting, if this is set to "Yes", we will indicate to PayPal that it should calculate the shipping on each payment (if there are multiple payments for a single transaction, PayPal is permitted to add shipping charges to each payment.)', 'event_espresso'); ?><br/> |
30 | -<?php _e( 'Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso' );?> |
|
30 | +<?php _e('Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso'); ?> |
|
31 | 31 | <li> |
32 | -<strong><?php _e( 'Notes Regarding Paypal Taxes and Shipping', 'event_espresso' );?></strong><br/> |
|
33 | -<?php _e( 'If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso' );?><br/> |
|
34 | -<?php _e( 'However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso' );?><br/> |
|
35 | -<?php _e( 'Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso' );?> |
|
32 | +<strong><?php _e('Notes Regarding Paypal Taxes and Shipping', 'event_espresso'); ?></strong><br/> |
|
33 | +<?php _e('If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso'); ?><br/> |
|
34 | +<?php _e('However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso'); ?><br/> |
|
35 | +<?php _e('Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso'); ?> |
|
36 | 36 | </li> |
37 | 37 | <li> |
38 | 38 | <strong><?php _e('Shipping Address Options', 'event_espresso'); ?></strong><br /> |
@@ -7,6 +7,10 @@ discard block |
||
7 | 7 | |
8 | 8 | protected $_post_type; |
9 | 9 | protected $_meta_field; |
10 | + |
|
11 | + /** |
|
12 | + * @param string $post_type |
|
13 | + */ |
|
10 | 14 | function __construct($post_type, $meta_field_to_chk = ''){ |
11 | 15 | $this->_post_type = $post_type; |
12 | 16 | $this->_meta_field = $meta_field_to_chk; |
@@ -27,7 +31,6 @@ discard block |
||
27 | 31 | } |
28 | 32 | /** |
29 | 33 | * Gets the where default where conditions for a custom post type model |
30 | - * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
|
31 | 34 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
32 | 35 | */ |
33 | 36 | protected function _get_default_where_conditions() { |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | /* |
4 | 4 | * Strategy specifically for adding where conditions specific to CPT models. |
5 | 5 | */ |
6 | -class EE_CPT_Where_Conditions extends EE_Default_Where_Conditions{ |
|
6 | +class EE_CPT_Where_Conditions extends EE_Default_Where_Conditions { |
|
7 | 7 | |
8 | 8 | protected $_post_type; |
9 | 9 | protected $_meta_field; |
10 | - function __construct($post_type, $meta_field_to_chk = ''){ |
|
10 | + function __construct($post_type, $meta_field_to_chk = '') { |
|
11 | 11 | $this->_post_type = $post_type; |
12 | 12 | $this->_meta_field = $meta_field_to_chk; |
13 | 13 | } |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | * @param string $column column name |
18 | 18 | * @return EE_Model_Field_Base |
19 | 19 | */ |
20 | - protected function _get_field_on_column($column){ |
|
20 | + protected function _get_field_on_column($column) { |
|
21 | 21 | $all_fields = $this->_model->field_settings(true); |
22 | - foreach($all_fields as $field_name => $field_obj){ |
|
23 | - if($column == $field_obj->get_table_column()){ |
|
22 | + foreach ($all_fields as $field_name => $field_obj) { |
|
23 | + if ($column == $field_obj->get_table_column()) { |
|
24 | 24 | return $field_obj; |
25 | 25 | } |
26 | 26 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | //find post_type field |
35 | 35 | $post_type_field = $this->_get_field_on_column('post_type'); |
36 | 36 | $status_field = $this->_get_field_on_column('post_status'); |
37 | - return array( $post_type_field->get_name() => $this->_post_type, |
|
38 | - $status_field->get_name() => array('NOT IN',array('auto-draft','trash')) |
|
37 | + return array($post_type_field->get_name() => $this->_post_type, |
|
38 | + $status_field->get_name() => array('NOT IN', array('auto-draft', 'trash')) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | } |
@@ -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 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | 69 | |
70 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
70 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function _ajax_hooks() { |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'edit' => __('Update Event', 'event_espresso'), |
94 | 94 | 'add_category' => __('Save New Category', 'event_espresso'), |
95 | 95 | 'edit_category' => __('Update Category', 'event_espresso'), |
96 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
96 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function _set_page_routes() { |
102 | 102 | //load formatter helper |
103 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
103 | + EE_Registry::instance()->load_helper('Formatter'); |
|
104 | 104 | //load field generator helper |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $this->_page_routes = array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'help_tour' => array( |
321 | 321 | 'Event_Editor_Help_Tour' |
322 | 322 | ), |
323 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | 324 | 'require_nonce' => FALSE |
325 | 325 | ), |
326 | 326 | 'edit' => array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | 'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ), |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => FALSE |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'filename' => 'events_default_settings_status' |
399 | 399 | ) |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => FALSE |
403 | 403 | ), |
404 | 404 | //template settings |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'general_settings_templates' |
415 | 415 | ) |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ), |
420 | 420 | //event category stuff |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'label' => __('Edit Category', 'event_espresso'), |
439 | 439 | 'order' => 15, |
440 | 440 | 'persistent' => FALSE, |
441 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
441 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
442 | 442 | ), |
443 | 443 | 'help_tabs' => array( |
444 | 444 | 'edit_category_help_tab' => array( |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | |
509 | 509 | public function load_scripts_styles() { |
510 | 510 | |
511 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
511 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
513 | 513 | wp_enqueue_style('events-admin-css'); |
514 | 514 | wp_enqueue_style('ee-cat-admin'); |
515 | 515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
516 | 516 | //registers for all views |
517 | 517 | //scripts |
518 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
518 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function load_scripts_styles_edit() { |
534 | 534 | //styles |
535 | 535 | wp_enqueue_style('espresso-ui-theme'); |
536 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
536 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
537 | 537 | wp_enqueue_style('event-editor-css'); |
538 | 538 | |
539 | 539 | //scripts |
540 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
540 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
541 | 541 | wp_enqueue_script('event-datetime-metabox'); |
542 | 542 | |
543 | 543 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | public function admin_init() { |
575 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
575 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -593,45 +593,45 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function verify_event_edit($event = NULL) { |
595 | 595 | // no event? |
596 | - if ( empty( $event )) { |
|
596 | + if (empty($event)) { |
|
597 | 597 | // set event |
598 | 598 | $event = $this->_cpt_model_obj; |
599 | 599 | } |
600 | 600 | // STILL no event? |
601 | - if ( empty ( $event )) { |
|
601 | + if (empty ($event)) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | // first check if event is active. |
605 | - if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
|
605 | + if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) { |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | $orig_status = $event->status(); |
609 | 609 | //made it here so it IS active... next check that any of the tickets are sold. |
610 | - if ( $event->is_sold_out( true ) ) { |
|
611 | - if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
610 | + if ($event->is_sold_out(true)) { |
|
611 | + if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) { |
|
612 | 612 | EE_Error::add_attention( |
613 | 613 | sprintf( |
614 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
615 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
614 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
615 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | } |
619 | 619 | return; |
620 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
620 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
621 | 621 | EE_Error::add_attention( |
622 | 622 | sprintf( |
623 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | - 'event_espresso' ), |
|
625 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
623 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | + 'event_espresso'), |
|
625 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
626 | 626 | ) |
627 | 627 | ); |
628 | 628 | } |
629 | 629 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
630 | - if ( ! $event->tickets_on_sale() ) { |
|
630 | + if ( ! $event->tickets_on_sale()) { |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | //made it here so show warning |
634 | - EE_Error::add_attention( $this->_edit_event_warning() ); |
|
634 | + EE_Error::add_attention($this->_edit_event_warning()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ), |
672 | 672 | ); |
673 | 673 | |
674 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
674 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
675 | 675 | $this->_views['trash'] = array( |
676 | 676 | 'slug' => 'trash', |
677 | 677 | 'label' => __('Trash', 'event_espresso'), |
@@ -701,39 +701,39 @@ discard block |
||
701 | 701 | 'desc' => __('View Registrations for Event', 'event_espresso') |
702 | 702 | ) |
703 | 703 | ); |
704 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
704 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
705 | 705 | $statuses = array( |
706 | 706 | 'sold_out_status' => array( |
707 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
708 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
707 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
708 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
709 | 709 | ), |
710 | 710 | 'active_status' => array( |
711 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
712 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
711 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
712 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
713 | 713 | ), |
714 | 714 | 'upcoming_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'postponed_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'cancelled_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'expired_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'inactive_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
733 | 733 | ) |
734 | 734 | ); |
735 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
736 | - return array_merge( $items, $statuses ); |
|
735 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
736 | + return array_merge($items, $statuses); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | * @return EEM_Event |
746 | 746 | */ |
747 | 747 | private function _event_model() { |
748 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
749 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
748 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
749 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
750 | 750 | } |
751 | 751 | return $this->_event_model; |
752 | 752 | } |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | * @param string $new_slug what the slug is |
766 | 766 | * @return string The new html string for the permalink area |
767 | 767 | */ |
768 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
768 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
769 | 769 | //make sure this is only when editing |
770 | - if ( !empty( $id ) ) { |
|
771 | - $post = get_post( $id ); |
|
772 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
773 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">'; |
|
770 | + if ( ! empty($id)) { |
|
771 | + $post = get_post($id); |
|
772 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
773 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">'; |
|
774 | 774 | } |
775 | 775 | return $return; |
776 | 776 | } |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @return string html for generated table |
787 | 787 | */ |
788 | 788 | protected function _events_overview_list_table() { |
789 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
790 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
789 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
790 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
791 | 791 | $this->_display_legend($this->_event_legend_items()); |
792 | 792 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
793 | 793 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -805,51 +805,51 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | |
808 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
808 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
809 | 809 | |
810 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
810 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
811 | 811 | //getout we're not processing an event save. |
812 | 812 | return; |
813 | 813 | } |
814 | 814 | |
815 | 815 | $event_values = array( |
816 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
817 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
816 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
817 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
818 | 818 | 'EVT_additional_limit' => min( |
819 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
820 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
823 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
824 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
826 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
819 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
820 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
823 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
824 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
826 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
827 | 827 | ); |
828 | 828 | |
829 | 829 | //update event |
830 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
830 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
834 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
835 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
834 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
835 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
836 | 836 | |
837 | 837 | |
838 | 838 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
839 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
839 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
840 | 840 | |
841 | 841 | $att_success = TRUE; |
842 | 842 | |
843 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
844 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
845 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
843 | + foreach ($event_update_callbacks as $e_callback) { |
|
844 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
845 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | //any errors? |
849 | - if ( $success && FALSE === $att_success ) { |
|
850 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
851 | - } else if ( $success === FALSE ) { |
|
852 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
849 | + if ($success && FALSE === $att_success) { |
|
850 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
851 | + } else if ($success === FALSE) { |
|
852 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | /** |
860 | 860 | * @see parent::restore_item() |
861 | 861 | */ |
862 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
862 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
863 | 863 | //copy existing event meta to new post |
864 | 864 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
865 | - if ( $post_evt instanceof EE_Event ) { |
|
865 | + if ($post_evt instanceof EE_Event) { |
|
866 | 866 | //meta revision restore |
867 | - $post_evt->restore_revision( $revision_id ); |
|
867 | + $post_evt->restore_revision($revision_id); |
|
868 | 868 | //related objs restore |
869 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
869 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | |
@@ -879,52 +879,52 @@ discard block |
||
879 | 879 | * @param array $data The request data from the form |
880 | 880 | * @return bool Success or fail. |
881 | 881 | */ |
882 | - protected function _default_venue_update( $evtobj, $data ) { |
|
883 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
882 | + protected function _default_venue_update($evtobj, $data) { |
|
883 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
884 | 884 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
885 | 885 | $rows_affected = NULL; |
886 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
886 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
887 | 887 | |
888 | 888 | // very important. If we don't have a venue name... |
889 | 889 | // then we'll get out because not necessary to create empty venue |
890 | - if ( empty( $data['venue_title'] ) ) { |
|
890 | + if (empty($data['venue_title'])) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $venue_array = array( |
895 | 895 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
896 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
897 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
898 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
899 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
900 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
901 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
902 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
903 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
904 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
905 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
906 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
907 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
908 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
909 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
911 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
896 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
897 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
898 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
899 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
900 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
901 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
902 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
903 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
904 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
905 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
906 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
907 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
908 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
909 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
911 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
912 | 912 | 'status' => 'publish' |
913 | 913 | ); |
914 | 914 | |
915 | 915 | |
916 | 916 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
917 | - if ( !empty( $venue_id ) ) { |
|
918 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
919 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
917 | + if ( ! empty($venue_id)) { |
|
918 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
919 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
920 | 920 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
921 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
921 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
922 | 922 | return $rows_affected > 0 ? TRUE : FALSE; |
923 | 923 | } else { |
924 | 924 | //we insert the venue |
925 | - $venue_id = $venue_model->insert( $venue_array ); |
|
926 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
927 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
925 | + $venue_id = $venue_model->insert($venue_array); |
|
926 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
927 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
928 | 928 | } |
929 | 929 | //when we have the ancestor come in it's already been handled by the revision save. |
930 | 930 | } |
@@ -938,55 +938,55 @@ discard block |
||
938 | 938 | * @param array $data The request data from the form |
939 | 939 | * @return bool success or fail |
940 | 940 | */ |
941 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
941 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
942 | 942 | $success = true; |
943 | 943 | $saved_dtt = null; |
944 | 944 | $saved_tickets = array(); |
945 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
945 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
946 | 946 | |
947 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
947 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
948 | 948 | //trim all values to ensure any excess whitespace is removed. |
949 | - $dtt = array_map( 'trim', $dtt ); |
|
950 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
949 | + $dtt = array_map('trim', $dtt); |
|
950 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
951 | 951 | $datetime_values = array( |
952 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
952 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
953 | 953 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
954 | 954 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
955 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
955 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
956 | 956 | 'DTT_order' => $row, |
957 | 957 | ); |
958 | 958 | |
959 | 959 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
960 | 960 | |
961 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
962 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
963 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
964 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
965 | - foreach ( $datetime_values as $field => $value ) { |
|
966 | - $DTM->set( $field, $value ); |
|
961 | + if ( ! empty($dtt['DTT_ID'])) { |
|
962 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
963 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
964 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
965 | + foreach ($datetime_values as $field => $value) { |
|
966 | + $DTM->set($field, $value); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
970 | 970 | $saved_dtts[$DTM->ID()] = $DTM; |
971 | 971 | } else { |
972 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
973 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
974 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
975 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
976 | - foreach ( $datetime_values as $field => $value ) { |
|
977 | - $DTM->set( $field, $value ); |
|
972 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
973 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
974 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
975 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
976 | + foreach ($datetime_values as $field => $value) { |
|
977 | + $DTM->set($field, $value); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | $DTM->save(); |
981 | 981 | |
982 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
982 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
983 | 983 | |
984 | 984 | //load DTT helper |
985 | 985 | EE_Registry::instance()->load_helper('DTT_Helper'); |
986 | 986 | |
987 | 987 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
988 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
989 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
988 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
989 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
990 | 990 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
991 | 991 | $DTT->save(); |
992 | 992 | } |
@@ -994,45 +994,45 @@ discard block |
||
994 | 994 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
995 | 995 | $saved_dtt = $DTT; |
996 | 996 | |
997 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
997 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | //no dtts get deleted so we don't do any of that logic here. |
1001 | 1001 | //update tickets next |
1002 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1003 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1004 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1002 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1003 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1004 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1005 | 1005 | $update_prices = false; |
1006 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1006 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1007 | 1007 | |
1008 | 1008 | // trim inputs to ensure any excess whitespace is removed. |
1009 | - $tkt = array_map( 'trim', $tkt ); |
|
1009 | + $tkt = array_map('trim', $tkt); |
|
1010 | 1010 | |
1011 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1011 | + if (empty($tkt['TKT_start_date'])) { |
|
1012 | 1012 | //let's use now in the set timezone. |
1013 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1014 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1013 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1014 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1017 | + if (empty($tkt['TKT_end_date'])) { |
|
1018 | 1018 | //use the start date of the first datetime |
1019 | 1019 | $dtt = $evtobj->first_datetime(); |
1020 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1020 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | $TKT_values = array( |
1024 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1025 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1026 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1027 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1024 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1025 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1026 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1027 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1028 | 1028 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1029 | 1029 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1030 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1032 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1033 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1030 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1032 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1033 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1034 | 1034 | 'TKT_row' => $row, |
1035 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1035 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1036 | 1036 | 'TKT_price' => $ticket_price |
1037 | 1037 | ); |
1038 | 1038 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1043 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1043 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1044 | 1044 | $TKT_values['TKT_ID'] = 0; |
1045 | 1045 | $TKT_values['TKT_is_default'] = 0; |
1046 | 1046 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1051,58 +1051,58 @@ discard block |
||
1051 | 1051 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1052 | 1052 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1053 | 1053 | |
1054 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1055 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1056 | - if ( $TKT instanceof EE_Ticket ) { |
|
1057 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1054 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1055 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1056 | + if ($TKT instanceof EE_Ticket) { |
|
1057 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1058 | 1058 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1059 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1060 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1061 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1059 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1060 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1061 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1062 | 1062 | //set new values |
1063 | - foreach ( $TKT_values as $field => $value ) { |
|
1064 | - if ( $field == 'TKT_qty' ) { |
|
1065 | - $TKT->set_qty( $value ); |
|
1063 | + foreach ($TKT_values as $field => $value) { |
|
1064 | + if ($field == 'TKT_qty') { |
|
1065 | + $TKT->set_qty($value); |
|
1066 | 1066 | } else { |
1067 | - $TKT->set( $field, $value ); |
|
1067 | + $TKT->set($field, $value); |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1071 | - if ( $create_new_TKT ) { |
|
1071 | + if ($create_new_TKT) { |
|
1072 | 1072 | //archive the old ticket first |
1073 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1073 | + $TKT->set('TKT_deleted', 1); |
|
1074 | 1074 | $TKT->save(); |
1075 | 1075 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1076 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1076 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1077 | 1077 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1078 | 1078 | $TKT = clone $TKT; |
1079 | - $TKT->set( 'TKT_ID', 0 ); |
|
1080 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1081 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1082 | - $TKT->set( 'TKT_sold', 0 ); |
|
1079 | + $TKT->set('TKT_ID', 0); |
|
1080 | + $TKT->set('TKT_deleted', 0); |
|
1081 | + $TKT->set('TKT_price', $ticket_price); |
|
1082 | + $TKT->set('TKT_sold', 0); |
|
1083 | 1083 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1084 | 1084 | $update_prices = true; |
1085 | 1085 | } |
1086 | 1086 | //make sure price is set if it hasn't been already |
1087 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1087 | + $TKT->set('TKT_price', $ticket_price); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | } else { |
1091 | 1091 | //no TKT_id so a new TKT |
1092 | 1092 | $TKT_values['TKT_price'] = $ticket_price; |
1093 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1094 | - if ( $TKT instanceof EE_Ticket ) { |
|
1093 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1094 | + if ($TKT instanceof EE_Ticket) { |
|
1095 | 1095 | //need to reset values to properly account for the date formats |
1096 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1097 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1098 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1096 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1097 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1098 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1099 | 1099 | |
1100 | 1100 | //set new values |
1101 | - foreach ( $TKT_values as $field => $value ) { |
|
1102 | - if ( $field == 'TKT_qty' ) { |
|
1103 | - $TKT->set_qty( $value ); |
|
1101 | + foreach ($TKT_values as $field => $value) { |
|
1102 | + if ($field == 'TKT_qty') { |
|
1103 | + $TKT->set_qty($value); |
|
1104 | 1104 | } else { |
1105 | - $TKT->set( $field, $value ); |
|
1105 | + $TKT->set($field, $value); |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
@@ -1110,32 +1110,32 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | // cap ticket qty by datetime reg limits |
1113 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1113 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1114 | 1114 | //update ticket. |
1115 | 1115 | $TKT->save(); |
1116 | 1116 | |
1117 | 1117 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1118 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1119 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1118 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1119 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1120 | 1120 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1121 | 1121 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | //initially let's add the ticket to the dtt |
1126 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1126 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1127 | 1127 | |
1128 | 1128 | $saved_tickets[$TKT->ID()] = $TKT; |
1129 | 1129 | |
1130 | 1130 | //add prices to ticket |
1131 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1131 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1132 | 1132 | } |
1133 | 1133 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1134 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1134 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1136 | 1136 | |
1137 | - foreach ( $tickets_removed as $id ) { |
|
1138 | - $id = absint( $id ); |
|
1137 | + foreach ($tickets_removed as $id) { |
|
1138 | + $id = absint($id); |
|
1139 | 1139 | |
1140 | 1140 | //get the ticket for this id |
1141 | 1141 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1144 | 1144 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1145 | 1145 | |
1146 | - foreach( $dtts as $dtt ) { |
|
1146 | + foreach ($dtts as $dtt) { |
|
1147 | 1147 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1155 | 1155 | $tkt_to_remove->delete_permanently(); |
1156 | 1156 | } |
1157 | - return array( $saved_dtt, $saved_tickets ); |
|
1157 | + return array($saved_dtt, $saved_tickets); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1169,31 +1169,31 @@ discard block |
||
1169 | 1169 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1170 | 1170 | * @return void |
1171 | 1171 | */ |
1172 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1173 | - foreach ( $prices as $row => $prc ) { |
|
1172 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1173 | + foreach ($prices as $row => $prc) { |
|
1174 | 1174 | $PRC_values = array( |
1175 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1176 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1177 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1178 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1179 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1175 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1176 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1177 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1178 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1179 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1180 | 1180 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1181 | 1181 | 'PRC_order' => $row |
1182 | 1182 | ); |
1183 | 1183 | |
1184 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1184 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1185 | 1185 | $PRC_values['PRC_ID'] = 0; |
1186 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1186 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1187 | 1187 | } else { |
1188 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1188 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1189 | 1189 | //update this price with new values |
1190 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1191 | - $PRC->set( $field, $newprc ); |
|
1190 | + foreach ($PRC_values as $field => $newprc) { |
|
1191 | + $PRC->set($field, $newprc); |
|
1192 | 1192 | } |
1193 | 1193 | $PRC->save(); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1196 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1216,33 +1216,33 @@ discard block |
||
1216 | 1216 | |
1217 | 1217 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
1218 | 1218 | |
1219 | - $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
|
1219 | + $postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL; |
|
1220 | 1220 | |
1221 | 1221 | |
1222 | 1222 | //if no postid then get out cause we need it for stuff in here |
1223 | - if ( empty( $postid ) ) return; |
|
1223 | + if (empty($postid)) return; |
|
1224 | 1224 | |
1225 | 1225 | |
1226 | 1226 | //handle datetime saves |
1227 | 1227 | $items = array(); |
1228 | 1228 | |
1229 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
|
1230 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
1229 | + $get_one_where = array($this->_event_model()->primary_key_name() => $postid); |
|
1230 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
1231 | 1231 | |
1232 | 1232 | //now let's get the attached datetimes from the most recent autosave |
1233 | 1233 | $dtts = $event->get_many_related('Datetime'); |
1234 | 1234 | |
1235 | 1235 | $dtt_ids = array(); |
1236 | - foreach( $dtts as $dtt ) { |
|
1236 | + foreach ($dtts as $dtt) { |
|
1237 | 1237 | $dtt_ids[] = $dtt->ID(); |
1238 | 1238 | $order = $dtt->order(); |
1239 | 1239 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
1240 | 1240 | } |
1241 | - $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
|
1241 | + $this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids); |
|
1242 | 1242 | |
1243 | 1243 | //handle DECAF venues |
1244 | 1244 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
1245 | - if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
|
1245 | + if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) { |
|
1246 | 1246 | $venue = $event->get_first_related('Venue'); |
1247 | 1247 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
1248 | 1248 | } |
@@ -1253,23 +1253,23 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $ticket_ids = array(); |
1255 | 1255 | $price_ids = array(); |
1256 | - foreach ( $tickets as $ticket ) { |
|
1256 | + foreach ($tickets as $ticket) { |
|
1257 | 1257 | $ticket_ids[] = $price->ID(); |
1258 | 1258 | $ticket_order = $price->get('TKT_order'); |
1259 | - $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
|
1260 | - $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
|
1259 | + $this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID(); |
|
1260 | + $this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID(); |
|
1261 | 1261 | |
1262 | 1262 | //now we have to make sure the prices are updated appropriately |
1263 | 1263 | $prices = $ticket->get_many_related('Prices'); |
1264 | 1264 | |
1265 | - foreach ( $prices as $price ) { |
|
1265 | + foreach ($prices as $price) { |
|
1266 | 1266 | $price_ids[] = $price->ID(); |
1267 | 1267 | $price_order = $price->get('PRC_order'); |
1268 | - $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
|
1269 | - $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
|
1270 | - $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
|
1268 | + $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID(); |
|
1269 | + $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID(); |
|
1270 | + $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default'); |
|
1271 | 1271 | } |
1272 | - $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
|
1272 | + $this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids); |
|
1273 | 1273 | } |
1274 | 1274 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
1275 | 1275 | } |
@@ -1287,12 +1287,12 @@ discard block |
||
1287 | 1287 | private function _generate_publish_box_extra_content() { |
1288 | 1288 | |
1289 | 1289 | //load formatter helper |
1290 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1290 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1291 | 1291 | |
1292 | 1292 | //args for getting related registrations |
1293 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1294 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1295 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1293 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1294 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1295 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1296 | 1296 | |
1297 | 1297 | |
1298 | 1298 | // publish box |
@@ -1321,9 +1321,9 @@ discard block |
||
1321 | 1321 | ), |
1322 | 1322 | REG_ADMIN_URL |
1323 | 1323 | ), |
1324 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1325 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1326 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1324 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1325 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1326 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1327 | 1327 | 'misc_pub_section_class' => apply_filters( |
1328 | 1328 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1329 | 1329 | 'misc-pub-section' |
@@ -1342,9 +1342,9 @@ discard block |
||
1342 | 1342 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1343 | 1343 | $this->_cpt_model_obj |
1344 | 1344 | ); |
1345 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1345 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1346 | 1346 | // load template |
1347 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1347 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
@@ -1376,16 +1376,16 @@ discard block |
||
1376 | 1376 | $this->verify_cpt_object(); |
1377 | 1377 | add_meta_box( |
1378 | 1378 | 'espresso_event_editor_tickets', |
1379 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1380 | - array( $this, 'ticket_metabox' ), |
|
1379 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1380 | + array($this, 'ticket_metabox'), |
|
1381 | 1381 | $this->page_slug, |
1382 | 1382 | 'normal', |
1383 | 1383 | 'high' |
1384 | 1384 | ); |
1385 | 1385 | add_meta_box( |
1386 | 1386 | 'espresso_event_editor_event_options', |
1387 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1388 | - array( $this, 'registration_options_meta_box' ), |
|
1387 | + __('Event Registration Options', 'event_espresso'), |
|
1388 | + array($this, 'registration_options_meta_box'), |
|
1389 | 1389 | $this->page_slug, |
1390 | 1390 | 'side', |
1391 | 1391 | 'default' |
@@ -1415,38 +1415,38 @@ discard block |
||
1415 | 1415 | 'disabled' => '' |
1416 | 1416 | ); |
1417 | 1417 | |
1418 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1418 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1419 | 1419 | |
1420 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1420 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1421 | 1421 | |
1422 | 1422 | /** |
1423 | 1423 | * 1. Start with retrieving Datetimes |
1424 | 1424 | * 2. Fore each datetime get related tickets |
1425 | 1425 | * 3. For each ticket get related prices |
1426 | 1426 | */ |
1427 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1428 | - EE_Registry::instance()->load_helper('DTT_Helper' ); |
|
1427 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1428 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1429 | 1429 | /** @type EE_Datetime $first_datetime */ |
1430 | - $first_datetime = array_slice( $times, 0, 1 ); |
|
1430 | + $first_datetime = array_slice($times, 0, 1); |
|
1431 | 1431 | //do we get related tickets? |
1432 | - if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) { |
|
1433 | - foreach ( $times as $time ) { |
|
1434 | - if ( $time instanceof EE_Datetime ) { |
|
1432 | + if ($first_datetime[0]->get('DTT_ID') !== 0) { |
|
1433 | + foreach ($times as $time) { |
|
1434 | + if ($time instanceof EE_Datetime) { |
|
1435 | 1435 | $existing_datetime_ids[] = $time->get('DTT_ID'); |
1436 | 1436 | $template_args['time'] = $time; |
1437 | 1437 | $related_tickets = $time->tickets( |
1438 | 1438 | array( |
1439 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1439 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1440 | 1440 | 'default_where_conditions' => 'none' |
1441 | 1441 | ) |
1442 | 1442 | ); |
1443 | 1443 | |
1444 | - if ( !empty($related_tickets) ) { |
|
1444 | + if ( ! empty($related_tickets)) { |
|
1445 | 1445 | $template_args['total_ticket_rows'] = count($related_tickets); |
1446 | 1446 | $row = 0; |
1447 | - foreach ( $related_tickets as $ticket ) { |
|
1447 | + foreach ($related_tickets as $ticket) { |
|
1448 | 1448 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1449 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1449 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1450 | 1450 | |
1451 | 1451 | $row++; |
1452 | 1452 | } |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | $template_args['total_ticket_rows'] = 1; |
1455 | 1455 | /** @type EE_Ticket $ticket */ |
1456 | 1456 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1457 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1457 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1458 | 1458 | } |
1459 | 1459 | } |
1460 | 1460 | } |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | $template_args['time'] = $times[0]; |
1463 | 1463 | /** @type EE_Ticket $ticket */ |
1464 | 1464 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1465 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1465 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1466 | 1466 | // NOTE: we're just sending the first default row |
1467 | 1467 | // (decaf can't manage default tickets so this should be sufficient); |
1468 | 1468 | } |
@@ -1471,8 +1471,8 @@ discard block |
||
1471 | 1471 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1472 | 1472 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1473 | 1473 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1474 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1475 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1474 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1475 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1476 | 1476 | EEH_Template::display_template($template, $template_args); |
1477 | 1477 | } |
1478 | 1478 | |
@@ -1487,21 +1487,21 @@ discard block |
||
1487 | 1487 | * @param int $row |
1488 | 1488 | * @return string generated html for the ticket row. |
1489 | 1489 | */ |
1490 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1490 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1491 | 1491 | $template_args = array( |
1492 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1493 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1492 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1493 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1494 | 1494 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1495 | 1495 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1496 | 1496 | 'TKT_name' => $ticket->get('TKT_name'), |
1497 | 1497 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1498 | 1498 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1499 | 1499 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1500 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1500 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1501 | 1501 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1502 | 1502 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1503 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1504 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1503 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1504 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1505 | 1505 | ); |
1506 | 1506 | |
1507 | 1507 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1517,23 +1517,23 @@ discard block |
||
1517 | 1517 | |
1518 | 1518 | //make sure we have default start and end dates if skeleton |
1519 | 1519 | //handle rows that should NOT be empty |
1520 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1520 | + if (empty($template_args['TKT_start_date'])) { |
|
1521 | 1521 | //if empty then the start date will be now. |
1522 | 1522 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1523 | 1523 | } |
1524 | 1524 | |
1525 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1525 | + if (empty($template_args['TKT_end_date'])) { |
|
1526 | 1526 | //get the earliest datetime (if present); |
1527 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1527 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1528 | 1528 | |
1529 | - if ( !empty( $earliest_dtt ) ) |
|
1529 | + if ( ! empty($earliest_dtt)) |
|
1530 | 1530 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1531 | 1531 | else |
1532 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1532 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | - $template_args = array_merge( $template_args, $price_args ); |
|
1536 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1535 | + $template_args = array_merge($template_args, $price_args); |
|
1536 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1537 | 1537 | return EEH_Template::display_template($template, $template_args, TRUE); |
1538 | 1538 | } |
1539 | 1539 | |
@@ -1562,8 +1562,8 @@ discard block |
||
1562 | 1562 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1563 | 1563 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1564 | 1564 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1565 | - $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 ); |
|
1566 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1565 | + $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); |
|
1566 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1567 | 1567 | EEH_Template::display_template($templatepath, $template_args); |
1568 | 1568 | } |
1569 | 1569 | |
@@ -1591,21 +1591,21 @@ discard block |
||
1591 | 1591 | $EEME = $this->_event_model(); |
1592 | 1592 | |
1593 | 1593 | $offset = ($current_page - 1) * $per_page; |
1594 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1594 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1595 | 1595 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1596 | 1596 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1597 | 1597 | |
1598 | 1598 | if (isset($this->_req_data['month_range'])) { |
1599 | 1599 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1600 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1601 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1600 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1601 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | 1604 | $where = array(); |
1605 | 1605 | |
1606 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1606 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1607 | 1607 | //determine what post_status our condition will have for the query. |
1608 | - switch ( $status ) { |
|
1608 | + switch ($status) { |
|
1609 | 1609 | case 'month' : |
1610 | 1610 | case 'today' : |
1611 | 1611 | case NULL : |
@@ -1613,7 +1613,7 @@ discard block |
||
1613 | 1613 | break; |
1614 | 1614 | |
1615 | 1615 | case 'draft' : |
1616 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1616 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1617 | 1617 | break; |
1618 | 1618 | |
1619 | 1619 | default : |
@@ -1621,43 +1621,43 @@ discard block |
||
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | //categories? |
1624 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1624 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1625 | 1625 | |
1626 | - if ( !empty ( $category ) ) { |
|
1626 | + if ( ! empty ($category)) { |
|
1627 | 1627 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1628 | 1628 | $where['Term_Taxonomy.term_id'] = $category; |
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | //date where conditions |
1632 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1632 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1633 | 1633 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1634 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1635 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1636 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1637 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1634 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1635 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1636 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1637 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1638 | 1638 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1639 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1640 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1641 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1642 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1643 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1644 | - $now = date( 'Y-m-01' ); |
|
1645 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1646 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1647 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1648 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1639 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1640 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1641 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1642 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1643 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1644 | + $now = date('Y-m-01'); |
|
1645 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1646 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1647 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1648 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | |
1652 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1653 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1652 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1653 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1654 | 1654 | } else { |
1655 | - if ( ! isset( $where['status'] ) ) { |
|
1656 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1655 | + if ( ! isset($where['status'])) { |
|
1656 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1657 | 1657 | $where['OR'] = array( |
1658 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1658 | + 'status*restrict_private' => array('!=', 'private'), |
|
1659 | 1659 | 'AND' => array( |
1660 | - 'status*inclusive' => array( '=', 'private' ), |
|
1660 | + 'status*inclusive' => array('=', 'private'), |
|
1661 | 1661 | 'EVT_wp_user' => get_current_user_id() |
1662 | 1662 | ) |
1663 | 1663 | ); |
@@ -1665,16 +1665,16 @@ discard block |
||
1665 | 1665 | } |
1666 | 1666 | } |
1667 | 1667 | |
1668 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1669 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1668 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1669 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1670 | 1670 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1671 | 1671 | } |
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | |
1675 | 1675 | //search query handling |
1676 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1677 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1676 | + if (isset($this->_req_data['s'])) { |
|
1677 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1678 | 1678 | $where['OR'] = array( |
1679 | 1679 | 'EVT_name' => array('LIKE', $search_string), |
1680 | 1680 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1683,32 +1683,32 @@ discard block |
||
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | |
1686 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1687 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1686 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1687 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1688 | 1688 | |
1689 | 1689 | |
1690 | 1690 | //let's first check if we have special requests coming in. |
1691 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1692 | - switch ( $this->_req_data['active_status'] ) { |
|
1691 | + if (isset($this->_req_data['active_status'])) { |
|
1692 | + switch ($this->_req_data['active_status']) { |
|
1693 | 1693 | case 'upcoming' : |
1694 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1694 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1695 | 1695 | break; |
1696 | 1696 | |
1697 | 1697 | case 'expired' : |
1698 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1698 | + return $EEME->get_expired_events($query_params, $count); |
|
1699 | 1699 | break; |
1700 | 1700 | |
1701 | 1701 | case 'active' : |
1702 | - return $EEME->get_active_events( $query_params, $count ); |
|
1702 | + return $EEME->get_active_events($query_params, $count); |
|
1703 | 1703 | break; |
1704 | 1704 | |
1705 | 1705 | case 'inactive' : |
1706 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1706 | + return $EEME->get_inactive_events($query_params, $count); |
|
1707 | 1707 | break; |
1708 | 1708 | } |
1709 | 1709 | } |
1710 | 1710 | |
1711 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1711 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1712 | 1712 | |
1713 | 1713 | return $events; |
1714 | 1714 | } |
@@ -1717,23 +1717,23 @@ discard block |
||
1717 | 1717 | |
1718 | 1718 | |
1719 | 1719 | //handling for WordPress CPT actions (trash, restore, delete) |
1720 | - public function trash_cpt_item( $post_id ) { |
|
1720 | + public function trash_cpt_item($post_id) { |
|
1721 | 1721 | $this->_req_data['EVT_ID'] = $post_id; |
1722 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1722 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | |
1726 | 1726 | |
1727 | 1727 | |
1728 | - public function restore_cpt_item( $post_id ) { |
|
1728 | + public function restore_cpt_item($post_id) { |
|
1729 | 1729 | $this->_req_data['EVT_ID'] = $post_id; |
1730 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1730 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | |
1734 | - public function delete_cpt_item( $post_id ) { |
|
1734 | + public function delete_cpt_item($post_id) { |
|
1735 | 1735 | $this->_req_data['EVT_ID'] = $post_id; |
1736 | - $this->_delete_event( FALSE ); |
|
1736 | + $this->_delete_event(FALSE); |
|
1737 | 1737 | } |
1738 | 1738 | |
1739 | 1739 | |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | * @param string $event_status |
1746 | 1746 | * @return void |
1747 | 1747 | */ |
1748 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1748 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1749 | 1749 | //determine the event id and set to array. |
1750 | 1750 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1751 | 1751 | // loop thru events |
@@ -1753,7 +1753,7 @@ discard block |
||
1753 | 1753 | // clean status |
1754 | 1754 | $event_status = sanitize_key($event_status); |
1755 | 1755 | // grab status |
1756 | - if (!empty($event_status)) { |
|
1756 | + if ( ! empty($event_status)) { |
|
1757 | 1757 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1758 | 1758 | } else { |
1759 | 1759 | $success = FALSE; |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | } |
1768 | 1768 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1769 | 1769 | |
1770 | - if ( $redirect_after ) |
|
1770 | + if ($redirect_after) |
|
1771 | 1771 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1772 | 1772 | } |
1773 | 1773 | |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | // clean status |
1783 | 1783 | $event_status = sanitize_key($event_status); |
1784 | 1784 | // grab status |
1785 | - if (!empty($event_status)) { |
|
1785 | + if ( ! empty($event_status)) { |
|
1786 | 1786 | $success = TRUE; |
1787 | 1787 | //determine the event id and set to array. |
1788 | 1788 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1817,15 +1817,15 @@ discard block |
||
1817 | 1817 | * @param string $event_status |
1818 | 1818 | * @return bool |
1819 | 1819 | */ |
1820 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1820 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1821 | 1821 | // grab event id |
1822 | - if (!$EVT_ID) { |
|
1822 | + if ( ! $EVT_ID) { |
|
1823 | 1823 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1824 | 1824 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1825 | 1825 | return FALSE; |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1828 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1829 | 1829 | |
1830 | 1830 | // clean status |
1831 | 1831 | $event_status = sanitize_key($event_status); |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | $hook = FALSE; |
1852 | 1852 | } |
1853 | 1853 | //use class to change status |
1854 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1854 | + $this->_cpt_model_obj->set_status($event_status); |
|
1855 | 1855 | $success = $this->_cpt_model_obj->save(); |
1856 | 1856 | |
1857 | 1857 | if ($success === FALSE) { |
@@ -1873,15 +1873,15 @@ discard block |
||
1873 | 1873 | * @access protected |
1874 | 1874 | * @param bool $redirect_after |
1875 | 1875 | */ |
1876 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1876 | + protected function _delete_event($redirect_after = TRUE) { |
|
1877 | 1877 | //determine the event id and set to array. |
1878 | 1878 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1879 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1879 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1880 | 1880 | |
1881 | 1881 | |
1882 | 1882 | // loop thru events |
1883 | 1883 | if ($EVT_ID) { |
1884 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1884 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1885 | 1885 | // get list of events with no prices |
1886 | 1886 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1887 | 1887 | // remove this event from the list of events with no prices |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1896 | 1896 | } |
1897 | 1897 | |
1898 | - if ( $redirect_after ) |
|
1898 | + if ($redirect_after) |
|
1899 | 1899 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1900 | 1900 | } |
1901 | 1901 | |
@@ -1913,12 +1913,12 @@ discard block |
||
1913 | 1913 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1914 | 1914 | // loop thru events |
1915 | 1915 | foreach ($EVT_IDs as $EVT_ID) { |
1916 | - $EVT_ID = absint( $EVT_ID ); |
|
1917 | - if ( $EVT_ID ) { |
|
1918 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1916 | + $EVT_ID = absint($EVT_ID); |
|
1917 | + if ($EVT_ID) { |
|
1918 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1919 | 1919 | $success = $results !== FALSE ? $success : FALSE; |
1920 | 1920 | // remove this event from the list of events with no prices |
1921 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1921 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1922 | 1922 | } else { |
1923 | 1923 | $success = FALSE; |
1924 | 1924 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1938,21 +1938,21 @@ discard block |
||
1938 | 1938 | * @param int $EVT_ID |
1939 | 1939 | * @return bool |
1940 | 1940 | */ |
1941 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1941 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1942 | 1942 | // grab event id |
1943 | - if ( ! $EVT_ID ) { |
|
1943 | + if ( ! $EVT_ID) { |
|
1944 | 1944 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1945 | 1945 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1946 | 1946 | return FALSE; |
1947 | 1947 | } |
1948 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1948 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1949 | 1949 | |
1950 | 1950 | //need to delete related tickets and prices first. |
1951 | 1951 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1952 | - foreach ( $datetimes as $datetime ) { |
|
1952 | + foreach ($datetimes as $datetime) { |
|
1953 | 1953 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1954 | 1954 | $tickets = $datetime->get_many_related('Ticket'); |
1955 | - foreach ( $tickets as $ticket ) { |
|
1955 | + foreach ($tickets as $ticket) { |
|
1956 | 1956 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1957 | 1957 | $ticket->delete_related_permanently('Price'); |
1958 | 1958 | $ticket->delete_permanently(); |
@@ -1962,14 +1962,14 @@ discard block |
||
1962 | 1962 | |
1963 | 1963 | //what about related venues or terms? |
1964 | 1964 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1965 | - foreach ( $venues as $venue ) { |
|
1965 | + foreach ($venues as $venue) { |
|
1966 | 1966 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1967 | 1967 | } |
1968 | 1968 | |
1969 | 1969 | //any attached question groups? |
1970 | 1970 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1971 | - if ( !empty( $question_groups ) ) { |
|
1972 | - foreach ( $question_groups as $question_group ) { |
|
1971 | + if ( ! empty($question_groups)) { |
|
1972 | + foreach ($question_groups as $question_group) { |
|
1973 | 1973 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1974 | 1974 | } |
1975 | 1975 | } |
@@ -1978,12 +1978,12 @@ discard block |
||
1978 | 1978 | |
1979 | 1979 | |
1980 | 1980 | //Message Template Groups |
1981 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1981 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1982 | 1982 | |
1983 | 1983 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1984 | 1984 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1985 | 1985 | |
1986 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1986 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1987 | 1987 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1988 | 1988 | } |
1989 | 1989 | |
@@ -1997,7 +1997,7 @@ discard block |
||
1997 | 1997 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1998 | 1998 | return FALSE; |
1999 | 1999 | } |
2000 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
2000 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2001 | 2001 | return TRUE; |
2002 | 2002 | } |
2003 | 2003 | |
@@ -2014,7 +2014,7 @@ discard block |
||
2014 | 2014 | */ |
2015 | 2015 | public function total_events() { |
2016 | 2016 | |
2017 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2017 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2018 | 2018 | return $count; |
2019 | 2019 | } |
2020 | 2020 | |
@@ -2029,10 +2029,10 @@ discard block |
||
2029 | 2029 | */ |
2030 | 2030 | public function total_events_draft() { |
2031 | 2031 | $where = array( |
2032 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
2032 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
2033 | 2033 | ); |
2034 | 2034 | |
2035 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2035 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2036 | 2036 | return $count; |
2037 | 2037 | } |
2038 | 2038 | |
@@ -2051,7 +2051,7 @@ discard block |
||
2051 | 2051 | 'status' => 'trash' |
2052 | 2052 | ); |
2053 | 2053 | |
2054 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2054 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2055 | 2055 | return $count; |
2056 | 2056 | } |
2057 | 2057 | |
@@ -2079,11 +2079,11 @@ discard block |
||
2079 | 2079 | // translated |
2080 | 2080 | TRUE |
2081 | 2081 | ); |
2082 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2082 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2083 | 2083 | |
2084 | 2084 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2085 | 2085 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2086 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2086 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2087 | 2087 | $this->display_admin_page_with_sidebar(); |
2088 | 2088 | } |
2089 | 2089 | |
@@ -2109,9 +2109,9 @@ discard block |
||
2109 | 2109 | |
2110 | 2110 | protected function _template_settings() { |
2111 | 2111 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2112 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2113 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2114 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2112 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2113 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2114 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | |
@@ -2124,22 +2124,22 @@ discard block |
||
2124 | 2124 | * @return void |
2125 | 2125 | */ |
2126 | 2126 | private function _set_category_object() { |
2127 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2127 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2128 | 2128 | return; //already have the category object so get out. |
2129 | 2129 | |
2130 | 2130 | //set default category object |
2131 | 2131 | $this->_set_empty_category_object(); |
2132 | 2132 | |
2133 | 2133 | //only set if we've got an id |
2134 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2134 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2135 | 2135 | return; |
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2139 | 2139 | |
2140 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2140 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2141 | 2141 | |
2142 | - if ( !empty( $term ) ) { |
|
2142 | + if ( ! empty($term)) { |
|
2143 | 2143 | $this->_category->category_name = $term->name; |
2144 | 2144 | $this->_category->category_identifier = $term->slug; |
2145 | 2145 | $this->_category->category_desc = $term->description; |
@@ -2153,13 +2153,13 @@ discard block |
||
2153 | 2153 | |
2154 | 2154 | private function _set_empty_category_object() { |
2155 | 2155 | $this->_category = new stdClass(); |
2156 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2156 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2157 | 2157 | $this->_category->id = $this->_category->parent = 0; |
2158 | 2158 | } |
2159 | 2159 | |
2160 | 2160 | |
2161 | 2161 | protected function _category_list_table() { |
2162 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2162 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2163 | 2163 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2164 | 2164 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2165 | 2165 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2169,22 +2169,22 @@ discard block |
||
2169 | 2169 | protected function _category_details($view) { |
2170 | 2170 | |
2171 | 2171 | //load formatter helper |
2172 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
2172 | + EE_Registry::instance()->load_helper('Formatter'); |
|
2173 | 2173 | //load field generator helper |
2174 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2174 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2175 | 2175 | |
2176 | 2176 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2177 | 2177 | $this->_set_add_edit_form_tags($route); |
2178 | 2178 | |
2179 | 2179 | $this->_set_category_object(); |
2180 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2180 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2181 | 2181 | |
2182 | 2182 | $delete_action = 'delete_category'; |
2183 | 2183 | |
2184 | 2184 | //custom redirect |
2185 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2185 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2186 | 2186 | |
2187 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2187 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2188 | 2188 | |
2189 | 2189 | //take care of contents |
2190 | 2190 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2198,25 +2198,25 @@ discard block |
||
2198 | 2198 | 'type' => 'wp_editor', |
2199 | 2199 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2200 | 2200 | 'class' => 'my_editor_custom', |
2201 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2201 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2202 | 2202 | ); |
2203 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2203 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2204 | 2204 | |
2205 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2205 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2206 | 2206 | |
2207 | 2207 | //setup category select for term parents. |
2208 | 2208 | $category_select_values[] = array( |
2209 | 2209 | 'text' => __('No Parent', 'event_espresso'), |
2210 | 2210 | 'id' => 0 |
2211 | 2211 | ); |
2212 | - foreach ( $all_terms as $term ) { |
|
2212 | + foreach ($all_terms as $term) { |
|
2213 | 2213 | $category_select_values[] = array( |
2214 | 2214 | 'text' => $term->name, |
2215 | 2215 | 'id' => $term->term_id |
2216 | 2216 | ); |
2217 | 2217 | } |
2218 | 2218 | |
2219 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2219 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2220 | 2220 | |
2221 | 2221 | $template_args = array( |
2222 | 2222 | 'category' => $this->_category, |
@@ -2226,15 +2226,15 @@ discard block |
||
2226 | 2226 | 'disable' => '', |
2227 | 2227 | 'disabled_message' => FALSE |
2228 | 2228 | ); |
2229 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2230 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2229 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2230 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | |
2234 | 2234 | protected function _delete_categories() { |
2235 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2235 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2236 | 2236 | |
2237 | - foreach ( $cat_ids as $cat_id ) { |
|
2237 | + foreach ($cat_ids as $cat_id) { |
|
2238 | 2238 | $this->_delete_category($cat_id); |
2239 | 2239 | } |
2240 | 2240 | |
@@ -2242,7 +2242,7 @@ discard block |
||
2242 | 2242 | $query_args = array( |
2243 | 2243 | 'action' => 'category_list' |
2244 | 2244 | ); |
2245 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2245 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2246 | 2246 | |
2247 | 2247 | } |
2248 | 2248 | |
@@ -2252,61 +2252,61 @@ discard block |
||
2252 | 2252 | |
2253 | 2253 | protected function _delete_category($cat_id) { |
2254 | 2254 | global $wpdb; |
2255 | - $cat_id = absint( $cat_id ); |
|
2256 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2255 | + $cat_id = absint($cat_id); |
|
2256 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2257 | 2257 | } |
2258 | 2258 | |
2259 | 2259 | |
2260 | 2260 | |
2261 | 2261 | protected function _insert_or_update_category($new_category) { |
2262 | 2262 | |
2263 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2263 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2264 | 2264 | $success = 0; //we already have a success message so lets not send another. |
2265 | 2265 | |
2266 | - if ( $cat_id ) { |
|
2266 | + if ($cat_id) { |
|
2267 | 2267 | $query_args = array( |
2268 | 2268 | 'action' => 'edit_category', |
2269 | 2269 | 'EVT_CAT_ID' => $cat_id |
2270 | 2270 | ); |
2271 | 2271 | } else { |
2272 | - $query_args = array( 'action' => 'add_category' ); |
|
2272 | + $query_args = array('action' => 'add_category'); |
|
2273 | 2273 | } |
2274 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2274 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2275 | 2275 | |
2276 | 2276 | } |
2277 | 2277 | |
2278 | 2278 | |
2279 | 2279 | |
2280 | - private function _insert_category( $update = FALSE ) { |
|
2280 | + private function _insert_category($update = FALSE) { |
|
2281 | 2281 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2282 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2283 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2284 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2282 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2283 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2284 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2285 | 2285 | |
2286 | - if ( empty( $category_name ) ) { |
|
2287 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2288 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2286 | + if (empty($category_name)) { |
|
2287 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2288 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2289 | 2289 | return false; |
2290 | 2290 | } |
2291 | 2291 | |
2292 | - $term_args=array( |
|
2292 | + $term_args = array( |
|
2293 | 2293 | 'name'=>$category_name, |
2294 | 2294 | 'description'=>$category_desc, |
2295 | 2295 | 'parent'=>$category_parent |
2296 | 2296 | ); |
2297 | 2297 | //was the category_identifier input disabled? |
2298 | - if(isset($this->_req_data['category_identifier'])){ |
|
2298 | + if (isset($this->_req_data['category_identifier'])) { |
|
2299 | 2299 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2300 | 2300 | } |
2301 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2301 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2302 | 2302 | |
2303 | - if ( !is_array( $insert_ids ) ) { |
|
2304 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2305 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2303 | + if ( ! is_array($insert_ids)) { |
|
2304 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2305 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2306 | 2306 | } else { |
2307 | 2307 | $cat_id = $insert_ids['term_id']; |
2308 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2309 | - EE_Error::add_success( $msg ); |
|
2308 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2309 | + EE_Error::add_success($msg); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | return $cat_id; |
@@ -2315,32 +2315,32 @@ discard block |
||
2315 | 2315 | |
2316 | 2316 | |
2317 | 2317 | |
2318 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2318 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2319 | 2319 | global $wpdb; |
2320 | 2320 | |
2321 | 2321 | //testing term stuff |
2322 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2323 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2324 | - $limit = ($current_page-1)*$per_page; |
|
2322 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2323 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2324 | + $limit = ($current_page - 1) * $per_page; |
|
2325 | 2325 | |
2326 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2326 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2327 | 2327 | |
2328 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2329 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2328 | + if (isset($this->_req_data['s'])) { |
|
2329 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2330 | 2330 | $where['OR'] = array( |
2331 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2332 | - 'description' => array( 'LIKE', $sstr ) |
|
2331 | + 'Term.name' => array('LIKE', $sstr), |
|
2332 | + 'description' => array('LIKE', $sstr) |
|
2333 | 2333 | ); |
2334 | 2334 | } |
2335 | 2335 | |
2336 | 2336 | $query_params = array( |
2337 | - $where , |
|
2338 | - 'order_by' => array( $orderby => $order ), |
|
2339 | - 'limit' => $limit . ',' . $per_page, |
|
2337 | + $where, |
|
2338 | + 'order_by' => array($orderby => $order), |
|
2339 | + 'limit' => $limit.','.$per_page, |
|
2340 | 2340 | 'force_join' => array('Term') |
2341 | 2341 | ); |
2342 | 2342 | |
2343 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2343 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2344 | 2344 | |
2345 | 2345 | return $categories; |
2346 | 2346 | } |
@@ -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 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
45 | 45 | * @return \Payments_Admin_Page |
46 | 46 | */ |
47 | - public function __construct( $routing = TRUE ) { |
|
48 | - parent::__construct( $routing ); |
|
47 | + public function __construct($routing = TRUE) { |
|
48 | + parent::__construct($routing); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | protected function _set_page_config() { |
131 | 131 | $payment_method_list_config = array( |
132 | 132 | 'nav' => array( |
133 | - 'label' => __( 'Payment Methods', 'event_espresso' ), |
|
133 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
134 | 134 | 'order' => 10 |
135 | 135 | ), |
136 | 136 | 'metaboxes' => $this->_default_espresso_metaboxes, |
137 | 137 | 'help_tabs' => array_merge( |
138 | 138 | array( |
139 | 139 | 'payment_methods_overview_help_tab' => array( |
140 | - 'title' => __( 'Payment Methods Overview', 'event_espresso' ), |
|
140 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
141 | 141 | 'filename' => 'payment_methods_overview' |
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | $this->_add_payment_method_help_tabs() ), |
145 | - 'help_tour' => array( 'Payment_Methods_Selection_Help_Tour' ), |
|
145 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
146 | 146 | 'require_nonce' => false |
147 | 147 | ); |
148 | 148 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ) |
161 | 161 | ), |
162 | 162 | //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
163 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | 164 | 'require_nonce' => FALSE |
165 | 165 | ), |
166 | 166 | 'payment_log'=>array( |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function _add_payment_method_help_tabs(){ |
|
182 | + protected function _add_payment_method_help_tabs() { |
|
183 | 183 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
184 | 184 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
185 | 185 | $all_pmt_help_tabs_config = array(); |
186 | - foreach( $payment_method_types as $payment_method_type ){ |
|
187 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
186 | + foreach ($payment_method_types as $payment_method_type) { |
|
187 | + if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | - foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){ |
|
191 | - $template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array(); |
|
192 | - $template_args[ 'admin_page_obj' ] = $this; |
|
190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
191 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
192 | + $template_args['admin_page_obj'] = $this; |
|
193 | 193 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
194 | 194 | 'title'=>$config['title'], |
195 | 195 | 'content'=>EEH_Template::display_template( |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | |
218 | 218 | public function load_scripts_styles() { |
219 | - wp_enqueue_script( 'ee_admin_js' ); |
|
220 | - wp_enqueue_script( 'ee-text-links' ); |
|
221 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
219 | + wp_enqueue_script('ee_admin_js'); |
|
220 | + wp_enqueue_script('ee-text-links'); |
|
221 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | |
228 | 228 | public function load_scripts_styles_default() { |
229 | 229 | //styles |
230 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
231 | - wp_enqueue_style( 'espresso_payments' ); |
|
232 | - wp_enqueue_style( 'ee-text-links' ); |
|
230 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
231 | + wp_enqueue_style('espresso_payments'); |
|
232 | + wp_enqueue_style('ee-text-links'); |
|
233 | 233 | //scripts |
234 | 234 | } |
235 | 235 | |
@@ -243,46 +243,46 @@ discard block |
||
243 | 243 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
244 | 244 | * recheck here. |
245 | 245 | */ |
246 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
246 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
247 | 247 | EEM_Payment_Method::instance()->verify_button_urls(); |
248 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
249 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
248 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
249 | + EE_Registry::instance()->load_helper('HTML'); |
|
250 | 250 | //setup tabs, one for each payment method type |
251 | 251 | $tabs = array(); |
252 | 252 | $payment_methods = array(); |
253 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
253 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
254 | 254 | // we don't want to show admin-only PMTs for now |
255 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
255 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
256 | 256 | continue; |
257 | 257 | } |
258 | 258 | //check access |
259 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
259 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
260 | 260 | continue; |
261 | 261 | } |
262 | 262 | //check for any active pms of that type |
263 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
264 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
263 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
264 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
265 | 265 | $payment_method = EE_Payment_Method::new_instance( |
266 | 266 | array( |
267 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
267 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
268 | 268 | 'PMD_type' =>$pmt_obj->system_name(), |
269 | 269 | 'PMD_name' =>$pmt_obj->pretty_name(), |
270 | 270 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
271 | 271 | ) |
272 | 272 | ); |
273 | 273 | } |
274 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
274 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
275 | 275 | } |
276 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
277 | - foreach( $payment_methods as $payment_method ) { |
|
278 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
276 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
277 | + foreach ($payment_methods as $payment_method) { |
|
278 | + if ($payment_method instanceof EE_Payment_Method) { |
|
279 | 279 | add_meta_box( |
280 | 280 | //html id |
281 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
281 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
282 | 282 | //title |
283 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
283 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
284 | 284 | //callback |
285 | - array( $this, 'payment_method_settings_meta_box' ), |
|
285 | + array($this, 'payment_method_settings_meta_box'), |
|
286 | 286 | //post type |
287 | 287 | null, |
288 | 288 | //context |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | //priority |
291 | 291 | 'default', |
292 | 292 | //callback args |
293 | - array( 'payment_method' => $payment_method ) |
|
293 | + array('payment_method' => $payment_method) |
|
294 | 294 | ); |
295 | 295 | //setup for tabbed content |
296 | - $tabs[ $payment_method->slug() ] = array( |
|
296 | + $tabs[$payment_method->slug()] = array( |
|
297 | 297 | 'label' => $payment_method->admin_name(), |
298 | 298 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
299 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
300 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
299 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
300 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
301 | 301 | 'slug' => $payment_method->slug() |
302 | 302 | ); |
303 | 303 | } |
304 | 304 | } |
305 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
305 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
306 | 306 | $this->display_admin_page_with_sidebar(); |
307 | 307 | |
308 | 308 | } |
@@ -313,20 +313,20 @@ discard block |
||
313 | 313 | * _get_active_payment_method_slug |
314 | 314 | * @return string |
315 | 315 | */ |
316 | - protected function _get_active_payment_method_slug(){ |
|
316 | + protected function _get_active_payment_method_slug() { |
|
317 | 317 | $payment_method_slug = FALSE; |
318 | 318 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
319 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
319 | + if (isset($this->_req_data['payment_method'])) { |
|
320 | 320 | // if they provided the current payment method, use it |
321 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
321 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
322 | 322 | } |
323 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
323 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
324 | 324 | // if that didn't work or wasn't provided, find another way to select the current pm |
325 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
325 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
326 | 326 | // like, looking for an active one |
327 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
327 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
328 | 328 | // test that one as well |
329 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
329 | + if ($this->_verify_payment_method($payment_method)) { |
|
330 | 330 | $payment_method_slug = $payment_method->slug(); |
331 | 331 | } else { |
332 | 332 | $payment_method_slug = 'paypal_standard'; |
@@ -344,11 +344,11 @@ discard block |
||
344 | 344 | * @param \EE_Payment_Method $payment_method |
345 | 345 | * @return boolean |
346 | 346 | */ |
347 | - protected function _verify_payment_method( $payment_method ){ |
|
347 | + protected function _verify_payment_method($payment_method) { |
|
348 | 348 | if ( |
349 | 349 | $payment_method instanceof EE_Payment_Method && |
350 | 350 | $payment_method->type_obj() instanceof EE_PMT_Base && |
351 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
351 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
352 | 352 | ) { |
353 | 353 | return TRUE; |
354 | 354 | } |
@@ -365,21 +365,21 @@ discard block |
||
365 | 365 | * @return string |
366 | 366 | * @throws EE_Error |
367 | 367 | */ |
368 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
369 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
370 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
371 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
368 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
369 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
370 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
371 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
372 | 372 | } |
373 | 373 | $payment_method_scopes = $payment_method->active(); |
374 | 374 | // if the payment method really exists show its form, otherwise the activation template |
375 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
376 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
377 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
378 | - $form->receive_form_submission( $this->_req_data ); |
|
375 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
376 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
377 | + if ($form->form_data_present_in($this->_req_data)) { |
|
378 | + $form->receive_form_submission($this->_req_data); |
|
379 | 379 | } |
380 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
380 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
381 | 381 | } else { |
382 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
382 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
@@ -392,14 +392,14 @@ discard block |
||
392 | 392 | * @param \EE_Payment_Method $payment_method |
393 | 393 | * @return \EE_Form_Section_Proper |
394 | 394 | */ |
395 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
396 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
395 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
396 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
397 | 397 | return new EE_Form_Section_Proper(); |
398 | 398 | } |
399 | 399 | return new EE_Form_Section_Proper( |
400 | 400 | array( |
401 | - 'name' => $payment_method->slug() . '_settings_form', |
|
402 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
401 | + 'name' => $payment_method->slug().'_settings_form', |
|
402 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
403 | 403 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
404 | 404 | array( |
405 | 405 | 'action' => 'update_payment_method', |
@@ -411,12 +411,12 @@ discard block |
||
411 | 411 | 'subsections' => apply_filters( |
412 | 412 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
413 | 413 | array( |
414 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
415 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
416 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
417 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
418 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
419 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
414 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
415 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
416 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
417 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
418 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
419 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
420 | 420 | ), |
421 | 421 | $payment_method |
422 | 422 | ) |
@@ -433,19 +433,19 @@ discard block |
||
433 | 433 | * @param \EE_Payment_Method $payment_method |
434 | 434 | * @return \EE_Form_Section_Proper |
435 | 435 | */ |
436 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
437 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
436 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
437 | + if ($payment_method->type_obj()->requires_https()) { |
|
438 | 438 | return new EE_Form_Section_HTML( |
439 | 439 | EEH_HTML::tr( |
440 | 440 | EEH_HTML::th( |
441 | 441 | EEH_HTML::label( |
442 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
442 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
443 | 443 | ) |
444 | - ) . |
|
444 | + ). |
|
445 | 445 | EEH_HTML::td( |
446 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
447 | - EEH_HTML::br() . |
|
448 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
446 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
447 | + EEH_HTML::br(). |
|
448 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
449 | 449 | ) |
450 | 450 | ) |
451 | 451 | ); |
@@ -463,19 +463,19 @@ discard block |
||
463 | 463 | * @param \EE_Payment_Method $payment_method |
464 | 464 | * @return \EE_Form_Section_Proper |
465 | 465 | */ |
466 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
467 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
466 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
467 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
468 | 468 | return new EE_Form_Section_HTML( |
469 | 469 | EEH_HTML::tr( |
470 | 470 | EEH_HTML::th( |
471 | 471 | EEH_HTML::label( |
472 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
472 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
473 | 473 | ) |
474 | - ) . |
|
474 | + ). |
|
475 | 475 | EEH_HTML::td( |
476 | 476 | EEH_HTML::strong( |
477 | 477 | sprintf( |
478 | - __( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
478 | + __('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
479 | 479 | EE_Config::instance()->currency->code |
480 | 480 | ) |
481 | 481 | ) |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | * @param \EE_Payment_Method $payment_method |
496 | 496 | * @return \EE_Form_Section_HTML |
497 | 497 | */ |
498 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
498 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
499 | 499 | //modify the form so we only have/show fields that will be implemented for this version |
500 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
500 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | * @return \EE_Payment_Method_Form |
511 | 511 | * @throws \EE_Error |
512 | 512 | */ |
513 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
514 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
513 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
514 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
515 | 515 | $form_section->exclude( |
516 | 516 | array( |
517 | 517 | 'PMD_type', //dont want them changing the type |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | ); |
523 | 523 | return $form_section; |
524 | 524 | } else { |
525 | - throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name )); |
|
525 | + throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name)); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
@@ -535,18 +535,18 @@ discard block |
||
535 | 535 | * @param \EE_Payment_Method $payment_method |
536 | 536 | * @return \EE_Form_Section_HTML |
537 | 537 | */ |
538 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
538 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
539 | 539 | $update_button = new EE_Submit_Input( |
540 | 540 | array( |
541 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
542 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
541 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
542 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
543 | 543 | 'html_label' => EEH_HTML::nbsp() |
544 | 544 | ) |
545 | 545 | ); |
546 | 546 | return new EE_Form_Section_HTML( |
547 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
547 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
548 | 548 | EEH_HTML::tr( |
549 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
549 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
550 | 550 | EEH_HTML::td( |
551 | 551 | $update_button->get_html_for_input() |
552 | 552 | ) |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | * @param \EE_Payment_Method $payment_method |
564 | 564 | * @return \EE_Form_Section_Proper |
565 | 565 | */ |
566 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
567 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
566 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
567 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
568 | 568 | return new EE_Form_Section_HTML( |
569 | 569 | EEH_HTML::tr( |
570 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
570 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
571 | 571 | EEH_HTML::td( |
572 | 572 | EEH_HTML::link( |
573 | 573 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | ), |
580 | 580 | $link_text_and_title, |
581 | 581 | $link_text_and_title, |
582 | - 'deactivate_' . $payment_method->slug(), |
|
582 | + 'deactivate_'.$payment_method->slug(), |
|
583 | 583 | 'espresso-button button-secondary' |
584 | 584 | ) |
585 | 585 | ) |
@@ -595,12 +595,12 @@ discard block |
||
595 | 595 | * @param \EE_Payment_Method $payment_method |
596 | 596 | * @return \EE_Form_Section_Proper |
597 | 597 | */ |
598 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
599 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
598 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
599 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
600 | 600 | return new EE_Form_Section_Proper( |
601 | 601 | array( |
602 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
603 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
602 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
603 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
604 | 604 | 'action' => '#', |
605 | 605 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
606 | 606 | 'subsections' => apply_filters( |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | new EE_Form_Section_HTML( |
610 | 610 | EEH_HTML::tr( |
611 | 611 | EEH_HTML::th( |
612 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
613 | - ) . |
|
612 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
613 | + ). |
|
614 | 614 | EEH_HTML::td( |
615 | 615 | EEH_HTML::link( |
616 | 616 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | ), |
623 | 623 | $link_text_and_title, |
624 | 624 | $link_text_and_title, |
625 | - 'activate_' . $payment_method->slug(), |
|
625 | + 'activate_'.$payment_method->slug(), |
|
626 | 626 | 'espresso-button-green button-primary' |
627 | 627 | ) |
628 | 628 | ) |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | protected function _fine_print() { |
645 | 645 | return new EE_Form_Section_HTML( |
646 | 646 | EEH_HTML::tr( |
647 | - EEH_HTML::th() . |
|
647 | + EEH_HTML::th(). |
|
648 | 648 | EEH_HTML::td( |
649 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
649 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
650 | 650 | ) |
651 | 651 | ) |
652 | 652 | ); |
@@ -658,15 +658,15 @@ discard block |
||
658 | 658 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
659 | 659 | * @global WP_User $current_user |
660 | 660 | */ |
661 | - protected function _activate_payment_method(){ |
|
662 | - if(isset($this->_req_data['payment_method_type'])){ |
|
661 | + protected function _activate_payment_method() { |
|
662 | + if (isset($this->_req_data['payment_method_type'])) { |
|
663 | 663 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
664 | 664 | //see if one exists |
665 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
666 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
665 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
666 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
667 | 667 | |
668 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
669 | - }else{ |
|
668 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
669 | + } else { |
|
670 | 670 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
671 | 671 | } |
672 | 672 | } |
@@ -674,14 +674,14 @@ discard block |
||
674 | 674 | /** |
675 | 675 | * Deactivates the payment method with the specified slug, and redirects. |
676 | 676 | */ |
677 | - protected function _deactivate_payment_method(){ |
|
678 | - if(isset($this->_req_data['payment_method'])){ |
|
677 | + protected function _deactivate_payment_method() { |
|
678 | + if (isset($this->_req_data['payment_method'])) { |
|
679 | 679 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
680 | 680 | //deactivate it |
681 | 681 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
682 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
683 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
684 | - }else{ |
|
682 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
683 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
684 | + } else { |
|
685 | 685 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
686 | 686 | } |
687 | 687 | } |
@@ -695,39 +695,39 @@ discard block |
||
695 | 695 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
696 | 696 | * @return void |
697 | 697 | */ |
698 | - protected function _update_payment_method(){ |
|
699 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
698 | + protected function _update_payment_method() { |
|
699 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
700 | 700 | //ok let's find which gateway form to use based on the form input |
701 | 701 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
702 | 702 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
703 | 703 | $correct_pmt_form_to_use = NULL; |
704 | 704 | $pmt_obj = NULL; |
705 | - foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){ |
|
705 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
706 | 706 | /** @var $pmt_obj EE_PMT_Base */ |
707 | 707 | //get the form and simplify it, like what we do when we display it |
708 | 708 | $pmt_form = $pmt_obj->settings_form(); |
709 | 709 | $this->_simplify_form($pmt_form); |
710 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
710 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
711 | 711 | $correct_pmt_form_to_use = $pmt_form; |
712 | 712 | break; |
713 | 713 | } |
714 | 714 | } |
715 | 715 | //if we couldn't find the correct payment method type... |
716 | - if( ! $correct_pmt_form_to_use ){ |
|
716 | + if ( ! $correct_pmt_form_to_use) { |
|
717 | 717 | EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
718 | 718 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
719 | 719 | } |
720 | 720 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
721 | - if($correct_pmt_form_to_use->is_valid()){ |
|
721 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
722 | 722 | $correct_pmt_form_to_use->save(); |
723 | 723 | $pm = $correct_pmt_form_to_use->get_model_object(); |
724 | 724 | /** @var $pm EE_Payment_Method */ |
725 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug())); |
|
726 | - }else{ |
|
725 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug())); |
|
726 | + } else { |
|
727 | 727 | EE_Error::add_error( |
728 | 728 | sprintf( |
729 | 729 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
730 | - $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
730 | + $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
731 | 731 | ), |
732 | 732 | __FILE__, |
733 | 733 | __FUNCTION__, |
@@ -744,11 +744,11 @@ discard block |
||
744 | 744 | protected function _payment_settings() { |
745 | 745 | |
746 | 746 | $this->_template_args['values'] = $this->_yes_no_values; |
747 | - $this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE; |
|
747 | + $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE; |
|
748 | 748 | |
749 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
750 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
751 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
749 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
750 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
751 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
752 | 752 | $this->display_admin_page_with_sidebar(); |
753 | 753 | |
754 | 754 | } |
@@ -762,13 +762,13 @@ discard block |
||
762 | 762 | * @return array |
763 | 763 | */ |
764 | 764 | protected function _update_payment_settings() { |
765 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
766 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
765 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
766 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
767 | 767 | |
768 | 768 | |
769 | - $what = __('Payment Settings','event_espresso'); |
|
770 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
771 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
769 | + $what = __('Payment Settings', 'event_espresso'); |
|
770 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
771 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
772 | 772 | |
773 | 773 | } |
774 | 774 | protected function _payment_log_overview_list_table() { |
@@ -794,18 +794,18 @@ discard block |
||
794 | 794 | * @param bool $count |
795 | 795 | * @return array |
796 | 796 | */ |
797 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
798 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
797 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
798 | + EE_Registry::instance()->load_model('Change_Log'); |
|
799 | 799 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
800 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
800 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
801 | 801 | //check if they've selected a specific payment method |
802 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
802 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
803 | 803 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
804 | 804 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
805 | 805 | } |
806 | 806 | //take into account search |
807 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
808 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
807 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
808 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
809 | 809 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
810 | 810 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
811 | 811 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -820,48 +820,48 @@ discard block |
||
820 | 820 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
821 | 821 | |
822 | 822 | } |
823 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
823 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
824 | 824 | //add date |
825 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
826 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
825 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
826 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
827 | 827 | //make sure our timestamps start and end right at the boundaries for each day |
828 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
829 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
828 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
829 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
830 | 830 | |
831 | 831 | //convert to timestamps |
832 | - $start_date = strtotime( $start_date ); |
|
833 | - $end_date = strtotime( $end_date ); |
|
832 | + $start_date = strtotime($start_date); |
|
833 | + $end_date = strtotime($end_date); |
|
834 | 834 | |
835 | 835 | //makes sure start date is the lowest value and vice versa |
836 | - $start_date = min( $start_date, $end_date ); |
|
837 | - $end_date = max( $start_date, $end_date ); |
|
836 | + $start_date = min($start_date, $end_date); |
|
837 | + $end_date = max($start_date, $end_date); |
|
838 | 838 | |
839 | 839 | //convert for query |
840 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
841 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
840 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
841 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
842 | 842 | |
843 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
843 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
844 | 844 | |
845 | 845 | } |
846 | - if($count){ |
|
846 | + if ($count) { |
|
847 | 847 | return EEM_Change_Log::instance()->count($query_params); |
848 | 848 | } |
849 | - if(isset($this->_req_data['order'])){ |
|
850 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
849 | + if (isset($this->_req_data['order'])) { |
|
850 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
851 | 851 | $query_params['order_by'] = array('LOG_time' => $sort); |
852 | - }else{ |
|
852 | + } else { |
|
853 | 853 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
854 | 854 | } |
855 | - $offset = ($current_page-1)*$per_page; |
|
855 | + $offset = ($current_page - 1) * $per_page; |
|
856 | 856 | |
857 | - if( ! isset($this->_req_data['download_results'])){ |
|
858 | - $query_params['limit'] = array( $offset, $per_page ); |
|
857 | + if ( ! isset($this->_req_data['download_results'])) { |
|
858 | + $query_params['limit'] = array($offset, $per_page); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | |
862 | 862 | |
863 | 863 | //now they've requested to instead just download the file instead of viewing it. |
864 | - if(isset($this->_req_data['download_results'])){ |
|
864 | + if (isset($this->_req_data['download_results'])) { |
|
865 | 865 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
866 | 866 | header('Content-Disposition: attachment'); |
867 | 867 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -883,36 +883,36 @@ discard block |
||
883 | 883 | * @param EE_Change_Log $logB |
884 | 884 | * @return int |
885 | 885 | */ |
886 | - protected function _sort_logs_again($logA,$logB){ |
|
886 | + protected function _sort_logs_again($logA, $logB) { |
|
887 | 887 | $timeA = $logA->get_raw('LOG_time'); |
888 | 888 | $timeB = $logB->get_raw('LOG_time'); |
889 | - if($timeA == $timeB){ |
|
889 | + if ($timeA == $timeB) { |
|
890 | 890 | return 0; |
891 | 891 | } |
892 | 892 | $comparison = $timeA < $timeB ? -1 : 1; |
893 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
893 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
894 | 894 | return $comparison * -1; |
895 | - }else{ |
|
895 | + } else { |
|
896 | 896 | return $comparison; |
897 | 897 | } |
898 | 898 | } |
899 | 899 | |
900 | 900 | protected function _payment_log_details() { |
901 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
901 | + EE_Registry::instance()->load_model('Change_Log'); |
|
902 | 902 | /** @var $payment_log EE_Change_Log */ |
903 | 903 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
904 | 904 | $payment_method = NULL; |
905 | 905 | $transaction = NULL; |
906 | - if( $payment_log instanceof EE_Change_Log ){ |
|
907 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
906 | + if ($payment_log instanceof EE_Change_Log) { |
|
907 | + if ($payment_log->object() instanceof EE_Payment) { |
|
908 | 908 | $payment_method = $payment_log->object()->payment_method(); |
909 | 909 | $transaction = $payment_log->object()->transaction(); |
910 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
910 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
911 | 911 | $payment_method = $payment_log->object(); |
912 | 912 | } |
913 | 913 | } |
914 | 914 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
915 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
915 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
916 | 916 | array( |
917 | 917 | 'payment_log'=>$payment_log, |
918 | 918 | 'payment_method'=>$payment_method, |
@@ -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 | /** |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | protected $_job_step_response = null; |
38 | 38 | |
39 | 39 | |
40 | - public function __construct( $routing = TRUE ) { |
|
41 | - parent::__construct( $routing ); |
|
40 | + public function __construct($routing = TRUE) { |
|
41 | + parent::__construct($routing); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | |
54 | 54 | |
55 | 55 | protected function _ajax_hooks() { |
56 | - add_action('wp_ajax_espresso_batch_continue',array($this,'batch_continue')); |
|
57 | - add_action('wp_ajax_espresso_batch_cleanup',array($this,'batch_cleanup')); |
|
56 | + add_action('wp_ajax_espresso_batch_continue', array($this, 'batch_continue')); |
|
57 | + add_action('wp_ajax_espresso_batch_cleanup', array($this, 'batch_cleanup')); |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | 'nav' => array( |
103 | 103 | 'label' => __('Shortcodes', 'event_espresso'), |
104 | 104 | 'order' => 30), |
105 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_shortcodes_boxes' ) ), |
|
105 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')), |
|
106 | 106 | 'require_nonce' => FALSE |
107 | 107 | ), |
108 | 108 | 'contact_support' => array( |
109 | 109 | 'nav' => array( |
110 | 110 | 'label' => __('Support', 'event_espresso'), |
111 | 111 | 'order' => 40), |
112 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_support_boxes' ) ), |
|
112 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')), |
|
113 | 113 | 'require_nonce' => FALSE |
114 | 114 | ), |
115 | 115 | 'developers' => array( |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | |
138 | 138 | |
139 | 139 | protected function _installation() { |
140 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
141 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE); |
|
140 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php'; |
|
141 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE); |
|
142 | 142 | $this->display_admin_page_with_sidebar(); |
143 | 143 | } |
144 | 144 | |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | 'other_resources' => __('Other Resources', 'event_espresso') |
164 | 164 | ); |
165 | 165 | |
166 | - foreach ( $boxes as $box => $label ) { |
|
167 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
166 | + foreach ($boxes as $box => $label) { |
|
167 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
168 | 168 | $callback_args = array('template_path' => $template_path); |
169 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
169 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | 'shortcodes_event_listings' => __('Event Listings', 'event_espresso'), |
188 | 188 | 'shortcodes_ticket_selector' => __('Event Ticket Selector', 'event_espresso'), |
189 | 189 | 'shortcodes_category' => __('Event Categories', 'event_espresso'), |
190 | - 'shortcodes_attendee' => __( 'Event Attendees', 'event_espresso' ) |
|
190 | + 'shortcodes_attendee' => __('Event Attendees', 'event_espresso') |
|
191 | 191 | /*'shortcodes_single_events' => __('Single Events', 'event_espresso'),*/ |
192 | 192 | /*'shortcodes_attendee_listings' => __('Attendee Listings', 'event_espresso'),*/ |
193 | 193 | ); |
194 | 194 | |
195 | - foreach ( $boxes as $box => $label ) { |
|
196 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
195 | + foreach ($boxes as $box => $label) { |
|
196 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
197 | 197 | $callback_args = array('template_path' => $template_path); |
198 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
198 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -214,41 +214,41 @@ discard block |
||
214 | 214 | 'important_information' => __('Important Information', 'event_espresso') |
215 | 215 | ); |
216 | 216 | |
217 | - foreach ( $boxes as $box => $label ) { |
|
218 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
217 | + foreach ($boxes as $box => $label) { |
|
218 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
219 | 219 | $callback_args = array('template_path' => $template_path, 'template_args' => $this->_template_args); |
220 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
220 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | 224 | |
225 | 225 | protected function _developers() { |
226 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php'; |
|
227 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true ); |
|
226 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php'; |
|
227 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true); |
|
228 | 228 | $this->display_admin_page_with_sidebar(); |
229 | 229 | } |
230 | 230 | |
231 | 231 | public function load_scripts_styles_batch_create() { |
232 | 232 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
233 | - wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' )); |
|
234 | - wp_localize_script( 'support_batch_runner', 'ee_job_response', $job_response->to_array() ); |
|
235 | - wp_localize_script( 'support_batch_runner', 'ee_job_i18n', |
|
233 | + wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar')); |
|
234 | + wp_localize_script('support_batch_runner', 'ee_job_response', $job_response->to_array()); |
|
235 | + wp_localize_script('support_batch_runner', 'ee_job_i18n', |
|
236 | 236 | array( |
237 | - 'redirect_url' => $this->_req_data['redirect_url' ], |
|
237 | + 'redirect_url' => $this->_req_data['redirect_url'], |
|
238 | 238 | )); |
239 | 239 | } |
240 | 240 | public function load_scripts_styles_batch_file_create() { |
241 | 241 | //creates a job based on the request variable |
242 | 242 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
243 | - wp_enqueue_script( 'support_batch_file_runner', EE_SUPPORT_ASSETS_URL . 'support_batch_file_runner.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION,true); |
|
244 | - wp_localize_script( 'support_batch_file_runner', 'ee_job_response', $job_response->to_array() ); |
|
245 | - wp_localize_script( 'support_batch_file_runner', 'ee_job_i18n', |
|
243 | + wp_enqueue_script('support_batch_file_runner', EE_SUPPORT_ASSETS_URL.'support_batch_file_runner.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true); |
|
244 | + wp_localize_script('support_batch_file_runner', 'ee_job_response', $job_response->to_array()); |
|
245 | + wp_localize_script('support_batch_file_runner', 'ee_job_i18n', |
|
246 | 246 | array( |
247 | 247 | 'download_and_redirecting' => sprintf( |
248 | 248 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
249 | - '<a href="' . $this->_req_data['redirect_url' ] .'">', |
|
249 | + '<a href="'.$this->_req_data['redirect_url'].'">', |
|
250 | 250 | '</a>' ), |
251 | - 'redirect_url' => $this->_req_data['redirect_url' ], |
|
251 | + 'redirect_url' => $this->_req_data['redirect_url'], |
|
252 | 252 | )); |
253 | 253 | } |
254 | 254 | |
@@ -259,16 +259,16 @@ discard block |
||
259 | 259 | * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
260 | 260 | */ |
261 | 261 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() { |
262 | - wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) ); |
|
263 | - wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION ); |
|
264 | - wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' )); |
|
265 | - $job_handler_classname = stripslashes( $this->_req_data[ 'job_handler' ] ); |
|
262 | + wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery')); |
|
263 | + wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION); |
|
264 | + wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar')); |
|
265 | + $job_handler_classname = stripslashes($this->_req_data['job_handler']); |
|
266 | 266 | $request_data = array_diff_key( |
267 | 267 | $this->_req_data, |
268 | - array_flip( array( 'action', 'page' ) ) ); |
|
268 | + array_flip(array('action', 'page')) ); |
|
269 | 269 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
270 | 270 | //eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
271 | - $job_response = $batch_runner->create_job( $job_handler_classname, $request_data ); |
|
271 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
272 | 272 | //remember the response for later. We need it to display the page body |
273 | 273 | $this->_job_step_response = $job_response; |
274 | 274 | return $job_response; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * Invokes the report-generating code |
278 | 278 | */ |
279 | 279 | protected function batch_create() { |
280 | - echo EEH_Template::locate_template( EE_SUPPORT_ADMIN . 'templates' . DS . 'admin_batch_runner.template.html' ); |
|
280 | + echo EEH_Template::locate_template(EE_SUPPORT_ADMIN.'templates'.DS.'admin_batch_runner.template.html'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | * and then sends the user back to wherever they were before |
286 | 286 | */ |
287 | 287 | protected function batch_file_create() { |
288 | - if( $this->_job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse ) { |
|
289 | - $filename = EEH_File::get_filename_from_filepath( $this->_job_step_response->job_parameters()->extra_datum( 'filepath' ) ); |
|
288 | + if ($this->_job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse) { |
|
289 | + $filename = EEH_File::get_filename_from_filepath($this->_job_step_response->job_parameters()->extra_datum('filepath')); |
|
290 | 290 | } else { |
291 | - $filename = __( 'Unknown', 'event_espresso' ); |
|
291 | + $filename = __('Unknown', 'event_espresso'); |
|
292 | 292 | } |
293 | 293 | echo EEH_Template::locate_template( |
294 | - EE_SUPPORT_ADMIN . 'templates' . DS . 'admin_batch_file_runner.template.html', |
|
294 | + EE_SUPPORT_ADMIN.'templates'.DS.'admin_batch_file_runner.template.html', |
|
295 | 295 | array( |
296 | 296 | 'filename' => $filename |
297 | 297 | ) |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | * Receives ajax calls for continuing a job |
303 | 303 | */ |
304 | 304 | public function batch_continue() { |
305 | - $job_id = sanitize_text_field( $this->_req_data[ 'job_id' ] ); |
|
305 | + $job_id = sanitize_text_field($this->_req_data['job_id']); |
|
306 | 306 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
307 | - $responseobj = $batch_runner->continue_job( $job_id); |
|
308 | - $this->_template_args[ 'data' ] = $responseobj->to_array(); |
|
307 | + $responseobj = $batch_runner->continue_job($job_id); |
|
308 | + $this->_template_args['data'] = $responseobj->to_array(); |
|
309 | 309 | $this->_return_json(); |
310 | 310 | } |
311 | 311 | |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * @return type |
315 | 315 | */ |
316 | 316 | public function batch_cleanup() { |
317 | - $job_id = sanitize_text_field( $this->_req_data[ 'job_id' ] ); |
|
317 | + $job_id = sanitize_text_field($this->_req_data['job_id']); |
|
318 | 318 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
319 | - $response_obj = $batch_runner->cleanup_job( $job_id ); |
|
320 | - $this->_template_args[ 'data' ] = $response_obj->to_array(); |
|
319 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
320 | + $this->_template_args['data'] = $response_obj->to_array(); |
|
321 | 321 | $this->_return_json(); |
322 | 322 | } |
323 | 323 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Transaction Model |
@@ -68,36 +68,36 @@ discard block |
||
68 | 68 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
69 | 69 | * @return EEM_Transaction |
70 | 70 | */ |
71 | - protected function __construct( $timezone ) { |
|
72 | - $this->singular_item = __('Transaction','event_espresso'); |
|
73 | - $this->plural_item = __('Transactions','event_espresso'); |
|
71 | + protected function __construct($timezone) { |
|
72 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
73 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
74 | 74 | |
75 | 75 | $this->_tables = array( |
76 | - 'Transaction'=>new EE_Primary_Table('esp_transaction','TXN_ID') |
|
76 | + 'Transaction'=>new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
77 | 77 | ); |
78 | 78 | $this->_fields = array( |
79 | 79 | 'Transaction'=>array( |
80 | - 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')), |
|
81 | - 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, time(), $timezone ), |
|
82 | - 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0), |
|
83 | - 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0), |
|
84 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
85 | - 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''), |
|
86 | - 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''), |
|
80 | + 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
81 | + 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone), |
|
82 | + 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0), |
|
83 | + 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
84 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
85 | + 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''), |
|
86 | + 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
87 | 87 | 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'), |
88 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ), |
|
88 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()), |
|
89 | 89 | ) |
90 | 90 | ); |
91 | 91 | $this->_model_relations = array( |
92 | 92 | 'Registration'=>new EE_Has_Many_Relation(), |
93 | 93 | 'Payment'=>new EE_Has_Many_Relation(), |
94 | 94 | 'Status'=>new EE_Belongs_To_Relation(), |
95 | - 'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items |
|
95 | + 'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items |
|
96 | 96 | 'Payment_Method'=>new EE_Belongs_To_Relation(), |
97 | 97 | 'Message' => new EE_Has_Many_Relation() |
98 | 98 | ); |
99 | 99 | $this->_model_chain_to_wp_user = 'Registration.Event'; |
100 | - parent::__construct( $timezone ); |
|
100 | + parent::__construct($timezone); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | * @param string $period |
109 | 109 | * @return \stdClass[] |
110 | 110 | */ |
111 | - public function get_revenue_per_day_report( $period = '-1 month' ) { |
|
111 | + public function get_revenue_per_day_report($period = '-1 month') { |
|
112 | 112 | |
113 | - $sql_date = $this->convert_datetime_for_query( 'TXN_timestamp', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
113 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
114 | 114 | $results = $this->_get_all_wpdb_results( |
115 | 115 | array( |
116 | 116 | array( |
117 | 117 | 'TXN_timestamp' => array('>=', $sql_date)), |
118 | 118 | 'group_by' => 'txnDate', |
119 | - 'order_by' => array('TXN_timestamp' => 'DESC' ) |
|
119 | + 'order_by' => array('TXN_timestamp' => 'DESC') |
|
120 | 120 | ), |
121 | 121 | OBJECT, |
122 | 122 | array( |
123 | - 'txnDate' => array('DATE(Transaction.TXN_timestamp)','%s'), |
|
123 | + 'txnDate' => array('DATE(Transaction.TXN_timestamp)', '%s'), |
|
124 | 124 | 'revenue' => array('SUM(Transaction.TXN_paid)', '%d') |
125 | 125 | )); |
126 | 126 | return $results; |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * @throws \EE_Error |
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | - public function get_revenue_per_event_report( $period = 'month' ) { |
|
139 | + public function get_revenue_per_event_report($period = 'month') { |
|
140 | 140 | /** @type WPDB $wpdb */ |
141 | 141 | global $wpdb; |
142 | - $date_mod = strtotime( '-1 ' . $period ); |
|
142 | + $date_mod = strtotime('-1 '.$period); |
|
143 | 143 | |
144 | 144 | $SQL = 'SELECT post_title as event_name, SUM(TXN_paid) AS revenue'; |
145 | - $SQL .= ' FROM ' . $this->_get_main_table()->get_table_name() . ' txn'; |
|
146 | - $SQL .= ' LEFT JOIN ' . $wpdb->prefix . 'esp_registration reg ON reg.TXN_ID = txn.TXN_ID'; |
|
147 | - $SQL .= ' LEFT JOIN ' . $wpdb->posts . ' evt ON evt.ID = reg.EVT_ID'; |
|
145 | + $SQL .= ' FROM '.$this->_get_main_table()->get_table_name().' txn'; |
|
146 | + $SQL .= ' LEFT JOIN '.$wpdb->prefix.'esp_registration reg ON reg.TXN_ID = txn.TXN_ID'; |
|
147 | + $SQL .= ' LEFT JOIN '.$wpdb->posts.' evt ON evt.ID = reg.EVT_ID'; |
|
148 | 148 | $SQL .= ' WHERE REG_count = 1'; |
149 | 149 | $SQL .= ' AND REG_date >= %d'; |
150 | 150 | $SQL .= ' GROUP BY event_name'; |
151 | 151 | $SQL .= ' ORDER BY event_name'; |
152 | 152 | $SQL .= ' LIMIT 0, 24'; |
153 | 153 | |
154 | - return $this->_do_wpdb_query( 'get_results', array( $wpdb->prepare( $SQL, $date_mod ) ) ); |
|
154 | + return $this->_do_wpdb_query('get_results', array($wpdb->prepare($SQL, $date_mod))); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * @param string $reg_url_link |
168 | 168 | * @return EE_Transaction |
169 | 169 | */ |
170 | - public function get_transaction_from_reg_url_link( $reg_url_link = '' ){ |
|
171 | - return $this->get_one( array( |
|
170 | + public function get_transaction_from_reg_url_link($reg_url_link = '') { |
|
171 | + return $this->get_one(array( |
|
172 | 172 | array( |
173 | - 'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) |
|
173 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '') |
|
174 | 174 | ) |
175 | 175 | )); |
176 | 176 | } |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | * @param boolean $save_txn whether or not to save the transaction during this function call |
191 | 191 | * @return boolean |
192 | 192 | */ |
193 | - public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){ |
|
193 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) { |
|
194 | 194 | EE_Error::doing_it_wrong( |
195 | - __CLASS__ . '::' . __FUNCTION__, |
|
196 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
195 | + __CLASS__.'::'.__FUNCTION__, |
|
196 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
197 | 197 | '4.6.0' |
198 | 198 | ); |
199 | 199 | /** @type EE_Transaction_Processor $transaction_processor */ |
200 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
201 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this->ensure_is_obj( $transaction_obj_or_id )); |
|
200 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
201 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this->ensure_is_obj($transaction_obj_or_id)); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | array( |
230 | 230 | 0 => array( |
231 | 231 | 'STS_ID' => EEM_Transaction::failed_status_code, |
232 | - 'TXN_timestamp' => array( '<', time() - $time_to_leave_alone ) |
|
232 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
233 | 233 | ) |
234 | 234 | ), |
235 | 235 | $time_to_leave_alone |
@@ -242,26 +242,26 @@ discard block |
||
242 | 242 | */ |
243 | 243 | $txn_ids = apply_filters( |
244 | 244 | 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
245 | - EEM_Transaction::instance()->get_col( $ids_query, 'TXN_ID' ), |
|
245 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
246 | 246 | $time_to_leave_alone |
247 | 247 | ); |
248 | 248 | |
249 | 249 | //now that we have the ids to delete, let's get deletin' |
250 | 250 | //Why no wpdb->prepare? Because the data is trusted. We got the ids from the original query to get them FROM |
251 | 251 | //the db (which is sanitized) so no need to prepare them again. |
252 | - if ( $txn_ids ) { |
|
253 | - $query = ' |
|
252 | + if ($txn_ids) { |
|
253 | + $query = ' |
|
254 | 254 | DELETE |
255 | - FROM ' . $this->table() . ' |
|
255 | + FROM ' . $this->table().' |
|
256 | 256 | WHERE |
257 | - TXN_ID IN ( ' . implode( ",", $txn_ids ) . ')'; |
|
258 | - $deleted = $wpdb->query( $query ); |
|
257 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
258 | + $deleted = $wpdb->query($query); |
|
259 | 259 | } |
260 | - if ( $deleted ) { |
|
260 | + if ($deleted) { |
|
261 | 261 | /** |
262 | 262 | * Allows code to do something after the transactions have been deleted. |
263 | 263 | */ |
264 | - do_action( 'AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids ); |
|
264 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
265 | 265 | } |
266 | 266 | return $deleted; |
267 | 267 | } |
@@ -1,6 +1,6 @@ |
||
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 | * Class EE_Line_Item_Filter_Collection |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | * @package Event Espresso |
8 | 8 | * @subpackage core, capabilities |
9 | 9 | */ |
10 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
11 | - exit( 'No direct script access allowed' ); |
|
10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function instance() { |
71 | 71 | //check if instantiated, and if not do so. |
72 | - if ( ! self::$_instance instanceof EE_Capabilities ) { |
|
72 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
73 | 73 | self::$_instance = new self(); |
74 | 74 | } |
75 | 75 | return self::$_instance; |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @since 4.5.0 |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function init_caps( $reset = false ) { |
|
102 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
101 | + public function init_caps($reset = false) { |
|
102 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
103 | 103 | $this->_caps_map = $this->_init_caps_map(); |
104 | - $this->init_role_caps( $reset ); |
|
104 | + $this->init_role_caps($reset); |
|
105 | 105 | $this->_set_meta_caps(); |
106 | 106 | } |
107 | 107 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
121 | 121 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
122 | 122 | |
123 | - $this->_meta_caps = apply_filters( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps ); |
|
123 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
124 | 124 | |
125 | 125 | //add filter for map_meta_caps but only if models can query. |
126 | - if ( EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ) ) ) { |
|
127 | - add_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10, 4 ); |
|
126 | + if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
127 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function _get_default_meta_caps_array() { |
139 | 139 | static $default_meta_caps = array(); |
140 | - if ( empty( $default_meta_caps ) ) { |
|
140 | + if (empty($default_meta_caps)) { |
|
141 | 141 | $default_meta_caps = array( |
142 | 142 | //edits |
143 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_event', array( 'Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events' ) ), |
|
144 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_venue', array( 'Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues' ) ), |
|
145 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_registration', array( 'Registration', '', 'ee_edit_others_registrations', '' ) ), |
|
146 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_checkin', array( 'Registration', '', 'ee_edit_others_checkins', '' ) ), |
|
147 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_edit_message', array( 'Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages' ) ), |
|
148 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_default_ticket', array( 'Ticket', '', 'ee_edit_others_default_tickets', '' ) ), |
|
149 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question', array( 'Question', '', '', 'ee_edit_system_questions' ) ), |
|
150 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question_group', array( 'Question_Group', '', '', 'ee_edit_system_question_groups' ) ), |
|
151 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_payment_method', array( 'Payment_Method', '', 'ee_edit_others_payment_methods', '' ) ), |
|
143 | + new EE_Meta_Capability_Map_Edit('ee_edit_event', array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
144 | + new EE_Meta_Capability_Map_Edit('ee_edit_venue', array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
145 | + new EE_Meta_Capability_Map_Edit('ee_edit_registration', array('Registration', '', 'ee_edit_others_registrations', '')), |
|
146 | + new EE_Meta_Capability_Map_Edit('ee_edit_checkin', array('Registration', '', 'ee_edit_others_checkins', '')), |
|
147 | + new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
148 | + new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
149 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', array('Question', '', '', 'ee_edit_system_questions')), |
|
150 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
151 | + new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
152 | 152 | //reads |
153 | - new EE_Meta_Capability_Map_Read( 'ee_read_event', array( 'Event', '', 'ee_read_others_events', 'ee_read_private_events' ) ), |
|
154 | - new EE_Meta_Capability_Map_Read( 'ee_read_venue', array( 'Venue', '', 'ee_read_others_venues', 'ee_read_private_venues' ) ), |
|
155 | - new EE_Meta_Capability_Map_Read( 'ee_read_registration', array( 'Registration', '', '', 'ee_edit_others_registrations' ) ), |
|
156 | - new EE_Meta_Capability_Map_Read( 'ee_read_checkin', array( 'Registration', '', '', 'ee_read_others_checkins' ) ), |
|
157 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_read_message', array( 'Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages' ) ), |
|
158 | - new EE_Meta_Capability_Map_Read( 'ee_read_default_ticket', array( 'Ticket', '', '', 'ee_read_others_default_tickets' ) ), |
|
159 | - new EE_Meta_Capability_Map_Read( 'ee_read_payment_method', array( 'Payment_Method', '', '', 'ee_read_others_payment_methods' ) ), |
|
153 | + new EE_Meta_Capability_Map_Read('ee_read_event', array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
154 | + new EE_Meta_Capability_Map_Read('ee_read_venue', array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
155 | + new EE_Meta_Capability_Map_Read('ee_read_registration', array('Registration', '', '', 'ee_edit_others_registrations')), |
|
156 | + new EE_Meta_Capability_Map_Read('ee_read_checkin', array('Registration', '', '', 'ee_read_others_checkins')), |
|
157 | + new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
158 | + new EE_Meta_Capability_Map_Read('ee_read_default_ticket', array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
159 | + new EE_Meta_Capability_Map_Read('ee_read_payment_method', array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
160 | 160 | |
161 | 161 | //deletes |
162 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_event', array( 'Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events' ) ), |
|
163 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_venue', array( 'Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues' ) ), |
|
164 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_registration', array( 'Registration', '', 'ee_delete_others_registrations', '' ) ), |
|
165 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_checkin', array( 'Registration', '', 'ee_delete_others_checkins', '' ) ), |
|
166 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_delete_message', array( 'Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages' ) ), |
|
167 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_default_ticket', array( 'Ticket', '', 'ee_delete_others_default_tickets', '' ) ), |
|
168 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question', array( 'Question', '', '', 'delete_system_questions' ) ), |
|
169 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question_group', array( 'Question_Group', '', '', 'delete_system_question_groups' ) ), |
|
170 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_payment_method', array( 'Payment_Method', '', 'ee_delete_others_payment_methods', '' ) ), |
|
162 | + new EE_Meta_Capability_Map_Delete('ee_delete_event', array('Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events')), |
|
163 | + new EE_Meta_Capability_Map_Delete('ee_delete_venue', array('Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues')), |
|
164 | + new EE_Meta_Capability_Map_Delete('ee_delete_registration', array('Registration', '', 'ee_delete_others_registrations', '')), |
|
165 | + new EE_Meta_Capability_Map_Delete('ee_delete_checkin', array('Registration', '', 'ee_delete_others_checkins', '')), |
|
166 | + new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
167 | + new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
168 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', array('Question', '', '', 'delete_system_questions')), |
|
169 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', array('Question_Group', '', '', 'delete_system_question_groups')), |
|
170 | + new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | return $default_meta_caps; |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return array actual users capabilities |
193 | 193 | */ |
194 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
194 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
195 | 195 | //loop through our _meta_caps array |
196 | - foreach ( $this->_meta_caps as $meta_map ) { |
|
197 | - if ( ! $meta_map instanceof EE_Meta_Capability_Map ) { |
|
196 | + foreach ($this->_meta_caps as $meta_map) { |
|
197 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | $meta_map->ensure_is_model(); |
201 | 201 | |
202 | - $caps = $meta_map->map_meta_caps( $caps, $cap, $user_id, $args ); |
|
202 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
203 | 203 | } |
204 | 204 | return $caps; |
205 | 205 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - $caps = apply_filters( 'FHEE__EE_Capabilities__init_caps_map__caps', $caps ); |
|
367 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
368 | 368 | return $caps; |
369 | 369 | } |
370 | 370 | |
@@ -381,26 +381,26 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - public function init_role_caps( $reset = false, $custom_map = array() ) { |
|
384 | + public function init_role_caps($reset = false, $custom_map = array()) { |
|
385 | 385 | |
386 | - $caps_map = empty( $custom_map ) ? $this->_caps_map : $custom_map; |
|
386 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
387 | 387 | |
388 | 388 | //first let's determine if these caps have already been set. |
389 | - $caps_set_before = get_option( self::option_name, array() ); |
|
389 | + $caps_set_before = get_option(self::option_name, array()); |
|
390 | 390 | //if not reset, see what caps are new for each role. if they're new, add them. |
391 | - foreach ( $caps_map as $role => $caps_for_role ) { |
|
392 | - foreach ( $caps_for_role as $cap ) { |
|
391 | + foreach ($caps_map as $role => $caps_for_role) { |
|
392 | + foreach ($caps_for_role as $cap) { |
|
393 | 393 | //first check we haven't already added this cap before, or it's a reset |
394 | - if ( $reset || ! isset( $caps_set_before[ $role ] ) || ! in_array( $cap, $caps_set_before[ $role ] ) ) { |
|
395 | - $this->add_cap_to_role( $role, $cap ); |
|
396 | - $caps_set_before[ $role ][] = $cap; |
|
394 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
395 | + $this->add_cap_to_role($role, $cap); |
|
396 | + $caps_set_before[$role][] = $cap; |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | 401 | //now let's just save the cap that has been set. |
402 | - update_option( self::option_name, $caps_set_before ); |
|
403 | - do_action( 'AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before ); |
|
402 | + update_option(self::option_name, $caps_set_before); |
|
403 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | * @param bool $grant Whether to grant access to this cap on this role. |
420 | 420 | * @return void |
421 | 421 | */ |
422 | - public function add_cap_to_role( $role, $cap, $grant = true ) { |
|
423 | - $role = get_role( $role ); |
|
424 | - if ( $role instanceof WP_Role ) { |
|
425 | - $role->add_cap( $cap, $grant ); |
|
422 | + public function add_cap_to_role($role, $cap, $grant = true) { |
|
423 | + $role = get_role($role); |
|
424 | + if ($role instanceof WP_Role) { |
|
425 | + $role->add_cap($cap, $grant); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return void |
444 | 444 | */ |
445 | - public function remove_cap_from_role( $role, $cap ) { |
|
446 | - $role = get_role( $role ); |
|
447 | - if ( $role instanceof WP_Role ) { |
|
448 | - $role->remove_cap( $cap ); |
|
445 | + public function remove_cap_from_role($role, $cap) { |
|
446 | + $role = get_role($role); |
|
447 | + if ($role instanceof WP_Role) { |
|
448 | + $role->remove_cap($cap); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return bool Whether user can or not. |
468 | 468 | */ |
469 | - public function current_user_can( $cap, $context, $id = 0 ) { |
|
469 | + public function current_user_can($cap, $context, $id = 0) { |
|
470 | 470 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
471 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id ); |
|
472 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id ); |
|
473 | - return ! empty( $id ) ? current_user_can( $filtered_cap, $id ) : current_user_can( $filtered_cap ); |
|
471 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
472 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id); |
|
473 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -487,11 +487,11 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @return bool Whether user can or not. |
489 | 489 | */ |
490 | - public function user_can( $user, $cap, $context, $id = 0 ) { |
|
490 | + public function user_can($user, $cap, $context, $id = 0) { |
|
491 | 491 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
492 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id ); |
|
493 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id ); |
|
494 | - return ! empty( $id ) ? user_can( $user, $filtered_cap, $id ) : user_can( $user, $filtered_cap ); |
|
492 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
493 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id); |
|
494 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -511,12 +511,12 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @return bool Whether user can or not. |
513 | 513 | */ |
514 | - public function current_user_can_for_blog( $blog_id, $cap, $context, $id = 0 ) { |
|
515 | - $user_can = ! empty( $id ) ? current_user_can_for_blog( $blog_id, $cap, $id ) : current_user_can( $blog_id, $cap ); |
|
514 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) { |
|
515 | + $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
516 | 516 | |
517 | 517 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
518 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, $blog_id, $cap, $id ); |
|
519 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id ); |
|
518 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, $blog_id, $cap, $id); |
|
519 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id); |
|
520 | 520 | return $user_can; |
521 | 521 | } |
522 | 522 | |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return array |
534 | 534 | */ |
535 | - public function get_ee_capabilities( $role = 'administrator' ) { |
|
535 | + public function get_ee_capabilities($role = 'administrator') { |
|
536 | 536 | $capabilities = $this->_init_caps_map(); |
537 | - if ( empty( $role ) ) { |
|
537 | + if (empty($role)) { |
|
538 | 538 | return $capabilities; |
539 | 539 | } |
540 | - return isset( $capabilities[ $role ] ) ? $capabilities[ $role ] : array(); |
|
540 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | * } |
586 | 586 | * @throws EE_Error |
587 | 587 | */ |
588 | - public function __construct( $meta_cap, $map_values ) { |
|
588 | + public function __construct($meta_cap, $map_values) { |
|
589 | 589 | $this->meta_cap = $meta_cap; |
590 | 590 | //verify there are four args in the $map_values array; |
591 | - if ( count( $map_values ) !== 4 ) { |
|
592 | - throw new EE_Error( sprintf( __( 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso' ), '<br>' . print_r( $map_values, true ) ) ); |
|
591 | + if (count($map_values) !== 4) { |
|
592 | + throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso'), '<br>'.print_r($map_values, true))); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | //set properties |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * Makes it so this object stops filtering caps |
605 | 605 | */ |
606 | - public function remove_filters(){ |
|
607 | - remove_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10 ); |
|
606 | + public function remove_filters() { |
|
607 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | |
@@ -619,19 +619,19 @@ discard block |
||
619 | 619 | */ |
620 | 620 | public function ensure_is_model() { |
621 | 621 | //is it already instantiated? |
622 | - if ( $this->_model instanceof EEM_Base ) { |
|
622 | + if ($this->_model instanceof EEM_Base) { |
|
623 | 623 | return; |
624 | 624 | } |
625 | 625 | |
626 | 626 | //ensure model name is string |
627 | 627 | $this->_model_name = (string) $this->_model_name; |
628 | 628 | //error proof if the name has EEM in it |
629 | - $this->_model_name = str_replace( 'EEM', '', $this->_model_name ); |
|
629 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
630 | 630 | |
631 | - $this->_model = EE_Registry::instance()->load_model( $this->_model_name ); |
|
631 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
632 | 632 | |
633 | - if ( ! $this->_model instanceof EEM_Base ) { |
|
634 | - throw new EE_Error( sprintf( __( 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso' ), get_class( $this ), $this->_model ) ); |
|
633 | + if ( ! $this->_model instanceof EEM_Base) { |
|
634 | + throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso'), get_class($this), $this->_model)); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * |
648 | 648 | * @return array |
649 | 649 | */ |
650 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
651 | - return $this->_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
650 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
651 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return array actual users capabilities |
668 | 668 | */ |
669 | - abstract protected function _map_meta_caps( $caps, $cap, $user_id, $args ); |
|
669 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | |
@@ -698,28 +698,28 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return array actual users capabilities |
700 | 700 | */ |
701 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
701 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
702 | 702 | //only process if we're checking our mapped_cap |
703 | - if ( $cap !== $this->meta_cap ) { |
|
703 | + if ($cap !== $this->meta_cap) { |
|
704 | 704 | return $caps; |
705 | 705 | } |
706 | 706 | |
707 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
707 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
708 | 708 | |
709 | 709 | //if no obj then let's just do cap |
710 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
710 | + if ( ! $obj instanceof EE_Base_Class) { |
|
711 | 711 | $caps[] = $cap; |
712 | 712 | return $caps; |
713 | 713 | } |
714 | 714 | |
715 | - if ( $obj instanceof EE_CPT_Base ) { |
|
715 | + if ($obj instanceof EE_CPT_Base) { |
|
716 | 716 | //if the item author is set and the user is the author... |
717 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
718 | - if ( empty( $this->published_cap ) ) { |
|
717 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
718 | + if (empty($this->published_cap)) { |
|
719 | 719 | $caps[] = $cap; |
720 | 720 | } else { |
721 | 721 | //if obj is published... |
722 | - if ( $obj->status() == 'publish' ) { |
|
722 | + if ($obj->status() == 'publish') { |
|
723 | 723 | $caps[] = $this->published_cap; |
724 | 724 | } else { |
725 | 725 | $caps[] = $cap; |
@@ -727,21 +727,21 @@ discard block |
||
727 | 727 | } |
728 | 728 | } else { |
729 | 729 | //the user is trying to edit someone else's obj |
730 | - if ( ! empty( $this->others_cap ) ) { |
|
730 | + if ( ! empty($this->others_cap)) { |
|
731 | 731 | $caps[] = $this->others_cap; |
732 | 732 | } |
733 | - if ( ! empty( $this->published_cap ) && $obj->status() == 'publish' ) { |
|
733 | + if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
734 | 734 | $caps[] = $this->published_cap; |
735 | - } elseif ( ! empty( $this->private_cap ) && $obj->status() == 'private' ) { |
|
735 | + } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
736 | 736 | $caps[] = $this->private_cap; |
737 | 737 | } |
738 | 738 | } |
739 | 739 | } else { |
740 | 740 | //not a cpt object so handled differently |
741 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
741 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
742 | 742 | $caps[] = $cap; |
743 | 743 | } else { |
744 | - if ( ! empty( $this->others_cap ) ) { |
|
744 | + if ( ! empty($this->others_cap)) { |
|
745 | 745 | $caps[] = $this->others_cap; |
746 | 746 | } |
747 | 747 | } |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | * |
779 | 779 | * @return array actual users capabilities |
780 | 780 | */ |
781 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
782 | - return parent::_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
781 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
782 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
@@ -811,45 +811,45 @@ discard block |
||
811 | 811 | * |
812 | 812 | * @return array actual users capabilities |
813 | 813 | */ |
814 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
814 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
815 | 815 | //only process if we're checking our mapped cap; |
816 | - if ( $cap !== $this->meta_cap ) { |
|
816 | + if ($cap !== $this->meta_cap) { |
|
817 | 817 | return $caps; |
818 | 818 | } |
819 | 819 | |
820 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
820 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
821 | 821 | |
822 | 822 | //if no obj then let's just do cap |
823 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
823 | + if ( ! $obj instanceof EE_Base_Class) { |
|
824 | 824 | $caps[] = $cap; |
825 | 825 | return $caps; |
826 | 826 | } |
827 | 827 | |
828 | - if ( $obj instanceof EE_CPT_Base ) { |
|
829 | - $status_obj = get_post_status_object( $obj->status() ); |
|
830 | - if ( $status_obj->public ) { |
|
828 | + if ($obj instanceof EE_CPT_Base) { |
|
829 | + $status_obj = get_post_status_object($obj->status()); |
|
830 | + if ($status_obj->public) { |
|
831 | 831 | $caps[] = $cap; |
832 | 832 | return $caps; |
833 | 833 | } |
834 | 834 | |
835 | 835 | //if the item author is set and the user is the author... |
836 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
836 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
837 | 837 | $caps[] = $cap; |
838 | - } elseif ( $status_obj->private && ! empty( $this->private_cap ) ) { |
|
838 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
839 | 839 | //the user is trying to view someone else's obj |
840 | 840 | $caps[] = $this->private_cap; |
841 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
841 | + } elseif ( ! empty($this->others_cap)) { |
|
842 | 842 | $caps[] = $this->others_cap; |
843 | 843 | } else { |
844 | 844 | $caps[] = $cap; |
845 | 845 | } |
846 | 846 | } else { |
847 | 847 | //not a cpt object so handled differently |
848 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
848 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
849 | 849 | $caps[] = $cap; |
850 | - } elseif ( ! empty( $this->private_cap ) ) { |
|
850 | + } elseif ( ! empty($this->private_cap)) { |
|
851 | 851 | $caps[] = $this->private_cap; |
852 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
852 | + } elseif ( ! empty($this->others_cap)) { |
|
853 | 853 | $caps[] = $this->others_cap; |
854 | 854 | } else { |
855 | 855 | $caps[] = $cap; |
@@ -886,30 +886,30 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return array actual users capabilities |
888 | 888 | */ |
889 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
889 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
890 | 890 | //only process if we're checking our mapped_cap |
891 | - if ( $cap !== $this->meta_cap ) { |
|
891 | + if ($cap !== $this->meta_cap) { |
|
892 | 892 | return $caps; |
893 | 893 | } |
894 | 894 | |
895 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
895 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
896 | 896 | |
897 | 897 | //if no obj then let's just do cap |
898 | - if ( ! $obj instanceof EE_Message_Template_Group ) { |
|
898 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
899 | 899 | $caps[] = $cap; |
900 | 900 | return $caps; |
901 | 901 | } |
902 | 902 | |
903 | 903 | $is_global = $obj->is_global(); |
904 | 904 | |
905 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
906 | - if ( $is_global ) { |
|
907 | - $caps[] = $this->private_cap; |
|
905 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
906 | + if ($is_global) { |
|
907 | + $caps[] = $this->private_cap; |
|
908 | 908 | } else { |
909 | 909 | $caps[] = $cap; |
910 | 910 | } |
911 | 911 | } else { |
912 | - if ( $is_global ) { |
|
912 | + if ($is_global) { |
|
913 | 913 | $caps[] = $this->private_cap; |
914 | 914 | } else { |
915 | 915 | $caps[] = $this->others_cap; |
@@ -947,16 +947,16 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @return array actual users capabilities |
949 | 949 | */ |
950 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
950 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
951 | 951 | //only process if we're checking our mapped_cap |
952 | - if ( $cap !== $this->meta_cap ) { |
|
952 | + if ($cap !== $this->meta_cap) { |
|
953 | 953 | return $caps; |
954 | 954 | } |
955 | 955 | |
956 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
956 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
957 | 957 | |
958 | 958 | //if no obj then let's just do cap |
959 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
959 | + if ( ! $obj instanceof EE_Base_Class) { |
|
960 | 960 | $caps[] = $cap; |
961 | 961 | return $caps; |
962 | 962 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
965 | 965 | $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
966 | 966 | |
967 | - if ( $is_system ) { |
|
967 | + if ($is_system) { |
|
968 | 968 | $caps[] = $this->private_cap; |
969 | 969 | } else { |
970 | 970 | $caps[] = $cap; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | $this->_shortcodes = array( |
43 | 43 | '[TXN_ID]' => __('The transaction id for the purchase.', 'event_espresso'), |
44 | 44 | '[PAYMENT_URL]' => __('This is a link to make a payment for the event', 'event_espresso'), |
45 | - '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>' |
|
46 | - . '<li>' . sprintf( __('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
47 | - . '<li>' . sprintf( __('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
48 | - . '<li>' . sprintf( __('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
45 | + '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
46 | + . '<li>'.sprintf(__('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
47 | + . '<li>'.sprintf(__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
48 | + . '<li>'.sprintf(__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
49 | 49 | . '</ul>', |
50 | - '[PAYMENT_DUE_DATE_*]' => __( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
50 | + '[PAYMENT_DUE_DATE_*]' => __('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
51 | 51 | . '<ul>' |
52 | - . '<li>' . sprintf( __( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
53 | - . '<li>' . sprintf( __( '%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
54 | - . '<li>' . sprintf( __( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
52 | + . '<li>'.sprintf(__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
53 | + . '<li>'.sprintf(__('%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
54 | + . '<li>'.sprintf(__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
55 | 55 | '[INVOICE_LINK]' => __('This is a full html link to the invoice', 'event_espresso'), |
56 | 56 | '[INVOICE_URL]' => __('This is just the url for the invoice', 'event_espresso'), |
57 | 57 | '[INVOICE_LOGO_URL]' => __('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
58 | 58 | '[INVOICE_LOGO]' => __('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
59 | 59 | '[INVOICE_PAYEE_NAME]' => __('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
60 | - '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
61 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), |
|
60 | + '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
61 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), |
|
64 | 64 | '[TOTAL_COST]' => __('The total cost for the transaction', 'event_espresso'), |
65 | 65 | '[TXN_STATUS]' => __('The transaction status for the transaction.', 'event_espresso'), |
66 | 66 | '[TXN_STATUS_ID]' => __('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
@@ -71,54 +71,54 @@ discard block |
||
71 | 71 | '[TOTAL_OWING]' => __('The total owing on a transaction with no attributes.', 'event_espresso'), |
72 | 72 | '[TXN_SUBTOTAL]' => __('The subtotal for all txn line items.', 'event_espresso'), |
73 | 73 | '[TXN_TAX_SUBTOTAL]' => __('The subtotal for all tax line items.', 'event_espresso'), |
74 | - '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' . |
|
75 | - '<li><strong>still_owing</strong>:' . __('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
76 | - '<li><strong>none_owing</strong>:' . __('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>', |
|
74 | + '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
75 | + '<li><strong>still_owing</strong>:'.__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
76 | + '<li><strong>none_owing</strong>:'.__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>', |
|
77 | 77 | '[TXN_TOTAL_TICKETS]' => __('The total number of all tickets purchased in a transaction', 'event_espresso'), |
78 | 78 | '[TKT_QTY_PURCHASED]' => __('The total number of all tickets purchased in a transaction. <strong>NOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.</strong>', 'event_espresso'), |
79 | 79 | '[TRANSACTION_ADMIN_URL]' => __('The url to the admin page for this transaction', 'event_espresso'), |
80 | 80 | '[RECEIPT_URL]' => __('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
81 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => __( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( __( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
81 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => __('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - protected function _parser( $shortcode ) { |
|
87 | + protected function _parser($shortcode) { |
|
88 | 88 | |
89 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
89 | + EE_Registry::instance()->load_helper('Template'); |
|
90 | 90 | |
91 | 91 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
92 | 92 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
93 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
93 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
94 | 94 | |
95 | 95 | //payment |
96 | 96 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
97 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
97 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
98 | 98 | |
99 | 99 | |
100 | - if ( ! $transaction instanceof EE_Transaction ) |
|
100 | + if ( ! $transaction instanceof EE_Transaction) |
|
101 | 101 | return ''; |
102 | 102 | |
103 | - switch ( $shortcode ) { |
|
103 | + switch ($shortcode) { |
|
104 | 104 | case '[TXN_ID]' : |
105 | 105 | return $transaction->ID(); |
106 | 106 | break; |
107 | 107 | |
108 | 108 | case '[PAYMENT_URL]' : |
109 | 109 | $payment_url = $transaction->payment_overview_url(); |
110 | - return empty( $payment_url ) ? __( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
110 | + return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
111 | 111 | break; |
112 | 112 | |
113 | 113 | case '[INVOICE_LINK]' : |
114 | 114 | $invoice_url = $transaction->invoice_url(); |
115 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
116 | - return sprintf( __('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' ); |
|
115 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
116 | + return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
117 | 117 | break; /**/ |
118 | 118 | |
119 | 119 | case '[INVOICE_URL]' : |
120 | 120 | $invoice_url = $transaction->invoice_url(); |
121 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
121 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
122 | 122 | break; |
123 | 123 | |
124 | 124 | case '[INVOICE_LOGO_URL]' : |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | break; |
127 | 127 | |
128 | 128 | case '[INVOICE_LOGO]' : |
129 | - return $this->_get_invoice_logo( TRUE ); |
|
129 | + return $this->_get_invoice_logo(TRUE); |
|
130 | 130 | break; |
131 | 131 | |
132 | 132 | case '[INVOICE_PAYEE_NAME]' : |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | |
149 | 149 | case "[TOTAL_COST]" : |
150 | 150 | $total = $transaction->total(); |
151 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
151 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
152 | 152 | break; |
153 | 153 | |
154 | 154 | case "[PAYMENT_STATUS]" : |
155 | 155 | $status = $transaction->pretty_status(); |
156 | - return !empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
156 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
157 | 157 | break; /**/ |
158 | 158 | |
159 | 159 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
160 | 160 | case "[TXN_STATUS]" : |
161 | 161 | $status = $transaction->pretty_status(); |
162 | - return !empty( $status ) ? $status : __('Unknown', 'event_espresso'); |
|
162 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
163 | 163 | break; |
164 | 164 | |
165 | 165 | case "[TXN_STATUS_ID]" : |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | break; |
168 | 168 | |
169 | 169 | case "[PAYMENT_GATEWAY]" : |
170 | - return $this->_get_payment_gateway( $transaction ); |
|
170 | + return $this->_get_payment_gateway($transaction); |
|
171 | 171 | break; |
172 | 172 | |
173 | 173 | case "[AMOUNT_PAID]" : |
174 | 174 | $amount = $payment instanceof EE_Payment ? $payment->amount() : 0; |
175 | - return EEH_Template::format_currency( $amount ); |
|
175 | + return EEH_Template::format_currency($amount); |
|
176 | 176 | break; |
177 | 177 | |
178 | 178 | case "[TOTAL_AMOUNT_PAID]" : |
179 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
179 | + return EEH_Template::format_currency($transaction->paid()); |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case "[TOTAL_OWING]" : |
183 | 183 | $total_owing = $transaction->remaining(); |
184 | - return EEH_Template::format_currency( $total_owing ); |
|
184 | + return EEH_Template::format_currency($total_owing); |
|
185 | 185 | break; |
186 | 186 | |
187 | 187 | case "[TXN_SUBTOTAL]" : |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | break; |
190 | 190 | |
191 | 191 | case "[TXN_TAX_SUBTOTAL]" : |
192 | - return EEH_Template::format_currency($this->_get_subtotal( TRUE )); |
|
192 | + return EEH_Template::format_currency($this->_get_subtotal(TRUE)); |
|
193 | 193 | break; |
194 | 194 | |
195 | 195 | case "[TKT_QTY_PURCHASED]" : |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | break; |
199 | 199 | |
200 | 200 | case "[TRANSACTION_ADMIN_URL]" : |
201 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
202 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
203 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') ); |
|
201 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
202 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
203 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
204 | 204 | return $url; |
205 | 205 | break; |
206 | 206 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | //get primary_registration |
209 | 209 | $reg = $this->_data->primary_reg_obj; |
210 | 210 | |
211 | - if ( ! $reg instanceof EE_Registration ) { |
|
211 | + if ( ! $reg instanceof EE_Registration) { |
|
212 | 212 | return ''; |
213 | 213 | } |
214 | 214 | return $reg->receipt_url(); |
215 | 215 | break; |
216 | 216 | |
217 | 217 | case "[INVOICE_RECEIPT_SWITCHER_URL]" : |
218 | - return $this->_get_invoice_receipt_switcher( FALSE ); |
|
218 | + return $this->_get_invoice_receipt_switcher(FALSE); |
|
219 | 219 | break; |
220 | 220 | |
221 | 221 | case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" : |
@@ -225,20 +225,20 @@ discard block |
||
225 | 225 | |
226 | 226 | } |
227 | 227 | |
228 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) { |
|
229 | - return $this->_get_custom_total_oweing( $shortcode ); |
|
228 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) { |
|
229 | + return $this->_get_custom_total_oweing($shortcode); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) { |
|
233 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
232 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) { |
|
233 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) { |
|
237 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
236 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) { |
|
237 | + return $this->_get_payment_link_if_needed($shortcode); |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
241 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
240 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
241 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return ''; |
@@ -255,22 +255,22 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return string parsed. |
257 | 257 | */ |
258 | - private function _get_custom_total_oweing( $shortcode ) { |
|
259 | - $valid_shortcodes = array( 'transaction' ); |
|
260 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
258 | + private function _get_custom_total_oweing($shortcode) { |
|
259 | + $valid_shortcodes = array('transaction'); |
|
260 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
261 | 261 | |
262 | 262 | //ensure default is set. |
263 | 263 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
264 | 264 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
265 | 265 | |
266 | - if ( $total_owing > 0 ) { |
|
267 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
266 | + if ($total_owing > 0) { |
|
267 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
268 | 268 | |
269 | 269 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
270 | 270 | $this->_set_shortcode_helper(); |
271 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
271 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
272 | 272 | } else { |
273 | - $owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
273 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | return $owing_content; |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | |
279 | 279 | |
280 | 280 | |
281 | - private function _get_payment_gateway( $transaction ) { |
|
282 | - $pm = $this->_get_payment_method( $transaction ); |
|
281 | + private function _get_payment_gateway($transaction) { |
|
282 | + $pm = $this->_get_payment_method($transaction); |
|
283 | 283 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
284 | 284 | } |
285 | 285 | |
@@ -294,37 +294,37 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return string url or html |
296 | 296 | */ |
297 | - private function _get_invoice_logo( $img_tags = FALSE ) { |
|
297 | + private function _get_invoice_logo($img_tags = FALSE) { |
|
298 | 298 | //try to get the invoice payment method's logo for this transaction image first |
299 | 299 | $pm = $this->_get_payment_method(); |
300 | - if ( $pm instanceof EE_Payment_Method ){ |
|
301 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE ); |
|
302 | - }else{ |
|
300 | + if ($pm instanceof EE_Payment_Method) { |
|
301 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE); |
|
302 | + } else { |
|
303 | 303 | $invoice_logo_url = NULL; |
304 | 304 | } |
305 | - if( empty( $invoice_logo_url ) ){ |
|
305 | + if (empty($invoice_logo_url)) { |
|
306 | 306 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
307 | 307 | } |
308 | 308 | |
309 | - if ( empty( $invoice_logo_url ) ) { |
|
309 | + if (empty($invoice_logo_url)) { |
|
310 | 310 | return ''; |
311 | 311 | } |
312 | 312 | |
313 | - if ( ! $img_tags ) { |
|
313 | + if ( ! $img_tags) { |
|
314 | 314 | return $invoice_logo_url; |
315 | 315 | } |
316 | 316 | |
317 | 317 | //image tags have been requested. |
318 | - $image_size = getimagesize( $invoice_logo_url ); |
|
318 | + $image_size = getimagesize($invoice_logo_url); |
|
319 | 319 | |
320 | 320 | //if image is wider than 200px, set the wideth to 200 |
321 | - if ( $image_size[0] > 300 ) { |
|
321 | + if ($image_size[0] > 300) { |
|
322 | 322 | $image_width = 300; |
323 | - }else{ |
|
323 | + } else { |
|
324 | 324 | $image_width = $image_size[0]; |
325 | 325 | } |
326 | 326 | |
327 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
327 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -341,26 +341,26 @@ discard block |
||
341 | 341 | private function _get_invoice_payee_name() { |
342 | 342 | $payee_name = NULL; |
343 | 343 | $pm = $this->_get_payment_method(); |
344 | - if( $pm instanceof EE_Payment_Method ){ |
|
345 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE ); |
|
344 | + if ($pm instanceof EE_Payment_Method) { |
|
345 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE); |
|
346 | 346 | } |
347 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
347 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
348 | 348 | return $payee_name; |
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * gets the payment method for this transaction. Otherwise gets a default one. |
353 | 353 | */ |
354 | - private function _get_payment_method( $transaction = null ){ |
|
355 | - if( $transaction instanceof EE_Transaction ) { |
|
354 | + private function _get_payment_method($transaction = null) { |
|
355 | + if ($transaction instanceof EE_Transaction) { |
|
356 | 356 | $payment_method = $transaction->payment_method(); |
357 | - if ( empty( $payment_method ) ) { |
|
358 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
357 | + if (empty($payment_method)) { |
|
358 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
359 | 359 | } |
360 | 360 | return $payment_method; |
361 | - }else{ |
|
361 | + } else { |
|
362 | 362 | //get the first payment method we can find |
363 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
363 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | private function _get_invoice_payee_email() { |
378 | 378 | $payee_email = NULL; |
379 | 379 | $pm = $this->_get_payment_method(); |
380 | - if( $pm instanceof EE_Payment_Method ){ |
|
381 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE ); |
|
380 | + if ($pm instanceof EE_Payment_Method) { |
|
381 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE); |
|
382 | 382 | } |
383 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
383 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
384 | 384 | return $payee_email; |
385 | 385 | } |
386 | 386 | |
@@ -396,24 +396,24 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string |
398 | 398 | */ |
399 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
399 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
400 | 400 | $payee_tax_number = NULL; |
401 | 401 | $pm = $this->_get_payment_method(); |
402 | - if( $pm instanceof EE_Payment_Method ){ |
|
403 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE ); |
|
402 | + if ($pm instanceof EE_Payment_Method) { |
|
403 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE); |
|
404 | 404 | } |
405 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
405 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
406 | 406 | |
407 | - if ( empty( $payee_tax_number ) ) { |
|
407 | + if (empty($payee_tax_number)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | 411 | //any attributes? |
412 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
412 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
413 | 413 | |
414 | 414 | //prefix? |
415 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __( 'VAT/Tax Number: ', 'event_espresso' ); |
|
416 | - return $prefix . $payee_tax_number; |
|
415 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
416 | + return $prefix.$payee_tax_number; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -430,22 +430,22 @@ discard block |
||
430 | 430 | private function _get_invoice_payee_address() { |
431 | 431 | $payee_address = NULL; |
432 | 432 | $pm = $this->_get_payment_method(); |
433 | - if( $pm instanceof EE_Payment_Method ){ |
|
434 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE ); |
|
433 | + if ($pm instanceof EE_Payment_Method) { |
|
434 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE); |
|
435 | 435 | } |
436 | - if ( empty( $payee_address ) ) { |
|
436 | + if (empty($payee_address)) { |
|
437 | 437 | $organization = EE_Registry::instance()->CFG->organization; |
438 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
439 | - $payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
440 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
438 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
439 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
440 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
441 | 441 | |
442 | 442 | //state |
443 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
444 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
443 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
444 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
445 | 445 | |
446 | 446 | //Country |
447 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
448 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
447 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
448 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
449 | 449 | } |
450 | 450 | return $payee_address; |
451 | 451 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | private function _get_invoice_payment_instructions() { |
464 | 464 | $instructions = NULL; |
465 | 465 | $pm = $this->_get_payment_method(); |
466 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : ''; |
|
466 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : ''; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -477,27 +477,27 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - protected function _get_invoice_receipt_switcher( $button = TRUE ) { |
|
480 | + protected function _get_invoice_receipt_switcher($button = TRUE) { |
|
481 | 481 | $reg = $this->_data->primary_reg_obj; |
482 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
483 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
482 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
483 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
484 | 484 | return''; |
485 | 485 | } |
486 | 486 | |
487 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
488 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso' ) : __( 'Switch to Invoice', 'event_espresso' ); |
|
489 | - $switch_to_label = ! $switch_to_invoice ? __( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
487 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
488 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso') : __('Switch to Invoice', 'event_espresso'); |
|
489 | + $switch_to_label = ! $switch_to_invoice ? __('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
490 | 490 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
491 | 491 | |
492 | - if ( ! $button ) { |
|
492 | + if ( ! $button) { |
|
493 | 493 | return $switch_to_url; |
494 | 494 | } |
495 | 495 | |
496 | - if ( ! empty( $switch_to_url ) ) { |
|
496 | + if ( ! empty($switch_to_url)) { |
|
497 | 497 | |
498 | 498 | return ' |
499 | -<form method="post" action="' . $switch_to_url . '" > |
|
500 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
499 | +<form method="post" action="' . $switch_to_url.'" > |
|
500 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
501 | 501 | </form> |
502 | 502 | '; |
503 | 503 | } |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - private function _get_receipt_url( EE_Transaction $transaction ) { |
|
520 | + private function _get_receipt_url(EE_Transaction $transaction) { |
|
521 | 521 | //get primary_registration |
522 | 522 | $reg = $this->_data->primary_reg_obj; |
523 | 523 | |
524 | - if ( ! $reg instanceof EE_Registration ) { |
|
524 | + if ( ! $reg instanceof EE_Registration) { |
|
525 | 525 | return ''; |
526 | 526 | } |
527 | 527 | |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return int |
539 | 539 | */ |
540 | - private function _get_subtotal( $tax = FALSE ) { |
|
541 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL; |
|
540 | + private function _get_subtotal($tax = FALSE) { |
|
541 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL; |
|
542 | 542 | |
543 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
543 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
544 | 544 | return 0; |
545 | 545 | } |
546 | 546 | |
@@ -559,27 +559,27 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return string parsed. |
561 | 561 | */ |
562 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
563 | - $valid_shortcodes = array( 'transaction' ); |
|
564 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
562 | + private function _get_payment_link_if_needed($shortcode) { |
|
563 | + $valid_shortcodes = array('transaction'); |
|
564 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
565 | 565 | |
566 | 566 | //ensure default is set. |
567 | 567 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
568 | 568 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
569 | 569 | |
570 | - if ( $total_owing > 0 ) { |
|
571 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
572 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
573 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
574 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
575 | - $opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
576 | - $opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag; |
|
577 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
578 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
570 | + if ($total_owing > 0) { |
|
571 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
572 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
573 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
574 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
575 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
576 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
577 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
578 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
579 | 579 | |
580 | 580 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
581 | 581 | $this->_set_shortcode_helper(); |
582 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
582 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
583 | 583 | } else { |
584 | 584 | return ''; |
585 | 585 | } |
@@ -599,31 +599,31 @@ discard block |
||
599 | 599 | * @param EE_Transaction $transaction |
600 | 600 | * @return string |
601 | 601 | */ |
602 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
602 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
603 | 603 | //if transaction is paid in full then we can just return an empty string |
604 | - if ( $transaction->remaining() === 0 ) { |
|
604 | + if ($transaction->remaining() === 0) { |
|
605 | 605 | return ''; |
606 | 606 | } |
607 | 607 | |
608 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
609 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
610 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
611 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : __( 'Payment in full due by: ', 'event_espresso' ); |
|
612 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
608 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
609 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
610 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
611 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso'); |
|
612 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
613 | 613 | |
614 | 614 | //setup date due: |
615 | 615 | try { |
616 | - if ( $transaction_created instanceof DateTime ) { |
|
617 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
616 | + if ($transaction_created instanceof DateTime) { |
|
617 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
618 | 618 | } else { |
619 | 619 | throw new Exception(); |
620 | 620 | } |
621 | - } catch( Exception $e ) { |
|
621 | + } catch (Exception $e) { |
|
622 | 622 | //format was likely invalid. |
623 | 623 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
624 | 624 | } |
625 | 625 | |
626 | - return $prefix_text . $date_due; |
|
626 | + return $prefix_text.$date_due; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | } //end EE_Transaction Shortcodes library |