@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | <li data-datetime-row="<?php echo esc_attr($dtt_row); ?>" data-context="datetime-ticket" data-ticket-row="<?php echo esc_attr($tkt_row); ?>" |
| 16 | 16 | class="datetime-ticket clickable<?php echo $ticket_selected; |
| 17 | - echo $tkt_status_class; ?>"> |
|
| 17 | + echo $tkt_status_class; ?>"> |
|
| 18 | 18 | <input type="checkbox" name="datetime_ticket[<?php echo esc_attr($dtt_row); ?>][<?php echo esc_attr($tkt_row); ?>]" |
| 19 | 19 | class="datetime-ticket-checkbox" value="1"<?php echo $datetime_ticket_checked; ?>> |
| 20 | 20 | <span class="ee-icon ee-icon-tickets ticket-list-ticket-name"><?php echo $TKT_name; ?></span> |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | placeholder="Datetime Description (optional)"><?php echo esc_textarea($DTT_description); ?></textarea> |
| 24 | 24 | </div> |
| 25 | 25 | <?php do_action( |
| 26 | - 'AHEE__event_tickets_datetime_attached_tickets_row_template__advanced_details_after_dtt_description', |
|
| 27 | - $dtt_row, |
|
| 28 | - $DTT_ID |
|
| 29 | - ); ?> |
|
| 26 | + 'AHEE__event_tickets_datetime_attached_tickets_row_template__advanced_details_after_dtt_description', |
|
| 27 | + $dtt_row, |
|
| 28 | + $DTT_ID |
|
| 29 | + ); ?> |
|
| 30 | 30 | <h4 class="datetime-tickets-heading"><?php esc_html_e('Assigned Tickets', 'event_espresso'); ?></h4> |
| 31 | 31 | |
| 32 | 32 | <ul class="datetime-tickets-list"> |
@@ -36,28 +36,28 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | <div class="add-datetime-ticket-container"> |
| 38 | 38 | <h4 class="datetime-tickets-heading"><?php |
| 39 | - esc_html_e( |
|
| 40 | - 'Add New Ticket', |
|
| 41 | - 'event_espresso' |
|
| 42 | - ); ?></h4><?php echo $add_new_datetime_ticket_help_link; ?><br> |
|
| 39 | + esc_html_e( |
|
| 40 | + 'Add New Ticket', |
|
| 41 | + 'event_espresso' |
|
| 42 | + ); ?></h4><?php echo $add_new_datetime_ticket_help_link; ?><br> |
|
| 43 | 43 | <table class="add-new-ticket-table"> |
| 44 | 44 | <thead> |
| 45 | 45 | <tr valign="top"> |
| 46 | 46 | <td><span class="ANT_TKT_name_label"><?php |
| 47 | - esc_html_e( |
|
| 48 | - 'Ticket Name', |
|
| 49 | - 'event_espresso' |
|
| 50 | - ); ?></span></td> |
|
| 47 | + esc_html_e( |
|
| 48 | + 'Ticket Name', |
|
| 49 | + 'event_espresso' |
|
| 50 | + ); ?></span></td> |
|
| 51 | 51 | <td><span class="ANT_TKT_goes_on_sale_label"><?php |
| 52 | - esc_html_e( |
|
| 53 | - 'Sale Starts', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?></span></td> |
|
| 52 | + esc_html_e( |
|
| 53 | + 'Sale Starts', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?></span></td> |
|
| 56 | 56 | <td><span class="ANT_TKT_sell_until_label"><?php |
| 57 | - esc_html_e( |
|
| 58 | - 'Sell Until', |
|
| 59 | - 'event_espresso' |
|
| 60 | - ); ?></span></td> |
|
| 57 | + esc_html_e( |
|
| 58 | + 'Sell Until', |
|
| 59 | + 'event_espresso' |
|
| 60 | + ); ?></span></td> |
|
| 61 | 61 | <td><span class="ANT_TKT_price_label"><?php esc_html_e('Price', 'event_espresso'); ?></span> |
| 62 | 62 | </td> |
| 63 | 63 | <td><span class="ANT_TKT_qty_label"><?php esc_html_e('Qty', 'event_espresso'); ?></span></td> |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | <div class="ee-editor-footer-container"> |
| 108 | 108 | <div class="ee-editor-id-container"> |
| 109 | 109 | <span class="ee-item-id"><?php |
| 110 | - echo $DTT_ID |
|
| 111 | - ? sprintf( |
|
| 112 | - esc_html__('Datetime ID: %d', 'event_espresso'), |
|
| 113 | - $DTT_ID |
|
| 114 | - ) |
|
| 115 | - : ''; ?></span> |
|
| 110 | + echo $DTT_ID |
|
| 111 | + ? sprintf( |
|
| 112 | + esc_html__('Datetime ID: %d', 'event_espresso'), |
|
| 113 | + $DTT_ID |
|
| 114 | + ) |
|
| 115 | + : ''; ?></span> |
|
| 116 | 116 | </div> |
| 117 | 117 | <div class="save-cancel-button-container"> |
| 118 | 118 | <button data-context="short-ticket" data-datetime-row="<?php echo esc_attr($dtt_row); ?>" |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | wp_enqueue_style('espresso-ui-theme'); |
| 342 | 342 | wp_register_style( |
| 343 | 343 | 'espresso_PRICING', |
| 344 | - PRICING_ASSETS_URL . 'espresso_pricing_admin.css', |
|
| 344 | + PRICING_ASSETS_URL.'espresso_pricing_admin.css', |
|
| 345 | 345 | [], |
| 346 | 346 | EVENT_ESPRESSO_VERSION |
| 347 | 347 | ); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | wp_enqueue_script('jquery-ui-widget'); |
| 354 | 354 | wp_register_script( |
| 355 | 355 | 'espresso_PRICING', |
| 356 | - PRICING_ASSETS_URL . 'espresso_pricing_admin.js', |
|
| 356 | + PRICING_ASSETS_URL.'espresso_pricing_admin.js', |
|
| 357 | 357 | ['jquery'], |
| 358 | 358 | EVENT_ESPRESSO_VERSION, |
| 359 | 359 | true |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | protected function _price_overview_list_table() |
| 452 | 452 | { |
| 453 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 453 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 454 | 454 | 'add_new_price', |
| 455 | 455 | 'add', |
| 456 | 456 | [], |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | // start with an empty array |
| 478 | 478 | $event_pricing = []; |
| 479 | 479 | |
| 480 | - require_once(PRICING_ADMIN . 'Prices_List_Table.class.php'); |
|
| 480 | + require_once(PRICING_ADMIN.'Prices_List_Table.class.php'); |
|
| 481 | 481 | |
| 482 | 482 | $orderby = $this->request->getRequestParam('orderby', ''); |
| 483 | 483 | $order = $this->request->getRequestParam('order', 'ASC'); |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
| 556 | 556 | } |
| 557 | 557 | // add PRC_ID to title if editing |
| 558 | - $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title; |
|
| 558 | + $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title.' # '.$PRC_ID : $this->_admin_page_title; |
|
| 559 | 559 | |
| 560 | 560 | if ($PRC_ID) { |
| 561 | 561 | $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | $this->_set_add_edit_form_tags('insert_price'); |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if (! $price instanceof EE_Price) { |
|
| 571 | + if ( ! $price instanceof EE_Price) { |
|
| 572 | 572 | throw new RuntimeException( |
| 573 | 573 | sprintf( |
| 574 | 574 | esc_html__( |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | public function _edit_price_details_meta_box(): string |
| 627 | 627 | { |
| 628 | 628 | return EEH_Template::display_template( |
| 629 | - PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php', |
|
| 629 | + PRICING_TEMPLATE_PATH.'pricing_details_main_meta_box.template.php', |
|
| 630 | 630 | $this->_template_args, |
| 631 | 631 | true |
| 632 | 632 | ); |
@@ -789,19 +789,19 @@ discard block |
||
| 789 | 789 | */ |
| 790 | 790 | public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result) |
| 791 | 791 | { |
| 792 | - if (! $entity_ID || (float) $result < 1) { |
|
| 792 | + if ( ! $entity_ID || (float) $result < 1) { |
|
| 793 | 793 | return; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | $entity = $entity_model->get_one_by_ID($entity_ID); |
| 797 | - if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) { |
|
| 797 | + if ( ! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) { |
|
| 798 | 798 | return; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | // get default tickets for updating |
| 802 | 802 | $default_tickets = EEM_Ticket::instance()->get_all_default_tickets(); |
| 803 | 803 | foreach ($default_tickets as $default_ticket) { |
| 804 | - if (! $default_ticket instanceof EE_Ticket) { |
|
| 804 | + if ( ! $default_ticket instanceof EE_Ticket) { |
|
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | 807 | switch ($action) { |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | */ |
| 877 | 877 | protected function _price_types_overview_list_table() |
| 878 | 878 | { |
| 879 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 879 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 880 | 880 | 'add_new_price_type', |
| 881 | 881 | 'add_type', |
| 882 | 882 | [], |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
| 902 | 902 | { |
| 903 | 903 | // start with an empty array |
| 904 | - require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php'); |
|
| 904 | + require_once(PRICING_ADMIN.'Price_Types_List_Table.class.php'); |
|
| 905 | 905 | |
| 906 | 906 | $orderby = $this->request->getRequestParam('orderby', ''); |
| 907 | 907 | $order = $this->request->getRequestParam('order', 'ASC'); |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
| 963 | 963 | } |
| 964 | 964 | // add PRT_ID to title if editing |
| 965 | - $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title; |
|
| 965 | + $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title.' # '.$PRT_ID : $this->_admin_page_title; |
|
| 966 | 966 | |
| 967 | 967 | if ($PRT_ID) { |
| 968 | 968 | $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | $this->_set_add_edit_form_tags('insert_price_type'); |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | - if (! $price_type instanceof EE_Price_Type) { |
|
| 976 | + if ( ! $price_type instanceof EE_Price_Type) { |
|
| 977 | 977 | throw new RuntimeException( |
| 978 | 978 | sprintf( |
| 979 | 979 | esc_html__( |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | public function _edit_price_type_details_meta_box(): string |
| 1024 | 1024 | { |
| 1025 | 1025 | return EEH_Template::display_template( |
| 1026 | - PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php', |
|
| 1026 | + PRICING_TEMPLATE_PATH.'pricing_type_details_main_meta_box.template.php', |
|
| 1027 | 1027 | $this->_template_args, |
| 1028 | 1028 | true |
| 1029 | 1029 | ); |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | */ |
| 1036 | 1036 | protected function set_price_type_column_values(): array |
| 1037 | 1037 | { |
| 1038 | - $base_type = $this->request->getRequestParam( |
|
| 1038 | + $base_type = $this->request->getRequestParam( |
|
| 1039 | 1039 | 'base_type', |
| 1040 | 1040 | EEM_Price_Type::base_type_base_price, |
| 1041 | 1041 | DataType::INTEGER |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | { |
| 1162 | 1162 | return ' |
| 1163 | 1163 | <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" > |
| 1164 | - ' . esc_html__('learn more about how pricing works', 'event_espresso') . ' |
|
| 1164 | + ' . esc_html__('learn more about how pricing works', 'event_espresso').' |
|
| 1165 | 1165 | </a>'; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | public function _update_tax_settings() |
| 1238 | 1238 | { |
| 1239 | 1239 | $tax_settings = EE_Config::instance()->tax_settings; |
| 1240 | - if (! $tax_settings instanceof EE_Tax_Config) { |
|
| 1240 | + if ( ! $tax_settings instanceof EE_Tax_Config) { |
|
| 1241 | 1241 | $tax_settings = new EE_Tax_Config(); |
| 1242 | 1242 | } |
| 1243 | 1243 | try { |
@@ -12,1270 +12,1270 @@ |
||
| 12 | 12 | class Pricing_Admin_Page extends EE_Admin_Page |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - protected function _init_page_props() |
|
| 16 | - { |
|
| 17 | - $this->page_slug = PRICING_PG_SLUG; |
|
| 18 | - $this->page_label = PRICING_LABEL; |
|
| 19 | - $this->_admin_base_url = PRICING_ADMIN_URL; |
|
| 20 | - $this->_admin_base_path = PRICING_ADMIN; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - protected function _ajax_hooks() |
|
| 25 | - { |
|
| 26 | - add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - protected function _define_page_props() |
|
| 31 | - { |
|
| 32 | - $this->_admin_page_title = PRICING_LABEL; |
|
| 33 | - $this->_labels = [ |
|
| 34 | - 'buttons' => [ |
|
| 35 | - 'add' => esc_html__('Add New Default Price', 'event_espresso'), |
|
| 36 | - 'edit' => esc_html__('Edit Default Price', 'event_espresso'), |
|
| 37 | - 'delete' => esc_html__('Delete Default Price', 'event_espresso'), |
|
| 38 | - 'add_type' => esc_html__('Add New Default Price Type', 'event_espresso'), |
|
| 39 | - 'edit_type' => esc_html__('Edit Price Type', 'event_espresso'), |
|
| 40 | - 'delete_type' => esc_html__('Delete Price Type', 'event_espresso'), |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * an array for storing request actions and their corresponding methods |
|
| 48 | - * |
|
| 49 | - * @return void |
|
| 50 | - */ |
|
| 51 | - protected function _set_page_routes() |
|
| 52 | - { |
|
| 53 | - $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
| 54 | - $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
| 55 | - $this->_page_routes = [ |
|
| 56 | - 'default' => [ |
|
| 57 | - 'func' => '_price_overview_list_table', |
|
| 58 | - 'capability' => 'ee_read_default_prices', |
|
| 59 | - ], |
|
| 60 | - 'add_new_price' => [ |
|
| 61 | - 'func' => '_edit_price_details', |
|
| 62 | - 'args' => ['new_price' => true], |
|
| 63 | - 'capability' => 'ee_edit_default_prices', |
|
| 64 | - ], |
|
| 65 | - 'edit_price' => [ |
|
| 66 | - 'func' => '_edit_price_details', |
|
| 67 | - 'args' => ['new_price' => false], |
|
| 68 | - 'capability' => 'ee_edit_default_price', |
|
| 69 | - 'obj_id' => $PRC_ID, |
|
| 70 | - ], |
|
| 71 | - 'insert_price' => [ |
|
| 72 | - 'func' => '_insert_or_update_price', |
|
| 73 | - 'args' => ['new_price' => true], |
|
| 74 | - 'noheader' => true, |
|
| 75 | - 'capability' => 'ee_edit_default_prices', |
|
| 76 | - ], |
|
| 77 | - 'update_price' => [ |
|
| 78 | - 'func' => '_insert_or_update_price', |
|
| 79 | - 'args' => ['new_price' => false], |
|
| 80 | - 'noheader' => true, |
|
| 81 | - 'capability' => 'ee_edit_default_price', |
|
| 82 | - 'obj_id' => $PRC_ID, |
|
| 83 | - ], |
|
| 84 | - 'trash_price' => [ |
|
| 85 | - 'func' => '_trash_or_restore_price', |
|
| 86 | - 'args' => ['trash' => true], |
|
| 87 | - 'noheader' => true, |
|
| 88 | - 'capability' => 'ee_delete_default_price', |
|
| 89 | - 'obj_id' => $PRC_ID, |
|
| 90 | - ], |
|
| 91 | - 'restore_price' => [ |
|
| 92 | - 'func' => '_trash_or_restore_price', |
|
| 93 | - 'args' => ['trash' => false], |
|
| 94 | - 'noheader' => true, |
|
| 95 | - 'capability' => 'ee_delete_default_price', |
|
| 96 | - 'obj_id' => $PRC_ID, |
|
| 97 | - ], |
|
| 98 | - 'delete_price' => [ |
|
| 99 | - 'func' => '_delete_price', |
|
| 100 | - 'noheader' => true, |
|
| 101 | - 'capability' => 'ee_delete_default_price', |
|
| 102 | - 'obj_id' => $PRC_ID, |
|
| 103 | - ], |
|
| 104 | - 'espresso_update_price_order' => [ |
|
| 105 | - 'func' => 'update_price_order', |
|
| 106 | - 'noheader' => true, |
|
| 107 | - 'capability' => 'ee_edit_default_prices', |
|
| 108 | - ], |
|
| 109 | - // price types |
|
| 110 | - 'price_types' => [ |
|
| 111 | - 'func' => '_price_types_overview_list_table', |
|
| 112 | - 'capability' => 'ee_read_default_price_types', |
|
| 113 | - ], |
|
| 114 | - 'add_new_price_type' => [ |
|
| 115 | - 'func' => '_edit_price_type_details', |
|
| 116 | - 'capability' => 'ee_edit_default_price_types', |
|
| 117 | - ], |
|
| 118 | - 'edit_price_type' => [ |
|
| 119 | - 'func' => '_edit_price_type_details', |
|
| 120 | - 'capability' => 'ee_edit_default_price_type', |
|
| 121 | - 'obj_id' => $PRT_ID, |
|
| 122 | - ], |
|
| 123 | - 'insert_price_type' => [ |
|
| 124 | - 'func' => '_insert_or_update_price_type', |
|
| 125 | - 'args' => ['new_price_type' => true], |
|
| 126 | - 'noheader' => true, |
|
| 127 | - 'capability' => 'ee_edit_default_price_types', |
|
| 128 | - ], |
|
| 129 | - 'update_price_type' => [ |
|
| 130 | - 'func' => '_insert_or_update_price_type', |
|
| 131 | - 'args' => ['new_price_type' => false], |
|
| 132 | - 'noheader' => true, |
|
| 133 | - 'capability' => 'ee_edit_default_price_type', |
|
| 134 | - 'obj_id' => $PRT_ID, |
|
| 135 | - ], |
|
| 136 | - 'trash_price_type' => [ |
|
| 137 | - 'func' => '_trash_or_restore_price_type', |
|
| 138 | - 'args' => ['trash' => true], |
|
| 139 | - 'noheader' => true, |
|
| 140 | - 'capability' => 'ee_delete_default_price_type', |
|
| 141 | - 'obj_id' => $PRT_ID, |
|
| 142 | - ], |
|
| 143 | - 'restore_price_type' => [ |
|
| 144 | - 'func' => '_trash_or_restore_price_type', |
|
| 145 | - 'args' => ['trash' => false], |
|
| 146 | - 'noheader' => true, |
|
| 147 | - 'capability' => 'ee_delete_default_price_type', |
|
| 148 | - 'obj_id' => $PRT_ID, |
|
| 149 | - ], |
|
| 150 | - 'delete_price_type' => [ |
|
| 151 | - 'func' => '_delete_price_type', |
|
| 152 | - 'noheader' => true, |
|
| 153 | - 'capability' => 'ee_delete_default_price_type', |
|
| 154 | - 'obj_id' => $PRT_ID, |
|
| 155 | - ], |
|
| 156 | - 'tax_settings' => [ |
|
| 157 | - 'func' => '_tax_settings', |
|
| 158 | - 'capability' => 'manage_options', |
|
| 159 | - ], |
|
| 160 | - 'update_tax_settings' => [ |
|
| 161 | - 'func' => '_update_tax_settings', |
|
| 162 | - 'capability' => 'manage_options', |
|
| 163 | - 'noheader' => true, |
|
| 164 | - ], |
|
| 165 | - ]; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - protected function _set_page_config() |
|
| 170 | - { |
|
| 171 | - $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
| 172 | - $this->_page_config = [ |
|
| 173 | - 'default' => [ |
|
| 174 | - 'nav' => [ |
|
| 175 | - 'label' => esc_html__('Default Pricing', 'event_espresso'), |
|
| 176 | - 'order' => 10, |
|
| 177 | - ], |
|
| 178 | - 'list_table' => 'Prices_List_Table', |
|
| 179 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 180 | - 'help_tabs' => [ |
|
| 181 | - 'pricing_default_pricing_help_tab' => [ |
|
| 182 | - 'title' => esc_html__('Default Pricing', 'event_espresso'), |
|
| 183 | - 'filename' => 'pricing_default_pricing', |
|
| 184 | - ], |
|
| 185 | - 'pricing_default_pricing_table_column_headings_help_tab' => [ |
|
| 186 | - 'title' => esc_html__('Default Pricing Table Column Headings', 'event_espresso'), |
|
| 187 | - 'filename' => 'pricing_default_pricing_table_column_headings', |
|
| 188 | - ], |
|
| 189 | - 'pricing_default_pricing_views_bulk_actions_search_help_tab' => [ |
|
| 190 | - 'title' => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'), |
|
| 191 | - 'filename' => 'pricing_default_pricing_views_bulk_actions_search', |
|
| 192 | - ], |
|
| 193 | - ], |
|
| 194 | - 'require_nonce' => false, |
|
| 195 | - ], |
|
| 196 | - 'add_new_price' => [ |
|
| 197 | - 'nav' => [ |
|
| 198 | - 'label' => esc_html__('Add New Default Price', 'event_espresso'), |
|
| 199 | - 'order' => 20, |
|
| 200 | - 'persistent' => false, |
|
| 201 | - ], |
|
| 202 | - 'help_tabs' => [ |
|
| 203 | - 'add_new_default_price_help_tab' => [ |
|
| 204 | - 'title' => esc_html__('Add New Default Price', 'event_espresso'), |
|
| 205 | - 'filename' => 'pricing_add_new_default_price', |
|
| 206 | - ], |
|
| 207 | - ], |
|
| 208 | - 'metaboxes' => array_merge( |
|
| 209 | - ['_publish_post_box'], |
|
| 210 | - $this->_default_espresso_metaboxes |
|
| 211 | - ), |
|
| 212 | - 'require_nonce' => false, |
|
| 213 | - ], |
|
| 214 | - 'edit_price' => [ |
|
| 215 | - 'nav' => [ |
|
| 216 | - 'label' => esc_html__('Edit Default Price', 'event_espresso'), |
|
| 217 | - 'order' => 20, |
|
| 218 | - 'url' => $PRC_ID |
|
| 219 | - ? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url) |
|
| 220 | - : $this->_admin_base_url, |
|
| 221 | - 'persistent' => false, |
|
| 222 | - ], |
|
| 223 | - 'metaboxes' => array_merge( |
|
| 224 | - ['_publish_post_box'], |
|
| 225 | - $this->_default_espresso_metaboxes |
|
| 226 | - ), |
|
| 227 | - 'help_tabs' => [ |
|
| 228 | - 'edit_default_price_help_tab' => [ |
|
| 229 | - 'title' => esc_html__('Edit Default Price', 'event_espresso'), |
|
| 230 | - 'filename' => 'pricing_edit_default_price', |
|
| 231 | - ], |
|
| 232 | - ], |
|
| 233 | - 'require_nonce' => false, |
|
| 234 | - ], |
|
| 235 | - 'price_types' => [ |
|
| 236 | - 'nav' => [ |
|
| 237 | - 'label' => esc_html__('Price Types', 'event_espresso'), |
|
| 238 | - 'order' => 30, |
|
| 239 | - ], |
|
| 240 | - 'list_table' => 'Price_Types_List_Table', |
|
| 241 | - 'help_tabs' => [ |
|
| 242 | - 'pricing_price_types_help_tab' => [ |
|
| 243 | - 'title' => esc_html__('Price Types', 'event_espresso'), |
|
| 244 | - 'filename' => 'pricing_price_types', |
|
| 245 | - ], |
|
| 246 | - 'pricing_price_types_table_column_headings_help_tab' => [ |
|
| 247 | - 'title' => esc_html__('Price Types Table Column Headings', 'event_espresso'), |
|
| 248 | - 'filename' => 'pricing_price_types_table_column_headings', |
|
| 249 | - ], |
|
| 250 | - 'pricing_price_types_views_bulk_actions_search_help_tab' => [ |
|
| 251 | - 'title' => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'), |
|
| 252 | - 'filename' => 'pricing_price_types_views_bulk_actions_search', |
|
| 253 | - ], |
|
| 254 | - ], |
|
| 255 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 256 | - 'require_nonce' => false, |
|
| 257 | - ], |
|
| 258 | - 'add_new_price_type' => [ |
|
| 259 | - 'nav' => [ |
|
| 260 | - 'label' => esc_html__('Add New Price Type', 'event_espresso'), |
|
| 261 | - 'order' => 40, |
|
| 262 | - 'persistent' => false, |
|
| 263 | - ], |
|
| 264 | - 'help_tabs' => [ |
|
| 265 | - 'add_new_price_type_help_tab' => [ |
|
| 266 | - 'title' => esc_html__('Add New Price Type', 'event_espresso'), |
|
| 267 | - 'filename' => 'pricing_add_new_price_type', |
|
| 268 | - ], |
|
| 269 | - ], |
|
| 270 | - 'metaboxes' => array_merge( |
|
| 271 | - ['_publish_post_box'], |
|
| 272 | - $this->_default_espresso_metaboxes |
|
| 273 | - ), |
|
| 274 | - 'require_nonce' => false, |
|
| 275 | - ], |
|
| 276 | - 'edit_price_type' => [ |
|
| 277 | - 'nav' => [ |
|
| 278 | - 'label' => esc_html__('Edit Price Type', 'event_espresso'), |
|
| 279 | - 'order' => 40, |
|
| 280 | - 'persistent' => false, |
|
| 281 | - ], |
|
| 282 | - 'help_tabs' => [ |
|
| 283 | - 'edit_price_type_help_tab' => [ |
|
| 284 | - 'title' => esc_html__('Edit Price Type', 'event_espresso'), |
|
| 285 | - 'filename' => 'pricing_edit_price_type', |
|
| 286 | - ], |
|
| 287 | - ], |
|
| 288 | - 'metaboxes' => array_merge( |
|
| 289 | - ['_publish_post_box'], |
|
| 290 | - $this->_default_espresso_metaboxes |
|
| 291 | - ), |
|
| 292 | - 'require_nonce' => false, |
|
| 293 | - ], |
|
| 294 | - 'tax_settings' => [ |
|
| 295 | - 'nav' => [ |
|
| 296 | - 'label' => esc_html__('Tax Settings', 'event_espresso'), |
|
| 297 | - 'order' => 40, |
|
| 298 | - ], |
|
| 299 | - 'labels' => [ |
|
| 300 | - 'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'), |
|
| 301 | - ], |
|
| 302 | - 'metaboxes' => array_merge( |
|
| 303 | - ['_publish_post_box'], |
|
| 304 | - $this->_default_espresso_metaboxes |
|
| 305 | - ), |
|
| 306 | - 'require_nonce' => true, |
|
| 307 | - ], |
|
| 308 | - ]; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - |
|
| 312 | - protected function _add_screen_options() |
|
| 313 | - { |
|
| 314 | - // todo |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - |
|
| 318 | - protected function _add_screen_options_default() |
|
| 319 | - { |
|
| 320 | - $this->_per_page_screen_option(); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - |
|
| 324 | - protected function _add_screen_options_price_types() |
|
| 325 | - { |
|
| 326 | - $page_title = $this->_admin_page_title; |
|
| 327 | - $this->_admin_page_title = esc_html__('Price Types', 'event_espresso'); |
|
| 328 | - $this->_per_page_screen_option(); |
|
| 329 | - $this->_admin_page_title = $page_title; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - |
|
| 333 | - protected function _add_feature_pointers() |
|
| 334 | - { |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - |
|
| 338 | - public function load_scripts_styles() |
|
| 339 | - { |
|
| 340 | - // styles |
|
| 341 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 342 | - wp_register_style( |
|
| 343 | - 'espresso_PRICING', |
|
| 344 | - PRICING_ASSETS_URL . 'espresso_pricing_admin.css', |
|
| 345 | - [], |
|
| 346 | - EVENT_ESPRESSO_VERSION |
|
| 347 | - ); |
|
| 348 | - wp_enqueue_style('espresso_PRICING'); |
|
| 349 | - |
|
| 350 | - // scripts |
|
| 351 | - wp_enqueue_script('ee_admin_js'); |
|
| 352 | - wp_enqueue_script('jquery-ui-position'); |
|
| 353 | - wp_enqueue_script('jquery-ui-widget'); |
|
| 354 | - wp_register_script( |
|
| 355 | - 'espresso_PRICING', |
|
| 356 | - PRICING_ASSETS_URL . 'espresso_pricing_admin.js', |
|
| 357 | - ['jquery'], |
|
| 358 | - EVENT_ESPRESSO_VERSION, |
|
| 359 | - true |
|
| 360 | - ); |
|
| 361 | - wp_enqueue_script('espresso_PRICING'); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - |
|
| 365 | - public function load_scripts_styles_default() |
|
| 366 | - { |
|
| 367 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - |
|
| 371 | - public function admin_footer_scripts() |
|
| 372 | - { |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - public function admin_init() |
|
| 377 | - { |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - public function admin_notices() |
|
| 382 | - { |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - protected function _set_list_table_views_default() |
|
| 387 | - { |
|
| 388 | - $this->_views = [ |
|
| 389 | - 'all' => [ |
|
| 390 | - 'slug' => 'all', |
|
| 391 | - 'label' => esc_html__('View All Default Pricing', 'event_espresso'), |
|
| 392 | - 'count' => 0, |
|
| 393 | - 'bulk_action' => [ |
|
| 394 | - 'trash_price' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 395 | - ], |
|
| 396 | - ], |
|
| 397 | - ]; |
|
| 398 | - |
|
| 399 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
| 400 | - $this->_views['trashed'] = [ |
|
| 401 | - 'slug' => 'trashed', |
|
| 402 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 403 | - 'count' => 0, |
|
| 404 | - 'bulk_action' => [ |
|
| 405 | - 'restore_price' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 406 | - 'delete_price' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 407 | - ], |
|
| 408 | - ]; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - protected function _set_list_table_views_price_types() |
|
| 414 | - { |
|
| 415 | - $this->_views = [ |
|
| 416 | - 'all' => [ |
|
| 417 | - 'slug' => 'all', |
|
| 418 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 419 | - 'count' => 0, |
|
| 420 | - 'bulk_action' => [ |
|
| 421 | - 'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 422 | - ], |
|
| 423 | - ], |
|
| 424 | - ]; |
|
| 425 | - |
|
| 426 | - if ( |
|
| 427 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 428 | - 'ee_delete_default_price_types', |
|
| 429 | - 'pricing_trash_price_type' |
|
| 430 | - ) |
|
| 431 | - ) { |
|
| 432 | - $this->_views['trashed'] = [ |
|
| 433 | - 'slug' => 'trashed', |
|
| 434 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 435 | - 'count' => 0, |
|
| 436 | - 'bulk_action' => [ |
|
| 437 | - 'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 438 | - 'delete_price_type' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 439 | - ], |
|
| 440 | - ]; |
|
| 441 | - } |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * generates HTML for main Prices Admin page |
|
| 447 | - * |
|
| 448 | - * @return void |
|
| 449 | - * @throws EE_Error |
|
| 450 | - */ |
|
| 451 | - protected function _price_overview_list_table() |
|
| 452 | - { |
|
| 453 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 454 | - 'add_new_price', |
|
| 455 | - 'add', |
|
| 456 | - [], |
|
| 457 | - 'add-new-h2' |
|
| 458 | - ); |
|
| 459 | - $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
| 460 | - $this->_search_btn_label = esc_html__('Default Prices', 'event_espresso'); |
|
| 461 | - $this->display_admin_list_table_page_with_sidebar(); |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * retrieve data for Prices List table |
|
| 467 | - * |
|
| 468 | - * @param int $per_page how many prices displayed per page |
|
| 469 | - * @param bool $count return the count or objects |
|
| 470 | - * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
| 471 | - * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
| 472 | - * @throws EE_Error |
|
| 473 | - * @throws ReflectionException |
|
| 474 | - */ |
|
| 475 | - public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
| 476 | - { |
|
| 477 | - // start with an empty array |
|
| 478 | - $event_pricing = []; |
|
| 479 | - |
|
| 480 | - require_once(PRICING_ADMIN . 'Prices_List_Table.class.php'); |
|
| 481 | - |
|
| 482 | - $orderby = $this->request->getRequestParam('orderby', ''); |
|
| 483 | - $order = $this->request->getRequestParam('order', 'ASC'); |
|
| 484 | - |
|
| 485 | - switch ($orderby) { |
|
| 486 | - case 'name': |
|
| 487 | - $orderby = ['PRC_name' => $order]; |
|
| 488 | - break; |
|
| 489 | - case 'type': |
|
| 490 | - $orderby = ['Price_Type.PRT_name' => $order]; |
|
| 491 | - break; |
|
| 492 | - case 'amount': |
|
| 493 | - $orderby = ['PRC_amount' => $order]; |
|
| 494 | - break; |
|
| 495 | - default: |
|
| 496 | - $orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order]; |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
| 500 | - $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
| 501 | - |
|
| 502 | - $where = [ |
|
| 503 | - 'PRC_is_default' => 1, |
|
| 504 | - 'PRC_deleted' => $trashed, |
|
| 505 | - ]; |
|
| 506 | - |
|
| 507 | - $offset = ($current_page - 1) * $per_page; |
|
| 508 | - $limit = [$offset, $per_page]; |
|
| 509 | - |
|
| 510 | - $search_term = $this->request->getRequestParam('s'); |
|
| 511 | - if ($search_term) { |
|
| 512 | - $search_term = "%{$search_term}%"; |
|
| 513 | - $where['OR'] = [ |
|
| 514 | - 'PRC_name' => ['LIKE', $search_term], |
|
| 515 | - 'PRC_desc' => ['LIKE', $search_term], |
|
| 516 | - 'PRC_amount' => ['LIKE', $search_term], |
|
| 517 | - 'Price_Type.PRT_name' => ['LIKE', $search_term], |
|
| 518 | - ]; |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - $query_params = [ |
|
| 522 | - $where, |
|
| 523 | - 'order_by' => $orderby, |
|
| 524 | - 'limit' => $limit, |
|
| 525 | - 'group_by' => 'PRC_ID', |
|
| 526 | - ]; |
|
| 527 | - |
|
| 528 | - if ($count) { |
|
| 529 | - return $trashed |
|
| 530 | - ? EEM_Price::instance()->count([$where]) |
|
| 531 | - : EEM_Price::instance()->count_deleted_and_undeleted([$where]); |
|
| 532 | - } |
|
| 533 | - return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * @return void |
|
| 539 | - * @throws EE_Error |
|
| 540 | - * @throws ReflectionException |
|
| 541 | - */ |
|
| 542 | - protected function _edit_price_details() |
|
| 543 | - { |
|
| 544 | - // grab price ID |
|
| 545 | - $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
| 546 | - // change page title based on request action |
|
| 547 | - switch ($this->_req_action) { |
|
| 548 | - case 'add_new_price': |
|
| 549 | - $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso'); |
|
| 550 | - break; |
|
| 551 | - case 'edit_price': |
|
| 552 | - $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso'); |
|
| 553 | - break; |
|
| 554 | - default: |
|
| 555 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
| 556 | - } |
|
| 557 | - // add PRC_ID to title if editing |
|
| 558 | - $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title; |
|
| 559 | - |
|
| 560 | - if ($PRC_ID) { |
|
| 561 | - $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
| 562 | - $additional_hidden_fields = [ |
|
| 563 | - 'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID], |
|
| 564 | - ]; |
|
| 565 | - $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields); |
|
| 566 | - } else { |
|
| 567 | - $price = EEM_Price::instance()->get_new_price(); |
|
| 568 | - $this->_set_add_edit_form_tags('insert_price'); |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - if (! $price instanceof EE_Price) { |
|
| 572 | - throw new RuntimeException( |
|
| 573 | - sprintf( |
|
| 574 | - esc_html__( |
|
| 575 | - 'A valid Price could not be retrieved from the database with ID: %1$s', |
|
| 576 | - 'event_espresso' |
|
| 577 | - ), |
|
| 578 | - $PRC_ID |
|
| 579 | - ) |
|
| 580 | - ); |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - $this->_template_args['PRC_ID'] = $PRC_ID; |
|
| 584 | - $this->_template_args['price'] = $price; |
|
| 585 | - |
|
| 586 | - $default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1; |
|
| 587 | - |
|
| 588 | - $this->_template_args['default_base_price'] = $default_base_price; |
|
| 589 | - |
|
| 590 | - // get price types |
|
| 591 | - $price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]); |
|
| 592 | - if (empty($price_types)) { |
|
| 593 | - $msg = esc_html__( |
|
| 594 | - 'You have no price types defined. Please add a price type before adding a price.', |
|
| 595 | - 'event_espresso' |
|
| 596 | - ); |
|
| 597 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 598 | - $this->display_admin_page_with_sidebar(); |
|
| 599 | - } |
|
| 600 | - $attributes = []; |
|
| 601 | - $price_type_names = []; |
|
| 602 | - $attributes[] = 'id="PRT_ID"'; |
|
| 603 | - if ($default_base_price) { |
|
| 604 | - $attributes[] = 'disabled="disabled"'; |
|
| 605 | - $price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')]; |
|
| 606 | - } |
|
| 607 | - foreach ($price_types as $type) { |
|
| 608 | - $price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()]; |
|
| 609 | - } |
|
| 610 | - $this->_template_args['attributes'] = implode(' ', $attributes); |
|
| 611 | - $this->_template_args['price_types'] = $price_type_names; |
|
| 612 | - |
|
| 613 | - $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
| 614 | - $this->_template_args['admin_page_content'] = $this->_edit_price_details_meta_box(); |
|
| 615 | - |
|
| 616 | - $this->_set_publish_post_box_vars('id', $PRC_ID); |
|
| 617 | - // the details template wrapper |
|
| 618 | - $this->display_admin_page_with_sidebar(); |
|
| 619 | - } |
|
| 620 | - |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * |
|
| 624 | - * @return string |
|
| 625 | - */ |
|
| 626 | - public function _edit_price_details_meta_box(): string |
|
| 627 | - { |
|
| 628 | - return EEH_Template::display_template( |
|
| 629 | - PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php', |
|
| 630 | - $this->_template_args, |
|
| 631 | - true |
|
| 632 | - ); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - |
|
| 636 | - /** |
|
| 637 | - * @return array |
|
| 638 | - * @throws EE_Error |
|
| 639 | - * @throws ReflectionException |
|
| 640 | - */ |
|
| 641 | - protected function set_price_column_values(): array |
|
| 642 | - { |
|
| 643 | - $PRC_order = 0; |
|
| 644 | - $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
| 645 | - if ($PRT_ID) { |
|
| 646 | - /** @var EE_Price_Type $price_type */ |
|
| 647 | - $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
| 648 | - if ($price_type instanceof EE_Price_Type) { |
|
| 649 | - $PRC_order = $price_type->order(); |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - return [ |
|
| 653 | - 'PRT_ID' => $PRT_ID, |
|
| 654 | - 'PRC_amount' => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT), |
|
| 655 | - 'PRC_name' => $this->request->getRequestParam('PRC_name'), |
|
| 656 | - 'PRC_desc' => $this->request->getRequestParam('PRC_desc'), |
|
| 657 | - 'PRC_is_default' => 1, |
|
| 658 | - 'PRC_overrides' => null, |
|
| 659 | - 'PRC_order' => $PRC_order, |
|
| 660 | - 'PRC_deleted' => 0, |
|
| 661 | - 'PRC_parent' => 0, |
|
| 662 | - ]; |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - |
|
| 666 | - /** |
|
| 667 | - * @param bool $insert - whether to insert or update |
|
| 668 | - * @return void |
|
| 669 | - * @throws EE_Error |
|
| 670 | - * @throws ReflectionException |
|
| 671 | - */ |
|
| 672 | - protected function _insert_or_update_price(bool $insert = false) |
|
| 673 | - { |
|
| 674 | - // why be so pessimistic ??? : ( |
|
| 675 | - $updated = 0; |
|
| 676 | - |
|
| 677 | - $set_column_values = $this->set_price_column_values(); |
|
| 678 | - // is this a new Price ? |
|
| 679 | - if ($insert) { |
|
| 680 | - // run the insert |
|
| 681 | - $PRC_ID = EEM_Price::instance()->insert($set_column_values); |
|
| 682 | - if ($PRC_ID) { |
|
| 683 | - // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type |
|
| 684 | - $price = EEM_price::instance()->get_one_by_ID($PRC_ID); |
|
| 685 | - if ( |
|
| 686 | - $price instanceof EE_Price |
|
| 687 | - && $price->type_obj() instanceof EE_Price_type |
|
| 688 | - && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax |
|
| 689 | - ) { |
|
| 690 | - $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
| 691 | - $ticket->_add_relation_to($price, 'Price'); |
|
| 692 | - $ticket->save(); |
|
| 693 | - } |
|
| 694 | - $updated = 1; |
|
| 695 | - } |
|
| 696 | - $action_desc = 'created'; |
|
| 697 | - } else { |
|
| 698 | - $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
| 699 | - // run the update |
|
| 700 | - $where_cols_n_values = ['PRC_ID' => $PRC_ID]; |
|
| 701 | - $updated = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]); |
|
| 702 | - |
|
| 703 | - $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
| 704 | - if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
| 705 | - // if this is $PRC_ID == 1, |
|
| 706 | - // then we need to update the default ticket attached to this price so the TKT_price value is updated. |
|
| 707 | - if ($PRC_ID === 1) { |
|
| 708 | - $ticket = $price->get_first_related('Ticket'); |
|
| 709 | - if ($ticket) { |
|
| 710 | - $ticket->set('TKT_price', $price->get('PRC_amount')); |
|
| 711 | - $ticket->set('TKT_name', $price->get('PRC_name')); |
|
| 712 | - $ticket->set('TKT_description', $price->get('PRC_desc')); |
|
| 713 | - $ticket->save(); |
|
| 714 | - } |
|
| 715 | - } else { |
|
| 716 | - // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type. |
|
| 717 | - $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
| 718 | - $ticket->_add_relation_to($PRC_ID, 'Price'); |
|
| 719 | - $ticket->save(); |
|
| 720 | - } |
|
| 721 | - } |
|
| 722 | - |
|
| 723 | - $action_desc = 'updated'; |
|
| 724 | - } |
|
| 725 | - |
|
| 726 | - $query_args = ['action' => 'edit_price', 'id' => $PRC_ID]; |
|
| 727 | - |
|
| 728 | - $this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args); |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - |
|
| 732 | - /** |
|
| 733 | - * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 734 | - * @return void |
|
| 735 | - * @throws EE_Error |
|
| 736 | - * @throws ReflectionException |
|
| 737 | - */ |
|
| 738 | - protected function _trash_or_restore_price(bool $trash = true) |
|
| 739 | - { |
|
| 740 | - $entity_model = EEM_Price::instance(); |
|
| 741 | - $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
| 742 | - $result = $this->trashRestoreDeleteEntities( |
|
| 743 | - $entity_model, |
|
| 744 | - 'id', |
|
| 745 | - $action, |
|
| 746 | - 'PRC_deleted', |
|
| 747 | - [$this, 'adjustTicketRelations'] |
|
| 748 | - ); |
|
| 749 | - |
|
| 750 | - if ($result) { |
|
| 751 | - $msg = $trash |
|
| 752 | - ? esc_html( |
|
| 753 | - _n( |
|
| 754 | - 'The Price has been trashed', |
|
| 755 | - 'The Prices have been trashed', |
|
| 756 | - $result, |
|
| 757 | - 'event_espresso' |
|
| 758 | - ) |
|
| 759 | - ) |
|
| 760 | - : esc_html( |
|
| 761 | - _n( |
|
| 762 | - 'The Price has been restored', |
|
| 763 | - 'The Prices have been restored', |
|
| 764 | - $result, |
|
| 765 | - 'event_espresso' |
|
| 766 | - ) |
|
| 767 | - ); |
|
| 768 | - EE_Error::add_success($msg); |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - $this->_redirect_after_action( |
|
| 772 | - $result, |
|
| 773 | - _n('Price', 'Prices', $result, 'event_espresso'), |
|
| 774 | - $trash ? 'trashed' : 'restored', |
|
| 775 | - ['action' => 'default'], |
|
| 776 | - true |
|
| 777 | - ); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - |
|
| 781 | - /** |
|
| 782 | - * @param EEM_Base $entity_model |
|
| 783 | - * @param int|string $entity_ID |
|
| 784 | - * @param string $action |
|
| 785 | - * @param int $result |
|
| 786 | - * @throws EE_Error |
|
| 787 | - * @throws ReflectionException |
|
| 788 | - * @since $VID:$ |
|
| 789 | - */ |
|
| 790 | - public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result) |
|
| 791 | - { |
|
| 792 | - if (! $entity_ID || (float) $result < 1) { |
|
| 793 | - return; |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - $entity = $entity_model->get_one_by_ID($entity_ID); |
|
| 797 | - if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) { |
|
| 798 | - return; |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - // get default tickets for updating |
|
| 802 | - $default_tickets = EEM_Ticket::instance()->get_all_default_tickets(); |
|
| 803 | - foreach ($default_tickets as $default_ticket) { |
|
| 804 | - if (! $default_ticket instanceof EE_Ticket) { |
|
| 805 | - continue; |
|
| 806 | - } |
|
| 807 | - switch ($action) { |
|
| 808 | - case EE_Admin_List_Table::ACTION_DELETE: |
|
| 809 | - case EE_Admin_List_Table::ACTION_TRASH: |
|
| 810 | - // if trashing then remove relations to base default ticket. |
|
| 811 | - $default_ticket->_remove_relation_to($entity_ID, 'Price'); |
|
| 812 | - break; |
|
| 813 | - case EE_Admin_List_Table::ACTION_RESTORE: |
|
| 814 | - // if restoring then add back to base default ticket |
|
| 815 | - $default_ticket->_add_relation_to($entity_ID, 'Price'); |
|
| 816 | - break; |
|
| 817 | - } |
|
| 818 | - $default_ticket->save(); |
|
| 819 | - } |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - |
|
| 823 | - /** |
|
| 824 | - * @return void |
|
| 825 | - * @throws EE_Error |
|
| 826 | - * @throws ReflectionException |
|
| 827 | - */ |
|
| 828 | - protected function _delete_price() |
|
| 829 | - { |
|
| 830 | - $entity_model = EEM_Price::instance(); |
|
| 831 | - $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
| 832 | - $entity = $entity_model->item_name($deleted); |
|
| 833 | - $this->_redirect_after_action($deleted, $entity, 'deleted', ['action' => 'default']); |
|
| 834 | - } |
|
| 835 | - |
|
| 836 | - |
|
| 837 | - /** |
|
| 838 | - * @throws EE_Error |
|
| 839 | - * @throws ReflectionException |
|
| 840 | - */ |
|
| 841 | - public function update_price_order() |
|
| 842 | - { |
|
| 843 | - // grab our row IDs |
|
| 844 | - $row_ids = $this->request->getRequestParam('row_ids', ''); |
|
| 845 | - $row_ids = explode(',', rtrim($row_ids, ',')); |
|
| 846 | - |
|
| 847 | - $all_updated = true; |
|
| 848 | - foreach ($row_ids as $i => $row_id) { |
|
| 849 | - // Update the prices when re-ordering |
|
| 850 | - $fields_n_values = ['PRC_order' => $i + 1]; |
|
| 851 | - $query_params = [['PRC_ID' => absint($row_id)]]; |
|
| 852 | - // any failure will toggle $all_updated to false |
|
| 853 | - $all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false |
|
| 854 | - ? $all_updated |
|
| 855 | - : false; |
|
| 856 | - } |
|
| 857 | - $success = $all_updated ? esc_html__('Price order was updated successfully.', 'event_espresso') : false; |
|
| 858 | - $errors = ! $all_updated ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso') |
|
| 859 | - : false; |
|
| 860 | - |
|
| 861 | - echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]); |
|
| 862 | - die(); |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - |
|
| 866 | - /****************************************************************************************************************** |
|
| 15 | + protected function _init_page_props() |
|
| 16 | + { |
|
| 17 | + $this->page_slug = PRICING_PG_SLUG; |
|
| 18 | + $this->page_label = PRICING_LABEL; |
|
| 19 | + $this->_admin_base_url = PRICING_ADMIN_URL; |
|
| 20 | + $this->_admin_base_path = PRICING_ADMIN; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + protected function _ajax_hooks() |
|
| 25 | + { |
|
| 26 | + add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + protected function _define_page_props() |
|
| 31 | + { |
|
| 32 | + $this->_admin_page_title = PRICING_LABEL; |
|
| 33 | + $this->_labels = [ |
|
| 34 | + 'buttons' => [ |
|
| 35 | + 'add' => esc_html__('Add New Default Price', 'event_espresso'), |
|
| 36 | + 'edit' => esc_html__('Edit Default Price', 'event_espresso'), |
|
| 37 | + 'delete' => esc_html__('Delete Default Price', 'event_espresso'), |
|
| 38 | + 'add_type' => esc_html__('Add New Default Price Type', 'event_espresso'), |
|
| 39 | + 'edit_type' => esc_html__('Edit Price Type', 'event_espresso'), |
|
| 40 | + 'delete_type' => esc_html__('Delete Price Type', 'event_espresso'), |
|
| 41 | + ], |
|
| 42 | + ]; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * an array for storing request actions and their corresponding methods |
|
| 48 | + * |
|
| 49 | + * @return void |
|
| 50 | + */ |
|
| 51 | + protected function _set_page_routes() |
|
| 52 | + { |
|
| 53 | + $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
| 54 | + $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
| 55 | + $this->_page_routes = [ |
|
| 56 | + 'default' => [ |
|
| 57 | + 'func' => '_price_overview_list_table', |
|
| 58 | + 'capability' => 'ee_read_default_prices', |
|
| 59 | + ], |
|
| 60 | + 'add_new_price' => [ |
|
| 61 | + 'func' => '_edit_price_details', |
|
| 62 | + 'args' => ['new_price' => true], |
|
| 63 | + 'capability' => 'ee_edit_default_prices', |
|
| 64 | + ], |
|
| 65 | + 'edit_price' => [ |
|
| 66 | + 'func' => '_edit_price_details', |
|
| 67 | + 'args' => ['new_price' => false], |
|
| 68 | + 'capability' => 'ee_edit_default_price', |
|
| 69 | + 'obj_id' => $PRC_ID, |
|
| 70 | + ], |
|
| 71 | + 'insert_price' => [ |
|
| 72 | + 'func' => '_insert_or_update_price', |
|
| 73 | + 'args' => ['new_price' => true], |
|
| 74 | + 'noheader' => true, |
|
| 75 | + 'capability' => 'ee_edit_default_prices', |
|
| 76 | + ], |
|
| 77 | + 'update_price' => [ |
|
| 78 | + 'func' => '_insert_or_update_price', |
|
| 79 | + 'args' => ['new_price' => false], |
|
| 80 | + 'noheader' => true, |
|
| 81 | + 'capability' => 'ee_edit_default_price', |
|
| 82 | + 'obj_id' => $PRC_ID, |
|
| 83 | + ], |
|
| 84 | + 'trash_price' => [ |
|
| 85 | + 'func' => '_trash_or_restore_price', |
|
| 86 | + 'args' => ['trash' => true], |
|
| 87 | + 'noheader' => true, |
|
| 88 | + 'capability' => 'ee_delete_default_price', |
|
| 89 | + 'obj_id' => $PRC_ID, |
|
| 90 | + ], |
|
| 91 | + 'restore_price' => [ |
|
| 92 | + 'func' => '_trash_or_restore_price', |
|
| 93 | + 'args' => ['trash' => false], |
|
| 94 | + 'noheader' => true, |
|
| 95 | + 'capability' => 'ee_delete_default_price', |
|
| 96 | + 'obj_id' => $PRC_ID, |
|
| 97 | + ], |
|
| 98 | + 'delete_price' => [ |
|
| 99 | + 'func' => '_delete_price', |
|
| 100 | + 'noheader' => true, |
|
| 101 | + 'capability' => 'ee_delete_default_price', |
|
| 102 | + 'obj_id' => $PRC_ID, |
|
| 103 | + ], |
|
| 104 | + 'espresso_update_price_order' => [ |
|
| 105 | + 'func' => 'update_price_order', |
|
| 106 | + 'noheader' => true, |
|
| 107 | + 'capability' => 'ee_edit_default_prices', |
|
| 108 | + ], |
|
| 109 | + // price types |
|
| 110 | + 'price_types' => [ |
|
| 111 | + 'func' => '_price_types_overview_list_table', |
|
| 112 | + 'capability' => 'ee_read_default_price_types', |
|
| 113 | + ], |
|
| 114 | + 'add_new_price_type' => [ |
|
| 115 | + 'func' => '_edit_price_type_details', |
|
| 116 | + 'capability' => 'ee_edit_default_price_types', |
|
| 117 | + ], |
|
| 118 | + 'edit_price_type' => [ |
|
| 119 | + 'func' => '_edit_price_type_details', |
|
| 120 | + 'capability' => 'ee_edit_default_price_type', |
|
| 121 | + 'obj_id' => $PRT_ID, |
|
| 122 | + ], |
|
| 123 | + 'insert_price_type' => [ |
|
| 124 | + 'func' => '_insert_or_update_price_type', |
|
| 125 | + 'args' => ['new_price_type' => true], |
|
| 126 | + 'noheader' => true, |
|
| 127 | + 'capability' => 'ee_edit_default_price_types', |
|
| 128 | + ], |
|
| 129 | + 'update_price_type' => [ |
|
| 130 | + 'func' => '_insert_or_update_price_type', |
|
| 131 | + 'args' => ['new_price_type' => false], |
|
| 132 | + 'noheader' => true, |
|
| 133 | + 'capability' => 'ee_edit_default_price_type', |
|
| 134 | + 'obj_id' => $PRT_ID, |
|
| 135 | + ], |
|
| 136 | + 'trash_price_type' => [ |
|
| 137 | + 'func' => '_trash_or_restore_price_type', |
|
| 138 | + 'args' => ['trash' => true], |
|
| 139 | + 'noheader' => true, |
|
| 140 | + 'capability' => 'ee_delete_default_price_type', |
|
| 141 | + 'obj_id' => $PRT_ID, |
|
| 142 | + ], |
|
| 143 | + 'restore_price_type' => [ |
|
| 144 | + 'func' => '_trash_or_restore_price_type', |
|
| 145 | + 'args' => ['trash' => false], |
|
| 146 | + 'noheader' => true, |
|
| 147 | + 'capability' => 'ee_delete_default_price_type', |
|
| 148 | + 'obj_id' => $PRT_ID, |
|
| 149 | + ], |
|
| 150 | + 'delete_price_type' => [ |
|
| 151 | + 'func' => '_delete_price_type', |
|
| 152 | + 'noheader' => true, |
|
| 153 | + 'capability' => 'ee_delete_default_price_type', |
|
| 154 | + 'obj_id' => $PRT_ID, |
|
| 155 | + ], |
|
| 156 | + 'tax_settings' => [ |
|
| 157 | + 'func' => '_tax_settings', |
|
| 158 | + 'capability' => 'manage_options', |
|
| 159 | + ], |
|
| 160 | + 'update_tax_settings' => [ |
|
| 161 | + 'func' => '_update_tax_settings', |
|
| 162 | + 'capability' => 'manage_options', |
|
| 163 | + 'noheader' => true, |
|
| 164 | + ], |
|
| 165 | + ]; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + protected function _set_page_config() |
|
| 170 | + { |
|
| 171 | + $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
| 172 | + $this->_page_config = [ |
|
| 173 | + 'default' => [ |
|
| 174 | + 'nav' => [ |
|
| 175 | + 'label' => esc_html__('Default Pricing', 'event_espresso'), |
|
| 176 | + 'order' => 10, |
|
| 177 | + ], |
|
| 178 | + 'list_table' => 'Prices_List_Table', |
|
| 179 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 180 | + 'help_tabs' => [ |
|
| 181 | + 'pricing_default_pricing_help_tab' => [ |
|
| 182 | + 'title' => esc_html__('Default Pricing', 'event_espresso'), |
|
| 183 | + 'filename' => 'pricing_default_pricing', |
|
| 184 | + ], |
|
| 185 | + 'pricing_default_pricing_table_column_headings_help_tab' => [ |
|
| 186 | + 'title' => esc_html__('Default Pricing Table Column Headings', 'event_espresso'), |
|
| 187 | + 'filename' => 'pricing_default_pricing_table_column_headings', |
|
| 188 | + ], |
|
| 189 | + 'pricing_default_pricing_views_bulk_actions_search_help_tab' => [ |
|
| 190 | + 'title' => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'), |
|
| 191 | + 'filename' => 'pricing_default_pricing_views_bulk_actions_search', |
|
| 192 | + ], |
|
| 193 | + ], |
|
| 194 | + 'require_nonce' => false, |
|
| 195 | + ], |
|
| 196 | + 'add_new_price' => [ |
|
| 197 | + 'nav' => [ |
|
| 198 | + 'label' => esc_html__('Add New Default Price', 'event_espresso'), |
|
| 199 | + 'order' => 20, |
|
| 200 | + 'persistent' => false, |
|
| 201 | + ], |
|
| 202 | + 'help_tabs' => [ |
|
| 203 | + 'add_new_default_price_help_tab' => [ |
|
| 204 | + 'title' => esc_html__('Add New Default Price', 'event_espresso'), |
|
| 205 | + 'filename' => 'pricing_add_new_default_price', |
|
| 206 | + ], |
|
| 207 | + ], |
|
| 208 | + 'metaboxes' => array_merge( |
|
| 209 | + ['_publish_post_box'], |
|
| 210 | + $this->_default_espresso_metaboxes |
|
| 211 | + ), |
|
| 212 | + 'require_nonce' => false, |
|
| 213 | + ], |
|
| 214 | + 'edit_price' => [ |
|
| 215 | + 'nav' => [ |
|
| 216 | + 'label' => esc_html__('Edit Default Price', 'event_espresso'), |
|
| 217 | + 'order' => 20, |
|
| 218 | + 'url' => $PRC_ID |
|
| 219 | + ? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url) |
|
| 220 | + : $this->_admin_base_url, |
|
| 221 | + 'persistent' => false, |
|
| 222 | + ], |
|
| 223 | + 'metaboxes' => array_merge( |
|
| 224 | + ['_publish_post_box'], |
|
| 225 | + $this->_default_espresso_metaboxes |
|
| 226 | + ), |
|
| 227 | + 'help_tabs' => [ |
|
| 228 | + 'edit_default_price_help_tab' => [ |
|
| 229 | + 'title' => esc_html__('Edit Default Price', 'event_espresso'), |
|
| 230 | + 'filename' => 'pricing_edit_default_price', |
|
| 231 | + ], |
|
| 232 | + ], |
|
| 233 | + 'require_nonce' => false, |
|
| 234 | + ], |
|
| 235 | + 'price_types' => [ |
|
| 236 | + 'nav' => [ |
|
| 237 | + 'label' => esc_html__('Price Types', 'event_espresso'), |
|
| 238 | + 'order' => 30, |
|
| 239 | + ], |
|
| 240 | + 'list_table' => 'Price_Types_List_Table', |
|
| 241 | + 'help_tabs' => [ |
|
| 242 | + 'pricing_price_types_help_tab' => [ |
|
| 243 | + 'title' => esc_html__('Price Types', 'event_espresso'), |
|
| 244 | + 'filename' => 'pricing_price_types', |
|
| 245 | + ], |
|
| 246 | + 'pricing_price_types_table_column_headings_help_tab' => [ |
|
| 247 | + 'title' => esc_html__('Price Types Table Column Headings', 'event_espresso'), |
|
| 248 | + 'filename' => 'pricing_price_types_table_column_headings', |
|
| 249 | + ], |
|
| 250 | + 'pricing_price_types_views_bulk_actions_search_help_tab' => [ |
|
| 251 | + 'title' => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'), |
|
| 252 | + 'filename' => 'pricing_price_types_views_bulk_actions_search', |
|
| 253 | + ], |
|
| 254 | + ], |
|
| 255 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 256 | + 'require_nonce' => false, |
|
| 257 | + ], |
|
| 258 | + 'add_new_price_type' => [ |
|
| 259 | + 'nav' => [ |
|
| 260 | + 'label' => esc_html__('Add New Price Type', 'event_espresso'), |
|
| 261 | + 'order' => 40, |
|
| 262 | + 'persistent' => false, |
|
| 263 | + ], |
|
| 264 | + 'help_tabs' => [ |
|
| 265 | + 'add_new_price_type_help_tab' => [ |
|
| 266 | + 'title' => esc_html__('Add New Price Type', 'event_espresso'), |
|
| 267 | + 'filename' => 'pricing_add_new_price_type', |
|
| 268 | + ], |
|
| 269 | + ], |
|
| 270 | + 'metaboxes' => array_merge( |
|
| 271 | + ['_publish_post_box'], |
|
| 272 | + $this->_default_espresso_metaboxes |
|
| 273 | + ), |
|
| 274 | + 'require_nonce' => false, |
|
| 275 | + ], |
|
| 276 | + 'edit_price_type' => [ |
|
| 277 | + 'nav' => [ |
|
| 278 | + 'label' => esc_html__('Edit Price Type', 'event_espresso'), |
|
| 279 | + 'order' => 40, |
|
| 280 | + 'persistent' => false, |
|
| 281 | + ], |
|
| 282 | + 'help_tabs' => [ |
|
| 283 | + 'edit_price_type_help_tab' => [ |
|
| 284 | + 'title' => esc_html__('Edit Price Type', 'event_espresso'), |
|
| 285 | + 'filename' => 'pricing_edit_price_type', |
|
| 286 | + ], |
|
| 287 | + ], |
|
| 288 | + 'metaboxes' => array_merge( |
|
| 289 | + ['_publish_post_box'], |
|
| 290 | + $this->_default_espresso_metaboxes |
|
| 291 | + ), |
|
| 292 | + 'require_nonce' => false, |
|
| 293 | + ], |
|
| 294 | + 'tax_settings' => [ |
|
| 295 | + 'nav' => [ |
|
| 296 | + 'label' => esc_html__('Tax Settings', 'event_espresso'), |
|
| 297 | + 'order' => 40, |
|
| 298 | + ], |
|
| 299 | + 'labels' => [ |
|
| 300 | + 'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'), |
|
| 301 | + ], |
|
| 302 | + 'metaboxes' => array_merge( |
|
| 303 | + ['_publish_post_box'], |
|
| 304 | + $this->_default_espresso_metaboxes |
|
| 305 | + ), |
|
| 306 | + 'require_nonce' => true, |
|
| 307 | + ], |
|
| 308 | + ]; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + |
|
| 312 | + protected function _add_screen_options() |
|
| 313 | + { |
|
| 314 | + // todo |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + |
|
| 318 | + protected function _add_screen_options_default() |
|
| 319 | + { |
|
| 320 | + $this->_per_page_screen_option(); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + |
|
| 324 | + protected function _add_screen_options_price_types() |
|
| 325 | + { |
|
| 326 | + $page_title = $this->_admin_page_title; |
|
| 327 | + $this->_admin_page_title = esc_html__('Price Types', 'event_espresso'); |
|
| 328 | + $this->_per_page_screen_option(); |
|
| 329 | + $this->_admin_page_title = $page_title; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + |
|
| 333 | + protected function _add_feature_pointers() |
|
| 334 | + { |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + |
|
| 338 | + public function load_scripts_styles() |
|
| 339 | + { |
|
| 340 | + // styles |
|
| 341 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 342 | + wp_register_style( |
|
| 343 | + 'espresso_PRICING', |
|
| 344 | + PRICING_ASSETS_URL . 'espresso_pricing_admin.css', |
|
| 345 | + [], |
|
| 346 | + EVENT_ESPRESSO_VERSION |
|
| 347 | + ); |
|
| 348 | + wp_enqueue_style('espresso_PRICING'); |
|
| 349 | + |
|
| 350 | + // scripts |
|
| 351 | + wp_enqueue_script('ee_admin_js'); |
|
| 352 | + wp_enqueue_script('jquery-ui-position'); |
|
| 353 | + wp_enqueue_script('jquery-ui-widget'); |
|
| 354 | + wp_register_script( |
|
| 355 | + 'espresso_PRICING', |
|
| 356 | + PRICING_ASSETS_URL . 'espresso_pricing_admin.js', |
|
| 357 | + ['jquery'], |
|
| 358 | + EVENT_ESPRESSO_VERSION, |
|
| 359 | + true |
|
| 360 | + ); |
|
| 361 | + wp_enqueue_script('espresso_PRICING'); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + |
|
| 365 | + public function load_scripts_styles_default() |
|
| 366 | + { |
|
| 367 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + |
|
| 371 | + public function admin_footer_scripts() |
|
| 372 | + { |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + public function admin_init() |
|
| 377 | + { |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + public function admin_notices() |
|
| 382 | + { |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + protected function _set_list_table_views_default() |
|
| 387 | + { |
|
| 388 | + $this->_views = [ |
|
| 389 | + 'all' => [ |
|
| 390 | + 'slug' => 'all', |
|
| 391 | + 'label' => esc_html__('View All Default Pricing', 'event_espresso'), |
|
| 392 | + 'count' => 0, |
|
| 393 | + 'bulk_action' => [ |
|
| 394 | + 'trash_price' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 395 | + ], |
|
| 396 | + ], |
|
| 397 | + ]; |
|
| 398 | + |
|
| 399 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
| 400 | + $this->_views['trashed'] = [ |
|
| 401 | + 'slug' => 'trashed', |
|
| 402 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 403 | + 'count' => 0, |
|
| 404 | + 'bulk_action' => [ |
|
| 405 | + 'restore_price' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 406 | + 'delete_price' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 407 | + ], |
|
| 408 | + ]; |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + protected function _set_list_table_views_price_types() |
|
| 414 | + { |
|
| 415 | + $this->_views = [ |
|
| 416 | + 'all' => [ |
|
| 417 | + 'slug' => 'all', |
|
| 418 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 419 | + 'count' => 0, |
|
| 420 | + 'bulk_action' => [ |
|
| 421 | + 'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 422 | + ], |
|
| 423 | + ], |
|
| 424 | + ]; |
|
| 425 | + |
|
| 426 | + if ( |
|
| 427 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 428 | + 'ee_delete_default_price_types', |
|
| 429 | + 'pricing_trash_price_type' |
|
| 430 | + ) |
|
| 431 | + ) { |
|
| 432 | + $this->_views['trashed'] = [ |
|
| 433 | + 'slug' => 'trashed', |
|
| 434 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 435 | + 'count' => 0, |
|
| 436 | + 'bulk_action' => [ |
|
| 437 | + 'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 438 | + 'delete_price_type' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 439 | + ], |
|
| 440 | + ]; |
|
| 441 | + } |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * generates HTML for main Prices Admin page |
|
| 447 | + * |
|
| 448 | + * @return void |
|
| 449 | + * @throws EE_Error |
|
| 450 | + */ |
|
| 451 | + protected function _price_overview_list_table() |
|
| 452 | + { |
|
| 453 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 454 | + 'add_new_price', |
|
| 455 | + 'add', |
|
| 456 | + [], |
|
| 457 | + 'add-new-h2' |
|
| 458 | + ); |
|
| 459 | + $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
| 460 | + $this->_search_btn_label = esc_html__('Default Prices', 'event_espresso'); |
|
| 461 | + $this->display_admin_list_table_page_with_sidebar(); |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * retrieve data for Prices List table |
|
| 467 | + * |
|
| 468 | + * @param int $per_page how many prices displayed per page |
|
| 469 | + * @param bool $count return the count or objects |
|
| 470 | + * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
| 471 | + * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
| 472 | + * @throws EE_Error |
|
| 473 | + * @throws ReflectionException |
|
| 474 | + */ |
|
| 475 | + public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
| 476 | + { |
|
| 477 | + // start with an empty array |
|
| 478 | + $event_pricing = []; |
|
| 479 | + |
|
| 480 | + require_once(PRICING_ADMIN . 'Prices_List_Table.class.php'); |
|
| 481 | + |
|
| 482 | + $orderby = $this->request->getRequestParam('orderby', ''); |
|
| 483 | + $order = $this->request->getRequestParam('order', 'ASC'); |
|
| 484 | + |
|
| 485 | + switch ($orderby) { |
|
| 486 | + case 'name': |
|
| 487 | + $orderby = ['PRC_name' => $order]; |
|
| 488 | + break; |
|
| 489 | + case 'type': |
|
| 490 | + $orderby = ['Price_Type.PRT_name' => $order]; |
|
| 491 | + break; |
|
| 492 | + case 'amount': |
|
| 493 | + $orderby = ['PRC_amount' => $order]; |
|
| 494 | + break; |
|
| 495 | + default: |
|
| 496 | + $orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order]; |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
| 500 | + $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
| 501 | + |
|
| 502 | + $where = [ |
|
| 503 | + 'PRC_is_default' => 1, |
|
| 504 | + 'PRC_deleted' => $trashed, |
|
| 505 | + ]; |
|
| 506 | + |
|
| 507 | + $offset = ($current_page - 1) * $per_page; |
|
| 508 | + $limit = [$offset, $per_page]; |
|
| 509 | + |
|
| 510 | + $search_term = $this->request->getRequestParam('s'); |
|
| 511 | + if ($search_term) { |
|
| 512 | + $search_term = "%{$search_term}%"; |
|
| 513 | + $where['OR'] = [ |
|
| 514 | + 'PRC_name' => ['LIKE', $search_term], |
|
| 515 | + 'PRC_desc' => ['LIKE', $search_term], |
|
| 516 | + 'PRC_amount' => ['LIKE', $search_term], |
|
| 517 | + 'Price_Type.PRT_name' => ['LIKE', $search_term], |
|
| 518 | + ]; |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + $query_params = [ |
|
| 522 | + $where, |
|
| 523 | + 'order_by' => $orderby, |
|
| 524 | + 'limit' => $limit, |
|
| 525 | + 'group_by' => 'PRC_ID', |
|
| 526 | + ]; |
|
| 527 | + |
|
| 528 | + if ($count) { |
|
| 529 | + return $trashed |
|
| 530 | + ? EEM_Price::instance()->count([$where]) |
|
| 531 | + : EEM_Price::instance()->count_deleted_and_undeleted([$where]); |
|
| 532 | + } |
|
| 533 | + return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * @return void |
|
| 539 | + * @throws EE_Error |
|
| 540 | + * @throws ReflectionException |
|
| 541 | + */ |
|
| 542 | + protected function _edit_price_details() |
|
| 543 | + { |
|
| 544 | + // grab price ID |
|
| 545 | + $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
| 546 | + // change page title based on request action |
|
| 547 | + switch ($this->_req_action) { |
|
| 548 | + case 'add_new_price': |
|
| 549 | + $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso'); |
|
| 550 | + break; |
|
| 551 | + case 'edit_price': |
|
| 552 | + $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso'); |
|
| 553 | + break; |
|
| 554 | + default: |
|
| 555 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
| 556 | + } |
|
| 557 | + // add PRC_ID to title if editing |
|
| 558 | + $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title; |
|
| 559 | + |
|
| 560 | + if ($PRC_ID) { |
|
| 561 | + $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
| 562 | + $additional_hidden_fields = [ |
|
| 563 | + 'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID], |
|
| 564 | + ]; |
|
| 565 | + $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields); |
|
| 566 | + } else { |
|
| 567 | + $price = EEM_Price::instance()->get_new_price(); |
|
| 568 | + $this->_set_add_edit_form_tags('insert_price'); |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + if (! $price instanceof EE_Price) { |
|
| 572 | + throw new RuntimeException( |
|
| 573 | + sprintf( |
|
| 574 | + esc_html__( |
|
| 575 | + 'A valid Price could not be retrieved from the database with ID: %1$s', |
|
| 576 | + 'event_espresso' |
|
| 577 | + ), |
|
| 578 | + $PRC_ID |
|
| 579 | + ) |
|
| 580 | + ); |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + $this->_template_args['PRC_ID'] = $PRC_ID; |
|
| 584 | + $this->_template_args['price'] = $price; |
|
| 585 | + |
|
| 586 | + $default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1; |
|
| 587 | + |
|
| 588 | + $this->_template_args['default_base_price'] = $default_base_price; |
|
| 589 | + |
|
| 590 | + // get price types |
|
| 591 | + $price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]); |
|
| 592 | + if (empty($price_types)) { |
|
| 593 | + $msg = esc_html__( |
|
| 594 | + 'You have no price types defined. Please add a price type before adding a price.', |
|
| 595 | + 'event_espresso' |
|
| 596 | + ); |
|
| 597 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 598 | + $this->display_admin_page_with_sidebar(); |
|
| 599 | + } |
|
| 600 | + $attributes = []; |
|
| 601 | + $price_type_names = []; |
|
| 602 | + $attributes[] = 'id="PRT_ID"'; |
|
| 603 | + if ($default_base_price) { |
|
| 604 | + $attributes[] = 'disabled="disabled"'; |
|
| 605 | + $price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')]; |
|
| 606 | + } |
|
| 607 | + foreach ($price_types as $type) { |
|
| 608 | + $price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()]; |
|
| 609 | + } |
|
| 610 | + $this->_template_args['attributes'] = implode(' ', $attributes); |
|
| 611 | + $this->_template_args['price_types'] = $price_type_names; |
|
| 612 | + |
|
| 613 | + $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
| 614 | + $this->_template_args['admin_page_content'] = $this->_edit_price_details_meta_box(); |
|
| 615 | + |
|
| 616 | + $this->_set_publish_post_box_vars('id', $PRC_ID); |
|
| 617 | + // the details template wrapper |
|
| 618 | + $this->display_admin_page_with_sidebar(); |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * |
|
| 624 | + * @return string |
|
| 625 | + */ |
|
| 626 | + public function _edit_price_details_meta_box(): string |
|
| 627 | + { |
|
| 628 | + return EEH_Template::display_template( |
|
| 629 | + PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php', |
|
| 630 | + $this->_template_args, |
|
| 631 | + true |
|
| 632 | + ); |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + |
|
| 636 | + /** |
|
| 637 | + * @return array |
|
| 638 | + * @throws EE_Error |
|
| 639 | + * @throws ReflectionException |
|
| 640 | + */ |
|
| 641 | + protected function set_price_column_values(): array |
|
| 642 | + { |
|
| 643 | + $PRC_order = 0; |
|
| 644 | + $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
| 645 | + if ($PRT_ID) { |
|
| 646 | + /** @var EE_Price_Type $price_type */ |
|
| 647 | + $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
| 648 | + if ($price_type instanceof EE_Price_Type) { |
|
| 649 | + $PRC_order = $price_type->order(); |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + return [ |
|
| 653 | + 'PRT_ID' => $PRT_ID, |
|
| 654 | + 'PRC_amount' => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT), |
|
| 655 | + 'PRC_name' => $this->request->getRequestParam('PRC_name'), |
|
| 656 | + 'PRC_desc' => $this->request->getRequestParam('PRC_desc'), |
|
| 657 | + 'PRC_is_default' => 1, |
|
| 658 | + 'PRC_overrides' => null, |
|
| 659 | + 'PRC_order' => $PRC_order, |
|
| 660 | + 'PRC_deleted' => 0, |
|
| 661 | + 'PRC_parent' => 0, |
|
| 662 | + ]; |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + |
|
| 666 | + /** |
|
| 667 | + * @param bool $insert - whether to insert or update |
|
| 668 | + * @return void |
|
| 669 | + * @throws EE_Error |
|
| 670 | + * @throws ReflectionException |
|
| 671 | + */ |
|
| 672 | + protected function _insert_or_update_price(bool $insert = false) |
|
| 673 | + { |
|
| 674 | + // why be so pessimistic ??? : ( |
|
| 675 | + $updated = 0; |
|
| 676 | + |
|
| 677 | + $set_column_values = $this->set_price_column_values(); |
|
| 678 | + // is this a new Price ? |
|
| 679 | + if ($insert) { |
|
| 680 | + // run the insert |
|
| 681 | + $PRC_ID = EEM_Price::instance()->insert($set_column_values); |
|
| 682 | + if ($PRC_ID) { |
|
| 683 | + // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type |
|
| 684 | + $price = EEM_price::instance()->get_one_by_ID($PRC_ID); |
|
| 685 | + if ( |
|
| 686 | + $price instanceof EE_Price |
|
| 687 | + && $price->type_obj() instanceof EE_Price_type |
|
| 688 | + && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax |
|
| 689 | + ) { |
|
| 690 | + $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
| 691 | + $ticket->_add_relation_to($price, 'Price'); |
|
| 692 | + $ticket->save(); |
|
| 693 | + } |
|
| 694 | + $updated = 1; |
|
| 695 | + } |
|
| 696 | + $action_desc = 'created'; |
|
| 697 | + } else { |
|
| 698 | + $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
| 699 | + // run the update |
|
| 700 | + $where_cols_n_values = ['PRC_ID' => $PRC_ID]; |
|
| 701 | + $updated = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]); |
|
| 702 | + |
|
| 703 | + $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
| 704 | + if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
| 705 | + // if this is $PRC_ID == 1, |
|
| 706 | + // then we need to update the default ticket attached to this price so the TKT_price value is updated. |
|
| 707 | + if ($PRC_ID === 1) { |
|
| 708 | + $ticket = $price->get_first_related('Ticket'); |
|
| 709 | + if ($ticket) { |
|
| 710 | + $ticket->set('TKT_price', $price->get('PRC_amount')); |
|
| 711 | + $ticket->set('TKT_name', $price->get('PRC_name')); |
|
| 712 | + $ticket->set('TKT_description', $price->get('PRC_desc')); |
|
| 713 | + $ticket->save(); |
|
| 714 | + } |
|
| 715 | + } else { |
|
| 716 | + // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type. |
|
| 717 | + $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
| 718 | + $ticket->_add_relation_to($PRC_ID, 'Price'); |
|
| 719 | + $ticket->save(); |
|
| 720 | + } |
|
| 721 | + } |
|
| 722 | + |
|
| 723 | + $action_desc = 'updated'; |
|
| 724 | + } |
|
| 725 | + |
|
| 726 | + $query_args = ['action' => 'edit_price', 'id' => $PRC_ID]; |
|
| 727 | + |
|
| 728 | + $this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args); |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + |
|
| 732 | + /** |
|
| 733 | + * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 734 | + * @return void |
|
| 735 | + * @throws EE_Error |
|
| 736 | + * @throws ReflectionException |
|
| 737 | + */ |
|
| 738 | + protected function _trash_or_restore_price(bool $trash = true) |
|
| 739 | + { |
|
| 740 | + $entity_model = EEM_Price::instance(); |
|
| 741 | + $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
| 742 | + $result = $this->trashRestoreDeleteEntities( |
|
| 743 | + $entity_model, |
|
| 744 | + 'id', |
|
| 745 | + $action, |
|
| 746 | + 'PRC_deleted', |
|
| 747 | + [$this, 'adjustTicketRelations'] |
|
| 748 | + ); |
|
| 749 | + |
|
| 750 | + if ($result) { |
|
| 751 | + $msg = $trash |
|
| 752 | + ? esc_html( |
|
| 753 | + _n( |
|
| 754 | + 'The Price has been trashed', |
|
| 755 | + 'The Prices have been trashed', |
|
| 756 | + $result, |
|
| 757 | + 'event_espresso' |
|
| 758 | + ) |
|
| 759 | + ) |
|
| 760 | + : esc_html( |
|
| 761 | + _n( |
|
| 762 | + 'The Price has been restored', |
|
| 763 | + 'The Prices have been restored', |
|
| 764 | + $result, |
|
| 765 | + 'event_espresso' |
|
| 766 | + ) |
|
| 767 | + ); |
|
| 768 | + EE_Error::add_success($msg); |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + $this->_redirect_after_action( |
|
| 772 | + $result, |
|
| 773 | + _n('Price', 'Prices', $result, 'event_espresso'), |
|
| 774 | + $trash ? 'trashed' : 'restored', |
|
| 775 | + ['action' => 'default'], |
|
| 776 | + true |
|
| 777 | + ); |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + |
|
| 781 | + /** |
|
| 782 | + * @param EEM_Base $entity_model |
|
| 783 | + * @param int|string $entity_ID |
|
| 784 | + * @param string $action |
|
| 785 | + * @param int $result |
|
| 786 | + * @throws EE_Error |
|
| 787 | + * @throws ReflectionException |
|
| 788 | + * @since $VID:$ |
|
| 789 | + */ |
|
| 790 | + public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result) |
|
| 791 | + { |
|
| 792 | + if (! $entity_ID || (float) $result < 1) { |
|
| 793 | + return; |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + $entity = $entity_model->get_one_by_ID($entity_ID); |
|
| 797 | + if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) { |
|
| 798 | + return; |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + // get default tickets for updating |
|
| 802 | + $default_tickets = EEM_Ticket::instance()->get_all_default_tickets(); |
|
| 803 | + foreach ($default_tickets as $default_ticket) { |
|
| 804 | + if (! $default_ticket instanceof EE_Ticket) { |
|
| 805 | + continue; |
|
| 806 | + } |
|
| 807 | + switch ($action) { |
|
| 808 | + case EE_Admin_List_Table::ACTION_DELETE: |
|
| 809 | + case EE_Admin_List_Table::ACTION_TRASH: |
|
| 810 | + // if trashing then remove relations to base default ticket. |
|
| 811 | + $default_ticket->_remove_relation_to($entity_ID, 'Price'); |
|
| 812 | + break; |
|
| 813 | + case EE_Admin_List_Table::ACTION_RESTORE: |
|
| 814 | + // if restoring then add back to base default ticket |
|
| 815 | + $default_ticket->_add_relation_to($entity_ID, 'Price'); |
|
| 816 | + break; |
|
| 817 | + } |
|
| 818 | + $default_ticket->save(); |
|
| 819 | + } |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + |
|
| 823 | + /** |
|
| 824 | + * @return void |
|
| 825 | + * @throws EE_Error |
|
| 826 | + * @throws ReflectionException |
|
| 827 | + */ |
|
| 828 | + protected function _delete_price() |
|
| 829 | + { |
|
| 830 | + $entity_model = EEM_Price::instance(); |
|
| 831 | + $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
| 832 | + $entity = $entity_model->item_name($deleted); |
|
| 833 | + $this->_redirect_after_action($deleted, $entity, 'deleted', ['action' => 'default']); |
|
| 834 | + } |
|
| 835 | + |
|
| 836 | + |
|
| 837 | + /** |
|
| 838 | + * @throws EE_Error |
|
| 839 | + * @throws ReflectionException |
|
| 840 | + */ |
|
| 841 | + public function update_price_order() |
|
| 842 | + { |
|
| 843 | + // grab our row IDs |
|
| 844 | + $row_ids = $this->request->getRequestParam('row_ids', ''); |
|
| 845 | + $row_ids = explode(',', rtrim($row_ids, ',')); |
|
| 846 | + |
|
| 847 | + $all_updated = true; |
|
| 848 | + foreach ($row_ids as $i => $row_id) { |
|
| 849 | + // Update the prices when re-ordering |
|
| 850 | + $fields_n_values = ['PRC_order' => $i + 1]; |
|
| 851 | + $query_params = [['PRC_ID' => absint($row_id)]]; |
|
| 852 | + // any failure will toggle $all_updated to false |
|
| 853 | + $all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false |
|
| 854 | + ? $all_updated |
|
| 855 | + : false; |
|
| 856 | + } |
|
| 857 | + $success = $all_updated ? esc_html__('Price order was updated successfully.', 'event_espresso') : false; |
|
| 858 | + $errors = ! $all_updated ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso') |
|
| 859 | + : false; |
|
| 860 | + |
|
| 861 | + echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]); |
|
| 862 | + die(); |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + |
|
| 866 | + /****************************************************************************************************************** |
|
| 867 | 867 | *********************************************** TICKET PRICE TYPES ********************************************* |
| 868 | 868 | ******************************************************************************************************************/ |
| 869 | 869 | |
| 870 | 870 | |
| 871 | - /** |
|
| 872 | - * generates HTML for main Prices Admin page |
|
| 873 | - * |
|
| 874 | - * @return void |
|
| 875 | - * @throws EE_Error |
|
| 876 | - */ |
|
| 877 | - protected function _price_types_overview_list_table() |
|
| 878 | - { |
|
| 879 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 880 | - 'add_new_price_type', |
|
| 881 | - 'add_type', |
|
| 882 | - [], |
|
| 883 | - 'add-new-h2' |
|
| 884 | - ); |
|
| 885 | - $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
| 886 | - $this->_search_btn_label = esc_html__('Price Types', 'event_espresso'); |
|
| 887 | - $this->display_admin_list_table_page_with_sidebar(); |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - |
|
| 891 | - /** |
|
| 892 | - * retrieve data for Price Types List table |
|
| 893 | - * |
|
| 894 | - * @param int $per_page how many prices displayed per page |
|
| 895 | - * @param bool $count return the count or objects |
|
| 896 | - * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
| 897 | - * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
| 898 | - * @throws EE_Error |
|
| 899 | - * @throws ReflectionException |
|
| 900 | - */ |
|
| 901 | - public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
| 902 | - { |
|
| 903 | - // start with an empty array |
|
| 904 | - require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php'); |
|
| 905 | - |
|
| 906 | - $orderby = $this->request->getRequestParam('orderby', ''); |
|
| 907 | - $order = $this->request->getRequestParam('order', 'ASC'); |
|
| 908 | - |
|
| 909 | - switch ($orderby) { |
|
| 910 | - case 'name': |
|
| 911 | - $orderby = ['PRT_name' => $order]; |
|
| 912 | - break; |
|
| 913 | - default: |
|
| 914 | - $orderby = ['PRT_order' => $order]; |
|
| 915 | - } |
|
| 916 | - |
|
| 917 | - $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
| 918 | - $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
| 919 | - |
|
| 920 | - $offset = ($current_page - 1) * $per_page; |
|
| 921 | - $limit = [$offset, $per_page]; |
|
| 922 | - |
|
| 923 | - $where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]]; |
|
| 924 | - |
|
| 925 | - $search_term = $this->request->getRequestParam('s'); |
|
| 926 | - if ($search_term) { |
|
| 927 | - $where['OR'] = [ |
|
| 928 | - 'PRT_name' => ['LIKE', "%{$search_term}%"], |
|
| 929 | - ]; |
|
| 930 | - } |
|
| 931 | - $query_params = [ |
|
| 932 | - $where, |
|
| 933 | - 'order_by' => $orderby, |
|
| 934 | - 'limit' => $limit, |
|
| 935 | - ]; |
|
| 936 | - return $count |
|
| 937 | - ? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params) |
|
| 938 | - : EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
|
| 939 | - } |
|
| 940 | - |
|
| 941 | - |
|
| 942 | - /** |
|
| 943 | - * _edit_price_type_details |
|
| 944 | - * |
|
| 945 | - * @return void |
|
| 946 | - * @throws EE_Error |
|
| 947 | - * @throws ReflectionException |
|
| 948 | - */ |
|
| 949 | - protected function _edit_price_type_details() |
|
| 950 | - { |
|
| 951 | - // grab price type ID |
|
| 952 | - $PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
| 953 | - // change page title based on request action |
|
| 954 | - switch ($this->_req_action) { |
|
| 955 | - case 'add_new_price_type': |
|
| 956 | - $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso'); |
|
| 957 | - break; |
|
| 958 | - case 'edit_price_type': |
|
| 959 | - $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso'); |
|
| 960 | - break; |
|
| 961 | - default: |
|
| 962 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
| 963 | - } |
|
| 964 | - // add PRT_ID to title if editing |
|
| 965 | - $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title; |
|
| 966 | - |
|
| 967 | - if ($PRT_ID) { |
|
| 968 | - $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
| 969 | - $additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]]; |
|
| 970 | - $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields); |
|
| 971 | - } else { |
|
| 972 | - $price_type = EEM_Price_Type::instance()->get_new_price_type(); |
|
| 973 | - $this->_set_add_edit_form_tags('insert_price_type'); |
|
| 974 | - } |
|
| 975 | - |
|
| 976 | - if (! $price_type instanceof EE_Price_Type) { |
|
| 977 | - throw new RuntimeException( |
|
| 978 | - sprintf( |
|
| 979 | - esc_html__( |
|
| 980 | - 'A valid Price Type could not be retrieved from the database with ID: %1$s', |
|
| 981 | - 'event_espresso' |
|
| 982 | - ), |
|
| 983 | - $PRT_ID |
|
| 984 | - ) |
|
| 985 | - ); |
|
| 986 | - } |
|
| 987 | - |
|
| 988 | - $this->_template_args['PRT_ID'] = $PRT_ID; |
|
| 989 | - $this->_template_args['price_type'] = $price_type; |
|
| 990 | - |
|
| 991 | - $base_types = EEM_Price_Type::instance()->get_base_types(); |
|
| 992 | - $select_values = []; |
|
| 993 | - foreach ($base_types as $ref => $text) { |
|
| 994 | - if ($ref == EEM_Price_Type::base_type_base_price) { |
|
| 995 | - // do not allow creation of base_type_base_prices because that's a system only base type. |
|
| 996 | - continue; |
|
| 997 | - } |
|
| 998 | - $select_values[] = ['id' => $ref, 'text' => $text]; |
|
| 999 | - } |
|
| 1000 | - |
|
| 1001 | - $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input( |
|
| 1002 | - 'base_type', |
|
| 1003 | - $select_values, |
|
| 1004 | - $price_type->base_type(), |
|
| 1005 | - 'id="price-type-base-type-slct"' |
|
| 1006 | - ); |
|
| 1007 | - |
|
| 1008 | - $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
| 1009 | - $this->_template_args['admin_page_content'] = $this->_edit_price_type_details_meta_box(); |
|
| 1010 | - |
|
| 1011 | - $redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url); |
|
| 1012 | - $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL); |
|
| 1013 | - // the details template wrapper |
|
| 1014 | - $this->display_admin_page_with_sidebar(); |
|
| 1015 | - } |
|
| 1016 | - |
|
| 1017 | - |
|
| 1018 | - /** |
|
| 1019 | - * _edit_price_type_details_meta_box |
|
| 1020 | - * |
|
| 1021 | - * @return string |
|
| 1022 | - */ |
|
| 1023 | - public function _edit_price_type_details_meta_box(): string |
|
| 1024 | - { |
|
| 1025 | - return EEH_Template::display_template( |
|
| 1026 | - PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php', |
|
| 1027 | - $this->_template_args, |
|
| 1028 | - true |
|
| 1029 | - ); |
|
| 1030 | - } |
|
| 1031 | - |
|
| 1032 | - |
|
| 1033 | - /** |
|
| 1034 | - * @return array |
|
| 1035 | - */ |
|
| 1036 | - protected function set_price_type_column_values(): array |
|
| 1037 | - { |
|
| 1038 | - $base_type = $this->request->getRequestParam( |
|
| 1039 | - 'base_type', |
|
| 1040 | - EEM_Price_Type::base_type_base_price, |
|
| 1041 | - DataType::INTEGER |
|
| 1042 | - ); |
|
| 1043 | - $is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER); |
|
| 1044 | - $order = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER); |
|
| 1045 | - switch ($base_type) { |
|
| 1046 | - case EEM_Price_Type::base_type_base_price: |
|
| 1047 | - $is_percent = 0; |
|
| 1048 | - $order = 0; |
|
| 1049 | - break; |
|
| 1050 | - |
|
| 1051 | - case EEM_Price_Type::base_type_discount: |
|
| 1052 | - case EEM_Price_Type::base_type_surcharge: |
|
| 1053 | - break; |
|
| 1054 | - |
|
| 1055 | - case EEM_Price_Type::base_type_tax: |
|
| 1056 | - $is_percent = 1; |
|
| 1057 | - break; |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - return [ |
|
| 1061 | - 'PBT_ID' => $base_type, |
|
| 1062 | - 'PRT_name' => $this->request->getRequestParam('PRT_name', ''), |
|
| 1063 | - 'PRT_is_percent' => $is_percent, |
|
| 1064 | - 'PRT_order' => $order, |
|
| 1065 | - 'PRT_deleted' => 0, |
|
| 1066 | - ]; |
|
| 1067 | - } |
|
| 1068 | - |
|
| 1069 | - |
|
| 1070 | - /** |
|
| 1071 | - * @param bool $new_price_type - whether to insert or update |
|
| 1072 | - * @return void |
|
| 1073 | - * @throws EE_Error |
|
| 1074 | - * @throws ReflectionException |
|
| 1075 | - */ |
|
| 1076 | - protected function _insert_or_update_price_type(bool $new_price_type = false) |
|
| 1077 | - { |
|
| 1078 | - // why be so pessimistic ??? : ( |
|
| 1079 | - $success = 0; |
|
| 1080 | - |
|
| 1081 | - $set_column_values = $this->set_price_type_column_values(); |
|
| 1082 | - // is this a new Price ? |
|
| 1083 | - if ($new_price_type) { |
|
| 1084 | - // run the insert |
|
| 1085 | - if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) { |
|
| 1086 | - $success = 1; |
|
| 1087 | - } |
|
| 1088 | - $action_desc = 'created'; |
|
| 1089 | - } else { |
|
| 1090 | - $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
| 1091 | - // run the update |
|
| 1092 | - $where_cols_n_values = ['PRT_ID' => $PRT_ID]; |
|
| 1093 | - if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) { |
|
| 1094 | - $success = 1; |
|
| 1095 | - } |
|
| 1096 | - $action_desc = 'updated'; |
|
| 1097 | - } |
|
| 1098 | - |
|
| 1099 | - $query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID]; |
|
| 1100 | - $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args); |
|
| 1101 | - } |
|
| 1102 | - |
|
| 1103 | - |
|
| 1104 | - /** |
|
| 1105 | - * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 1106 | - * @return void |
|
| 1107 | - * @throws EE_Error |
|
| 1108 | - * @throws ReflectionException |
|
| 1109 | - */ |
|
| 1110 | - protected function _trash_or_restore_price_type(bool $trash = true) |
|
| 1111 | - { |
|
| 1112 | - $entity_model = EEM_Price_Type::instance(); |
|
| 1113 | - $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
| 1114 | - $success = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted'); |
|
| 1115 | - if ($success) { |
|
| 1116 | - $msg = $trash |
|
| 1117 | - ? esc_html( |
|
| 1118 | - _n( |
|
| 1119 | - 'The Price Type has been trashed', |
|
| 1120 | - 'The Price Types have been trashed', |
|
| 1121 | - $success, |
|
| 1122 | - 'event_espresso' |
|
| 1123 | - ) |
|
| 1124 | - ) |
|
| 1125 | - : esc_html( |
|
| 1126 | - _n( |
|
| 1127 | - 'The Price Type has been restored', |
|
| 1128 | - 'The Price Types have been restored', |
|
| 1129 | - $success, |
|
| 1130 | - 'event_espresso' |
|
| 1131 | - ) |
|
| 1132 | - ); |
|
| 1133 | - EE_Error::add_success($msg); |
|
| 1134 | - } |
|
| 1135 | - $this->_redirect_after_action('', '', '', ['action' => 'price_types'], true); |
|
| 1136 | - } |
|
| 1137 | - |
|
| 1138 | - |
|
| 1139 | - /** |
|
| 1140 | - * @return void |
|
| 1141 | - * @throws EE_Error |
|
| 1142 | - * @throws ReflectionException |
|
| 1143 | - */ |
|
| 1144 | - protected function _delete_price_type() |
|
| 1145 | - { |
|
| 1146 | - $entity_model = EEM_Price_Type::instance(); |
|
| 1147 | - $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
| 1148 | - $this->_redirect_after_action( |
|
| 1149 | - $deleted, |
|
| 1150 | - $entity_model->item_name($deleted), |
|
| 1151 | - 'deleted', |
|
| 1152 | - ['action' => 'price_types'] |
|
| 1153 | - ); |
|
| 1154 | - } |
|
| 1155 | - |
|
| 1156 | - |
|
| 1157 | - /** |
|
| 1158 | - * @return string |
|
| 1159 | - */ |
|
| 1160 | - protected function _learn_more_about_pricing_link(): string |
|
| 1161 | - { |
|
| 1162 | - return ' |
|
| 871 | + /** |
|
| 872 | + * generates HTML for main Prices Admin page |
|
| 873 | + * |
|
| 874 | + * @return void |
|
| 875 | + * @throws EE_Error |
|
| 876 | + */ |
|
| 877 | + protected function _price_types_overview_list_table() |
|
| 878 | + { |
|
| 879 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 880 | + 'add_new_price_type', |
|
| 881 | + 'add_type', |
|
| 882 | + [], |
|
| 883 | + 'add-new-h2' |
|
| 884 | + ); |
|
| 885 | + $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
| 886 | + $this->_search_btn_label = esc_html__('Price Types', 'event_espresso'); |
|
| 887 | + $this->display_admin_list_table_page_with_sidebar(); |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + |
|
| 891 | + /** |
|
| 892 | + * retrieve data for Price Types List table |
|
| 893 | + * |
|
| 894 | + * @param int $per_page how many prices displayed per page |
|
| 895 | + * @param bool $count return the count or objects |
|
| 896 | + * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
| 897 | + * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
| 898 | + * @throws EE_Error |
|
| 899 | + * @throws ReflectionException |
|
| 900 | + */ |
|
| 901 | + public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
| 902 | + { |
|
| 903 | + // start with an empty array |
|
| 904 | + require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php'); |
|
| 905 | + |
|
| 906 | + $orderby = $this->request->getRequestParam('orderby', ''); |
|
| 907 | + $order = $this->request->getRequestParam('order', 'ASC'); |
|
| 908 | + |
|
| 909 | + switch ($orderby) { |
|
| 910 | + case 'name': |
|
| 911 | + $orderby = ['PRT_name' => $order]; |
|
| 912 | + break; |
|
| 913 | + default: |
|
| 914 | + $orderby = ['PRT_order' => $order]; |
|
| 915 | + } |
|
| 916 | + |
|
| 917 | + $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
| 918 | + $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
| 919 | + |
|
| 920 | + $offset = ($current_page - 1) * $per_page; |
|
| 921 | + $limit = [$offset, $per_page]; |
|
| 922 | + |
|
| 923 | + $where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]]; |
|
| 924 | + |
|
| 925 | + $search_term = $this->request->getRequestParam('s'); |
|
| 926 | + if ($search_term) { |
|
| 927 | + $where['OR'] = [ |
|
| 928 | + 'PRT_name' => ['LIKE', "%{$search_term}%"], |
|
| 929 | + ]; |
|
| 930 | + } |
|
| 931 | + $query_params = [ |
|
| 932 | + $where, |
|
| 933 | + 'order_by' => $orderby, |
|
| 934 | + 'limit' => $limit, |
|
| 935 | + ]; |
|
| 936 | + return $count |
|
| 937 | + ? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params) |
|
| 938 | + : EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
|
| 939 | + } |
|
| 940 | + |
|
| 941 | + |
|
| 942 | + /** |
|
| 943 | + * _edit_price_type_details |
|
| 944 | + * |
|
| 945 | + * @return void |
|
| 946 | + * @throws EE_Error |
|
| 947 | + * @throws ReflectionException |
|
| 948 | + */ |
|
| 949 | + protected function _edit_price_type_details() |
|
| 950 | + { |
|
| 951 | + // grab price type ID |
|
| 952 | + $PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
| 953 | + // change page title based on request action |
|
| 954 | + switch ($this->_req_action) { |
|
| 955 | + case 'add_new_price_type': |
|
| 956 | + $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso'); |
|
| 957 | + break; |
|
| 958 | + case 'edit_price_type': |
|
| 959 | + $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso'); |
|
| 960 | + break; |
|
| 961 | + default: |
|
| 962 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
| 963 | + } |
|
| 964 | + // add PRT_ID to title if editing |
|
| 965 | + $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title; |
|
| 966 | + |
|
| 967 | + if ($PRT_ID) { |
|
| 968 | + $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
| 969 | + $additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]]; |
|
| 970 | + $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields); |
|
| 971 | + } else { |
|
| 972 | + $price_type = EEM_Price_Type::instance()->get_new_price_type(); |
|
| 973 | + $this->_set_add_edit_form_tags('insert_price_type'); |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + if (! $price_type instanceof EE_Price_Type) { |
|
| 977 | + throw new RuntimeException( |
|
| 978 | + sprintf( |
|
| 979 | + esc_html__( |
|
| 980 | + 'A valid Price Type could not be retrieved from the database with ID: %1$s', |
|
| 981 | + 'event_espresso' |
|
| 982 | + ), |
|
| 983 | + $PRT_ID |
|
| 984 | + ) |
|
| 985 | + ); |
|
| 986 | + } |
|
| 987 | + |
|
| 988 | + $this->_template_args['PRT_ID'] = $PRT_ID; |
|
| 989 | + $this->_template_args['price_type'] = $price_type; |
|
| 990 | + |
|
| 991 | + $base_types = EEM_Price_Type::instance()->get_base_types(); |
|
| 992 | + $select_values = []; |
|
| 993 | + foreach ($base_types as $ref => $text) { |
|
| 994 | + if ($ref == EEM_Price_Type::base_type_base_price) { |
|
| 995 | + // do not allow creation of base_type_base_prices because that's a system only base type. |
|
| 996 | + continue; |
|
| 997 | + } |
|
| 998 | + $select_values[] = ['id' => $ref, 'text' => $text]; |
|
| 999 | + } |
|
| 1000 | + |
|
| 1001 | + $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input( |
|
| 1002 | + 'base_type', |
|
| 1003 | + $select_values, |
|
| 1004 | + $price_type->base_type(), |
|
| 1005 | + 'id="price-type-base-type-slct"' |
|
| 1006 | + ); |
|
| 1007 | + |
|
| 1008 | + $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
| 1009 | + $this->_template_args['admin_page_content'] = $this->_edit_price_type_details_meta_box(); |
|
| 1010 | + |
|
| 1011 | + $redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url); |
|
| 1012 | + $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL); |
|
| 1013 | + // the details template wrapper |
|
| 1014 | + $this->display_admin_page_with_sidebar(); |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + |
|
| 1018 | + /** |
|
| 1019 | + * _edit_price_type_details_meta_box |
|
| 1020 | + * |
|
| 1021 | + * @return string |
|
| 1022 | + */ |
|
| 1023 | + public function _edit_price_type_details_meta_box(): string |
|
| 1024 | + { |
|
| 1025 | + return EEH_Template::display_template( |
|
| 1026 | + PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php', |
|
| 1027 | + $this->_template_args, |
|
| 1028 | + true |
|
| 1029 | + ); |
|
| 1030 | + } |
|
| 1031 | + |
|
| 1032 | + |
|
| 1033 | + /** |
|
| 1034 | + * @return array |
|
| 1035 | + */ |
|
| 1036 | + protected function set_price_type_column_values(): array |
|
| 1037 | + { |
|
| 1038 | + $base_type = $this->request->getRequestParam( |
|
| 1039 | + 'base_type', |
|
| 1040 | + EEM_Price_Type::base_type_base_price, |
|
| 1041 | + DataType::INTEGER |
|
| 1042 | + ); |
|
| 1043 | + $is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER); |
|
| 1044 | + $order = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER); |
|
| 1045 | + switch ($base_type) { |
|
| 1046 | + case EEM_Price_Type::base_type_base_price: |
|
| 1047 | + $is_percent = 0; |
|
| 1048 | + $order = 0; |
|
| 1049 | + break; |
|
| 1050 | + |
|
| 1051 | + case EEM_Price_Type::base_type_discount: |
|
| 1052 | + case EEM_Price_Type::base_type_surcharge: |
|
| 1053 | + break; |
|
| 1054 | + |
|
| 1055 | + case EEM_Price_Type::base_type_tax: |
|
| 1056 | + $is_percent = 1; |
|
| 1057 | + break; |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + return [ |
|
| 1061 | + 'PBT_ID' => $base_type, |
|
| 1062 | + 'PRT_name' => $this->request->getRequestParam('PRT_name', ''), |
|
| 1063 | + 'PRT_is_percent' => $is_percent, |
|
| 1064 | + 'PRT_order' => $order, |
|
| 1065 | + 'PRT_deleted' => 0, |
|
| 1066 | + ]; |
|
| 1067 | + } |
|
| 1068 | + |
|
| 1069 | + |
|
| 1070 | + /** |
|
| 1071 | + * @param bool $new_price_type - whether to insert or update |
|
| 1072 | + * @return void |
|
| 1073 | + * @throws EE_Error |
|
| 1074 | + * @throws ReflectionException |
|
| 1075 | + */ |
|
| 1076 | + protected function _insert_or_update_price_type(bool $new_price_type = false) |
|
| 1077 | + { |
|
| 1078 | + // why be so pessimistic ??? : ( |
|
| 1079 | + $success = 0; |
|
| 1080 | + |
|
| 1081 | + $set_column_values = $this->set_price_type_column_values(); |
|
| 1082 | + // is this a new Price ? |
|
| 1083 | + if ($new_price_type) { |
|
| 1084 | + // run the insert |
|
| 1085 | + if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) { |
|
| 1086 | + $success = 1; |
|
| 1087 | + } |
|
| 1088 | + $action_desc = 'created'; |
|
| 1089 | + } else { |
|
| 1090 | + $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
| 1091 | + // run the update |
|
| 1092 | + $where_cols_n_values = ['PRT_ID' => $PRT_ID]; |
|
| 1093 | + if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) { |
|
| 1094 | + $success = 1; |
|
| 1095 | + } |
|
| 1096 | + $action_desc = 'updated'; |
|
| 1097 | + } |
|
| 1098 | + |
|
| 1099 | + $query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID]; |
|
| 1100 | + $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args); |
|
| 1101 | + } |
|
| 1102 | + |
|
| 1103 | + |
|
| 1104 | + /** |
|
| 1105 | + * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 1106 | + * @return void |
|
| 1107 | + * @throws EE_Error |
|
| 1108 | + * @throws ReflectionException |
|
| 1109 | + */ |
|
| 1110 | + protected function _trash_or_restore_price_type(bool $trash = true) |
|
| 1111 | + { |
|
| 1112 | + $entity_model = EEM_Price_Type::instance(); |
|
| 1113 | + $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
| 1114 | + $success = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted'); |
|
| 1115 | + if ($success) { |
|
| 1116 | + $msg = $trash |
|
| 1117 | + ? esc_html( |
|
| 1118 | + _n( |
|
| 1119 | + 'The Price Type has been trashed', |
|
| 1120 | + 'The Price Types have been trashed', |
|
| 1121 | + $success, |
|
| 1122 | + 'event_espresso' |
|
| 1123 | + ) |
|
| 1124 | + ) |
|
| 1125 | + : esc_html( |
|
| 1126 | + _n( |
|
| 1127 | + 'The Price Type has been restored', |
|
| 1128 | + 'The Price Types have been restored', |
|
| 1129 | + $success, |
|
| 1130 | + 'event_espresso' |
|
| 1131 | + ) |
|
| 1132 | + ); |
|
| 1133 | + EE_Error::add_success($msg); |
|
| 1134 | + } |
|
| 1135 | + $this->_redirect_after_action('', '', '', ['action' => 'price_types'], true); |
|
| 1136 | + } |
|
| 1137 | + |
|
| 1138 | + |
|
| 1139 | + /** |
|
| 1140 | + * @return void |
|
| 1141 | + * @throws EE_Error |
|
| 1142 | + * @throws ReflectionException |
|
| 1143 | + */ |
|
| 1144 | + protected function _delete_price_type() |
|
| 1145 | + { |
|
| 1146 | + $entity_model = EEM_Price_Type::instance(); |
|
| 1147 | + $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
| 1148 | + $this->_redirect_after_action( |
|
| 1149 | + $deleted, |
|
| 1150 | + $entity_model->item_name($deleted), |
|
| 1151 | + 'deleted', |
|
| 1152 | + ['action' => 'price_types'] |
|
| 1153 | + ); |
|
| 1154 | + } |
|
| 1155 | + |
|
| 1156 | + |
|
| 1157 | + /** |
|
| 1158 | + * @return string |
|
| 1159 | + */ |
|
| 1160 | + protected function _learn_more_about_pricing_link(): string |
|
| 1161 | + { |
|
| 1162 | + return ' |
|
| 1163 | 1163 | <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" > |
| 1164 | 1164 | ' . esc_html__('learn more about how pricing works', 'event_espresso') . ' |
| 1165 | 1165 | </a>'; |
| 1166 | - } |
|
| 1167 | - |
|
| 1168 | - |
|
| 1169 | - /** |
|
| 1170 | - * @throws EE_Error |
|
| 1171 | - */ |
|
| 1172 | - protected function _tax_settings() |
|
| 1173 | - { |
|
| 1174 | - $this->_set_add_edit_form_tags('update_tax_settings'); |
|
| 1175 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 1176 | - $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html(); |
|
| 1177 | - $this->display_admin_page_with_sidebar(); |
|
| 1178 | - } |
|
| 1179 | - |
|
| 1180 | - |
|
| 1181 | - /** |
|
| 1182 | - * @return EE_Form_Section_Proper |
|
| 1183 | - * @throws EE_Error |
|
| 1184 | - */ |
|
| 1185 | - protected function tax_settings_form(): EE_Form_Section_Proper |
|
| 1186 | - { |
|
| 1187 | - $tax_settings = EE_Config::instance()->tax_settings; |
|
| 1188 | - return new EE_Form_Section_Proper( |
|
| 1189 | - [ |
|
| 1190 | - 'name' => 'tax_settings_form', |
|
| 1191 | - 'html_id' => 'tax_settings_form', |
|
| 1192 | - 'html_class' => 'padding', |
|
| 1193 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1194 | - 'subsections' => apply_filters( |
|
| 1195 | - 'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections', |
|
| 1196 | - [ |
|
| 1197 | - 'tax_settings' => new EE_Form_Section_Proper( |
|
| 1198 | - [ |
|
| 1199 | - 'name' => 'tax_settings_tbl', |
|
| 1200 | - 'html_id' => 'tax_settings_tbl', |
|
| 1201 | - 'html_class' => 'form-table', |
|
| 1202 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1203 | - 'subsections' => [ |
|
| 1204 | - 'prices_displayed_including_taxes' => new EE_Yes_No_Input( |
|
| 1205 | - [ |
|
| 1206 | - 'html_label_text' => esc_html__( |
|
| 1207 | - 'Show Prices With Taxes Included?', |
|
| 1208 | - 'event_espresso' |
|
| 1209 | - ), |
|
| 1210 | - 'html_help_text' => esc_html__( |
|
| 1211 | - 'Indicates whether or not to display prices with the taxes included', |
|
| 1212 | - 'event_espresso' |
|
| 1213 | - ), |
|
| 1214 | - 'default' => $tax_settings->prices_displayed_including_taxes |
|
| 1215 | - ?? true, |
|
| 1216 | - 'display_html_label_text' => false, |
|
| 1217 | - ] |
|
| 1218 | - ), |
|
| 1219 | - ], |
|
| 1220 | - ] |
|
| 1221 | - ), |
|
| 1222 | - ] |
|
| 1223 | - ), |
|
| 1224 | - ] |
|
| 1225 | - ); |
|
| 1226 | - } |
|
| 1227 | - |
|
| 1228 | - |
|
| 1229 | - /** |
|
| 1230 | - * _update_tax_settings |
|
| 1231 | - * |
|
| 1232 | - * @return void |
|
| 1233 | - * @throws EE_Error |
|
| 1234 | - * @throws ReflectionException |
|
| 1235 | - * @since 4.9.13 |
|
| 1236 | - */ |
|
| 1237 | - public function _update_tax_settings() |
|
| 1238 | - { |
|
| 1239 | - $tax_settings = EE_Config::instance()->tax_settings; |
|
| 1240 | - if (! $tax_settings instanceof EE_Tax_Config) { |
|
| 1241 | - $tax_settings = new EE_Tax_Config(); |
|
| 1242 | - } |
|
| 1243 | - try { |
|
| 1244 | - $tax_form = $this->tax_settings_form(); |
|
| 1245 | - // check for form submission |
|
| 1246 | - if ($tax_form->was_submitted()) { |
|
| 1247 | - // capture form data |
|
| 1248 | - $tax_form->receive_form_submission(); |
|
| 1249 | - // validate form data |
|
| 1250 | - if ($tax_form->is_valid()) { |
|
| 1251 | - // grab validated data from form |
|
| 1252 | - $valid_data = $tax_form->valid_data(); |
|
| 1253 | - // set data on config |
|
| 1254 | - $tax_settings->prices_displayed_including_taxes = |
|
| 1255 | - $valid_data['tax_settings']['prices_displayed_including_taxes']; |
|
| 1256 | - } else { |
|
| 1257 | - if ($tax_form->submission_error_message() !== '') { |
|
| 1258 | - EE_Error::add_error( |
|
| 1259 | - $tax_form->submission_error_message(), |
|
| 1260 | - __FILE__, |
|
| 1261 | - __FUNCTION__, |
|
| 1262 | - __LINE__ |
|
| 1263 | - ); |
|
| 1264 | - } |
|
| 1265 | - } |
|
| 1266 | - } |
|
| 1267 | - } catch (EE_Error $e) { |
|
| 1268 | - EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1269 | - } |
|
| 1270 | - |
|
| 1271 | - $what = 'Tax Settings'; |
|
| 1272 | - $success = $this->_update_espresso_configuration( |
|
| 1273 | - $what, |
|
| 1274 | - $tax_settings, |
|
| 1275 | - __FILE__, |
|
| 1276 | - __FUNCTION__, |
|
| 1277 | - __LINE__ |
|
| 1278 | - ); |
|
| 1279 | - $this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']); |
|
| 1280 | - } |
|
| 1166 | + } |
|
| 1167 | + |
|
| 1168 | + |
|
| 1169 | + /** |
|
| 1170 | + * @throws EE_Error |
|
| 1171 | + */ |
|
| 1172 | + protected function _tax_settings() |
|
| 1173 | + { |
|
| 1174 | + $this->_set_add_edit_form_tags('update_tax_settings'); |
|
| 1175 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 1176 | + $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html(); |
|
| 1177 | + $this->display_admin_page_with_sidebar(); |
|
| 1178 | + } |
|
| 1179 | + |
|
| 1180 | + |
|
| 1181 | + /** |
|
| 1182 | + * @return EE_Form_Section_Proper |
|
| 1183 | + * @throws EE_Error |
|
| 1184 | + */ |
|
| 1185 | + protected function tax_settings_form(): EE_Form_Section_Proper |
|
| 1186 | + { |
|
| 1187 | + $tax_settings = EE_Config::instance()->tax_settings; |
|
| 1188 | + return new EE_Form_Section_Proper( |
|
| 1189 | + [ |
|
| 1190 | + 'name' => 'tax_settings_form', |
|
| 1191 | + 'html_id' => 'tax_settings_form', |
|
| 1192 | + 'html_class' => 'padding', |
|
| 1193 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1194 | + 'subsections' => apply_filters( |
|
| 1195 | + 'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections', |
|
| 1196 | + [ |
|
| 1197 | + 'tax_settings' => new EE_Form_Section_Proper( |
|
| 1198 | + [ |
|
| 1199 | + 'name' => 'tax_settings_tbl', |
|
| 1200 | + 'html_id' => 'tax_settings_tbl', |
|
| 1201 | + 'html_class' => 'form-table', |
|
| 1202 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1203 | + 'subsections' => [ |
|
| 1204 | + 'prices_displayed_including_taxes' => new EE_Yes_No_Input( |
|
| 1205 | + [ |
|
| 1206 | + 'html_label_text' => esc_html__( |
|
| 1207 | + 'Show Prices With Taxes Included?', |
|
| 1208 | + 'event_espresso' |
|
| 1209 | + ), |
|
| 1210 | + 'html_help_text' => esc_html__( |
|
| 1211 | + 'Indicates whether or not to display prices with the taxes included', |
|
| 1212 | + 'event_espresso' |
|
| 1213 | + ), |
|
| 1214 | + 'default' => $tax_settings->prices_displayed_including_taxes |
|
| 1215 | + ?? true, |
|
| 1216 | + 'display_html_label_text' => false, |
|
| 1217 | + ] |
|
| 1218 | + ), |
|
| 1219 | + ], |
|
| 1220 | + ] |
|
| 1221 | + ), |
|
| 1222 | + ] |
|
| 1223 | + ), |
|
| 1224 | + ] |
|
| 1225 | + ); |
|
| 1226 | + } |
|
| 1227 | + |
|
| 1228 | + |
|
| 1229 | + /** |
|
| 1230 | + * _update_tax_settings |
|
| 1231 | + * |
|
| 1232 | + * @return void |
|
| 1233 | + * @throws EE_Error |
|
| 1234 | + * @throws ReflectionException |
|
| 1235 | + * @since 4.9.13 |
|
| 1236 | + */ |
|
| 1237 | + public function _update_tax_settings() |
|
| 1238 | + { |
|
| 1239 | + $tax_settings = EE_Config::instance()->tax_settings; |
|
| 1240 | + if (! $tax_settings instanceof EE_Tax_Config) { |
|
| 1241 | + $tax_settings = new EE_Tax_Config(); |
|
| 1242 | + } |
|
| 1243 | + try { |
|
| 1244 | + $tax_form = $this->tax_settings_form(); |
|
| 1245 | + // check for form submission |
|
| 1246 | + if ($tax_form->was_submitted()) { |
|
| 1247 | + // capture form data |
|
| 1248 | + $tax_form->receive_form_submission(); |
|
| 1249 | + // validate form data |
|
| 1250 | + if ($tax_form->is_valid()) { |
|
| 1251 | + // grab validated data from form |
|
| 1252 | + $valid_data = $tax_form->valid_data(); |
|
| 1253 | + // set data on config |
|
| 1254 | + $tax_settings->prices_displayed_including_taxes = |
|
| 1255 | + $valid_data['tax_settings']['prices_displayed_including_taxes']; |
|
| 1256 | + } else { |
|
| 1257 | + if ($tax_form->submission_error_message() !== '') { |
|
| 1258 | + EE_Error::add_error( |
|
| 1259 | + $tax_form->submission_error_message(), |
|
| 1260 | + __FILE__, |
|
| 1261 | + __FUNCTION__, |
|
| 1262 | + __LINE__ |
|
| 1263 | + ); |
|
| 1264 | + } |
|
| 1265 | + } |
|
| 1266 | + } |
|
| 1267 | + } catch (EE_Error $e) { |
|
| 1268 | + EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1269 | + } |
|
| 1270 | + |
|
| 1271 | + $what = 'Tax Settings'; |
|
| 1272 | + $success = $this->_update_espresso_configuration( |
|
| 1273 | + $what, |
|
| 1274 | + $tax_settings, |
|
| 1275 | + __FILE__, |
|
| 1276 | + __FUNCTION__, |
|
| 1277 | + __LINE__ |
|
| 1278 | + ); |
|
| 1279 | + $this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']); |
|
| 1280 | + } |
|
| 1281 | 1281 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (! class_exists('WP_List_Table')) { |
| 4 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 4 | + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -19,891 +19,891 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | abstract class EE_Admin_List_Table extends WP_List_Table |
| 21 | 21 | { |
| 22 | - const ACTION_COPY = 'duplicate'; |
|
| 23 | - |
|
| 24 | - const ACTION_DELETE = 'delete'; |
|
| 25 | - |
|
| 26 | - const ACTION_EDIT = 'edit'; |
|
| 27 | - |
|
| 28 | - const ACTION_RESTORE = 'restore'; |
|
| 29 | - |
|
| 30 | - const ACTION_TRASH = 'trash'; |
|
| 31 | - |
|
| 32 | - protected static $actions = [ |
|
| 33 | - self::ACTION_COPY, |
|
| 34 | - self::ACTION_DELETE, |
|
| 35 | - self::ACTION_EDIT, |
|
| 36 | - self::ACTION_RESTORE, |
|
| 37 | - self::ACTION_TRASH, |
|
| 38 | - ]; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * holds the data that will be processed for the table |
|
| 42 | - * |
|
| 43 | - * @var array $_data |
|
| 44 | - */ |
|
| 45 | - protected $_data; |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * This holds the value of all the data available for the given view (for all pages). |
|
| 50 | - * |
|
| 51 | - * @var int $_all_data_count |
|
| 52 | - */ |
|
| 53 | - protected $_all_data_count; |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Will contain the count of trashed items for the view label. |
|
| 58 | - * |
|
| 59 | - * @var int $_trashed_count |
|
| 60 | - */ |
|
| 61 | - protected $_trashed_count; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * This is what will be referenced as the slug for the current screen |
|
| 66 | - * |
|
| 67 | - * @var string $_screen |
|
| 68 | - */ |
|
| 69 | - protected $_screen; |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * this is the EE_Admin_Page object |
|
| 74 | - * |
|
| 75 | - * @var EE_Admin_Page $_admin_page |
|
| 76 | - */ |
|
| 77 | - protected $_admin_page; |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * The current view |
|
| 82 | - * |
|
| 83 | - * @var string $_view |
|
| 84 | - */ |
|
| 85 | - protected $_view; |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * array of possible views for this table |
|
| 90 | - * |
|
| 91 | - * @var array $_views |
|
| 92 | - */ |
|
| 93 | - protected $_views; |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * An array of key => value pairs containing information about the current table |
|
| 98 | - * array( |
|
| 99 | - * 'plural' => 'plural label', |
|
| 100 | - * 'singular' => 'singular label', |
|
| 101 | - * 'ajax' => false, //whether to use ajax or not |
|
| 102 | - * 'screen' => null, //string used to reference what screen this is |
|
| 103 | - * (WP_List_table converts to screen object) |
|
| 104 | - * ) |
|
| 105 | - * |
|
| 106 | - * @var array $_wp_list_args |
|
| 107 | - */ |
|
| 108 | - protected $_wp_list_args; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * an array of column names |
|
| 112 | - * array( |
|
| 113 | - * 'internal-name' => 'Title' |
|
| 114 | - * ) |
|
| 115 | - * |
|
| 116 | - * @var array $_columns |
|
| 117 | - */ |
|
| 118 | - protected $_columns; |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * An array of sortable columns |
|
| 122 | - * array( |
|
| 123 | - * 'internal-name' => 'orderby' //or |
|
| 124 | - * 'internal-name' => array( 'orderby', true ) |
|
| 125 | - * ) |
|
| 126 | - * |
|
| 127 | - * @var array $_sortable_columns |
|
| 128 | - */ |
|
| 129 | - protected $_sortable_columns; |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * callback method used to perform AJAX row reordering |
|
| 133 | - * |
|
| 134 | - * @var string $_ajax_sorting_callback |
|
| 135 | - */ |
|
| 136 | - protected $_ajax_sorting_callback; |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * An array of hidden columns (if needed) |
|
| 140 | - * array('internal-name', 'internal-name') |
|
| 141 | - * |
|
| 142 | - * @var array $_hidden_columns |
|
| 143 | - */ |
|
| 144 | - protected $_hidden_columns; |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * holds the per_page value |
|
| 148 | - * |
|
| 149 | - * @var int $_per_page |
|
| 150 | - */ |
|
| 151 | - protected $_per_page; |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * holds what page number is currently being viewed |
|
| 155 | - * |
|
| 156 | - * @var int $_current_page |
|
| 157 | - */ |
|
| 158 | - protected $_current_page; |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * the reference string for the nonce_action |
|
| 162 | - * |
|
| 163 | - * @var string $_nonce_action_ref |
|
| 164 | - */ |
|
| 165 | - protected $_nonce_action_ref; |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * property to hold incoming request data (as set by the admin_page_core) |
|
| 169 | - * |
|
| 170 | - * @var array $_req_data |
|
| 171 | - */ |
|
| 172 | - protected $_req_data; |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * yes / no array for admin form fields |
|
| 177 | - * |
|
| 178 | - * @var array $_yes_no |
|
| 179 | - */ |
|
| 180 | - protected $_yes_no = []; |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Array describing buttons that should appear at the bottom of the page |
|
| 184 | - * Keys are strings that represent the button's function (specifically a key in _labels['buttons']), |
|
| 185 | - * and the values are another array with the following keys |
|
| 186 | - * array( |
|
| 187 | - * 'route' => 'page_route', |
|
| 188 | - * 'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button. |
|
| 189 | - * ) |
|
| 190 | - * |
|
| 191 | - * @var array $_bottom_buttons |
|
| 192 | - */ |
|
| 193 | - protected $_bottom_buttons = []; |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Used to indicate what should be the primary column for the list table. |
|
| 198 | - * If not present then falls back to what WP calculates |
|
| 199 | - * as the primary column. |
|
| 200 | - * |
|
| 201 | - * @type string $_primary_column |
|
| 202 | - */ |
|
| 203 | - protected $_primary_column = ''; |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Used to indicate whether the table has a checkbox column or not. |
|
| 208 | - * |
|
| 209 | - * @type bool $_has_checkbox_column |
|
| 210 | - */ |
|
| 211 | - protected $_has_checkbox_column = false; |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table |
|
| 216 | - */ |
|
| 217 | - public function __construct(EE_Admin_Page $admin_page) |
|
| 218 | - { |
|
| 219 | - $this->_admin_page = $admin_page; |
|
| 220 | - $this->_req_data = $this->_admin_page->get_request_data(); |
|
| 221 | - $this->_view = $this->_admin_page->get_view(); |
|
| 222 | - $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
| 223 | - $this->_current_page = $this->get_pagenum(); |
|
| 224 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
| 225 | - $this->_yes_no = [ |
|
| 226 | - esc_html__('No', 'event_espresso'), |
|
| 227 | - esc_html__('Yes', 'event_espresso') |
|
| 228 | - ]; |
|
| 229 | - |
|
| 230 | - $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page'); |
|
| 231 | - |
|
| 232 | - $this->_setup_data(); |
|
| 233 | - $this->_add_view_counts(); |
|
| 234 | - |
|
| 235 | - $this->_nonce_action_ref = $this->_view; |
|
| 236 | - |
|
| 237 | - $this->_set_properties(); |
|
| 238 | - |
|
| 239 | - // set primary column |
|
| 240 | - add_filter('list_table_primary_column', [$this, 'set_primary_column']); |
|
| 241 | - |
|
| 242 | - // set parent defaults |
|
| 243 | - parent::__construct($this->_wp_list_args); |
|
| 244 | - |
|
| 245 | - $this->prepare_items(); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * _setup_data |
|
| 251 | - * this method is used to setup the $_data, $_all_data_count, and _per_page properties |
|
| 252 | - * |
|
| 253 | - * @return void |
|
| 254 | - * @uses $this->_admin_page |
|
| 255 | - */ |
|
| 256 | - abstract protected function _setup_data(); |
|
| 257 | - |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * set the properties that this class needs to be able to execute wp_list_table properly |
|
| 261 | - * properties set: |
|
| 262 | - * _wp_list_args = what the arguments required for the parent _wp_list_table. |
|
| 263 | - * _columns = set the columns in an array. |
|
| 264 | - * _sortable_columns = columns that are sortable (array). |
|
| 265 | - * _hidden_columns = columns that are hidden (array) |
|
| 266 | - * _default_orderby = the default orderby for sorting. |
|
| 267 | - * |
|
| 268 | - * @abstract |
|
| 269 | - * @access protected |
|
| 270 | - * @return void |
|
| 271 | - */ |
|
| 272 | - abstract protected function _set_properties(); |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * _get_table_filters |
|
| 277 | - * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 278 | - * gets shown in the table. |
|
| 279 | - * |
|
| 280 | - * @abstract |
|
| 281 | - * @access protected |
|
| 282 | - * @return string |
|
| 283 | - */ |
|
| 284 | - abstract protected function _get_table_filters(); |
|
| 285 | - |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * this is a method that child class will do to add counts to the views array so when views are displayed the |
|
| 289 | - * counts of the views is accurate. |
|
| 290 | - * |
|
| 291 | - * @abstract |
|
| 292 | - * @access protected |
|
| 293 | - * @return void |
|
| 294 | - */ |
|
| 295 | - abstract protected function _add_view_counts(); |
|
| 296 | - |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * _get_hidden_fields |
|
| 300 | - * returns a html string of hidden fields so if any table filters are used the current view will be respected. |
|
| 301 | - * |
|
| 302 | - * @return string |
|
| 303 | - */ |
|
| 304 | - protected function _get_hidden_fields() |
|
| 305 | - { |
|
| 306 | - $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
| 307 | - $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
| 308 | - // if action is STILL empty, then we set it to default |
|
| 309 | - $action = empty($action) ? 'default' : $action; |
|
| 310 | - $field = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n"; |
|
| 311 | - $field .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n"; |
|
| 312 | - $field .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n"; |
|
| 313 | - |
|
| 314 | - $bulk_actions = $this->_get_bulk_actions(); |
|
| 315 | - foreach ($bulk_actions as $bulk_action => $label) { |
|
| 316 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"' |
|
| 317 | - . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n"; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - return $field; |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * _set_column_info |
|
| 326 | - * we're using this to set the column headers property. |
|
| 327 | - * |
|
| 328 | - * @access protected |
|
| 329 | - * @return void |
|
| 330 | - */ |
|
| 331 | - protected function _set_column_info() |
|
| 332 | - { |
|
| 333 | - $columns = $this->get_columns(); |
|
| 334 | - $hidden = $this->get_hidden_columns(); |
|
| 335 | - $_sortable = $this->get_sortable_columns(); |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * Dynamic hook allowing for adding sortable columns in this list table. |
|
| 339 | - * Note that $this->screen->id is in the format |
|
| 340 | - * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
| 341 | - * table it is: event-espresso_page_espresso_messages. |
|
| 342 | - * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
| 343 | - * hook prefix ("event-espresso") will be different. |
|
| 344 | - * |
|
| 345 | - * @var array |
|
| 346 | - */ |
|
| 347 | - $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
| 348 | - |
|
| 349 | - $sortable = []; |
|
| 350 | - foreach ($_sortable as $id => $data) { |
|
| 351 | - if (empty($data)) { |
|
| 352 | - continue; |
|
| 353 | - } |
|
| 354 | - // fix for offset errors with WP_List_Table default get_columninfo() |
|
| 355 | - if (is_array($data)) { |
|
| 356 | - $_data[0] = key($data); |
|
| 357 | - $_data[1] = isset($data[1]) ? $data[1] : false; |
|
| 358 | - } else { |
|
| 359 | - $_data[0] = $data; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - $data = (array) $data; |
|
| 363 | - |
|
| 364 | - if (! isset($data[1])) { |
|
| 365 | - $_data[1] = false; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - $sortable[ $id ] = $_data; |
|
| 369 | - } |
|
| 370 | - $primary = $this->get_primary_column_name(); |
|
| 371 | - $this->_column_headers = [$columns, $hidden, $sortable, $primary]; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
| 377 | - * |
|
| 378 | - * @return string |
|
| 379 | - */ |
|
| 380 | - protected function get_primary_column_name() |
|
| 381 | - { |
|
| 382 | - foreach (class_parents($this) as $parent) { |
|
| 383 | - if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) { |
|
| 384 | - return parent::get_primary_column_name(); |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - return $this->_primary_column; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
| 393 | - * |
|
| 394 | - * @param EE_Base_Class $item |
|
| 395 | - * @param string $column_name |
|
| 396 | - * @param string $primary |
|
| 397 | - * @return string |
|
| 398 | - */ |
|
| 399 | - protected function handle_row_actions($item, $column_name, $primary) |
|
| 400 | - { |
|
| 401 | - foreach (class_parents($this) as $parent) { |
|
| 402 | - if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) { |
|
| 403 | - return parent::handle_row_actions($item, $column_name, $primary); |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - return ''; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * _get_bulk_actions |
|
| 412 | - * This is a wrapper called by WP_List_Table::get_bulk_actions() |
|
| 413 | - * |
|
| 414 | - * @access protected |
|
| 415 | - * @return array bulk_actions |
|
| 416 | - */ |
|
| 417 | - protected function _get_bulk_actions() |
|
| 418 | - { |
|
| 419 | - $actions = []; |
|
| 420 | - // the _views property should have the bulk_actions, so let's go through and extract them into a properly |
|
| 421 | - // formatted array for the wp_list_table(); |
|
| 422 | - foreach ($this->_views as $view => $args) { |
|
| 423 | - if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) { |
|
| 424 | - // each bulk action will correspond with a admin page route, so we can check whatever the capability is |
|
| 425 | - // for that page route and skip adding the bulk action if no access for the current logged in user. |
|
| 426 | - foreach ($args['bulk_action'] as $route => $label) { |
|
| 427 | - if ($this->_admin_page->check_user_access($route, true)) { |
|
| 428 | - $actions[ $route ] = $label; |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - return $actions; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - /** |
|
| 438 | - * Generate the table navigation above or below the table. |
|
| 439 | - * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions. |
|
| 440 | - * |
|
| 441 | - * @throws EE_Error |
|
| 442 | - * @since 4.9.44.rc.001 |
|
| 443 | - */ |
|
| 444 | - public function display_tablenav($which) |
|
| 445 | - { |
|
| 446 | - if ('top' === $which) { |
|
| 447 | - wp_nonce_field('bulk-' . $this->_args['plural']); |
|
| 448 | - } |
|
| 449 | - ?> |
|
| 22 | + const ACTION_COPY = 'duplicate'; |
|
| 23 | + |
|
| 24 | + const ACTION_DELETE = 'delete'; |
|
| 25 | + |
|
| 26 | + const ACTION_EDIT = 'edit'; |
|
| 27 | + |
|
| 28 | + const ACTION_RESTORE = 'restore'; |
|
| 29 | + |
|
| 30 | + const ACTION_TRASH = 'trash'; |
|
| 31 | + |
|
| 32 | + protected static $actions = [ |
|
| 33 | + self::ACTION_COPY, |
|
| 34 | + self::ACTION_DELETE, |
|
| 35 | + self::ACTION_EDIT, |
|
| 36 | + self::ACTION_RESTORE, |
|
| 37 | + self::ACTION_TRASH, |
|
| 38 | + ]; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * holds the data that will be processed for the table |
|
| 42 | + * |
|
| 43 | + * @var array $_data |
|
| 44 | + */ |
|
| 45 | + protected $_data; |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * This holds the value of all the data available for the given view (for all pages). |
|
| 50 | + * |
|
| 51 | + * @var int $_all_data_count |
|
| 52 | + */ |
|
| 53 | + protected $_all_data_count; |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Will contain the count of trashed items for the view label. |
|
| 58 | + * |
|
| 59 | + * @var int $_trashed_count |
|
| 60 | + */ |
|
| 61 | + protected $_trashed_count; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * This is what will be referenced as the slug for the current screen |
|
| 66 | + * |
|
| 67 | + * @var string $_screen |
|
| 68 | + */ |
|
| 69 | + protected $_screen; |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * this is the EE_Admin_Page object |
|
| 74 | + * |
|
| 75 | + * @var EE_Admin_Page $_admin_page |
|
| 76 | + */ |
|
| 77 | + protected $_admin_page; |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * The current view |
|
| 82 | + * |
|
| 83 | + * @var string $_view |
|
| 84 | + */ |
|
| 85 | + protected $_view; |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * array of possible views for this table |
|
| 90 | + * |
|
| 91 | + * @var array $_views |
|
| 92 | + */ |
|
| 93 | + protected $_views; |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * An array of key => value pairs containing information about the current table |
|
| 98 | + * array( |
|
| 99 | + * 'plural' => 'plural label', |
|
| 100 | + * 'singular' => 'singular label', |
|
| 101 | + * 'ajax' => false, //whether to use ajax or not |
|
| 102 | + * 'screen' => null, //string used to reference what screen this is |
|
| 103 | + * (WP_List_table converts to screen object) |
|
| 104 | + * ) |
|
| 105 | + * |
|
| 106 | + * @var array $_wp_list_args |
|
| 107 | + */ |
|
| 108 | + protected $_wp_list_args; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * an array of column names |
|
| 112 | + * array( |
|
| 113 | + * 'internal-name' => 'Title' |
|
| 114 | + * ) |
|
| 115 | + * |
|
| 116 | + * @var array $_columns |
|
| 117 | + */ |
|
| 118 | + protected $_columns; |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * An array of sortable columns |
|
| 122 | + * array( |
|
| 123 | + * 'internal-name' => 'orderby' //or |
|
| 124 | + * 'internal-name' => array( 'orderby', true ) |
|
| 125 | + * ) |
|
| 126 | + * |
|
| 127 | + * @var array $_sortable_columns |
|
| 128 | + */ |
|
| 129 | + protected $_sortable_columns; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * callback method used to perform AJAX row reordering |
|
| 133 | + * |
|
| 134 | + * @var string $_ajax_sorting_callback |
|
| 135 | + */ |
|
| 136 | + protected $_ajax_sorting_callback; |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * An array of hidden columns (if needed) |
|
| 140 | + * array('internal-name', 'internal-name') |
|
| 141 | + * |
|
| 142 | + * @var array $_hidden_columns |
|
| 143 | + */ |
|
| 144 | + protected $_hidden_columns; |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * holds the per_page value |
|
| 148 | + * |
|
| 149 | + * @var int $_per_page |
|
| 150 | + */ |
|
| 151 | + protected $_per_page; |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * holds what page number is currently being viewed |
|
| 155 | + * |
|
| 156 | + * @var int $_current_page |
|
| 157 | + */ |
|
| 158 | + protected $_current_page; |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * the reference string for the nonce_action |
|
| 162 | + * |
|
| 163 | + * @var string $_nonce_action_ref |
|
| 164 | + */ |
|
| 165 | + protected $_nonce_action_ref; |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * property to hold incoming request data (as set by the admin_page_core) |
|
| 169 | + * |
|
| 170 | + * @var array $_req_data |
|
| 171 | + */ |
|
| 172 | + protected $_req_data; |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * yes / no array for admin form fields |
|
| 177 | + * |
|
| 178 | + * @var array $_yes_no |
|
| 179 | + */ |
|
| 180 | + protected $_yes_no = []; |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Array describing buttons that should appear at the bottom of the page |
|
| 184 | + * Keys are strings that represent the button's function (specifically a key in _labels['buttons']), |
|
| 185 | + * and the values are another array with the following keys |
|
| 186 | + * array( |
|
| 187 | + * 'route' => 'page_route', |
|
| 188 | + * 'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button. |
|
| 189 | + * ) |
|
| 190 | + * |
|
| 191 | + * @var array $_bottom_buttons |
|
| 192 | + */ |
|
| 193 | + protected $_bottom_buttons = []; |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Used to indicate what should be the primary column for the list table. |
|
| 198 | + * If not present then falls back to what WP calculates |
|
| 199 | + * as the primary column. |
|
| 200 | + * |
|
| 201 | + * @type string $_primary_column |
|
| 202 | + */ |
|
| 203 | + protected $_primary_column = ''; |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Used to indicate whether the table has a checkbox column or not. |
|
| 208 | + * |
|
| 209 | + * @type bool $_has_checkbox_column |
|
| 210 | + */ |
|
| 211 | + protected $_has_checkbox_column = false; |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table |
|
| 216 | + */ |
|
| 217 | + public function __construct(EE_Admin_Page $admin_page) |
|
| 218 | + { |
|
| 219 | + $this->_admin_page = $admin_page; |
|
| 220 | + $this->_req_data = $this->_admin_page->get_request_data(); |
|
| 221 | + $this->_view = $this->_admin_page->get_view(); |
|
| 222 | + $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
| 223 | + $this->_current_page = $this->get_pagenum(); |
|
| 224 | + $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
| 225 | + $this->_yes_no = [ |
|
| 226 | + esc_html__('No', 'event_espresso'), |
|
| 227 | + esc_html__('Yes', 'event_espresso') |
|
| 228 | + ]; |
|
| 229 | + |
|
| 230 | + $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page'); |
|
| 231 | + |
|
| 232 | + $this->_setup_data(); |
|
| 233 | + $this->_add_view_counts(); |
|
| 234 | + |
|
| 235 | + $this->_nonce_action_ref = $this->_view; |
|
| 236 | + |
|
| 237 | + $this->_set_properties(); |
|
| 238 | + |
|
| 239 | + // set primary column |
|
| 240 | + add_filter('list_table_primary_column', [$this, 'set_primary_column']); |
|
| 241 | + |
|
| 242 | + // set parent defaults |
|
| 243 | + parent::__construct($this->_wp_list_args); |
|
| 244 | + |
|
| 245 | + $this->prepare_items(); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * _setup_data |
|
| 251 | + * this method is used to setup the $_data, $_all_data_count, and _per_page properties |
|
| 252 | + * |
|
| 253 | + * @return void |
|
| 254 | + * @uses $this->_admin_page |
|
| 255 | + */ |
|
| 256 | + abstract protected function _setup_data(); |
|
| 257 | + |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * set the properties that this class needs to be able to execute wp_list_table properly |
|
| 261 | + * properties set: |
|
| 262 | + * _wp_list_args = what the arguments required for the parent _wp_list_table. |
|
| 263 | + * _columns = set the columns in an array. |
|
| 264 | + * _sortable_columns = columns that are sortable (array). |
|
| 265 | + * _hidden_columns = columns that are hidden (array) |
|
| 266 | + * _default_orderby = the default orderby for sorting. |
|
| 267 | + * |
|
| 268 | + * @abstract |
|
| 269 | + * @access protected |
|
| 270 | + * @return void |
|
| 271 | + */ |
|
| 272 | + abstract protected function _set_properties(); |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * _get_table_filters |
|
| 277 | + * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 278 | + * gets shown in the table. |
|
| 279 | + * |
|
| 280 | + * @abstract |
|
| 281 | + * @access protected |
|
| 282 | + * @return string |
|
| 283 | + */ |
|
| 284 | + abstract protected function _get_table_filters(); |
|
| 285 | + |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * this is a method that child class will do to add counts to the views array so when views are displayed the |
|
| 289 | + * counts of the views is accurate. |
|
| 290 | + * |
|
| 291 | + * @abstract |
|
| 292 | + * @access protected |
|
| 293 | + * @return void |
|
| 294 | + */ |
|
| 295 | + abstract protected function _add_view_counts(); |
|
| 296 | + |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * _get_hidden_fields |
|
| 300 | + * returns a html string of hidden fields so if any table filters are used the current view will be respected. |
|
| 301 | + * |
|
| 302 | + * @return string |
|
| 303 | + */ |
|
| 304 | + protected function _get_hidden_fields() |
|
| 305 | + { |
|
| 306 | + $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
| 307 | + $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
| 308 | + // if action is STILL empty, then we set it to default |
|
| 309 | + $action = empty($action) ? 'default' : $action; |
|
| 310 | + $field = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n"; |
|
| 311 | + $field .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n"; |
|
| 312 | + $field .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n"; |
|
| 313 | + |
|
| 314 | + $bulk_actions = $this->_get_bulk_actions(); |
|
| 315 | + foreach ($bulk_actions as $bulk_action => $label) { |
|
| 316 | + $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"' |
|
| 317 | + . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n"; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + return $field; |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * _set_column_info |
|
| 326 | + * we're using this to set the column headers property. |
|
| 327 | + * |
|
| 328 | + * @access protected |
|
| 329 | + * @return void |
|
| 330 | + */ |
|
| 331 | + protected function _set_column_info() |
|
| 332 | + { |
|
| 333 | + $columns = $this->get_columns(); |
|
| 334 | + $hidden = $this->get_hidden_columns(); |
|
| 335 | + $_sortable = $this->get_sortable_columns(); |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * Dynamic hook allowing for adding sortable columns in this list table. |
|
| 339 | + * Note that $this->screen->id is in the format |
|
| 340 | + * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
| 341 | + * table it is: event-espresso_page_espresso_messages. |
|
| 342 | + * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
| 343 | + * hook prefix ("event-espresso") will be different. |
|
| 344 | + * |
|
| 345 | + * @var array |
|
| 346 | + */ |
|
| 347 | + $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
| 348 | + |
|
| 349 | + $sortable = []; |
|
| 350 | + foreach ($_sortable as $id => $data) { |
|
| 351 | + if (empty($data)) { |
|
| 352 | + continue; |
|
| 353 | + } |
|
| 354 | + // fix for offset errors with WP_List_Table default get_columninfo() |
|
| 355 | + if (is_array($data)) { |
|
| 356 | + $_data[0] = key($data); |
|
| 357 | + $_data[1] = isset($data[1]) ? $data[1] : false; |
|
| 358 | + } else { |
|
| 359 | + $_data[0] = $data; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + $data = (array) $data; |
|
| 363 | + |
|
| 364 | + if (! isset($data[1])) { |
|
| 365 | + $_data[1] = false; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + $sortable[ $id ] = $_data; |
|
| 369 | + } |
|
| 370 | + $primary = $this->get_primary_column_name(); |
|
| 371 | + $this->_column_headers = [$columns, $hidden, $sortable, $primary]; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
| 377 | + * |
|
| 378 | + * @return string |
|
| 379 | + */ |
|
| 380 | + protected function get_primary_column_name() |
|
| 381 | + { |
|
| 382 | + foreach (class_parents($this) as $parent) { |
|
| 383 | + if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) { |
|
| 384 | + return parent::get_primary_column_name(); |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + return $this->_primary_column; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
| 393 | + * |
|
| 394 | + * @param EE_Base_Class $item |
|
| 395 | + * @param string $column_name |
|
| 396 | + * @param string $primary |
|
| 397 | + * @return string |
|
| 398 | + */ |
|
| 399 | + protected function handle_row_actions($item, $column_name, $primary) |
|
| 400 | + { |
|
| 401 | + foreach (class_parents($this) as $parent) { |
|
| 402 | + if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) { |
|
| 403 | + return parent::handle_row_actions($item, $column_name, $primary); |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + return ''; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * _get_bulk_actions |
|
| 412 | + * This is a wrapper called by WP_List_Table::get_bulk_actions() |
|
| 413 | + * |
|
| 414 | + * @access protected |
|
| 415 | + * @return array bulk_actions |
|
| 416 | + */ |
|
| 417 | + protected function _get_bulk_actions() |
|
| 418 | + { |
|
| 419 | + $actions = []; |
|
| 420 | + // the _views property should have the bulk_actions, so let's go through and extract them into a properly |
|
| 421 | + // formatted array for the wp_list_table(); |
|
| 422 | + foreach ($this->_views as $view => $args) { |
|
| 423 | + if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) { |
|
| 424 | + // each bulk action will correspond with a admin page route, so we can check whatever the capability is |
|
| 425 | + // for that page route and skip adding the bulk action if no access for the current logged in user. |
|
| 426 | + foreach ($args['bulk_action'] as $route => $label) { |
|
| 427 | + if ($this->_admin_page->check_user_access($route, true)) { |
|
| 428 | + $actions[ $route ] = $label; |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + return $actions; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * Generate the table navigation above or below the table. |
|
| 439 | + * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions. |
|
| 440 | + * |
|
| 441 | + * @throws EE_Error |
|
| 442 | + * @since 4.9.44.rc.001 |
|
| 443 | + */ |
|
| 444 | + public function display_tablenav($which) |
|
| 445 | + { |
|
| 446 | + if ('top' === $which) { |
|
| 447 | + wp_nonce_field('bulk-' . $this->_args['plural']); |
|
| 448 | + } |
|
| 449 | + ?> |
|
| 450 | 450 | <div class="tablenav <?php echo esc_attr($which); ?>"> |
| 451 | 451 | <?php if ($this->_get_bulk_actions()) { ?> |
| 452 | 452 | <div class="alignleft actions bulkactions"> |
| 453 | 453 | <?php $this->bulk_actions(); ?> |
| 454 | 454 | </div> |
| 455 | 455 | <?php } |
| 456 | - $this->extra_tablenav($which); |
|
| 457 | - $this->pagination($which); |
|
| 458 | - ?> |
|
| 456 | + $this->extra_tablenav($which); |
|
| 457 | + $this->pagination($which); |
|
| 458 | + ?> |
|
| 459 | 459 | |
| 460 | 460 | <br class="clear" /> |
| 461 | 461 | </div> |
| 462 | 462 | <?php |
| 463 | - } |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * _filters |
|
| 468 | - * This receives the filters array from children _get_table_filters() and assembles the string including the filter |
|
| 469 | - * button. |
|
| 470 | - * |
|
| 471 | - * @access private |
|
| 472 | - * @return void echos html showing filters |
|
| 473 | - */ |
|
| 474 | - private function _filters() |
|
| 475 | - { |
|
| 476 | - $classname = get_class($this); |
|
| 477 | - $filters = apply_filters( |
|
| 478 | - "FHEE__{$classname}__filters", |
|
| 479 | - (array) $this->_get_table_filters(), |
|
| 480 | - $this, |
|
| 481 | - $this->_screen |
|
| 482 | - ); |
|
| 483 | - |
|
| 484 | - if (empty($filters)) { |
|
| 485 | - return; |
|
| 486 | - } |
|
| 487 | - foreach ($filters as $filter) { |
|
| 488 | - echo $filter; // already escaped |
|
| 489 | - } |
|
| 490 | - // add filter button at end |
|
| 491 | - echo '<input type="submit" class="button-secondary" value="' |
|
| 492 | - . esc_html__('Filter', 'event_espresso') |
|
| 493 | - . '" id="post-query-submit" />'; |
|
| 494 | - // add reset filters button at end |
|
| 495 | - echo '<a class="button button-secondary" href="' |
|
| 496 | - . esc_url_raw($this->_admin_page->get_current_page_view_url()) |
|
| 497 | - . '" style="display:inline-block">' |
|
| 498 | - . esc_html__('Reset Filters', 'event_espresso') |
|
| 499 | - . '</a>'; |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * Callback for 'list_table_primary_column' WordPress filter |
|
| 505 | - * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary |
|
| 506 | - * column when class is instantiated. |
|
| 507 | - * |
|
| 508 | - * @param string $column_name |
|
| 509 | - * @return string |
|
| 510 | - * @see WP_List_Table::get_primary_column_name |
|
| 511 | - */ |
|
| 512 | - public function set_primary_column($column_name) |
|
| 513 | - { |
|
| 514 | - return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * |
|
| 520 | - */ |
|
| 521 | - public function prepare_items() |
|
| 522 | - { |
|
| 523 | - |
|
| 524 | - $this->_set_column_info(); |
|
| 525 | - // $this->_column_headers = $this->get_column_info(); |
|
| 526 | - $total_items = $this->_all_data_count; |
|
| 527 | - $this->process_bulk_action(); |
|
| 528 | - |
|
| 529 | - $this->items = $this->_data; |
|
| 530 | - $this->set_pagination_args( |
|
| 531 | - [ |
|
| 532 | - 'total_items' => $total_items, |
|
| 533 | - 'per_page' => $this->_per_page, |
|
| 534 | - 'total_pages' => ceil($total_items / $this->_per_page), |
|
| 535 | - ] |
|
| 536 | - ); |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * @param object|array $item |
|
| 542 | - * @return string html content for the column |
|
| 543 | - */ |
|
| 544 | - protected function column_cb($item) |
|
| 545 | - { |
|
| 546 | - return ''; |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - |
|
| 550 | - /** |
|
| 551 | - * This column is the default for when there is no defined column method for a registered column. |
|
| 552 | - * This can be overridden by child classes, but allows for hooking in for custom columns. |
|
| 553 | - * |
|
| 554 | - * @param EE_Base_Class $item |
|
| 555 | - * @param string $column_name The column being called. |
|
| 556 | - * @return string html content for the column |
|
| 557 | - */ |
|
| 558 | - public function column_default($item, $column_name) |
|
| 559 | - { |
|
| 560 | - /** |
|
| 561 | - * Dynamic hook allowing for adding additional column content in this list table. |
|
| 562 | - * Note that $this->screen->id is in the format |
|
| 563 | - * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
| 564 | - * table it is: event-espresso_page_espresso_messages. |
|
| 565 | - * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
| 566 | - * hook prefix ("event-espresso") will be different. |
|
| 567 | - */ |
|
| 568 | - ob_start(); |
|
| 569 | - do_action( |
|
| 570 | - 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, |
|
| 571 | - $item, |
|
| 572 | - $this->_screen |
|
| 573 | - ); |
|
| 574 | - return ob_get_clean(); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - |
|
| 578 | - /** |
|
| 579 | - * Get a list of columns. The format is: |
|
| 580 | - * 'internal-name' => 'Title' |
|
| 581 | - * |
|
| 582 | - * @return array |
|
| 583 | - * @since 3.1.0 |
|
| 584 | - * @access public |
|
| 585 | - * @abstract |
|
| 586 | - */ |
|
| 587 | - public function get_columns() |
|
| 588 | - { |
|
| 589 | - /** |
|
| 590 | - * Dynamic hook allowing for adding additional columns in this list table. |
|
| 591 | - * Note that $this->screen->id is in the format |
|
| 592 | - * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
| 593 | - * table it is: event-espresso_page_espresso_messages. |
|
| 594 | - * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
| 595 | - * hook prefix ("event-espresso") will be different. |
|
| 596 | - * |
|
| 597 | - * @var array |
|
| 598 | - */ |
|
| 599 | - return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen); |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - |
|
| 603 | - /** |
|
| 604 | - * Get an associative array ( id => link ) with the list |
|
| 605 | - * of views available on this table. |
|
| 606 | - * |
|
| 607 | - * @return array |
|
| 608 | - * @since 3.1.0 |
|
| 609 | - * @access protected |
|
| 610 | - */ |
|
| 611 | - public function get_views() |
|
| 612 | - { |
|
| 613 | - return $this->_views; |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - |
|
| 617 | - /** |
|
| 618 | - * Generate the views html. |
|
| 619 | - */ |
|
| 620 | - public function display_views() |
|
| 621 | - { |
|
| 622 | - $views = $this->get_views(); |
|
| 623 | - $assembled_views = []; |
|
| 624 | - |
|
| 625 | - if (empty($views)) { |
|
| 626 | - return; |
|
| 627 | - } |
|
| 628 | - echo "<ul class='subsubsub'>\n"; |
|
| 629 | - foreach ($views as $view) { |
|
| 630 | - $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
| 631 | - if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) { |
|
| 632 | - $filter = "<li"; |
|
| 633 | - $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : ''; |
|
| 634 | - $filter .= ">"; |
|
| 635 | - $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>'; |
|
| 636 | - $filter .= '<span class="count">(' . $count . ')</span>'; |
|
| 637 | - $filter .= '</li>'; |
|
| 638 | - $assembled_views[ $view['slug'] ] = $filter; |
|
| 639 | - } |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - echo ! empty($assembled_views) |
|
| 643 | - ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views) |
|
| 644 | - : ''; |
|
| 645 | - echo "</ul>"; |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - |
|
| 649 | - /** |
|
| 650 | - * Generates content for a single row of the table |
|
| 651 | - * |
|
| 652 | - * @param EE_Base_Class $item The current item |
|
| 653 | - * @since 4.1 |
|
| 654 | - * @access public |
|
| 655 | - */ |
|
| 656 | - public function single_row($item) |
|
| 657 | - { |
|
| 658 | - $row_class = $this->_get_row_class($item); |
|
| 659 | - echo '<tr class="' . esc_attr($row_class) . '">'; |
|
| 660 | - $this->single_row_columns($item); // already escaped |
|
| 661 | - echo '</tr>'; |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * This simply sets up the row class for the table rows. |
|
| 667 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 668 | - * |
|
| 669 | - * @param EE_Base_Class $item the current item |
|
| 670 | - * @return string |
|
| 671 | - */ |
|
| 672 | - protected function _get_row_class($item) |
|
| 673 | - { |
|
| 674 | - static $row_class = ''; |
|
| 675 | - $row_class = ($row_class === '' ? 'alternate' : ''); |
|
| 676 | - |
|
| 677 | - $new_row_class = $row_class; |
|
| 678 | - |
|
| 679 | - if (! empty($this->_ajax_sorting_callback)) { |
|
| 680 | - $new_row_class .= ' rowsortable'; |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - return $new_row_class; |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - |
|
| 687 | - /** |
|
| 688 | - * @return array |
|
| 689 | - */ |
|
| 690 | - public function get_sortable_columns() |
|
| 691 | - { |
|
| 692 | - return (array) $this->_sortable_columns; |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - |
|
| 696 | - /** |
|
| 697 | - * @return string |
|
| 698 | - */ |
|
| 699 | - public function get_ajax_sorting_callback() |
|
| 700 | - { |
|
| 701 | - return $this->_ajax_sorting_callback; |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - |
|
| 705 | - /** |
|
| 706 | - * @return array |
|
| 707 | - */ |
|
| 708 | - public function get_hidden_columns() |
|
| 709 | - { |
|
| 710 | - $user_id = get_current_user_id(); |
|
| 711 | - $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id); |
|
| 712 | - if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
| 713 | - update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true); |
|
| 714 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true); |
|
| 715 | - } |
|
| 716 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
| 717 | - return (array) get_user_option($ref, $user_id); |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - |
|
| 721 | - /** |
|
| 722 | - * Generates the columns for a single row of the table. |
|
| 723 | - * Overridden from wp_list_table so as to allow us to filter the column content for a given |
|
| 724 | - * column. |
|
| 725 | - * |
|
| 726 | - * @param EE_Base_Class $item The current item |
|
| 727 | - * @since 3.1.0 |
|
| 728 | - */ |
|
| 729 | - public function single_row_columns($item) |
|
| 730 | - { |
|
| 731 | - [$columns, $hidden, $sortable, $primary] = $this->get_column_info(); |
|
| 732 | - |
|
| 733 | - foreach ($columns as $column_name => $column_display_name) { |
|
| 734 | - |
|
| 735 | - /** |
|
| 736 | - * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns |
|
| 737 | - * are hidden or not instead of using "display:none;". This bit of code provides backward compat. |
|
| 738 | - */ |
|
| 739 | - $hidden_class = in_array($column_name, $hidden) ? ' hidden' : ''; |
|
| 740 | - |
|
| 741 | - $classes = $column_name . ' column-' . $column_name . $hidden_class; |
|
| 742 | - if ($primary === $column_name) { |
|
| 743 | - $classes .= ' has-row-actions column-primary'; |
|
| 744 | - } |
|
| 745 | - |
|
| 746 | - $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"'; |
|
| 747 | - |
|
| 748 | - $class = 'class="' . esc_attr($classes) . '"'; |
|
| 749 | - |
|
| 750 | - $attributes = "{$class}{$data}"; |
|
| 751 | - |
|
| 752 | - if ($column_name === 'cb') { |
|
| 753 | - echo '<th scope="row" class="check-column">'; |
|
| 754 | - echo apply_filters( |
|
| 755 | - 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', |
|
| 756 | - $this->column_cb($item), // already escaped |
|
| 757 | - $item, |
|
| 758 | - $this |
|
| 759 | - ); |
|
| 760 | - echo '</th>'; |
|
| 761 | - } elseif (method_exists($this, 'column_' . $column_name)) { |
|
| 762 | - echo "<td $attributes>"; // already escaped |
|
| 763 | - echo apply_filters( |
|
| 764 | - 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', |
|
| 765 | - call_user_func([$this, 'column_' . $column_name], $item), |
|
| 766 | - $item, |
|
| 767 | - $this |
|
| 768 | - ); |
|
| 769 | - echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 770 | - echo "</td>"; |
|
| 771 | - } else { |
|
| 772 | - echo "<td $attributes>"; // already escaped |
|
| 773 | - echo apply_filters( |
|
| 774 | - 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', |
|
| 775 | - $this->column_default($item, $column_name), |
|
| 776 | - $item, |
|
| 777 | - $column_name, |
|
| 778 | - $this |
|
| 779 | - ); |
|
| 780 | - echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 781 | - echo "</td>"; |
|
| 782 | - } |
|
| 783 | - } |
|
| 784 | - } |
|
| 785 | - |
|
| 786 | - |
|
| 787 | - /** |
|
| 788 | - * Extra controls to be displayed between bulk actions and pagination |
|
| 789 | - * |
|
| 790 | - * @access public |
|
| 791 | - * @param string $which |
|
| 792 | - * @throws EE_Error |
|
| 793 | - */ |
|
| 794 | - public function extra_tablenav($which) |
|
| 795 | - { |
|
| 796 | - if ($which === 'top') { |
|
| 797 | - $this->_filters(); |
|
| 798 | - echo $this->_get_hidden_fields(); // already escaped |
|
| 799 | - } else { |
|
| 800 | - echo '<div class="list-table-bottom-buttons alignleft actions">'; |
|
| 801 | - foreach ($this->_bottom_buttons as $type => $action) { |
|
| 802 | - $route = isset($action['route']) ? $action['route'] : ''; |
|
| 803 | - $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
| 804 | - // already escaped |
|
| 805 | - echo $this->_admin_page->get_action_link_or_button( |
|
| 806 | - $route, |
|
| 807 | - $type, |
|
| 808 | - $extra_request, |
|
| 809 | - 'button button-secondary' |
|
| 810 | - ); |
|
| 811 | - } |
|
| 812 | - do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
| 813 | - echo '</div>'; |
|
| 814 | - } |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - |
|
| 818 | - /** |
|
| 819 | - * Get an associative array ( option_name => option_title ) with the list |
|
| 820 | - * of bulk actions available on this table. |
|
| 821 | - * |
|
| 822 | - * @return array |
|
| 823 | - * @since 3.1.0 |
|
| 824 | - * @access protected |
|
| 825 | - */ |
|
| 826 | - public function get_bulk_actions() |
|
| 827 | - { |
|
| 828 | - return (array) $this->_get_bulk_actions(); |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - |
|
| 832 | - /** |
|
| 833 | - * Processing bulk actions. |
|
| 834 | - */ |
|
| 835 | - public function process_bulk_action() |
|
| 836 | - { |
|
| 837 | - // this is not used it is handled by the child EE_Admin_Page class (routes). However, including here for |
|
| 838 | - // reference in case there is a case where it gets used. |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - |
|
| 842 | - /** |
|
| 843 | - * returns the EE admin page this list table is associated with |
|
| 844 | - * |
|
| 845 | - * @return EE_Admin_Page |
|
| 846 | - */ |
|
| 847 | - public function get_admin_page() |
|
| 848 | - { |
|
| 849 | - return $this->_admin_page; |
|
| 850 | - } |
|
| 851 | - |
|
| 852 | - |
|
| 853 | - /** |
|
| 854 | - * A "helper" function for all children to provide an html string of |
|
| 855 | - * actions to output in their content. It is preferable for child classes |
|
| 856 | - * to use this method for generating their actions content so that it's |
|
| 857 | - * filterable by plugins |
|
| 858 | - * |
|
| 859 | - * @param string $action_container what are the html container |
|
| 860 | - * elements for this actions string? |
|
| 861 | - * @param string $action_class What class is for the container |
|
| 862 | - * element. |
|
| 863 | - * @param string $action_items The contents for the action items |
|
| 864 | - * container. This is filtered before |
|
| 865 | - * returned. |
|
| 866 | - * @param string $action_id What id (optional) is used for the |
|
| 867 | - * container element. |
|
| 868 | - * @param EE_Base_Class $item The object for the column displaying |
|
| 869 | - * the actions. |
|
| 870 | - * @return string The assembled action elements container. |
|
| 871 | - */ |
|
| 872 | - protected function _action_string( |
|
| 873 | - $action_items, |
|
| 874 | - $item, |
|
| 875 | - $action_container = 'ul', |
|
| 876 | - $action_class = '', |
|
| 877 | - $action_id = '' |
|
| 878 | - ) { |
|
| 879 | - $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : ''; |
|
| 880 | - $action_id = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : ''; |
|
| 881 | - $open_tag = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
| 882 | - $close_tag = ! empty($action_container) ? '</' . $action_container . '>' : ''; |
|
| 883 | - try { |
|
| 884 | - $content = apply_filters( |
|
| 885 | - 'FHEE__EE_Admin_List_Table___action_string__action_items', |
|
| 886 | - $action_items, |
|
| 887 | - $item, |
|
| 888 | - $this |
|
| 889 | - ); |
|
| 890 | - } catch (Exception $e) { |
|
| 891 | - if (WP_DEBUG) { |
|
| 892 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 893 | - } |
|
| 894 | - $content = $action_items; |
|
| 895 | - } |
|
| 896 | - return "{$open_tag}{$content}{$close_tag}"; |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - |
|
| 900 | - /** |
|
| 901 | - * @return string |
|
| 902 | - */ |
|
| 903 | - protected function getReturnUrl() |
|
| 904 | - { |
|
| 905 | - $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST'); |
|
| 906 | - $uri = $this->_admin_page->get_request()->getServerParam('REQUEST_URI'); |
|
| 907 | - return urlencode(esc_url_raw("//{$host}{$uri}")); |
|
| 908 | - } |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * _filters |
|
| 468 | + * This receives the filters array from children _get_table_filters() and assembles the string including the filter |
|
| 469 | + * button. |
|
| 470 | + * |
|
| 471 | + * @access private |
|
| 472 | + * @return void echos html showing filters |
|
| 473 | + */ |
|
| 474 | + private function _filters() |
|
| 475 | + { |
|
| 476 | + $classname = get_class($this); |
|
| 477 | + $filters = apply_filters( |
|
| 478 | + "FHEE__{$classname}__filters", |
|
| 479 | + (array) $this->_get_table_filters(), |
|
| 480 | + $this, |
|
| 481 | + $this->_screen |
|
| 482 | + ); |
|
| 483 | + |
|
| 484 | + if (empty($filters)) { |
|
| 485 | + return; |
|
| 486 | + } |
|
| 487 | + foreach ($filters as $filter) { |
|
| 488 | + echo $filter; // already escaped |
|
| 489 | + } |
|
| 490 | + // add filter button at end |
|
| 491 | + echo '<input type="submit" class="button-secondary" value="' |
|
| 492 | + . esc_html__('Filter', 'event_espresso') |
|
| 493 | + . '" id="post-query-submit" />'; |
|
| 494 | + // add reset filters button at end |
|
| 495 | + echo '<a class="button button-secondary" href="' |
|
| 496 | + . esc_url_raw($this->_admin_page->get_current_page_view_url()) |
|
| 497 | + . '" style="display:inline-block">' |
|
| 498 | + . esc_html__('Reset Filters', 'event_espresso') |
|
| 499 | + . '</a>'; |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * Callback for 'list_table_primary_column' WordPress filter |
|
| 505 | + * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary |
|
| 506 | + * column when class is instantiated. |
|
| 507 | + * |
|
| 508 | + * @param string $column_name |
|
| 509 | + * @return string |
|
| 510 | + * @see WP_List_Table::get_primary_column_name |
|
| 511 | + */ |
|
| 512 | + public function set_primary_column($column_name) |
|
| 513 | + { |
|
| 514 | + return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * |
|
| 520 | + */ |
|
| 521 | + public function prepare_items() |
|
| 522 | + { |
|
| 523 | + |
|
| 524 | + $this->_set_column_info(); |
|
| 525 | + // $this->_column_headers = $this->get_column_info(); |
|
| 526 | + $total_items = $this->_all_data_count; |
|
| 527 | + $this->process_bulk_action(); |
|
| 528 | + |
|
| 529 | + $this->items = $this->_data; |
|
| 530 | + $this->set_pagination_args( |
|
| 531 | + [ |
|
| 532 | + 'total_items' => $total_items, |
|
| 533 | + 'per_page' => $this->_per_page, |
|
| 534 | + 'total_pages' => ceil($total_items / $this->_per_page), |
|
| 535 | + ] |
|
| 536 | + ); |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * @param object|array $item |
|
| 542 | + * @return string html content for the column |
|
| 543 | + */ |
|
| 544 | + protected function column_cb($item) |
|
| 545 | + { |
|
| 546 | + return ''; |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + |
|
| 550 | + /** |
|
| 551 | + * This column is the default for when there is no defined column method for a registered column. |
|
| 552 | + * This can be overridden by child classes, but allows for hooking in for custom columns. |
|
| 553 | + * |
|
| 554 | + * @param EE_Base_Class $item |
|
| 555 | + * @param string $column_name The column being called. |
|
| 556 | + * @return string html content for the column |
|
| 557 | + */ |
|
| 558 | + public function column_default($item, $column_name) |
|
| 559 | + { |
|
| 560 | + /** |
|
| 561 | + * Dynamic hook allowing for adding additional column content in this list table. |
|
| 562 | + * Note that $this->screen->id is in the format |
|
| 563 | + * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
| 564 | + * table it is: event-espresso_page_espresso_messages. |
|
| 565 | + * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
| 566 | + * hook prefix ("event-espresso") will be different. |
|
| 567 | + */ |
|
| 568 | + ob_start(); |
|
| 569 | + do_action( |
|
| 570 | + 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, |
|
| 571 | + $item, |
|
| 572 | + $this->_screen |
|
| 573 | + ); |
|
| 574 | + return ob_get_clean(); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + |
|
| 578 | + /** |
|
| 579 | + * Get a list of columns. The format is: |
|
| 580 | + * 'internal-name' => 'Title' |
|
| 581 | + * |
|
| 582 | + * @return array |
|
| 583 | + * @since 3.1.0 |
|
| 584 | + * @access public |
|
| 585 | + * @abstract |
|
| 586 | + */ |
|
| 587 | + public function get_columns() |
|
| 588 | + { |
|
| 589 | + /** |
|
| 590 | + * Dynamic hook allowing for adding additional columns in this list table. |
|
| 591 | + * Note that $this->screen->id is in the format |
|
| 592 | + * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
| 593 | + * table it is: event-espresso_page_espresso_messages. |
|
| 594 | + * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
| 595 | + * hook prefix ("event-espresso") will be different. |
|
| 596 | + * |
|
| 597 | + * @var array |
|
| 598 | + */ |
|
| 599 | + return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen); |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + |
|
| 603 | + /** |
|
| 604 | + * Get an associative array ( id => link ) with the list |
|
| 605 | + * of views available on this table. |
|
| 606 | + * |
|
| 607 | + * @return array |
|
| 608 | + * @since 3.1.0 |
|
| 609 | + * @access protected |
|
| 610 | + */ |
|
| 611 | + public function get_views() |
|
| 612 | + { |
|
| 613 | + return $this->_views; |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + |
|
| 617 | + /** |
|
| 618 | + * Generate the views html. |
|
| 619 | + */ |
|
| 620 | + public function display_views() |
|
| 621 | + { |
|
| 622 | + $views = $this->get_views(); |
|
| 623 | + $assembled_views = []; |
|
| 624 | + |
|
| 625 | + if (empty($views)) { |
|
| 626 | + return; |
|
| 627 | + } |
|
| 628 | + echo "<ul class='subsubsub'>\n"; |
|
| 629 | + foreach ($views as $view) { |
|
| 630 | + $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
| 631 | + if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) { |
|
| 632 | + $filter = "<li"; |
|
| 633 | + $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : ''; |
|
| 634 | + $filter .= ">"; |
|
| 635 | + $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>'; |
|
| 636 | + $filter .= '<span class="count">(' . $count . ')</span>'; |
|
| 637 | + $filter .= '</li>'; |
|
| 638 | + $assembled_views[ $view['slug'] ] = $filter; |
|
| 639 | + } |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + echo ! empty($assembled_views) |
|
| 643 | + ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views) |
|
| 644 | + : ''; |
|
| 645 | + echo "</ul>"; |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + |
|
| 649 | + /** |
|
| 650 | + * Generates content for a single row of the table |
|
| 651 | + * |
|
| 652 | + * @param EE_Base_Class $item The current item |
|
| 653 | + * @since 4.1 |
|
| 654 | + * @access public |
|
| 655 | + */ |
|
| 656 | + public function single_row($item) |
|
| 657 | + { |
|
| 658 | + $row_class = $this->_get_row_class($item); |
|
| 659 | + echo '<tr class="' . esc_attr($row_class) . '">'; |
|
| 660 | + $this->single_row_columns($item); // already escaped |
|
| 661 | + echo '</tr>'; |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * This simply sets up the row class for the table rows. |
|
| 667 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 668 | + * |
|
| 669 | + * @param EE_Base_Class $item the current item |
|
| 670 | + * @return string |
|
| 671 | + */ |
|
| 672 | + protected function _get_row_class($item) |
|
| 673 | + { |
|
| 674 | + static $row_class = ''; |
|
| 675 | + $row_class = ($row_class === '' ? 'alternate' : ''); |
|
| 676 | + |
|
| 677 | + $new_row_class = $row_class; |
|
| 678 | + |
|
| 679 | + if (! empty($this->_ajax_sorting_callback)) { |
|
| 680 | + $new_row_class .= ' rowsortable'; |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + return $new_row_class; |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + |
|
| 687 | + /** |
|
| 688 | + * @return array |
|
| 689 | + */ |
|
| 690 | + public function get_sortable_columns() |
|
| 691 | + { |
|
| 692 | + return (array) $this->_sortable_columns; |
|
| 693 | + } |
|
| 694 | + |
|
| 695 | + |
|
| 696 | + /** |
|
| 697 | + * @return string |
|
| 698 | + */ |
|
| 699 | + public function get_ajax_sorting_callback() |
|
| 700 | + { |
|
| 701 | + return $this->_ajax_sorting_callback; |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + |
|
| 705 | + /** |
|
| 706 | + * @return array |
|
| 707 | + */ |
|
| 708 | + public function get_hidden_columns() |
|
| 709 | + { |
|
| 710 | + $user_id = get_current_user_id(); |
|
| 711 | + $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id); |
|
| 712 | + if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
| 713 | + update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true); |
|
| 714 | + update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true); |
|
| 715 | + } |
|
| 716 | + $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
| 717 | + return (array) get_user_option($ref, $user_id); |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + |
|
| 721 | + /** |
|
| 722 | + * Generates the columns for a single row of the table. |
|
| 723 | + * Overridden from wp_list_table so as to allow us to filter the column content for a given |
|
| 724 | + * column. |
|
| 725 | + * |
|
| 726 | + * @param EE_Base_Class $item The current item |
|
| 727 | + * @since 3.1.0 |
|
| 728 | + */ |
|
| 729 | + public function single_row_columns($item) |
|
| 730 | + { |
|
| 731 | + [$columns, $hidden, $sortable, $primary] = $this->get_column_info(); |
|
| 732 | + |
|
| 733 | + foreach ($columns as $column_name => $column_display_name) { |
|
| 734 | + |
|
| 735 | + /** |
|
| 736 | + * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns |
|
| 737 | + * are hidden or not instead of using "display:none;". This bit of code provides backward compat. |
|
| 738 | + */ |
|
| 739 | + $hidden_class = in_array($column_name, $hidden) ? ' hidden' : ''; |
|
| 740 | + |
|
| 741 | + $classes = $column_name . ' column-' . $column_name . $hidden_class; |
|
| 742 | + if ($primary === $column_name) { |
|
| 743 | + $classes .= ' has-row-actions column-primary'; |
|
| 744 | + } |
|
| 745 | + |
|
| 746 | + $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"'; |
|
| 747 | + |
|
| 748 | + $class = 'class="' . esc_attr($classes) . '"'; |
|
| 749 | + |
|
| 750 | + $attributes = "{$class}{$data}"; |
|
| 751 | + |
|
| 752 | + if ($column_name === 'cb') { |
|
| 753 | + echo '<th scope="row" class="check-column">'; |
|
| 754 | + echo apply_filters( |
|
| 755 | + 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', |
|
| 756 | + $this->column_cb($item), // already escaped |
|
| 757 | + $item, |
|
| 758 | + $this |
|
| 759 | + ); |
|
| 760 | + echo '</th>'; |
|
| 761 | + } elseif (method_exists($this, 'column_' . $column_name)) { |
|
| 762 | + echo "<td $attributes>"; // already escaped |
|
| 763 | + echo apply_filters( |
|
| 764 | + 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', |
|
| 765 | + call_user_func([$this, 'column_' . $column_name], $item), |
|
| 766 | + $item, |
|
| 767 | + $this |
|
| 768 | + ); |
|
| 769 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 770 | + echo "</td>"; |
|
| 771 | + } else { |
|
| 772 | + echo "<td $attributes>"; // already escaped |
|
| 773 | + echo apply_filters( |
|
| 774 | + 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', |
|
| 775 | + $this->column_default($item, $column_name), |
|
| 776 | + $item, |
|
| 777 | + $column_name, |
|
| 778 | + $this |
|
| 779 | + ); |
|
| 780 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 781 | + echo "</td>"; |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + } |
|
| 785 | + |
|
| 786 | + |
|
| 787 | + /** |
|
| 788 | + * Extra controls to be displayed between bulk actions and pagination |
|
| 789 | + * |
|
| 790 | + * @access public |
|
| 791 | + * @param string $which |
|
| 792 | + * @throws EE_Error |
|
| 793 | + */ |
|
| 794 | + public function extra_tablenav($which) |
|
| 795 | + { |
|
| 796 | + if ($which === 'top') { |
|
| 797 | + $this->_filters(); |
|
| 798 | + echo $this->_get_hidden_fields(); // already escaped |
|
| 799 | + } else { |
|
| 800 | + echo '<div class="list-table-bottom-buttons alignleft actions">'; |
|
| 801 | + foreach ($this->_bottom_buttons as $type => $action) { |
|
| 802 | + $route = isset($action['route']) ? $action['route'] : ''; |
|
| 803 | + $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
| 804 | + // already escaped |
|
| 805 | + echo $this->_admin_page->get_action_link_or_button( |
|
| 806 | + $route, |
|
| 807 | + $type, |
|
| 808 | + $extra_request, |
|
| 809 | + 'button button-secondary' |
|
| 810 | + ); |
|
| 811 | + } |
|
| 812 | + do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
| 813 | + echo '</div>'; |
|
| 814 | + } |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + |
|
| 818 | + /** |
|
| 819 | + * Get an associative array ( option_name => option_title ) with the list |
|
| 820 | + * of bulk actions available on this table. |
|
| 821 | + * |
|
| 822 | + * @return array |
|
| 823 | + * @since 3.1.0 |
|
| 824 | + * @access protected |
|
| 825 | + */ |
|
| 826 | + public function get_bulk_actions() |
|
| 827 | + { |
|
| 828 | + return (array) $this->_get_bulk_actions(); |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + |
|
| 832 | + /** |
|
| 833 | + * Processing bulk actions. |
|
| 834 | + */ |
|
| 835 | + public function process_bulk_action() |
|
| 836 | + { |
|
| 837 | + // this is not used it is handled by the child EE_Admin_Page class (routes). However, including here for |
|
| 838 | + // reference in case there is a case where it gets used. |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + |
|
| 842 | + /** |
|
| 843 | + * returns the EE admin page this list table is associated with |
|
| 844 | + * |
|
| 845 | + * @return EE_Admin_Page |
|
| 846 | + */ |
|
| 847 | + public function get_admin_page() |
|
| 848 | + { |
|
| 849 | + return $this->_admin_page; |
|
| 850 | + } |
|
| 851 | + |
|
| 852 | + |
|
| 853 | + /** |
|
| 854 | + * A "helper" function for all children to provide an html string of |
|
| 855 | + * actions to output in their content. It is preferable for child classes |
|
| 856 | + * to use this method for generating their actions content so that it's |
|
| 857 | + * filterable by plugins |
|
| 858 | + * |
|
| 859 | + * @param string $action_container what are the html container |
|
| 860 | + * elements for this actions string? |
|
| 861 | + * @param string $action_class What class is for the container |
|
| 862 | + * element. |
|
| 863 | + * @param string $action_items The contents for the action items |
|
| 864 | + * container. This is filtered before |
|
| 865 | + * returned. |
|
| 866 | + * @param string $action_id What id (optional) is used for the |
|
| 867 | + * container element. |
|
| 868 | + * @param EE_Base_Class $item The object for the column displaying |
|
| 869 | + * the actions. |
|
| 870 | + * @return string The assembled action elements container. |
|
| 871 | + */ |
|
| 872 | + protected function _action_string( |
|
| 873 | + $action_items, |
|
| 874 | + $item, |
|
| 875 | + $action_container = 'ul', |
|
| 876 | + $action_class = '', |
|
| 877 | + $action_id = '' |
|
| 878 | + ) { |
|
| 879 | + $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : ''; |
|
| 880 | + $action_id = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : ''; |
|
| 881 | + $open_tag = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
| 882 | + $close_tag = ! empty($action_container) ? '</' . $action_container . '>' : ''; |
|
| 883 | + try { |
|
| 884 | + $content = apply_filters( |
|
| 885 | + 'FHEE__EE_Admin_List_Table___action_string__action_items', |
|
| 886 | + $action_items, |
|
| 887 | + $item, |
|
| 888 | + $this |
|
| 889 | + ); |
|
| 890 | + } catch (Exception $e) { |
|
| 891 | + if (WP_DEBUG) { |
|
| 892 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 893 | + } |
|
| 894 | + $content = $action_items; |
|
| 895 | + } |
|
| 896 | + return "{$open_tag}{$content}{$close_tag}"; |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + |
|
| 900 | + /** |
|
| 901 | + * @return string |
|
| 902 | + */ |
|
| 903 | + protected function getReturnUrl() |
|
| 904 | + { |
|
| 905 | + $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST'); |
|
| 906 | + $uri = $this->_admin_page->get_request()->getServerParam('REQUEST_URI'); |
|
| 907 | + return urlencode(esc_url_raw("//{$host}{$uri}")); |
|
| 908 | + } |
|
| 909 | 909 | } |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function is_espresso_event($event = null) |
| 21 | 21 | { |
| 22 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 23 | - // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
| 24 | - $event = EEH_Event_View::get_event($event); |
|
| 25 | - // do we have a valid event ? |
|
| 26 | - return $event instanceof EE_Event; |
|
| 27 | - } |
|
| 28 | - return false; |
|
| 22 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 23 | + // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
| 24 | + $event = EEH_Event_View::get_event($event); |
|
| 25 | + // do we have a valid event ? |
|
| 26 | + return $event instanceof EE_Event; |
|
| 27 | + } |
|
| 28 | + return false; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function is_espresso_event_single() |
| 38 | 38 | { |
| 39 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 40 | - global $wp_query; |
|
| 41 | - // return conditionals set by CPTs |
|
| 42 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : false; |
|
| 43 | - } |
|
| 44 | - return false; |
|
| 39 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 40 | + global $wp_query; |
|
| 41 | + // return conditionals set by CPTs |
|
| 42 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : false; |
|
| 43 | + } |
|
| 44 | + return false; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function is_espresso_event_archive() |
| 54 | 54 | { |
| 55 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 56 | - global $wp_query; |
|
| 57 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : false; |
|
| 58 | - } |
|
| 59 | - return false; |
|
| 55 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 56 | + global $wp_query; |
|
| 57 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : false; |
|
| 58 | + } |
|
| 59 | + return false; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function is_espresso_event_taxonomy() |
| 69 | 69 | { |
| 70 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 71 | - global $wp_query; |
|
| 72 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : false; |
|
| 73 | - } |
|
| 74 | - return false; |
|
| 70 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 71 | + global $wp_query; |
|
| 72 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : false; |
|
| 73 | + } |
|
| 74 | + return false; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function is_espresso_venue($venue = null) |
| 87 | 87 | { |
| 88 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 89 | - // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
| 90 | - $venue = EEH_Venue_View::get_venue($venue, false); |
|
| 91 | - // do we have a valid event ? |
|
| 92 | - return $venue instanceof EE_Venue; |
|
| 93 | - } |
|
| 94 | - return false; |
|
| 88 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 89 | + // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
| 90 | + $venue = EEH_Venue_View::get_venue($venue, false); |
|
| 91 | + // do we have a valid event ? |
|
| 92 | + return $venue instanceof EE_Venue; |
|
| 93 | + } |
|
| 94 | + return false; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | function is_espresso_venue_single() |
| 104 | 104 | { |
| 105 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 106 | - global $wp_query; |
|
| 107 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : false; |
|
| 108 | - } |
|
| 109 | - return false; |
|
| 105 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 106 | + global $wp_query; |
|
| 107 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : false; |
|
| 108 | + } |
|
| 109 | + return false; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | function is_espresso_venue_archive() |
| 119 | 119 | { |
| 120 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 121 | - global $wp_query; |
|
| 122 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : false; |
|
| 123 | - } |
|
| 124 | - return false; |
|
| 120 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 121 | + global $wp_query; |
|
| 122 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : false; |
|
| 123 | + } |
|
| 124 | + return false; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | function is_espresso_venue_taxonomy() |
| 134 | 134 | { |
| 135 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 136 | - global $wp_query; |
|
| 137 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : false; |
|
| 138 | - } |
|
| 139 | - return false; |
|
| 135 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 136 | + global $wp_query; |
|
| 137 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : false; |
|
| 138 | + } |
|
| 139 | + return false; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -148,62 +148,62 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | function can_use_espresso_conditionals($conditional_tag) |
| 150 | 150 | { |
| 151 | - if (! did_action('AHEE__EE_System__initialize')) { |
|
| 152 | - EE_Error::doing_it_wrong( |
|
| 153 | - __FUNCTION__, |
|
| 154 | - sprintf( |
|
| 155 | - esc_html__( |
|
| 156 | - 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
| 157 | - 'event_espresso' |
|
| 158 | - ), |
|
| 159 | - $conditional_tag |
|
| 160 | - ), |
|
| 161 | - '4.4.0' |
|
| 162 | - ); |
|
| 163 | - return false; |
|
| 164 | - } |
|
| 165 | - return true; |
|
| 151 | + if (! did_action('AHEE__EE_System__initialize')) { |
|
| 152 | + EE_Error::doing_it_wrong( |
|
| 153 | + __FUNCTION__, |
|
| 154 | + sprintf( |
|
| 155 | + esc_html__( |
|
| 156 | + 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
| 157 | + 'event_espresso' |
|
| 158 | + ), |
|
| 159 | + $conditional_tag |
|
| 160 | + ), |
|
| 161 | + '4.4.0' |
|
| 162 | + ); |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 165 | + return true; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | |
| 169 | 169 | /*************************** Event Queries ***************************/ |
| 170 | 170 | |
| 171 | 171 | if (! function_exists('espresso_get_events')) { |
| 172 | - /** |
|
| 173 | - * espresso_get_events |
|
| 174 | - * |
|
| 175 | - * @param array $params |
|
| 176 | - * @return array |
|
| 177 | - */ |
|
| 178 | - function espresso_get_events($params = []) |
|
| 179 | - { |
|
| 180 | - //set default params |
|
| 181 | - $default_espresso_events_params = [ |
|
| 182 | - 'limit' => 10, |
|
| 183 | - 'show_expired' => false, |
|
| 184 | - 'month' => null, |
|
| 185 | - 'category_slug' => null, |
|
| 186 | - 'order_by' => 'start_date', |
|
| 187 | - 'sort' => 'ASC', |
|
| 188 | - ]; |
|
| 189 | - // allow the defaults to be filtered |
|
| 190 | - $default_espresso_events_params = apply_filters( |
|
| 191 | - 'espresso_get_events__default_espresso_events_params', |
|
| 192 | - $default_espresso_events_params |
|
| 193 | - ); |
|
| 194 | - // grab params and merge with defaults, then extract |
|
| 195 | - $params = array_merge($default_espresso_events_params, $params); |
|
| 196 | - // run the query |
|
| 197 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
| 198 | - // assign results to a variable so we can return it |
|
| 199 | - $events = $events_query->have_posts() ? $events_query->posts : []; |
|
| 200 | - // but first reset the query and postdata |
|
| 201 | - wp_reset_query(); |
|
| 202 | - wp_reset_postdata(); |
|
| 203 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
| 204 | - unset($events_query); |
|
| 205 | - return $events; |
|
| 206 | - } |
|
| 172 | + /** |
|
| 173 | + * espresso_get_events |
|
| 174 | + * |
|
| 175 | + * @param array $params |
|
| 176 | + * @return array |
|
| 177 | + */ |
|
| 178 | + function espresso_get_events($params = []) |
|
| 179 | + { |
|
| 180 | + //set default params |
|
| 181 | + $default_espresso_events_params = [ |
|
| 182 | + 'limit' => 10, |
|
| 183 | + 'show_expired' => false, |
|
| 184 | + 'month' => null, |
|
| 185 | + 'category_slug' => null, |
|
| 186 | + 'order_by' => 'start_date', |
|
| 187 | + 'sort' => 'ASC', |
|
| 188 | + ]; |
|
| 189 | + // allow the defaults to be filtered |
|
| 190 | + $default_espresso_events_params = apply_filters( |
|
| 191 | + 'espresso_get_events__default_espresso_events_params', |
|
| 192 | + $default_espresso_events_params |
|
| 193 | + ); |
|
| 194 | + // grab params and merge with defaults, then extract |
|
| 195 | + $params = array_merge($default_espresso_events_params, $params); |
|
| 196 | + // run the query |
|
| 197 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
| 198 | + // assign results to a variable so we can return it |
|
| 199 | + $events = $events_query->have_posts() ? $events_query->posts : []; |
|
| 200 | + // but first reset the query and postdata |
|
| 201 | + wp_reset_query(); |
|
| 202 | + wp_reset_postdata(); |
|
| 203 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
| 204 | + unset($events_query); |
|
| 205 | + return $events; |
|
| 206 | + } |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | |
@@ -218,357 +218,357 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | function espresso_load_ticket_selector() |
| 220 | 220 | { |
| 221 | - EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
| 221 | + EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if (! function_exists('espresso_ticket_selector')) { |
| 225 | - /** |
|
| 226 | - * espresso_ticket_selector |
|
| 227 | - * |
|
| 228 | - * @param null $event |
|
| 229 | - * @throws EE_Error |
|
| 230 | - * @throws ReflectionException |
|
| 231 | - */ |
|
| 232 | - function espresso_ticket_selector($event = null) |
|
| 233 | - { |
|
| 234 | - if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
| 235 | - espresso_load_ticket_selector(); |
|
| 236 | - EED_Ticket_Selector::set_definitions(); |
|
| 237 | - echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
| 238 | - } |
|
| 239 | - } |
|
| 225 | + /** |
|
| 226 | + * espresso_ticket_selector |
|
| 227 | + * |
|
| 228 | + * @param null $event |
|
| 229 | + * @throws EE_Error |
|
| 230 | + * @throws ReflectionException |
|
| 231 | + */ |
|
| 232 | + function espresso_ticket_selector($event = null) |
|
| 233 | + { |
|
| 234 | + if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
| 235 | + espresso_load_ticket_selector(); |
|
| 236 | + EED_Ticket_Selector::set_definitions(); |
|
| 237 | + echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | if (! function_exists('espresso_view_details_btn')) { |
| 244 | - /** |
|
| 245 | - * espresso_view_details_btn |
|
| 246 | - * |
|
| 247 | - * @param null $event |
|
| 248 | - * @throws EE_Error |
|
| 249 | - * @throws ReflectionException |
|
| 250 | - */ |
|
| 251 | - function espresso_view_details_btn($event = null) |
|
| 252 | - { |
|
| 253 | - if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
| 254 | - espresso_load_ticket_selector(); |
|
| 255 | - echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
| 256 | - } |
|
| 257 | - } |
|
| 244 | + /** |
|
| 245 | + * espresso_view_details_btn |
|
| 246 | + * |
|
| 247 | + * @param null $event |
|
| 248 | + * @throws EE_Error |
|
| 249 | + * @throws ReflectionException |
|
| 250 | + */ |
|
| 251 | + function espresso_view_details_btn($event = null) |
|
| 252 | + { |
|
| 253 | + if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
| 254 | + espresso_load_ticket_selector(); |
|
| 255 | + echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | /*************************** EEH_Event_View ***************************/ |
| 262 | 262 | |
| 263 | 263 | if (! function_exists('espresso_load_event_list_assets')) { |
| 264 | - /** |
|
| 265 | - * espresso_load_event_list_assets |
|
| 266 | - * ensures that event list styles and scripts are loaded |
|
| 267 | - * |
|
| 268 | - * @return void |
|
| 269 | - */ |
|
| 270 | - function espresso_load_event_list_assets() |
|
| 271 | - { |
|
| 272 | - $event_list = EED_Events_Archive::instance(); |
|
| 273 | - add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
| 274 | - add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
| 275 | - } |
|
| 264 | + /** |
|
| 265 | + * espresso_load_event_list_assets |
|
| 266 | + * ensures that event list styles and scripts are loaded |
|
| 267 | + * |
|
| 268 | + * @return void |
|
| 269 | + */ |
|
| 270 | + function espresso_load_event_list_assets() |
|
| 271 | + { |
|
| 272 | + $event_list = EED_Events_Archive::instance(); |
|
| 273 | + add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
| 274 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
| 275 | + } |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
| 279 | 279 | if (! function_exists('espresso_event_reg_button')) { |
| 280 | - /** |
|
| 281 | - * espresso_event_reg_button |
|
| 282 | - * returns the "Register Now" button if event is active, |
|
| 283 | - * an inactive button like status banner if the event is not active |
|
| 284 | - * or a "Read More" button if so desired |
|
| 285 | - * |
|
| 286 | - * @param null $btn_text_if_active |
|
| 287 | - * @param bool $btn_text_if_inactive |
|
| 288 | - * @param bool $EVT_ID |
|
| 289 | - * @return void |
|
| 290 | - * @throws EE_Error |
|
| 291 | - * @throws ReflectionException |
|
| 292 | - */ |
|
| 293 | - function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
| 294 | - { |
|
| 295 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
| 296 | - if (! $event instanceof EE_Event) { |
|
| 297 | - return; |
|
| 298 | - } |
|
| 299 | - $event_status = $event->get_active_status(); |
|
| 300 | - switch ($event_status) { |
|
| 301 | - case EE_Datetime::sold_out : |
|
| 302 | - $btn_text = __('Sold Out', 'event_espresso'); |
|
| 303 | - $class = 'ee-pink'; |
|
| 304 | - break; |
|
| 305 | - case EE_Datetime::expired : |
|
| 306 | - $btn_text = __('Event is Over', 'event_espresso'); |
|
| 307 | - $class = 'ee-grey'; |
|
| 308 | - break; |
|
| 309 | - case EE_Datetime::inactive : |
|
| 310 | - $btn_text = __('Event Not Active', 'event_espresso'); |
|
| 311 | - $class = 'ee-grey'; |
|
| 312 | - break; |
|
| 313 | - case EE_Datetime::cancelled : |
|
| 314 | - $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
| 315 | - $class = 'ee-red'; |
|
| 316 | - break; |
|
| 317 | - case EE_Datetime::upcoming : |
|
| 318 | - case EE_Datetime::active : |
|
| 319 | - default : |
|
| 320 | - $btn_text = ! empty($btn_text_if_active) |
|
| 321 | - ? $btn_text_if_active |
|
| 322 | - : __('Register Now', 'event_espresso'); |
|
| 323 | - $class = 'ee-green'; |
|
| 324 | - } |
|
| 325 | - if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
| 326 | - $btn_text = $btn_text_if_inactive; |
|
| 327 | - $class = 'ee-grey'; |
|
| 328 | - } |
|
| 329 | - ?> |
|
| 280 | + /** |
|
| 281 | + * espresso_event_reg_button |
|
| 282 | + * returns the "Register Now" button if event is active, |
|
| 283 | + * an inactive button like status banner if the event is not active |
|
| 284 | + * or a "Read More" button if so desired |
|
| 285 | + * |
|
| 286 | + * @param null $btn_text_if_active |
|
| 287 | + * @param bool $btn_text_if_inactive |
|
| 288 | + * @param bool $EVT_ID |
|
| 289 | + * @return void |
|
| 290 | + * @throws EE_Error |
|
| 291 | + * @throws ReflectionException |
|
| 292 | + */ |
|
| 293 | + function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
| 294 | + { |
|
| 295 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 296 | + if (! $event instanceof EE_Event) { |
|
| 297 | + return; |
|
| 298 | + } |
|
| 299 | + $event_status = $event->get_active_status(); |
|
| 300 | + switch ($event_status) { |
|
| 301 | + case EE_Datetime::sold_out : |
|
| 302 | + $btn_text = __('Sold Out', 'event_espresso'); |
|
| 303 | + $class = 'ee-pink'; |
|
| 304 | + break; |
|
| 305 | + case EE_Datetime::expired : |
|
| 306 | + $btn_text = __('Event is Over', 'event_espresso'); |
|
| 307 | + $class = 'ee-grey'; |
|
| 308 | + break; |
|
| 309 | + case EE_Datetime::inactive : |
|
| 310 | + $btn_text = __('Event Not Active', 'event_espresso'); |
|
| 311 | + $class = 'ee-grey'; |
|
| 312 | + break; |
|
| 313 | + case EE_Datetime::cancelled : |
|
| 314 | + $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
| 315 | + $class = 'ee-red'; |
|
| 316 | + break; |
|
| 317 | + case EE_Datetime::upcoming : |
|
| 318 | + case EE_Datetime::active : |
|
| 319 | + default : |
|
| 320 | + $btn_text = ! empty($btn_text_if_active) |
|
| 321 | + ? $btn_text_if_active |
|
| 322 | + : __('Register Now', 'event_espresso'); |
|
| 323 | + $class = 'ee-green'; |
|
| 324 | + } |
|
| 325 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
| 326 | + $btn_text = $btn_text_if_inactive; |
|
| 327 | + $class = 'ee-grey'; |
|
| 328 | + } |
|
| 329 | + ?> |
|
| 330 | 330 | <a class="ee-button ee-register-button <?php echo esc_attr($class); ?>" |
| 331 | 331 | href="<?php espresso_event_link_url($EVT_ID); ?>" |
| 332 | 332 | <?php echo EED_Events_Archive::link_target(); // already escaped |
| 333 | - ?> |
|
| 333 | + ?> |
|
| 334 | 334 | > |
| 335 | 335 | <?php echo esc_html($btn_text); ?> |
| 336 | 336 | </a> |
| 337 | 337 | <?php |
| 338 | - } |
|
| 338 | + } |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
| 342 | 342 | if (! function_exists('espresso_display_ticket_selector')) { |
| 343 | - /** |
|
| 344 | - * espresso_display_ticket_selector |
|
| 345 | - * whether or not to display the Ticket Selector for an event |
|
| 346 | - * |
|
| 347 | - * @param bool $EVT_ID |
|
| 348 | - * @return boolean |
|
| 349 | - * @throws EE_Error |
|
| 350 | - * @throws ReflectionException |
|
| 351 | - */ |
|
| 352 | - function espresso_display_ticket_selector($EVT_ID = false) |
|
| 353 | - { |
|
| 354 | - return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
| 355 | - } |
|
| 343 | + /** |
|
| 344 | + * espresso_display_ticket_selector |
|
| 345 | + * whether or not to display the Ticket Selector for an event |
|
| 346 | + * |
|
| 347 | + * @param bool $EVT_ID |
|
| 348 | + * @return boolean |
|
| 349 | + * @throws EE_Error |
|
| 350 | + * @throws ReflectionException |
|
| 351 | + */ |
|
| 352 | + function espresso_display_ticket_selector($EVT_ID = false) |
|
| 353 | + { |
|
| 354 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
| 355 | + } |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | |
| 359 | 359 | if (! function_exists('espresso_event_status_banner')) { |
| 360 | - /** |
|
| 361 | - * espresso_event_status |
|
| 362 | - * returns a banner showing the event status if it is sold out, expired, or inactive |
|
| 363 | - * |
|
| 364 | - * @param bool $EVT_ID |
|
| 365 | - * @return string |
|
| 366 | - * @throws EE_Error |
|
| 367 | - * @throws ReflectionException |
|
| 368 | - */ |
|
| 369 | - function espresso_event_status_banner($EVT_ID = false) |
|
| 370 | - { |
|
| 371 | - return EEH_Event_View::event_status($EVT_ID); |
|
| 372 | - } |
|
| 360 | + /** |
|
| 361 | + * espresso_event_status |
|
| 362 | + * returns a banner showing the event status if it is sold out, expired, or inactive |
|
| 363 | + * |
|
| 364 | + * @param bool $EVT_ID |
|
| 365 | + * @return string |
|
| 366 | + * @throws EE_Error |
|
| 367 | + * @throws ReflectionException |
|
| 368 | + */ |
|
| 369 | + function espresso_event_status_banner($EVT_ID = false) |
|
| 370 | + { |
|
| 371 | + return EEH_Event_View::event_status($EVT_ID); |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
| 376 | 376 | if (! function_exists('espresso_event_status')) { |
| 377 | - /** |
|
| 378 | - * espresso_event_status |
|
| 379 | - * returns the event status if it is sold out, expired, or inactive |
|
| 380 | - * |
|
| 381 | - * @param int $EVT_ID |
|
| 382 | - * @param bool $echo |
|
| 383 | - * @return string |
|
| 384 | - * @throws EE_Error |
|
| 385 | - * @throws ReflectionException |
|
| 386 | - */ |
|
| 387 | - function espresso_event_status($EVT_ID = 0, $echo = true) |
|
| 388 | - { |
|
| 389 | - return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
| 390 | - } |
|
| 377 | + /** |
|
| 378 | + * espresso_event_status |
|
| 379 | + * returns the event status if it is sold out, expired, or inactive |
|
| 380 | + * |
|
| 381 | + * @param int $EVT_ID |
|
| 382 | + * @param bool $echo |
|
| 383 | + * @return string |
|
| 384 | + * @throws EE_Error |
|
| 385 | + * @throws ReflectionException |
|
| 386 | + */ |
|
| 387 | + function espresso_event_status($EVT_ID = 0, $echo = true) |
|
| 388 | + { |
|
| 389 | + return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
| 390 | + } |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | |
| 394 | 394 | if (! function_exists('espresso_event_categories')) { |
| 395 | - /** |
|
| 396 | - * espresso_event_categories |
|
| 397 | - * returns the terms associated with an event |
|
| 398 | - * |
|
| 399 | - * @param int $EVT_ID |
|
| 400 | - * @param bool $hide_uncategorized |
|
| 401 | - * @param bool $echo |
|
| 402 | - * @return string |
|
| 403 | - * @throws EE_Error |
|
| 404 | - * @throws ReflectionException |
|
| 405 | - */ |
|
| 406 | - function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
| 407 | - { |
|
| 408 | - if ($echo) { |
|
| 409 | - echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); // already escaped |
|
| 410 | - return ''; |
|
| 411 | - } |
|
| 412 | - return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
| 413 | - } |
|
| 395 | + /** |
|
| 396 | + * espresso_event_categories |
|
| 397 | + * returns the terms associated with an event |
|
| 398 | + * |
|
| 399 | + * @param int $EVT_ID |
|
| 400 | + * @param bool $hide_uncategorized |
|
| 401 | + * @param bool $echo |
|
| 402 | + * @return string |
|
| 403 | + * @throws EE_Error |
|
| 404 | + * @throws ReflectionException |
|
| 405 | + */ |
|
| 406 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
| 407 | + { |
|
| 408 | + if ($echo) { |
|
| 409 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); // already escaped |
|
| 410 | + return ''; |
|
| 411 | + } |
|
| 412 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
| 413 | + } |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
| 417 | 417 | if (! function_exists('espresso_event_tickets_available')) { |
| 418 | - /** |
|
| 419 | - * espresso_event_tickets_available |
|
| 420 | - * returns the ticket types available for purchase for an event |
|
| 421 | - * |
|
| 422 | - * @param int $EVT_ID |
|
| 423 | - * @param bool $echo |
|
| 424 | - * @param bool $format |
|
| 425 | - * @return string |
|
| 426 | - * @throws EE_Error |
|
| 427 | - * @throws ReflectionException |
|
| 428 | - */ |
|
| 429 | - function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
| 430 | - { |
|
| 431 | - $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
| 432 | - if (is_array($tickets) && ! empty($tickets)) { |
|
| 433 | - // if formatting then $html will be a string, else it will be an array of ticket objects |
|
| 434 | - $html = |
|
| 435 | - $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
| 436 | - foreach ($tickets as $ticket) { |
|
| 437 | - if ($ticket instanceof EE_Ticket) { |
|
| 438 | - if ($format) { |
|
| 439 | - $html .= '<li id="ee-event-tickets-li-' |
|
| 440 | - . esc_attr($ticket->ID()) |
|
| 441 | - . '" class="ee-event-tickets-li">'; |
|
| 442 | - $html .= esc_html($ticket->name()) . ' '; |
|
| 443 | - $html .= EEH_Template::format_currency( |
|
| 444 | - $ticket->get_ticket_total_with_taxes() |
|
| 445 | - ); // already escaped |
|
| 446 | - $html .= '</li>'; |
|
| 447 | - } else { |
|
| 448 | - $html[] = $ticket; |
|
| 449 | - } |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - if ($format) { |
|
| 453 | - $html .= '</ul>'; |
|
| 454 | - } |
|
| 455 | - if ($echo && $format) { |
|
| 456 | - echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
| 457 | - return ''; |
|
| 458 | - } |
|
| 459 | - return $html; |
|
| 460 | - } |
|
| 461 | - return ''; |
|
| 462 | - } |
|
| 418 | + /** |
|
| 419 | + * espresso_event_tickets_available |
|
| 420 | + * returns the ticket types available for purchase for an event |
|
| 421 | + * |
|
| 422 | + * @param int $EVT_ID |
|
| 423 | + * @param bool $echo |
|
| 424 | + * @param bool $format |
|
| 425 | + * @return string |
|
| 426 | + * @throws EE_Error |
|
| 427 | + * @throws ReflectionException |
|
| 428 | + */ |
|
| 429 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
| 430 | + { |
|
| 431 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
| 432 | + if (is_array($tickets) && ! empty($tickets)) { |
|
| 433 | + // if formatting then $html will be a string, else it will be an array of ticket objects |
|
| 434 | + $html = |
|
| 435 | + $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
| 436 | + foreach ($tickets as $ticket) { |
|
| 437 | + if ($ticket instanceof EE_Ticket) { |
|
| 438 | + if ($format) { |
|
| 439 | + $html .= '<li id="ee-event-tickets-li-' |
|
| 440 | + . esc_attr($ticket->ID()) |
|
| 441 | + . '" class="ee-event-tickets-li">'; |
|
| 442 | + $html .= esc_html($ticket->name()) . ' '; |
|
| 443 | + $html .= EEH_Template::format_currency( |
|
| 444 | + $ticket->get_ticket_total_with_taxes() |
|
| 445 | + ); // already escaped |
|
| 446 | + $html .= '</li>'; |
|
| 447 | + } else { |
|
| 448 | + $html[] = $ticket; |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + if ($format) { |
|
| 453 | + $html .= '</ul>'; |
|
| 454 | + } |
|
| 455 | + if ($echo && $format) { |
|
| 456 | + echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
| 457 | + return ''; |
|
| 458 | + } |
|
| 459 | + return $html; |
|
| 460 | + } |
|
| 461 | + return ''; |
|
| 462 | + } |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | if (! function_exists('espresso_event_date_obj')) { |
| 466 | - /** |
|
| 467 | - * espresso_event_date_obj |
|
| 468 | - * returns the primary date object for an event |
|
| 469 | - * |
|
| 470 | - * @param bool $EVT_ID |
|
| 471 | - * @return EE_Datetime|null |
|
| 472 | - * @throws EE_Error |
|
| 473 | - * @throws ReflectionException |
|
| 474 | - */ |
|
| 475 | - function espresso_event_date_obj($EVT_ID = false) |
|
| 476 | - { |
|
| 477 | - return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
| 478 | - } |
|
| 466 | + /** |
|
| 467 | + * espresso_event_date_obj |
|
| 468 | + * returns the primary date object for an event |
|
| 469 | + * |
|
| 470 | + * @param bool $EVT_ID |
|
| 471 | + * @return EE_Datetime|null |
|
| 472 | + * @throws EE_Error |
|
| 473 | + * @throws ReflectionException |
|
| 474 | + */ |
|
| 475 | + function espresso_event_date_obj($EVT_ID = false) |
|
| 476 | + { |
|
| 477 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
| 478 | + } |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | |
| 482 | 482 | if (! function_exists('espresso_event_date')) { |
| 483 | - /** |
|
| 484 | - * espresso_event_date |
|
| 485 | - * returns the primary date for an event |
|
| 486 | - * |
|
| 487 | - * @param string $date_format |
|
| 488 | - * @param string $time_format |
|
| 489 | - * @param bool $EVT_ID |
|
| 490 | - * @param bool $echo |
|
| 491 | - * @return string |
|
| 492 | - * @throws EE_Error |
|
| 493 | - * @throws ReflectionException |
|
| 494 | - */ |
|
| 495 | - function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
| 496 | - { |
|
| 497 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 498 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 499 | - $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
| 500 | - $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
| 501 | - if ($echo) { |
|
| 502 | - echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); // already escaped |
|
| 503 | - return ''; |
|
| 504 | - } |
|
| 505 | - return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
| 506 | - |
|
| 507 | - } |
|
| 483 | + /** |
|
| 484 | + * espresso_event_date |
|
| 485 | + * returns the primary date for an event |
|
| 486 | + * |
|
| 487 | + * @param string $date_format |
|
| 488 | + * @param string $time_format |
|
| 489 | + * @param bool $EVT_ID |
|
| 490 | + * @param bool $echo |
|
| 491 | + * @return string |
|
| 492 | + * @throws EE_Error |
|
| 493 | + * @throws ReflectionException |
|
| 494 | + */ |
|
| 495 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
| 496 | + { |
|
| 497 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 498 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 499 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
| 500 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
| 501 | + if ($echo) { |
|
| 502 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); // already escaped |
|
| 503 | + return ''; |
|
| 504 | + } |
|
| 505 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
| 506 | + |
|
| 507 | + } |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | |
| 511 | 511 | if (! function_exists('espresso_list_of_event_dates')) { |
| 512 | - /** |
|
| 513 | - * espresso_list_of_event_dates |
|
| 514 | - * returns a unordered list of dates for an event |
|
| 515 | - * |
|
| 516 | - * @param int $EVT_ID |
|
| 517 | - * @param string $date_format |
|
| 518 | - * @param string $time_format |
|
| 519 | - * @param bool $echo |
|
| 520 | - * @param null $show_expired |
|
| 521 | - * @param bool $format |
|
| 522 | - * @param bool $add_breaks |
|
| 523 | - * @param null $limit |
|
| 524 | - * @return string |
|
| 525 | - * @throws EE_Error |
|
| 526 | - * @throws ReflectionException |
|
| 527 | - */ |
|
| 528 | - function espresso_list_of_event_dates( |
|
| 529 | - $EVT_ID = 0, |
|
| 530 | - $date_format = '', |
|
| 531 | - $time_format = '', |
|
| 532 | - $echo = true, |
|
| 533 | - $show_expired = null, |
|
| 534 | - $format = true, |
|
| 535 | - $add_breaks = true, |
|
| 536 | - $limit = null |
|
| 537 | - ) { |
|
| 538 | - $allowedtags = AllowedTags::getAllowedTags(); |
|
| 539 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 540 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 541 | - $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
| 542 | - $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
| 543 | - $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
|
| 544 | - if (! $format) { |
|
| 545 | - return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
| 546 | - } |
|
| 547 | - $newline = $add_breaks ? '<br />' : ''; |
|
| 548 | - if (is_array($datetimes) && ! empty($datetimes)) { |
|
| 549 | - global $post; |
|
| 550 | - $html = |
|
| 551 | - '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
| 552 | - foreach ($datetimes as $datetime) { |
|
| 553 | - if ($datetime instanceof EE_Datetime) { |
|
| 554 | - |
|
| 555 | - $datetime_name = $datetime->name(); |
|
| 556 | - $datetime_html = ! empty($datetime_name) |
|
| 557 | - ? ' |
|
| 512 | + /** |
|
| 513 | + * espresso_list_of_event_dates |
|
| 514 | + * returns a unordered list of dates for an event |
|
| 515 | + * |
|
| 516 | + * @param int $EVT_ID |
|
| 517 | + * @param string $date_format |
|
| 518 | + * @param string $time_format |
|
| 519 | + * @param bool $echo |
|
| 520 | + * @param null $show_expired |
|
| 521 | + * @param bool $format |
|
| 522 | + * @param bool $add_breaks |
|
| 523 | + * @param null $limit |
|
| 524 | + * @return string |
|
| 525 | + * @throws EE_Error |
|
| 526 | + * @throws ReflectionException |
|
| 527 | + */ |
|
| 528 | + function espresso_list_of_event_dates( |
|
| 529 | + $EVT_ID = 0, |
|
| 530 | + $date_format = '', |
|
| 531 | + $time_format = '', |
|
| 532 | + $echo = true, |
|
| 533 | + $show_expired = null, |
|
| 534 | + $format = true, |
|
| 535 | + $add_breaks = true, |
|
| 536 | + $limit = null |
|
| 537 | + ) { |
|
| 538 | + $allowedtags = AllowedTags::getAllowedTags(); |
|
| 539 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 540 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 541 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
| 542 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
| 543 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
|
| 544 | + if (! $format) { |
|
| 545 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
| 546 | + } |
|
| 547 | + $newline = $add_breaks ? '<br />' : ''; |
|
| 548 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
| 549 | + global $post; |
|
| 550 | + $html = |
|
| 551 | + '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
| 552 | + foreach ($datetimes as $datetime) { |
|
| 553 | + if ($datetime instanceof EE_Datetime) { |
|
| 554 | + |
|
| 555 | + $datetime_name = $datetime->name(); |
|
| 556 | + $datetime_html = ! empty($datetime_name) |
|
| 557 | + ? ' |
|
| 558 | 558 | <strong class="ee-event-datetimes-li-date-name"> |
| 559 | 559 | ' . esc_html($datetime_name) . ' |
| 560 | 560 | </strong>' . $newline |
| 561 | - : ''; |
|
| 561 | + : ''; |
|
| 562 | 562 | |
| 563 | - $datetime_description = $datetime->description(); |
|
| 564 | - $datetime_html .= ! empty($datetime_description) |
|
| 565 | - ? ' |
|
| 563 | + $datetime_description = $datetime->description(); |
|
| 564 | + $datetime_html .= ! empty($datetime_description) |
|
| 565 | + ? ' |
|
| 566 | 566 | <span class="ee-event-datetimes-li-date-desc"> |
| 567 | 567 | ' . wp_kses($datetime_description, $allowedtags) . ' |
| 568 | 568 | </span>' . $newline |
| 569 | - : ''; |
|
| 569 | + : ''; |
|
| 570 | 570 | |
| 571 | - $datetime_html .= ' |
|
| 571 | + $datetime_html .= ' |
|
| 572 | 572 | <span class="dashicons dashicons-calendar"></span> |
| 573 | 573 | <span class="ee-event-datetimes-li-daterange">' . $datetime->date_range($date_format) . '</span> |
| 574 | 574 | <br/> |
@@ -576,482 +576,482 @@ discard block |
||
| 576 | 576 | <span class="ee-event-datetimes-li-timerange">' . $datetime->time_range($time_format) . '</span> |
| 577 | 577 | '; |
| 578 | 578 | |
| 579 | - $datetime_html = apply_filters( |
|
| 580 | - 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
| 581 | - $datetime_html, |
|
| 582 | - $datetime |
|
| 583 | - ); |
|
| 579 | + $datetime_html = apply_filters( |
|
| 580 | + 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
| 581 | + $datetime_html, |
|
| 582 | + $datetime |
|
| 583 | + ); |
|
| 584 | 584 | |
| 585 | - $DTD_ID = esc_attr($datetime->ID()); |
|
| 586 | - $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
| 585 | + $DTD_ID = esc_attr($datetime->ID()); |
|
| 586 | + $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
| 587 | 587 | |
| 588 | - $html .= ' |
|
| 588 | + $html .= ' |
|
| 589 | 589 | <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li' . $active_status . '"> |
| 590 | 590 | ' . $datetime_html . ' |
| 591 | 591 | </li>'; |
| 592 | - } |
|
| 593 | - } |
|
| 594 | - $html .= '</ul>'; |
|
| 595 | - } else { |
|
| 596 | - $html = |
|
| 597 | - ' |
|
| 592 | + } |
|
| 593 | + } |
|
| 594 | + $html .= '</ul>'; |
|
| 595 | + } else { |
|
| 596 | + $html = |
|
| 597 | + ' |
|
| 598 | 598 | <p> |
| 599 | 599 | <span class="dashicons dashicons-marker pink-text"></span> |
| 600 | 600 | ' . esc_html__( |
| 601 | - 'There are no upcoming dates for this event.', |
|
| 602 | - 'event_espresso' |
|
| 603 | - ) . ' |
|
| 601 | + 'There are no upcoming dates for this event.', |
|
| 602 | + 'event_espresso' |
|
| 603 | + ) . ' |
|
| 604 | 604 | </p> |
| 605 | 605 | <br/>'; |
| 606 | - } |
|
| 607 | - if ($echo) { |
|
| 608 | - echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
| 609 | - return ''; |
|
| 610 | - } |
|
| 611 | - return $html; |
|
| 612 | - } |
|
| 606 | + } |
|
| 607 | + if ($echo) { |
|
| 608 | + echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
| 609 | + return ''; |
|
| 610 | + } |
|
| 611 | + return $html; |
|
| 612 | + } |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | |
| 616 | 616 | if (! function_exists('espresso_event_end_date')) { |
| 617 | - /** |
|
| 618 | - * espresso_event_end_date |
|
| 619 | - * returns the last date for an event |
|
| 620 | - * |
|
| 621 | - * @param string $date_format |
|
| 622 | - * @param string $time_format |
|
| 623 | - * @param bool $EVT_ID |
|
| 624 | - * @param bool $echo |
|
| 625 | - * @return string |
|
| 626 | - * @throws EE_Error |
|
| 627 | - * @throws ReflectionException |
|
| 628 | - */ |
|
| 629 | - function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
| 630 | - { |
|
| 631 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 632 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 633 | - $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
| 634 | - $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
| 635 | - if ($echo) { |
|
| 636 | - echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); // already escaped |
|
| 637 | - return ''; |
|
| 638 | - } |
|
| 639 | - return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
| 640 | - } |
|
| 617 | + /** |
|
| 618 | + * espresso_event_end_date |
|
| 619 | + * returns the last date for an event |
|
| 620 | + * |
|
| 621 | + * @param string $date_format |
|
| 622 | + * @param string $time_format |
|
| 623 | + * @param bool $EVT_ID |
|
| 624 | + * @param bool $echo |
|
| 625 | + * @return string |
|
| 626 | + * @throws EE_Error |
|
| 627 | + * @throws ReflectionException |
|
| 628 | + */ |
|
| 629 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
| 630 | + { |
|
| 631 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 632 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 633 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
| 634 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
| 635 | + if ($echo) { |
|
| 636 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); // already escaped |
|
| 637 | + return ''; |
|
| 638 | + } |
|
| 639 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
| 640 | + } |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | if (! function_exists('espresso_event_date_range')) { |
| 644 | - /** |
|
| 645 | - * espresso_event_date_range |
|
| 646 | - * returns the first and last chronologically ordered dates for an event (if different) |
|
| 647 | - * |
|
| 648 | - * @param string $date_format |
|
| 649 | - * @param string $time_format |
|
| 650 | - * @param string $single_date_format |
|
| 651 | - * @param string $single_time_format |
|
| 652 | - * @param bool $EVT_ID |
|
| 653 | - * @param bool $echo |
|
| 654 | - * @return string |
|
| 655 | - * @throws EE_Error |
|
| 656 | - * @throws ReflectionException |
|
| 657 | - */ |
|
| 658 | - function espresso_event_date_range( |
|
| 659 | - $date_format = '', |
|
| 660 | - $time_format = '', |
|
| 661 | - $single_date_format = '', |
|
| 662 | - $single_time_format = '', |
|
| 663 | - $EVT_ID = false, |
|
| 664 | - $echo = true |
|
| 665 | - ) { |
|
| 666 | - // set and filter date and time formats when a range is returned |
|
| 667 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 668 | - $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
| 669 | - // get the start and end date with NO time portion |
|
| 670 | - $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
| 671 | - $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
| 672 | - // now we can determine if date range spans more than one day |
|
| 673 | - if ($the_event_date != $the_event_end_date) { |
|
| 674 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 675 | - $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
| 676 | - $html = sprintf( |
|
| 677 | - /* translators: 1: first event date, 2: last event date */ |
|
| 678 | - esc_html__('%1$s - %2$s', 'event_espresso'), |
|
| 679 | - EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
| 680 | - EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
| 681 | - ); |
|
| 682 | - } else { |
|
| 683 | - // set and filter date and time formats when only a single datetime is returned |
|
| 684 | - $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
| 685 | - $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
| 686 | - $single_date_format = |
|
| 687 | - apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
| 688 | - $single_time_format = |
|
| 689 | - apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
| 690 | - $html = |
|
| 691 | - EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
| 692 | - } |
|
| 693 | - if ($echo) { |
|
| 694 | - echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
| 695 | - return ''; |
|
| 696 | - } |
|
| 697 | - return $html; |
|
| 698 | - } |
|
| 644 | + /** |
|
| 645 | + * espresso_event_date_range |
|
| 646 | + * returns the first and last chronologically ordered dates for an event (if different) |
|
| 647 | + * |
|
| 648 | + * @param string $date_format |
|
| 649 | + * @param string $time_format |
|
| 650 | + * @param string $single_date_format |
|
| 651 | + * @param string $single_time_format |
|
| 652 | + * @param bool $EVT_ID |
|
| 653 | + * @param bool $echo |
|
| 654 | + * @return string |
|
| 655 | + * @throws EE_Error |
|
| 656 | + * @throws ReflectionException |
|
| 657 | + */ |
|
| 658 | + function espresso_event_date_range( |
|
| 659 | + $date_format = '', |
|
| 660 | + $time_format = '', |
|
| 661 | + $single_date_format = '', |
|
| 662 | + $single_time_format = '', |
|
| 663 | + $EVT_ID = false, |
|
| 664 | + $echo = true |
|
| 665 | + ) { |
|
| 666 | + // set and filter date and time formats when a range is returned |
|
| 667 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 668 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
| 669 | + // get the start and end date with NO time portion |
|
| 670 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
| 671 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
| 672 | + // now we can determine if date range spans more than one day |
|
| 673 | + if ($the_event_date != $the_event_end_date) { |
|
| 674 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 675 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
| 676 | + $html = sprintf( |
|
| 677 | + /* translators: 1: first event date, 2: last event date */ |
|
| 678 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
| 679 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
| 680 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
| 681 | + ); |
|
| 682 | + } else { |
|
| 683 | + // set and filter date and time formats when only a single datetime is returned |
|
| 684 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
| 685 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
| 686 | + $single_date_format = |
|
| 687 | + apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
| 688 | + $single_time_format = |
|
| 689 | + apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
| 690 | + $html = |
|
| 691 | + EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
| 692 | + } |
|
| 693 | + if ($echo) { |
|
| 694 | + echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
| 695 | + return ''; |
|
| 696 | + } |
|
| 697 | + return $html; |
|
| 698 | + } |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | if (! function_exists('espresso_next_upcoming_datetime_obj')) { |
| 702 | - /** |
|
| 703 | - * espresso_next_upcoming_datetime_obj |
|
| 704 | - * returns the next upcoming datetime object for an event |
|
| 705 | - * |
|
| 706 | - * @param int $EVT_ID |
|
| 707 | - * @return EE_Datetime|null |
|
| 708 | - * @throws EE_Error |
|
| 709 | - */ |
|
| 710 | - function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
| 711 | - { |
|
| 712 | - return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
| 713 | - } |
|
| 702 | + /** |
|
| 703 | + * espresso_next_upcoming_datetime_obj |
|
| 704 | + * returns the next upcoming datetime object for an event |
|
| 705 | + * |
|
| 706 | + * @param int $EVT_ID |
|
| 707 | + * @return EE_Datetime|null |
|
| 708 | + * @throws EE_Error |
|
| 709 | + */ |
|
| 710 | + function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
| 711 | + { |
|
| 712 | + return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
| 713 | + } |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | if (! function_exists('espresso_next_upcoming_datetime')) { |
| 717 | - /** |
|
| 718 | - * espresso_next_upcoming_datetime |
|
| 719 | - * returns the start date and time for the next upcoming event. |
|
| 720 | - * |
|
| 721 | - * @param string $date_format |
|
| 722 | - * @param string $time_format |
|
| 723 | - * @param int $EVT_ID |
|
| 724 | - * @param bool $echo |
|
| 725 | - * @return string |
|
| 726 | - * @throws EE_Error |
|
| 727 | - * @throws ReflectionException |
|
| 728 | - */ |
|
| 729 | - function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
| 730 | - { |
|
| 731 | - |
|
| 732 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 733 | - $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
| 734 | - |
|
| 735 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 736 | - $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
| 737 | - |
|
| 738 | - $datetime_format = trim($date_format . ' ' . $time_format); |
|
| 739 | - |
|
| 740 | - $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
| 741 | - |
|
| 742 | - if (! $datetime instanceof EE_Datetime) { |
|
| 743 | - return ''; |
|
| 744 | - } |
|
| 745 | - if ($echo) { |
|
| 746 | - echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format)); |
|
| 747 | - return ''; |
|
| 748 | - } |
|
| 749 | - return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
| 750 | - } |
|
| 717 | + /** |
|
| 718 | + * espresso_next_upcoming_datetime |
|
| 719 | + * returns the start date and time for the next upcoming event. |
|
| 720 | + * |
|
| 721 | + * @param string $date_format |
|
| 722 | + * @param string $time_format |
|
| 723 | + * @param int $EVT_ID |
|
| 724 | + * @param bool $echo |
|
| 725 | + * @return string |
|
| 726 | + * @throws EE_Error |
|
| 727 | + * @throws ReflectionException |
|
| 728 | + */ |
|
| 729 | + function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
| 730 | + { |
|
| 731 | + |
|
| 732 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 733 | + $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
| 734 | + |
|
| 735 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 736 | + $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
| 737 | + |
|
| 738 | + $datetime_format = trim($date_format . ' ' . $time_format); |
|
| 739 | + |
|
| 740 | + $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
| 741 | + |
|
| 742 | + if (! $datetime instanceof EE_Datetime) { |
|
| 743 | + return ''; |
|
| 744 | + } |
|
| 745 | + if ($echo) { |
|
| 746 | + echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format)); |
|
| 747 | + return ''; |
|
| 748 | + } |
|
| 749 | + return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
| 750 | + } |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | if (! function_exists('espresso_event_date_as_calendar_page')) { |
| 754 | - /** |
|
| 755 | - * espresso_event_date_as_calendar_page |
|
| 756 | - * returns the primary date for an event, stylized to appear as the page of a calendar |
|
| 757 | - * |
|
| 758 | - * @param bool $EVT_ID |
|
| 759 | - * @return void |
|
| 760 | - * @throws EE_Error |
|
| 761 | - * @throws ReflectionException |
|
| 762 | - */ |
|
| 763 | - function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
| 764 | - { |
|
| 765 | - EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
| 766 | - } |
|
| 754 | + /** |
|
| 755 | + * espresso_event_date_as_calendar_page |
|
| 756 | + * returns the primary date for an event, stylized to appear as the page of a calendar |
|
| 757 | + * |
|
| 758 | + * @param bool $EVT_ID |
|
| 759 | + * @return void |
|
| 760 | + * @throws EE_Error |
|
| 761 | + * @throws ReflectionException |
|
| 762 | + */ |
|
| 763 | + function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
| 764 | + { |
|
| 765 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
| 766 | + } |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | |
| 770 | 770 | if (! function_exists('espresso_event_link_url')) { |
| 771 | - /** |
|
| 772 | - * espresso_event_link_url |
|
| 773 | - * |
|
| 774 | - * @param int $EVT_ID |
|
| 775 | - * @param bool $echo |
|
| 776 | - * @return string |
|
| 777 | - * @throws EE_Error |
|
| 778 | - * @throws ReflectionException |
|
| 779 | - */ |
|
| 780 | - function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
| 781 | - { |
|
| 782 | - if ($echo) { |
|
| 783 | - echo EEH_Event_View::event_link_url($EVT_ID); // already escaped |
|
| 784 | - return ''; |
|
| 785 | - } |
|
| 786 | - return EEH_Event_View::event_link_url($EVT_ID); |
|
| 787 | - } |
|
| 771 | + /** |
|
| 772 | + * espresso_event_link_url |
|
| 773 | + * |
|
| 774 | + * @param int $EVT_ID |
|
| 775 | + * @param bool $echo |
|
| 776 | + * @return string |
|
| 777 | + * @throws EE_Error |
|
| 778 | + * @throws ReflectionException |
|
| 779 | + */ |
|
| 780 | + function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
| 781 | + { |
|
| 782 | + if ($echo) { |
|
| 783 | + echo EEH_Event_View::event_link_url($EVT_ID); // already escaped |
|
| 784 | + return ''; |
|
| 785 | + } |
|
| 786 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
| 787 | + } |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | |
| 791 | 791 | if (! function_exists('espresso_event_has_content_or_excerpt')) { |
| 792 | - /** |
|
| 793 | - * espresso_event_has_content_or_excerpt |
|
| 794 | - * |
|
| 795 | - * @access public |
|
| 796 | - * @param bool $EVT_ID |
|
| 797 | - * @return boolean |
|
| 798 | - * @throws EE_Error |
|
| 799 | - * @throws ReflectionException |
|
| 800 | - */ |
|
| 801 | - function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
| 802 | - { |
|
| 803 | - return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
| 804 | - } |
|
| 792 | + /** |
|
| 793 | + * espresso_event_has_content_or_excerpt |
|
| 794 | + * |
|
| 795 | + * @access public |
|
| 796 | + * @param bool $EVT_ID |
|
| 797 | + * @return boolean |
|
| 798 | + * @throws EE_Error |
|
| 799 | + * @throws ReflectionException |
|
| 800 | + */ |
|
| 801 | + function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
| 802 | + { |
|
| 803 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
| 804 | + } |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | |
| 808 | 808 | if (! function_exists('espresso_event_content_or_excerpt')) { |
| 809 | - /** |
|
| 810 | - * espresso_event_content_or_excerpt |
|
| 811 | - * |
|
| 812 | - * @param int $num_words |
|
| 813 | - * @param null $more |
|
| 814 | - * @param bool $echo |
|
| 815 | - * @return string |
|
| 816 | - */ |
|
| 817 | - function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
| 818 | - { |
|
| 819 | - if ($echo) { |
|
| 820 | - echo EEH_Event_View::event_content_or_excerpt($num_words, $more); // already escaped |
|
| 821 | - return ''; |
|
| 822 | - } |
|
| 823 | - return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
| 824 | - } |
|
| 809 | + /** |
|
| 810 | + * espresso_event_content_or_excerpt |
|
| 811 | + * |
|
| 812 | + * @param int $num_words |
|
| 813 | + * @param null $more |
|
| 814 | + * @param bool $echo |
|
| 815 | + * @return string |
|
| 816 | + */ |
|
| 817 | + function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
| 818 | + { |
|
| 819 | + if ($echo) { |
|
| 820 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); // already escaped |
|
| 821 | + return ''; |
|
| 822 | + } |
|
| 823 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
| 824 | + } |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | |
| 828 | 828 | if (! function_exists('espresso_event_phone')) { |
| 829 | - /** |
|
| 830 | - * espresso_event_phone |
|
| 831 | - * |
|
| 832 | - * @param int $EVT_ID |
|
| 833 | - * @param bool $echo |
|
| 834 | - * @return string |
|
| 835 | - * @throws EE_Error |
|
| 836 | - * @throws ReflectionException |
|
| 837 | - */ |
|
| 838 | - function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
| 839 | - { |
|
| 840 | - if ($echo) { |
|
| 841 | - echo EEH_Event_View::event_phone($EVT_ID); // already escaped |
|
| 842 | - return ''; |
|
| 843 | - } |
|
| 844 | - return EEH_Event_View::event_phone($EVT_ID); |
|
| 845 | - } |
|
| 829 | + /** |
|
| 830 | + * espresso_event_phone |
|
| 831 | + * |
|
| 832 | + * @param int $EVT_ID |
|
| 833 | + * @param bool $echo |
|
| 834 | + * @return string |
|
| 835 | + * @throws EE_Error |
|
| 836 | + * @throws ReflectionException |
|
| 837 | + */ |
|
| 838 | + function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
| 839 | + { |
|
| 840 | + if ($echo) { |
|
| 841 | + echo EEH_Event_View::event_phone($EVT_ID); // already escaped |
|
| 842 | + return ''; |
|
| 843 | + } |
|
| 844 | + return EEH_Event_View::event_phone($EVT_ID); |
|
| 845 | + } |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | |
| 849 | 849 | if (! function_exists('espresso_edit_event_link')) { |
| 850 | - /** |
|
| 851 | - * espresso_edit_event_link |
|
| 852 | - * returns a link to edit an event |
|
| 853 | - * |
|
| 854 | - * @param int $EVT_ID |
|
| 855 | - * @param bool $echo |
|
| 856 | - * @return string |
|
| 857 | - * @throws EE_Error |
|
| 858 | - * @throws ReflectionException |
|
| 859 | - */ |
|
| 860 | - function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
| 861 | - { |
|
| 862 | - if ($echo) { |
|
| 863 | - echo EEH_Event_View::edit_event_link($EVT_ID); // already escaped |
|
| 864 | - return ''; |
|
| 865 | - } |
|
| 866 | - return EEH_Event_View::edit_event_link($EVT_ID); |
|
| 867 | - } |
|
| 850 | + /** |
|
| 851 | + * espresso_edit_event_link |
|
| 852 | + * returns a link to edit an event |
|
| 853 | + * |
|
| 854 | + * @param int $EVT_ID |
|
| 855 | + * @param bool $echo |
|
| 856 | + * @return string |
|
| 857 | + * @throws EE_Error |
|
| 858 | + * @throws ReflectionException |
|
| 859 | + */ |
|
| 860 | + function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
| 861 | + { |
|
| 862 | + if ($echo) { |
|
| 863 | + echo EEH_Event_View::edit_event_link($EVT_ID); // already escaped |
|
| 864 | + return ''; |
|
| 865 | + } |
|
| 866 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
| 867 | + } |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | |
| 871 | 871 | if (! function_exists('espresso_organization_name')) { |
| 872 | - /** |
|
| 873 | - * espresso_organization_name |
|
| 874 | - * |
|
| 875 | - * @param bool $echo |
|
| 876 | - * @return string |
|
| 877 | - * @throws EE_Error |
|
| 878 | - */ |
|
| 879 | - function espresso_organization_name($echo = true) |
|
| 880 | - { |
|
| 881 | - if ($echo) { |
|
| 882 | - echo EE_Registry::instance()->CFG->organization->get_pretty('name'); // already escaped |
|
| 883 | - return ''; |
|
| 884 | - } |
|
| 885 | - return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
| 886 | - } |
|
| 872 | + /** |
|
| 873 | + * espresso_organization_name |
|
| 874 | + * |
|
| 875 | + * @param bool $echo |
|
| 876 | + * @return string |
|
| 877 | + * @throws EE_Error |
|
| 878 | + */ |
|
| 879 | + function espresso_organization_name($echo = true) |
|
| 880 | + { |
|
| 881 | + if ($echo) { |
|
| 882 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); // already escaped |
|
| 883 | + return ''; |
|
| 884 | + } |
|
| 885 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
| 886 | + } |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | if (! function_exists('espresso_organization_address')) { |
| 890 | - /** |
|
| 891 | - * espresso_organization_address |
|
| 892 | - * |
|
| 893 | - * @param string $type |
|
| 894 | - * @return string |
|
| 895 | - */ |
|
| 896 | - function espresso_organization_address($type = 'inline') |
|
| 897 | - { |
|
| 898 | - if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
| 899 | - $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
| 900 | - EE_Registry::instance()->CFG->organization->address_1, |
|
| 901 | - EE_Registry::instance()->CFG->organization->address_2, |
|
| 902 | - EE_Registry::instance()->CFG->organization->city, |
|
| 903 | - EE_Registry::instance()->CFG->organization->STA_ID, |
|
| 904 | - EE_Registry::instance()->CFG->organization->zip, |
|
| 905 | - EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 906 | - ); |
|
| 907 | - return EEH_Address::format($address, $type); |
|
| 908 | - } |
|
| 909 | - return ''; |
|
| 910 | - } |
|
| 890 | + /** |
|
| 891 | + * espresso_organization_address |
|
| 892 | + * |
|
| 893 | + * @param string $type |
|
| 894 | + * @return string |
|
| 895 | + */ |
|
| 896 | + function espresso_organization_address($type = 'inline') |
|
| 897 | + { |
|
| 898 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
| 899 | + $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
| 900 | + EE_Registry::instance()->CFG->organization->address_1, |
|
| 901 | + EE_Registry::instance()->CFG->organization->address_2, |
|
| 902 | + EE_Registry::instance()->CFG->organization->city, |
|
| 903 | + EE_Registry::instance()->CFG->organization->STA_ID, |
|
| 904 | + EE_Registry::instance()->CFG->organization->zip, |
|
| 905 | + EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 906 | + ); |
|
| 907 | + return EEH_Address::format($address, $type); |
|
| 908 | + } |
|
| 909 | + return ''; |
|
| 910 | + } |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | if (! function_exists('espresso_organization_email')) { |
| 914 | - /** |
|
| 915 | - * espresso_organization_email |
|
| 916 | - * |
|
| 917 | - * @param bool $echo |
|
| 918 | - * @return string |
|
| 919 | - * @throws EE_Error |
|
| 920 | - */ |
|
| 921 | - function espresso_organization_email($echo = true) |
|
| 922 | - { |
|
| 923 | - if ($echo) { |
|
| 924 | - echo EE_Registry::instance()->CFG->organization->get_pretty('email'); // already escaped |
|
| 925 | - return ''; |
|
| 926 | - } |
|
| 927 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
| 928 | - } |
|
| 914 | + /** |
|
| 915 | + * espresso_organization_email |
|
| 916 | + * |
|
| 917 | + * @param bool $echo |
|
| 918 | + * @return string |
|
| 919 | + * @throws EE_Error |
|
| 920 | + */ |
|
| 921 | + function espresso_organization_email($echo = true) |
|
| 922 | + { |
|
| 923 | + if ($echo) { |
|
| 924 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); // already escaped |
|
| 925 | + return ''; |
|
| 926 | + } |
|
| 927 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
| 928 | + } |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | if (! function_exists('espresso_organization_logo_url')) { |
| 932 | - /** |
|
| 933 | - * espresso_organization_logo_url |
|
| 934 | - * |
|
| 935 | - * @param bool $echo |
|
| 936 | - * @return string |
|
| 937 | - * @throws EE_Error |
|
| 938 | - */ |
|
| 939 | - function espresso_organization_logo_url($echo = true) |
|
| 940 | - { |
|
| 941 | - if ($echo) { |
|
| 942 | - echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); // already escaped |
|
| 943 | - return ''; |
|
| 944 | - } |
|
| 945 | - return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
| 946 | - } |
|
| 932 | + /** |
|
| 933 | + * espresso_organization_logo_url |
|
| 934 | + * |
|
| 935 | + * @param bool $echo |
|
| 936 | + * @return string |
|
| 937 | + * @throws EE_Error |
|
| 938 | + */ |
|
| 939 | + function espresso_organization_logo_url($echo = true) |
|
| 940 | + { |
|
| 941 | + if ($echo) { |
|
| 942 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); // already escaped |
|
| 943 | + return ''; |
|
| 944 | + } |
|
| 945 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
| 946 | + } |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | if (! function_exists('espresso_organization_facebook')) { |
| 950 | - /** |
|
| 951 | - * espresso_organization_facebook |
|
| 952 | - * |
|
| 953 | - * @param bool $echo |
|
| 954 | - * @return string |
|
| 955 | - * @throws EE_Error |
|
| 956 | - */ |
|
| 957 | - function espresso_organization_facebook($echo = true) |
|
| 958 | - { |
|
| 959 | - if ($echo) { |
|
| 960 | - echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); // already escaped |
|
| 961 | - return ''; |
|
| 962 | - } |
|
| 963 | - return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
| 964 | - } |
|
| 950 | + /** |
|
| 951 | + * espresso_organization_facebook |
|
| 952 | + * |
|
| 953 | + * @param bool $echo |
|
| 954 | + * @return string |
|
| 955 | + * @throws EE_Error |
|
| 956 | + */ |
|
| 957 | + function espresso_organization_facebook($echo = true) |
|
| 958 | + { |
|
| 959 | + if ($echo) { |
|
| 960 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); // already escaped |
|
| 961 | + return ''; |
|
| 962 | + } |
|
| 963 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
| 964 | + } |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | if (! function_exists('espresso_organization_twitter')) { |
| 968 | - /** |
|
| 969 | - * espresso_organization_twitter |
|
| 970 | - * |
|
| 971 | - * @param bool $echo |
|
| 972 | - * @return string |
|
| 973 | - * @throws EE_Error |
|
| 974 | - */ |
|
| 975 | - function espresso_organization_twitter($echo = true) |
|
| 976 | - { |
|
| 977 | - if ($echo) { |
|
| 978 | - echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); // already escaped |
|
| 979 | - return ''; |
|
| 980 | - } |
|
| 981 | - return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
| 982 | - } |
|
| 968 | + /** |
|
| 969 | + * espresso_organization_twitter |
|
| 970 | + * |
|
| 971 | + * @param bool $echo |
|
| 972 | + * @return string |
|
| 973 | + * @throws EE_Error |
|
| 974 | + */ |
|
| 975 | + function espresso_organization_twitter($echo = true) |
|
| 976 | + { |
|
| 977 | + if ($echo) { |
|
| 978 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); // already escaped |
|
| 979 | + return ''; |
|
| 980 | + } |
|
| 981 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
| 982 | + } |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | if (! function_exists('espresso_organization_linkedin')) { |
| 986 | - /** |
|
| 987 | - * espresso_organization_linkedin |
|
| 988 | - * |
|
| 989 | - * @param bool $echo |
|
| 990 | - * @return string |
|
| 991 | - * @throws EE_Error |
|
| 992 | - */ |
|
| 993 | - function espresso_organization_linkedin($echo = true) |
|
| 994 | - { |
|
| 995 | - if ($echo) { |
|
| 996 | - echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); // already escaped |
|
| 997 | - return ''; |
|
| 998 | - } |
|
| 999 | - return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
| 1000 | - } |
|
| 986 | + /** |
|
| 987 | + * espresso_organization_linkedin |
|
| 988 | + * |
|
| 989 | + * @param bool $echo |
|
| 990 | + * @return string |
|
| 991 | + * @throws EE_Error |
|
| 992 | + */ |
|
| 993 | + function espresso_organization_linkedin($echo = true) |
|
| 994 | + { |
|
| 995 | + if ($echo) { |
|
| 996 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); // already escaped |
|
| 997 | + return ''; |
|
| 998 | + } |
|
| 999 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
| 1000 | + } |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | if (! function_exists('espresso_organization_pinterest')) { |
| 1004 | - /** |
|
| 1005 | - * espresso_organization_pinterest |
|
| 1006 | - * |
|
| 1007 | - * @param bool $echo |
|
| 1008 | - * @return string |
|
| 1009 | - * @throws EE_Error |
|
| 1010 | - */ |
|
| 1011 | - function espresso_organization_pinterest($echo = true) |
|
| 1012 | - { |
|
| 1013 | - if ($echo) { |
|
| 1014 | - echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); // already escaped |
|
| 1015 | - return ''; |
|
| 1016 | - } |
|
| 1017 | - return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
| 1018 | - } |
|
| 1004 | + /** |
|
| 1005 | + * espresso_organization_pinterest |
|
| 1006 | + * |
|
| 1007 | + * @param bool $echo |
|
| 1008 | + * @return string |
|
| 1009 | + * @throws EE_Error |
|
| 1010 | + */ |
|
| 1011 | + function espresso_organization_pinterest($echo = true) |
|
| 1012 | + { |
|
| 1013 | + if ($echo) { |
|
| 1014 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); // already escaped |
|
| 1015 | + return ''; |
|
| 1016 | + } |
|
| 1017 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
| 1018 | + } |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | if (! function_exists('espresso_organization_google')) { |
| 1022 | - /** |
|
| 1023 | - * espresso_organization_google |
|
| 1024 | - * |
|
| 1025 | - * @param bool $echo |
|
| 1026 | - * @return string |
|
| 1027 | - * @throws EE_Error |
|
| 1028 | - */ |
|
| 1029 | - function espresso_organization_google($echo = true) |
|
| 1030 | - { |
|
| 1031 | - if ($echo) { |
|
| 1032 | - echo EE_Registry::instance()->CFG->organization->get_pretty('google'); // already escaped |
|
| 1033 | - return ''; |
|
| 1034 | - } |
|
| 1035 | - return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
| 1036 | - } |
|
| 1022 | + /** |
|
| 1023 | + * espresso_organization_google |
|
| 1024 | + * |
|
| 1025 | + * @param bool $echo |
|
| 1026 | + * @return string |
|
| 1027 | + * @throws EE_Error |
|
| 1028 | + */ |
|
| 1029 | + function espresso_organization_google($echo = true) |
|
| 1030 | + { |
|
| 1031 | + if ($echo) { |
|
| 1032 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); // already escaped |
|
| 1033 | + return ''; |
|
| 1034 | + } |
|
| 1035 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
| 1036 | + } |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | if (! function_exists('espresso_organization_instagram')) { |
| 1040 | - /** |
|
| 1041 | - * espresso_organization_instagram |
|
| 1042 | - * |
|
| 1043 | - * @param bool $echo |
|
| 1044 | - * @return string |
|
| 1045 | - * @throws EE_Error |
|
| 1046 | - */ |
|
| 1047 | - function espresso_organization_instagram($echo = true) |
|
| 1048 | - { |
|
| 1049 | - if ($echo) { |
|
| 1050 | - echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); // already escaped |
|
| 1051 | - return ''; |
|
| 1052 | - } |
|
| 1053 | - return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
| 1054 | - } |
|
| 1040 | + /** |
|
| 1041 | + * espresso_organization_instagram |
|
| 1042 | + * |
|
| 1043 | + * @param bool $echo |
|
| 1044 | + * @return string |
|
| 1045 | + * @throws EE_Error |
|
| 1046 | + */ |
|
| 1047 | + function espresso_organization_instagram($echo = true) |
|
| 1048 | + { |
|
| 1049 | + if ($echo) { |
|
| 1050 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); // already escaped |
|
| 1051 | + return ''; |
|
| 1052 | + } |
|
| 1053 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
| 1054 | + } |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | |
@@ -1059,345 +1059,345 @@ discard block |
||
| 1059 | 1059 | |
| 1060 | 1060 | |
| 1061 | 1061 | if (! function_exists('espresso_event_venues')) { |
| 1062 | - /** |
|
| 1063 | - * espresso_event_venues |
|
| 1064 | - * |
|
| 1065 | - * @return array all venues related to an event |
|
| 1066 | - * @throws EE_Error |
|
| 1067 | - * @throws ReflectionException |
|
| 1068 | - */ |
|
| 1069 | - function espresso_event_venues() |
|
| 1070 | - { |
|
| 1071 | - return EEH_Venue_View::get_event_venues(); |
|
| 1072 | - } |
|
| 1062 | + /** |
|
| 1063 | + * espresso_event_venues |
|
| 1064 | + * |
|
| 1065 | + * @return array all venues related to an event |
|
| 1066 | + * @throws EE_Error |
|
| 1067 | + * @throws ReflectionException |
|
| 1068 | + */ |
|
| 1069 | + function espresso_event_venues() |
|
| 1070 | + { |
|
| 1071 | + return EEH_Venue_View::get_event_venues(); |
|
| 1072 | + } |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | |
| 1076 | 1076 | if (! function_exists('espresso_venue_id')) { |
| 1077 | - /** |
|
| 1078 | - * espresso_venue_name |
|
| 1079 | - * |
|
| 1080 | - * @access public |
|
| 1081 | - * @param int $EVT_ID |
|
| 1082 | - * @return string |
|
| 1083 | - * @throws EE_Error |
|
| 1084 | - * @throws ReflectionException |
|
| 1085 | - */ |
|
| 1086 | - function espresso_venue_id($EVT_ID = 0) |
|
| 1087 | - { |
|
| 1088 | - $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
| 1089 | - return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
| 1090 | - } |
|
| 1077 | + /** |
|
| 1078 | + * espresso_venue_name |
|
| 1079 | + * |
|
| 1080 | + * @access public |
|
| 1081 | + * @param int $EVT_ID |
|
| 1082 | + * @return string |
|
| 1083 | + * @throws EE_Error |
|
| 1084 | + * @throws ReflectionException |
|
| 1085 | + */ |
|
| 1086 | + function espresso_venue_id($EVT_ID = 0) |
|
| 1087 | + { |
|
| 1088 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
| 1089 | + return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
| 1090 | + } |
|
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | |
| 1094 | 1094 | if (! function_exists('espresso_is_venue_private')) { |
| 1095 | - /** |
|
| 1096 | - * Return whether a venue is private or not. |
|
| 1097 | - * |
|
| 1098 | - * @param int $VNU_ID optional, the venue id to check. |
|
| 1099 | - * |
|
| 1100 | - * @return bool | null |
|
| 1101 | - * @throws EE_Error |
|
| 1102 | - * @throws ReflectionException |
|
| 1103 | - * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
| 1104 | - */ |
|
| 1105 | - function espresso_is_venue_private($VNU_ID = 0) |
|
| 1106 | - { |
|
| 1107 | - return EEH_Venue_View::is_venue_private($VNU_ID); |
|
| 1108 | - } |
|
| 1095 | + /** |
|
| 1096 | + * Return whether a venue is private or not. |
|
| 1097 | + * |
|
| 1098 | + * @param int $VNU_ID optional, the venue id to check. |
|
| 1099 | + * |
|
| 1100 | + * @return bool | null |
|
| 1101 | + * @throws EE_Error |
|
| 1102 | + * @throws ReflectionException |
|
| 1103 | + * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
| 1104 | + */ |
|
| 1105 | + function espresso_is_venue_private($VNU_ID = 0) |
|
| 1106 | + { |
|
| 1107 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
| 1108 | + } |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | |
| 1112 | 1112 | if (! function_exists('espresso_venue_is_password_protected')) { |
| 1113 | - /** |
|
| 1114 | - * returns true or false if a venue is password protected or not |
|
| 1115 | - * |
|
| 1116 | - * @param int $VNU_ID optional, the venue id to check. |
|
| 1117 | - * @return bool |
|
| 1118 | - * @throws EE_Error |
|
| 1119 | - * @throws ReflectionException |
|
| 1120 | - */ |
|
| 1121 | - function espresso_venue_is_password_protected($VNU_ID = 0) |
|
| 1122 | - { |
|
| 1123 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
| 1124 | - return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
| 1125 | - } |
|
| 1113 | + /** |
|
| 1114 | + * returns true or false if a venue is password protected or not |
|
| 1115 | + * |
|
| 1116 | + * @param int $VNU_ID optional, the venue id to check. |
|
| 1117 | + * @return bool |
|
| 1118 | + * @throws EE_Error |
|
| 1119 | + * @throws ReflectionException |
|
| 1120 | + */ |
|
| 1121 | + function espresso_venue_is_password_protected($VNU_ID = 0) |
|
| 1122 | + { |
|
| 1123 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
| 1124 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
| 1125 | + } |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | |
| 1129 | 1129 | if (! function_exists('espresso_password_protected_venue_form')) { |
| 1130 | - /** |
|
| 1131 | - * Returns a password form if venue is password protected. |
|
| 1132 | - * |
|
| 1133 | - * @param int $VNU_ID optional, the venue id to check. |
|
| 1134 | - * @return string |
|
| 1135 | - * @throws EE_Error |
|
| 1136 | - * @throws ReflectionException |
|
| 1137 | - */ |
|
| 1138 | - function espresso_password_protected_venue_form($VNU_ID = 0) |
|
| 1139 | - { |
|
| 1140 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
| 1141 | - return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
| 1142 | - } |
|
| 1130 | + /** |
|
| 1131 | + * Returns a password form if venue is password protected. |
|
| 1132 | + * |
|
| 1133 | + * @param int $VNU_ID optional, the venue id to check. |
|
| 1134 | + * @return string |
|
| 1135 | + * @throws EE_Error |
|
| 1136 | + * @throws ReflectionException |
|
| 1137 | + */ |
|
| 1138 | + function espresso_password_protected_venue_form($VNU_ID = 0) |
|
| 1139 | + { |
|
| 1140 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
| 1141 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
| 1142 | + } |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | |
| 1146 | 1146 | if (! function_exists('espresso_venue_name')) { |
| 1147 | - /** |
|
| 1148 | - * espresso_venue_name |
|
| 1149 | - * |
|
| 1150 | - * @access public |
|
| 1151 | - * @param int $VNU_ID |
|
| 1152 | - * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
| 1153 | - * @param bool $echo |
|
| 1154 | - * @return string |
|
| 1155 | - * @throws EE_Error |
|
| 1156 | - * @throws ReflectionException |
|
| 1157 | - */ |
|
| 1158 | - function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
| 1159 | - { |
|
| 1160 | - if ($echo) { |
|
| 1161 | - echo EEH_Venue_View::venue_name($link_to, $VNU_ID); // already escaped |
|
| 1162 | - return ''; |
|
| 1163 | - } |
|
| 1164 | - return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
| 1165 | - } |
|
| 1147 | + /** |
|
| 1148 | + * espresso_venue_name |
|
| 1149 | + * |
|
| 1150 | + * @access public |
|
| 1151 | + * @param int $VNU_ID |
|
| 1152 | + * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
| 1153 | + * @param bool $echo |
|
| 1154 | + * @return string |
|
| 1155 | + * @throws EE_Error |
|
| 1156 | + * @throws ReflectionException |
|
| 1157 | + */ |
|
| 1158 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
| 1159 | + { |
|
| 1160 | + if ($echo) { |
|
| 1161 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); // already escaped |
|
| 1162 | + return ''; |
|
| 1163 | + } |
|
| 1164 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
| 1165 | + } |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | |
| 1169 | 1169 | if (! function_exists('espresso_venue_link')) { |
| 1170 | - /** |
|
| 1171 | - * espresso_venue_link |
|
| 1172 | - * |
|
| 1173 | - * @access public |
|
| 1174 | - * @param int $VNU_ID |
|
| 1175 | - * @param string $text |
|
| 1176 | - * @return string |
|
| 1177 | - * @throws EE_Error |
|
| 1178 | - * @throws ReflectionException |
|
| 1179 | - */ |
|
| 1180 | - function espresso_venue_link($VNU_ID = 0, $text = '') |
|
| 1181 | - { |
|
| 1182 | - return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
| 1183 | - } |
|
| 1170 | + /** |
|
| 1171 | + * espresso_venue_link |
|
| 1172 | + * |
|
| 1173 | + * @access public |
|
| 1174 | + * @param int $VNU_ID |
|
| 1175 | + * @param string $text |
|
| 1176 | + * @return string |
|
| 1177 | + * @throws EE_Error |
|
| 1178 | + * @throws ReflectionException |
|
| 1179 | + */ |
|
| 1180 | + function espresso_venue_link($VNU_ID = 0, $text = '') |
|
| 1181 | + { |
|
| 1182 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
| 1183 | + } |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | |
| 1187 | 1187 | if (! function_exists('espresso_venue_description')) { |
| 1188 | - /** |
|
| 1189 | - * espresso_venue_description |
|
| 1190 | - * |
|
| 1191 | - * @access public |
|
| 1192 | - * @param bool $VNU_ID |
|
| 1193 | - * @param bool $echo |
|
| 1194 | - * @return string |
|
| 1195 | - * @throws EE_Error |
|
| 1196 | - * @throws ReflectionException |
|
| 1197 | - */ |
|
| 1198 | - function espresso_venue_description($VNU_ID = false, $echo = true) |
|
| 1199 | - { |
|
| 1200 | - if ($echo) { |
|
| 1201 | - echo EEH_Venue_View::venue_description($VNU_ID); // already escaped |
|
| 1202 | - return ''; |
|
| 1203 | - } |
|
| 1204 | - return EEH_Venue_View::venue_description($VNU_ID); |
|
| 1205 | - } |
|
| 1188 | + /** |
|
| 1189 | + * espresso_venue_description |
|
| 1190 | + * |
|
| 1191 | + * @access public |
|
| 1192 | + * @param bool $VNU_ID |
|
| 1193 | + * @param bool $echo |
|
| 1194 | + * @return string |
|
| 1195 | + * @throws EE_Error |
|
| 1196 | + * @throws ReflectionException |
|
| 1197 | + */ |
|
| 1198 | + function espresso_venue_description($VNU_ID = false, $echo = true) |
|
| 1199 | + { |
|
| 1200 | + if ($echo) { |
|
| 1201 | + echo EEH_Venue_View::venue_description($VNU_ID); // already escaped |
|
| 1202 | + return ''; |
|
| 1203 | + } |
|
| 1204 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
| 1205 | + } |
|
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | 1208 | |
| 1209 | 1209 | if (! function_exists('espresso_venue_excerpt')) { |
| 1210 | - /** |
|
| 1211 | - * espresso_venue_excerpt |
|
| 1212 | - * |
|
| 1213 | - * @access public |
|
| 1214 | - * @param int $VNU_ID |
|
| 1215 | - * @param bool $echo |
|
| 1216 | - * @return string |
|
| 1217 | - * @throws EE_Error |
|
| 1218 | - * @throws ReflectionException |
|
| 1219 | - */ |
|
| 1220 | - function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
| 1221 | - { |
|
| 1222 | - if ($echo) { |
|
| 1223 | - echo EEH_Venue_View::venue_excerpt($VNU_ID); // already escaped |
|
| 1224 | - return ''; |
|
| 1225 | - } |
|
| 1226 | - return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
| 1227 | - } |
|
| 1210 | + /** |
|
| 1211 | + * espresso_venue_excerpt |
|
| 1212 | + * |
|
| 1213 | + * @access public |
|
| 1214 | + * @param int $VNU_ID |
|
| 1215 | + * @param bool $echo |
|
| 1216 | + * @return string |
|
| 1217 | + * @throws EE_Error |
|
| 1218 | + * @throws ReflectionException |
|
| 1219 | + */ |
|
| 1220 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
| 1221 | + { |
|
| 1222 | + if ($echo) { |
|
| 1223 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); // already escaped |
|
| 1224 | + return ''; |
|
| 1225 | + } |
|
| 1226 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
| 1227 | + } |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | |
| 1231 | 1231 | if (! function_exists('espresso_venue_categories')) { |
| 1232 | - /** |
|
| 1233 | - * espresso_venue_categories |
|
| 1234 | - * returns the terms associated with a venue |
|
| 1235 | - * |
|
| 1236 | - * @param int $VNU_ID |
|
| 1237 | - * @param bool $hide_uncategorized |
|
| 1238 | - * @param bool $echo |
|
| 1239 | - * @return string |
|
| 1240 | - * @throws EE_Error |
|
| 1241 | - * @throws ReflectionException |
|
| 1242 | - */ |
|
| 1243 | - function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
| 1244 | - { |
|
| 1245 | - if ($echo) { |
|
| 1246 | - echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); // already escaped |
|
| 1247 | - return ''; |
|
| 1248 | - } |
|
| 1249 | - return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
| 1250 | - } |
|
| 1232 | + /** |
|
| 1233 | + * espresso_venue_categories |
|
| 1234 | + * returns the terms associated with a venue |
|
| 1235 | + * |
|
| 1236 | + * @param int $VNU_ID |
|
| 1237 | + * @param bool $hide_uncategorized |
|
| 1238 | + * @param bool $echo |
|
| 1239 | + * @return string |
|
| 1240 | + * @throws EE_Error |
|
| 1241 | + * @throws ReflectionException |
|
| 1242 | + */ |
|
| 1243 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
| 1244 | + { |
|
| 1245 | + if ($echo) { |
|
| 1246 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); // already escaped |
|
| 1247 | + return ''; |
|
| 1248 | + } |
|
| 1249 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
| 1250 | + } |
|
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | |
| 1254 | 1254 | if (! function_exists('espresso_venue_address')) { |
| 1255 | - /** |
|
| 1256 | - * espresso_venue_address |
|
| 1257 | - * returns a formatted block of html for displaying a venue's address |
|
| 1258 | - * |
|
| 1259 | - * @param string $type 'inline' or 'multiline' |
|
| 1260 | - * @param int $VNU_ID |
|
| 1261 | - * @param bool $echo |
|
| 1262 | - * @return string |
|
| 1263 | - * @throws EE_Error |
|
| 1264 | - * @throws ReflectionException |
|
| 1265 | - */ |
|
| 1266 | - function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
| 1267 | - { |
|
| 1268 | - if ($echo) { |
|
| 1269 | - echo EEH_Venue_View::venue_address($type, $VNU_ID); // already escaped |
|
| 1270 | - return ''; |
|
| 1271 | - } |
|
| 1272 | - return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
| 1273 | - } |
|
| 1255 | + /** |
|
| 1256 | + * espresso_venue_address |
|
| 1257 | + * returns a formatted block of html for displaying a venue's address |
|
| 1258 | + * |
|
| 1259 | + * @param string $type 'inline' or 'multiline' |
|
| 1260 | + * @param int $VNU_ID |
|
| 1261 | + * @param bool $echo |
|
| 1262 | + * @return string |
|
| 1263 | + * @throws EE_Error |
|
| 1264 | + * @throws ReflectionException |
|
| 1265 | + */ |
|
| 1266 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
| 1267 | + { |
|
| 1268 | + if ($echo) { |
|
| 1269 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); // already escaped |
|
| 1270 | + return ''; |
|
| 1271 | + } |
|
| 1272 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
| 1273 | + } |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | 1276 | |
| 1277 | 1277 | if (! function_exists('espresso_venue_raw_address')) { |
| 1278 | - /** |
|
| 1279 | - * espresso_venue_address |
|
| 1280 | - * returns an UN-formatted string containing a venue's address |
|
| 1281 | - * |
|
| 1282 | - * @param string $type 'inline' or 'multiline' |
|
| 1283 | - * @param int $VNU_ID |
|
| 1284 | - * @param bool $echo |
|
| 1285 | - * @return string |
|
| 1286 | - * @throws EE_Error |
|
| 1287 | - * @throws ReflectionException |
|
| 1288 | - */ |
|
| 1289 | - function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
| 1290 | - { |
|
| 1291 | - if ($echo) { |
|
| 1292 | - echo EEH_Venue_View::venue_address($type, $VNU_ID, false, false); // already escaped |
|
| 1293 | - return ''; |
|
| 1294 | - } |
|
| 1295 | - return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
| 1296 | - } |
|
| 1278 | + /** |
|
| 1279 | + * espresso_venue_address |
|
| 1280 | + * returns an UN-formatted string containing a venue's address |
|
| 1281 | + * |
|
| 1282 | + * @param string $type 'inline' or 'multiline' |
|
| 1283 | + * @param int $VNU_ID |
|
| 1284 | + * @param bool $echo |
|
| 1285 | + * @return string |
|
| 1286 | + * @throws EE_Error |
|
| 1287 | + * @throws ReflectionException |
|
| 1288 | + */ |
|
| 1289 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
| 1290 | + { |
|
| 1291 | + if ($echo) { |
|
| 1292 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, false, false); // already escaped |
|
| 1293 | + return ''; |
|
| 1294 | + } |
|
| 1295 | + return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
| 1296 | + } |
|
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | 1299 | |
| 1300 | 1300 | if (! function_exists('espresso_venue_has_address')) { |
| 1301 | - /** |
|
| 1302 | - * espresso_venue_has_address |
|
| 1303 | - * returns TRUE or FALSE if a Venue has address information |
|
| 1304 | - * |
|
| 1305 | - * @param int $VNU_ID |
|
| 1306 | - * @return bool |
|
| 1307 | - * @throws EE_Error |
|
| 1308 | - * @throws ReflectionException |
|
| 1309 | - */ |
|
| 1310 | - function espresso_venue_has_address($VNU_ID = 0) |
|
| 1311 | - { |
|
| 1312 | - return EEH_Venue_View::venue_has_address($VNU_ID); |
|
| 1313 | - } |
|
| 1301 | + /** |
|
| 1302 | + * espresso_venue_has_address |
|
| 1303 | + * returns TRUE or FALSE if a Venue has address information |
|
| 1304 | + * |
|
| 1305 | + * @param int $VNU_ID |
|
| 1306 | + * @return bool |
|
| 1307 | + * @throws EE_Error |
|
| 1308 | + * @throws ReflectionException |
|
| 1309 | + */ |
|
| 1310 | + function espresso_venue_has_address($VNU_ID = 0) |
|
| 1311 | + { |
|
| 1312 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
| 1313 | + } |
|
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | |
| 1317 | 1317 | if (! function_exists('espresso_venue_gmap')) { |
| 1318 | - /** |
|
| 1319 | - * espresso_venue_gmap |
|
| 1320 | - * returns a google map for the venue address |
|
| 1321 | - * |
|
| 1322 | - * @param int $VNU_ID |
|
| 1323 | - * @param bool $map_ID |
|
| 1324 | - * @param array $gmap |
|
| 1325 | - * @param bool $echo |
|
| 1326 | - * @return string |
|
| 1327 | - * @throws EE_Error |
|
| 1328 | - * @throws ReflectionException |
|
| 1329 | - */ |
|
| 1330 | - function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
| 1331 | - { |
|
| 1332 | - if ($echo) { |
|
| 1333 | - echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
| 1334 | - return ''; |
|
| 1335 | - } |
|
| 1336 | - return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
| 1337 | - } |
|
| 1318 | + /** |
|
| 1319 | + * espresso_venue_gmap |
|
| 1320 | + * returns a google map for the venue address |
|
| 1321 | + * |
|
| 1322 | + * @param int $VNU_ID |
|
| 1323 | + * @param bool $map_ID |
|
| 1324 | + * @param array $gmap |
|
| 1325 | + * @param bool $echo |
|
| 1326 | + * @return string |
|
| 1327 | + * @throws EE_Error |
|
| 1328 | + * @throws ReflectionException |
|
| 1329 | + */ |
|
| 1330 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
| 1331 | + { |
|
| 1332 | + if ($echo) { |
|
| 1333 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
| 1334 | + return ''; |
|
| 1335 | + } |
|
| 1336 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
| 1337 | + } |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | |
| 1341 | 1341 | if (! function_exists('espresso_venue_phone')) { |
| 1342 | - /** |
|
| 1343 | - * espresso_venue_phone |
|
| 1344 | - * |
|
| 1345 | - * @param int $VNU_ID |
|
| 1346 | - * @param bool $echo |
|
| 1347 | - * @return string |
|
| 1348 | - * @throws EE_Error |
|
| 1349 | - * @throws ReflectionException |
|
| 1350 | - */ |
|
| 1351 | - function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
| 1352 | - { |
|
| 1353 | - if ($echo) { |
|
| 1354 | - echo EEH_Venue_View::venue_phone($VNU_ID); // already escaped |
|
| 1355 | - return ''; |
|
| 1356 | - } |
|
| 1357 | - return EEH_Venue_View::venue_phone($VNU_ID); |
|
| 1358 | - } |
|
| 1342 | + /** |
|
| 1343 | + * espresso_venue_phone |
|
| 1344 | + * |
|
| 1345 | + * @param int $VNU_ID |
|
| 1346 | + * @param bool $echo |
|
| 1347 | + * @return string |
|
| 1348 | + * @throws EE_Error |
|
| 1349 | + * @throws ReflectionException |
|
| 1350 | + */ |
|
| 1351 | + function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
| 1352 | + { |
|
| 1353 | + if ($echo) { |
|
| 1354 | + echo EEH_Venue_View::venue_phone($VNU_ID); // already escaped |
|
| 1355 | + return ''; |
|
| 1356 | + } |
|
| 1357 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
| 1358 | + } |
|
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | |
| 1362 | 1362 | if (! function_exists('espresso_venue_website')) { |
| 1363 | - /** |
|
| 1364 | - * espresso_venue_website |
|
| 1365 | - * |
|
| 1366 | - * @param int $VNU_ID |
|
| 1367 | - * @param bool $echo |
|
| 1368 | - * @return string |
|
| 1369 | - * @throws EE_Error |
|
| 1370 | - * @throws ReflectionException |
|
| 1371 | - */ |
|
| 1372 | - function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
| 1373 | - { |
|
| 1374 | - if ($echo) { |
|
| 1375 | - echo EEH_Venue_View::venue_website_link($VNU_ID); // already escaped |
|
| 1376 | - return ''; |
|
| 1377 | - } |
|
| 1378 | - return EEH_Venue_View::venue_website_link($VNU_ID); |
|
| 1379 | - } |
|
| 1363 | + /** |
|
| 1364 | + * espresso_venue_website |
|
| 1365 | + * |
|
| 1366 | + * @param int $VNU_ID |
|
| 1367 | + * @param bool $echo |
|
| 1368 | + * @return string |
|
| 1369 | + * @throws EE_Error |
|
| 1370 | + * @throws ReflectionException |
|
| 1371 | + */ |
|
| 1372 | + function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
| 1373 | + { |
|
| 1374 | + if ($echo) { |
|
| 1375 | + echo EEH_Venue_View::venue_website_link($VNU_ID); // already escaped |
|
| 1376 | + return ''; |
|
| 1377 | + } |
|
| 1378 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
| 1379 | + } |
|
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | |
| 1383 | 1383 | if (! function_exists('espresso_edit_venue_link')) { |
| 1384 | - /** |
|
| 1385 | - * espresso_edit_venue_link |
|
| 1386 | - * |
|
| 1387 | - * @param int $VNU_ID |
|
| 1388 | - * @param bool $echo |
|
| 1389 | - * @return string |
|
| 1390 | - * @throws EE_Error |
|
| 1391 | - * @throws ReflectionException |
|
| 1392 | - */ |
|
| 1393 | - function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
| 1394 | - { |
|
| 1395 | - if ($echo) { |
|
| 1396 | - echo EEH_Venue_View::edit_venue_link($VNU_ID); // already escaped |
|
| 1397 | - return ''; |
|
| 1398 | - } |
|
| 1399 | - return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
| 1400 | - } |
|
| 1384 | + /** |
|
| 1385 | + * espresso_edit_venue_link |
|
| 1386 | + * |
|
| 1387 | + * @param int $VNU_ID |
|
| 1388 | + * @param bool $echo |
|
| 1389 | + * @return string |
|
| 1390 | + * @throws EE_Error |
|
| 1391 | + * @throws ReflectionException |
|
| 1392 | + */ |
|
| 1393 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
| 1394 | + { |
|
| 1395 | + if ($echo) { |
|
| 1396 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); // already escaped |
|
| 1397 | + return ''; |
|
| 1398 | + } |
|
| 1399 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
| 1400 | + } |
|
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | 1403 | |
@@ -5,43 +5,43 @@ |
||
| 5 | 5 | global $post; |
| 6 | 6 | ?> |
| 7 | 7 | <div class="venue-content"> |
| 8 | -<?php if ( apply_filters( 'FHEE__content_espresso_venues_details_template__display_entry_meta', TRUE )): ?> |
|
| 8 | +<?php if (apply_filters('FHEE__content_espresso_venues_details_template__display_entry_meta', TRUE)): ?> |
|
| 9 | 9 | <div class="entry-meta"> |
| 10 | - <span class="tags-links"><?php espresso_venue_categories( $post->ID, TRUE, TRUE ); ?></span> |
|
| 10 | + <span class="tags-links"><?php espresso_venue_categories($post->ID, TRUE, TRUE); ?></span> |
|
| 11 | 11 | <?php |
| 12 | - if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : |
|
| 12 | + if ( ! post_password_required() && (comments_open() || get_comments_number())) : |
|
| 13 | 13 | ?> |
| 14 | - <span class="comments-link"><?php comments_popup_link( esc_html__( 'Leave a comment', 'event_espresso' ), esc_html__( '1 Comment', 'event_espresso' ), esc_html__( '% Comments', 'event_espresso' ) ); ?></span> |
|
| 14 | + <span class="comments-link"><?php comments_popup_link(esc_html__('Leave a comment', 'event_espresso'), esc_html__('1 Comment', 'event_espresso'), esc_html__('% Comments', 'event_espresso')); ?></span> |
|
| 15 | 15 | <?php |
| 16 | 16 | endif; |
| 17 | 17 | |
| 18 | - edit_post_link( esc_html__( 'Edit', 'event_espresso' ), '<span class="edit-link">', '</span>' ); |
|
| 18 | + edit_post_link(esc_html__('Edit', 'event_espresso'), '<span class="edit-link">', '</span>'); |
|
| 19 | 19 | ?> |
| 20 | 20 | </div> |
| 21 | 21 | <?php endif; ?> |
| 22 | 22 | |
| 23 | 23 | <h3 class="event-venues-h3 ee-event-h3"> |
| 24 | - <?php esc_html_e( 'Details', 'event_espresso' ); ?> |
|
| 24 | + <?php esc_html_e('Details', 'event_espresso'); ?> |
|
| 25 | 25 | </h3> |
| 26 | 26 | |
| 27 | - <?php if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?> |
|
| 27 | + <?php if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?> |
|
| 28 | 28 | <p> |
| 29 | - <span class="small-text"><strong><?php esc_html_e( 'Venue Phone:', 'event_espresso' ); ?> </strong></span><?php echo wp_kses($venue_phone, AllowedTags::getAllowedTags()); ?> |
|
| 29 | + <span class="small-text"><strong><?php esc_html_e('Venue Phone:', 'event_espresso'); ?> </strong></span><?php echo wp_kses($venue_phone, AllowedTags::getAllowedTags()); ?> |
|
| 30 | 30 | </p> |
| 31 | 31 | <?php endif; ?> |
| 32 | - <?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?> |
|
| 32 | + <?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?> |
|
| 33 | 33 | <p> |
| 34 | - <span class="small-text"><strong><?php esc_html_e( 'Venue Website:', 'event_espresso' ); ?> </strong></span><?php echo wp_kses($venue_website, AllowedTags::getAllowedTags()); ?> |
|
| 34 | + <span class="small-text"><strong><?php esc_html_e('Venue Website:', 'event_espresso'); ?> </strong></span><?php echo wp_kses($venue_website, AllowedTags::getAllowedTags()); ?> |
|
| 35 | 35 | </p> |
| 36 | 36 | <?php endif; ?> |
| 37 | 37 | <?php |
| 38 | - do_action( 'AHEE__content_espresso_venues_details_template__before_the_content', $post ); |
|
| 39 | - if ( is_archive() && has_excerpt( $post->ID )) { |
|
| 38 | + do_action('AHEE__content_espresso_venues_details_template__before_the_content', $post); |
|
| 39 | + if (is_archive() && has_excerpt($post->ID)) { |
|
| 40 | 40 | the_excerpt(); |
| 41 | 41 | } else { |
| 42 | 42 | the_content(); |
| 43 | 43 | } |
| 44 | - do_action( 'AHEE__content_espresso_venues_details_template__after_the_content', $post ); |
|
| 44 | + do_action('AHEE__content_espresso_venues_details_template__after_the_content', $post); |
|
| 45 | 45 | ?> |
| 46 | 46 | </div> |
| 47 | 47 | <!-- .venue-content --> |
@@ -3,75 +3,75 @@ |
||
| 3 | 3 | use EventEspresso\core\services\request\sanitizers\AllowedTags; |
| 4 | 4 | |
| 5 | 5 | if ( |
| 6 | - ( is_single() && espresso_display_venue_in_event_details() ) |
|
| 7 | - || ( is_archive() && espresso_display_venue_in_event_list() ) |
|
| 6 | + (is_single() && espresso_display_venue_in_event_details()) |
|
| 7 | + || (is_archive() && espresso_display_venue_in_event_list()) |
|
| 8 | 8 | ) : |
| 9 | 9 | global $post; |
| 10 | - do_action( 'AHEE_event_details_before_venue_details', $post ); |
|
| 11 | - $venue_name = espresso_venue_name( 0, 'details', FALSE ); |
|
| 12 | - if ( empty( $venue_name ) && espresso_is_venue_private() ) { |
|
| 13 | - do_action( 'AHEE_event_details_after_venue_details', $post ); |
|
| 10 | + do_action('AHEE_event_details_before_venue_details', $post); |
|
| 11 | + $venue_name = espresso_venue_name(0, 'details', FALSE); |
|
| 12 | + if (empty($venue_name) && espresso_is_venue_private()) { |
|
| 13 | + do_action('AHEE_event_details_after_venue_details', $post); |
|
| 14 | 14 | return ''; |
| 15 | 15 | } |
| 16 | 16 | ?> |
| 17 | 17 | |
| 18 | 18 | <div class="espresso-venue-dv<?php echo espresso_is_venue_private() ? ' espresso-private-venue-dv' : ''; ?>"> |
| 19 | 19 | <h4> |
| 20 | - <strong><?php esc_html_e( 'Venue:', 'event_espresso' ); ?></strong> |
|
| 20 | + <strong><?php esc_html_e('Venue:', 'event_espresso'); ?></strong> |
|
| 21 | 21 | <strong> <?php echo wp_kses($venue_name, AllowedTags::getAllowedTags()); ?></strong> |
| 22 | 22 | </h4> |
| 23 | 23 | <p><span class="smaller-text tags-links"><?php echo espresso_venue_categories(); ?></span></p> |
| 24 | -<?php if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?> |
|
| 24 | +<?php if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?> |
|
| 25 | 25 | <p> |
| 26 | 26 | <span class="small-text"> |
| 27 | - <strong><?php esc_html_e( 'Venue Phone:', 'event_espresso' ); ?></strong> |
|
| 27 | + <strong><?php esc_html_e('Venue Phone:', 'event_espresso'); ?></strong> |
|
| 28 | 28 | </span> |
| 29 | 29 | <?php echo wp_kses($venue_phone, AllowedTags::getAllowedTags()); ?> |
| 30 | 30 | </p> |
| 31 | -<?php endif; ?> |
|
| 32 | -<?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?> |
|
| 31 | +<?php endif; ?> |
|
| 32 | +<?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?> |
|
| 33 | 33 | <p> |
| 34 | 34 | <span class="small-text"> |
| 35 | - <strong><?php esc_html_e( 'Venue Website:', 'event_espresso' ); ?></strong> |
|
| 35 | + <strong><?php esc_html_e('Venue Website:', 'event_espresso'); ?></strong> |
|
| 36 | 36 | </span> |
| 37 | 37 | <?php echo wp_kses($venue_website, AllowedTags::getAllowedTags()); ?> |
| 38 | 38 | </p> |
| 39 | 39 | <?php endif; ?> |
| 40 | -<?php if ( espresso_venue_has_address( $post->ID )) : ?> |
|
| 41 | - <strong><span class="dashicons dashicons-location-alt"></span><?php esc_html_e( 'Address:', 'event_espresso' ); ?></strong> |
|
| 42 | - <?php espresso_venue_address( 'inline' ); // already escaped ?> |
|
| 43 | - <?php espresso_venue_gmap( $post->ID ); // already escaped ?> |
|
| 40 | +<?php if (espresso_venue_has_address($post->ID)) : ?> |
|
| 41 | + <strong><span class="dashicons dashicons-location-alt"></span><?php esc_html_e('Address:', 'event_espresso'); ?></strong> |
|
| 42 | + <?php espresso_venue_address('inline'); // already escaped ?> |
|
| 43 | + <?php espresso_venue_gmap($post->ID); // already escaped ?> |
|
| 44 | 44 | <div class="clear"><br/></div> |
| 45 | -<?php endif; ?> |
|
| 45 | +<?php endif; ?> |
|
| 46 | 46 | |
| 47 | - <?php $VNU_ID = espresso_venue_id( $post->ID ); ?> |
|
| 48 | - <?php if ( is_single() ) : ?> |
|
| 49 | - <?php $venue_description = espresso_venue_description( $VNU_ID, FALSE ); ?> |
|
| 50 | - <?php if ( $venue_description ) : ?> |
|
| 47 | + <?php $VNU_ID = espresso_venue_id($post->ID); ?> |
|
| 48 | + <?php if (is_single()) : ?> |
|
| 49 | + <?php $venue_description = espresso_venue_description($VNU_ID, FALSE); ?> |
|
| 50 | + <?php if ($venue_description) : ?> |
|
| 51 | 51 | <p> |
| 52 | - <strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/> |
|
| 53 | - <?php echo do_shortcode( $venue_description ); ?> |
|
| 52 | + <strong><?php esc_html_e('Description:', 'event_espresso'); ?></strong><br/> |
|
| 53 | + <?php echo do_shortcode($venue_description); ?> |
|
| 54 | 54 | </p> |
| 55 | - <?php endif; ?> |
|
| 55 | + <?php endif; ?> |
|
| 56 | 56 | <?php else : ?> |
| 57 | - <?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?> |
|
| 58 | - <?php if ( $venue_excerpt ) : ?> |
|
| 57 | + <?php $venue_excerpt = espresso_venue_excerpt($VNU_ID, FALSE); ?> |
|
| 58 | + <?php if ($venue_excerpt) : ?> |
|
| 59 | 59 | <p> |
| 60 | - <strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/> |
|
| 60 | + <strong><?php esc_html_e('Description:', 'event_espresso'); ?></strong><br/> |
|
| 61 | 61 | <?php echo wp_kses($venue_excerpt, AllowedTags::getAllowedTags()); ?> |
| 62 | 62 | </p> |
| 63 | - <?php endif; ?> |
|
| 64 | - <?php endif; ?> |
|
| 63 | + <?php endif; ?> |
|
| 64 | + <?php endif; ?> |
|
| 65 | 65 | </div> |
| 66 | 66 | <!-- .espresso-venue-dv --> |
| 67 | 67 | <?php |
| 68 | -do_action( 'AHEE_event_details_after_venue_details', $post ); |
|
| 68 | +do_action('AHEE_event_details_after_venue_details', $post); |
|
| 69 | 69 | else : |
| 70 | - if ( espresso_venue_is_password_protected() ) : |
|
| 70 | + if (espresso_venue_is_password_protected()) : |
|
| 71 | 71 | ?> |
| 72 | 72 | <div class="espresso-venue-dv espresso-password-protected-venue-dv" > |
| 73 | 73 | <h3 class="event-venues-h3 ee-event-h3"> |
| 74 | - <?php esc_html_e( 'Location', 'event_espresso' );?> |
|
| 74 | + <?php esc_html_e('Location', 'event_espresso'); ?> |
|
| 75 | 75 | </h3> |
| 76 | 76 | <?php echo espresso_password_protected_venue_form(); ?> |
| 77 | 77 | </div> |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | use EventEspresso\core\services\request\sanitizers\AllowedTags; |
| 16 | 16 | |
| 17 | 17 | $gravatar = $show_gravatar |
| 18 | - ? get_avatar( |
|
| 19 | - $contact->email(), |
|
| 20 | - (int) apply_filters('FHEE__loop-espresso_attendees-shortcode__template__avatar_size', 32) |
|
| 21 | - ) |
|
| 22 | - : ''; |
|
| 18 | + ? get_avatar( |
|
| 19 | + $contact->email(), |
|
| 20 | + (int) apply_filters('FHEE__loop-espresso_attendees-shortcode__template__avatar_size', 32) |
|
| 21 | + ) |
|
| 22 | + : ''; |
|
| 23 | 23 | ?> |
| 24 | 24 | <?php do_action( 'AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar ); ?> |
| 25 | 25 | <li><?php echo wp_kses($gravatar . ' ' . $contact->full_name(true), AllowedTags::getAllowedTags()); ?></li> |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | ) |
| 22 | 22 | : ''; |
| 23 | 23 | ?> |
| 24 | -<?php do_action( 'AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar ); ?> |
|
| 25 | -<li><?php echo wp_kses($gravatar . ' ' . $contact->full_name(true), AllowedTags::getAllowedTags()); ?></li> |
|
| 26 | -<?php do_action( 'AHEE__content-espresso_event_attendees__after', $contact, $show_gravatar ); ?> |
|
| 24 | +<?php do_action('AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar); ?> |
|
| 25 | +<li><?php echo wp_kses($gravatar.' '.$contact->full_name(true), AllowedTags::getAllowedTags()); ?></li> |
|
| 26 | +<?php do_action('AHEE__content-espresso_event_attendees__after', $contact, $show_gravatar); ?> |
|
| 27 | 27 | |
| 28 | 28 | <!--<br >--> |
@@ -4,27 +4,27 @@ discard block |
||
| 4 | 4 | <div class="event-content"> |
| 5 | 5 | <?php use EventEspresso\core\services\request\sanitizers\AllowedTags; |
| 6 | 6 | |
| 7 | -if ( apply_filters( 'FHEE__content_espresso_events_details_template__display_entry_meta', TRUE )): ?> |
|
| 7 | +if (apply_filters('FHEE__content_espresso_events_details_template__display_entry_meta', TRUE)): ?> |
|
| 8 | 8 | |
| 9 | 9 | <div class="entry-meta"> |
| 10 | 10 | |
| 11 | 11 | <span class="tags-links"> |
| 12 | - <?php espresso_event_categories( $post->ID, TRUE, TRUE ); ?> |
|
| 12 | + <?php espresso_event_categories($post->ID, TRUE, TRUE); ?> |
|
| 13 | 13 | </span> |
| 14 | 14 | |
| 15 | - <?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?> |
|
| 15 | + <?php if ( ! post_password_required() && (comments_open() || get_comments_number())) : ?> |
|
| 16 | 16 | <span class="comments-link"> |
| 17 | 17 | <?php comments_popup_link( |
| 18 | - esc_html__( 'Leave a comment', 'event_espresso' ), |
|
| 19 | - esc_html__( '1 Comment', 'event_espresso' ), |
|
| 20 | - esc_html__( '% Comments', 'event_espresso' ) |
|
| 18 | + esc_html__('Leave a comment', 'event_espresso'), |
|
| 19 | + esc_html__('1 Comment', 'event_espresso'), |
|
| 20 | + esc_html__('% Comments', 'event_espresso') |
|
| 21 | 21 | ); ?> |
| 22 | 22 | </span> |
| 23 | 23 | |
| 24 | 24 | <?php |
| 25 | 25 | endif; |
| 26 | 26 | edit_post_link( |
| 27 | - esc_html__( 'Edit', 'event_espresso' ), |
|
| 27 | + esc_html__('Edit', 'event_espresso'), |
|
| 28 | 28 | '<span class="edit-link">', |
| 29 | 29 | '</span>' |
| 30 | 30 | ); |
@@ -32,25 +32,25 @@ discard block |
||
| 32 | 32 | </div> |
| 33 | 33 | |
| 34 | 34 | <?php endif; |
| 35 | - $event_phone = espresso_event_phone( $post->ID, FALSE ); |
|
| 35 | + $event_phone = espresso_event_phone($post->ID, FALSE); |
|
| 36 | 36 | |
| 37 | - if ( $event_phone != '' ) : ?> |
|
| 37 | + if ($event_phone != '') : ?> |
|
| 38 | 38 | <p class="event-phone"> |
| 39 | 39 | <span class="small-text"> |
| 40 | - <strong><?php esc_html_e( 'Event Phone:', 'event_espresso' ); ?> </strong> |
|
| 40 | + <strong><?php esc_html_e('Event Phone:', 'event_espresso'); ?> </strong> |
|
| 41 | 41 | </span> |
| 42 | 42 | <?php echo wp_kses($event_phone, AllowedTags::getAllowedTags()); ?> |
| 43 | 43 | </p> |
| 44 | -<?php endif; ?> |
|
| 44 | +<?php endif; ?> |
|
| 45 | 45 | |
| 46 | 46 | <?php |
| 47 | - if ( apply_filters( 'FHEE__content_espresso_events_details_template__display_the_content', true ) ) { |
|
| 48 | - do_action( 'AHEE_event_details_before_the_content', $post ); |
|
| 47 | + if (apply_filters('FHEE__content_espresso_events_details_template__display_the_content', true)) { |
|
| 48 | + do_action('AHEE_event_details_before_the_content', $post); |
|
| 49 | 49 | echo apply_filters( |
| 50 | 50 | 'FHEE__content_espresso_events_details_template__the_content', |
| 51 | - espresso_event_content_or_excerpt( 55, null, false ) |
|
| 51 | + espresso_event_content_or_excerpt(55, null, false) |
|
| 52 | 52 | ); |
| 53 | - do_action( 'AHEE_event_details_after_the_content', $post ); |
|
| 53 | + do_action('AHEE_event_details_after_the_content', $post); |
|
| 54 | 54 | } |
| 55 | 55 | ?> |
| 56 | 56 | </div> |