@@ -14,122 +14,122 @@ discard block |
||
| 14 | 14 | class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @var SessionLifespan $session_lifespan |
|
| 19 | - */ |
|
| 20 | - private $session_lifespan; |
|
| 21 | - |
|
| 22 | - private $_status; |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @param Transactions_Admin_Page $admin_page |
|
| 27 | - * @param SessionLifespan $lifespan |
|
| 28 | - */ |
|
| 29 | - public function __construct(Transactions_Admin_Page $admin_page, SessionLifespan $lifespan) |
|
| 30 | - { |
|
| 31 | - parent::__construct($admin_page); |
|
| 32 | - $this->session_lifespan = $lifespan; |
|
| 33 | - $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - *_setup_data |
|
| 39 | - */ |
|
| 40 | - protected function _setup_data() |
|
| 41 | - { |
|
| 42 | - $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
| 43 | - $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
| 44 | - $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - *_set_properties |
|
| 50 | - */ |
|
| 51 | - protected function _set_properties() |
|
| 52 | - { |
|
| 53 | - $this->_wp_list_args = array( |
|
| 54 | - 'singular' => esc_html__('transaction', 'event_espresso'), |
|
| 55 | - 'plural' => esc_html__('transactions', 'event_espresso'), |
|
| 56 | - 'ajax' => true, |
|
| 57 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 58 | - ); |
|
| 59 | - $ID_column_name = esc_html__('ID', 'event_espresso'); |
|
| 60 | - $ID_column_name .= '<span class="show-on-mobile-view-only" style="float:none">'; |
|
| 61 | - $ID_column_name .= ' : ' . esc_html__('Transaction Date', 'event_espresso'); |
|
| 62 | - $ID_column_name .= '</span> '; |
|
| 63 | - $this->_columns = array( |
|
| 64 | - 'id' => $ID_column_name, |
|
| 65 | - 'TXN_timestamp' => esc_html__('Transaction Date', 'event_espresso'), |
|
| 66 | - 'event_name' => esc_html__('Event', 'event_espresso'), |
|
| 67 | - 'ATT_fname' => esc_html__('Primary Registrant', 'event_espresso'), |
|
| 68 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 69 | - 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
| 70 | - 'actions' => $this->actionsColumnHeader(), |
|
| 71 | - ); |
|
| 72 | - |
|
| 73 | - $this->_sortable_columns = array( |
|
| 74 | - 'id' => array('TXN_ID' => false), |
|
| 75 | - 'event_name' => array('event_name' => false), |
|
| 76 | - 'ATT_fname' => array('ATT_fname' => false), |
|
| 77 | - 'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted |
|
| 78 | - ); |
|
| 79 | - |
|
| 80 | - $this->_primary_column = 'TXN_ID'; |
|
| 81 | - |
|
| 82 | - $this->_hidden_columns = array(); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * This simply sets up the row class for the table rows. |
|
| 88 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 89 | - * |
|
| 90 | - * @param EE_Transaction $transaction the current item |
|
| 91 | - * @return string |
|
| 92 | - * @throws EE_Error |
|
| 93 | - * @throws ReflectionException |
|
| 94 | - */ |
|
| 95 | - protected function _get_row_class($transaction) |
|
| 96 | - { |
|
| 97 | - $class = parent::_get_row_class($transaction); |
|
| 98 | - // add status class |
|
| 99 | - $class .= ' txn-status-' . $transaction->status_ID(); |
|
| 100 | - if ($this->_has_checkbox_column) { |
|
| 101 | - $class .= ' has-checkbox-column'; |
|
| 102 | - } |
|
| 103 | - return $class; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * _get_table_filters |
|
| 109 | - * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 110 | - * get's shown in the table. |
|
| 111 | - * |
|
| 112 | - * @abstract |
|
| 113 | - * @access protected |
|
| 114 | - * @return array |
|
| 115 | - */ |
|
| 116 | - protected function _get_table_filters() |
|
| 117 | - { |
|
| 118 | - $filters = array(); |
|
| 119 | - $start_date = isset($this->_req_data['txn-filter-start-date']) |
|
| 120 | - ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) |
|
| 121 | - : date( |
|
| 122 | - 'm/d/Y', |
|
| 123 | - strtotime('-10 year') |
|
| 124 | - ); |
|
| 125 | - $end_date = isset($this->_req_data['txn-filter-end-date']) |
|
| 126 | - ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) |
|
| 127 | - : date( |
|
| 128 | - 'm/d/Y', |
|
| 129 | - current_time('timestamp') |
|
| 130 | - ); |
|
| 131 | - ob_start(); |
|
| 132 | - ?> |
|
| 17 | + /** |
|
| 18 | + * @var SessionLifespan $session_lifespan |
|
| 19 | + */ |
|
| 20 | + private $session_lifespan; |
|
| 21 | + |
|
| 22 | + private $_status; |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @param Transactions_Admin_Page $admin_page |
|
| 27 | + * @param SessionLifespan $lifespan |
|
| 28 | + */ |
|
| 29 | + public function __construct(Transactions_Admin_Page $admin_page, SessionLifespan $lifespan) |
|
| 30 | + { |
|
| 31 | + parent::__construct($admin_page); |
|
| 32 | + $this->session_lifespan = $lifespan; |
|
| 33 | + $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + *_setup_data |
|
| 39 | + */ |
|
| 40 | + protected function _setup_data() |
|
| 41 | + { |
|
| 42 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
| 43 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
| 44 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + *_set_properties |
|
| 50 | + */ |
|
| 51 | + protected function _set_properties() |
|
| 52 | + { |
|
| 53 | + $this->_wp_list_args = array( |
|
| 54 | + 'singular' => esc_html__('transaction', 'event_espresso'), |
|
| 55 | + 'plural' => esc_html__('transactions', 'event_espresso'), |
|
| 56 | + 'ajax' => true, |
|
| 57 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 58 | + ); |
|
| 59 | + $ID_column_name = esc_html__('ID', 'event_espresso'); |
|
| 60 | + $ID_column_name .= '<span class="show-on-mobile-view-only" style="float:none">'; |
|
| 61 | + $ID_column_name .= ' : ' . esc_html__('Transaction Date', 'event_espresso'); |
|
| 62 | + $ID_column_name .= '</span> '; |
|
| 63 | + $this->_columns = array( |
|
| 64 | + 'id' => $ID_column_name, |
|
| 65 | + 'TXN_timestamp' => esc_html__('Transaction Date', 'event_espresso'), |
|
| 66 | + 'event_name' => esc_html__('Event', 'event_espresso'), |
|
| 67 | + 'ATT_fname' => esc_html__('Primary Registrant', 'event_espresso'), |
|
| 68 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 69 | + 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
| 70 | + 'actions' => $this->actionsColumnHeader(), |
|
| 71 | + ); |
|
| 72 | + |
|
| 73 | + $this->_sortable_columns = array( |
|
| 74 | + 'id' => array('TXN_ID' => false), |
|
| 75 | + 'event_name' => array('event_name' => false), |
|
| 76 | + 'ATT_fname' => array('ATT_fname' => false), |
|
| 77 | + 'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted |
|
| 78 | + ); |
|
| 79 | + |
|
| 80 | + $this->_primary_column = 'TXN_ID'; |
|
| 81 | + |
|
| 82 | + $this->_hidden_columns = array(); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * This simply sets up the row class for the table rows. |
|
| 88 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 89 | + * |
|
| 90 | + * @param EE_Transaction $transaction the current item |
|
| 91 | + * @return string |
|
| 92 | + * @throws EE_Error |
|
| 93 | + * @throws ReflectionException |
|
| 94 | + */ |
|
| 95 | + protected function _get_row_class($transaction) |
|
| 96 | + { |
|
| 97 | + $class = parent::_get_row_class($transaction); |
|
| 98 | + // add status class |
|
| 99 | + $class .= ' txn-status-' . $transaction->status_ID(); |
|
| 100 | + if ($this->_has_checkbox_column) { |
|
| 101 | + $class .= ' has-checkbox-column'; |
|
| 102 | + } |
|
| 103 | + return $class; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * _get_table_filters |
|
| 109 | + * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 110 | + * get's shown in the table. |
|
| 111 | + * |
|
| 112 | + * @abstract |
|
| 113 | + * @access protected |
|
| 114 | + * @return array |
|
| 115 | + */ |
|
| 116 | + protected function _get_table_filters() |
|
| 117 | + { |
|
| 118 | + $filters = array(); |
|
| 119 | + $start_date = isset($this->_req_data['txn-filter-start-date']) |
|
| 120 | + ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) |
|
| 121 | + : date( |
|
| 122 | + 'm/d/Y', |
|
| 123 | + strtotime('-10 year') |
|
| 124 | + ); |
|
| 125 | + $end_date = isset($this->_req_data['txn-filter-end-date']) |
|
| 126 | + ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) |
|
| 127 | + : date( |
|
| 128 | + 'm/d/Y', |
|
| 129 | + current_time('timestamp') |
|
| 130 | + ); |
|
| 131 | + ob_start(); |
|
| 132 | + ?> |
|
| 133 | 133 | <label for="txn-filter-start-date">Display Transactions from </label> |
| 134 | 134 | <input class="datepicker" |
| 135 | 135 | id="txn-filter-start-date" |
@@ -147,577 +147,577 @@ discard block |
||
| 147 | 147 | value="<?php echo esc_html($end_date); ?>" |
| 148 | 148 | /> |
| 149 | 149 | <?php |
| 150 | - $filters[] = ob_get_contents(); |
|
| 151 | - ob_end_clean(); |
|
| 152 | - return $filters; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - *_add_view_counts |
|
| 158 | - */ |
|
| 159 | - protected function _add_view_counts() |
|
| 160 | - { |
|
| 161 | - foreach ($this->_views as $view) { |
|
| 162 | - $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * column TXN_ID |
|
| 169 | - * |
|
| 170 | - * @param EE_Transaction $transaction |
|
| 171 | - * @return string |
|
| 172 | - * @throws EE_Error |
|
| 173 | - */ |
|
| 174 | - public function column_id(EE_Transaction $transaction) |
|
| 175 | - { |
|
| 176 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 177 | - array( |
|
| 178 | - 'action' => 'view_transaction', |
|
| 179 | - 'TXN_ID' => $transaction->ID(), |
|
| 180 | - ), |
|
| 181 | - TXN_ADMIN_URL |
|
| 182 | - ); |
|
| 183 | - $content = '<a class="ee-aria-tooltip" href="' . $view_lnk_url . '"' |
|
| 184 | - . ' aria-label="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">' |
|
| 185 | - . $transaction->ID() |
|
| 186 | - . '</a>'; |
|
| 187 | - |
|
| 188 | - // txn timestamp |
|
| 189 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>'; |
|
| 190 | - return $this->columnContent('id', $content, 'end'); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * @param EE_Transaction $transaction |
|
| 196 | - * @return string |
|
| 197 | - * @throws EE_Error |
|
| 198 | - * @throws InvalidArgumentException |
|
| 199 | - * @throws InvalidDataTypeException |
|
| 200 | - * @throws InvalidInterfaceException |
|
| 201 | - */ |
|
| 202 | - protected function _get_txn_timestamp(EE_Transaction $transaction) |
|
| 203 | - { |
|
| 204 | - // is TXN less than 2 hours old ? |
|
| 205 | - if ( |
|
| 206 | - ($transaction->failed() || $transaction->is_abandoned()) |
|
| 207 | - && $this->session_lifespan->expiration() < $transaction->datetime(false, true) |
|
| 208 | - ) { |
|
| 209 | - $timestamp = esc_html__('TXN in progress...', 'event_espresso'); |
|
| 210 | - } else { |
|
| 211 | - $timestamp = $transaction->get_i18n_datetime('TXN_timestamp', 'M jS Y g:i a'); |
|
| 212 | - } |
|
| 213 | - return $timestamp; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * column_cb |
|
| 219 | - * |
|
| 220 | - * @param EE_Transaction $transaction |
|
| 221 | - * @return string |
|
| 222 | - * @throws EE_Error |
|
| 223 | - */ |
|
| 224 | - public function column_cb($transaction) |
|
| 225 | - { |
|
| 226 | - return sprintf( |
|
| 227 | - '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
|
| 228 | - $this->_wp_list_args['singular'], |
|
| 229 | - $transaction->ID() |
|
| 230 | - ); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * column_TXN_timestamp |
|
| 236 | - * |
|
| 237 | - * @param EE_Transaction $transaction |
|
| 238 | - * @return string |
|
| 239 | - * @throws EE_Error |
|
| 240 | - * @throws ReflectionException |
|
| 241 | - */ |
|
| 242 | - public function column_TXN_timestamp(EE_Transaction $transaction) |
|
| 243 | - { |
|
| 244 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 245 | - array( |
|
| 246 | - 'action' => 'view_transaction', |
|
| 247 | - 'TXN_ID' => $transaction->ID(), |
|
| 248 | - ), |
|
| 249 | - TXN_ADMIN_URL |
|
| 250 | - ); |
|
| 251 | - $status = esc_attr($transaction->status_ID()); |
|
| 252 | - $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 253 | - return ' |
|
| 150 | + $filters[] = ob_get_contents(); |
|
| 151 | + ob_end_clean(); |
|
| 152 | + return $filters; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + *_add_view_counts |
|
| 158 | + */ |
|
| 159 | + protected function _add_view_counts() |
|
| 160 | + { |
|
| 161 | + foreach ($this->_views as $view) { |
|
| 162 | + $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * column TXN_ID |
|
| 169 | + * |
|
| 170 | + * @param EE_Transaction $transaction |
|
| 171 | + * @return string |
|
| 172 | + * @throws EE_Error |
|
| 173 | + */ |
|
| 174 | + public function column_id(EE_Transaction $transaction) |
|
| 175 | + { |
|
| 176 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 177 | + array( |
|
| 178 | + 'action' => 'view_transaction', |
|
| 179 | + 'TXN_ID' => $transaction->ID(), |
|
| 180 | + ), |
|
| 181 | + TXN_ADMIN_URL |
|
| 182 | + ); |
|
| 183 | + $content = '<a class="ee-aria-tooltip" href="' . $view_lnk_url . '"' |
|
| 184 | + . ' aria-label="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">' |
|
| 185 | + . $transaction->ID() |
|
| 186 | + . '</a>'; |
|
| 187 | + |
|
| 188 | + // txn timestamp |
|
| 189 | + $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>'; |
|
| 190 | + return $this->columnContent('id', $content, 'end'); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * @param EE_Transaction $transaction |
|
| 196 | + * @return string |
|
| 197 | + * @throws EE_Error |
|
| 198 | + * @throws InvalidArgumentException |
|
| 199 | + * @throws InvalidDataTypeException |
|
| 200 | + * @throws InvalidInterfaceException |
|
| 201 | + */ |
|
| 202 | + protected function _get_txn_timestamp(EE_Transaction $transaction) |
|
| 203 | + { |
|
| 204 | + // is TXN less than 2 hours old ? |
|
| 205 | + if ( |
|
| 206 | + ($transaction->failed() || $transaction->is_abandoned()) |
|
| 207 | + && $this->session_lifespan->expiration() < $transaction->datetime(false, true) |
|
| 208 | + ) { |
|
| 209 | + $timestamp = esc_html__('TXN in progress...', 'event_espresso'); |
|
| 210 | + } else { |
|
| 211 | + $timestamp = $transaction->get_i18n_datetime('TXN_timestamp', 'M jS Y g:i a'); |
|
| 212 | + } |
|
| 213 | + return $timestamp; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * column_cb |
|
| 219 | + * |
|
| 220 | + * @param EE_Transaction $transaction |
|
| 221 | + * @return string |
|
| 222 | + * @throws EE_Error |
|
| 223 | + */ |
|
| 224 | + public function column_cb($transaction) |
|
| 225 | + { |
|
| 226 | + return sprintf( |
|
| 227 | + '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
|
| 228 | + $this->_wp_list_args['singular'], |
|
| 229 | + $transaction->ID() |
|
| 230 | + ); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * column_TXN_timestamp |
|
| 236 | + * |
|
| 237 | + * @param EE_Transaction $transaction |
|
| 238 | + * @return string |
|
| 239 | + * @throws EE_Error |
|
| 240 | + * @throws ReflectionException |
|
| 241 | + */ |
|
| 242 | + public function column_TXN_timestamp(EE_Transaction $transaction) |
|
| 243 | + { |
|
| 244 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 245 | + array( |
|
| 246 | + 'action' => 'view_transaction', |
|
| 247 | + 'TXN_ID' => $transaction->ID(), |
|
| 248 | + ), |
|
| 249 | + TXN_ADMIN_URL |
|
| 250 | + ); |
|
| 251 | + $status = esc_attr($transaction->status_ID()); |
|
| 252 | + $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 253 | + return ' |
|
| 254 | 254 | <div class="ee-layout-row"> |
| 255 | 255 | <span aria-label="' . $pretty_status . '" class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"></span> |
| 256 | 256 | <a href="' . $view_lnk_url . '" |
| 257 | 257 | class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" |
| 258 | 258 | aria-label="' . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID( |
| 259 | - ) . '"> |
|
| 259 | + ) . '"> |
|
| 260 | 260 | ' . $this->_get_txn_timestamp($transaction) . ' |
| 261 | 261 | </a> |
| 262 | 262 | </div>'; |
| 263 | - } |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * column_TXN_total |
|
| 268 | - * |
|
| 269 | - * @param EE_Transaction $transaction |
|
| 270 | - * @return string |
|
| 271 | - * @throws EE_Error |
|
| 272 | - */ |
|
| 273 | - public function column_TXN_total(EE_Transaction $transaction) |
|
| 274 | - { |
|
| 275 | - if ($transaction->get('TXN_total') > 0) { |
|
| 276 | - return '<span class="txn-pad-rght">' |
|
| 277 | - . apply_filters( |
|
| 278 | - 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
| 279 | - $transaction->get_pretty('TXN_total'), |
|
| 280 | - $transaction |
|
| 281 | - ) |
|
| 282 | - . '</span>'; |
|
| 283 | - } else { |
|
| 284 | - return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * column_TXN_paid |
|
| 291 | - * |
|
| 292 | - * @param EE_Transaction $transaction |
|
| 293 | - * @return mixed|string |
|
| 294 | - * @throws EE_Error |
|
| 295 | - */ |
|
| 296 | - public function column_TXN_paid(EE_Transaction $transaction) |
|
| 297 | - { |
|
| 298 | - $transaction_total = $transaction->get('TXN_total'); |
|
| 299 | - $transaction_paid = $transaction->get('TXN_paid'); |
|
| 300 | - |
|
| 301 | - if (EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
| 302 | - // monies owing |
|
| 303 | - $span_class = 'txn-overview-part-payment-spn'; |
|
| 304 | - if (EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
| 305 | - // paid in full |
|
| 306 | - $span_class = 'txn-overview-full-payment-spn'; |
|
| 307 | - } elseif (EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
| 308 | - // no payments made |
|
| 309 | - $span_class = 'txn-overview-no-payment-spn'; |
|
| 310 | - } |
|
| 311 | - } else { |
|
| 312 | - // transaction_total == 0 so this is a free event |
|
| 313 | - $span_class = 'txn-overview-free-event-spn'; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - $payment_method = $transaction->payment_method(); |
|
| 317 | - $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
| 318 | - ? $payment_method->admin_name() |
|
| 319 | - : esc_html__('Unknown', 'event_espresso'); |
|
| 320 | - |
|
| 321 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' |
|
| 322 | - . $transaction->get_pretty('TXN_paid') |
|
| 323 | - . '</span>'; |
|
| 324 | - if ($transaction_paid > 0) { |
|
| 325 | - $content .= ' <span class="ee-status-text-small">' |
|
| 326 | - . sprintf( |
|
| 327 | - esc_html__('...via %s', 'event_espresso'), |
|
| 328 | - $payment_method_name |
|
| 329 | - ) |
|
| 330 | - . '</span>'; |
|
| 331 | - } |
|
| 332 | - return "<div>{$content}</div>"; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * column_ATT_fname |
|
| 338 | - * |
|
| 339 | - * @param EE_Transaction $transaction |
|
| 340 | - * @return string |
|
| 341 | - * @throws EE_Error |
|
| 342 | - * @throws InvalidArgumentException |
|
| 343 | - * @throws InvalidDataTypeException |
|
| 344 | - * @throws InvalidInterfaceException |
|
| 345 | - */ |
|
| 346 | - public function column_ATT_fname(EE_Transaction $transaction) |
|
| 347 | - { |
|
| 348 | - $primary_reg = $transaction->primary_registration(); |
|
| 349 | - $attendee = $primary_reg->get_first_related('Attendee'); |
|
| 350 | - if ($attendee instanceof EE_Attendee) { |
|
| 351 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 352 | - array( |
|
| 353 | - 'action' => 'view_registration', |
|
| 354 | - '_REG_ID' => $primary_reg->ID(), |
|
| 355 | - ), |
|
| 356 | - REG_ADMIN_URL |
|
| 357 | - ); |
|
| 358 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 359 | - 'ee_read_registration', |
|
| 360 | - 'espresso_registrations_view_registration', |
|
| 361 | - $primary_reg->ID() |
|
| 362 | - ) |
|
| 363 | - ? '<a href="' . $edit_lnk_url . '"' |
|
| 364 | - . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 365 | - . $attendee->full_name() |
|
| 366 | - . '</a>' |
|
| 367 | - : $attendee->full_name(); |
|
| 368 | - $content .= '<br>' . $attendee->email(); |
|
| 369 | - return $content; |
|
| 370 | - } |
|
| 371 | - return $transaction->failed() || $transaction->is_abandoned() |
|
| 372 | - ? esc_html__('no contact record.', 'event_espresso') |
|
| 373 | - : esc_html__( |
|
| 374 | - 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 375 | - 'event_espresso' |
|
| 376 | - ); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * column_ATT_email |
|
| 382 | - * |
|
| 383 | - * @param EE_Transaction $transaction |
|
| 384 | - * @return string |
|
| 385 | - * @throws EE_Error |
|
| 386 | - */ |
|
| 387 | - public function column_ATT_email(EE_Transaction $transaction) |
|
| 388 | - { |
|
| 389 | - $attendee = $transaction->primary_registration()->get_first_related('Attendee'); |
|
| 390 | - if (! empty($attendee)) { |
|
| 391 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' |
|
| 392 | - . $attendee->get('ATT_email') |
|
| 393 | - . '</a>'; |
|
| 394 | - } else { |
|
| 395 | - return $transaction->failed() || $transaction->is_abandoned() |
|
| 396 | - ? esc_html__('no contact record.', 'event_espresso') |
|
| 397 | - : esc_html__( |
|
| 398 | - 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 399 | - 'event_espresso' |
|
| 400 | - ); |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * column_event_name |
|
| 407 | - * |
|
| 408 | - * @param EE_Transaction $transaction |
|
| 409 | - * @return string |
|
| 410 | - * @throws EE_Error |
|
| 411 | - * @throws InvalidArgumentException |
|
| 412 | - * @throws InvalidDataTypeException |
|
| 413 | - * @throws InvalidInterfaceException |
|
| 414 | - */ |
|
| 415 | - public function column_event_name(EE_Transaction $transaction) |
|
| 416 | - { |
|
| 417 | - $actions = array(); |
|
| 418 | - $event = $transaction->primary_registration()->get_first_related('Event'); |
|
| 419 | - if (! empty($event)) { |
|
| 420 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 421 | - array('action' => 'edit', 'post' => $event->ID()), |
|
| 422 | - EVENTS_ADMIN_URL |
|
| 423 | - ); |
|
| 424 | - $event_name = $event->get('EVT_name'); |
|
| 425 | - |
|
| 426 | - // filter this view by transactions for this event |
|
| 427 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( |
|
| 428 | - array( |
|
| 429 | - 'action' => 'default', |
|
| 430 | - 'EVT_ID' => $event->ID(), |
|
| 431 | - ), |
|
| 432 | - TXN_ADMIN_URL |
|
| 433 | - ); |
|
| 434 | - if ( |
|
| 435 | - empty($this->_req_data['EVT_ID']) |
|
| 436 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 437 | - 'ee_edit_event', |
|
| 438 | - 'espresso_events_edit', |
|
| 439 | - $event->ID() |
|
| 440 | - ) |
|
| 441 | - ) { |
|
| 442 | - $actions['filter_by_event'] = '<a class="ee-aria-tooltip" href="' . $txn_by_event_lnk . '"' |
|
| 443 | - . ' aria-label="' . esc_attr__( |
|
| 444 | - 'Filter transactions by this event', |
|
| 445 | - 'event_espresso' |
|
| 446 | - ) . '">' |
|
| 447 | - . esc_html__('View Transactions for this event', 'event_espresso') |
|
| 448 | - . '</a>'; |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - return sprintf( |
|
| 452 | - '%1$s %2$s', |
|
| 453 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 454 | - 'ee_edit_event', |
|
| 455 | - 'espresso_events_edit', |
|
| 456 | - $event->ID() |
|
| 457 | - ) |
|
| 458 | - ? '<a class="ee-aria-tooltip" href="' . $edit_event_url . '"' |
|
| 459 | - . ' aria-label="' |
|
| 460 | - . sprintf( |
|
| 461 | - esc_attr__('Edit Event: %s', 'event_espresso'), |
|
| 462 | - $event->get('EVT_name') |
|
| 463 | - ) |
|
| 464 | - . '">' |
|
| 465 | - . wp_trim_words( |
|
| 466 | - $event_name, |
|
| 467 | - 30, |
|
| 468 | - '...' |
|
| 469 | - ) |
|
| 470 | - . '</a>' |
|
| 471 | - : wp_trim_words($event_name, 30, '...'), |
|
| 472 | - $this->row_actions($actions) |
|
| 473 | - ); |
|
| 474 | - } else { |
|
| 475 | - return esc_html__( |
|
| 476 | - 'The event associated with this transaction via the primary registration cannot be retrieved.', |
|
| 477 | - 'event_espresso' |
|
| 478 | - ); |
|
| 479 | - } |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * column_actions |
|
| 485 | - * |
|
| 486 | - * @param EE_Transaction $transaction |
|
| 487 | - * @return string |
|
| 488 | - * @throws EE_Error |
|
| 489 | - */ |
|
| 490 | - public function column_actions(EE_Transaction $transaction) |
|
| 491 | - { |
|
| 492 | - return $this->actionsModalMenu( |
|
| 493 | - $this->_action_string( |
|
| 494 | - $this->get_transaction_details_link($transaction) |
|
| 495 | - . $this->get_invoice_link($transaction) |
|
| 496 | - . $this->get_receipt_link($transaction) |
|
| 497 | - . $this->get_primary_registration_details_link($transaction) |
|
| 498 | - . $this->get_send_payment_reminder_trigger_link($transaction) |
|
| 499 | - . $this->get_payment_overview_link($transaction) |
|
| 500 | - . $this->get_related_messages_link($transaction), |
|
| 501 | - $transaction, |
|
| 502 | - 'div', |
|
| 503 | - 'txn-overview-actions ee-list-table-actions' |
|
| 504 | - ) |
|
| 505 | - ); |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - |
|
| 509 | - /** |
|
| 510 | - * Get the transaction details link. |
|
| 511 | - * |
|
| 512 | - * @param EE_Transaction $transaction |
|
| 513 | - * @return string |
|
| 514 | - * @throws EE_Error |
|
| 515 | - */ |
|
| 516 | - protected function get_transaction_details_link(EE_Transaction $transaction) |
|
| 517 | - { |
|
| 518 | - $url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 519 | - array( |
|
| 520 | - 'action' => 'view_transaction', |
|
| 521 | - 'TXN_ID' => $transaction->ID(), |
|
| 522 | - ), |
|
| 523 | - TXN_ADMIN_URL |
|
| 524 | - ); |
|
| 525 | - return ' |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * column_TXN_total |
|
| 268 | + * |
|
| 269 | + * @param EE_Transaction $transaction |
|
| 270 | + * @return string |
|
| 271 | + * @throws EE_Error |
|
| 272 | + */ |
|
| 273 | + public function column_TXN_total(EE_Transaction $transaction) |
|
| 274 | + { |
|
| 275 | + if ($transaction->get('TXN_total') > 0) { |
|
| 276 | + return '<span class="txn-pad-rght">' |
|
| 277 | + . apply_filters( |
|
| 278 | + 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
| 279 | + $transaction->get_pretty('TXN_total'), |
|
| 280 | + $transaction |
|
| 281 | + ) |
|
| 282 | + . '</span>'; |
|
| 283 | + } else { |
|
| 284 | + return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * column_TXN_paid |
|
| 291 | + * |
|
| 292 | + * @param EE_Transaction $transaction |
|
| 293 | + * @return mixed|string |
|
| 294 | + * @throws EE_Error |
|
| 295 | + */ |
|
| 296 | + public function column_TXN_paid(EE_Transaction $transaction) |
|
| 297 | + { |
|
| 298 | + $transaction_total = $transaction->get('TXN_total'); |
|
| 299 | + $transaction_paid = $transaction->get('TXN_paid'); |
|
| 300 | + |
|
| 301 | + if (EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
| 302 | + // monies owing |
|
| 303 | + $span_class = 'txn-overview-part-payment-spn'; |
|
| 304 | + if (EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
| 305 | + // paid in full |
|
| 306 | + $span_class = 'txn-overview-full-payment-spn'; |
|
| 307 | + } elseif (EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
| 308 | + // no payments made |
|
| 309 | + $span_class = 'txn-overview-no-payment-spn'; |
|
| 310 | + } |
|
| 311 | + } else { |
|
| 312 | + // transaction_total == 0 so this is a free event |
|
| 313 | + $span_class = 'txn-overview-free-event-spn'; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + $payment_method = $transaction->payment_method(); |
|
| 317 | + $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
| 318 | + ? $payment_method->admin_name() |
|
| 319 | + : esc_html__('Unknown', 'event_espresso'); |
|
| 320 | + |
|
| 321 | + $content = '<span class="' . $span_class . ' txn-pad-rght">' |
|
| 322 | + . $transaction->get_pretty('TXN_paid') |
|
| 323 | + . '</span>'; |
|
| 324 | + if ($transaction_paid > 0) { |
|
| 325 | + $content .= ' <span class="ee-status-text-small">' |
|
| 326 | + . sprintf( |
|
| 327 | + esc_html__('...via %s', 'event_espresso'), |
|
| 328 | + $payment_method_name |
|
| 329 | + ) |
|
| 330 | + . '</span>'; |
|
| 331 | + } |
|
| 332 | + return "<div>{$content}</div>"; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * column_ATT_fname |
|
| 338 | + * |
|
| 339 | + * @param EE_Transaction $transaction |
|
| 340 | + * @return string |
|
| 341 | + * @throws EE_Error |
|
| 342 | + * @throws InvalidArgumentException |
|
| 343 | + * @throws InvalidDataTypeException |
|
| 344 | + * @throws InvalidInterfaceException |
|
| 345 | + */ |
|
| 346 | + public function column_ATT_fname(EE_Transaction $transaction) |
|
| 347 | + { |
|
| 348 | + $primary_reg = $transaction->primary_registration(); |
|
| 349 | + $attendee = $primary_reg->get_first_related('Attendee'); |
|
| 350 | + if ($attendee instanceof EE_Attendee) { |
|
| 351 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 352 | + array( |
|
| 353 | + 'action' => 'view_registration', |
|
| 354 | + '_REG_ID' => $primary_reg->ID(), |
|
| 355 | + ), |
|
| 356 | + REG_ADMIN_URL |
|
| 357 | + ); |
|
| 358 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 359 | + 'ee_read_registration', |
|
| 360 | + 'espresso_registrations_view_registration', |
|
| 361 | + $primary_reg->ID() |
|
| 362 | + ) |
|
| 363 | + ? '<a href="' . $edit_lnk_url . '"' |
|
| 364 | + . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 365 | + . $attendee->full_name() |
|
| 366 | + . '</a>' |
|
| 367 | + : $attendee->full_name(); |
|
| 368 | + $content .= '<br>' . $attendee->email(); |
|
| 369 | + return $content; |
|
| 370 | + } |
|
| 371 | + return $transaction->failed() || $transaction->is_abandoned() |
|
| 372 | + ? esc_html__('no contact record.', 'event_espresso') |
|
| 373 | + : esc_html__( |
|
| 374 | + 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 375 | + 'event_espresso' |
|
| 376 | + ); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * column_ATT_email |
|
| 382 | + * |
|
| 383 | + * @param EE_Transaction $transaction |
|
| 384 | + * @return string |
|
| 385 | + * @throws EE_Error |
|
| 386 | + */ |
|
| 387 | + public function column_ATT_email(EE_Transaction $transaction) |
|
| 388 | + { |
|
| 389 | + $attendee = $transaction->primary_registration()->get_first_related('Attendee'); |
|
| 390 | + if (! empty($attendee)) { |
|
| 391 | + return '<a href="mailto:' . $attendee->get('ATT_email') . '">' |
|
| 392 | + . $attendee->get('ATT_email') |
|
| 393 | + . '</a>'; |
|
| 394 | + } else { |
|
| 395 | + return $transaction->failed() || $transaction->is_abandoned() |
|
| 396 | + ? esc_html__('no contact record.', 'event_espresso') |
|
| 397 | + : esc_html__( |
|
| 398 | + 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 399 | + 'event_espresso' |
|
| 400 | + ); |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * column_event_name |
|
| 407 | + * |
|
| 408 | + * @param EE_Transaction $transaction |
|
| 409 | + * @return string |
|
| 410 | + * @throws EE_Error |
|
| 411 | + * @throws InvalidArgumentException |
|
| 412 | + * @throws InvalidDataTypeException |
|
| 413 | + * @throws InvalidInterfaceException |
|
| 414 | + */ |
|
| 415 | + public function column_event_name(EE_Transaction $transaction) |
|
| 416 | + { |
|
| 417 | + $actions = array(); |
|
| 418 | + $event = $transaction->primary_registration()->get_first_related('Event'); |
|
| 419 | + if (! empty($event)) { |
|
| 420 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 421 | + array('action' => 'edit', 'post' => $event->ID()), |
|
| 422 | + EVENTS_ADMIN_URL |
|
| 423 | + ); |
|
| 424 | + $event_name = $event->get('EVT_name'); |
|
| 425 | + |
|
| 426 | + // filter this view by transactions for this event |
|
| 427 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( |
|
| 428 | + array( |
|
| 429 | + 'action' => 'default', |
|
| 430 | + 'EVT_ID' => $event->ID(), |
|
| 431 | + ), |
|
| 432 | + TXN_ADMIN_URL |
|
| 433 | + ); |
|
| 434 | + if ( |
|
| 435 | + empty($this->_req_data['EVT_ID']) |
|
| 436 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 437 | + 'ee_edit_event', |
|
| 438 | + 'espresso_events_edit', |
|
| 439 | + $event->ID() |
|
| 440 | + ) |
|
| 441 | + ) { |
|
| 442 | + $actions['filter_by_event'] = '<a class="ee-aria-tooltip" href="' . $txn_by_event_lnk . '"' |
|
| 443 | + . ' aria-label="' . esc_attr__( |
|
| 444 | + 'Filter transactions by this event', |
|
| 445 | + 'event_espresso' |
|
| 446 | + ) . '">' |
|
| 447 | + . esc_html__('View Transactions for this event', 'event_espresso') |
|
| 448 | + . '</a>'; |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + return sprintf( |
|
| 452 | + '%1$s %2$s', |
|
| 453 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 454 | + 'ee_edit_event', |
|
| 455 | + 'espresso_events_edit', |
|
| 456 | + $event->ID() |
|
| 457 | + ) |
|
| 458 | + ? '<a class="ee-aria-tooltip" href="' . $edit_event_url . '"' |
|
| 459 | + . ' aria-label="' |
|
| 460 | + . sprintf( |
|
| 461 | + esc_attr__('Edit Event: %s', 'event_espresso'), |
|
| 462 | + $event->get('EVT_name') |
|
| 463 | + ) |
|
| 464 | + . '">' |
|
| 465 | + . wp_trim_words( |
|
| 466 | + $event_name, |
|
| 467 | + 30, |
|
| 468 | + '...' |
|
| 469 | + ) |
|
| 470 | + . '</a>' |
|
| 471 | + : wp_trim_words($event_name, 30, '...'), |
|
| 472 | + $this->row_actions($actions) |
|
| 473 | + ); |
|
| 474 | + } else { |
|
| 475 | + return esc_html__( |
|
| 476 | + 'The event associated with this transaction via the primary registration cannot be retrieved.', |
|
| 477 | + 'event_espresso' |
|
| 478 | + ); |
|
| 479 | + } |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * column_actions |
|
| 485 | + * |
|
| 486 | + * @param EE_Transaction $transaction |
|
| 487 | + * @return string |
|
| 488 | + * @throws EE_Error |
|
| 489 | + */ |
|
| 490 | + public function column_actions(EE_Transaction $transaction) |
|
| 491 | + { |
|
| 492 | + return $this->actionsModalMenu( |
|
| 493 | + $this->_action_string( |
|
| 494 | + $this->get_transaction_details_link($transaction) |
|
| 495 | + . $this->get_invoice_link($transaction) |
|
| 496 | + . $this->get_receipt_link($transaction) |
|
| 497 | + . $this->get_primary_registration_details_link($transaction) |
|
| 498 | + . $this->get_send_payment_reminder_trigger_link($transaction) |
|
| 499 | + . $this->get_payment_overview_link($transaction) |
|
| 500 | + . $this->get_related_messages_link($transaction), |
|
| 501 | + $transaction, |
|
| 502 | + 'div', |
|
| 503 | + 'txn-overview-actions ee-list-table-actions' |
|
| 504 | + ) |
|
| 505 | + ); |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * Get the transaction details link. |
|
| 511 | + * |
|
| 512 | + * @param EE_Transaction $transaction |
|
| 513 | + * @return string |
|
| 514 | + * @throws EE_Error |
|
| 515 | + */ |
|
| 516 | + protected function get_transaction_details_link(EE_Transaction $transaction) |
|
| 517 | + { |
|
| 518 | + $url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 519 | + array( |
|
| 520 | + 'action' => 'view_transaction', |
|
| 521 | + 'TXN_ID' => $transaction->ID(), |
|
| 522 | + ), |
|
| 523 | + TXN_ADMIN_URL |
|
| 524 | + ); |
|
| 525 | + return ' |
|
| 526 | 526 | <a class="ee-aria-tooltip button button--icon-only" href="' . $url . '"' |
| 527 | - . ' aria-label="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="button button--icon-only"> |
|
| 527 | + . ' aria-label="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="button button--icon-only"> |
|
| 528 | 528 | <span class="dashicons dashicons-cart"></span> |
| 529 | 529 | </a>'; |
| 530 | - } |
|
| 531 | - |
|
| 532 | - |
|
| 533 | - /** |
|
| 534 | - * Get the invoice link for the given registration. |
|
| 535 | - * |
|
| 536 | - * @param EE_Transaction $transaction |
|
| 537 | - * @return string |
|
| 538 | - * @throws EE_Error |
|
| 539 | - */ |
|
| 540 | - protected function get_invoice_link(EE_Transaction $transaction) |
|
| 541 | - { |
|
| 542 | - $registration = $transaction->primary_registration(); |
|
| 543 | - if ($registration instanceof EE_Registration) { |
|
| 544 | - $url = $registration->invoice_url(); |
|
| 545 | - // only show invoice link if message type is active. |
|
| 546 | - if ( |
|
| 547 | - $registration->attendee() instanceof EE_Attendee |
|
| 548 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
| 549 | - ) { |
|
| 550 | - return ' |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + |
|
| 533 | + /** |
|
| 534 | + * Get the invoice link for the given registration. |
|
| 535 | + * |
|
| 536 | + * @param EE_Transaction $transaction |
|
| 537 | + * @return string |
|
| 538 | + * @throws EE_Error |
|
| 539 | + */ |
|
| 540 | + protected function get_invoice_link(EE_Transaction $transaction) |
|
| 541 | + { |
|
| 542 | + $registration = $transaction->primary_registration(); |
|
| 543 | + if ($registration instanceof EE_Registration) { |
|
| 544 | + $url = $registration->invoice_url(); |
|
| 545 | + // only show invoice link if message type is active. |
|
| 546 | + if ( |
|
| 547 | + $registration->attendee() instanceof EE_Attendee |
|
| 548 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
| 549 | + ) { |
|
| 550 | + return ' |
|
| 551 | 551 | <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"' |
| 552 | - . ' target="_blank" href="' . $url . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 552 | + . ' target="_blank" href="' . $url . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 553 | 553 | <span class="dashicons dashicons-media-spreadsheet"></span> |
| 554 | 554 | </a>'; |
| 555 | - } |
|
| 556 | - } |
|
| 557 | - return ''; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - |
|
| 561 | - /** |
|
| 562 | - * Get the receipt link for the transaction. |
|
| 563 | - * |
|
| 564 | - * @param EE_Transaction $transaction |
|
| 565 | - * @return string |
|
| 566 | - * @throws EE_Error |
|
| 567 | - */ |
|
| 568 | - protected function get_receipt_link(EE_Transaction $transaction) |
|
| 569 | - { |
|
| 570 | - $registration = $transaction->primary_registration(); |
|
| 571 | - if ($registration instanceof EE_Registration) { |
|
| 572 | - $url = $registration->receipt_url(); |
|
| 573 | - // only show receipt link if message type is active. |
|
| 574 | - if ( |
|
| 575 | - $registration->attendee() instanceof EE_Attendee |
|
| 576 | - && EEH_MSG_Template::is_mt_active('receipt') |
|
| 577 | - ) { |
|
| 578 | - return ' |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | + return ''; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + |
|
| 561 | + /** |
|
| 562 | + * Get the receipt link for the transaction. |
|
| 563 | + * |
|
| 564 | + * @param EE_Transaction $transaction |
|
| 565 | + * @return string |
|
| 566 | + * @throws EE_Error |
|
| 567 | + */ |
|
| 568 | + protected function get_receipt_link(EE_Transaction $transaction) |
|
| 569 | + { |
|
| 570 | + $registration = $transaction->primary_registration(); |
|
| 571 | + if ($registration instanceof EE_Registration) { |
|
| 572 | + $url = $registration->receipt_url(); |
|
| 573 | + // only show receipt link if message type is active. |
|
| 574 | + if ( |
|
| 575 | + $registration->attendee() instanceof EE_Attendee |
|
| 576 | + && EEH_MSG_Template::is_mt_active('receipt') |
|
| 577 | + ) { |
|
| 578 | + return ' |
|
| 579 | 579 | <a aria-label="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"' |
| 580 | - . ' target="_blank" href="' . $url . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 580 | + . ' target="_blank" href="' . $url . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 581 | 581 | <span class="dashicons dashicons-text-page"></span> |
| 582 | 582 | </a>'; |
| 583 | - } |
|
| 584 | - } |
|
| 585 | - return ''; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * Get the link to view the details for the primary registration. |
|
| 591 | - * |
|
| 592 | - * @param EE_Transaction $transaction |
|
| 593 | - * @return string |
|
| 594 | - * @throws EE_Error |
|
| 595 | - * @throws InvalidArgumentException |
|
| 596 | - * @throws InvalidDataTypeException |
|
| 597 | - * @throws InvalidInterfaceException |
|
| 598 | - */ |
|
| 599 | - protected function get_primary_registration_details_link(EE_Transaction $transaction) |
|
| 600 | - { |
|
| 601 | - $registration = $transaction->primary_registration(); |
|
| 602 | - if ($registration instanceof EE_Registration) { |
|
| 603 | - $url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 604 | - array( |
|
| 605 | - 'action' => 'view_registration', |
|
| 606 | - '_REG_ID' => $registration->ID(), |
|
| 607 | - ), |
|
| 608 | - REG_ADMIN_URL |
|
| 609 | - ); |
|
| 610 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 611 | - 'ee_read_registration', |
|
| 612 | - 'espresso_registrations_view_registration', |
|
| 613 | - $registration->ID() |
|
| 614 | - ) |
|
| 615 | - ? ' |
|
| 583 | + } |
|
| 584 | + } |
|
| 585 | + return ''; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * Get the link to view the details for the primary registration. |
|
| 591 | + * |
|
| 592 | + * @param EE_Transaction $transaction |
|
| 593 | + * @return string |
|
| 594 | + * @throws EE_Error |
|
| 595 | + * @throws InvalidArgumentException |
|
| 596 | + * @throws InvalidDataTypeException |
|
| 597 | + * @throws InvalidInterfaceException |
|
| 598 | + */ |
|
| 599 | + protected function get_primary_registration_details_link(EE_Transaction $transaction) |
|
| 600 | + { |
|
| 601 | + $registration = $transaction->primary_registration(); |
|
| 602 | + if ($registration instanceof EE_Registration) { |
|
| 603 | + $url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 604 | + array( |
|
| 605 | + 'action' => 'view_registration', |
|
| 606 | + '_REG_ID' => $registration->ID(), |
|
| 607 | + ), |
|
| 608 | + REG_ADMIN_URL |
|
| 609 | + ); |
|
| 610 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 611 | + 'ee_read_registration', |
|
| 612 | + 'espresso_registrations_view_registration', |
|
| 613 | + $registration->ID() |
|
| 614 | + ) |
|
| 615 | + ? ' |
|
| 616 | 616 | <a href="' . $url . '" |
| 617 | 617 | aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" |
| 618 | 618 | class="ee-aria-tooltip button button--icon-only" |
| 619 | 619 | > |
| 620 | 620 | <span class="dashicons dashicons-clipboard"></span> |
| 621 | 621 | </a>' |
| 622 | - : ''; |
|
| 623 | - } |
|
| 624 | - return ''; |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - |
|
| 628 | - /** |
|
| 629 | - * Get send payment reminder trigger link |
|
| 630 | - * |
|
| 631 | - * @param EE_Transaction $transaction |
|
| 632 | - * @return string |
|
| 633 | - * @throws EE_Error |
|
| 634 | - * @throws InvalidArgumentException |
|
| 635 | - * @throws InvalidDataTypeException |
|
| 636 | - * @throws InvalidInterfaceException |
|
| 637 | - */ |
|
| 638 | - protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction) |
|
| 639 | - { |
|
| 640 | - $registration = $transaction->primary_registration(); |
|
| 641 | - if ( |
|
| 642 | - $registration instanceof EE_Registration |
|
| 643 | - && $registration->attendee() instanceof EE_Attendee |
|
| 644 | - && EEH_MSG_Template::is_mt_active('payment_reminder') |
|
| 645 | - && ! in_array( |
|
| 646 | - $transaction->status_ID(), |
|
| 647 | - array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code), |
|
| 648 | - true |
|
| 649 | - ) |
|
| 650 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 651 | - 'ee_send_message', |
|
| 652 | - 'espresso_transactions_send_payment_reminder' |
|
| 653 | - ) |
|
| 654 | - ) { |
|
| 655 | - $url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 656 | - array( |
|
| 657 | - 'action' => 'send_payment_reminder', |
|
| 658 | - 'TXN_ID' => $transaction->ID(), |
|
| 659 | - ), |
|
| 660 | - TXN_ADMIN_URL |
|
| 661 | - ); |
|
| 662 | - return ' |
|
| 622 | + : ''; |
|
| 623 | + } |
|
| 624 | + return ''; |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + |
|
| 628 | + /** |
|
| 629 | + * Get send payment reminder trigger link |
|
| 630 | + * |
|
| 631 | + * @param EE_Transaction $transaction |
|
| 632 | + * @return string |
|
| 633 | + * @throws EE_Error |
|
| 634 | + * @throws InvalidArgumentException |
|
| 635 | + * @throws InvalidDataTypeException |
|
| 636 | + * @throws InvalidInterfaceException |
|
| 637 | + */ |
|
| 638 | + protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction) |
|
| 639 | + { |
|
| 640 | + $registration = $transaction->primary_registration(); |
|
| 641 | + if ( |
|
| 642 | + $registration instanceof EE_Registration |
|
| 643 | + && $registration->attendee() instanceof EE_Attendee |
|
| 644 | + && EEH_MSG_Template::is_mt_active('payment_reminder') |
|
| 645 | + && ! in_array( |
|
| 646 | + $transaction->status_ID(), |
|
| 647 | + array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code), |
|
| 648 | + true |
|
| 649 | + ) |
|
| 650 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 651 | + 'ee_send_message', |
|
| 652 | + 'espresso_transactions_send_payment_reminder' |
|
| 653 | + ) |
|
| 654 | + ) { |
|
| 655 | + $url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 656 | + array( |
|
| 657 | + 'action' => 'send_payment_reminder', |
|
| 658 | + 'TXN_ID' => $transaction->ID(), |
|
| 659 | + ), |
|
| 660 | + TXN_ADMIN_URL |
|
| 661 | + ); |
|
| 662 | + return ' |
|
| 663 | 663 | <a href="' . $url . '" |
| 664 | 664 | aria-label="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" |
| 665 | 665 | class="ee-aria-tooltip button button--icon-only" |
| 666 | 666 | > |
| 667 | 667 | <span class="dashicons dashicons-email-alt"></span> |
| 668 | 668 | </a>'; |
| 669 | - } |
|
| 670 | - return ''; |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * Get link to filtered view in the message activity list table of messages for this transaction. |
|
| 676 | - * |
|
| 677 | - * @param EE_Transaction $transaction |
|
| 678 | - * @return string |
|
| 679 | - * @throws EE_Error |
|
| 680 | - * @throws InvalidArgumentException |
|
| 681 | - * @throws InvalidDataTypeException |
|
| 682 | - * @throws InvalidInterfaceException |
|
| 683 | - */ |
|
| 684 | - protected function get_related_messages_link(EE_Transaction $transaction) |
|
| 685 | - { |
|
| 686 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 687 | - 'ee_read_global_messages', |
|
| 688 | - 'view_filtered_messages' |
|
| 689 | - ) |
|
| 690 | - ? EEH_MSG_Template::get_message_action_link( |
|
| 691 | - 'see_notifications_for', |
|
| 692 | - null, |
|
| 693 | - array('TXN_ID' => $transaction->ID()) |
|
| 694 | - ) |
|
| 695 | - : ''; |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * Return the link to make a payment on the frontend |
|
| 701 | - * |
|
| 702 | - * @param EE_Transaction $transaction |
|
| 703 | - * @return string |
|
| 704 | - * @throws EE_Error |
|
| 705 | - */ |
|
| 706 | - protected function get_payment_overview_link(EE_Transaction $transaction) |
|
| 707 | - { |
|
| 708 | - $registration = $transaction->primary_registration(); |
|
| 709 | - if ( |
|
| 710 | - $registration instanceof EE_Registration |
|
| 711 | - && $transaction->status_ID() !== EEM_Transaction::complete_status_code |
|
| 712 | - && $registration->owes_monies_and_can_pay() |
|
| 713 | - ) { |
|
| 714 | - return ' |
|
| 669 | + } |
|
| 670 | + return ''; |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * Get link to filtered view in the message activity list table of messages for this transaction. |
|
| 676 | + * |
|
| 677 | + * @param EE_Transaction $transaction |
|
| 678 | + * @return string |
|
| 679 | + * @throws EE_Error |
|
| 680 | + * @throws InvalidArgumentException |
|
| 681 | + * @throws InvalidDataTypeException |
|
| 682 | + * @throws InvalidInterfaceException |
|
| 683 | + */ |
|
| 684 | + protected function get_related_messages_link(EE_Transaction $transaction) |
|
| 685 | + { |
|
| 686 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 687 | + 'ee_read_global_messages', |
|
| 688 | + 'view_filtered_messages' |
|
| 689 | + ) |
|
| 690 | + ? EEH_MSG_Template::get_message_action_link( |
|
| 691 | + 'see_notifications_for', |
|
| 692 | + null, |
|
| 693 | + array('TXN_ID' => $transaction->ID()) |
|
| 694 | + ) |
|
| 695 | + : ''; |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * Return the link to make a payment on the frontend |
|
| 701 | + * |
|
| 702 | + * @param EE_Transaction $transaction |
|
| 703 | + * @return string |
|
| 704 | + * @throws EE_Error |
|
| 705 | + */ |
|
| 706 | + protected function get_payment_overview_link(EE_Transaction $transaction) |
|
| 707 | + { |
|
| 708 | + $registration = $transaction->primary_registration(); |
|
| 709 | + if ( |
|
| 710 | + $registration instanceof EE_Registration |
|
| 711 | + && $transaction->status_ID() !== EEM_Transaction::complete_status_code |
|
| 712 | + && $registration->owes_monies_and_can_pay() |
|
| 713 | + ) { |
|
| 714 | + return ' |
|
| 715 | 715 | <a aria-label="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"' |
| 716 | - . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"' |
|
| 717 | - . ' class="ee-aria-tooltip button button--icon-only"> |
|
| 716 | + . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"' |
|
| 717 | + . ' class="ee-aria-tooltip button button--icon-only"> |
|
| 718 | 718 | <span class="dashicons dashicons-money"></span> |
| 719 | 719 | </a>'; |
| 720 | - } |
|
| 721 | - return ''; |
|
| 722 | - } |
|
| 720 | + } |
|
| 721 | + return ''; |
|
| 722 | + } |
|
| 723 | 723 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | ); |
| 59 | 59 | $ID_column_name = esc_html__('ID', 'event_espresso'); |
| 60 | 60 | $ID_column_name .= '<span class="show-on-mobile-view-only" style="float:none">'; |
| 61 | - $ID_column_name .= ' : ' . esc_html__('Transaction Date', 'event_espresso'); |
|
| 61 | + $ID_column_name .= ' : '.esc_html__('Transaction Date', 'event_espresso'); |
|
| 62 | 62 | $ID_column_name .= '</span> '; |
| 63 | 63 | $this->_columns = array( |
| 64 | 64 | 'id' => $ID_column_name, |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $class = parent::_get_row_class($transaction); |
| 98 | 98 | // add status class |
| 99 | - $class .= ' txn-status-' . $transaction->status_ID(); |
|
| 99 | + $class .= ' txn-status-'.$transaction->status_ID(); |
|
| 100 | 100 | if ($this->_has_checkbox_column) { |
| 101 | 101 | $class .= ' has-checkbox-column'; |
| 102 | 102 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | protected function _add_view_counts() |
| 160 | 160 | { |
| 161 | 161 | foreach ($this->_views as $view) { |
| 162 | - $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
| 162 | + $this->_views[$view['slug']]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | ), |
| 181 | 181 | TXN_ADMIN_URL |
| 182 | 182 | ); |
| 183 | - $content = '<a class="ee-aria-tooltip" href="' . $view_lnk_url . '"' |
|
| 184 | - . ' aria-label="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">' |
|
| 183 | + $content = '<a class="ee-aria-tooltip" href="'.$view_lnk_url.'"' |
|
| 184 | + . ' aria-label="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">' |
|
| 185 | 185 | . $transaction->ID() |
| 186 | 186 | . '</a>'; |
| 187 | 187 | |
| 188 | 188 | // txn timestamp |
| 189 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>'; |
|
| 189 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>'; |
|
| 190 | 190 | return $this->columnContent('id', $content, 'end'); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
| 253 | 253 | return ' |
| 254 | 254 | <div class="ee-layout-row"> |
| 255 | - <span aria-label="' . $pretty_status . '" class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"></span> |
|
| 256 | - <a href="' . $view_lnk_url . '" |
|
| 257 | - class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" |
|
| 258 | - aria-label="' . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID( |
|
| 259 | - ) . '"> |
|
| 260 | - ' . $this->_get_txn_timestamp($transaction) . ' |
|
| 255 | + <span aria-label="' . $pretty_status.'" class="ee-status-dot ee-status-bg--'.$status.' ee-aria-tooltip"></span> |
|
| 256 | + <a href="' . $view_lnk_url.'" |
|
| 257 | + class="row-title ee-status-color--' . $status.' ee-aria-tooltip" |
|
| 258 | + aria-label="' . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID( |
|
| 259 | + ).'"> |
|
| 260 | + ' . $this->_get_txn_timestamp($transaction).' |
|
| 261 | 261 | </a> |
| 262 | 262 | </div>'; |
| 263 | 263 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | ) |
| 282 | 282 | . '</span>'; |
| 283 | 283 | } else { |
| 284 | - return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
| 284 | + return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>'; |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | ? $payment_method->admin_name() |
| 319 | 319 | : esc_html__('Unknown', 'event_espresso'); |
| 320 | 320 | |
| 321 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' |
|
| 321 | + $content = '<span class="'.$span_class.' txn-pad-rght">' |
|
| 322 | 322 | . $transaction->get_pretty('TXN_paid') |
| 323 | 323 | . '</span>'; |
| 324 | 324 | if ($transaction_paid > 0) { |
@@ -360,12 +360,12 @@ discard block |
||
| 360 | 360 | 'espresso_registrations_view_registration', |
| 361 | 361 | $primary_reg->ID() |
| 362 | 362 | ) |
| 363 | - ? '<a href="' . $edit_lnk_url . '"' |
|
| 364 | - . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 363 | + ? '<a href="'.$edit_lnk_url.'"' |
|
| 364 | + . ' aria-label="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
| 365 | 365 | . $attendee->full_name() |
| 366 | 366 | . '</a>' |
| 367 | 367 | : $attendee->full_name(); |
| 368 | - $content .= '<br>' . $attendee->email(); |
|
| 368 | + $content .= '<br>'.$attendee->email(); |
|
| 369 | 369 | return $content; |
| 370 | 370 | } |
| 371 | 371 | return $transaction->failed() || $transaction->is_abandoned() |
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | public function column_ATT_email(EE_Transaction $transaction) |
| 388 | 388 | { |
| 389 | 389 | $attendee = $transaction->primary_registration()->get_first_related('Attendee'); |
| 390 | - if (! empty($attendee)) { |
|
| 391 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' |
|
| 390 | + if ( ! empty($attendee)) { |
|
| 391 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">' |
|
| 392 | 392 | . $attendee->get('ATT_email') |
| 393 | 393 | . '</a>'; |
| 394 | 394 | } else { |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | { |
| 417 | 417 | $actions = array(); |
| 418 | 418 | $event = $transaction->primary_registration()->get_first_related('Event'); |
| 419 | - if (! empty($event)) { |
|
| 419 | + if ( ! empty($event)) { |
|
| 420 | 420 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
| 421 | 421 | array('action' => 'edit', 'post' => $event->ID()), |
| 422 | 422 | EVENTS_ADMIN_URL |
@@ -439,11 +439,11 @@ discard block |
||
| 439 | 439 | $event->ID() |
| 440 | 440 | ) |
| 441 | 441 | ) { |
| 442 | - $actions['filter_by_event'] = '<a class="ee-aria-tooltip" href="' . $txn_by_event_lnk . '"' |
|
| 443 | - . ' aria-label="' . esc_attr__( |
|
| 442 | + $actions['filter_by_event'] = '<a class="ee-aria-tooltip" href="'.$txn_by_event_lnk.'"' |
|
| 443 | + . ' aria-label="'.esc_attr__( |
|
| 444 | 444 | 'Filter transactions by this event', |
| 445 | 445 | 'event_espresso' |
| 446 | - ) . '">' |
|
| 446 | + ).'">' |
|
| 447 | 447 | . esc_html__('View Transactions for this event', 'event_espresso') |
| 448 | 448 | . '</a>'; |
| 449 | 449 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | 'espresso_events_edit', |
| 456 | 456 | $event->ID() |
| 457 | 457 | ) |
| 458 | - ? '<a class="ee-aria-tooltip" href="' . $edit_event_url . '"' |
|
| 458 | + ? '<a class="ee-aria-tooltip" href="'.$edit_event_url.'"' |
|
| 459 | 459 | . ' aria-label="' |
| 460 | 460 | . sprintf( |
| 461 | 461 | esc_attr__('Edit Event: %s', 'event_espresso'), |
@@ -523,8 +523,8 @@ discard block |
||
| 523 | 523 | TXN_ADMIN_URL |
| 524 | 524 | ); |
| 525 | 525 | return ' |
| 526 | - <a class="ee-aria-tooltip button button--icon-only" href="' . $url . '"' |
|
| 527 | - . ' aria-label="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="button button--icon-only"> |
|
| 526 | + <a class="ee-aria-tooltip button button--icon-only" href="' . $url.'"' |
|
| 527 | + . ' aria-label="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="button button--icon-only"> |
|
| 528 | 528 | <span class="dashicons dashicons-cart"></span> |
| 529 | 529 | </a>'; |
| 530 | 530 | } |
@@ -548,8 +548,8 @@ discard block |
||
| 548 | 548 | && EEH_MSG_Template::is_mt_active('invoice') |
| 549 | 549 | ) { |
| 550 | 550 | return ' |
| 551 | - <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"' |
|
| 552 | - . ' target="_blank" href="' . $url . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 551 | + <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"' |
|
| 552 | + . ' target="_blank" href="'.$url.'" class="ee-aria-tooltip button button--icon-only"> |
|
| 553 | 553 | <span class="dashicons dashicons-media-spreadsheet"></span> |
| 554 | 554 | </a>'; |
| 555 | 555 | } |
@@ -576,8 +576,8 @@ discard block |
||
| 576 | 576 | && EEH_MSG_Template::is_mt_active('receipt') |
| 577 | 577 | ) { |
| 578 | 578 | return ' |
| 579 | - <a aria-label="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"' |
|
| 580 | - . ' target="_blank" href="' . $url . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 579 | + <a aria-label="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"' |
|
| 580 | + . ' target="_blank" href="'.$url.'" class="ee-aria-tooltip button button--icon-only"> |
|
| 581 | 581 | <span class="dashicons dashicons-text-page"></span> |
| 582 | 582 | </a>'; |
| 583 | 583 | } |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | $registration->ID() |
| 614 | 614 | ) |
| 615 | 615 | ? ' |
| 616 | - <a href="' . $url . '" |
|
| 617 | - aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" |
|
| 616 | + <a href="' . $url.'" |
|
| 617 | + aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'" |
|
| 618 | 618 | class="ee-aria-tooltip button button--icon-only" |
| 619 | 619 | > |
| 620 | 620 | <span class="dashicons dashicons-clipboard"></span> |
@@ -660,8 +660,8 @@ discard block |
||
| 660 | 660 | TXN_ADMIN_URL |
| 661 | 661 | ); |
| 662 | 662 | return ' |
| 663 | - <a href="' . $url . '" |
|
| 664 | - aria-label="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" |
|
| 663 | + <a href="' . $url.'" |
|
| 664 | + aria-label="' . esc_attr__('Send Payment Reminder', 'event_espresso').'" |
|
| 665 | 665 | class="ee-aria-tooltip button button--icon-only" |
| 666 | 666 | > |
| 667 | 667 | <span class="dashicons dashicons-email-alt"></span> |
@@ -712,8 +712,8 @@ discard block |
||
| 712 | 712 | && $registration->owes_monies_and_can_pay() |
| 713 | 713 | ) { |
| 714 | 714 | return ' |
| 715 | - <a aria-label="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"' |
|
| 716 | - . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"' |
|
| 715 | + <a aria-label="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"' |
|
| 716 | + . ' target="_blank" href="'.$registration->payment_overview_url(true).'"' |
|
| 717 | 717 | . ' class="ee-aria-tooltip button button--icon-only"> |
| 718 | 718 | <span class="dashicons dashicons-money"></span> |
| 719 | 719 | </a>'; |
@@ -16,2920 +16,2920 @@ |
||
| 16 | 16 | class Events_Admin_Page extends EE_Admin_Page_CPT |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * This will hold the event object for event_details screen. |
|
| 19 | + /** |
|
| 20 | + * This will hold the event object for event_details screen. |
|
| 21 | + * |
|
| 22 | + * @var EE_Event $_event |
|
| 23 | + */ |
|
| 24 | + protected $_event; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * This will hold the category object for category_details screen. |
|
| 29 | + * |
|
| 30 | + * @var stdClass $_category |
|
| 31 | + */ |
|
| 32 | + protected $_category; |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * This will hold the event model instance |
|
| 37 | + * |
|
| 38 | + * @var EEM_Event $_event_model |
|
| 39 | + */ |
|
| 40 | + protected $_event_model; |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var EE_Event |
|
| 45 | + */ |
|
| 46 | + protected $_cpt_model_obj = false; |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var NodeGroupDao |
|
| 51 | + */ |
|
| 52 | + protected $model_obj_node_group_persister; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Initialize page props for this admin page group. |
|
| 57 | + */ |
|
| 58 | + protected function _init_page_props() |
|
| 59 | + { |
|
| 60 | + $this->page_slug = EVENTS_PG_SLUG; |
|
| 61 | + $this->page_label = EVENTS_LABEL; |
|
| 62 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
| 63 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
| 64 | + $this->_cpt_model_names = [ |
|
| 65 | + 'create_new' => 'EEM_Event', |
|
| 66 | + 'edit' => 'EEM_Event', |
|
| 67 | + ]; |
|
| 68 | + $this->_cpt_edit_routes = [ |
|
| 69 | + 'espresso_events' => 'edit', |
|
| 70 | + ]; |
|
| 71 | + add_action( |
|
| 72 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
| 73 | + [$this, 'verify_event_edit'], |
|
| 74 | + 10, |
|
| 75 | + 2 |
|
| 76 | + ); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Sets the ajax hooks used for this admin page group. |
|
| 82 | + */ |
|
| 83 | + protected function _ajax_hooks() |
|
| 84 | + { |
|
| 85 | + add_action('wp_ajax_ee_save_timezone_setting', [$this, 'saveTimezoneString']); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Sets the page properties for this admin page group. |
|
| 91 | + */ |
|
| 92 | + protected function _define_page_props() |
|
| 93 | + { |
|
| 94 | + $this->_admin_page_title = EVENTS_LABEL; |
|
| 95 | + $this->_labels = [ |
|
| 96 | + 'buttons' => [ |
|
| 97 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
| 98 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
| 99 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
| 100 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
| 101 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
| 102 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
| 103 | + ], |
|
| 104 | + 'editor_title' => [ |
|
| 105 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
| 106 | + ], |
|
| 107 | + 'publishbox' => [ |
|
| 108 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
| 109 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
| 110 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
| 111 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
| 112 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
| 113 | + ], |
|
| 114 | + ]; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * Sets the page routes property for this admin page group. |
|
| 120 | + */ |
|
| 121 | + protected function _set_page_routes() |
|
| 122 | + { |
|
| 123 | + // load formatter helper |
|
| 124 | + // load field generator helper |
|
| 125 | + // is there a evt_id in the request? |
|
| 126 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 127 | + $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
| 128 | + |
|
| 129 | + $this->_page_routes = [ |
|
| 130 | + 'default' => [ |
|
| 131 | + 'func' => '_events_overview_list_table', |
|
| 132 | + 'capability' => 'ee_read_events', |
|
| 133 | + ], |
|
| 134 | + 'create_new' => [ |
|
| 135 | + 'func' => '_create_new_cpt_item', |
|
| 136 | + 'capability' => 'ee_edit_events', |
|
| 137 | + ], |
|
| 138 | + 'edit' => [ |
|
| 139 | + 'func' => '_edit_cpt_item', |
|
| 140 | + 'capability' => 'ee_edit_event', |
|
| 141 | + 'obj_id' => $EVT_ID, |
|
| 142 | + ], |
|
| 143 | + 'copy_event' => [ |
|
| 144 | + 'func' => '_copy_events', |
|
| 145 | + 'capability' => 'ee_edit_event', |
|
| 146 | + 'obj_id' => $EVT_ID, |
|
| 147 | + 'noheader' => true, |
|
| 148 | + ], |
|
| 149 | + 'trash_event' => [ |
|
| 150 | + 'func' => '_trash_or_restore_event', |
|
| 151 | + 'args' => ['event_status' => 'trash'], |
|
| 152 | + 'capability' => 'ee_delete_event', |
|
| 153 | + 'obj_id' => $EVT_ID, |
|
| 154 | + 'noheader' => true, |
|
| 155 | + ], |
|
| 156 | + 'trash_events' => [ |
|
| 157 | + 'func' => '_trash_or_restore_events', |
|
| 158 | + 'args' => ['event_status' => 'trash'], |
|
| 159 | + 'capability' => 'ee_delete_events', |
|
| 160 | + 'noheader' => true, |
|
| 161 | + ], |
|
| 162 | + 'restore_event' => [ |
|
| 163 | + 'func' => '_trash_or_restore_event', |
|
| 164 | + 'args' => ['event_status' => 'draft'], |
|
| 165 | + 'capability' => 'ee_delete_event', |
|
| 166 | + 'obj_id' => $EVT_ID, |
|
| 167 | + 'noheader' => true, |
|
| 168 | + ], |
|
| 169 | + 'restore_events' => [ |
|
| 170 | + 'func' => '_trash_or_restore_events', |
|
| 171 | + 'args' => ['event_status' => 'draft'], |
|
| 172 | + 'capability' => 'ee_delete_events', |
|
| 173 | + 'noheader' => true, |
|
| 174 | + ], |
|
| 175 | + 'delete_event' => [ |
|
| 176 | + 'func' => '_delete_event', |
|
| 177 | + 'capability' => 'ee_delete_event', |
|
| 178 | + 'obj_id' => $EVT_ID, |
|
| 179 | + 'noheader' => true, |
|
| 180 | + ], |
|
| 181 | + 'delete_events' => [ |
|
| 182 | + 'func' => '_delete_events', |
|
| 183 | + 'capability' => 'ee_delete_events', |
|
| 184 | + 'noheader' => true, |
|
| 185 | + ], |
|
| 186 | + 'view_report' => [ |
|
| 187 | + 'func' => '_view_report', |
|
| 188 | + 'capability' => 'ee_edit_events', |
|
| 189 | + ], |
|
| 190 | + 'default_event_settings' => [ |
|
| 191 | + 'func' => '_default_event_settings', |
|
| 192 | + 'capability' => 'manage_options', |
|
| 193 | + ], |
|
| 194 | + 'update_default_event_settings' => [ |
|
| 195 | + 'func' => '_update_default_event_settings', |
|
| 196 | + 'capability' => 'manage_options', |
|
| 197 | + 'noheader' => true, |
|
| 198 | + ], |
|
| 199 | + 'template_settings' => [ |
|
| 200 | + 'func' => '_template_settings', |
|
| 201 | + 'capability' => 'manage_options', |
|
| 202 | + ], |
|
| 203 | + // event category tab related |
|
| 204 | + 'add_category' => [ |
|
| 205 | + 'func' => '_category_details', |
|
| 206 | + 'capability' => 'ee_edit_event_category', |
|
| 207 | + 'args' => ['add'], |
|
| 208 | + ], |
|
| 209 | + 'edit_category' => [ |
|
| 210 | + 'func' => '_category_details', |
|
| 211 | + 'capability' => 'ee_edit_event_category', |
|
| 212 | + 'args' => ['edit'], |
|
| 213 | + ], |
|
| 214 | + 'delete_categories' => [ |
|
| 215 | + 'func' => '_delete_categories', |
|
| 216 | + 'capability' => 'ee_delete_event_category', |
|
| 217 | + 'noheader' => true, |
|
| 218 | + ], |
|
| 219 | + 'delete_category' => [ |
|
| 220 | + 'func' => '_delete_categories', |
|
| 221 | + 'capability' => 'ee_delete_event_category', |
|
| 222 | + 'noheader' => true, |
|
| 223 | + ], |
|
| 224 | + 'insert_category' => [ |
|
| 225 | + 'func' => '_insert_or_update_category', |
|
| 226 | + 'args' => ['new_category' => true], |
|
| 227 | + 'capability' => 'ee_edit_event_category', |
|
| 228 | + 'noheader' => true, |
|
| 229 | + ], |
|
| 230 | + 'update_category' => [ |
|
| 231 | + 'func' => '_insert_or_update_category', |
|
| 232 | + 'args' => ['new_category' => false], |
|
| 233 | + 'capability' => 'ee_edit_event_category', |
|
| 234 | + 'noheader' => true, |
|
| 235 | + ], |
|
| 236 | + 'category_list' => [ |
|
| 237 | + 'func' => '_category_list_table', |
|
| 238 | + 'capability' => 'ee_manage_event_categories', |
|
| 239 | + ], |
|
| 240 | + 'preview_deletion' => [ |
|
| 241 | + 'func' => 'previewDeletion', |
|
| 242 | + 'capability' => 'ee_delete_events', |
|
| 243 | + ], |
|
| 244 | + 'confirm_deletion' => [ |
|
| 245 | + 'func' => 'confirmDeletion', |
|
| 246 | + 'capability' => 'ee_delete_events', |
|
| 247 | + 'noheader' => true, |
|
| 248 | + ], |
|
| 249 | + ]; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Set the _page_config property for this admin page group. |
|
| 255 | + */ |
|
| 256 | + protected function _set_page_config() |
|
| 257 | + { |
|
| 258 | + $post_id = $this->request->getRequestParam('post', 0, 'int'); |
|
| 259 | + $EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
| 260 | + $this->_page_config = [ |
|
| 261 | + 'default' => [ |
|
| 262 | + 'nav' => [ |
|
| 263 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 264 | + 'order' => 10, |
|
| 265 | + ], |
|
| 266 | + 'list_table' => 'Events_Admin_List_Table', |
|
| 267 | + 'help_tabs' => [ |
|
| 268 | + 'events_overview_help_tab' => [ |
|
| 269 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
| 270 | + 'filename' => 'events_overview', |
|
| 271 | + ], |
|
| 272 | + 'events_overview_table_column_headings_help_tab' => [ |
|
| 273 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
| 274 | + 'filename' => 'events_overview_table_column_headings', |
|
| 275 | + ], |
|
| 276 | + 'events_overview_filters_help_tab' => [ |
|
| 277 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
| 278 | + 'filename' => 'events_overview_filters', |
|
| 279 | + ], |
|
| 280 | + 'events_overview_view_help_tab' => [ |
|
| 281 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
| 282 | + 'filename' => 'events_overview_views', |
|
| 283 | + ], |
|
| 284 | + 'events_overview_other_help_tab' => [ |
|
| 285 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
| 286 | + 'filename' => 'events_overview_other', |
|
| 287 | + ], |
|
| 288 | + ], |
|
| 289 | + // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 290 | + // 'help_tour' => [ |
|
| 291 | + // 'Event_Overview_Help_Tour', |
|
| 292 | + // // 'New_Features_Test_Help_Tour' for testing multiple help tour |
|
| 293 | + // ], |
|
| 294 | + 'qtips' => ['EE_Event_List_Table_Tips'], |
|
| 295 | + 'require_nonce' => false, |
|
| 296 | + ], |
|
| 297 | + 'create_new' => [ |
|
| 298 | + 'nav' => [ |
|
| 299 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
| 300 | + 'order' => 5, |
|
| 301 | + 'persistent' => false, |
|
| 302 | + ], |
|
| 303 | + 'metaboxes' => ['_register_event_editor_meta_boxes'], |
|
| 304 | + 'help_tabs' => [ |
|
| 305 | + 'event_editor_help_tab' => [ |
|
| 306 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 307 | + 'filename' => 'event_editor', |
|
| 308 | + ], |
|
| 309 | + 'event_editor_title_richtexteditor_help_tab' => [ |
|
| 310 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 311 | + 'filename' => 'event_editor_title_richtexteditor', |
|
| 312 | + ], |
|
| 313 | + 'event_editor_venue_details_help_tab' => [ |
|
| 314 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 315 | + 'filename' => 'event_editor_venue_details', |
|
| 316 | + ], |
|
| 317 | + 'event_editor_event_datetimes_help_tab' => [ |
|
| 318 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 319 | + 'filename' => 'event_editor_event_datetimes', |
|
| 320 | + ], |
|
| 321 | + 'event_editor_event_tickets_help_tab' => [ |
|
| 322 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 323 | + 'filename' => 'event_editor_event_tickets', |
|
| 324 | + ], |
|
| 325 | + 'event_editor_event_registration_options_help_tab' => [ |
|
| 326 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 327 | + 'filename' => 'event_editor_event_registration_options', |
|
| 328 | + ], |
|
| 329 | + 'event_editor_tags_categories_help_tab' => [ |
|
| 330 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 331 | + 'filename' => 'event_editor_tags_categories', |
|
| 332 | + ], |
|
| 333 | + 'event_editor_questions_registrants_help_tab' => [ |
|
| 334 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 335 | + 'filename' => 'event_editor_questions_registrants', |
|
| 336 | + ], |
|
| 337 | + 'event_editor_save_new_event_help_tab' => [ |
|
| 338 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 339 | + 'filename' => 'event_editor_save_new_event', |
|
| 340 | + ], |
|
| 341 | + 'event_editor_other_help_tab' => [ |
|
| 342 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 343 | + 'filename' => 'event_editor_other', |
|
| 344 | + ], |
|
| 345 | + ], |
|
| 346 | + // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 347 | + // 'help_tour' => [ |
|
| 348 | + // 'Event_Editor_Help_Tour', |
|
| 349 | + // ], |
|
| 350 | + 'qtips' => ['EE_Event_Editor_Decaf_Tips'], |
|
| 351 | + 'require_nonce' => false, |
|
| 352 | + ], |
|
| 353 | + 'edit' => [ |
|
| 354 | + 'nav' => [ |
|
| 355 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
| 356 | + 'order' => 5, |
|
| 357 | + 'persistent' => false, |
|
| 358 | + 'url' => $post_id |
|
| 359 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 360 | + ['post' => $post_id, 'action' => 'edit'], |
|
| 361 | + $this->_current_page_view_url |
|
| 362 | + ) |
|
| 363 | + : $this->_admin_base_url, |
|
| 364 | + ], |
|
| 365 | + 'metaboxes' => ['_register_event_editor_meta_boxes'], |
|
| 366 | + 'help_tabs' => [ |
|
| 367 | + 'event_editor_help_tab' => [ |
|
| 368 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 369 | + 'filename' => 'event_editor', |
|
| 370 | + ], |
|
| 371 | + 'event_editor_title_richtexteditor_help_tab' => [ |
|
| 372 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 373 | + 'filename' => 'event_editor_title_richtexteditor', |
|
| 374 | + ], |
|
| 375 | + 'event_editor_venue_details_help_tab' => [ |
|
| 376 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 377 | + 'filename' => 'event_editor_venue_details', |
|
| 378 | + ], |
|
| 379 | + 'event_editor_event_datetimes_help_tab' => [ |
|
| 380 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 381 | + 'filename' => 'event_editor_event_datetimes', |
|
| 382 | + ], |
|
| 383 | + 'event_editor_event_tickets_help_tab' => [ |
|
| 384 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 385 | + 'filename' => 'event_editor_event_tickets', |
|
| 386 | + ], |
|
| 387 | + 'event_editor_event_registration_options_help_tab' => [ |
|
| 388 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 389 | + 'filename' => 'event_editor_event_registration_options', |
|
| 390 | + ], |
|
| 391 | + 'event_editor_tags_categories_help_tab' => [ |
|
| 392 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 393 | + 'filename' => 'event_editor_tags_categories', |
|
| 394 | + ], |
|
| 395 | + 'event_editor_questions_registrants_help_tab' => [ |
|
| 396 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 397 | + 'filename' => 'event_editor_questions_registrants', |
|
| 398 | + ], |
|
| 399 | + 'event_editor_save_new_event_help_tab' => [ |
|
| 400 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 401 | + 'filename' => 'event_editor_save_new_event', |
|
| 402 | + ], |
|
| 403 | + 'event_editor_other_help_tab' => [ |
|
| 404 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 405 | + 'filename' => 'event_editor_other', |
|
| 406 | + ], |
|
| 407 | + ], |
|
| 408 | + 'require_nonce' => false, |
|
| 409 | + ], |
|
| 410 | + 'default_event_settings' => [ |
|
| 411 | + 'nav' => [ |
|
| 412 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
| 413 | + 'order' => 40, |
|
| 414 | + ], |
|
| 415 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
| 416 | + 'labels' => [ |
|
| 417 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
| 418 | + ], |
|
| 419 | + 'help_tabs' => [ |
|
| 420 | + 'default_settings_help_tab' => [ |
|
| 421 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
| 422 | + 'filename' => 'events_default_settings', |
|
| 423 | + ], |
|
| 424 | + 'default_settings_status_help_tab' => [ |
|
| 425 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
| 426 | + 'filename' => 'events_default_settings_status', |
|
| 427 | + ], |
|
| 428 | + 'default_maximum_tickets_help_tab' => [ |
|
| 429 | + 'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), |
|
| 430 | + 'filename' => 'events_default_settings_max_tickets', |
|
| 431 | + ], |
|
| 432 | + ], |
|
| 433 | + // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 434 | + // 'help_tour' => ['Event_Default_Settings_Help_Tour'], |
|
| 435 | + 'require_nonce' => false, |
|
| 436 | + ], |
|
| 437 | + // template settings |
|
| 438 | + 'template_settings' => [ |
|
| 439 | + 'nav' => [ |
|
| 440 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 441 | + 'order' => 30, |
|
| 442 | + ], |
|
| 443 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 444 | + 'help_tabs' => [ |
|
| 445 | + 'general_settings_templates_help_tab' => [ |
|
| 446 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 447 | + 'filename' => 'general_settings_templates', |
|
| 448 | + ], |
|
| 449 | + ], |
|
| 450 | + // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 451 | + // 'help_tour' => ['Templates_Help_Tour'], |
|
| 452 | + 'require_nonce' => false, |
|
| 453 | + ], |
|
| 454 | + // event category stuff |
|
| 455 | + 'add_category' => [ |
|
| 456 | + 'nav' => [ |
|
| 457 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
| 458 | + 'order' => 15, |
|
| 459 | + 'persistent' => false, |
|
| 460 | + ], |
|
| 461 | + 'help_tabs' => [ |
|
| 462 | + 'add_category_help_tab' => [ |
|
| 463 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
| 464 | + 'filename' => 'events_add_category', |
|
| 465 | + ], |
|
| 466 | + ], |
|
| 467 | + // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 468 | + // 'help_tour' => ['Event_Add_Category_Help_Tour'], |
|
| 469 | + 'metaboxes' => ['_publish_post_box'], |
|
| 470 | + 'require_nonce' => false, |
|
| 471 | + ], |
|
| 472 | + 'edit_category' => [ |
|
| 473 | + 'nav' => [ |
|
| 474 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
| 475 | + 'order' => 15, |
|
| 476 | + 'persistent' => false, |
|
| 477 | + 'url' => $EVT_CAT_ID |
|
| 478 | + ? add_query_arg( |
|
| 479 | + ['EVT_CAT_ID' => $EVT_CAT_ID], |
|
| 480 | + $this->_current_page_view_url |
|
| 481 | + ) |
|
| 482 | + : $this->_admin_base_url, |
|
| 483 | + ], |
|
| 484 | + 'help_tabs' => [ |
|
| 485 | + 'edit_category_help_tab' => [ |
|
| 486 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
| 487 | + 'filename' => 'events_edit_category', |
|
| 488 | + ], |
|
| 489 | + ], |
|
| 490 | + /*'help_tour' => ['Event_Edit_Category_Help_Tour'],*/ |
|
| 491 | + 'metaboxes' => ['_publish_post_box'], |
|
| 492 | + 'require_nonce' => false, |
|
| 493 | + ], |
|
| 494 | + 'category_list' => [ |
|
| 495 | + 'nav' => [ |
|
| 496 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
| 497 | + 'order' => 20, |
|
| 498 | + ], |
|
| 499 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
| 500 | + 'help_tabs' => [ |
|
| 501 | + 'events_categories_help_tab' => [ |
|
| 502 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
| 503 | + 'filename' => 'events_categories', |
|
| 504 | + ], |
|
| 505 | + 'events_categories_table_column_headings_help_tab' => [ |
|
| 506 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
| 507 | + 'filename' => 'events_categories_table_column_headings', |
|
| 508 | + ], |
|
| 509 | + 'events_categories_view_help_tab' => [ |
|
| 510 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
| 511 | + 'filename' => 'events_categories_views', |
|
| 512 | + ], |
|
| 513 | + 'events_categories_other_help_tab' => [ |
|
| 514 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
| 515 | + 'filename' => 'events_categories_other', |
|
| 516 | + ], |
|
| 517 | + ], |
|
| 518 | + // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 519 | + // 'help_tour' => [ |
|
| 520 | + // 'Event_Categories_Help_Tour', |
|
| 521 | + // ], |
|
| 522 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 523 | + 'require_nonce' => false, |
|
| 524 | + ], |
|
| 525 | + 'preview_deletion' => [ |
|
| 526 | + 'nav' => [ |
|
| 527 | + 'label' => esc_html__('Preview Deletion', 'event_espresso'), |
|
| 528 | + 'order' => 15, |
|
| 529 | + 'persistent' => false, |
|
| 530 | + 'url' => '', |
|
| 531 | + ], |
|
| 532 | + 'require_nonce' => false, |
|
| 533 | + ], |
|
| 534 | + ]; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Used to register any global screen options if necessary for every route in this admin page group. |
|
| 540 | + */ |
|
| 541 | + protected function _add_screen_options() |
|
| 542 | + { |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * Implementing the screen options for the 'default' route. |
|
| 548 | + * |
|
| 549 | + * @throws InvalidArgumentException |
|
| 550 | + * @throws InvalidDataTypeException |
|
| 551 | + * @throws InvalidInterfaceException |
|
| 552 | + */ |
|
| 553 | + protected function _add_screen_options_default() |
|
| 554 | + { |
|
| 555 | + $this->_per_page_screen_option(); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * Implementing screen options for the category list route. |
|
| 561 | + * |
|
| 562 | + * @throws InvalidArgumentException |
|
| 563 | + * @throws InvalidDataTypeException |
|
| 564 | + * @throws InvalidInterfaceException |
|
| 565 | + */ |
|
| 566 | + protected function _add_screen_options_category_list() |
|
| 567 | + { |
|
| 568 | + $page_title = $this->_admin_page_title; |
|
| 569 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
| 570 | + $this->_per_page_screen_option(); |
|
| 571 | + $this->_admin_page_title = $page_title; |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * Used to register any global feature pointers for the admin page group. |
|
| 577 | + */ |
|
| 578 | + protected function _add_feature_pointers() |
|
| 579 | + { |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * Registers and enqueues any global scripts and styles for the entire admin page group. |
|
| 585 | + */ |
|
| 586 | + public function load_scripts_styles() |
|
| 587 | + { |
|
| 588 | + wp_register_style( |
|
| 589 | + 'events-admin-css', |
|
| 590 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 591 | + [], |
|
| 592 | + EVENT_ESPRESSO_VERSION |
|
| 593 | + ); |
|
| 594 | + wp_register_style( |
|
| 595 | + 'ee-cat-admin', |
|
| 596 | + EVENTS_ASSETS_URL . 'ee-cat-admin.css', |
|
| 597 | + [], |
|
| 598 | + EVENT_ESPRESSO_VERSION |
|
| 599 | + ); |
|
| 600 | + wp_enqueue_style('events-admin-css'); |
|
| 601 | + wp_enqueue_style('ee-cat-admin'); |
|
| 602 | + // scripts |
|
| 603 | + wp_register_script( |
|
| 604 | + 'event_editor_js', |
|
| 605 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 606 | + ['ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'], |
|
| 607 | + EVENT_ESPRESSO_VERSION, |
|
| 608 | + true |
|
| 609 | + ); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + |
|
| 613 | + /** |
|
| 614 | + * Enqueuing scripts and styles specific to this view |
|
| 615 | + */ |
|
| 616 | + public function load_scripts_styles_create_new() |
|
| 617 | + { |
|
| 618 | + $this->load_scripts_styles_edit(); |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * Enqueuing scripts and styles specific to this view |
|
| 624 | + */ |
|
| 625 | + public function load_scripts_styles_edit() |
|
| 626 | + { |
|
| 627 | + // styles |
|
| 628 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 629 | + wp_register_style( |
|
| 630 | + 'event-editor-css', |
|
| 631 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 632 | + ['ee-admin-css'], |
|
| 633 | + EVENT_ESPRESSO_VERSION |
|
| 634 | + ); |
|
| 635 | + wp_enqueue_style('event-editor-css'); |
|
| 636 | + // scripts |
|
| 637 | + if (! $this->admin_config->useAdvancedEditor()) { |
|
| 638 | + wp_register_script( |
|
| 639 | + 'event-datetime-metabox', |
|
| 640 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 641 | + ['event_editor_js', 'ee-datepicker'], |
|
| 642 | + EVENT_ESPRESSO_VERSION |
|
| 643 | + ); |
|
| 644 | + wp_enqueue_script('event-datetime-metabox'); |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + |
|
| 649 | + /** |
|
| 650 | + * Populating the _views property for the category list table view. |
|
| 651 | + */ |
|
| 652 | + protected function _set_list_table_views_category_list() |
|
| 653 | + { |
|
| 654 | + $this->_views = [ |
|
| 655 | + 'all' => [ |
|
| 656 | + 'slug' => 'all', |
|
| 657 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 658 | + 'count' => 0, |
|
| 659 | + 'bulk_action' => [ |
|
| 660 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 661 | + ], |
|
| 662 | + ], |
|
| 663 | + ]; |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + |
|
| 667 | + /** |
|
| 668 | + * For adding anything that fires on the admin_init hook for any route within this admin page group. |
|
| 669 | + */ |
|
| 670 | + public function admin_init() |
|
| 671 | + { |
|
| 672 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
| 673 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 674 | + 'event_espresso' |
|
| 675 | + ); |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + |
|
| 679 | + /** |
|
| 680 | + * For adding anything that should be triggered on the admin_notices hook for any route within this admin page |
|
| 681 | + * group. |
|
| 682 | + */ |
|
| 683 | + public function admin_notices() |
|
| 684 | + { |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + |
|
| 688 | + /** |
|
| 689 | + * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within |
|
| 690 | + * this admin page group. |
|
| 691 | + */ |
|
| 692 | + public function admin_footer_scripts() |
|
| 693 | + { |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + |
|
| 697 | + /** |
|
| 698 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
| 699 | + * warning (via EE_Error::add_error()); |
|
| 700 | + * |
|
| 701 | + * @param EE_Event $event Event object |
|
| 702 | + * @param string $req_type |
|
| 703 | + * @return void |
|
| 704 | + * @throws EE_Error |
|
| 705 | + * @throws ReflectionException |
|
| 706 | + */ |
|
| 707 | + public function verify_event_edit($event = null, $req_type = '') |
|
| 708 | + { |
|
| 709 | + // don't need to do this when processing |
|
| 710 | + if (! empty($req_type)) { |
|
| 711 | + return; |
|
| 712 | + } |
|
| 713 | + // no event? |
|
| 714 | + if (! $event instanceof EE_Event) { |
|
| 715 | + $event = $this->_cpt_model_obj; |
|
| 716 | + } |
|
| 717 | + // STILL no event? |
|
| 718 | + if (! $event instanceof EE_Event) { |
|
| 719 | + return; |
|
| 720 | + } |
|
| 721 | + $orig_status = $event->status(); |
|
| 722 | + // first check if event is active. |
|
| 723 | + if ( |
|
| 724 | + $orig_status === EEM_Event::cancelled |
|
| 725 | + || $orig_status === EEM_Event::postponed |
|
| 726 | + || $event->is_expired() |
|
| 727 | + || $event->is_inactive() |
|
| 728 | + ) { |
|
| 729 | + return; |
|
| 730 | + } |
|
| 731 | + // made it here so it IS active... next check that any of the tickets are sold. |
|
| 732 | + if ($event->is_sold_out(true)) { |
|
| 733 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
| 734 | + EE_Error::add_attention( |
|
| 735 | + sprintf( |
|
| 736 | + esc_html__( |
|
| 737 | + 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
| 738 | + 'event_espresso' |
|
| 739 | + ), |
|
| 740 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
| 741 | + ) |
|
| 742 | + ); |
|
| 743 | + } |
|
| 744 | + return; |
|
| 745 | + } |
|
| 746 | + if ($orig_status === EEM_Event::sold_out) { |
|
| 747 | + EE_Error::add_attention( |
|
| 748 | + sprintf( |
|
| 749 | + esc_html__( |
|
| 750 | + 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
| 751 | + 'event_espresso' |
|
| 752 | + ), |
|
| 753 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
| 754 | + ) |
|
| 755 | + ); |
|
| 756 | + } |
|
| 757 | + // now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
| 758 | + if (! $event->tickets_on_sale()) { |
|
| 759 | + return; |
|
| 760 | + } |
|
| 761 | + // made it here so show warning |
|
| 762 | + $this->_edit_event_warning(); |
|
| 763 | + } |
|
| 764 | + |
|
| 765 | + |
|
| 766 | + /** |
|
| 767 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
| 768 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
| 769 | + * |
|
| 770 | + * @access protected |
|
| 771 | + * @return void |
|
| 772 | + */ |
|
| 773 | + protected function _edit_event_warning() |
|
| 774 | + { |
|
| 775 | + // we don't want to add warnings during these requests |
|
| 776 | + if ($this->request->getRequestParam('action') === 'editpost') { |
|
| 777 | + return; |
|
| 778 | + } |
|
| 779 | + EE_Error::add_attention( |
|
| 780 | + sprintf( |
|
| 781 | + esc_html__( |
|
| 782 | + 'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s', |
|
| 783 | + 'event_espresso' |
|
| 784 | + ), |
|
| 785 | + '<a class="espresso-help-tab-lnk">', |
|
| 786 | + '</a>' |
|
| 787 | + ) |
|
| 788 | + ); |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + |
|
| 792 | + /** |
|
| 793 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
| 794 | + * Otherwise, do the normal logic |
|
| 795 | + * |
|
| 796 | + * @return void |
|
| 797 | + * @throws EE_Error |
|
| 798 | + * @throws InvalidArgumentException |
|
| 799 | + * @throws InvalidDataTypeException |
|
| 800 | + * @throws InvalidInterfaceException |
|
| 801 | + */ |
|
| 802 | + protected function _create_new_cpt_item() |
|
| 803 | + { |
|
| 804 | + $has_timezone_string = get_option('timezone_string'); |
|
| 805 | + // only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
| 806 | + if (! $has_timezone_string && ! EEM_Event::instance()->exists([])) { |
|
| 807 | + EE_Error::add_attention( |
|
| 808 | + sprintf( |
|
| 809 | + esc_html__( |
|
| 810 | + 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s', |
|
| 811 | + 'event_espresso' |
|
| 812 | + ), |
|
| 813 | + '<br>', |
|
| 814 | + '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">' |
|
| 815 | + . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) |
|
| 816 | + . '</select>', |
|
| 817 | + '<button class="button button--secondary timezone-submit">', |
|
| 818 | + '</button><span class="spinner"></span>' |
|
| 819 | + ), |
|
| 820 | + __FILE__, |
|
| 821 | + __FUNCTION__, |
|
| 822 | + __LINE__ |
|
| 823 | + ); |
|
| 824 | + } |
|
| 825 | + parent::_create_new_cpt_item(); |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + |
|
| 829 | + /** |
|
| 830 | + * Sets the _views property for the default route in this admin page group. |
|
| 831 | + */ |
|
| 832 | + protected function _set_list_table_views_default() |
|
| 833 | + { |
|
| 834 | + $this->_views = [ |
|
| 835 | + 'all' => [ |
|
| 836 | + 'slug' => 'all', |
|
| 837 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
| 838 | + 'count' => 0, |
|
| 839 | + 'bulk_action' => [ |
|
| 840 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 841 | + ], |
|
| 842 | + ], |
|
| 843 | + 'draft' => [ |
|
| 844 | + 'slug' => 'draft', |
|
| 845 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
| 846 | + 'count' => 0, |
|
| 847 | + 'bulk_action' => [ |
|
| 848 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 849 | + ], |
|
| 850 | + ], |
|
| 851 | + ]; |
|
| 852 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 853 | + $this->_views['trash'] = [ |
|
| 854 | + 'slug' => 'trash', |
|
| 855 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 856 | + 'count' => 0, |
|
| 857 | + 'bulk_action' => [ |
|
| 858 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
| 859 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 860 | + ], |
|
| 861 | + ]; |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + |
|
| 866 | + /** |
|
| 867 | + * Provides the legend item array for the default list table view. |
|
| 868 | + * |
|
| 869 | + * @return array |
|
| 870 | + * @throws EE_Error |
|
| 871 | + * @throws EE_Error |
|
| 872 | + */ |
|
| 873 | + protected function _event_legend_items() |
|
| 874 | + { |
|
| 875 | + $items = [ |
|
| 876 | + 'view_details' => [ |
|
| 877 | + 'class' => 'dashicons dashicons-visibility', |
|
| 878 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
| 879 | + ], |
|
| 880 | + 'edit_event' => [ |
|
| 881 | + 'class' => 'dashicons dashicons-calendar-alt', |
|
| 882 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
| 883 | + ], |
|
| 884 | + 'view_attendees' => [ |
|
| 885 | + 'class' => 'dashicons dashicons-groups', |
|
| 886 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
| 887 | + ], |
|
| 888 | + ]; |
|
| 889 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
| 890 | + $statuses = [ |
|
| 891 | + 'sold_out_status' => [ |
|
| 892 | + 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::sold_out, |
|
| 893 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
| 894 | + ], |
|
| 895 | + 'active_status' => [ |
|
| 896 | + 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::active, |
|
| 897 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
| 898 | + ], |
|
| 899 | + 'upcoming_status' => [ |
|
| 900 | + 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::upcoming, |
|
| 901 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
| 902 | + ], |
|
| 903 | + 'postponed_status' => [ |
|
| 904 | + 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::postponed, |
|
| 905 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
| 906 | + ], |
|
| 907 | + 'cancelled_status' => [ |
|
| 908 | + 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::cancelled, |
|
| 909 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
| 910 | + ], |
|
| 911 | + 'expired_status' => [ |
|
| 912 | + 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::expired, |
|
| 913 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
| 914 | + ], |
|
| 915 | + 'inactive_status' => [ |
|
| 916 | + 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::inactive, |
|
| 917 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
| 918 | + ], |
|
| 919 | + ]; |
|
| 920 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
| 921 | + return array_merge($items, $statuses); |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + |
|
| 925 | + /** |
|
| 926 | + * @return EEM_Event |
|
| 927 | + * @throws EE_Error |
|
| 928 | + * @throws InvalidArgumentException |
|
| 929 | + * @throws InvalidDataTypeException |
|
| 930 | + * @throws InvalidInterfaceException |
|
| 931 | + * @throws ReflectionException |
|
| 932 | + */ |
|
| 933 | + private function _event_model() |
|
| 934 | + { |
|
| 935 | + if (! $this->_event_model instanceof EEM_Event) { |
|
| 936 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
| 937 | + } |
|
| 938 | + return $this->_event_model; |
|
| 939 | + } |
|
| 940 | + |
|
| 941 | + |
|
| 942 | + /** |
|
| 943 | + * Adds extra buttons to the WP CPT permalink field row. |
|
| 944 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 945 | + * |
|
| 946 | + * @param string $return the current html |
|
| 947 | + * @param int $id the post id for the page |
|
| 948 | + * @param string $new_title What the title is |
|
| 949 | + * @param string $new_slug what the slug is |
|
| 950 | + * @return string The new html string for the permalink area |
|
| 951 | + */ |
|
| 952 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 953 | + { |
|
| 954 | + // make sure this is only when editing |
|
| 955 | + if (! empty($id)) { |
|
| 956 | + $post = get_post($id); |
|
| 957 | + $return .= '<a class="button button--small button--secondary" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
| 958 | + . esc_html__('Shortcode', 'event_espresso') |
|
| 959 | + . '</a> '; |
|
| 960 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
| 961 | + . $post->ID |
|
| 962 | + . ']">'; |
|
| 963 | + } |
|
| 964 | + return $return; |
|
| 965 | + } |
|
| 966 | + |
|
| 967 | + |
|
| 968 | + /** |
|
| 969 | + * _events_overview_list_table |
|
| 970 | + * This contains the logic for showing the events_overview list |
|
| 971 | + * |
|
| 972 | + * @access protected |
|
| 973 | + * @return void |
|
| 974 | + * @throws DomainException |
|
| 975 | + * @throws EE_Error |
|
| 976 | + * @throws InvalidArgumentException |
|
| 977 | + * @throws InvalidDataTypeException |
|
| 978 | + * @throws InvalidInterfaceException |
|
| 979 | + */ |
|
| 980 | + protected function _events_overview_list_table() |
|
| 981 | + { |
|
| 982 | + $after_list_table = []; |
|
| 983 | + $links_html = EEH_HTML::div('', '', 'ee-admin-section ee-layout-stack'); |
|
| 984 | + $links_html .= EEH_HTML::h3(esc_html__('Links', 'event_espresso')); |
|
| 985 | + $links_html .= EEH_HTML::div( |
|
| 986 | + EEH_Template::get_button_or_link( |
|
| 987 | + get_post_type_archive_link('espresso_events'), |
|
| 988 | + esc_html__('View Event Archive Page', 'event_espresso'), |
|
| 989 | + 'button button--small button--secondary' |
|
| 990 | + ), |
|
| 991 | + '', |
|
| 992 | + 'ee-admin-button-row ee-admin-button-row--align-start' |
|
| 993 | + ); |
|
| 994 | + $links_html .= EEH_HTML::divx(); |
|
| 995 | + |
|
| 996 | + $after_list_table['view_event_list_button'] = $links_html; |
|
| 997 | + |
|
| 998 | + $after_list_table['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
| 999 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 1000 | + 'create_new', |
|
| 1001 | + 'add', |
|
| 1002 | + [], |
|
| 1003 | + 'add-new-h2' |
|
| 1004 | + ); |
|
| 1005 | + |
|
| 1006 | + $this->_template_args['after_list_table'] = array_merge( |
|
| 1007 | + (array) $this->_template_args['after_list_table'], |
|
| 1008 | + $after_list_table |
|
| 1009 | + ); |
|
| 1010 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + |
|
| 1014 | + /** |
|
| 1015 | + * this allows for extra misc actions in the default WP publish box |
|
| 1016 | + * |
|
| 1017 | + * @return void |
|
| 1018 | + * @throws DomainException |
|
| 1019 | + * @throws EE_Error |
|
| 1020 | + * @throws InvalidArgumentException |
|
| 1021 | + * @throws InvalidDataTypeException |
|
| 1022 | + * @throws InvalidInterfaceException |
|
| 1023 | + * @throws ReflectionException |
|
| 1024 | + */ |
|
| 1025 | + public function extra_misc_actions_publish_box() |
|
| 1026 | + { |
|
| 1027 | + $this->_generate_publish_box_extra_content(); |
|
| 1028 | + } |
|
| 1029 | + |
|
| 1030 | + |
|
| 1031 | + /** |
|
| 1032 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
| 1033 | + * saved. |
|
| 1034 | + * Typically you would use this to save any additional data. |
|
| 1035 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
| 1036 | + * ALSO very important. When a post transitions from scheduled to published, |
|
| 1037 | + * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from |
|
| 1038 | + * other meta saves. So MAKE sure that you handle this accordingly. |
|
| 1039 | + * |
|
| 1040 | + * @access protected |
|
| 1041 | + * @abstract |
|
| 1042 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 1043 | + * @param object $post The post object of the cpt that was saved. |
|
| 1044 | + * @return void |
|
| 1045 | + * @throws EE_Error |
|
| 1046 | + * @throws InvalidArgumentException |
|
| 1047 | + * @throws InvalidDataTypeException |
|
| 1048 | + * @throws InvalidInterfaceException |
|
| 1049 | + * @throws ReflectionException |
|
| 1050 | + */ |
|
| 1051 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 1052 | + { |
|
| 1053 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
| 1054 | + // get out we're not processing an event save. |
|
| 1055 | + return; |
|
| 1056 | + } |
|
| 1057 | + $event_values = [ |
|
| 1058 | + 'EVT_member_only' => $this->request->getRequestParam('member_only', false, 'bool'), |
|
| 1059 | + 'EVT_allow_overflow' => $this->request->getRequestParam('EVT_allow_overflow', false, 'bool'), |
|
| 1060 | + 'EVT_timezone_string' => $this->request->getRequestParam('timezone_string'), |
|
| 1061 | + ]; |
|
| 1062 | + // check if the new EDTR reg options meta box is being used, and if so, don't run updates for legacy version |
|
| 1063 | + if (! $this->admin_config->useAdvancedEditor() || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1064 | + $event_values['EVT_display_ticket_selector'] = $this->request->getRequestParam( |
|
| 1065 | + 'display_ticket_selector', |
|
| 1066 | + false, |
|
| 1067 | + 'bool' |
|
| 1068 | + ); |
|
| 1069 | + $event_values['EVT_additional_limit'] = min( |
|
| 1070 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
| 1071 | + $this->request->getRequestParam('additional_limit', null, 'int') |
|
| 1072 | + ); |
|
| 1073 | + $event_values['EVT_default_registration_status'] = $this->request->getRequestParam( |
|
| 1074 | + 'EVT_default_registration_status', |
|
| 1075 | + EE_Registry::instance()->CFG->registration->default_STS_ID |
|
| 1076 | + ); |
|
| 1077 | + |
|
| 1078 | + $event_values['EVT_external_URL'] = $this->request->getRequestParam('externalURL'); |
|
| 1079 | + $event_values['EVT_phone'] = $this->request->getRequestParam('event_phone'); |
|
| 1080 | + $event_values['EVT_display_desc'] = $this->request->getRequestParam('display_desc', false, 'bool'); |
|
| 1081 | + } |
|
| 1082 | + // update event |
|
| 1083 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
| 1084 | + // get event_object for other metaboxes... |
|
| 1085 | + // though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. |
|
| 1086 | + // i have to setup where conditions to override the filters in the model |
|
| 1087 | + // that filter out autodraft and inherit statuses so we GET the inherit id! |
|
| 1088 | + $event = $this->_event_model()->get_one( |
|
| 1089 | + [ |
|
| 1090 | + [ |
|
| 1091 | + $this->_event_model()->primary_key_name() => $post_id, |
|
| 1092 | + 'OR' => [ |
|
| 1093 | + 'status' => $post->post_status, |
|
| 1094 | + // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db, |
|
| 1095 | + // but the returned object here has a status of "publish", so use the original post status as well |
|
| 1096 | + 'status*1' => $this->request->getRequestParam('original_post_status'), |
|
| 1097 | + ], |
|
| 1098 | + ], |
|
| 1099 | + ] |
|
| 1100 | + ); |
|
| 1101 | + |
|
| 1102 | + // the following are default callbacks for event attachment updates |
|
| 1103 | + // that can be overridden by caffeinated functionality and/or addons. |
|
| 1104 | + $event_update_callbacks = []; |
|
| 1105 | + if (! $this->admin_config->useAdvancedEditor()) { |
|
| 1106 | + $event_update_callbacks['_default_venue_update'] = [$this, '_default_venue_update']; |
|
| 1107 | + $event_update_callbacks['_default_tickets_update'] = [$this, '_default_tickets_update']; |
|
| 1108 | + } |
|
| 1109 | + $event_update_callbacks = apply_filters( |
|
| 1110 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 1111 | + $event_update_callbacks |
|
| 1112 | + ); |
|
| 1113 | + |
|
| 1114 | + $att_success = true; |
|
| 1115 | + foreach ($event_update_callbacks as $e_callback) { |
|
| 1116 | + $_success = is_callable($e_callback) |
|
| 1117 | + ? $e_callback($event, $this->request->requestParams()) |
|
| 1118 | + : false; |
|
| 1119 | + // if ANY of these updates fail then we want the appropriate global error message |
|
| 1120 | + $att_success = $_success !== false ? $att_success : false; |
|
| 1121 | + } |
|
| 1122 | + // any errors? |
|
| 1123 | + if ($success && $att_success === false) { |
|
| 1124 | + EE_Error::add_error( |
|
| 1125 | + esc_html__( |
|
| 1126 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
| 1127 | + 'event_espresso' |
|
| 1128 | + ), |
|
| 1129 | + __FILE__, |
|
| 1130 | + __FUNCTION__, |
|
| 1131 | + __LINE__ |
|
| 1132 | + ); |
|
| 1133 | + } elseif ($success === false) { |
|
| 1134 | + EE_Error::add_error( |
|
| 1135 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
| 1136 | + __FILE__, |
|
| 1137 | + __FUNCTION__, |
|
| 1138 | + __LINE__ |
|
| 1139 | + ); |
|
| 1140 | + } |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + |
|
| 1144 | + /** |
|
| 1145 | + * @param int $post_id |
|
| 1146 | + * @param int $revision_id |
|
| 1147 | + * @throws EE_Error |
|
| 1148 | + * @throws EE_Error |
|
| 1149 | + * @throws ReflectionException |
|
| 1150 | + * @see parent::restore_item() |
|
| 1151 | + */ |
|
| 1152 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 1153 | + { |
|
| 1154 | + // copy existing event meta to new post |
|
| 1155 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
| 1156 | + if ($post_evt instanceof EE_Event) { |
|
| 1157 | + // meta revision restore |
|
| 1158 | + $post_evt->restore_revision($revision_id); |
|
| 1159 | + // related objs restore |
|
| 1160 | + $post_evt->restore_revision($revision_id, ['Venue', 'Datetime', 'Price']); |
|
| 1161 | + } |
|
| 1162 | + } |
|
| 1163 | + |
|
| 1164 | + |
|
| 1165 | + /** |
|
| 1166 | + * Attach the venue to the Event |
|
| 1167 | + * |
|
| 1168 | + * @param EE_Event $event Event Object to add the venue to |
|
| 1169 | + * @param array $data The request data from the form |
|
| 1170 | + * @return bool Success or fail. |
|
| 1171 | + * @throws EE_Error |
|
| 1172 | + * @throws ReflectionException |
|
| 1173 | + */ |
|
| 1174 | + protected function _default_venue_update(EE_Event $event, $data) |
|
| 1175 | + { |
|
| 1176 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1177 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
| 1178 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
| 1179 | + // very important. If we don't have a venue name... |
|
| 1180 | + // then we'll get out because not necessary to create empty venue |
|
| 1181 | + if (empty($data['venue_title'])) { |
|
| 1182 | + return false; |
|
| 1183 | + } |
|
| 1184 | + $venue_array = [ |
|
| 1185 | + 'VNU_wp_user' => $event->get('EVT_wp_user'), |
|
| 1186 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
| 1187 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
| 1188 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
| 1189 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) |
|
| 1190 | + ? $data['venue_short_description'] |
|
| 1191 | + : null, |
|
| 1192 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
| 1193 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
| 1194 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
| 1195 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
| 1196 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
| 1197 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
| 1198 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
| 1199 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
| 1200 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
| 1201 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
| 1202 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
| 1203 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
| 1204 | + 'status' => 'publish', |
|
| 1205 | + ]; |
|
| 1206 | + // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
| 1207 | + if (! empty($venue_id)) { |
|
| 1208 | + $update_where = [$venue_model->primary_key_name() => $venue_id]; |
|
| 1209 | + $rows_affected = $venue_model->update($venue_array, [$update_where]); |
|
| 1210 | + // we've gotta make sure that the venue is always attached to a revision.. |
|
| 1211 | + // add_relation_to should take care of making sure that the relation is already present. |
|
| 1212 | + $event->_add_relation_to($venue_id, 'Venue'); |
|
| 1213 | + return $rows_affected > 0; |
|
| 1214 | + } |
|
| 1215 | + // we insert the venue |
|
| 1216 | + $venue_id = $venue_model->insert($venue_array); |
|
| 1217 | + $event->_add_relation_to($venue_id, 'Venue'); |
|
| 1218 | + return ! empty($venue_id); |
|
| 1219 | + // when we have the ancestor come in it's already been handled by the revision save. |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + |
|
| 1223 | + /** |
|
| 1224 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 1225 | + * |
|
| 1226 | + * @param EE_Event $event The Event object we're attaching data to |
|
| 1227 | + * @param array $data The request data from the form |
|
| 1228 | + * @return array |
|
| 1229 | + * @throws EE_Error |
|
| 1230 | + * @throws ReflectionException |
|
| 1231 | + * @throws Exception |
|
| 1232 | + */ |
|
| 1233 | + protected function _default_tickets_update(EE_Event $event, $data) |
|
| 1234 | + { |
|
| 1235 | + if ($this->admin_config->useAdvancedEditor()) { |
|
| 1236 | + return []; |
|
| 1237 | + } |
|
| 1238 | + $datetime = null; |
|
| 1239 | + $saved_tickets = []; |
|
| 1240 | + $event_timezone = $event->get_timezone(); |
|
| 1241 | + $date_formats = ['Y-m-d', 'h:i a']; |
|
| 1242 | + foreach ($data['edit_event_datetimes'] as $row => $datetime_data) { |
|
| 1243 | + // trim all values to ensure any excess whitespace is removed. |
|
| 1244 | + $datetime_data = array_map('trim', $datetime_data); |
|
| 1245 | + $datetime_data['DTT_EVT_end'] = |
|
| 1246 | + isset($datetime_data['DTT_EVT_end']) && ! empty($datetime_data['DTT_EVT_end']) |
|
| 1247 | + ? $datetime_data['DTT_EVT_end'] |
|
| 1248 | + : $datetime_data['DTT_EVT_start']; |
|
| 1249 | + $datetime_values = [ |
|
| 1250 | + 'DTT_ID' => ! empty($datetime_data['DTT_ID']) ? $datetime_data['DTT_ID'] : null, |
|
| 1251 | + 'DTT_EVT_start' => $datetime_data['DTT_EVT_start'], |
|
| 1252 | + 'DTT_EVT_end' => $datetime_data['DTT_EVT_end'], |
|
| 1253 | + 'DTT_reg_limit' => empty($datetime_data['DTT_reg_limit']) ? EE_INF : $datetime_data['DTT_reg_limit'], |
|
| 1254 | + 'DTT_order' => $row, |
|
| 1255 | + ]; |
|
| 1256 | + // if we have an id then let's get existing object first and then set the new values. |
|
| 1257 | + // Otherwise we instantiate a new object for save. |
|
| 1258 | + if (! empty($datetime_data['DTT_ID'])) { |
|
| 1259 | + $datetime = EEM_Datetime::instance($event_timezone)->get_one_by_ID($datetime_data['DTT_ID']); |
|
| 1260 | + if (! $datetime instanceof EE_Ticket) { |
|
| 1261 | + throw new RuntimeException( |
|
| 1262 | + sprintf( |
|
| 1263 | + esc_html__( |
|
| 1264 | + 'Something went wrong! A valid Datetime could not be retrieved from the database using the supplied ID: %1$d', |
|
| 1265 | + 'event_espresso' |
|
| 1266 | + ), |
|
| 1267 | + $datetime_data['DTT_ID'] |
|
| 1268 | + ) |
|
| 1269 | + ); |
|
| 1270 | + } |
|
| 1271 | + $datetime->set_date_format($date_formats[0]); |
|
| 1272 | + $datetime->set_time_format($date_formats[1]); |
|
| 1273 | + foreach ($datetime_values as $field => $value) { |
|
| 1274 | + $datetime->set($field, $value); |
|
| 1275 | + } |
|
| 1276 | + } else { |
|
| 1277 | + $datetime = EE_Datetime::new_instance($datetime_values, $event_timezone, $date_formats); |
|
| 1278 | + } |
|
| 1279 | + if (! $datetime instanceof EE_Datetime) { |
|
| 1280 | + throw new RuntimeException( |
|
| 1281 | + sprintf( |
|
| 1282 | + esc_html__( |
|
| 1283 | + 'Something went wrong! A valid Datetime could not be generated or retrieved using the supplied data: %1$s', |
|
| 1284 | + 'event_espresso' |
|
| 1285 | + ), |
|
| 1286 | + print_r($datetime_values, true) |
|
| 1287 | + ) |
|
| 1288 | + ); |
|
| 1289 | + } |
|
| 1290 | + // before going any further make sure our dates are setup correctly |
|
| 1291 | + // so that the end date is always equal or greater than the start date. |
|
| 1292 | + if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) { |
|
| 1293 | + $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start')); |
|
| 1294 | + $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days'); |
|
| 1295 | + } |
|
| 1296 | + $datetime->save(); |
|
| 1297 | + $event->_add_relation_to($datetime, 'Datetime'); |
|
| 1298 | + } |
|
| 1299 | + // no datetimes get deleted so we don't do any of that logic here. |
|
| 1300 | + // update tickets next |
|
| 1301 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : []; |
|
| 1302 | + |
|
| 1303 | + // set up some default start and end dates in case those are not present in the incoming data |
|
| 1304 | + $default_start_date = new DateTime('now', new DateTimeZone($event->get_timezone())); |
|
| 1305 | + $default_start_date = $default_start_date->format($date_formats[0] . ' ' . $date_formats[1]); |
|
| 1306 | + // use the start date of the first datetime for the end date |
|
| 1307 | + $first_datetime = $event->first_datetime(); |
|
| 1308 | + $default_end_date = $first_datetime->start_date_and_time($date_formats[0], $date_formats[1]); |
|
| 1309 | + |
|
| 1310 | + // now process the incoming data |
|
| 1311 | + foreach ($data['edit_tickets'] as $row => $ticket_data) { |
|
| 1312 | + $update_prices = false; |
|
| 1313 | + $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount']) |
|
| 1314 | + ? $data['edit_prices'][ $row ][1]['PRC_amount'] |
|
| 1315 | + : 0; |
|
| 1316 | + // trim inputs to ensure any excess whitespace is removed. |
|
| 1317 | + $ticket_data = array_map('trim', $ticket_data); |
|
| 1318 | + $ticket_values = [ |
|
| 1319 | + 'TKT_ID' => ! empty($ticket_data['TKT_ID']) ? $ticket_data['TKT_ID'] : null, |
|
| 1320 | + 'TTM_ID' => ! empty($ticket_data['TTM_ID']) ? $ticket_data['TTM_ID'] : 0, |
|
| 1321 | + 'TKT_name' => ! empty($ticket_data['TKT_name']) ? $ticket_data['TKT_name'] : '', |
|
| 1322 | + 'TKT_description' => ! empty($ticket_data['TKT_description']) ? $ticket_data['TKT_description'] : '', |
|
| 1323 | + 'TKT_start_date' => ! empty($ticket_data['TKT_start_date']) |
|
| 1324 | + ? $ticket_data['TKT_start_date'] |
|
| 1325 | + : $default_start_date, |
|
| 1326 | + 'TKT_end_date' => ! empty($ticket_data['TKT_end_date']) |
|
| 1327 | + ? $ticket_data['TKT_end_date'] |
|
| 1328 | + : $default_end_date, |
|
| 1329 | + 'TKT_qty' => ! empty($ticket_data['TKT_qty']) |
|
| 1330 | + || (isset($ticket_data['TKT_qty']) && (int) $ticket_data['TKT_qty'] === 0) |
|
| 1331 | + ? $ticket_data['TKT_qty'] |
|
| 1332 | + : EE_INF, |
|
| 1333 | + 'TKT_uses' => ! empty($ticket_data['TKT_uses']) |
|
| 1334 | + || (isset($ticket_data['TKT_uses']) && (int) $ticket_data['TKT_uses'] === 0) |
|
| 1335 | + ? $ticket_data['TKT_uses'] |
|
| 1336 | + : EE_INF, |
|
| 1337 | + 'TKT_min' => ! empty($ticket_data['TKT_min']) ? $ticket_data['TKT_min'] : 0, |
|
| 1338 | + 'TKT_max' => ! empty($ticket_data['TKT_max']) ? $ticket_data['TKT_max'] : EE_INF, |
|
| 1339 | + 'TKT_order' => isset($ticket_data['TKT_order']) ? $ticket_data['TKT_order'] : $row, |
|
| 1340 | + 'TKT_price' => $ticket_price, |
|
| 1341 | + 'TKT_row' => $row, |
|
| 1342 | + ]; |
|
| 1343 | + // if this is a default ticket, then we need to set the TKT_ID to 0 and update accordingly, |
|
| 1344 | + // which means in turn that the prices will become new prices as well. |
|
| 1345 | + if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) { |
|
| 1346 | + $ticket_values['TKT_ID'] = 0; |
|
| 1347 | + $ticket_values['TKT_is_default'] = 0; |
|
| 1348 | + $update_prices = true; |
|
| 1349 | + } |
|
| 1350 | + // if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 1351 | + // we actually do our saves ahead of adding any relations because its entirely possible that this |
|
| 1352 | + // ticket didn't get removed or added to any datetime in the session but DID have it's items modified. |
|
| 1353 | + // keep in mind that if the ticket has been sold (and we have changed pricing information), |
|
| 1354 | + // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
| 1355 | + if (! empty($ticket_data['TKT_ID'])) { |
|
| 1356 | + $existing_ticket = EEM_Ticket::instance($event_timezone)->get_one_by_ID($ticket_data['TKT_ID']); |
|
| 1357 | + if (! $existing_ticket instanceof EE_Ticket) { |
|
| 1358 | + throw new RuntimeException( |
|
| 1359 | + sprintf( |
|
| 1360 | + esc_html__( |
|
| 1361 | + 'Something went wrong! A valid Ticket could not be retrieved from the database using the supplied ID: %1$d', |
|
| 1362 | + 'event_espresso' |
|
| 1363 | + ), |
|
| 1364 | + $ticket_data['TKT_ID'] |
|
| 1365 | + ) |
|
| 1366 | + ); |
|
| 1367 | + } |
|
| 1368 | + $ticket_sold = $existing_ticket->count_related( |
|
| 1369 | + 'Registration', |
|
| 1370 | + [ |
|
| 1371 | + [ |
|
| 1372 | + 'STS_ID' => [ |
|
| 1373 | + 'NOT IN', |
|
| 1374 | + [EEM_Registration::status_id_incomplete], |
|
| 1375 | + ], |
|
| 1376 | + ], |
|
| 1377 | + ] |
|
| 1378 | + ) > 0; |
|
| 1379 | + // let's just check the total price for the existing ticket and determine if it matches the new total price. |
|
| 1380 | + // if they are different then we create a new ticket (if $ticket_sold) |
|
| 1381 | + // if they aren't different then we go ahead and modify existing ticket. |
|
| 1382 | + $create_new_ticket = $ticket_sold |
|
| 1383 | + && $ticket_price !== $existing_ticket->price() |
|
| 1384 | + && ! $existing_ticket->deleted(); |
|
| 1385 | + $existing_ticket->set_date_format($date_formats[0]); |
|
| 1386 | + $existing_ticket->set_time_format($date_formats[1]); |
|
| 1387 | + // set new values |
|
| 1388 | + foreach ($ticket_values as $field => $value) { |
|
| 1389 | + if ($field == 'TKT_qty') { |
|
| 1390 | + $existing_ticket->set_qty($value); |
|
| 1391 | + } elseif ($field == 'TKT_price') { |
|
| 1392 | + $existing_ticket->set('TKT_price', $ticket_price); |
|
| 1393 | + } else { |
|
| 1394 | + $existing_ticket->set($field, $value); |
|
| 1395 | + } |
|
| 1396 | + } |
|
| 1397 | + $ticket = $existing_ticket; |
|
| 1398 | + // if $create_new_ticket is false then we can safely update the existing ticket. |
|
| 1399 | + // Otherwise we have to create a new ticket. |
|
| 1400 | + if ($create_new_ticket) { |
|
| 1401 | + // archive the old ticket first |
|
| 1402 | + $existing_ticket->set('TKT_deleted', 1); |
|
| 1403 | + $existing_ticket->save(); |
|
| 1404 | + // make sure this ticket is still recorded in our $saved_tickets |
|
| 1405 | + // so we don't run it through the regular trash routine. |
|
| 1406 | + $saved_tickets[ $existing_ticket->ID() ] = $existing_ticket; |
|
| 1407 | + // create new ticket that's a copy of the existing except, |
|
| 1408 | + // (a new id of course and not archived) AND has the new TKT_price associated with it. |
|
| 1409 | + $new_ticket = clone $existing_ticket; |
|
| 1410 | + $new_ticket->set('TKT_ID', 0); |
|
| 1411 | + $new_ticket->set('TKT_deleted', 0); |
|
| 1412 | + $new_ticket->set('TKT_sold', 0); |
|
| 1413 | + // now we need to make sure that $new prices are created as well and attached to new ticket. |
|
| 1414 | + $update_prices = true; |
|
| 1415 | + $ticket = $new_ticket; |
|
| 1416 | + } |
|
| 1417 | + } else { |
|
| 1418 | + // no TKT_id so a new ticket |
|
| 1419 | + $ticket_values['TKT_price'] = $ticket_price; |
|
| 1420 | + $ticket = EE_Ticket::new_instance($ticket_values, $event_timezone, $date_formats); |
|
| 1421 | + $update_prices = true; |
|
| 1422 | + } |
|
| 1423 | + if (! $ticket instanceof EE_Ticket) { |
|
| 1424 | + throw new RuntimeException( |
|
| 1425 | + sprintf( |
|
| 1426 | + esc_html__( |
|
| 1427 | + 'Something went wrong! A valid Ticket could not be generated or retrieved using the supplied data: %1$s', |
|
| 1428 | + 'event_espresso' |
|
| 1429 | + ), |
|
| 1430 | + print_r($ticket_values, true) |
|
| 1431 | + ) |
|
| 1432 | + ); |
|
| 1433 | + } |
|
| 1434 | + // cap ticket qty by datetime reg limits |
|
| 1435 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
| 1436 | + // update ticket. |
|
| 1437 | + $ticket->save(); |
|
| 1438 | + // before going any further make sure our dates are setup correctly |
|
| 1439 | + // so that the end date is always equal or greater than the start date. |
|
| 1440 | + if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) { |
|
| 1441 | + $ticket->set('TKT_end_date', $ticket->get('TKT_start_date')); |
|
| 1442 | + $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days'); |
|
| 1443 | + $ticket->save(); |
|
| 1444 | + } |
|
| 1445 | + // initially let's add the ticket to the datetime |
|
| 1446 | + $datetime->_add_relation_to($ticket, 'Ticket'); |
|
| 1447 | + $saved_tickets[ $ticket->ID() ] = $ticket; |
|
| 1448 | + // add prices to ticket |
|
| 1449 | + $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $ticket, $update_prices); |
|
| 1450 | + } |
|
| 1451 | + // however now we need to handle permanently deleting tickets via the ui. |
|
| 1452 | + // Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. |
|
| 1453 | + // However, it does allow for deleting tickets that have no tickets sold, |
|
| 1454 | + // in which case we want to get rid of permanently because there is no need to save in db. |
|
| 1455 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? [] : $old_tickets; |
|
| 1456 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 1457 | + foreach ($tickets_removed as $id) { |
|
| 1458 | + $id = absint($id); |
|
| 1459 | + // get the ticket for this id |
|
| 1460 | + $ticket_to_remove = EEM_Ticket::instance()->get_one_by_ID($id); |
|
| 1461 | + if (! $ticket_to_remove instanceof EE_Ticket) { |
|
| 1462 | + continue; |
|
| 1463 | + } |
|
| 1464 | + // need to get all the related datetimes on this ticket and remove from every single one of them |
|
| 1465 | + // (remember this process can ONLY kick off if there are NO tickets sold) |
|
| 1466 | + $related_datetimes = $ticket_to_remove->get_many_related('Datetime'); |
|
| 1467 | + foreach ($related_datetimes as $related_datetime) { |
|
| 1468 | + $ticket_to_remove->_remove_relation_to($related_datetime, 'Datetime'); |
|
| 1469 | + } |
|
| 1470 | + // need to do the same for prices (except these prices can also be deleted because again, |
|
| 1471 | + // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 1472 | + $ticket_to_remove->delete_related_permanently('Price'); |
|
| 1473 | + // finally let's delete this ticket |
|
| 1474 | + // (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 1475 | + $ticket_to_remove->delete_permanently(); |
|
| 1476 | + } |
|
| 1477 | + return [$datetime, $saved_tickets]; |
|
| 1478 | + } |
|
| 1479 | + |
|
| 1480 | + |
|
| 1481 | + /** |
|
| 1482 | + * This attaches a list of given prices to a ticket. |
|
| 1483 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) |
|
| 1484 | + * because if there is a change in price information on a ticket, a new ticket is created anyways |
|
| 1485 | + * so the archived ticket will retain the old price info and prices are automatically "archived" via the ticket. |
|
| 1486 | + * |
|
| 1487 | + * @access private |
|
| 1488 | + * @param array $prices_data Array of prices from the form. |
|
| 1489 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 1490 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 1491 | + * @return void |
|
| 1492 | + * @throws EE_Error |
|
| 1493 | + * @throws ReflectionException |
|
| 1494 | + */ |
|
| 1495 | + private function _add_prices_to_ticket($prices_data, EE_Ticket $ticket, $new_prices = false) |
|
| 1496 | + { |
|
| 1497 | + $timezone = $ticket->get_timezone(); |
|
| 1498 | + foreach ($prices_data as $row => $price_data) { |
|
| 1499 | + $price_values = [ |
|
| 1500 | + 'PRC_ID' => ! empty($price_data['PRC_ID']) ? $price_data['PRC_ID'] : null, |
|
| 1501 | + 'PRT_ID' => ! empty($price_data['PRT_ID']) ? $price_data['PRT_ID'] : null, |
|
| 1502 | + 'PRC_amount' => ! empty($price_data['PRC_amount']) ? $price_data['PRC_amount'] : 0, |
|
| 1503 | + 'PRC_name' => ! empty($price_data['PRC_name']) ? $price_data['PRC_name'] : '', |
|
| 1504 | + 'PRC_desc' => ! empty($price_data['PRC_desc']) ? $price_data['PRC_desc'] : '', |
|
| 1505 | + 'PRC_is_default' => 0, // make sure prices are NOT set as default from this context |
|
| 1506 | + 'PRC_order' => $row, |
|
| 1507 | + ]; |
|
| 1508 | + if ($new_prices || empty($price_values['PRC_ID'])) { |
|
| 1509 | + $price_values['PRC_ID'] = 0; |
|
| 1510 | + $price = EE_Price::new_instance($price_values, $timezone); |
|
| 1511 | + } else { |
|
| 1512 | + $price = EEM_Price::instance($timezone)->get_one_by_ID($price_data['PRC_ID']); |
|
| 1513 | + // update this price with new values |
|
| 1514 | + foreach ($price_values as $field => $new_price) { |
|
| 1515 | + $price->set($field, $new_price); |
|
| 1516 | + } |
|
| 1517 | + } |
|
| 1518 | + if (! $price instanceof EE_Price) { |
|
| 1519 | + throw new RuntimeException( |
|
| 1520 | + sprintf( |
|
| 1521 | + esc_html__( |
|
| 1522 | + 'Something went wrong! A valid Price could not be generated or retrieved using the supplied data: %1$s', |
|
| 1523 | + 'event_espresso' |
|
| 1524 | + ), |
|
| 1525 | + print_r($price_values, true) |
|
| 1526 | + ) |
|
| 1527 | + ); |
|
| 1528 | + } |
|
| 1529 | + $price->save(); |
|
| 1530 | + $ticket->_add_relation_to($price, 'Price'); |
|
| 1531 | + } |
|
| 1532 | + } |
|
| 1533 | + |
|
| 1534 | + |
|
| 1535 | + /** |
|
| 1536 | + * Add in our autosave ajax handlers |
|
| 1537 | + * |
|
| 1538 | + */ |
|
| 1539 | + protected function _ee_autosave_create_new() |
|
| 1540 | + { |
|
| 1541 | + } |
|
| 1542 | + |
|
| 1543 | + |
|
| 1544 | + /** |
|
| 1545 | + * More autosave handlers. |
|
| 1546 | + */ |
|
| 1547 | + protected function _ee_autosave_edit() |
|
| 1548 | + { |
|
| 1549 | + } |
|
| 1550 | + |
|
| 1551 | + |
|
| 1552 | + /** |
|
| 1553 | + * @throws EE_Error |
|
| 1554 | + * @throws ReflectionException |
|
| 1555 | + */ |
|
| 1556 | + private function _generate_publish_box_extra_content() |
|
| 1557 | + { |
|
| 1558 | + // load formatter helper |
|
| 1559 | + // args for getting related registrations |
|
| 1560 | + $approved_query_args = [ |
|
| 1561 | + [ |
|
| 1562 | + 'REG_deleted' => 0, |
|
| 1563 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1564 | + ], |
|
| 1565 | + ]; |
|
| 1566 | + $not_approved_query_args = [ |
|
| 1567 | + [ |
|
| 1568 | + 'REG_deleted' => 0, |
|
| 1569 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
| 1570 | + ], |
|
| 1571 | + ]; |
|
| 1572 | + $pending_payment_query_args = [ |
|
| 1573 | + [ |
|
| 1574 | + 'REG_deleted' => 0, |
|
| 1575 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
| 1576 | + ], |
|
| 1577 | + ]; |
|
| 1578 | + // publish box |
|
| 1579 | + $publish_box_extra_args = [ |
|
| 1580 | + 'view_approved_reg_url' => add_query_arg( |
|
| 1581 | + [ |
|
| 1582 | + 'action' => 'default', |
|
| 1583 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1584 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
| 1585 | + ], |
|
| 1586 | + REG_ADMIN_URL |
|
| 1587 | + ), |
|
| 1588 | + 'view_not_approved_reg_url' => add_query_arg( |
|
| 1589 | + [ |
|
| 1590 | + 'action' => 'default', |
|
| 1591 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1592 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
| 1593 | + ], |
|
| 1594 | + REG_ADMIN_URL |
|
| 1595 | + ), |
|
| 1596 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
| 1597 | + [ |
|
| 1598 | + 'action' => 'default', |
|
| 1599 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1600 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
| 1601 | + ], |
|
| 1602 | + REG_ADMIN_URL |
|
| 1603 | + ), |
|
| 1604 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1605 | + 'Registration', |
|
| 1606 | + $approved_query_args |
|
| 1607 | + ), |
|
| 1608 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1609 | + 'Registration', |
|
| 1610 | + $not_approved_query_args |
|
| 1611 | + ), |
|
| 1612 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
| 1613 | + 'Registration', |
|
| 1614 | + $pending_payment_query_args |
|
| 1615 | + ), |
|
| 1616 | + 'misc_pub_section_class' => apply_filters( |
|
| 1617 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
| 1618 | + 'misc-pub-section' |
|
| 1619 | + ), |
|
| 1620 | + ]; |
|
| 1621 | + ob_start(); |
|
| 1622 | + do_action( |
|
| 1623 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
| 1624 | + $this->_cpt_model_obj |
|
| 1625 | + ); |
|
| 1626 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
| 1627 | + // load template |
|
| 1628 | + EEH_Template::display_template( |
|
| 1629 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1630 | + $publish_box_extra_args |
|
| 1631 | + ); |
|
| 1632 | + } |
|
| 1633 | + |
|
| 1634 | + |
|
| 1635 | + /** |
|
| 1636 | + * @return EE_Event |
|
| 1637 | + */ |
|
| 1638 | + public function get_event_object() |
|
| 1639 | + { |
|
| 1640 | + return $this->_cpt_model_obj; |
|
| 1641 | + } |
|
| 1642 | + |
|
| 1643 | + |
|
| 1644 | + |
|
| 1645 | + |
|
| 1646 | + /** METABOXES * */ |
|
| 1647 | + /** |
|
| 1648 | + * _register_event_editor_meta_boxes |
|
| 1649 | + * add all metaboxes related to the event_editor |
|
| 1650 | + * |
|
| 1651 | + * @return void |
|
| 1652 | + * @throws EE_Error |
|
| 1653 | + * @throws ReflectionException |
|
| 1654 | + */ |
|
| 1655 | + protected function _register_event_editor_meta_boxes() |
|
| 1656 | + { |
|
| 1657 | + $this->verify_cpt_object(); |
|
| 1658 | + $use_advanced_editor = $this->admin_config->useAdvancedEditor(); |
|
| 1659 | + // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
| 1660 | + if (! $use_advanced_editor || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1661 | + $this->addMetaBox( |
|
| 1662 | + 'espresso_event_editor_event_options', |
|
| 1663 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
| 1664 | + [$this, 'registration_options_meta_box'], |
|
| 1665 | + $this->page_slug, |
|
| 1666 | + 'side' |
|
| 1667 | + ); |
|
| 1668 | + } |
|
| 1669 | + if (! $use_advanced_editor) { |
|
| 1670 | + $this->addMetaBox( |
|
| 1671 | + 'espresso_event_editor_tickets', |
|
| 1672 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
| 1673 | + [$this, 'ticket_metabox'], |
|
| 1674 | + $this->page_slug, |
|
| 1675 | + 'normal', |
|
| 1676 | + 'high' |
|
| 1677 | + ); |
|
| 1678 | + } elseif ($this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1679 | + add_action( |
|
| 1680 | + 'add_meta_boxes_espresso_events', |
|
| 1681 | + function () { |
|
| 1682 | + global $current_screen; |
|
| 1683 | + remove_meta_box('authordiv', $current_screen, 'normal'); |
|
| 1684 | + }, |
|
| 1685 | + 99 |
|
| 1686 | + ); |
|
| 1687 | + } |
|
| 1688 | + // NOTE: if you're looking for other metaboxes in here, |
|
| 1689 | + // where a metabox has a related management page in the admin |
|
| 1690 | + // you will find it setup in the related management page's "_Hooks" file. |
|
| 1691 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + |
|
| 1695 | + /** |
|
| 1696 | + * @throws DomainException |
|
| 1697 | + * @throws EE_Error |
|
| 1698 | + * @throws ReflectionException |
|
| 1699 | + */ |
|
| 1700 | + public function ticket_metabox() |
|
| 1701 | + { |
|
| 1702 | + $existing_datetime_ids = $existing_ticket_ids = []; |
|
| 1703 | + // defaults for template args |
|
| 1704 | + $template_args = [ |
|
| 1705 | + 'existing_datetime_ids' => '', |
|
| 1706 | + 'event_datetime_help_link' => '', |
|
| 1707 | + 'ticket_options_help_link' => '', |
|
| 1708 | + 'time' => null, |
|
| 1709 | + 'ticket_rows' => '', |
|
| 1710 | + 'existing_ticket_ids' => '', |
|
| 1711 | + 'total_ticket_rows' => 1, |
|
| 1712 | + 'ticket_js_structure' => '', |
|
| 1713 | + 'trash_icon' => 'dashicons dashicons-lock', |
|
| 1714 | + 'disabled' => '', |
|
| 1715 | + ]; |
|
| 1716 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1717 | + /** |
|
| 1718 | + * 1. Start with retrieving Datetimes |
|
| 1719 | + * 2. Fore each datetime get related tickets |
|
| 1720 | + * 3. For each ticket get related prices |
|
| 1721 | + */ |
|
| 1722 | + /** @var EEM_Datetime $datetime_model */ |
|
| 1723 | + $datetime_model = EE_Registry::instance()->load_model('Datetime'); |
|
| 1724 | + /** @var EEM_Ticket $datetime_model */ |
|
| 1725 | + $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
| 1726 | + $times = $datetime_model->get_all_event_dates($event_id); |
|
| 1727 | + /** @type EE_Datetime $first_datetime */ |
|
| 1728 | + $first_datetime = reset($times); |
|
| 1729 | + // do we get related tickets? |
|
| 1730 | + if ( |
|
| 1731 | + $first_datetime instanceof EE_Datetime |
|
| 1732 | + && $first_datetime->ID() !== 0 |
|
| 1733 | + ) { |
|
| 1734 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
| 1735 | + $template_args['time'] = $first_datetime; |
|
| 1736 | + $related_tickets = $first_datetime->tickets( |
|
| 1737 | + [ |
|
| 1738 | + ['OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0]], |
|
| 1739 | + 'default_where_conditions' => 'none', |
|
| 1740 | + ] |
|
| 1741 | + ); |
|
| 1742 | + if (! empty($related_tickets)) { |
|
| 1743 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
| 1744 | + $row = 0; |
|
| 1745 | + foreach ($related_tickets as $ticket) { |
|
| 1746 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1747 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
| 1748 | + $row++; |
|
| 1749 | + } |
|
| 1750 | + } else { |
|
| 1751 | + $template_args['total_ticket_rows'] = 1; |
|
| 1752 | + /** @type EE_Ticket $ticket */ |
|
| 1753 | + $ticket = $ticket_model->create_default_object(); |
|
| 1754 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
| 1755 | + } |
|
| 1756 | + } else { |
|
| 1757 | + $template_args['time'] = $times[0]; |
|
| 1758 | + /** @type EE_Ticket[] $tickets */ |
|
| 1759 | + $tickets = $ticket_model->get_all_default_tickets(); |
|
| 1760 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($tickets[1]); |
|
| 1761 | + // NOTE: we're just sending the first default row |
|
| 1762 | + // (decaf can't manage default tickets so this should be sufficient); |
|
| 1763 | + } |
|
| 1764 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
| 1765 | + 'event_editor_event_datetimes_help_tab' |
|
| 1766 | + ); |
|
| 1767 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
| 1768 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1769 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1770 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
| 1771 | + $ticket_model->create_default_object(), |
|
| 1772 | + true |
|
| 1773 | + ); |
|
| 1774 | + $template = apply_filters( |
|
| 1775 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
| 1776 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1777 | + ); |
|
| 1778 | + EEH_Template::display_template($template, $template_args); |
|
| 1779 | + } |
|
| 1780 | + |
|
| 1781 | + |
|
| 1782 | + /** |
|
| 1783 | + * Setup an individual ticket form for the decaf event editor page |
|
| 1784 | + * |
|
| 1785 | + * @access private |
|
| 1786 | + * @param EE_Ticket $ticket the ticket object |
|
| 1787 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
| 1788 | + * @param int $row |
|
| 1789 | + * @return string generated html for the ticket row. |
|
| 1790 | + * @throws EE_Error |
|
| 1791 | + * @throws ReflectionException |
|
| 1792 | + */ |
|
| 1793 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
| 1794 | + { |
|
| 1795 | + $template_args = [ |
|
| 1796 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1797 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
| 1798 | + : '', |
|
| 1799 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
| 1800 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
| 1801 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
| 1802 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
| 1803 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
| 1804 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
| 1805 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1806 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
| 1807 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
| 1808 | + 'trash_icon' => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1809 | + && (! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1810 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'dashicons dashicons-lock', |
|
| 1811 | + 'disabled' => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1812 | + : ' disabled=disabled', |
|
| 1813 | + ]; |
|
| 1814 | + $price = $ticket->ID() !== 0 |
|
| 1815 | + ? $ticket->get_first_related('Price', ['default_where_conditions' => 'none']) |
|
| 1816 | + : null; |
|
| 1817 | + $price = $price instanceof EE_Price |
|
| 1818 | + ? $price |
|
| 1819 | + : EEM_Price::instance()->create_default_object(); |
|
| 1820 | + $price_args = [ |
|
| 1821 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1822 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
| 1823 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
| 1824 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
| 1825 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
| 1826 | + ]; |
|
| 1827 | + // make sure we have default start and end dates if skeleton |
|
| 1828 | + // handle rows that should NOT be empty |
|
| 1829 | + if (empty($template_args['TKT_start_date'])) { |
|
| 1830 | + // if empty then the start date will be now. |
|
| 1831 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
| 1832 | + } |
|
| 1833 | + if (empty($template_args['TKT_end_date'])) { |
|
| 1834 | + // get the earliest datetime (if present); |
|
| 1835 | + $earliest_datetime = $this->_cpt_model_obj->ID() > 0 |
|
| 1836 | + ? $this->_cpt_model_obj->get_first_related( |
|
| 1837 | + 'Datetime', |
|
| 1838 | + ['order_by' => ['DTT_EVT_start' => 'ASC']] |
|
| 1839 | + ) |
|
| 1840 | + : null; |
|
| 1841 | + $template_args['TKT_end_date'] = $earliest_datetime instanceof EE_Datetime |
|
| 1842 | + ? $earliest_datetime->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a') |
|
| 1843 | + : date('Y-m-d h:i a', mktime(0, 0, 0, date('m'), date('d') + 7, date('Y'))); |
|
| 1844 | + } |
|
| 1845 | + $template_args = array_merge($template_args, $price_args); |
|
| 1846 | + $template = apply_filters( |
|
| 1847 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
| 1848 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1849 | + $ticket |
|
| 1850 | + ); |
|
| 1851 | + return EEH_Template::display_template($template, $template_args, true); |
|
| 1852 | + } |
|
| 1853 | + |
|
| 1854 | + |
|
| 1855 | + /** |
|
| 1856 | + * @throws EE_Error |
|
| 1857 | + * @throws ReflectionException |
|
| 1858 | + */ |
|
| 1859 | + public function registration_options_meta_box() |
|
| 1860 | + { |
|
| 1861 | + $yes_no_values = [ |
|
| 1862 | + ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
| 1863 | + ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
| 1864 | + ]; |
|
| 1865 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 1866 | + [ |
|
| 1867 | + EEM_Registration::status_id_cancelled, |
|
| 1868 | + EEM_Registration::status_id_declined, |
|
| 1869 | + EEM_Registration::status_id_incomplete, |
|
| 1870 | + ], |
|
| 1871 | + true |
|
| 1872 | + ); |
|
| 1873 | + // $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
| 1874 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
| 1875 | + $template_args['event'] = $this->_cpt_model_obj; |
|
| 1876 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 1877 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 1878 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 1879 | + 'default_reg_status', |
|
| 1880 | + $default_reg_status_values, |
|
| 1881 | + $this->_cpt_model_obj->default_registration_status() |
|
| 1882 | + ); |
|
| 1883 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1884 | + 'display_desc', |
|
| 1885 | + $yes_no_values, |
|
| 1886 | + $this->_cpt_model_obj->display_description() |
|
| 1887 | + ); |
|
| 1888 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1889 | + 'display_ticket_selector', |
|
| 1890 | + $yes_no_values, |
|
| 1891 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
| 1892 | + '', |
|
| 1893 | + '', |
|
| 1894 | + false |
|
| 1895 | + ); |
|
| 1896 | + $template_args['additional_registration_options'] = apply_filters( |
|
| 1897 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 1898 | + '', |
|
| 1899 | + $template_args, |
|
| 1900 | + $yes_no_values, |
|
| 1901 | + $default_reg_status_values |
|
| 1902 | + ); |
|
| 1903 | + EEH_Template::display_template( |
|
| 1904 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1905 | + $template_args |
|
| 1906 | + ); |
|
| 1907 | + } |
|
| 1908 | + |
|
| 1909 | + |
|
| 1910 | + /** |
|
| 1911 | + * _get_events() |
|
| 1912 | + * This method simply returns all the events (for the given _view and paging) |
|
| 1913 | + * |
|
| 1914 | + * @access public |
|
| 1915 | + * @param int $per_page count of items per page (20 default); |
|
| 1916 | + * @param int $current_page what is the current page being viewed. |
|
| 1917 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
| 1918 | + * If FALSE then we return an array of event objects |
|
| 1919 | + * that match the given _view and paging parameters. |
|
| 1920 | + * @return array|int an array of event objects or a count of them. |
|
| 1921 | + * @throws Exception |
|
| 1922 | + */ |
|
| 1923 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
| 1924 | + { |
|
| 1925 | + $EEM_Event = $this->_event_model(); |
|
| 1926 | + $offset = ($current_page - 1) * $per_page; |
|
| 1927 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1928 | + $orderby = $this->request->getRequestParam('orderby', 'EVT_ID'); |
|
| 1929 | + $order = $this->request->getRequestParam('order', 'DESC'); |
|
| 1930 | + $month_range = $this->request->getRequestParam('month_range'); |
|
| 1931 | + if ($month_range) { |
|
| 1932 | + $pieces = explode(' ', $month_range, 3); |
|
| 1933 | + // simulate the FIRST day of the month, that fixes issues for months like February |
|
| 1934 | + // where PHP doesn't know what to assume for date. |
|
| 1935 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
| 1936 | + $month_r = ! empty($pieces[0]) ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
| 1937 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1938 | + } |
|
| 1939 | + $where = []; |
|
| 1940 | + $status = $this->request->getRequestParam('status'); |
|
| 1941 | + // determine what post_status our condition will have for the query. |
|
| 1942 | + switch ($status) { |
|
| 1943 | + case 'month': |
|
| 1944 | + case 'today': |
|
| 1945 | + case null: |
|
| 1946 | + case 'all': |
|
| 1947 | + break; |
|
| 1948 | + case 'draft': |
|
| 1949 | + $where['status'] = ['IN', ['draft', 'auto-draft']]; |
|
| 1950 | + break; |
|
| 1951 | + default: |
|
| 1952 | + $where['status'] = $status; |
|
| 1953 | + } |
|
| 1954 | + // categories? The default for all categories is -1 |
|
| 1955 | + $category = $this->request->getRequestParam('EVT_CAT', -1, 'int'); |
|
| 1956 | + if ($category !== -1) { |
|
| 1957 | + $where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY; |
|
| 1958 | + $where['Term_Taxonomy.term_id'] = $category; |
|
| 1959 | + } |
|
| 1960 | + // date where conditions |
|
| 1961 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
| 1962 | + if ($month_range) { |
|
| 1963 | + $DateTime = new DateTime( |
|
| 1964 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1965 | + new DateTimeZone('UTC') |
|
| 1966 | + ); |
|
| 1967 | + $start = $DateTime->getTimestamp(); |
|
| 1968 | + // set the datetime to be the end of the month |
|
| 1969 | + $DateTime->setDate( |
|
| 1970 | + $year_r, |
|
| 1971 | + $month_r, |
|
| 1972 | + $DateTime->format('t') |
|
| 1973 | + )->setTime(23, 59, 59); |
|
| 1974 | + $end = $DateTime->getTimestamp(); |
|
| 1975 | + $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]]; |
|
| 1976 | + } elseif ($status === 'today') { |
|
| 1977 | + $DateTime = |
|
| 1978 | + new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1979 | + $start = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats)); |
|
| 1980 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
| 1981 | + $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]]; |
|
| 1982 | + } elseif ($status === 'month') { |
|
| 1983 | + $now = date('Y-m-01'); |
|
| 1984 | + $DateTime = |
|
| 1985 | + new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1986 | + $start = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats)); |
|
| 1987 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
| 1988 | + ->setTime(23, 59, 59) |
|
| 1989 | + ->format(implode(' ', $start_formats)); |
|
| 1990 | + $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]]; |
|
| 1991 | + } |
|
| 1992 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1993 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
| 1994 | + } else { |
|
| 1995 | + if (! isset($where['status'])) { |
|
| 1996 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1997 | + $where['OR'] = [ |
|
| 1998 | + 'status*restrict_private' => ['!=', 'private'], |
|
| 1999 | + 'AND' => [ |
|
| 2000 | + 'status*inclusive' => ['=', 'private'], |
|
| 2001 | + 'EVT_wp_user' => get_current_user_id(), |
|
| 2002 | + ], |
|
| 2003 | + ]; |
|
| 2004 | + } |
|
| 2005 | + } |
|
| 2006 | + } |
|
| 2007 | + $wp_user = $this->request->getRequestParam('EVT_wp_user', 0, 'int'); |
|
| 2008 | + if ( |
|
| 2009 | + $wp_user |
|
| 2010 | + && $wp_user !== get_current_user_id() |
|
| 2011 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
| 2012 | + ) { |
|
| 2013 | + $where['EVT_wp_user'] = $wp_user; |
|
| 2014 | + } |
|
| 2015 | + // search query handling |
|
| 2016 | + $search_term = $this->request->getRequestParam('s'); |
|
| 2017 | + if ($search_term) { |
|
| 2018 | + $search_term = '%' . $search_term . '%'; |
|
| 2019 | + $where['OR'] = [ |
|
| 2020 | + 'EVT_name' => ['LIKE', $search_term], |
|
| 2021 | + 'EVT_desc' => ['LIKE', $search_term], |
|
| 2022 | + 'EVT_short_desc' => ['LIKE', $search_term], |
|
| 2023 | + ]; |
|
| 2024 | + } |
|
| 2025 | + // filter events by venue. |
|
| 2026 | + $venue = $this->request->getRequestParam('venue', 0, 'int'); |
|
| 2027 | + if ($venue) { |
|
| 2028 | + $where['Venue.VNU_ID'] = $venue; |
|
| 2029 | + } |
|
| 2030 | + $request_params = $this->request->requestParams(); |
|
| 2031 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $request_params); |
|
| 2032 | + $query_params = apply_filters( |
|
| 2033 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
| 2034 | + [ |
|
| 2035 | + $where, |
|
| 2036 | + 'limit' => $limit, |
|
| 2037 | + 'order_by' => $orderby, |
|
| 2038 | + 'order' => $order, |
|
| 2039 | + 'group_by' => 'EVT_ID', |
|
| 2040 | + ], |
|
| 2041 | + $request_params |
|
| 2042 | + ); |
|
| 2043 | + |
|
| 2044 | + // let's first check if we have special requests coming in. |
|
| 2045 | + $active_status = $this->request->getRequestParam('active_status'); |
|
| 2046 | + if ($active_status) { |
|
| 2047 | + switch ($active_status) { |
|
| 2048 | + case 'upcoming': |
|
| 2049 | + return $EEM_Event->get_upcoming_events($query_params, $count); |
|
| 2050 | + case 'expired': |
|
| 2051 | + return $EEM_Event->get_expired_events($query_params, $count); |
|
| 2052 | + case 'active': |
|
| 2053 | + return $EEM_Event->get_active_events($query_params, $count); |
|
| 2054 | + case 'inactive': |
|
| 2055 | + return $EEM_Event->get_inactive_events($query_params, $count); |
|
| 2056 | + } |
|
| 2057 | + } |
|
| 2058 | + |
|
| 2059 | + return $count ? $EEM_Event->count([$where], 'EVT_ID', true) : $EEM_Event->get_all($query_params); |
|
| 2060 | + } |
|
| 2061 | + |
|
| 2062 | + |
|
| 2063 | + /** |
|
| 2064 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
| 2065 | + * |
|
| 2066 | + * @param string $post_id |
|
| 2067 | + * @throws EE_Error |
|
| 2068 | + * @throws ReflectionException |
|
| 2069 | + */ |
|
| 2070 | + public function trash_cpt_item($post_id) |
|
| 2071 | + { |
|
| 2072 | + $this->request->setRequestParam('EVT_ID', $post_id); |
|
| 2073 | + $this->_trash_or_restore_event('trash', false); |
|
| 2074 | + } |
|
| 2075 | + |
|
| 2076 | + |
|
| 2077 | + /** |
|
| 2078 | + * @param string $post_id |
|
| 2079 | + * @throws EE_Error |
|
| 2080 | + * @throws ReflectionException |
|
| 2081 | + */ |
|
| 2082 | + public function restore_cpt_item($post_id) |
|
| 2083 | + { |
|
| 2084 | + $this->request->setRequestParam('EVT_ID', $post_id); |
|
| 2085 | + $this->_trash_or_restore_event('draft', false); |
|
| 2086 | + } |
|
| 2087 | + |
|
| 2088 | + |
|
| 2089 | + /** |
|
| 2090 | + * @param string $post_id |
|
| 2091 | + * @throws EE_Error |
|
| 2092 | + * @throws EE_Error |
|
| 2093 | + */ |
|
| 2094 | + public function delete_cpt_item($post_id) |
|
| 2095 | + { |
|
| 2096 | + throw new EE_Error( |
|
| 2097 | + esc_html__( |
|
| 2098 | + 'Please contact Event Espresso support with the details of the steps taken to produce this error.', |
|
| 2099 | + 'event_espresso' |
|
| 2100 | + ) |
|
| 2101 | + ); |
|
| 2102 | + // $this->request->setRequestParam('EVT_ID', $post_id); |
|
| 2103 | + // $this->_delete_event(); |
|
| 2104 | + } |
|
| 2105 | + |
|
| 2106 | + |
|
| 2107 | + /** |
|
| 2108 | + * _trash_or_restore_event |
|
| 2109 | + * |
|
| 2110 | + * @access protected |
|
| 2111 | + * @param string $event_status |
|
| 2112 | + * @param bool $redirect_after |
|
| 2113 | + * @throws EE_Error |
|
| 2114 | + * @throws EE_Error |
|
| 2115 | + * @throws ReflectionException |
|
| 2116 | + */ |
|
| 2117 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
| 2118 | + { |
|
| 2119 | + // determine the event id and set to array. |
|
| 2120 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 2121 | + // loop thru events |
|
| 2122 | + if ($EVT_ID) { |
|
| 2123 | + // clean status |
|
| 2124 | + $event_status = sanitize_key($event_status); |
|
| 2125 | + // grab status |
|
| 2126 | + if (! empty($event_status)) { |
|
| 2127 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
| 2128 | + } else { |
|
| 2129 | + $success = false; |
|
| 2130 | + $msg = esc_html__( |
|
| 2131 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 2132 | + 'event_espresso' |
|
| 2133 | + ); |
|
| 2134 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2135 | + } |
|
| 2136 | + } else { |
|
| 2137 | + $success = false; |
|
| 2138 | + $msg = esc_html__( |
|
| 2139 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 2140 | + 'event_espresso' |
|
| 2141 | + ); |
|
| 2142 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2143 | + } |
|
| 2144 | + $action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 2145 | + if ($redirect_after) { |
|
| 2146 | + $this->_redirect_after_action($success, 'Event', $action, ['action' => 'default']); |
|
| 2147 | + } |
|
| 2148 | + } |
|
| 2149 | + |
|
| 2150 | + |
|
| 2151 | + /** |
|
| 2152 | + * _trash_or_restore_events |
|
| 2153 | + * |
|
| 2154 | + * @access protected |
|
| 2155 | + * @param string $event_status |
|
| 2156 | + * @return void |
|
| 2157 | + * @throws EE_Error |
|
| 2158 | + * @throws EE_Error |
|
| 2159 | + * @throws ReflectionException |
|
| 2160 | + */ |
|
| 2161 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
| 2162 | + { |
|
| 2163 | + // clean status |
|
| 2164 | + $event_status = sanitize_key($event_status); |
|
| 2165 | + // grab status |
|
| 2166 | + if (! empty($event_status)) { |
|
| 2167 | + $success = true; |
|
| 2168 | + // determine the event id and set to array. |
|
| 2169 | + $EVT_IDs = $this->request->getRequestParam('EVT_IDs', [], 'int', true); |
|
| 2170 | + // loop thru events |
|
| 2171 | + foreach ($EVT_IDs as $EVT_ID) { |
|
| 2172 | + if ($EVT_ID = absint($EVT_ID)) { |
|
| 2173 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
| 2174 | + $success = $results !== false ? $success : false; |
|
| 2175 | + } else { |
|
| 2176 | + $msg = sprintf( |
|
| 2177 | + esc_html__( |
|
| 2178 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 2179 | + 'event_espresso' |
|
| 2180 | + ), |
|
| 2181 | + $EVT_ID |
|
| 2182 | + ); |
|
| 2183 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2184 | + $success = false; |
|
| 2185 | + } |
|
| 2186 | + } |
|
| 2187 | + } else { |
|
| 2188 | + $success = false; |
|
| 2189 | + $msg = esc_html__( |
|
| 2190 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 2191 | + 'event_espresso' |
|
| 2192 | + ); |
|
| 2193 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2194 | + } |
|
| 2195 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2196 | + $success = $success ? 2 : false; |
|
| 2197 | + $action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 2198 | + $this->_redirect_after_action($success, 'Events', $action, ['action' => 'default']); |
|
| 2199 | + } |
|
| 2200 | + |
|
| 2201 | + |
|
| 2202 | + /** |
|
| 2203 | + * @param int $EVT_ID |
|
| 2204 | + * @param string $event_status |
|
| 2205 | + * @return bool |
|
| 2206 | + * @throws EE_Error |
|
| 2207 | + * @throws ReflectionException |
|
| 2208 | + */ |
|
| 2209 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
| 2210 | + { |
|
| 2211 | + // grab event id |
|
| 2212 | + if (! $EVT_ID) { |
|
| 2213 | + $msg = esc_html__( |
|
| 2214 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2215 | + 'event_espresso' |
|
| 2216 | + ); |
|
| 2217 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2218 | + return false; |
|
| 2219 | + } |
|
| 2220 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2221 | + // clean status |
|
| 2222 | + $event_status = sanitize_key($event_status); |
|
| 2223 | + // grab status |
|
| 2224 | + if (empty($event_status)) { |
|
| 2225 | + $msg = esc_html__( |
|
| 2226 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
| 2227 | + 'event_espresso' |
|
| 2228 | + ); |
|
| 2229 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2230 | + return false; |
|
| 2231 | + } |
|
| 2232 | + // was event trashed or restored ? |
|
| 2233 | + switch ($event_status) { |
|
| 2234 | + case 'draft': |
|
| 2235 | + $action = 'restored from the trash'; |
|
| 2236 | + $hook = 'AHEE_event_restored_from_trash'; |
|
| 2237 | + break; |
|
| 2238 | + case 'trash': |
|
| 2239 | + $action = 'moved to the trash'; |
|
| 2240 | + $hook = 'AHEE_event_moved_to_trash'; |
|
| 2241 | + break; |
|
| 2242 | + default: |
|
| 2243 | + $action = 'updated'; |
|
| 2244 | + $hook = false; |
|
| 2245 | + } |
|
| 2246 | + // use class to change status |
|
| 2247 | + $this->_cpt_model_obj->set_status($event_status); |
|
| 2248 | + $success = $this->_cpt_model_obj->save(); |
|
| 2249 | + if (! $success) { |
|
| 2250 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 2251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2252 | + return false; |
|
| 2253 | + } |
|
| 2254 | + if ($hook) { |
|
| 2255 | + do_action($hook); |
|
| 2256 | + } |
|
| 2257 | + return true; |
|
| 2258 | + } |
|
| 2259 | + |
|
| 2260 | + |
|
| 2261 | + /** |
|
| 2262 | + * @param array $event_ids |
|
| 2263 | + * @return array |
|
| 2264 | + * @since 4.10.23.p |
|
| 2265 | + */ |
|
| 2266 | + private function cleanEventIds(array $event_ids) |
|
| 2267 | + { |
|
| 2268 | + return array_map('absint', $event_ids); |
|
| 2269 | + } |
|
| 2270 | + |
|
| 2271 | + |
|
| 2272 | + /** |
|
| 2273 | + * @return array |
|
| 2274 | + * @since 4.10.23.p |
|
| 2275 | + */ |
|
| 2276 | + private function getEventIdsFromRequest() |
|
| 2277 | + { |
|
| 2278 | + if ($this->request->requestParamIsSet('EVT_IDs')) { |
|
| 2279 | + return $this->request->getRequestParam('EVT_IDs', [], 'int', true); |
|
| 2280 | + } else { |
|
| 2281 | + return $this->request->getRequestParam('EVT_ID', [], 'int', true); |
|
| 2282 | + } |
|
| 2283 | + } |
|
| 2284 | + |
|
| 2285 | + |
|
| 2286 | + /** |
|
| 2287 | + * @param bool $preview_delete |
|
| 2288 | + * @throws EE_Error |
|
| 2289 | + */ |
|
| 2290 | + protected function _delete_event($preview_delete = true) |
|
| 2291 | + { |
|
| 2292 | + $this->_delete_events($preview_delete); |
|
| 2293 | + } |
|
| 2294 | + |
|
| 2295 | + |
|
| 2296 | + /** |
|
| 2297 | + * Gets the tree traversal batch persister. |
|
| 2298 | + * |
|
| 2299 | + * @return NodeGroupDao |
|
| 2300 | + * @throws InvalidArgumentException |
|
| 2301 | + * @throws InvalidDataTypeException |
|
| 2302 | + * @throws InvalidInterfaceException |
|
| 2303 | + * @since 4.10.12.p |
|
| 2304 | + */ |
|
| 2305 | + protected function getModelObjNodeGroupPersister() |
|
| 2306 | + { |
|
| 2307 | + if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) { |
|
| 2308 | + $this->model_obj_node_group_persister = |
|
| 2309 | + $this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao'); |
|
| 2310 | + } |
|
| 2311 | + return $this->model_obj_node_group_persister; |
|
| 2312 | + } |
|
| 2313 | + |
|
| 2314 | + |
|
| 2315 | + /** |
|
| 2316 | + * @param bool $preview_delete |
|
| 2317 | + * @return void |
|
| 2318 | + * @throws EE_Error |
|
| 2319 | + */ |
|
| 2320 | + protected function _delete_events($preview_delete = true) |
|
| 2321 | + { |
|
| 2322 | + $event_ids = $this->getEventIdsFromRequest(); |
|
| 2323 | + if ($preview_delete) { |
|
| 2324 | + $this->generateDeletionPreview($event_ids); |
|
| 2325 | + } else { |
|
| 2326 | + EEM_Event::instance()->delete_permanently([['EVT_ID' => ['IN', $event_ids]]]); |
|
| 2327 | + } |
|
| 2328 | + } |
|
| 2329 | + |
|
| 2330 | + |
|
| 2331 | + /** |
|
| 2332 | + * @param array $event_ids |
|
| 2333 | + */ |
|
| 2334 | + protected function generateDeletionPreview(array $event_ids) |
|
| 2335 | + { |
|
| 2336 | + $event_ids = $this->cleanEventIds($event_ids); |
|
| 2337 | + // Set a code we can use to reference this deletion task in the batch jobs and preview page. |
|
| 2338 | + $deletion_job_code = $this->getModelObjNodeGroupPersister()->generateGroupCode(); |
|
| 2339 | + $return_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2340 | + [ |
|
| 2341 | + 'action' => 'preview_deletion', |
|
| 2342 | + 'deletion_job_code' => $deletion_job_code, |
|
| 2343 | + ], |
|
| 2344 | + $this->_admin_base_url |
|
| 2345 | + ); |
|
| 2346 | + EEH_URL::safeRedirectAndExit( |
|
| 2347 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 2348 | + [ |
|
| 2349 | + 'page' => 'espresso_batch', |
|
| 2350 | + 'batch' => EED_Batch::batch_job, |
|
| 2351 | + 'EVT_IDs' => $event_ids, |
|
| 2352 | + 'deletion_job_code' => $deletion_job_code, |
|
| 2353 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'), |
|
| 2354 | + 'return_url' => urlencode($return_url), |
|
| 2355 | + ], |
|
| 2356 | + admin_url() |
|
| 2357 | + ) |
|
| 2358 | + ); |
|
| 2359 | + } |
|
| 2360 | + |
|
| 2361 | + |
|
| 2362 | + /** |
|
| 2363 | + * Checks for a POST submission |
|
| 2364 | + * |
|
| 2365 | + * @since 4.10.12.p |
|
| 2366 | + */ |
|
| 2367 | + protected function confirmDeletion() |
|
| 2368 | + { |
|
| 2369 | + $deletion_redirect_logic = |
|
| 2370 | + $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion'); |
|
| 2371 | + $deletion_redirect_logic->handle($this->get_request_data(), $this->admin_base_url()); |
|
| 2372 | + } |
|
| 2373 | + |
|
| 2374 | + |
|
| 2375 | + /** |
|
| 2376 | + * A page for users to preview what exactly will be deleted, and confirm they want to delete it. |
|
| 2377 | + * |
|
| 2378 | + * @throws EE_Error |
|
| 2379 | + * @since 4.10.12.p |
|
| 2380 | + */ |
|
| 2381 | + protected function previewDeletion() |
|
| 2382 | + { |
|
| 2383 | + $preview_deletion_logic = |
|
| 2384 | + $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\PreviewDeletion'); |
|
| 2385 | + $this->set_template_args($preview_deletion_logic->handle($this->get_request_data(), $this->admin_base_url())); |
|
| 2386 | + $this->display_admin_page_with_no_sidebar(); |
|
| 2387 | + } |
|
| 2388 | + |
|
| 2389 | + |
|
| 2390 | + /** |
|
| 2391 | + * get total number of events |
|
| 2392 | + * |
|
| 2393 | + * @access public |
|
| 2394 | + * @return int |
|
| 2395 | + * @throws EE_Error |
|
| 2396 | + * @throws EE_Error |
|
| 2397 | + */ |
|
| 2398 | + public function total_events() |
|
| 2399 | + { |
|
| 2400 | + return EEM_Event::instance()->count( |
|
| 2401 | + ['caps' => 'read_admin'], |
|
| 2402 | + 'EVT_ID', |
|
| 2403 | + true |
|
| 2404 | + ); |
|
| 2405 | + } |
|
| 2406 | + |
|
| 2407 | + |
|
| 2408 | + /** |
|
| 2409 | + * get total number of draft events |
|
| 2410 | + * |
|
| 2411 | + * @access public |
|
| 2412 | + * @return int |
|
| 2413 | + * @throws EE_Error |
|
| 2414 | + * @throws EE_Error |
|
| 2415 | + */ |
|
| 2416 | + public function total_events_draft() |
|
| 2417 | + { |
|
| 2418 | + return EEM_Event::instance()->count( |
|
| 2419 | + [ |
|
| 2420 | + ['status' => ['IN', ['draft', 'auto-draft']]], |
|
| 2421 | + 'caps' => 'read_admin', |
|
| 2422 | + ], |
|
| 2423 | + 'EVT_ID', |
|
| 2424 | + true |
|
| 2425 | + ); |
|
| 2426 | + } |
|
| 2427 | + |
|
| 2428 | + |
|
| 2429 | + /** |
|
| 2430 | + * get total number of trashed events |
|
| 2431 | + * |
|
| 2432 | + * @access public |
|
| 2433 | + * @return int |
|
| 2434 | + * @throws EE_Error |
|
| 2435 | + * @throws EE_Error |
|
| 2436 | + */ |
|
| 2437 | + public function total_trashed_events() |
|
| 2438 | + { |
|
| 2439 | + return EEM_Event::instance()->count( |
|
| 2440 | + [ |
|
| 2441 | + ['status' => 'trash'], |
|
| 2442 | + 'caps' => 'read_admin', |
|
| 2443 | + ], |
|
| 2444 | + 'EVT_ID', |
|
| 2445 | + true |
|
| 2446 | + ); |
|
| 2447 | + } |
|
| 2448 | + |
|
| 2449 | + |
|
| 2450 | + /** |
|
| 2451 | + * _default_event_settings |
|
| 2452 | + * This generates the Default Settings Tab |
|
| 2453 | + * |
|
| 2454 | + * @return void |
|
| 2455 | + * @throws DomainException |
|
| 2456 | + * @throws EE_Error |
|
| 2457 | + * @throws InvalidArgumentException |
|
| 2458 | + * @throws InvalidDataTypeException |
|
| 2459 | + * @throws InvalidInterfaceException |
|
| 2460 | + */ |
|
| 2461 | + protected function _default_event_settings() |
|
| 2462 | + { |
|
| 2463 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
| 2464 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 2465 | + $this->_template_args['admin_page_content'] = EEH_HTML::div( |
|
| 2466 | + $this->_default_event_settings_form()->get_html(), |
|
| 2467 | + '', |
|
| 2468 | + 'padding' |
|
| 2469 | + ); |
|
| 2470 | + $this->display_admin_page_with_sidebar(); |
|
| 2471 | + } |
|
| 2472 | + |
|
| 2473 | + |
|
| 2474 | + /** |
|
| 2475 | + * Return the form for event settings. |
|
| 2476 | + * |
|
| 2477 | + * @return EE_Form_Section_Proper |
|
| 2478 | + * @throws EE_Error |
|
| 2479 | + */ |
|
| 2480 | + protected function _default_event_settings_form() |
|
| 2481 | + { |
|
| 2482 | + $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2483 | + $registration_stati_for_selection = EEM_Registration::reg_status_array( |
|
| 2484 | + // exclude |
|
| 2485 | + [ |
|
| 2486 | + EEM_Registration::status_id_cancelled, |
|
| 2487 | + EEM_Registration::status_id_declined, |
|
| 2488 | + EEM_Registration::status_id_incomplete, |
|
| 2489 | + EEM_Registration::status_id_wait_list, |
|
| 2490 | + ], |
|
| 2491 | + true |
|
| 2492 | + ); |
|
| 2493 | + return new EE_Form_Section_Proper( |
|
| 2494 | + [ |
|
| 2495 | + 'name' => 'update_default_event_settings', |
|
| 2496 | + 'html_id' => 'update_default_event_settings', |
|
| 2497 | + 'html_class' => 'form-table', |
|
| 2498 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 2499 | + 'subsections' => apply_filters( |
|
| 2500 | + 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
| 2501 | + [ |
|
| 2502 | + 'defaults_section_header' => new EE_Form_Section_HTML( |
|
| 2503 | + EEH_HTML::h2( |
|
| 2504 | + esc_html__('Default Settings', 'event_espresso'), |
|
| 2505 | + '', |
|
| 2506 | + 'ee-admin-settings-hdr' |
|
| 2507 | + ) |
|
| 2508 | + ), |
|
| 2509 | + 'default_reg_status' => new EE_Select_Input( |
|
| 2510 | + $registration_stati_for_selection, |
|
| 2511 | + [ |
|
| 2512 | + 'default' => isset($registration_config->default_STS_ID) |
|
| 2513 | + && array_key_exists( |
|
| 2514 | + $registration_config->default_STS_ID, |
|
| 2515 | + $registration_stati_for_selection |
|
| 2516 | + ) |
|
| 2517 | + ? sanitize_text_field($registration_config->default_STS_ID) |
|
| 2518 | + : EEM_Registration::status_id_pending_payment, |
|
| 2519 | + 'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') |
|
| 2520 | + . EEH_Template::get_help_tab_link( |
|
| 2521 | + 'default_settings_status_help_tab' |
|
| 2522 | + ), |
|
| 2523 | + 'html_help_text' => esc_html__( |
|
| 2524 | + 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.', |
|
| 2525 | + 'event_espresso' |
|
| 2526 | + ), |
|
| 2527 | + ] |
|
| 2528 | + ), |
|
| 2529 | + 'default_max_tickets' => new EE_Integer_Input( |
|
| 2530 | + [ |
|
| 2531 | + 'default' => isset($registration_config->default_maximum_number_of_tickets) |
|
| 2532 | + ? $registration_config->default_maximum_number_of_tickets |
|
| 2533 | + : EEM_Event::get_default_additional_limit(), |
|
| 2534 | + 'html_label_text' => esc_html__( |
|
| 2535 | + 'Default Maximum Tickets Allowed Per Order:', |
|
| 2536 | + 'event_espresso' |
|
| 2537 | + ) |
|
| 2538 | + . EEH_Template::get_help_tab_link( |
|
| 2539 | + 'default_maximum_tickets_help_tab"' |
|
| 2540 | + ), |
|
| 2541 | + 'html_help_text' => esc_html__( |
|
| 2542 | + 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.', |
|
| 2543 | + 'event_espresso' |
|
| 2544 | + ), |
|
| 2545 | + ] |
|
| 2546 | + ), |
|
| 2547 | + ] |
|
| 2548 | + ), |
|
| 2549 | + ] |
|
| 2550 | + ); |
|
| 2551 | + } |
|
| 2552 | + |
|
| 2553 | + |
|
| 2554 | + /** |
|
| 2555 | + * @return void |
|
| 2556 | + * @throws EE_Error |
|
| 2557 | + * @throws InvalidArgumentException |
|
| 2558 | + * @throws InvalidDataTypeException |
|
| 2559 | + * @throws InvalidInterfaceException |
|
| 2560 | + */ |
|
| 2561 | + protected function _update_default_event_settings() |
|
| 2562 | + { |
|
| 2563 | + $form = $this->_default_event_settings_form(); |
|
| 2564 | + if ($form->was_submitted()) { |
|
| 2565 | + $form->receive_form_submission(); |
|
| 2566 | + if ($form->is_valid()) { |
|
| 2567 | + $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2568 | + $valid_data = $form->valid_data(); |
|
| 2569 | + if (isset($valid_data['default_reg_status'])) { |
|
| 2570 | + $registration_config->default_STS_ID = $valid_data['default_reg_status']; |
|
| 2571 | + } |
|
| 2572 | + if (isset($valid_data['default_max_tickets'])) { |
|
| 2573 | + $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets']; |
|
| 2574 | + } |
|
| 2575 | + do_action( |
|
| 2576 | + 'AHEE__Events_Admin_Page___update_default_event_settings', |
|
| 2577 | + $valid_data, |
|
| 2578 | + EE_Registry::instance()->CFG, |
|
| 2579 | + $this |
|
| 2580 | + ); |
|
| 2581 | + // update because data was valid! |
|
| 2582 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 2583 | + EE_Error::overwrite_success(); |
|
| 2584 | + EE_Error::add_success( |
|
| 2585 | + esc_html__('Default Event Settings were updated', 'event_espresso') |
|
| 2586 | + ); |
|
| 2587 | + } |
|
| 2588 | + } |
|
| 2589 | + $this->_redirect_after_action(0, '', '', ['action' => 'default_event_settings'], true); |
|
| 2590 | + } |
|
| 2591 | + |
|
| 2592 | + |
|
| 2593 | + /************* Templates ************* |
|
| 21 | 2594 | * |
| 22 | - * @var EE_Event $_event |
|
| 23 | - */ |
|
| 24 | - protected $_event; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * This will hold the category object for category_details screen. |
|
| 29 | - * |
|
| 30 | - * @var stdClass $_category |
|
| 31 | - */ |
|
| 32 | - protected $_category; |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * This will hold the event model instance |
|
| 37 | - * |
|
| 38 | - * @var EEM_Event $_event_model |
|
| 39 | - */ |
|
| 40 | - protected $_event_model; |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var EE_Event |
|
| 45 | - */ |
|
| 46 | - protected $_cpt_model_obj = false; |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var NodeGroupDao |
|
| 51 | - */ |
|
| 52 | - protected $model_obj_node_group_persister; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Initialize page props for this admin page group. |
|
| 57 | - */ |
|
| 58 | - protected function _init_page_props() |
|
| 59 | - { |
|
| 60 | - $this->page_slug = EVENTS_PG_SLUG; |
|
| 61 | - $this->page_label = EVENTS_LABEL; |
|
| 62 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
| 63 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
| 64 | - $this->_cpt_model_names = [ |
|
| 65 | - 'create_new' => 'EEM_Event', |
|
| 66 | - 'edit' => 'EEM_Event', |
|
| 67 | - ]; |
|
| 68 | - $this->_cpt_edit_routes = [ |
|
| 69 | - 'espresso_events' => 'edit', |
|
| 70 | - ]; |
|
| 71 | - add_action( |
|
| 72 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
| 73 | - [$this, 'verify_event_edit'], |
|
| 74 | - 10, |
|
| 75 | - 2 |
|
| 76 | - ); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Sets the ajax hooks used for this admin page group. |
|
| 82 | - */ |
|
| 83 | - protected function _ajax_hooks() |
|
| 84 | - { |
|
| 85 | - add_action('wp_ajax_ee_save_timezone_setting', [$this, 'saveTimezoneString']); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Sets the page properties for this admin page group. |
|
| 91 | - */ |
|
| 92 | - protected function _define_page_props() |
|
| 93 | - { |
|
| 94 | - $this->_admin_page_title = EVENTS_LABEL; |
|
| 95 | - $this->_labels = [ |
|
| 96 | - 'buttons' => [ |
|
| 97 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
| 98 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
| 99 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
| 100 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
| 101 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
| 102 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
| 103 | - ], |
|
| 104 | - 'editor_title' => [ |
|
| 105 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
| 106 | - ], |
|
| 107 | - 'publishbox' => [ |
|
| 108 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
| 109 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
| 110 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
| 111 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
| 112 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
| 113 | - ], |
|
| 114 | - ]; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Sets the page routes property for this admin page group. |
|
| 120 | - */ |
|
| 121 | - protected function _set_page_routes() |
|
| 122 | - { |
|
| 123 | - // load formatter helper |
|
| 124 | - // load field generator helper |
|
| 125 | - // is there a evt_id in the request? |
|
| 126 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 127 | - $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
| 128 | - |
|
| 129 | - $this->_page_routes = [ |
|
| 130 | - 'default' => [ |
|
| 131 | - 'func' => '_events_overview_list_table', |
|
| 132 | - 'capability' => 'ee_read_events', |
|
| 133 | - ], |
|
| 134 | - 'create_new' => [ |
|
| 135 | - 'func' => '_create_new_cpt_item', |
|
| 136 | - 'capability' => 'ee_edit_events', |
|
| 137 | - ], |
|
| 138 | - 'edit' => [ |
|
| 139 | - 'func' => '_edit_cpt_item', |
|
| 140 | - 'capability' => 'ee_edit_event', |
|
| 141 | - 'obj_id' => $EVT_ID, |
|
| 142 | - ], |
|
| 143 | - 'copy_event' => [ |
|
| 144 | - 'func' => '_copy_events', |
|
| 145 | - 'capability' => 'ee_edit_event', |
|
| 146 | - 'obj_id' => $EVT_ID, |
|
| 147 | - 'noheader' => true, |
|
| 148 | - ], |
|
| 149 | - 'trash_event' => [ |
|
| 150 | - 'func' => '_trash_or_restore_event', |
|
| 151 | - 'args' => ['event_status' => 'trash'], |
|
| 152 | - 'capability' => 'ee_delete_event', |
|
| 153 | - 'obj_id' => $EVT_ID, |
|
| 154 | - 'noheader' => true, |
|
| 155 | - ], |
|
| 156 | - 'trash_events' => [ |
|
| 157 | - 'func' => '_trash_or_restore_events', |
|
| 158 | - 'args' => ['event_status' => 'trash'], |
|
| 159 | - 'capability' => 'ee_delete_events', |
|
| 160 | - 'noheader' => true, |
|
| 161 | - ], |
|
| 162 | - 'restore_event' => [ |
|
| 163 | - 'func' => '_trash_or_restore_event', |
|
| 164 | - 'args' => ['event_status' => 'draft'], |
|
| 165 | - 'capability' => 'ee_delete_event', |
|
| 166 | - 'obj_id' => $EVT_ID, |
|
| 167 | - 'noheader' => true, |
|
| 168 | - ], |
|
| 169 | - 'restore_events' => [ |
|
| 170 | - 'func' => '_trash_or_restore_events', |
|
| 171 | - 'args' => ['event_status' => 'draft'], |
|
| 172 | - 'capability' => 'ee_delete_events', |
|
| 173 | - 'noheader' => true, |
|
| 174 | - ], |
|
| 175 | - 'delete_event' => [ |
|
| 176 | - 'func' => '_delete_event', |
|
| 177 | - 'capability' => 'ee_delete_event', |
|
| 178 | - 'obj_id' => $EVT_ID, |
|
| 179 | - 'noheader' => true, |
|
| 180 | - ], |
|
| 181 | - 'delete_events' => [ |
|
| 182 | - 'func' => '_delete_events', |
|
| 183 | - 'capability' => 'ee_delete_events', |
|
| 184 | - 'noheader' => true, |
|
| 185 | - ], |
|
| 186 | - 'view_report' => [ |
|
| 187 | - 'func' => '_view_report', |
|
| 188 | - 'capability' => 'ee_edit_events', |
|
| 189 | - ], |
|
| 190 | - 'default_event_settings' => [ |
|
| 191 | - 'func' => '_default_event_settings', |
|
| 192 | - 'capability' => 'manage_options', |
|
| 193 | - ], |
|
| 194 | - 'update_default_event_settings' => [ |
|
| 195 | - 'func' => '_update_default_event_settings', |
|
| 196 | - 'capability' => 'manage_options', |
|
| 197 | - 'noheader' => true, |
|
| 198 | - ], |
|
| 199 | - 'template_settings' => [ |
|
| 200 | - 'func' => '_template_settings', |
|
| 201 | - 'capability' => 'manage_options', |
|
| 202 | - ], |
|
| 203 | - // event category tab related |
|
| 204 | - 'add_category' => [ |
|
| 205 | - 'func' => '_category_details', |
|
| 206 | - 'capability' => 'ee_edit_event_category', |
|
| 207 | - 'args' => ['add'], |
|
| 208 | - ], |
|
| 209 | - 'edit_category' => [ |
|
| 210 | - 'func' => '_category_details', |
|
| 211 | - 'capability' => 'ee_edit_event_category', |
|
| 212 | - 'args' => ['edit'], |
|
| 213 | - ], |
|
| 214 | - 'delete_categories' => [ |
|
| 215 | - 'func' => '_delete_categories', |
|
| 216 | - 'capability' => 'ee_delete_event_category', |
|
| 217 | - 'noheader' => true, |
|
| 218 | - ], |
|
| 219 | - 'delete_category' => [ |
|
| 220 | - 'func' => '_delete_categories', |
|
| 221 | - 'capability' => 'ee_delete_event_category', |
|
| 222 | - 'noheader' => true, |
|
| 223 | - ], |
|
| 224 | - 'insert_category' => [ |
|
| 225 | - 'func' => '_insert_or_update_category', |
|
| 226 | - 'args' => ['new_category' => true], |
|
| 227 | - 'capability' => 'ee_edit_event_category', |
|
| 228 | - 'noheader' => true, |
|
| 229 | - ], |
|
| 230 | - 'update_category' => [ |
|
| 231 | - 'func' => '_insert_or_update_category', |
|
| 232 | - 'args' => ['new_category' => false], |
|
| 233 | - 'capability' => 'ee_edit_event_category', |
|
| 234 | - 'noheader' => true, |
|
| 235 | - ], |
|
| 236 | - 'category_list' => [ |
|
| 237 | - 'func' => '_category_list_table', |
|
| 238 | - 'capability' => 'ee_manage_event_categories', |
|
| 239 | - ], |
|
| 240 | - 'preview_deletion' => [ |
|
| 241 | - 'func' => 'previewDeletion', |
|
| 242 | - 'capability' => 'ee_delete_events', |
|
| 243 | - ], |
|
| 244 | - 'confirm_deletion' => [ |
|
| 245 | - 'func' => 'confirmDeletion', |
|
| 246 | - 'capability' => 'ee_delete_events', |
|
| 247 | - 'noheader' => true, |
|
| 248 | - ], |
|
| 249 | - ]; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Set the _page_config property for this admin page group. |
|
| 255 | - */ |
|
| 256 | - protected function _set_page_config() |
|
| 257 | - { |
|
| 258 | - $post_id = $this->request->getRequestParam('post', 0, 'int'); |
|
| 259 | - $EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
| 260 | - $this->_page_config = [ |
|
| 261 | - 'default' => [ |
|
| 262 | - 'nav' => [ |
|
| 263 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 264 | - 'order' => 10, |
|
| 265 | - ], |
|
| 266 | - 'list_table' => 'Events_Admin_List_Table', |
|
| 267 | - 'help_tabs' => [ |
|
| 268 | - 'events_overview_help_tab' => [ |
|
| 269 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
| 270 | - 'filename' => 'events_overview', |
|
| 271 | - ], |
|
| 272 | - 'events_overview_table_column_headings_help_tab' => [ |
|
| 273 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
| 274 | - 'filename' => 'events_overview_table_column_headings', |
|
| 275 | - ], |
|
| 276 | - 'events_overview_filters_help_tab' => [ |
|
| 277 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
| 278 | - 'filename' => 'events_overview_filters', |
|
| 279 | - ], |
|
| 280 | - 'events_overview_view_help_tab' => [ |
|
| 281 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
| 282 | - 'filename' => 'events_overview_views', |
|
| 283 | - ], |
|
| 284 | - 'events_overview_other_help_tab' => [ |
|
| 285 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
| 286 | - 'filename' => 'events_overview_other', |
|
| 287 | - ], |
|
| 288 | - ], |
|
| 289 | - // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 290 | - // 'help_tour' => [ |
|
| 291 | - // 'Event_Overview_Help_Tour', |
|
| 292 | - // // 'New_Features_Test_Help_Tour' for testing multiple help tour |
|
| 293 | - // ], |
|
| 294 | - 'qtips' => ['EE_Event_List_Table_Tips'], |
|
| 295 | - 'require_nonce' => false, |
|
| 296 | - ], |
|
| 297 | - 'create_new' => [ |
|
| 298 | - 'nav' => [ |
|
| 299 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
| 300 | - 'order' => 5, |
|
| 301 | - 'persistent' => false, |
|
| 302 | - ], |
|
| 303 | - 'metaboxes' => ['_register_event_editor_meta_boxes'], |
|
| 304 | - 'help_tabs' => [ |
|
| 305 | - 'event_editor_help_tab' => [ |
|
| 306 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 307 | - 'filename' => 'event_editor', |
|
| 308 | - ], |
|
| 309 | - 'event_editor_title_richtexteditor_help_tab' => [ |
|
| 310 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 311 | - 'filename' => 'event_editor_title_richtexteditor', |
|
| 312 | - ], |
|
| 313 | - 'event_editor_venue_details_help_tab' => [ |
|
| 314 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 315 | - 'filename' => 'event_editor_venue_details', |
|
| 316 | - ], |
|
| 317 | - 'event_editor_event_datetimes_help_tab' => [ |
|
| 318 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 319 | - 'filename' => 'event_editor_event_datetimes', |
|
| 320 | - ], |
|
| 321 | - 'event_editor_event_tickets_help_tab' => [ |
|
| 322 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 323 | - 'filename' => 'event_editor_event_tickets', |
|
| 324 | - ], |
|
| 325 | - 'event_editor_event_registration_options_help_tab' => [ |
|
| 326 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 327 | - 'filename' => 'event_editor_event_registration_options', |
|
| 328 | - ], |
|
| 329 | - 'event_editor_tags_categories_help_tab' => [ |
|
| 330 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 331 | - 'filename' => 'event_editor_tags_categories', |
|
| 332 | - ], |
|
| 333 | - 'event_editor_questions_registrants_help_tab' => [ |
|
| 334 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 335 | - 'filename' => 'event_editor_questions_registrants', |
|
| 336 | - ], |
|
| 337 | - 'event_editor_save_new_event_help_tab' => [ |
|
| 338 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 339 | - 'filename' => 'event_editor_save_new_event', |
|
| 340 | - ], |
|
| 341 | - 'event_editor_other_help_tab' => [ |
|
| 342 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 343 | - 'filename' => 'event_editor_other', |
|
| 344 | - ], |
|
| 345 | - ], |
|
| 346 | - // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 347 | - // 'help_tour' => [ |
|
| 348 | - // 'Event_Editor_Help_Tour', |
|
| 349 | - // ], |
|
| 350 | - 'qtips' => ['EE_Event_Editor_Decaf_Tips'], |
|
| 351 | - 'require_nonce' => false, |
|
| 352 | - ], |
|
| 353 | - 'edit' => [ |
|
| 354 | - 'nav' => [ |
|
| 355 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
| 356 | - 'order' => 5, |
|
| 357 | - 'persistent' => false, |
|
| 358 | - 'url' => $post_id |
|
| 359 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 360 | - ['post' => $post_id, 'action' => 'edit'], |
|
| 361 | - $this->_current_page_view_url |
|
| 362 | - ) |
|
| 363 | - : $this->_admin_base_url, |
|
| 364 | - ], |
|
| 365 | - 'metaboxes' => ['_register_event_editor_meta_boxes'], |
|
| 366 | - 'help_tabs' => [ |
|
| 367 | - 'event_editor_help_tab' => [ |
|
| 368 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 369 | - 'filename' => 'event_editor', |
|
| 370 | - ], |
|
| 371 | - 'event_editor_title_richtexteditor_help_tab' => [ |
|
| 372 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 373 | - 'filename' => 'event_editor_title_richtexteditor', |
|
| 374 | - ], |
|
| 375 | - 'event_editor_venue_details_help_tab' => [ |
|
| 376 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 377 | - 'filename' => 'event_editor_venue_details', |
|
| 378 | - ], |
|
| 379 | - 'event_editor_event_datetimes_help_tab' => [ |
|
| 380 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 381 | - 'filename' => 'event_editor_event_datetimes', |
|
| 382 | - ], |
|
| 383 | - 'event_editor_event_tickets_help_tab' => [ |
|
| 384 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 385 | - 'filename' => 'event_editor_event_tickets', |
|
| 386 | - ], |
|
| 387 | - 'event_editor_event_registration_options_help_tab' => [ |
|
| 388 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 389 | - 'filename' => 'event_editor_event_registration_options', |
|
| 390 | - ], |
|
| 391 | - 'event_editor_tags_categories_help_tab' => [ |
|
| 392 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 393 | - 'filename' => 'event_editor_tags_categories', |
|
| 394 | - ], |
|
| 395 | - 'event_editor_questions_registrants_help_tab' => [ |
|
| 396 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 397 | - 'filename' => 'event_editor_questions_registrants', |
|
| 398 | - ], |
|
| 399 | - 'event_editor_save_new_event_help_tab' => [ |
|
| 400 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 401 | - 'filename' => 'event_editor_save_new_event', |
|
| 402 | - ], |
|
| 403 | - 'event_editor_other_help_tab' => [ |
|
| 404 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 405 | - 'filename' => 'event_editor_other', |
|
| 406 | - ], |
|
| 407 | - ], |
|
| 408 | - 'require_nonce' => false, |
|
| 409 | - ], |
|
| 410 | - 'default_event_settings' => [ |
|
| 411 | - 'nav' => [ |
|
| 412 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
| 413 | - 'order' => 40, |
|
| 414 | - ], |
|
| 415 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
| 416 | - 'labels' => [ |
|
| 417 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
| 418 | - ], |
|
| 419 | - 'help_tabs' => [ |
|
| 420 | - 'default_settings_help_tab' => [ |
|
| 421 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
| 422 | - 'filename' => 'events_default_settings', |
|
| 423 | - ], |
|
| 424 | - 'default_settings_status_help_tab' => [ |
|
| 425 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
| 426 | - 'filename' => 'events_default_settings_status', |
|
| 427 | - ], |
|
| 428 | - 'default_maximum_tickets_help_tab' => [ |
|
| 429 | - 'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), |
|
| 430 | - 'filename' => 'events_default_settings_max_tickets', |
|
| 431 | - ], |
|
| 432 | - ], |
|
| 433 | - // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 434 | - // 'help_tour' => ['Event_Default_Settings_Help_Tour'], |
|
| 435 | - 'require_nonce' => false, |
|
| 436 | - ], |
|
| 437 | - // template settings |
|
| 438 | - 'template_settings' => [ |
|
| 439 | - 'nav' => [ |
|
| 440 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 441 | - 'order' => 30, |
|
| 442 | - ], |
|
| 443 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 444 | - 'help_tabs' => [ |
|
| 445 | - 'general_settings_templates_help_tab' => [ |
|
| 446 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 447 | - 'filename' => 'general_settings_templates', |
|
| 448 | - ], |
|
| 449 | - ], |
|
| 450 | - // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 451 | - // 'help_tour' => ['Templates_Help_Tour'], |
|
| 452 | - 'require_nonce' => false, |
|
| 453 | - ], |
|
| 454 | - // event category stuff |
|
| 455 | - 'add_category' => [ |
|
| 456 | - 'nav' => [ |
|
| 457 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
| 458 | - 'order' => 15, |
|
| 459 | - 'persistent' => false, |
|
| 460 | - ], |
|
| 461 | - 'help_tabs' => [ |
|
| 462 | - 'add_category_help_tab' => [ |
|
| 463 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
| 464 | - 'filename' => 'events_add_category', |
|
| 465 | - ], |
|
| 466 | - ], |
|
| 467 | - // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 468 | - // 'help_tour' => ['Event_Add_Category_Help_Tour'], |
|
| 469 | - 'metaboxes' => ['_publish_post_box'], |
|
| 470 | - 'require_nonce' => false, |
|
| 471 | - ], |
|
| 472 | - 'edit_category' => [ |
|
| 473 | - 'nav' => [ |
|
| 474 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
| 475 | - 'order' => 15, |
|
| 476 | - 'persistent' => false, |
|
| 477 | - 'url' => $EVT_CAT_ID |
|
| 478 | - ? add_query_arg( |
|
| 479 | - ['EVT_CAT_ID' => $EVT_CAT_ID], |
|
| 480 | - $this->_current_page_view_url |
|
| 481 | - ) |
|
| 482 | - : $this->_admin_base_url, |
|
| 483 | - ], |
|
| 484 | - 'help_tabs' => [ |
|
| 485 | - 'edit_category_help_tab' => [ |
|
| 486 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
| 487 | - 'filename' => 'events_edit_category', |
|
| 488 | - ], |
|
| 489 | - ], |
|
| 490 | - /*'help_tour' => ['Event_Edit_Category_Help_Tour'],*/ |
|
| 491 | - 'metaboxes' => ['_publish_post_box'], |
|
| 492 | - 'require_nonce' => false, |
|
| 493 | - ], |
|
| 494 | - 'category_list' => [ |
|
| 495 | - 'nav' => [ |
|
| 496 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
| 497 | - 'order' => 20, |
|
| 498 | - ], |
|
| 499 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
| 500 | - 'help_tabs' => [ |
|
| 501 | - 'events_categories_help_tab' => [ |
|
| 502 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
| 503 | - 'filename' => 'events_categories', |
|
| 504 | - ], |
|
| 505 | - 'events_categories_table_column_headings_help_tab' => [ |
|
| 506 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
| 507 | - 'filename' => 'events_categories_table_column_headings', |
|
| 508 | - ], |
|
| 509 | - 'events_categories_view_help_tab' => [ |
|
| 510 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
| 511 | - 'filename' => 'events_categories_views', |
|
| 512 | - ], |
|
| 513 | - 'events_categories_other_help_tab' => [ |
|
| 514 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
| 515 | - 'filename' => 'events_categories_other', |
|
| 516 | - ], |
|
| 517 | - ], |
|
| 518 | - // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 519 | - // 'help_tour' => [ |
|
| 520 | - // 'Event_Categories_Help_Tour', |
|
| 521 | - // ], |
|
| 522 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 523 | - 'require_nonce' => false, |
|
| 524 | - ], |
|
| 525 | - 'preview_deletion' => [ |
|
| 526 | - 'nav' => [ |
|
| 527 | - 'label' => esc_html__('Preview Deletion', 'event_espresso'), |
|
| 528 | - 'order' => 15, |
|
| 529 | - 'persistent' => false, |
|
| 530 | - 'url' => '', |
|
| 531 | - ], |
|
| 532 | - 'require_nonce' => false, |
|
| 533 | - ], |
|
| 534 | - ]; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Used to register any global screen options if necessary for every route in this admin page group. |
|
| 540 | - */ |
|
| 541 | - protected function _add_screen_options() |
|
| 542 | - { |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * Implementing the screen options for the 'default' route. |
|
| 548 | - * |
|
| 549 | - * @throws InvalidArgumentException |
|
| 550 | - * @throws InvalidDataTypeException |
|
| 551 | - * @throws InvalidInterfaceException |
|
| 552 | - */ |
|
| 553 | - protected function _add_screen_options_default() |
|
| 554 | - { |
|
| 555 | - $this->_per_page_screen_option(); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * Implementing screen options for the category list route. |
|
| 561 | - * |
|
| 562 | - * @throws InvalidArgumentException |
|
| 563 | - * @throws InvalidDataTypeException |
|
| 564 | - * @throws InvalidInterfaceException |
|
| 565 | - */ |
|
| 566 | - protected function _add_screen_options_category_list() |
|
| 567 | - { |
|
| 568 | - $page_title = $this->_admin_page_title; |
|
| 569 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
| 570 | - $this->_per_page_screen_option(); |
|
| 571 | - $this->_admin_page_title = $page_title; |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * Used to register any global feature pointers for the admin page group. |
|
| 577 | - */ |
|
| 578 | - protected function _add_feature_pointers() |
|
| 579 | - { |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - |
|
| 583 | - /** |
|
| 584 | - * Registers and enqueues any global scripts and styles for the entire admin page group. |
|
| 585 | - */ |
|
| 586 | - public function load_scripts_styles() |
|
| 587 | - { |
|
| 588 | - wp_register_style( |
|
| 589 | - 'events-admin-css', |
|
| 590 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 591 | - [], |
|
| 592 | - EVENT_ESPRESSO_VERSION |
|
| 593 | - ); |
|
| 594 | - wp_register_style( |
|
| 595 | - 'ee-cat-admin', |
|
| 596 | - EVENTS_ASSETS_URL . 'ee-cat-admin.css', |
|
| 597 | - [], |
|
| 598 | - EVENT_ESPRESSO_VERSION |
|
| 599 | - ); |
|
| 600 | - wp_enqueue_style('events-admin-css'); |
|
| 601 | - wp_enqueue_style('ee-cat-admin'); |
|
| 602 | - // scripts |
|
| 603 | - wp_register_script( |
|
| 604 | - 'event_editor_js', |
|
| 605 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 606 | - ['ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'], |
|
| 607 | - EVENT_ESPRESSO_VERSION, |
|
| 608 | - true |
|
| 609 | - ); |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - |
|
| 613 | - /** |
|
| 614 | - * Enqueuing scripts and styles specific to this view |
|
| 615 | - */ |
|
| 616 | - public function load_scripts_styles_create_new() |
|
| 617 | - { |
|
| 618 | - $this->load_scripts_styles_edit(); |
|
| 619 | - } |
|
| 620 | - |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * Enqueuing scripts and styles specific to this view |
|
| 624 | - */ |
|
| 625 | - public function load_scripts_styles_edit() |
|
| 626 | - { |
|
| 627 | - // styles |
|
| 628 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 629 | - wp_register_style( |
|
| 630 | - 'event-editor-css', |
|
| 631 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 632 | - ['ee-admin-css'], |
|
| 633 | - EVENT_ESPRESSO_VERSION |
|
| 634 | - ); |
|
| 635 | - wp_enqueue_style('event-editor-css'); |
|
| 636 | - // scripts |
|
| 637 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
| 638 | - wp_register_script( |
|
| 639 | - 'event-datetime-metabox', |
|
| 640 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 641 | - ['event_editor_js', 'ee-datepicker'], |
|
| 642 | - EVENT_ESPRESSO_VERSION |
|
| 643 | - ); |
|
| 644 | - wp_enqueue_script('event-datetime-metabox'); |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - |
|
| 649 | - /** |
|
| 650 | - * Populating the _views property for the category list table view. |
|
| 651 | - */ |
|
| 652 | - protected function _set_list_table_views_category_list() |
|
| 653 | - { |
|
| 654 | - $this->_views = [ |
|
| 655 | - 'all' => [ |
|
| 656 | - 'slug' => 'all', |
|
| 657 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 658 | - 'count' => 0, |
|
| 659 | - 'bulk_action' => [ |
|
| 660 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 661 | - ], |
|
| 662 | - ], |
|
| 663 | - ]; |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - |
|
| 667 | - /** |
|
| 668 | - * For adding anything that fires on the admin_init hook for any route within this admin page group. |
|
| 669 | - */ |
|
| 670 | - public function admin_init() |
|
| 671 | - { |
|
| 672 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
| 673 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 674 | - 'event_espresso' |
|
| 675 | - ); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - |
|
| 679 | - /** |
|
| 680 | - * For adding anything that should be triggered on the admin_notices hook for any route within this admin page |
|
| 681 | - * group. |
|
| 682 | - */ |
|
| 683 | - public function admin_notices() |
|
| 684 | - { |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - |
|
| 688 | - /** |
|
| 689 | - * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within |
|
| 690 | - * this admin page group. |
|
| 691 | - */ |
|
| 692 | - public function admin_footer_scripts() |
|
| 693 | - { |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - |
|
| 697 | - /** |
|
| 698 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
| 699 | - * warning (via EE_Error::add_error()); |
|
| 700 | - * |
|
| 701 | - * @param EE_Event $event Event object |
|
| 702 | - * @param string $req_type |
|
| 703 | - * @return void |
|
| 704 | - * @throws EE_Error |
|
| 705 | - * @throws ReflectionException |
|
| 706 | - */ |
|
| 707 | - public function verify_event_edit($event = null, $req_type = '') |
|
| 708 | - { |
|
| 709 | - // don't need to do this when processing |
|
| 710 | - if (! empty($req_type)) { |
|
| 711 | - return; |
|
| 712 | - } |
|
| 713 | - // no event? |
|
| 714 | - if (! $event instanceof EE_Event) { |
|
| 715 | - $event = $this->_cpt_model_obj; |
|
| 716 | - } |
|
| 717 | - // STILL no event? |
|
| 718 | - if (! $event instanceof EE_Event) { |
|
| 719 | - return; |
|
| 720 | - } |
|
| 721 | - $orig_status = $event->status(); |
|
| 722 | - // first check if event is active. |
|
| 723 | - if ( |
|
| 724 | - $orig_status === EEM_Event::cancelled |
|
| 725 | - || $orig_status === EEM_Event::postponed |
|
| 726 | - || $event->is_expired() |
|
| 727 | - || $event->is_inactive() |
|
| 728 | - ) { |
|
| 729 | - return; |
|
| 730 | - } |
|
| 731 | - // made it here so it IS active... next check that any of the tickets are sold. |
|
| 732 | - if ($event->is_sold_out(true)) { |
|
| 733 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
| 734 | - EE_Error::add_attention( |
|
| 735 | - sprintf( |
|
| 736 | - esc_html__( |
|
| 737 | - 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
| 738 | - 'event_espresso' |
|
| 739 | - ), |
|
| 740 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
| 741 | - ) |
|
| 742 | - ); |
|
| 743 | - } |
|
| 744 | - return; |
|
| 745 | - } |
|
| 746 | - if ($orig_status === EEM_Event::sold_out) { |
|
| 747 | - EE_Error::add_attention( |
|
| 748 | - sprintf( |
|
| 749 | - esc_html__( |
|
| 750 | - 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
| 751 | - 'event_espresso' |
|
| 752 | - ), |
|
| 753 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
| 754 | - ) |
|
| 755 | - ); |
|
| 756 | - } |
|
| 757 | - // now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
| 758 | - if (! $event->tickets_on_sale()) { |
|
| 759 | - return; |
|
| 760 | - } |
|
| 761 | - // made it here so show warning |
|
| 762 | - $this->_edit_event_warning(); |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - |
|
| 766 | - /** |
|
| 767 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
| 768 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
| 769 | - * |
|
| 770 | - * @access protected |
|
| 771 | - * @return void |
|
| 772 | - */ |
|
| 773 | - protected function _edit_event_warning() |
|
| 774 | - { |
|
| 775 | - // we don't want to add warnings during these requests |
|
| 776 | - if ($this->request->getRequestParam('action') === 'editpost') { |
|
| 777 | - return; |
|
| 778 | - } |
|
| 779 | - EE_Error::add_attention( |
|
| 780 | - sprintf( |
|
| 781 | - esc_html__( |
|
| 782 | - 'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s', |
|
| 783 | - 'event_espresso' |
|
| 784 | - ), |
|
| 785 | - '<a class="espresso-help-tab-lnk">', |
|
| 786 | - '</a>' |
|
| 787 | - ) |
|
| 788 | - ); |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - |
|
| 792 | - /** |
|
| 793 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
| 794 | - * Otherwise, do the normal logic |
|
| 795 | - * |
|
| 796 | - * @return void |
|
| 797 | - * @throws EE_Error |
|
| 798 | - * @throws InvalidArgumentException |
|
| 799 | - * @throws InvalidDataTypeException |
|
| 800 | - * @throws InvalidInterfaceException |
|
| 801 | - */ |
|
| 802 | - protected function _create_new_cpt_item() |
|
| 803 | - { |
|
| 804 | - $has_timezone_string = get_option('timezone_string'); |
|
| 805 | - // only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
| 806 | - if (! $has_timezone_string && ! EEM_Event::instance()->exists([])) { |
|
| 807 | - EE_Error::add_attention( |
|
| 808 | - sprintf( |
|
| 809 | - esc_html__( |
|
| 810 | - 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s', |
|
| 811 | - 'event_espresso' |
|
| 812 | - ), |
|
| 813 | - '<br>', |
|
| 814 | - '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">' |
|
| 815 | - . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) |
|
| 816 | - . '</select>', |
|
| 817 | - '<button class="button button--secondary timezone-submit">', |
|
| 818 | - '</button><span class="spinner"></span>' |
|
| 819 | - ), |
|
| 820 | - __FILE__, |
|
| 821 | - __FUNCTION__, |
|
| 822 | - __LINE__ |
|
| 823 | - ); |
|
| 824 | - } |
|
| 825 | - parent::_create_new_cpt_item(); |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - |
|
| 829 | - /** |
|
| 830 | - * Sets the _views property for the default route in this admin page group. |
|
| 831 | - */ |
|
| 832 | - protected function _set_list_table_views_default() |
|
| 833 | - { |
|
| 834 | - $this->_views = [ |
|
| 835 | - 'all' => [ |
|
| 836 | - 'slug' => 'all', |
|
| 837 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
| 838 | - 'count' => 0, |
|
| 839 | - 'bulk_action' => [ |
|
| 840 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 841 | - ], |
|
| 842 | - ], |
|
| 843 | - 'draft' => [ |
|
| 844 | - 'slug' => 'draft', |
|
| 845 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
| 846 | - 'count' => 0, |
|
| 847 | - 'bulk_action' => [ |
|
| 848 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 849 | - ], |
|
| 850 | - ], |
|
| 851 | - ]; |
|
| 852 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 853 | - $this->_views['trash'] = [ |
|
| 854 | - 'slug' => 'trash', |
|
| 855 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 856 | - 'count' => 0, |
|
| 857 | - 'bulk_action' => [ |
|
| 858 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
| 859 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 860 | - ], |
|
| 861 | - ]; |
|
| 862 | - } |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - |
|
| 866 | - /** |
|
| 867 | - * Provides the legend item array for the default list table view. |
|
| 868 | - * |
|
| 869 | - * @return array |
|
| 870 | - * @throws EE_Error |
|
| 871 | - * @throws EE_Error |
|
| 872 | - */ |
|
| 873 | - protected function _event_legend_items() |
|
| 874 | - { |
|
| 875 | - $items = [ |
|
| 876 | - 'view_details' => [ |
|
| 877 | - 'class' => 'dashicons dashicons-visibility', |
|
| 878 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
| 879 | - ], |
|
| 880 | - 'edit_event' => [ |
|
| 881 | - 'class' => 'dashicons dashicons-calendar-alt', |
|
| 882 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
| 883 | - ], |
|
| 884 | - 'view_attendees' => [ |
|
| 885 | - 'class' => 'dashicons dashicons-groups', |
|
| 886 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
| 887 | - ], |
|
| 888 | - ]; |
|
| 889 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
| 890 | - $statuses = [ |
|
| 891 | - 'sold_out_status' => [ |
|
| 892 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::sold_out, |
|
| 893 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
| 894 | - ], |
|
| 895 | - 'active_status' => [ |
|
| 896 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::active, |
|
| 897 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
| 898 | - ], |
|
| 899 | - 'upcoming_status' => [ |
|
| 900 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::upcoming, |
|
| 901 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
| 902 | - ], |
|
| 903 | - 'postponed_status' => [ |
|
| 904 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::postponed, |
|
| 905 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
| 906 | - ], |
|
| 907 | - 'cancelled_status' => [ |
|
| 908 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::cancelled, |
|
| 909 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
| 910 | - ], |
|
| 911 | - 'expired_status' => [ |
|
| 912 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::expired, |
|
| 913 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
| 914 | - ], |
|
| 915 | - 'inactive_status' => [ |
|
| 916 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::inactive, |
|
| 917 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
| 918 | - ], |
|
| 919 | - ]; |
|
| 920 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
| 921 | - return array_merge($items, $statuses); |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - |
|
| 925 | - /** |
|
| 926 | - * @return EEM_Event |
|
| 927 | - * @throws EE_Error |
|
| 928 | - * @throws InvalidArgumentException |
|
| 929 | - * @throws InvalidDataTypeException |
|
| 930 | - * @throws InvalidInterfaceException |
|
| 931 | - * @throws ReflectionException |
|
| 932 | - */ |
|
| 933 | - private function _event_model() |
|
| 934 | - { |
|
| 935 | - if (! $this->_event_model instanceof EEM_Event) { |
|
| 936 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
| 937 | - } |
|
| 938 | - return $this->_event_model; |
|
| 939 | - } |
|
| 940 | - |
|
| 941 | - |
|
| 942 | - /** |
|
| 943 | - * Adds extra buttons to the WP CPT permalink field row. |
|
| 944 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 945 | - * |
|
| 946 | - * @param string $return the current html |
|
| 947 | - * @param int $id the post id for the page |
|
| 948 | - * @param string $new_title What the title is |
|
| 949 | - * @param string $new_slug what the slug is |
|
| 950 | - * @return string The new html string for the permalink area |
|
| 951 | - */ |
|
| 952 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 953 | - { |
|
| 954 | - // make sure this is only when editing |
|
| 955 | - if (! empty($id)) { |
|
| 956 | - $post = get_post($id); |
|
| 957 | - $return .= '<a class="button button--small button--secondary" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
| 958 | - . esc_html__('Shortcode', 'event_espresso') |
|
| 959 | - . '</a> '; |
|
| 960 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
| 961 | - . $post->ID |
|
| 962 | - . ']">'; |
|
| 963 | - } |
|
| 964 | - return $return; |
|
| 965 | - } |
|
| 966 | - |
|
| 967 | - |
|
| 968 | - /** |
|
| 969 | - * _events_overview_list_table |
|
| 970 | - * This contains the logic for showing the events_overview list |
|
| 971 | - * |
|
| 972 | - * @access protected |
|
| 973 | - * @return void |
|
| 974 | - * @throws DomainException |
|
| 975 | - * @throws EE_Error |
|
| 976 | - * @throws InvalidArgumentException |
|
| 977 | - * @throws InvalidDataTypeException |
|
| 978 | - * @throws InvalidInterfaceException |
|
| 979 | - */ |
|
| 980 | - protected function _events_overview_list_table() |
|
| 981 | - { |
|
| 982 | - $after_list_table = []; |
|
| 983 | - $links_html = EEH_HTML::div('', '', 'ee-admin-section ee-layout-stack'); |
|
| 984 | - $links_html .= EEH_HTML::h3(esc_html__('Links', 'event_espresso')); |
|
| 985 | - $links_html .= EEH_HTML::div( |
|
| 986 | - EEH_Template::get_button_or_link( |
|
| 987 | - get_post_type_archive_link('espresso_events'), |
|
| 988 | - esc_html__('View Event Archive Page', 'event_espresso'), |
|
| 989 | - 'button button--small button--secondary' |
|
| 990 | - ), |
|
| 991 | - '', |
|
| 992 | - 'ee-admin-button-row ee-admin-button-row--align-start' |
|
| 993 | - ); |
|
| 994 | - $links_html .= EEH_HTML::divx(); |
|
| 995 | - |
|
| 996 | - $after_list_table['view_event_list_button'] = $links_html; |
|
| 997 | - |
|
| 998 | - $after_list_table['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
| 999 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 1000 | - 'create_new', |
|
| 1001 | - 'add', |
|
| 1002 | - [], |
|
| 1003 | - 'add-new-h2' |
|
| 1004 | - ); |
|
| 1005 | - |
|
| 1006 | - $this->_template_args['after_list_table'] = array_merge( |
|
| 1007 | - (array) $this->_template_args['after_list_table'], |
|
| 1008 | - $after_list_table |
|
| 1009 | - ); |
|
| 1010 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1011 | - } |
|
| 1012 | - |
|
| 1013 | - |
|
| 1014 | - /** |
|
| 1015 | - * this allows for extra misc actions in the default WP publish box |
|
| 1016 | - * |
|
| 1017 | - * @return void |
|
| 1018 | - * @throws DomainException |
|
| 1019 | - * @throws EE_Error |
|
| 1020 | - * @throws InvalidArgumentException |
|
| 1021 | - * @throws InvalidDataTypeException |
|
| 1022 | - * @throws InvalidInterfaceException |
|
| 1023 | - * @throws ReflectionException |
|
| 1024 | - */ |
|
| 1025 | - public function extra_misc_actions_publish_box() |
|
| 1026 | - { |
|
| 1027 | - $this->_generate_publish_box_extra_content(); |
|
| 1028 | - } |
|
| 1029 | - |
|
| 1030 | - |
|
| 1031 | - /** |
|
| 1032 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
| 1033 | - * saved. |
|
| 1034 | - * Typically you would use this to save any additional data. |
|
| 1035 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
| 1036 | - * ALSO very important. When a post transitions from scheduled to published, |
|
| 1037 | - * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from |
|
| 1038 | - * other meta saves. So MAKE sure that you handle this accordingly. |
|
| 1039 | - * |
|
| 1040 | - * @access protected |
|
| 1041 | - * @abstract |
|
| 1042 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 1043 | - * @param object $post The post object of the cpt that was saved. |
|
| 1044 | - * @return void |
|
| 1045 | - * @throws EE_Error |
|
| 1046 | - * @throws InvalidArgumentException |
|
| 1047 | - * @throws InvalidDataTypeException |
|
| 1048 | - * @throws InvalidInterfaceException |
|
| 1049 | - * @throws ReflectionException |
|
| 1050 | - */ |
|
| 1051 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 1052 | - { |
|
| 1053 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
| 1054 | - // get out we're not processing an event save. |
|
| 1055 | - return; |
|
| 1056 | - } |
|
| 1057 | - $event_values = [ |
|
| 1058 | - 'EVT_member_only' => $this->request->getRequestParam('member_only', false, 'bool'), |
|
| 1059 | - 'EVT_allow_overflow' => $this->request->getRequestParam('EVT_allow_overflow', false, 'bool'), |
|
| 1060 | - 'EVT_timezone_string' => $this->request->getRequestParam('timezone_string'), |
|
| 1061 | - ]; |
|
| 1062 | - // check if the new EDTR reg options meta box is being used, and if so, don't run updates for legacy version |
|
| 1063 | - if (! $this->admin_config->useAdvancedEditor() || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1064 | - $event_values['EVT_display_ticket_selector'] = $this->request->getRequestParam( |
|
| 1065 | - 'display_ticket_selector', |
|
| 1066 | - false, |
|
| 1067 | - 'bool' |
|
| 1068 | - ); |
|
| 1069 | - $event_values['EVT_additional_limit'] = min( |
|
| 1070 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
| 1071 | - $this->request->getRequestParam('additional_limit', null, 'int') |
|
| 1072 | - ); |
|
| 1073 | - $event_values['EVT_default_registration_status'] = $this->request->getRequestParam( |
|
| 1074 | - 'EVT_default_registration_status', |
|
| 1075 | - EE_Registry::instance()->CFG->registration->default_STS_ID |
|
| 1076 | - ); |
|
| 1077 | - |
|
| 1078 | - $event_values['EVT_external_URL'] = $this->request->getRequestParam('externalURL'); |
|
| 1079 | - $event_values['EVT_phone'] = $this->request->getRequestParam('event_phone'); |
|
| 1080 | - $event_values['EVT_display_desc'] = $this->request->getRequestParam('display_desc', false, 'bool'); |
|
| 1081 | - } |
|
| 1082 | - // update event |
|
| 1083 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
| 1084 | - // get event_object for other metaboxes... |
|
| 1085 | - // though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. |
|
| 1086 | - // i have to setup where conditions to override the filters in the model |
|
| 1087 | - // that filter out autodraft and inherit statuses so we GET the inherit id! |
|
| 1088 | - $event = $this->_event_model()->get_one( |
|
| 1089 | - [ |
|
| 1090 | - [ |
|
| 1091 | - $this->_event_model()->primary_key_name() => $post_id, |
|
| 1092 | - 'OR' => [ |
|
| 1093 | - 'status' => $post->post_status, |
|
| 1094 | - // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db, |
|
| 1095 | - // but the returned object here has a status of "publish", so use the original post status as well |
|
| 1096 | - 'status*1' => $this->request->getRequestParam('original_post_status'), |
|
| 1097 | - ], |
|
| 1098 | - ], |
|
| 1099 | - ] |
|
| 1100 | - ); |
|
| 1101 | - |
|
| 1102 | - // the following are default callbacks for event attachment updates |
|
| 1103 | - // that can be overridden by caffeinated functionality and/or addons. |
|
| 1104 | - $event_update_callbacks = []; |
|
| 1105 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
| 1106 | - $event_update_callbacks['_default_venue_update'] = [$this, '_default_venue_update']; |
|
| 1107 | - $event_update_callbacks['_default_tickets_update'] = [$this, '_default_tickets_update']; |
|
| 1108 | - } |
|
| 1109 | - $event_update_callbacks = apply_filters( |
|
| 1110 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 1111 | - $event_update_callbacks |
|
| 1112 | - ); |
|
| 1113 | - |
|
| 1114 | - $att_success = true; |
|
| 1115 | - foreach ($event_update_callbacks as $e_callback) { |
|
| 1116 | - $_success = is_callable($e_callback) |
|
| 1117 | - ? $e_callback($event, $this->request->requestParams()) |
|
| 1118 | - : false; |
|
| 1119 | - // if ANY of these updates fail then we want the appropriate global error message |
|
| 1120 | - $att_success = $_success !== false ? $att_success : false; |
|
| 1121 | - } |
|
| 1122 | - // any errors? |
|
| 1123 | - if ($success && $att_success === false) { |
|
| 1124 | - EE_Error::add_error( |
|
| 1125 | - esc_html__( |
|
| 1126 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
| 1127 | - 'event_espresso' |
|
| 1128 | - ), |
|
| 1129 | - __FILE__, |
|
| 1130 | - __FUNCTION__, |
|
| 1131 | - __LINE__ |
|
| 1132 | - ); |
|
| 1133 | - } elseif ($success === false) { |
|
| 1134 | - EE_Error::add_error( |
|
| 1135 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
| 1136 | - __FILE__, |
|
| 1137 | - __FUNCTION__, |
|
| 1138 | - __LINE__ |
|
| 1139 | - ); |
|
| 1140 | - } |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - |
|
| 1144 | - /** |
|
| 1145 | - * @param int $post_id |
|
| 1146 | - * @param int $revision_id |
|
| 1147 | - * @throws EE_Error |
|
| 1148 | - * @throws EE_Error |
|
| 1149 | - * @throws ReflectionException |
|
| 1150 | - * @see parent::restore_item() |
|
| 1151 | - */ |
|
| 1152 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 1153 | - { |
|
| 1154 | - // copy existing event meta to new post |
|
| 1155 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
| 1156 | - if ($post_evt instanceof EE_Event) { |
|
| 1157 | - // meta revision restore |
|
| 1158 | - $post_evt->restore_revision($revision_id); |
|
| 1159 | - // related objs restore |
|
| 1160 | - $post_evt->restore_revision($revision_id, ['Venue', 'Datetime', 'Price']); |
|
| 1161 | - } |
|
| 1162 | - } |
|
| 1163 | - |
|
| 1164 | - |
|
| 1165 | - /** |
|
| 1166 | - * Attach the venue to the Event |
|
| 1167 | - * |
|
| 1168 | - * @param EE_Event $event Event Object to add the venue to |
|
| 1169 | - * @param array $data The request data from the form |
|
| 1170 | - * @return bool Success or fail. |
|
| 1171 | - * @throws EE_Error |
|
| 1172 | - * @throws ReflectionException |
|
| 1173 | - */ |
|
| 1174 | - protected function _default_venue_update(EE_Event $event, $data) |
|
| 1175 | - { |
|
| 1176 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1177 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
| 1178 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
| 1179 | - // very important. If we don't have a venue name... |
|
| 1180 | - // then we'll get out because not necessary to create empty venue |
|
| 1181 | - if (empty($data['venue_title'])) { |
|
| 1182 | - return false; |
|
| 1183 | - } |
|
| 1184 | - $venue_array = [ |
|
| 1185 | - 'VNU_wp_user' => $event->get('EVT_wp_user'), |
|
| 1186 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
| 1187 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
| 1188 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
| 1189 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) |
|
| 1190 | - ? $data['venue_short_description'] |
|
| 1191 | - : null, |
|
| 1192 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
| 1193 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
| 1194 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
| 1195 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
| 1196 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
| 1197 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
| 1198 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
| 1199 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
| 1200 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
| 1201 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
| 1202 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
| 1203 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
| 1204 | - 'status' => 'publish', |
|
| 1205 | - ]; |
|
| 1206 | - // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
| 1207 | - if (! empty($venue_id)) { |
|
| 1208 | - $update_where = [$venue_model->primary_key_name() => $venue_id]; |
|
| 1209 | - $rows_affected = $venue_model->update($venue_array, [$update_where]); |
|
| 1210 | - // we've gotta make sure that the venue is always attached to a revision.. |
|
| 1211 | - // add_relation_to should take care of making sure that the relation is already present. |
|
| 1212 | - $event->_add_relation_to($venue_id, 'Venue'); |
|
| 1213 | - return $rows_affected > 0; |
|
| 1214 | - } |
|
| 1215 | - // we insert the venue |
|
| 1216 | - $venue_id = $venue_model->insert($venue_array); |
|
| 1217 | - $event->_add_relation_to($venue_id, 'Venue'); |
|
| 1218 | - return ! empty($venue_id); |
|
| 1219 | - // when we have the ancestor come in it's already been handled by the revision save. |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - |
|
| 1223 | - /** |
|
| 1224 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 1225 | - * |
|
| 1226 | - * @param EE_Event $event The Event object we're attaching data to |
|
| 1227 | - * @param array $data The request data from the form |
|
| 1228 | - * @return array |
|
| 1229 | - * @throws EE_Error |
|
| 1230 | - * @throws ReflectionException |
|
| 1231 | - * @throws Exception |
|
| 1232 | - */ |
|
| 1233 | - protected function _default_tickets_update(EE_Event $event, $data) |
|
| 1234 | - { |
|
| 1235 | - if ($this->admin_config->useAdvancedEditor()) { |
|
| 1236 | - return []; |
|
| 1237 | - } |
|
| 1238 | - $datetime = null; |
|
| 1239 | - $saved_tickets = []; |
|
| 1240 | - $event_timezone = $event->get_timezone(); |
|
| 1241 | - $date_formats = ['Y-m-d', 'h:i a']; |
|
| 1242 | - foreach ($data['edit_event_datetimes'] as $row => $datetime_data) { |
|
| 1243 | - // trim all values to ensure any excess whitespace is removed. |
|
| 1244 | - $datetime_data = array_map('trim', $datetime_data); |
|
| 1245 | - $datetime_data['DTT_EVT_end'] = |
|
| 1246 | - isset($datetime_data['DTT_EVT_end']) && ! empty($datetime_data['DTT_EVT_end']) |
|
| 1247 | - ? $datetime_data['DTT_EVT_end'] |
|
| 1248 | - : $datetime_data['DTT_EVT_start']; |
|
| 1249 | - $datetime_values = [ |
|
| 1250 | - 'DTT_ID' => ! empty($datetime_data['DTT_ID']) ? $datetime_data['DTT_ID'] : null, |
|
| 1251 | - 'DTT_EVT_start' => $datetime_data['DTT_EVT_start'], |
|
| 1252 | - 'DTT_EVT_end' => $datetime_data['DTT_EVT_end'], |
|
| 1253 | - 'DTT_reg_limit' => empty($datetime_data['DTT_reg_limit']) ? EE_INF : $datetime_data['DTT_reg_limit'], |
|
| 1254 | - 'DTT_order' => $row, |
|
| 1255 | - ]; |
|
| 1256 | - // if we have an id then let's get existing object first and then set the new values. |
|
| 1257 | - // Otherwise we instantiate a new object for save. |
|
| 1258 | - if (! empty($datetime_data['DTT_ID'])) { |
|
| 1259 | - $datetime = EEM_Datetime::instance($event_timezone)->get_one_by_ID($datetime_data['DTT_ID']); |
|
| 1260 | - if (! $datetime instanceof EE_Ticket) { |
|
| 1261 | - throw new RuntimeException( |
|
| 1262 | - sprintf( |
|
| 1263 | - esc_html__( |
|
| 1264 | - 'Something went wrong! A valid Datetime could not be retrieved from the database using the supplied ID: %1$d', |
|
| 1265 | - 'event_espresso' |
|
| 1266 | - ), |
|
| 1267 | - $datetime_data['DTT_ID'] |
|
| 1268 | - ) |
|
| 1269 | - ); |
|
| 1270 | - } |
|
| 1271 | - $datetime->set_date_format($date_formats[0]); |
|
| 1272 | - $datetime->set_time_format($date_formats[1]); |
|
| 1273 | - foreach ($datetime_values as $field => $value) { |
|
| 1274 | - $datetime->set($field, $value); |
|
| 1275 | - } |
|
| 1276 | - } else { |
|
| 1277 | - $datetime = EE_Datetime::new_instance($datetime_values, $event_timezone, $date_formats); |
|
| 1278 | - } |
|
| 1279 | - if (! $datetime instanceof EE_Datetime) { |
|
| 1280 | - throw new RuntimeException( |
|
| 1281 | - sprintf( |
|
| 1282 | - esc_html__( |
|
| 1283 | - 'Something went wrong! A valid Datetime could not be generated or retrieved using the supplied data: %1$s', |
|
| 1284 | - 'event_espresso' |
|
| 1285 | - ), |
|
| 1286 | - print_r($datetime_values, true) |
|
| 1287 | - ) |
|
| 1288 | - ); |
|
| 1289 | - } |
|
| 1290 | - // before going any further make sure our dates are setup correctly |
|
| 1291 | - // so that the end date is always equal or greater than the start date. |
|
| 1292 | - if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) { |
|
| 1293 | - $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start')); |
|
| 1294 | - $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days'); |
|
| 1295 | - } |
|
| 1296 | - $datetime->save(); |
|
| 1297 | - $event->_add_relation_to($datetime, 'Datetime'); |
|
| 1298 | - } |
|
| 1299 | - // no datetimes get deleted so we don't do any of that logic here. |
|
| 1300 | - // update tickets next |
|
| 1301 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : []; |
|
| 1302 | - |
|
| 1303 | - // set up some default start and end dates in case those are not present in the incoming data |
|
| 1304 | - $default_start_date = new DateTime('now', new DateTimeZone($event->get_timezone())); |
|
| 1305 | - $default_start_date = $default_start_date->format($date_formats[0] . ' ' . $date_formats[1]); |
|
| 1306 | - // use the start date of the first datetime for the end date |
|
| 1307 | - $first_datetime = $event->first_datetime(); |
|
| 1308 | - $default_end_date = $first_datetime->start_date_and_time($date_formats[0], $date_formats[1]); |
|
| 1309 | - |
|
| 1310 | - // now process the incoming data |
|
| 1311 | - foreach ($data['edit_tickets'] as $row => $ticket_data) { |
|
| 1312 | - $update_prices = false; |
|
| 1313 | - $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount']) |
|
| 1314 | - ? $data['edit_prices'][ $row ][1]['PRC_amount'] |
|
| 1315 | - : 0; |
|
| 1316 | - // trim inputs to ensure any excess whitespace is removed. |
|
| 1317 | - $ticket_data = array_map('trim', $ticket_data); |
|
| 1318 | - $ticket_values = [ |
|
| 1319 | - 'TKT_ID' => ! empty($ticket_data['TKT_ID']) ? $ticket_data['TKT_ID'] : null, |
|
| 1320 | - 'TTM_ID' => ! empty($ticket_data['TTM_ID']) ? $ticket_data['TTM_ID'] : 0, |
|
| 1321 | - 'TKT_name' => ! empty($ticket_data['TKT_name']) ? $ticket_data['TKT_name'] : '', |
|
| 1322 | - 'TKT_description' => ! empty($ticket_data['TKT_description']) ? $ticket_data['TKT_description'] : '', |
|
| 1323 | - 'TKT_start_date' => ! empty($ticket_data['TKT_start_date']) |
|
| 1324 | - ? $ticket_data['TKT_start_date'] |
|
| 1325 | - : $default_start_date, |
|
| 1326 | - 'TKT_end_date' => ! empty($ticket_data['TKT_end_date']) |
|
| 1327 | - ? $ticket_data['TKT_end_date'] |
|
| 1328 | - : $default_end_date, |
|
| 1329 | - 'TKT_qty' => ! empty($ticket_data['TKT_qty']) |
|
| 1330 | - || (isset($ticket_data['TKT_qty']) && (int) $ticket_data['TKT_qty'] === 0) |
|
| 1331 | - ? $ticket_data['TKT_qty'] |
|
| 1332 | - : EE_INF, |
|
| 1333 | - 'TKT_uses' => ! empty($ticket_data['TKT_uses']) |
|
| 1334 | - || (isset($ticket_data['TKT_uses']) && (int) $ticket_data['TKT_uses'] === 0) |
|
| 1335 | - ? $ticket_data['TKT_uses'] |
|
| 1336 | - : EE_INF, |
|
| 1337 | - 'TKT_min' => ! empty($ticket_data['TKT_min']) ? $ticket_data['TKT_min'] : 0, |
|
| 1338 | - 'TKT_max' => ! empty($ticket_data['TKT_max']) ? $ticket_data['TKT_max'] : EE_INF, |
|
| 1339 | - 'TKT_order' => isset($ticket_data['TKT_order']) ? $ticket_data['TKT_order'] : $row, |
|
| 1340 | - 'TKT_price' => $ticket_price, |
|
| 1341 | - 'TKT_row' => $row, |
|
| 1342 | - ]; |
|
| 1343 | - // if this is a default ticket, then we need to set the TKT_ID to 0 and update accordingly, |
|
| 1344 | - // which means in turn that the prices will become new prices as well. |
|
| 1345 | - if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) { |
|
| 1346 | - $ticket_values['TKT_ID'] = 0; |
|
| 1347 | - $ticket_values['TKT_is_default'] = 0; |
|
| 1348 | - $update_prices = true; |
|
| 1349 | - } |
|
| 1350 | - // if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 1351 | - // we actually do our saves ahead of adding any relations because its entirely possible that this |
|
| 1352 | - // ticket didn't get removed or added to any datetime in the session but DID have it's items modified. |
|
| 1353 | - // keep in mind that if the ticket has been sold (and we have changed pricing information), |
|
| 1354 | - // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
| 1355 | - if (! empty($ticket_data['TKT_ID'])) { |
|
| 1356 | - $existing_ticket = EEM_Ticket::instance($event_timezone)->get_one_by_ID($ticket_data['TKT_ID']); |
|
| 1357 | - if (! $existing_ticket instanceof EE_Ticket) { |
|
| 1358 | - throw new RuntimeException( |
|
| 1359 | - sprintf( |
|
| 1360 | - esc_html__( |
|
| 1361 | - 'Something went wrong! A valid Ticket could not be retrieved from the database using the supplied ID: %1$d', |
|
| 1362 | - 'event_espresso' |
|
| 1363 | - ), |
|
| 1364 | - $ticket_data['TKT_ID'] |
|
| 1365 | - ) |
|
| 1366 | - ); |
|
| 1367 | - } |
|
| 1368 | - $ticket_sold = $existing_ticket->count_related( |
|
| 1369 | - 'Registration', |
|
| 1370 | - [ |
|
| 1371 | - [ |
|
| 1372 | - 'STS_ID' => [ |
|
| 1373 | - 'NOT IN', |
|
| 1374 | - [EEM_Registration::status_id_incomplete], |
|
| 1375 | - ], |
|
| 1376 | - ], |
|
| 1377 | - ] |
|
| 1378 | - ) > 0; |
|
| 1379 | - // let's just check the total price for the existing ticket and determine if it matches the new total price. |
|
| 1380 | - // if they are different then we create a new ticket (if $ticket_sold) |
|
| 1381 | - // if they aren't different then we go ahead and modify existing ticket. |
|
| 1382 | - $create_new_ticket = $ticket_sold |
|
| 1383 | - && $ticket_price !== $existing_ticket->price() |
|
| 1384 | - && ! $existing_ticket->deleted(); |
|
| 1385 | - $existing_ticket->set_date_format($date_formats[0]); |
|
| 1386 | - $existing_ticket->set_time_format($date_formats[1]); |
|
| 1387 | - // set new values |
|
| 1388 | - foreach ($ticket_values as $field => $value) { |
|
| 1389 | - if ($field == 'TKT_qty') { |
|
| 1390 | - $existing_ticket->set_qty($value); |
|
| 1391 | - } elseif ($field == 'TKT_price') { |
|
| 1392 | - $existing_ticket->set('TKT_price', $ticket_price); |
|
| 1393 | - } else { |
|
| 1394 | - $existing_ticket->set($field, $value); |
|
| 1395 | - } |
|
| 1396 | - } |
|
| 1397 | - $ticket = $existing_ticket; |
|
| 1398 | - // if $create_new_ticket is false then we can safely update the existing ticket. |
|
| 1399 | - // Otherwise we have to create a new ticket. |
|
| 1400 | - if ($create_new_ticket) { |
|
| 1401 | - // archive the old ticket first |
|
| 1402 | - $existing_ticket->set('TKT_deleted', 1); |
|
| 1403 | - $existing_ticket->save(); |
|
| 1404 | - // make sure this ticket is still recorded in our $saved_tickets |
|
| 1405 | - // so we don't run it through the regular trash routine. |
|
| 1406 | - $saved_tickets[ $existing_ticket->ID() ] = $existing_ticket; |
|
| 1407 | - // create new ticket that's a copy of the existing except, |
|
| 1408 | - // (a new id of course and not archived) AND has the new TKT_price associated with it. |
|
| 1409 | - $new_ticket = clone $existing_ticket; |
|
| 1410 | - $new_ticket->set('TKT_ID', 0); |
|
| 1411 | - $new_ticket->set('TKT_deleted', 0); |
|
| 1412 | - $new_ticket->set('TKT_sold', 0); |
|
| 1413 | - // now we need to make sure that $new prices are created as well and attached to new ticket. |
|
| 1414 | - $update_prices = true; |
|
| 1415 | - $ticket = $new_ticket; |
|
| 1416 | - } |
|
| 1417 | - } else { |
|
| 1418 | - // no TKT_id so a new ticket |
|
| 1419 | - $ticket_values['TKT_price'] = $ticket_price; |
|
| 1420 | - $ticket = EE_Ticket::new_instance($ticket_values, $event_timezone, $date_formats); |
|
| 1421 | - $update_prices = true; |
|
| 1422 | - } |
|
| 1423 | - if (! $ticket instanceof EE_Ticket) { |
|
| 1424 | - throw new RuntimeException( |
|
| 1425 | - sprintf( |
|
| 1426 | - esc_html__( |
|
| 1427 | - 'Something went wrong! A valid Ticket could not be generated or retrieved using the supplied data: %1$s', |
|
| 1428 | - 'event_espresso' |
|
| 1429 | - ), |
|
| 1430 | - print_r($ticket_values, true) |
|
| 1431 | - ) |
|
| 1432 | - ); |
|
| 1433 | - } |
|
| 1434 | - // cap ticket qty by datetime reg limits |
|
| 1435 | - $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
| 1436 | - // update ticket. |
|
| 1437 | - $ticket->save(); |
|
| 1438 | - // before going any further make sure our dates are setup correctly |
|
| 1439 | - // so that the end date is always equal or greater than the start date. |
|
| 1440 | - if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) { |
|
| 1441 | - $ticket->set('TKT_end_date', $ticket->get('TKT_start_date')); |
|
| 1442 | - $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days'); |
|
| 1443 | - $ticket->save(); |
|
| 1444 | - } |
|
| 1445 | - // initially let's add the ticket to the datetime |
|
| 1446 | - $datetime->_add_relation_to($ticket, 'Ticket'); |
|
| 1447 | - $saved_tickets[ $ticket->ID() ] = $ticket; |
|
| 1448 | - // add prices to ticket |
|
| 1449 | - $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $ticket, $update_prices); |
|
| 1450 | - } |
|
| 1451 | - // however now we need to handle permanently deleting tickets via the ui. |
|
| 1452 | - // Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. |
|
| 1453 | - // However, it does allow for deleting tickets that have no tickets sold, |
|
| 1454 | - // in which case we want to get rid of permanently because there is no need to save in db. |
|
| 1455 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? [] : $old_tickets; |
|
| 1456 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 1457 | - foreach ($tickets_removed as $id) { |
|
| 1458 | - $id = absint($id); |
|
| 1459 | - // get the ticket for this id |
|
| 1460 | - $ticket_to_remove = EEM_Ticket::instance()->get_one_by_ID($id); |
|
| 1461 | - if (! $ticket_to_remove instanceof EE_Ticket) { |
|
| 1462 | - continue; |
|
| 1463 | - } |
|
| 1464 | - // need to get all the related datetimes on this ticket and remove from every single one of them |
|
| 1465 | - // (remember this process can ONLY kick off if there are NO tickets sold) |
|
| 1466 | - $related_datetimes = $ticket_to_remove->get_many_related('Datetime'); |
|
| 1467 | - foreach ($related_datetimes as $related_datetime) { |
|
| 1468 | - $ticket_to_remove->_remove_relation_to($related_datetime, 'Datetime'); |
|
| 1469 | - } |
|
| 1470 | - // need to do the same for prices (except these prices can also be deleted because again, |
|
| 1471 | - // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 1472 | - $ticket_to_remove->delete_related_permanently('Price'); |
|
| 1473 | - // finally let's delete this ticket |
|
| 1474 | - // (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 1475 | - $ticket_to_remove->delete_permanently(); |
|
| 1476 | - } |
|
| 1477 | - return [$datetime, $saved_tickets]; |
|
| 1478 | - } |
|
| 1479 | - |
|
| 1480 | - |
|
| 1481 | - /** |
|
| 1482 | - * This attaches a list of given prices to a ticket. |
|
| 1483 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) |
|
| 1484 | - * because if there is a change in price information on a ticket, a new ticket is created anyways |
|
| 1485 | - * so the archived ticket will retain the old price info and prices are automatically "archived" via the ticket. |
|
| 1486 | - * |
|
| 1487 | - * @access private |
|
| 1488 | - * @param array $prices_data Array of prices from the form. |
|
| 1489 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 1490 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 1491 | - * @return void |
|
| 1492 | - * @throws EE_Error |
|
| 1493 | - * @throws ReflectionException |
|
| 1494 | - */ |
|
| 1495 | - private function _add_prices_to_ticket($prices_data, EE_Ticket $ticket, $new_prices = false) |
|
| 1496 | - { |
|
| 1497 | - $timezone = $ticket->get_timezone(); |
|
| 1498 | - foreach ($prices_data as $row => $price_data) { |
|
| 1499 | - $price_values = [ |
|
| 1500 | - 'PRC_ID' => ! empty($price_data['PRC_ID']) ? $price_data['PRC_ID'] : null, |
|
| 1501 | - 'PRT_ID' => ! empty($price_data['PRT_ID']) ? $price_data['PRT_ID'] : null, |
|
| 1502 | - 'PRC_amount' => ! empty($price_data['PRC_amount']) ? $price_data['PRC_amount'] : 0, |
|
| 1503 | - 'PRC_name' => ! empty($price_data['PRC_name']) ? $price_data['PRC_name'] : '', |
|
| 1504 | - 'PRC_desc' => ! empty($price_data['PRC_desc']) ? $price_data['PRC_desc'] : '', |
|
| 1505 | - 'PRC_is_default' => 0, // make sure prices are NOT set as default from this context |
|
| 1506 | - 'PRC_order' => $row, |
|
| 1507 | - ]; |
|
| 1508 | - if ($new_prices || empty($price_values['PRC_ID'])) { |
|
| 1509 | - $price_values['PRC_ID'] = 0; |
|
| 1510 | - $price = EE_Price::new_instance($price_values, $timezone); |
|
| 1511 | - } else { |
|
| 1512 | - $price = EEM_Price::instance($timezone)->get_one_by_ID($price_data['PRC_ID']); |
|
| 1513 | - // update this price with new values |
|
| 1514 | - foreach ($price_values as $field => $new_price) { |
|
| 1515 | - $price->set($field, $new_price); |
|
| 1516 | - } |
|
| 1517 | - } |
|
| 1518 | - if (! $price instanceof EE_Price) { |
|
| 1519 | - throw new RuntimeException( |
|
| 1520 | - sprintf( |
|
| 1521 | - esc_html__( |
|
| 1522 | - 'Something went wrong! A valid Price could not be generated or retrieved using the supplied data: %1$s', |
|
| 1523 | - 'event_espresso' |
|
| 1524 | - ), |
|
| 1525 | - print_r($price_values, true) |
|
| 1526 | - ) |
|
| 1527 | - ); |
|
| 1528 | - } |
|
| 1529 | - $price->save(); |
|
| 1530 | - $ticket->_add_relation_to($price, 'Price'); |
|
| 1531 | - } |
|
| 1532 | - } |
|
| 1533 | - |
|
| 1534 | - |
|
| 1535 | - /** |
|
| 1536 | - * Add in our autosave ajax handlers |
|
| 1537 | - * |
|
| 1538 | - */ |
|
| 1539 | - protected function _ee_autosave_create_new() |
|
| 1540 | - { |
|
| 1541 | - } |
|
| 1542 | - |
|
| 1543 | - |
|
| 1544 | - /** |
|
| 1545 | - * More autosave handlers. |
|
| 1546 | - */ |
|
| 1547 | - protected function _ee_autosave_edit() |
|
| 1548 | - { |
|
| 1549 | - } |
|
| 1550 | - |
|
| 1551 | - |
|
| 1552 | - /** |
|
| 1553 | - * @throws EE_Error |
|
| 1554 | - * @throws ReflectionException |
|
| 1555 | - */ |
|
| 1556 | - private function _generate_publish_box_extra_content() |
|
| 1557 | - { |
|
| 1558 | - // load formatter helper |
|
| 1559 | - // args for getting related registrations |
|
| 1560 | - $approved_query_args = [ |
|
| 1561 | - [ |
|
| 1562 | - 'REG_deleted' => 0, |
|
| 1563 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1564 | - ], |
|
| 1565 | - ]; |
|
| 1566 | - $not_approved_query_args = [ |
|
| 1567 | - [ |
|
| 1568 | - 'REG_deleted' => 0, |
|
| 1569 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
| 1570 | - ], |
|
| 1571 | - ]; |
|
| 1572 | - $pending_payment_query_args = [ |
|
| 1573 | - [ |
|
| 1574 | - 'REG_deleted' => 0, |
|
| 1575 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
| 1576 | - ], |
|
| 1577 | - ]; |
|
| 1578 | - // publish box |
|
| 1579 | - $publish_box_extra_args = [ |
|
| 1580 | - 'view_approved_reg_url' => add_query_arg( |
|
| 1581 | - [ |
|
| 1582 | - 'action' => 'default', |
|
| 1583 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1584 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
| 1585 | - ], |
|
| 1586 | - REG_ADMIN_URL |
|
| 1587 | - ), |
|
| 1588 | - 'view_not_approved_reg_url' => add_query_arg( |
|
| 1589 | - [ |
|
| 1590 | - 'action' => 'default', |
|
| 1591 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1592 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
| 1593 | - ], |
|
| 1594 | - REG_ADMIN_URL |
|
| 1595 | - ), |
|
| 1596 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
| 1597 | - [ |
|
| 1598 | - 'action' => 'default', |
|
| 1599 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1600 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
| 1601 | - ], |
|
| 1602 | - REG_ADMIN_URL |
|
| 1603 | - ), |
|
| 1604 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1605 | - 'Registration', |
|
| 1606 | - $approved_query_args |
|
| 1607 | - ), |
|
| 1608 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1609 | - 'Registration', |
|
| 1610 | - $not_approved_query_args |
|
| 1611 | - ), |
|
| 1612 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
| 1613 | - 'Registration', |
|
| 1614 | - $pending_payment_query_args |
|
| 1615 | - ), |
|
| 1616 | - 'misc_pub_section_class' => apply_filters( |
|
| 1617 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
| 1618 | - 'misc-pub-section' |
|
| 1619 | - ), |
|
| 1620 | - ]; |
|
| 1621 | - ob_start(); |
|
| 1622 | - do_action( |
|
| 1623 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
| 1624 | - $this->_cpt_model_obj |
|
| 1625 | - ); |
|
| 1626 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
| 1627 | - // load template |
|
| 1628 | - EEH_Template::display_template( |
|
| 1629 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1630 | - $publish_box_extra_args |
|
| 1631 | - ); |
|
| 1632 | - } |
|
| 1633 | - |
|
| 1634 | - |
|
| 1635 | - /** |
|
| 1636 | - * @return EE_Event |
|
| 1637 | - */ |
|
| 1638 | - public function get_event_object() |
|
| 1639 | - { |
|
| 1640 | - return $this->_cpt_model_obj; |
|
| 1641 | - } |
|
| 1642 | - |
|
| 1643 | - |
|
| 1644 | - |
|
| 1645 | - |
|
| 1646 | - /** METABOXES * */ |
|
| 1647 | - /** |
|
| 1648 | - * _register_event_editor_meta_boxes |
|
| 1649 | - * add all metaboxes related to the event_editor |
|
| 1650 | - * |
|
| 1651 | - * @return void |
|
| 1652 | - * @throws EE_Error |
|
| 1653 | - * @throws ReflectionException |
|
| 1654 | - */ |
|
| 1655 | - protected function _register_event_editor_meta_boxes() |
|
| 1656 | - { |
|
| 1657 | - $this->verify_cpt_object(); |
|
| 1658 | - $use_advanced_editor = $this->admin_config->useAdvancedEditor(); |
|
| 1659 | - // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
| 1660 | - if (! $use_advanced_editor || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1661 | - $this->addMetaBox( |
|
| 1662 | - 'espresso_event_editor_event_options', |
|
| 1663 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
| 1664 | - [$this, 'registration_options_meta_box'], |
|
| 1665 | - $this->page_slug, |
|
| 1666 | - 'side' |
|
| 1667 | - ); |
|
| 1668 | - } |
|
| 1669 | - if (! $use_advanced_editor) { |
|
| 1670 | - $this->addMetaBox( |
|
| 1671 | - 'espresso_event_editor_tickets', |
|
| 1672 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
| 1673 | - [$this, 'ticket_metabox'], |
|
| 1674 | - $this->page_slug, |
|
| 1675 | - 'normal', |
|
| 1676 | - 'high' |
|
| 1677 | - ); |
|
| 1678 | - } elseif ($this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1679 | - add_action( |
|
| 1680 | - 'add_meta_boxes_espresso_events', |
|
| 1681 | - function () { |
|
| 1682 | - global $current_screen; |
|
| 1683 | - remove_meta_box('authordiv', $current_screen, 'normal'); |
|
| 1684 | - }, |
|
| 1685 | - 99 |
|
| 1686 | - ); |
|
| 1687 | - } |
|
| 1688 | - // NOTE: if you're looking for other metaboxes in here, |
|
| 1689 | - // where a metabox has a related management page in the admin |
|
| 1690 | - // you will find it setup in the related management page's "_Hooks" file. |
|
| 1691 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
| 1692 | - } |
|
| 1693 | - |
|
| 1694 | - |
|
| 1695 | - /** |
|
| 1696 | - * @throws DomainException |
|
| 1697 | - * @throws EE_Error |
|
| 1698 | - * @throws ReflectionException |
|
| 1699 | - */ |
|
| 1700 | - public function ticket_metabox() |
|
| 1701 | - { |
|
| 1702 | - $existing_datetime_ids = $existing_ticket_ids = []; |
|
| 1703 | - // defaults for template args |
|
| 1704 | - $template_args = [ |
|
| 1705 | - 'existing_datetime_ids' => '', |
|
| 1706 | - 'event_datetime_help_link' => '', |
|
| 1707 | - 'ticket_options_help_link' => '', |
|
| 1708 | - 'time' => null, |
|
| 1709 | - 'ticket_rows' => '', |
|
| 1710 | - 'existing_ticket_ids' => '', |
|
| 1711 | - 'total_ticket_rows' => 1, |
|
| 1712 | - 'ticket_js_structure' => '', |
|
| 1713 | - 'trash_icon' => 'dashicons dashicons-lock', |
|
| 1714 | - 'disabled' => '', |
|
| 1715 | - ]; |
|
| 1716 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1717 | - /** |
|
| 1718 | - * 1. Start with retrieving Datetimes |
|
| 1719 | - * 2. Fore each datetime get related tickets |
|
| 1720 | - * 3. For each ticket get related prices |
|
| 1721 | - */ |
|
| 1722 | - /** @var EEM_Datetime $datetime_model */ |
|
| 1723 | - $datetime_model = EE_Registry::instance()->load_model('Datetime'); |
|
| 1724 | - /** @var EEM_Ticket $datetime_model */ |
|
| 1725 | - $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
| 1726 | - $times = $datetime_model->get_all_event_dates($event_id); |
|
| 1727 | - /** @type EE_Datetime $first_datetime */ |
|
| 1728 | - $first_datetime = reset($times); |
|
| 1729 | - // do we get related tickets? |
|
| 1730 | - if ( |
|
| 1731 | - $first_datetime instanceof EE_Datetime |
|
| 1732 | - && $first_datetime->ID() !== 0 |
|
| 1733 | - ) { |
|
| 1734 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
| 1735 | - $template_args['time'] = $first_datetime; |
|
| 1736 | - $related_tickets = $first_datetime->tickets( |
|
| 1737 | - [ |
|
| 1738 | - ['OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0]], |
|
| 1739 | - 'default_where_conditions' => 'none', |
|
| 1740 | - ] |
|
| 1741 | - ); |
|
| 1742 | - if (! empty($related_tickets)) { |
|
| 1743 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
| 1744 | - $row = 0; |
|
| 1745 | - foreach ($related_tickets as $ticket) { |
|
| 1746 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1747 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
| 1748 | - $row++; |
|
| 1749 | - } |
|
| 1750 | - } else { |
|
| 1751 | - $template_args['total_ticket_rows'] = 1; |
|
| 1752 | - /** @type EE_Ticket $ticket */ |
|
| 1753 | - $ticket = $ticket_model->create_default_object(); |
|
| 1754 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
| 1755 | - } |
|
| 1756 | - } else { |
|
| 1757 | - $template_args['time'] = $times[0]; |
|
| 1758 | - /** @type EE_Ticket[] $tickets */ |
|
| 1759 | - $tickets = $ticket_model->get_all_default_tickets(); |
|
| 1760 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($tickets[1]); |
|
| 1761 | - // NOTE: we're just sending the first default row |
|
| 1762 | - // (decaf can't manage default tickets so this should be sufficient); |
|
| 1763 | - } |
|
| 1764 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
| 1765 | - 'event_editor_event_datetimes_help_tab' |
|
| 1766 | - ); |
|
| 1767 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
| 1768 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1769 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1770 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
| 1771 | - $ticket_model->create_default_object(), |
|
| 1772 | - true |
|
| 1773 | - ); |
|
| 1774 | - $template = apply_filters( |
|
| 1775 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
| 1776 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1777 | - ); |
|
| 1778 | - EEH_Template::display_template($template, $template_args); |
|
| 1779 | - } |
|
| 1780 | - |
|
| 1781 | - |
|
| 1782 | - /** |
|
| 1783 | - * Setup an individual ticket form for the decaf event editor page |
|
| 1784 | - * |
|
| 1785 | - * @access private |
|
| 1786 | - * @param EE_Ticket $ticket the ticket object |
|
| 1787 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
| 1788 | - * @param int $row |
|
| 1789 | - * @return string generated html for the ticket row. |
|
| 1790 | - * @throws EE_Error |
|
| 1791 | - * @throws ReflectionException |
|
| 1792 | - */ |
|
| 1793 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
| 1794 | - { |
|
| 1795 | - $template_args = [ |
|
| 1796 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1797 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
| 1798 | - : '', |
|
| 1799 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
| 1800 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
| 1801 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
| 1802 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
| 1803 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
| 1804 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
| 1805 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1806 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
| 1807 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
| 1808 | - 'trash_icon' => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1809 | - && (! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1810 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'dashicons dashicons-lock', |
|
| 1811 | - 'disabled' => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1812 | - : ' disabled=disabled', |
|
| 1813 | - ]; |
|
| 1814 | - $price = $ticket->ID() !== 0 |
|
| 1815 | - ? $ticket->get_first_related('Price', ['default_where_conditions' => 'none']) |
|
| 1816 | - : null; |
|
| 1817 | - $price = $price instanceof EE_Price |
|
| 1818 | - ? $price |
|
| 1819 | - : EEM_Price::instance()->create_default_object(); |
|
| 1820 | - $price_args = [ |
|
| 1821 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1822 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
| 1823 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
| 1824 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
| 1825 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
| 1826 | - ]; |
|
| 1827 | - // make sure we have default start and end dates if skeleton |
|
| 1828 | - // handle rows that should NOT be empty |
|
| 1829 | - if (empty($template_args['TKT_start_date'])) { |
|
| 1830 | - // if empty then the start date will be now. |
|
| 1831 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
| 1832 | - } |
|
| 1833 | - if (empty($template_args['TKT_end_date'])) { |
|
| 1834 | - // get the earliest datetime (if present); |
|
| 1835 | - $earliest_datetime = $this->_cpt_model_obj->ID() > 0 |
|
| 1836 | - ? $this->_cpt_model_obj->get_first_related( |
|
| 1837 | - 'Datetime', |
|
| 1838 | - ['order_by' => ['DTT_EVT_start' => 'ASC']] |
|
| 1839 | - ) |
|
| 1840 | - : null; |
|
| 1841 | - $template_args['TKT_end_date'] = $earliest_datetime instanceof EE_Datetime |
|
| 1842 | - ? $earliest_datetime->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a') |
|
| 1843 | - : date('Y-m-d h:i a', mktime(0, 0, 0, date('m'), date('d') + 7, date('Y'))); |
|
| 1844 | - } |
|
| 1845 | - $template_args = array_merge($template_args, $price_args); |
|
| 1846 | - $template = apply_filters( |
|
| 1847 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
| 1848 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1849 | - $ticket |
|
| 1850 | - ); |
|
| 1851 | - return EEH_Template::display_template($template, $template_args, true); |
|
| 1852 | - } |
|
| 1853 | - |
|
| 1854 | - |
|
| 1855 | - /** |
|
| 1856 | - * @throws EE_Error |
|
| 1857 | - * @throws ReflectionException |
|
| 1858 | - */ |
|
| 1859 | - public function registration_options_meta_box() |
|
| 1860 | - { |
|
| 1861 | - $yes_no_values = [ |
|
| 1862 | - ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
| 1863 | - ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
| 1864 | - ]; |
|
| 1865 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 1866 | - [ |
|
| 1867 | - EEM_Registration::status_id_cancelled, |
|
| 1868 | - EEM_Registration::status_id_declined, |
|
| 1869 | - EEM_Registration::status_id_incomplete, |
|
| 1870 | - ], |
|
| 1871 | - true |
|
| 1872 | - ); |
|
| 1873 | - // $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
| 1874 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
| 1875 | - $template_args['event'] = $this->_cpt_model_obj; |
|
| 1876 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 1877 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 1878 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 1879 | - 'default_reg_status', |
|
| 1880 | - $default_reg_status_values, |
|
| 1881 | - $this->_cpt_model_obj->default_registration_status() |
|
| 1882 | - ); |
|
| 1883 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1884 | - 'display_desc', |
|
| 1885 | - $yes_no_values, |
|
| 1886 | - $this->_cpt_model_obj->display_description() |
|
| 1887 | - ); |
|
| 1888 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1889 | - 'display_ticket_selector', |
|
| 1890 | - $yes_no_values, |
|
| 1891 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
| 1892 | - '', |
|
| 1893 | - '', |
|
| 1894 | - false |
|
| 1895 | - ); |
|
| 1896 | - $template_args['additional_registration_options'] = apply_filters( |
|
| 1897 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 1898 | - '', |
|
| 1899 | - $template_args, |
|
| 1900 | - $yes_no_values, |
|
| 1901 | - $default_reg_status_values |
|
| 1902 | - ); |
|
| 1903 | - EEH_Template::display_template( |
|
| 1904 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1905 | - $template_args |
|
| 1906 | - ); |
|
| 1907 | - } |
|
| 1908 | - |
|
| 1909 | - |
|
| 1910 | - /** |
|
| 1911 | - * _get_events() |
|
| 1912 | - * This method simply returns all the events (for the given _view and paging) |
|
| 1913 | - * |
|
| 1914 | - * @access public |
|
| 1915 | - * @param int $per_page count of items per page (20 default); |
|
| 1916 | - * @param int $current_page what is the current page being viewed. |
|
| 1917 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
| 1918 | - * If FALSE then we return an array of event objects |
|
| 1919 | - * that match the given _view and paging parameters. |
|
| 1920 | - * @return array|int an array of event objects or a count of them. |
|
| 1921 | - * @throws Exception |
|
| 1922 | - */ |
|
| 1923 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
| 1924 | - { |
|
| 1925 | - $EEM_Event = $this->_event_model(); |
|
| 1926 | - $offset = ($current_page - 1) * $per_page; |
|
| 1927 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1928 | - $orderby = $this->request->getRequestParam('orderby', 'EVT_ID'); |
|
| 1929 | - $order = $this->request->getRequestParam('order', 'DESC'); |
|
| 1930 | - $month_range = $this->request->getRequestParam('month_range'); |
|
| 1931 | - if ($month_range) { |
|
| 1932 | - $pieces = explode(' ', $month_range, 3); |
|
| 1933 | - // simulate the FIRST day of the month, that fixes issues for months like February |
|
| 1934 | - // where PHP doesn't know what to assume for date. |
|
| 1935 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
| 1936 | - $month_r = ! empty($pieces[0]) ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
| 1937 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1938 | - } |
|
| 1939 | - $where = []; |
|
| 1940 | - $status = $this->request->getRequestParam('status'); |
|
| 1941 | - // determine what post_status our condition will have for the query. |
|
| 1942 | - switch ($status) { |
|
| 1943 | - case 'month': |
|
| 1944 | - case 'today': |
|
| 1945 | - case null: |
|
| 1946 | - case 'all': |
|
| 1947 | - break; |
|
| 1948 | - case 'draft': |
|
| 1949 | - $where['status'] = ['IN', ['draft', 'auto-draft']]; |
|
| 1950 | - break; |
|
| 1951 | - default: |
|
| 1952 | - $where['status'] = $status; |
|
| 1953 | - } |
|
| 1954 | - // categories? The default for all categories is -1 |
|
| 1955 | - $category = $this->request->getRequestParam('EVT_CAT', -1, 'int'); |
|
| 1956 | - if ($category !== -1) { |
|
| 1957 | - $where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY; |
|
| 1958 | - $where['Term_Taxonomy.term_id'] = $category; |
|
| 1959 | - } |
|
| 1960 | - // date where conditions |
|
| 1961 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
| 1962 | - if ($month_range) { |
|
| 1963 | - $DateTime = new DateTime( |
|
| 1964 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1965 | - new DateTimeZone('UTC') |
|
| 1966 | - ); |
|
| 1967 | - $start = $DateTime->getTimestamp(); |
|
| 1968 | - // set the datetime to be the end of the month |
|
| 1969 | - $DateTime->setDate( |
|
| 1970 | - $year_r, |
|
| 1971 | - $month_r, |
|
| 1972 | - $DateTime->format('t') |
|
| 1973 | - )->setTime(23, 59, 59); |
|
| 1974 | - $end = $DateTime->getTimestamp(); |
|
| 1975 | - $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]]; |
|
| 1976 | - } elseif ($status === 'today') { |
|
| 1977 | - $DateTime = |
|
| 1978 | - new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1979 | - $start = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats)); |
|
| 1980 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
| 1981 | - $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]]; |
|
| 1982 | - } elseif ($status === 'month') { |
|
| 1983 | - $now = date('Y-m-01'); |
|
| 1984 | - $DateTime = |
|
| 1985 | - new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1986 | - $start = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats)); |
|
| 1987 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
| 1988 | - ->setTime(23, 59, 59) |
|
| 1989 | - ->format(implode(' ', $start_formats)); |
|
| 1990 | - $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]]; |
|
| 1991 | - } |
|
| 1992 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1993 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
| 1994 | - } else { |
|
| 1995 | - if (! isset($where['status'])) { |
|
| 1996 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1997 | - $where['OR'] = [ |
|
| 1998 | - 'status*restrict_private' => ['!=', 'private'], |
|
| 1999 | - 'AND' => [ |
|
| 2000 | - 'status*inclusive' => ['=', 'private'], |
|
| 2001 | - 'EVT_wp_user' => get_current_user_id(), |
|
| 2002 | - ], |
|
| 2003 | - ]; |
|
| 2004 | - } |
|
| 2005 | - } |
|
| 2006 | - } |
|
| 2007 | - $wp_user = $this->request->getRequestParam('EVT_wp_user', 0, 'int'); |
|
| 2008 | - if ( |
|
| 2009 | - $wp_user |
|
| 2010 | - && $wp_user !== get_current_user_id() |
|
| 2011 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
| 2012 | - ) { |
|
| 2013 | - $where['EVT_wp_user'] = $wp_user; |
|
| 2014 | - } |
|
| 2015 | - // search query handling |
|
| 2016 | - $search_term = $this->request->getRequestParam('s'); |
|
| 2017 | - if ($search_term) { |
|
| 2018 | - $search_term = '%' . $search_term . '%'; |
|
| 2019 | - $where['OR'] = [ |
|
| 2020 | - 'EVT_name' => ['LIKE', $search_term], |
|
| 2021 | - 'EVT_desc' => ['LIKE', $search_term], |
|
| 2022 | - 'EVT_short_desc' => ['LIKE', $search_term], |
|
| 2023 | - ]; |
|
| 2024 | - } |
|
| 2025 | - // filter events by venue. |
|
| 2026 | - $venue = $this->request->getRequestParam('venue', 0, 'int'); |
|
| 2027 | - if ($venue) { |
|
| 2028 | - $where['Venue.VNU_ID'] = $venue; |
|
| 2029 | - } |
|
| 2030 | - $request_params = $this->request->requestParams(); |
|
| 2031 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $request_params); |
|
| 2032 | - $query_params = apply_filters( |
|
| 2033 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
| 2034 | - [ |
|
| 2035 | - $where, |
|
| 2036 | - 'limit' => $limit, |
|
| 2037 | - 'order_by' => $orderby, |
|
| 2038 | - 'order' => $order, |
|
| 2039 | - 'group_by' => 'EVT_ID', |
|
| 2040 | - ], |
|
| 2041 | - $request_params |
|
| 2042 | - ); |
|
| 2043 | - |
|
| 2044 | - // let's first check if we have special requests coming in. |
|
| 2045 | - $active_status = $this->request->getRequestParam('active_status'); |
|
| 2046 | - if ($active_status) { |
|
| 2047 | - switch ($active_status) { |
|
| 2048 | - case 'upcoming': |
|
| 2049 | - return $EEM_Event->get_upcoming_events($query_params, $count); |
|
| 2050 | - case 'expired': |
|
| 2051 | - return $EEM_Event->get_expired_events($query_params, $count); |
|
| 2052 | - case 'active': |
|
| 2053 | - return $EEM_Event->get_active_events($query_params, $count); |
|
| 2054 | - case 'inactive': |
|
| 2055 | - return $EEM_Event->get_inactive_events($query_params, $count); |
|
| 2056 | - } |
|
| 2057 | - } |
|
| 2058 | - |
|
| 2059 | - return $count ? $EEM_Event->count([$where], 'EVT_ID', true) : $EEM_Event->get_all($query_params); |
|
| 2060 | - } |
|
| 2061 | - |
|
| 2062 | - |
|
| 2063 | - /** |
|
| 2064 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
| 2065 | - * |
|
| 2066 | - * @param string $post_id |
|
| 2067 | - * @throws EE_Error |
|
| 2068 | - * @throws ReflectionException |
|
| 2069 | - */ |
|
| 2070 | - public function trash_cpt_item($post_id) |
|
| 2071 | - { |
|
| 2072 | - $this->request->setRequestParam('EVT_ID', $post_id); |
|
| 2073 | - $this->_trash_or_restore_event('trash', false); |
|
| 2074 | - } |
|
| 2075 | - |
|
| 2076 | - |
|
| 2077 | - /** |
|
| 2078 | - * @param string $post_id |
|
| 2079 | - * @throws EE_Error |
|
| 2080 | - * @throws ReflectionException |
|
| 2081 | - */ |
|
| 2082 | - public function restore_cpt_item($post_id) |
|
| 2083 | - { |
|
| 2084 | - $this->request->setRequestParam('EVT_ID', $post_id); |
|
| 2085 | - $this->_trash_or_restore_event('draft', false); |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - |
|
| 2089 | - /** |
|
| 2090 | - * @param string $post_id |
|
| 2091 | - * @throws EE_Error |
|
| 2092 | - * @throws EE_Error |
|
| 2093 | - */ |
|
| 2094 | - public function delete_cpt_item($post_id) |
|
| 2095 | - { |
|
| 2096 | - throw new EE_Error( |
|
| 2097 | - esc_html__( |
|
| 2098 | - 'Please contact Event Espresso support with the details of the steps taken to produce this error.', |
|
| 2099 | - 'event_espresso' |
|
| 2100 | - ) |
|
| 2101 | - ); |
|
| 2102 | - // $this->request->setRequestParam('EVT_ID', $post_id); |
|
| 2103 | - // $this->_delete_event(); |
|
| 2104 | - } |
|
| 2105 | - |
|
| 2106 | - |
|
| 2107 | - /** |
|
| 2108 | - * _trash_or_restore_event |
|
| 2109 | - * |
|
| 2110 | - * @access protected |
|
| 2111 | - * @param string $event_status |
|
| 2112 | - * @param bool $redirect_after |
|
| 2113 | - * @throws EE_Error |
|
| 2114 | - * @throws EE_Error |
|
| 2115 | - * @throws ReflectionException |
|
| 2116 | - */ |
|
| 2117 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
| 2118 | - { |
|
| 2119 | - // determine the event id and set to array. |
|
| 2120 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 2121 | - // loop thru events |
|
| 2122 | - if ($EVT_ID) { |
|
| 2123 | - // clean status |
|
| 2124 | - $event_status = sanitize_key($event_status); |
|
| 2125 | - // grab status |
|
| 2126 | - if (! empty($event_status)) { |
|
| 2127 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
| 2128 | - } else { |
|
| 2129 | - $success = false; |
|
| 2130 | - $msg = esc_html__( |
|
| 2131 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 2132 | - 'event_espresso' |
|
| 2133 | - ); |
|
| 2134 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2135 | - } |
|
| 2136 | - } else { |
|
| 2137 | - $success = false; |
|
| 2138 | - $msg = esc_html__( |
|
| 2139 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 2140 | - 'event_espresso' |
|
| 2141 | - ); |
|
| 2142 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2143 | - } |
|
| 2144 | - $action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 2145 | - if ($redirect_after) { |
|
| 2146 | - $this->_redirect_after_action($success, 'Event', $action, ['action' => 'default']); |
|
| 2147 | - } |
|
| 2148 | - } |
|
| 2149 | - |
|
| 2150 | - |
|
| 2151 | - /** |
|
| 2152 | - * _trash_or_restore_events |
|
| 2153 | - * |
|
| 2154 | - * @access protected |
|
| 2155 | - * @param string $event_status |
|
| 2156 | - * @return void |
|
| 2157 | - * @throws EE_Error |
|
| 2158 | - * @throws EE_Error |
|
| 2159 | - * @throws ReflectionException |
|
| 2160 | - */ |
|
| 2161 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
| 2162 | - { |
|
| 2163 | - // clean status |
|
| 2164 | - $event_status = sanitize_key($event_status); |
|
| 2165 | - // grab status |
|
| 2166 | - if (! empty($event_status)) { |
|
| 2167 | - $success = true; |
|
| 2168 | - // determine the event id and set to array. |
|
| 2169 | - $EVT_IDs = $this->request->getRequestParam('EVT_IDs', [], 'int', true); |
|
| 2170 | - // loop thru events |
|
| 2171 | - foreach ($EVT_IDs as $EVT_ID) { |
|
| 2172 | - if ($EVT_ID = absint($EVT_ID)) { |
|
| 2173 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
| 2174 | - $success = $results !== false ? $success : false; |
|
| 2175 | - } else { |
|
| 2176 | - $msg = sprintf( |
|
| 2177 | - esc_html__( |
|
| 2178 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 2179 | - 'event_espresso' |
|
| 2180 | - ), |
|
| 2181 | - $EVT_ID |
|
| 2182 | - ); |
|
| 2183 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2184 | - $success = false; |
|
| 2185 | - } |
|
| 2186 | - } |
|
| 2187 | - } else { |
|
| 2188 | - $success = false; |
|
| 2189 | - $msg = esc_html__( |
|
| 2190 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 2191 | - 'event_espresso' |
|
| 2192 | - ); |
|
| 2193 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2194 | - } |
|
| 2195 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2196 | - $success = $success ? 2 : false; |
|
| 2197 | - $action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 2198 | - $this->_redirect_after_action($success, 'Events', $action, ['action' => 'default']); |
|
| 2199 | - } |
|
| 2200 | - |
|
| 2201 | - |
|
| 2202 | - /** |
|
| 2203 | - * @param int $EVT_ID |
|
| 2204 | - * @param string $event_status |
|
| 2205 | - * @return bool |
|
| 2206 | - * @throws EE_Error |
|
| 2207 | - * @throws ReflectionException |
|
| 2208 | - */ |
|
| 2209 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
| 2210 | - { |
|
| 2211 | - // grab event id |
|
| 2212 | - if (! $EVT_ID) { |
|
| 2213 | - $msg = esc_html__( |
|
| 2214 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2215 | - 'event_espresso' |
|
| 2216 | - ); |
|
| 2217 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2218 | - return false; |
|
| 2219 | - } |
|
| 2220 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2221 | - // clean status |
|
| 2222 | - $event_status = sanitize_key($event_status); |
|
| 2223 | - // grab status |
|
| 2224 | - if (empty($event_status)) { |
|
| 2225 | - $msg = esc_html__( |
|
| 2226 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
| 2227 | - 'event_espresso' |
|
| 2228 | - ); |
|
| 2229 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2230 | - return false; |
|
| 2231 | - } |
|
| 2232 | - // was event trashed or restored ? |
|
| 2233 | - switch ($event_status) { |
|
| 2234 | - case 'draft': |
|
| 2235 | - $action = 'restored from the trash'; |
|
| 2236 | - $hook = 'AHEE_event_restored_from_trash'; |
|
| 2237 | - break; |
|
| 2238 | - case 'trash': |
|
| 2239 | - $action = 'moved to the trash'; |
|
| 2240 | - $hook = 'AHEE_event_moved_to_trash'; |
|
| 2241 | - break; |
|
| 2242 | - default: |
|
| 2243 | - $action = 'updated'; |
|
| 2244 | - $hook = false; |
|
| 2245 | - } |
|
| 2246 | - // use class to change status |
|
| 2247 | - $this->_cpt_model_obj->set_status($event_status); |
|
| 2248 | - $success = $this->_cpt_model_obj->save(); |
|
| 2249 | - if (! $success) { |
|
| 2250 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 2251 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2252 | - return false; |
|
| 2253 | - } |
|
| 2254 | - if ($hook) { |
|
| 2255 | - do_action($hook); |
|
| 2256 | - } |
|
| 2257 | - return true; |
|
| 2258 | - } |
|
| 2259 | - |
|
| 2260 | - |
|
| 2261 | - /** |
|
| 2262 | - * @param array $event_ids |
|
| 2263 | - * @return array |
|
| 2264 | - * @since 4.10.23.p |
|
| 2265 | - */ |
|
| 2266 | - private function cleanEventIds(array $event_ids) |
|
| 2267 | - { |
|
| 2268 | - return array_map('absint', $event_ids); |
|
| 2269 | - } |
|
| 2270 | - |
|
| 2271 | - |
|
| 2272 | - /** |
|
| 2273 | - * @return array |
|
| 2274 | - * @since 4.10.23.p |
|
| 2275 | - */ |
|
| 2276 | - private function getEventIdsFromRequest() |
|
| 2277 | - { |
|
| 2278 | - if ($this->request->requestParamIsSet('EVT_IDs')) { |
|
| 2279 | - return $this->request->getRequestParam('EVT_IDs', [], 'int', true); |
|
| 2280 | - } else { |
|
| 2281 | - return $this->request->getRequestParam('EVT_ID', [], 'int', true); |
|
| 2282 | - } |
|
| 2283 | - } |
|
| 2284 | - |
|
| 2285 | - |
|
| 2286 | - /** |
|
| 2287 | - * @param bool $preview_delete |
|
| 2288 | - * @throws EE_Error |
|
| 2289 | - */ |
|
| 2290 | - protected function _delete_event($preview_delete = true) |
|
| 2291 | - { |
|
| 2292 | - $this->_delete_events($preview_delete); |
|
| 2293 | - } |
|
| 2294 | - |
|
| 2295 | - |
|
| 2296 | - /** |
|
| 2297 | - * Gets the tree traversal batch persister. |
|
| 2298 | - * |
|
| 2299 | - * @return NodeGroupDao |
|
| 2300 | - * @throws InvalidArgumentException |
|
| 2301 | - * @throws InvalidDataTypeException |
|
| 2302 | - * @throws InvalidInterfaceException |
|
| 2303 | - * @since 4.10.12.p |
|
| 2304 | - */ |
|
| 2305 | - protected function getModelObjNodeGroupPersister() |
|
| 2306 | - { |
|
| 2307 | - if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) { |
|
| 2308 | - $this->model_obj_node_group_persister = |
|
| 2309 | - $this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao'); |
|
| 2310 | - } |
|
| 2311 | - return $this->model_obj_node_group_persister; |
|
| 2312 | - } |
|
| 2313 | - |
|
| 2314 | - |
|
| 2315 | - /** |
|
| 2316 | - * @param bool $preview_delete |
|
| 2317 | - * @return void |
|
| 2318 | - * @throws EE_Error |
|
| 2319 | - */ |
|
| 2320 | - protected function _delete_events($preview_delete = true) |
|
| 2321 | - { |
|
| 2322 | - $event_ids = $this->getEventIdsFromRequest(); |
|
| 2323 | - if ($preview_delete) { |
|
| 2324 | - $this->generateDeletionPreview($event_ids); |
|
| 2325 | - } else { |
|
| 2326 | - EEM_Event::instance()->delete_permanently([['EVT_ID' => ['IN', $event_ids]]]); |
|
| 2327 | - } |
|
| 2328 | - } |
|
| 2329 | - |
|
| 2330 | - |
|
| 2331 | - /** |
|
| 2332 | - * @param array $event_ids |
|
| 2333 | - */ |
|
| 2334 | - protected function generateDeletionPreview(array $event_ids) |
|
| 2335 | - { |
|
| 2336 | - $event_ids = $this->cleanEventIds($event_ids); |
|
| 2337 | - // Set a code we can use to reference this deletion task in the batch jobs and preview page. |
|
| 2338 | - $deletion_job_code = $this->getModelObjNodeGroupPersister()->generateGroupCode(); |
|
| 2339 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2340 | - [ |
|
| 2341 | - 'action' => 'preview_deletion', |
|
| 2342 | - 'deletion_job_code' => $deletion_job_code, |
|
| 2343 | - ], |
|
| 2344 | - $this->_admin_base_url |
|
| 2345 | - ); |
|
| 2346 | - EEH_URL::safeRedirectAndExit( |
|
| 2347 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 2348 | - [ |
|
| 2349 | - 'page' => 'espresso_batch', |
|
| 2350 | - 'batch' => EED_Batch::batch_job, |
|
| 2351 | - 'EVT_IDs' => $event_ids, |
|
| 2352 | - 'deletion_job_code' => $deletion_job_code, |
|
| 2353 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'), |
|
| 2354 | - 'return_url' => urlencode($return_url), |
|
| 2355 | - ], |
|
| 2356 | - admin_url() |
|
| 2357 | - ) |
|
| 2358 | - ); |
|
| 2359 | - } |
|
| 2360 | - |
|
| 2361 | - |
|
| 2362 | - /** |
|
| 2363 | - * Checks for a POST submission |
|
| 2364 | - * |
|
| 2365 | - * @since 4.10.12.p |
|
| 2366 | - */ |
|
| 2367 | - protected function confirmDeletion() |
|
| 2368 | - { |
|
| 2369 | - $deletion_redirect_logic = |
|
| 2370 | - $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion'); |
|
| 2371 | - $deletion_redirect_logic->handle($this->get_request_data(), $this->admin_base_url()); |
|
| 2372 | - } |
|
| 2373 | - |
|
| 2374 | - |
|
| 2375 | - /** |
|
| 2376 | - * A page for users to preview what exactly will be deleted, and confirm they want to delete it. |
|
| 2377 | - * |
|
| 2378 | - * @throws EE_Error |
|
| 2379 | - * @since 4.10.12.p |
|
| 2380 | - */ |
|
| 2381 | - protected function previewDeletion() |
|
| 2382 | - { |
|
| 2383 | - $preview_deletion_logic = |
|
| 2384 | - $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\PreviewDeletion'); |
|
| 2385 | - $this->set_template_args($preview_deletion_logic->handle($this->get_request_data(), $this->admin_base_url())); |
|
| 2386 | - $this->display_admin_page_with_no_sidebar(); |
|
| 2387 | - } |
|
| 2388 | - |
|
| 2389 | - |
|
| 2390 | - /** |
|
| 2391 | - * get total number of events |
|
| 2392 | - * |
|
| 2393 | - * @access public |
|
| 2394 | - * @return int |
|
| 2395 | - * @throws EE_Error |
|
| 2396 | - * @throws EE_Error |
|
| 2397 | - */ |
|
| 2398 | - public function total_events() |
|
| 2399 | - { |
|
| 2400 | - return EEM_Event::instance()->count( |
|
| 2401 | - ['caps' => 'read_admin'], |
|
| 2402 | - 'EVT_ID', |
|
| 2403 | - true |
|
| 2404 | - ); |
|
| 2405 | - } |
|
| 2406 | - |
|
| 2407 | - |
|
| 2408 | - /** |
|
| 2409 | - * get total number of draft events |
|
| 2410 | - * |
|
| 2411 | - * @access public |
|
| 2412 | - * @return int |
|
| 2413 | - * @throws EE_Error |
|
| 2414 | - * @throws EE_Error |
|
| 2415 | - */ |
|
| 2416 | - public function total_events_draft() |
|
| 2417 | - { |
|
| 2418 | - return EEM_Event::instance()->count( |
|
| 2419 | - [ |
|
| 2420 | - ['status' => ['IN', ['draft', 'auto-draft']]], |
|
| 2421 | - 'caps' => 'read_admin', |
|
| 2422 | - ], |
|
| 2423 | - 'EVT_ID', |
|
| 2424 | - true |
|
| 2425 | - ); |
|
| 2426 | - } |
|
| 2427 | - |
|
| 2428 | - |
|
| 2429 | - /** |
|
| 2430 | - * get total number of trashed events |
|
| 2431 | - * |
|
| 2432 | - * @access public |
|
| 2433 | - * @return int |
|
| 2434 | - * @throws EE_Error |
|
| 2435 | - * @throws EE_Error |
|
| 2436 | - */ |
|
| 2437 | - public function total_trashed_events() |
|
| 2438 | - { |
|
| 2439 | - return EEM_Event::instance()->count( |
|
| 2440 | - [ |
|
| 2441 | - ['status' => 'trash'], |
|
| 2442 | - 'caps' => 'read_admin', |
|
| 2443 | - ], |
|
| 2444 | - 'EVT_ID', |
|
| 2445 | - true |
|
| 2446 | - ); |
|
| 2447 | - } |
|
| 2448 | - |
|
| 2449 | - |
|
| 2450 | - /** |
|
| 2451 | - * _default_event_settings |
|
| 2452 | - * This generates the Default Settings Tab |
|
| 2453 | - * |
|
| 2454 | - * @return void |
|
| 2455 | - * @throws DomainException |
|
| 2456 | - * @throws EE_Error |
|
| 2457 | - * @throws InvalidArgumentException |
|
| 2458 | - * @throws InvalidDataTypeException |
|
| 2459 | - * @throws InvalidInterfaceException |
|
| 2460 | - */ |
|
| 2461 | - protected function _default_event_settings() |
|
| 2462 | - { |
|
| 2463 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
| 2464 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 2465 | - $this->_template_args['admin_page_content'] = EEH_HTML::div( |
|
| 2466 | - $this->_default_event_settings_form()->get_html(), |
|
| 2467 | - '', |
|
| 2468 | - 'padding' |
|
| 2469 | - ); |
|
| 2470 | - $this->display_admin_page_with_sidebar(); |
|
| 2471 | - } |
|
| 2472 | - |
|
| 2473 | - |
|
| 2474 | - /** |
|
| 2475 | - * Return the form for event settings. |
|
| 2476 | - * |
|
| 2477 | - * @return EE_Form_Section_Proper |
|
| 2478 | - * @throws EE_Error |
|
| 2479 | - */ |
|
| 2480 | - protected function _default_event_settings_form() |
|
| 2481 | - { |
|
| 2482 | - $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2483 | - $registration_stati_for_selection = EEM_Registration::reg_status_array( |
|
| 2484 | - // exclude |
|
| 2485 | - [ |
|
| 2486 | - EEM_Registration::status_id_cancelled, |
|
| 2487 | - EEM_Registration::status_id_declined, |
|
| 2488 | - EEM_Registration::status_id_incomplete, |
|
| 2489 | - EEM_Registration::status_id_wait_list, |
|
| 2490 | - ], |
|
| 2491 | - true |
|
| 2492 | - ); |
|
| 2493 | - return new EE_Form_Section_Proper( |
|
| 2494 | - [ |
|
| 2495 | - 'name' => 'update_default_event_settings', |
|
| 2496 | - 'html_id' => 'update_default_event_settings', |
|
| 2497 | - 'html_class' => 'form-table', |
|
| 2498 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 2499 | - 'subsections' => apply_filters( |
|
| 2500 | - 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
| 2501 | - [ |
|
| 2502 | - 'defaults_section_header' => new EE_Form_Section_HTML( |
|
| 2503 | - EEH_HTML::h2( |
|
| 2504 | - esc_html__('Default Settings', 'event_espresso'), |
|
| 2505 | - '', |
|
| 2506 | - 'ee-admin-settings-hdr' |
|
| 2507 | - ) |
|
| 2508 | - ), |
|
| 2509 | - 'default_reg_status' => new EE_Select_Input( |
|
| 2510 | - $registration_stati_for_selection, |
|
| 2511 | - [ |
|
| 2512 | - 'default' => isset($registration_config->default_STS_ID) |
|
| 2513 | - && array_key_exists( |
|
| 2514 | - $registration_config->default_STS_ID, |
|
| 2515 | - $registration_stati_for_selection |
|
| 2516 | - ) |
|
| 2517 | - ? sanitize_text_field($registration_config->default_STS_ID) |
|
| 2518 | - : EEM_Registration::status_id_pending_payment, |
|
| 2519 | - 'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') |
|
| 2520 | - . EEH_Template::get_help_tab_link( |
|
| 2521 | - 'default_settings_status_help_tab' |
|
| 2522 | - ), |
|
| 2523 | - 'html_help_text' => esc_html__( |
|
| 2524 | - 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.', |
|
| 2525 | - 'event_espresso' |
|
| 2526 | - ), |
|
| 2527 | - ] |
|
| 2528 | - ), |
|
| 2529 | - 'default_max_tickets' => new EE_Integer_Input( |
|
| 2530 | - [ |
|
| 2531 | - 'default' => isset($registration_config->default_maximum_number_of_tickets) |
|
| 2532 | - ? $registration_config->default_maximum_number_of_tickets |
|
| 2533 | - : EEM_Event::get_default_additional_limit(), |
|
| 2534 | - 'html_label_text' => esc_html__( |
|
| 2535 | - 'Default Maximum Tickets Allowed Per Order:', |
|
| 2536 | - 'event_espresso' |
|
| 2537 | - ) |
|
| 2538 | - . EEH_Template::get_help_tab_link( |
|
| 2539 | - 'default_maximum_tickets_help_tab"' |
|
| 2540 | - ), |
|
| 2541 | - 'html_help_text' => esc_html__( |
|
| 2542 | - 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.', |
|
| 2543 | - 'event_espresso' |
|
| 2544 | - ), |
|
| 2545 | - ] |
|
| 2546 | - ), |
|
| 2547 | - ] |
|
| 2548 | - ), |
|
| 2549 | - ] |
|
| 2550 | - ); |
|
| 2551 | - } |
|
| 2552 | - |
|
| 2553 | - |
|
| 2554 | - /** |
|
| 2555 | - * @return void |
|
| 2556 | - * @throws EE_Error |
|
| 2557 | - * @throws InvalidArgumentException |
|
| 2558 | - * @throws InvalidDataTypeException |
|
| 2559 | - * @throws InvalidInterfaceException |
|
| 2560 | - */ |
|
| 2561 | - protected function _update_default_event_settings() |
|
| 2562 | - { |
|
| 2563 | - $form = $this->_default_event_settings_form(); |
|
| 2564 | - if ($form->was_submitted()) { |
|
| 2565 | - $form->receive_form_submission(); |
|
| 2566 | - if ($form->is_valid()) { |
|
| 2567 | - $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2568 | - $valid_data = $form->valid_data(); |
|
| 2569 | - if (isset($valid_data['default_reg_status'])) { |
|
| 2570 | - $registration_config->default_STS_ID = $valid_data['default_reg_status']; |
|
| 2571 | - } |
|
| 2572 | - if (isset($valid_data['default_max_tickets'])) { |
|
| 2573 | - $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets']; |
|
| 2574 | - } |
|
| 2575 | - do_action( |
|
| 2576 | - 'AHEE__Events_Admin_Page___update_default_event_settings', |
|
| 2577 | - $valid_data, |
|
| 2578 | - EE_Registry::instance()->CFG, |
|
| 2579 | - $this |
|
| 2580 | - ); |
|
| 2581 | - // update because data was valid! |
|
| 2582 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 2583 | - EE_Error::overwrite_success(); |
|
| 2584 | - EE_Error::add_success( |
|
| 2585 | - esc_html__('Default Event Settings were updated', 'event_espresso') |
|
| 2586 | - ); |
|
| 2587 | - } |
|
| 2588 | - } |
|
| 2589 | - $this->_redirect_after_action(0, '', '', ['action' => 'default_event_settings'], true); |
|
| 2590 | - } |
|
| 2591 | - |
|
| 2592 | - |
|
| 2593 | - /************* Templates ************* |
|
| 2594 | - * |
|
| 2595 | - * @throws EE_Error |
|
| 2596 | - */ |
|
| 2597 | - protected function _template_settings() |
|
| 2598 | - { |
|
| 2599 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
| 2600 | - $this->_template_args['preview_img'] = '<img src="' |
|
| 2601 | - . EVENTS_ASSETS_URL |
|
| 2602 | - . '/images/' |
|
| 2603 | - . 'caffeinated_template_features.jpg" alt="' |
|
| 2604 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
| 2605 | - . '" />'; |
|
| 2606 | - $this->_template_args['preview_text'] = '<strong>' |
|
| 2607 | - . esc_html__( |
|
| 2608 | - 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
| 2609 | - 'event_espresso' |
|
| 2610 | - ) . '</strong>'; |
|
| 2611 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
| 2612 | - } |
|
| 2613 | - |
|
| 2614 | - |
|
| 2615 | - /** Event Category Stuff **/ |
|
| 2616 | - /** |
|
| 2617 | - * set the _category property with the category object for the loaded page. |
|
| 2618 | - * |
|
| 2619 | - * @access private |
|
| 2620 | - * @return void |
|
| 2621 | - */ |
|
| 2622 | - private function _set_category_object() |
|
| 2623 | - { |
|
| 2624 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
| 2625 | - return; |
|
| 2626 | - } //already have the category object so get out. |
|
| 2627 | - // set default category object |
|
| 2628 | - $this->_set_empty_category_object(); |
|
| 2629 | - // only set if we've got an id |
|
| 2630 | - $category_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
| 2631 | - if (! $category_ID) { |
|
| 2632 | - return; |
|
| 2633 | - } |
|
| 2634 | - $term = get_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY); |
|
| 2635 | - if (! empty($term)) { |
|
| 2636 | - $this->_category->category_name = $term->name; |
|
| 2637 | - $this->_category->category_identifier = $term->slug; |
|
| 2638 | - $this->_category->category_desc = $term->description; |
|
| 2639 | - $this->_category->id = $term->term_id; |
|
| 2640 | - $this->_category->parent = $term->parent; |
|
| 2641 | - } |
|
| 2642 | - } |
|
| 2643 | - |
|
| 2644 | - |
|
| 2645 | - /** |
|
| 2646 | - * Clears out category properties. |
|
| 2647 | - */ |
|
| 2648 | - private function _set_empty_category_object() |
|
| 2649 | - { |
|
| 2650 | - $this->_category = new stdClass(); |
|
| 2651 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
| 2652 | - $this->_category->id = $this->_category->parent = 0; |
|
| 2653 | - } |
|
| 2654 | - |
|
| 2655 | - |
|
| 2656 | - /** |
|
| 2657 | - * @throws DomainException |
|
| 2658 | - * @throws EE_Error |
|
| 2659 | - * @throws InvalidArgumentException |
|
| 2660 | - * @throws InvalidDataTypeException |
|
| 2661 | - * @throws InvalidInterfaceException |
|
| 2662 | - */ |
|
| 2663 | - protected function _category_list_table() |
|
| 2664 | - { |
|
| 2665 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2666 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
| 2667 | - $this->_admin_page_title .= ' '; |
|
| 2668 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 2669 | - 'add_category', |
|
| 2670 | - 'add_category', |
|
| 2671 | - [], |
|
| 2672 | - 'add-new-h2' |
|
| 2673 | - ); |
|
| 2674 | - $this->display_admin_list_table_page_with_sidebar(); |
|
| 2675 | - } |
|
| 2676 | - |
|
| 2677 | - |
|
| 2678 | - /** |
|
| 2679 | - * Output category details view. |
|
| 2680 | - * |
|
| 2681 | - * @throws EE_Error |
|
| 2682 | - * @throws EE_Error |
|
| 2683 | - */ |
|
| 2684 | - protected function _category_details($view) |
|
| 2685 | - { |
|
| 2686 | - // load formatter helper |
|
| 2687 | - // load field generator helper |
|
| 2688 | - $route = $view === 'edit' ? 'update_category' : 'insert_category'; |
|
| 2689 | - $this->_set_add_edit_form_tags($route); |
|
| 2690 | - $this->_set_category_object(); |
|
| 2691 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
| 2692 | - $delete_action = 'delete_category'; |
|
| 2693 | - // custom redirect |
|
| 2694 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2695 | - ['action' => 'category_list'], |
|
| 2696 | - $this->_admin_base_url |
|
| 2697 | - ); |
|
| 2698 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
| 2699 | - // take care of contents |
|
| 2700 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
| 2701 | - $this->display_admin_page_with_sidebar(); |
|
| 2702 | - } |
|
| 2703 | - |
|
| 2704 | - |
|
| 2705 | - /** |
|
| 2706 | - * Output category details content. |
|
| 2707 | - * |
|
| 2708 | - * @throws DomainException |
|
| 2709 | - */ |
|
| 2710 | - protected function _category_details_content() |
|
| 2711 | - { |
|
| 2712 | - $editor_args['category_desc'] = [ |
|
| 2713 | - 'type' => 'wp_editor', |
|
| 2714 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
| 2715 | - 'class' => 'my_editor_custom', |
|
| 2716 | - 'wpeditor_args' => ['media_buttons' => false], |
|
| 2717 | - ]; |
|
| 2718 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
| 2719 | - $all_terms = get_terms( |
|
| 2720 | - [EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY], |
|
| 2721 | - ['hide_empty' => 0, 'exclude' => [$this->_category->id]] |
|
| 2722 | - ); |
|
| 2723 | - // setup category select for term parents. |
|
| 2724 | - $category_select_values[] = [ |
|
| 2725 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
| 2726 | - 'id' => 0, |
|
| 2727 | - ]; |
|
| 2728 | - foreach ($all_terms as $term) { |
|
| 2729 | - $category_select_values[] = [ |
|
| 2730 | - 'text' => $term->name, |
|
| 2731 | - 'id' => $term->term_id, |
|
| 2732 | - ]; |
|
| 2733 | - } |
|
| 2734 | - $category_select = EEH_Form_Fields::select_input( |
|
| 2735 | - 'category_parent', |
|
| 2736 | - $category_select_values, |
|
| 2737 | - $this->_category->parent |
|
| 2738 | - ); |
|
| 2739 | - $template_args = [ |
|
| 2740 | - 'category' => $this->_category, |
|
| 2741 | - 'category_select' => $category_select, |
|
| 2742 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
| 2743 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
| 2744 | - 'disable' => '', |
|
| 2745 | - 'disabled_message' => false, |
|
| 2746 | - ]; |
|
| 2747 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2748 | - return EEH_Template::display_template($template, $template_args, true); |
|
| 2749 | - } |
|
| 2750 | - |
|
| 2751 | - |
|
| 2752 | - /** |
|
| 2753 | - * Handles deleting categories. |
|
| 2754 | - * |
|
| 2755 | - * @throws EE_Error |
|
| 2756 | - */ |
|
| 2757 | - protected function _delete_categories() |
|
| 2758 | - { |
|
| 2759 | - $category_IDs = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int', true); |
|
| 2760 | - foreach ($category_IDs as $category_ID) { |
|
| 2761 | - $this->_delete_category($category_ID); |
|
| 2762 | - } |
|
| 2763 | - // doesn't matter what page we're coming from... we're going to the same place after delete. |
|
| 2764 | - $query_args = [ |
|
| 2765 | - 'action' => 'category_list', |
|
| 2766 | - ]; |
|
| 2767 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
| 2768 | - } |
|
| 2769 | - |
|
| 2770 | - |
|
| 2771 | - /** |
|
| 2772 | - * Handles deleting specific category. |
|
| 2773 | - * |
|
| 2774 | - * @param int $cat_id |
|
| 2775 | - */ |
|
| 2776 | - protected function _delete_category($cat_id) |
|
| 2777 | - { |
|
| 2778 | - $cat_id = absint($cat_id); |
|
| 2779 | - wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY); |
|
| 2780 | - } |
|
| 2781 | - |
|
| 2782 | - |
|
| 2783 | - /** |
|
| 2784 | - * Handles triggering the update or insertion of a new category. |
|
| 2785 | - * |
|
| 2786 | - * @param bool $new_category true means we're triggering the insert of a new category. |
|
| 2787 | - * @throws EE_Error |
|
| 2788 | - * @throws EE_Error |
|
| 2789 | - */ |
|
| 2790 | - protected function _insert_or_update_category($new_category) |
|
| 2791 | - { |
|
| 2792 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
| 2793 | - $success = 0; // we already have a success message so lets not send another. |
|
| 2794 | - if ($cat_id) { |
|
| 2795 | - $query_args = [ |
|
| 2796 | - 'action' => 'edit_category', |
|
| 2797 | - 'EVT_CAT_ID' => $cat_id, |
|
| 2798 | - ]; |
|
| 2799 | - } else { |
|
| 2800 | - $query_args = ['action' => 'add_category']; |
|
| 2801 | - } |
|
| 2802 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
| 2803 | - } |
|
| 2804 | - |
|
| 2805 | - |
|
| 2806 | - /** |
|
| 2807 | - * Inserts or updates category |
|
| 2808 | - * |
|
| 2809 | - * @param bool $update (true indicates we're updating a category). |
|
| 2810 | - * @return bool|mixed|string |
|
| 2811 | - */ |
|
| 2812 | - private function _insert_category($update = false) |
|
| 2813 | - { |
|
| 2814 | - $category_ID = $update ? $this->request->getRequestParam('EVT_CAT_ID', 0, 'int') : 0; |
|
| 2815 | - $category_name = $this->request->getRequestParam('category_name', ''); |
|
| 2816 | - $category_desc = $this->request->getRequestParam('category_desc', ''); |
|
| 2817 | - $category_parent = $this->request->getRequestParam('category_parent', 0, 'int'); |
|
| 2818 | - $category_identifier = $this->request->getRequestParam('category_identifier', ''); |
|
| 2819 | - |
|
| 2820 | - if (empty($category_name)) { |
|
| 2821 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
| 2822 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2823 | - return false; |
|
| 2824 | - } |
|
| 2825 | - $term_args = [ |
|
| 2826 | - 'name' => $category_name, |
|
| 2827 | - 'description' => $category_desc, |
|
| 2828 | - 'parent' => $category_parent, |
|
| 2829 | - ]; |
|
| 2830 | - // was the category_identifier input disabled? |
|
| 2831 | - if ($category_identifier) { |
|
| 2832 | - $term_args['slug'] = $category_identifier; |
|
| 2833 | - } |
|
| 2834 | - $insert_ids = $update |
|
| 2835 | - ? wp_update_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args) |
|
| 2836 | - : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args); |
|
| 2837 | - if (! is_array($insert_ids)) { |
|
| 2838 | - $msg = esc_html__( |
|
| 2839 | - 'An error occurred and the category has not been saved to the database.', |
|
| 2840 | - 'event_espresso' |
|
| 2841 | - ); |
|
| 2842 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2843 | - } else { |
|
| 2844 | - $category_ID = $insert_ids['term_id']; |
|
| 2845 | - $msg = sprintf( |
|
| 2846 | - esc_html__('The category %s was successfully saved', 'event_espresso'), |
|
| 2847 | - $category_name |
|
| 2848 | - ); |
|
| 2849 | - EE_Error::add_success($msg); |
|
| 2850 | - } |
|
| 2851 | - return $category_ID; |
|
| 2852 | - } |
|
| 2853 | - |
|
| 2854 | - |
|
| 2855 | - /** |
|
| 2856 | - * Gets categories or count of categories matching the arguments in the request. |
|
| 2857 | - * |
|
| 2858 | - * @param int $per_page |
|
| 2859 | - * @param int $current_page |
|
| 2860 | - * @param bool $count |
|
| 2861 | - * @return EE_Term_Taxonomy[]|int |
|
| 2862 | - * @throws EE_Error |
|
| 2863 | - */ |
|
| 2864 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
| 2865 | - { |
|
| 2866 | - // testing term stuff |
|
| 2867 | - $orderby = $this->request->getRequestParam('orderby', 'Term.term_id'); |
|
| 2868 | - $order = $this->request->getRequestParam('order', 'DESC'); |
|
| 2869 | - $limit = ($current_page - 1) * $per_page; |
|
| 2870 | - $where = ['taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]; |
|
| 2871 | - $search_term = $this->request->getRequestParam('s'); |
|
| 2872 | - if ($search_term) { |
|
| 2873 | - $search_term = '%' . $search_term . '%'; |
|
| 2874 | - $where['OR'] = [ |
|
| 2875 | - 'Term.name' => ['LIKE', $search_term], |
|
| 2876 | - 'description' => ['LIKE', $search_term], |
|
| 2877 | - ]; |
|
| 2878 | - } |
|
| 2879 | - $query_params = [ |
|
| 2880 | - $where, |
|
| 2881 | - 'order_by' => [$orderby => $order], |
|
| 2882 | - 'limit' => $limit . ',' . $per_page, |
|
| 2883 | - 'force_join' => ['Term'], |
|
| 2884 | - ]; |
|
| 2885 | - return $count |
|
| 2886 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
| 2887 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
| 2888 | - } |
|
| 2889 | - |
|
| 2890 | - /* end category stuff */ |
|
| 2891 | - |
|
| 2892 | - |
|
| 2893 | - /**************/ |
|
| 2894 | - |
|
| 2895 | - |
|
| 2896 | - /** |
|
| 2897 | - * Callback for the `ee_save_timezone_setting` ajax action. |
|
| 2898 | - * |
|
| 2899 | - * @throws EE_Error |
|
| 2900 | - * @throws InvalidArgumentException |
|
| 2901 | - * @throws InvalidDataTypeException |
|
| 2902 | - * @throws InvalidInterfaceException |
|
| 2903 | - */ |
|
| 2904 | - public function saveTimezoneString() |
|
| 2905 | - { |
|
| 2906 | - $timezone_string = $this->request->getRequestParam('timezone_selected'); |
|
| 2907 | - if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) { |
|
| 2908 | - EE_Error::add_error( |
|
| 2909 | - esc_html__('An invalid timezone string submitted.', 'event_espresso'), |
|
| 2910 | - __FILE__, |
|
| 2911 | - __FUNCTION__, |
|
| 2912 | - __LINE__ |
|
| 2913 | - ); |
|
| 2914 | - $this->_template_args['error'] = true; |
|
| 2915 | - $this->_return_json(); |
|
| 2916 | - } |
|
| 2917 | - |
|
| 2918 | - update_option('timezone_string', $timezone_string); |
|
| 2919 | - EE_Error::add_success( |
|
| 2920 | - esc_html__('Your timezone string was updated.', 'event_espresso') |
|
| 2921 | - ); |
|
| 2922 | - $this->_template_args['success'] = true; |
|
| 2923 | - $this->_return_json(true, ['action' => 'create_new']); |
|
| 2924 | - } |
|
| 2925 | - |
|
| 2926 | - |
|
| 2927 | - /** |
|
| 2928 | 2595 | * @throws EE_Error |
| 2929 | - * @deprecated 4.10.25.p |
|
| 2930 | 2596 | */ |
| 2931 | - public function save_timezonestring_setting() |
|
| 2932 | - { |
|
| 2933 | - $this->saveTimezoneString(); |
|
| 2934 | - } |
|
| 2597 | + protected function _template_settings() |
|
| 2598 | + { |
|
| 2599 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
| 2600 | + $this->_template_args['preview_img'] = '<img src="' |
|
| 2601 | + . EVENTS_ASSETS_URL |
|
| 2602 | + . '/images/' |
|
| 2603 | + . 'caffeinated_template_features.jpg" alt="' |
|
| 2604 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
| 2605 | + . '" />'; |
|
| 2606 | + $this->_template_args['preview_text'] = '<strong>' |
|
| 2607 | + . esc_html__( |
|
| 2608 | + 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
| 2609 | + 'event_espresso' |
|
| 2610 | + ) . '</strong>'; |
|
| 2611 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
| 2612 | + } |
|
| 2613 | + |
|
| 2614 | + |
|
| 2615 | + /** Event Category Stuff **/ |
|
| 2616 | + /** |
|
| 2617 | + * set the _category property with the category object for the loaded page. |
|
| 2618 | + * |
|
| 2619 | + * @access private |
|
| 2620 | + * @return void |
|
| 2621 | + */ |
|
| 2622 | + private function _set_category_object() |
|
| 2623 | + { |
|
| 2624 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
| 2625 | + return; |
|
| 2626 | + } //already have the category object so get out. |
|
| 2627 | + // set default category object |
|
| 2628 | + $this->_set_empty_category_object(); |
|
| 2629 | + // only set if we've got an id |
|
| 2630 | + $category_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
| 2631 | + if (! $category_ID) { |
|
| 2632 | + return; |
|
| 2633 | + } |
|
| 2634 | + $term = get_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY); |
|
| 2635 | + if (! empty($term)) { |
|
| 2636 | + $this->_category->category_name = $term->name; |
|
| 2637 | + $this->_category->category_identifier = $term->slug; |
|
| 2638 | + $this->_category->category_desc = $term->description; |
|
| 2639 | + $this->_category->id = $term->term_id; |
|
| 2640 | + $this->_category->parent = $term->parent; |
|
| 2641 | + } |
|
| 2642 | + } |
|
| 2643 | + |
|
| 2644 | + |
|
| 2645 | + /** |
|
| 2646 | + * Clears out category properties. |
|
| 2647 | + */ |
|
| 2648 | + private function _set_empty_category_object() |
|
| 2649 | + { |
|
| 2650 | + $this->_category = new stdClass(); |
|
| 2651 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
| 2652 | + $this->_category->id = $this->_category->parent = 0; |
|
| 2653 | + } |
|
| 2654 | + |
|
| 2655 | + |
|
| 2656 | + /** |
|
| 2657 | + * @throws DomainException |
|
| 2658 | + * @throws EE_Error |
|
| 2659 | + * @throws InvalidArgumentException |
|
| 2660 | + * @throws InvalidDataTypeException |
|
| 2661 | + * @throws InvalidInterfaceException |
|
| 2662 | + */ |
|
| 2663 | + protected function _category_list_table() |
|
| 2664 | + { |
|
| 2665 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2666 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
| 2667 | + $this->_admin_page_title .= ' '; |
|
| 2668 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 2669 | + 'add_category', |
|
| 2670 | + 'add_category', |
|
| 2671 | + [], |
|
| 2672 | + 'add-new-h2' |
|
| 2673 | + ); |
|
| 2674 | + $this->display_admin_list_table_page_with_sidebar(); |
|
| 2675 | + } |
|
| 2676 | + |
|
| 2677 | + |
|
| 2678 | + /** |
|
| 2679 | + * Output category details view. |
|
| 2680 | + * |
|
| 2681 | + * @throws EE_Error |
|
| 2682 | + * @throws EE_Error |
|
| 2683 | + */ |
|
| 2684 | + protected function _category_details($view) |
|
| 2685 | + { |
|
| 2686 | + // load formatter helper |
|
| 2687 | + // load field generator helper |
|
| 2688 | + $route = $view === 'edit' ? 'update_category' : 'insert_category'; |
|
| 2689 | + $this->_set_add_edit_form_tags($route); |
|
| 2690 | + $this->_set_category_object(); |
|
| 2691 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
| 2692 | + $delete_action = 'delete_category'; |
|
| 2693 | + // custom redirect |
|
| 2694 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2695 | + ['action' => 'category_list'], |
|
| 2696 | + $this->_admin_base_url |
|
| 2697 | + ); |
|
| 2698 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
| 2699 | + // take care of contents |
|
| 2700 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
| 2701 | + $this->display_admin_page_with_sidebar(); |
|
| 2702 | + } |
|
| 2703 | + |
|
| 2704 | + |
|
| 2705 | + /** |
|
| 2706 | + * Output category details content. |
|
| 2707 | + * |
|
| 2708 | + * @throws DomainException |
|
| 2709 | + */ |
|
| 2710 | + protected function _category_details_content() |
|
| 2711 | + { |
|
| 2712 | + $editor_args['category_desc'] = [ |
|
| 2713 | + 'type' => 'wp_editor', |
|
| 2714 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
| 2715 | + 'class' => 'my_editor_custom', |
|
| 2716 | + 'wpeditor_args' => ['media_buttons' => false], |
|
| 2717 | + ]; |
|
| 2718 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
| 2719 | + $all_terms = get_terms( |
|
| 2720 | + [EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY], |
|
| 2721 | + ['hide_empty' => 0, 'exclude' => [$this->_category->id]] |
|
| 2722 | + ); |
|
| 2723 | + // setup category select for term parents. |
|
| 2724 | + $category_select_values[] = [ |
|
| 2725 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
| 2726 | + 'id' => 0, |
|
| 2727 | + ]; |
|
| 2728 | + foreach ($all_terms as $term) { |
|
| 2729 | + $category_select_values[] = [ |
|
| 2730 | + 'text' => $term->name, |
|
| 2731 | + 'id' => $term->term_id, |
|
| 2732 | + ]; |
|
| 2733 | + } |
|
| 2734 | + $category_select = EEH_Form_Fields::select_input( |
|
| 2735 | + 'category_parent', |
|
| 2736 | + $category_select_values, |
|
| 2737 | + $this->_category->parent |
|
| 2738 | + ); |
|
| 2739 | + $template_args = [ |
|
| 2740 | + 'category' => $this->_category, |
|
| 2741 | + 'category_select' => $category_select, |
|
| 2742 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
| 2743 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
| 2744 | + 'disable' => '', |
|
| 2745 | + 'disabled_message' => false, |
|
| 2746 | + ]; |
|
| 2747 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2748 | + return EEH_Template::display_template($template, $template_args, true); |
|
| 2749 | + } |
|
| 2750 | + |
|
| 2751 | + |
|
| 2752 | + /** |
|
| 2753 | + * Handles deleting categories. |
|
| 2754 | + * |
|
| 2755 | + * @throws EE_Error |
|
| 2756 | + */ |
|
| 2757 | + protected function _delete_categories() |
|
| 2758 | + { |
|
| 2759 | + $category_IDs = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int', true); |
|
| 2760 | + foreach ($category_IDs as $category_ID) { |
|
| 2761 | + $this->_delete_category($category_ID); |
|
| 2762 | + } |
|
| 2763 | + // doesn't matter what page we're coming from... we're going to the same place after delete. |
|
| 2764 | + $query_args = [ |
|
| 2765 | + 'action' => 'category_list', |
|
| 2766 | + ]; |
|
| 2767 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
| 2768 | + } |
|
| 2769 | + |
|
| 2770 | + |
|
| 2771 | + /** |
|
| 2772 | + * Handles deleting specific category. |
|
| 2773 | + * |
|
| 2774 | + * @param int $cat_id |
|
| 2775 | + */ |
|
| 2776 | + protected function _delete_category($cat_id) |
|
| 2777 | + { |
|
| 2778 | + $cat_id = absint($cat_id); |
|
| 2779 | + wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY); |
|
| 2780 | + } |
|
| 2781 | + |
|
| 2782 | + |
|
| 2783 | + /** |
|
| 2784 | + * Handles triggering the update or insertion of a new category. |
|
| 2785 | + * |
|
| 2786 | + * @param bool $new_category true means we're triggering the insert of a new category. |
|
| 2787 | + * @throws EE_Error |
|
| 2788 | + * @throws EE_Error |
|
| 2789 | + */ |
|
| 2790 | + protected function _insert_or_update_category($new_category) |
|
| 2791 | + { |
|
| 2792 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
| 2793 | + $success = 0; // we already have a success message so lets not send another. |
|
| 2794 | + if ($cat_id) { |
|
| 2795 | + $query_args = [ |
|
| 2796 | + 'action' => 'edit_category', |
|
| 2797 | + 'EVT_CAT_ID' => $cat_id, |
|
| 2798 | + ]; |
|
| 2799 | + } else { |
|
| 2800 | + $query_args = ['action' => 'add_category']; |
|
| 2801 | + } |
|
| 2802 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
| 2803 | + } |
|
| 2804 | + |
|
| 2805 | + |
|
| 2806 | + /** |
|
| 2807 | + * Inserts or updates category |
|
| 2808 | + * |
|
| 2809 | + * @param bool $update (true indicates we're updating a category). |
|
| 2810 | + * @return bool|mixed|string |
|
| 2811 | + */ |
|
| 2812 | + private function _insert_category($update = false) |
|
| 2813 | + { |
|
| 2814 | + $category_ID = $update ? $this->request->getRequestParam('EVT_CAT_ID', 0, 'int') : 0; |
|
| 2815 | + $category_name = $this->request->getRequestParam('category_name', ''); |
|
| 2816 | + $category_desc = $this->request->getRequestParam('category_desc', ''); |
|
| 2817 | + $category_parent = $this->request->getRequestParam('category_parent', 0, 'int'); |
|
| 2818 | + $category_identifier = $this->request->getRequestParam('category_identifier', ''); |
|
| 2819 | + |
|
| 2820 | + if (empty($category_name)) { |
|
| 2821 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
| 2822 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2823 | + return false; |
|
| 2824 | + } |
|
| 2825 | + $term_args = [ |
|
| 2826 | + 'name' => $category_name, |
|
| 2827 | + 'description' => $category_desc, |
|
| 2828 | + 'parent' => $category_parent, |
|
| 2829 | + ]; |
|
| 2830 | + // was the category_identifier input disabled? |
|
| 2831 | + if ($category_identifier) { |
|
| 2832 | + $term_args['slug'] = $category_identifier; |
|
| 2833 | + } |
|
| 2834 | + $insert_ids = $update |
|
| 2835 | + ? wp_update_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args) |
|
| 2836 | + : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args); |
|
| 2837 | + if (! is_array($insert_ids)) { |
|
| 2838 | + $msg = esc_html__( |
|
| 2839 | + 'An error occurred and the category has not been saved to the database.', |
|
| 2840 | + 'event_espresso' |
|
| 2841 | + ); |
|
| 2842 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2843 | + } else { |
|
| 2844 | + $category_ID = $insert_ids['term_id']; |
|
| 2845 | + $msg = sprintf( |
|
| 2846 | + esc_html__('The category %s was successfully saved', 'event_espresso'), |
|
| 2847 | + $category_name |
|
| 2848 | + ); |
|
| 2849 | + EE_Error::add_success($msg); |
|
| 2850 | + } |
|
| 2851 | + return $category_ID; |
|
| 2852 | + } |
|
| 2853 | + |
|
| 2854 | + |
|
| 2855 | + /** |
|
| 2856 | + * Gets categories or count of categories matching the arguments in the request. |
|
| 2857 | + * |
|
| 2858 | + * @param int $per_page |
|
| 2859 | + * @param int $current_page |
|
| 2860 | + * @param bool $count |
|
| 2861 | + * @return EE_Term_Taxonomy[]|int |
|
| 2862 | + * @throws EE_Error |
|
| 2863 | + */ |
|
| 2864 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
| 2865 | + { |
|
| 2866 | + // testing term stuff |
|
| 2867 | + $orderby = $this->request->getRequestParam('orderby', 'Term.term_id'); |
|
| 2868 | + $order = $this->request->getRequestParam('order', 'DESC'); |
|
| 2869 | + $limit = ($current_page - 1) * $per_page; |
|
| 2870 | + $where = ['taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]; |
|
| 2871 | + $search_term = $this->request->getRequestParam('s'); |
|
| 2872 | + if ($search_term) { |
|
| 2873 | + $search_term = '%' . $search_term . '%'; |
|
| 2874 | + $where['OR'] = [ |
|
| 2875 | + 'Term.name' => ['LIKE', $search_term], |
|
| 2876 | + 'description' => ['LIKE', $search_term], |
|
| 2877 | + ]; |
|
| 2878 | + } |
|
| 2879 | + $query_params = [ |
|
| 2880 | + $where, |
|
| 2881 | + 'order_by' => [$orderby => $order], |
|
| 2882 | + 'limit' => $limit . ',' . $per_page, |
|
| 2883 | + 'force_join' => ['Term'], |
|
| 2884 | + ]; |
|
| 2885 | + return $count |
|
| 2886 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
| 2887 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
| 2888 | + } |
|
| 2889 | + |
|
| 2890 | + /* end category stuff */ |
|
| 2891 | + |
|
| 2892 | + |
|
| 2893 | + /**************/ |
|
| 2894 | + |
|
| 2895 | + |
|
| 2896 | + /** |
|
| 2897 | + * Callback for the `ee_save_timezone_setting` ajax action. |
|
| 2898 | + * |
|
| 2899 | + * @throws EE_Error |
|
| 2900 | + * @throws InvalidArgumentException |
|
| 2901 | + * @throws InvalidDataTypeException |
|
| 2902 | + * @throws InvalidInterfaceException |
|
| 2903 | + */ |
|
| 2904 | + public function saveTimezoneString() |
|
| 2905 | + { |
|
| 2906 | + $timezone_string = $this->request->getRequestParam('timezone_selected'); |
|
| 2907 | + if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) { |
|
| 2908 | + EE_Error::add_error( |
|
| 2909 | + esc_html__('An invalid timezone string submitted.', 'event_espresso'), |
|
| 2910 | + __FILE__, |
|
| 2911 | + __FUNCTION__, |
|
| 2912 | + __LINE__ |
|
| 2913 | + ); |
|
| 2914 | + $this->_template_args['error'] = true; |
|
| 2915 | + $this->_return_json(); |
|
| 2916 | + } |
|
| 2917 | + |
|
| 2918 | + update_option('timezone_string', $timezone_string); |
|
| 2919 | + EE_Error::add_success( |
|
| 2920 | + esc_html__('Your timezone string was updated.', 'event_espresso') |
|
| 2921 | + ); |
|
| 2922 | + $this->_template_args['success'] = true; |
|
| 2923 | + $this->_return_json(true, ['action' => 'create_new']); |
|
| 2924 | + } |
|
| 2925 | + |
|
| 2926 | + |
|
| 2927 | + /** |
|
| 2928 | + * @throws EE_Error |
|
| 2929 | + * @deprecated 4.10.25.p |
|
| 2930 | + */ |
|
| 2931 | + public function save_timezonestring_setting() |
|
| 2932 | + { |
|
| 2933 | + $this->saveTimezoneString(); |
|
| 2934 | + } |
|
| 2935 | 2935 | } |
@@ -587,13 +587,13 @@ discard block |
||
| 587 | 587 | { |
| 588 | 588 | wp_register_style( |
| 589 | 589 | 'events-admin-css', |
| 590 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 590 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
| 591 | 591 | [], |
| 592 | 592 | EVENT_ESPRESSO_VERSION |
| 593 | 593 | ); |
| 594 | 594 | wp_register_style( |
| 595 | 595 | 'ee-cat-admin', |
| 596 | - EVENTS_ASSETS_URL . 'ee-cat-admin.css', |
|
| 596 | + EVENTS_ASSETS_URL.'ee-cat-admin.css', |
|
| 597 | 597 | [], |
| 598 | 598 | EVENT_ESPRESSO_VERSION |
| 599 | 599 | ); |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | // scripts |
| 603 | 603 | wp_register_script( |
| 604 | 604 | 'event_editor_js', |
| 605 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 605 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
| 606 | 606 | ['ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'], |
| 607 | 607 | EVENT_ESPRESSO_VERSION, |
| 608 | 608 | true |
@@ -628,16 +628,16 @@ discard block |
||
| 628 | 628 | wp_enqueue_style('espresso-ui-theme'); |
| 629 | 629 | wp_register_style( |
| 630 | 630 | 'event-editor-css', |
| 631 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 631 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
| 632 | 632 | ['ee-admin-css'], |
| 633 | 633 | EVENT_ESPRESSO_VERSION |
| 634 | 634 | ); |
| 635 | 635 | wp_enqueue_style('event-editor-css'); |
| 636 | 636 | // scripts |
| 637 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
| 637 | + if ( ! $this->admin_config->useAdvancedEditor()) { |
|
| 638 | 638 | wp_register_script( |
| 639 | 639 | 'event-datetime-metabox', |
| 640 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 640 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
| 641 | 641 | ['event_editor_js', 'ee-datepicker'], |
| 642 | 642 | EVENT_ESPRESSO_VERSION |
| 643 | 643 | ); |
@@ -707,15 +707,15 @@ discard block |
||
| 707 | 707 | public function verify_event_edit($event = null, $req_type = '') |
| 708 | 708 | { |
| 709 | 709 | // don't need to do this when processing |
| 710 | - if (! empty($req_type)) { |
|
| 710 | + if ( ! empty($req_type)) { |
|
| 711 | 711 | return; |
| 712 | 712 | } |
| 713 | 713 | // no event? |
| 714 | - if (! $event instanceof EE_Event) { |
|
| 714 | + if ( ! $event instanceof EE_Event) { |
|
| 715 | 715 | $event = $this->_cpt_model_obj; |
| 716 | 716 | } |
| 717 | 717 | // STILL no event? |
| 718 | - if (! $event instanceof EE_Event) { |
|
| 718 | + if ( ! $event instanceof EE_Event) { |
|
| 719 | 719 | return; |
| 720 | 720 | } |
| 721 | 721 | $orig_status = $event->status(); |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | ); |
| 756 | 756 | } |
| 757 | 757 | // now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
| 758 | - if (! $event->tickets_on_sale()) { |
|
| 758 | + if ( ! $event->tickets_on_sale()) { |
|
| 759 | 759 | return; |
| 760 | 760 | } |
| 761 | 761 | // made it here so show warning |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | { |
| 804 | 804 | $has_timezone_string = get_option('timezone_string'); |
| 805 | 805 | // only nag them about setting their timezone if it's their first event, and they haven't already done it |
| 806 | - if (! $has_timezone_string && ! EEM_Event::instance()->exists([])) { |
|
| 806 | + if ( ! $has_timezone_string && ! EEM_Event::instance()->exists([])) { |
|
| 807 | 807 | EE_Error::add_attention( |
| 808 | 808 | sprintf( |
| 809 | 809 | esc_html__( |
@@ -872,7 +872,7 @@ discard block |
||
| 872 | 872 | */ |
| 873 | 873 | protected function _event_legend_items() |
| 874 | 874 | { |
| 875 | - $items = [ |
|
| 875 | + $items = [ |
|
| 876 | 876 | 'view_details' => [ |
| 877 | 877 | 'class' => 'dashicons dashicons-visibility', |
| 878 | 878 | 'desc' => esc_html__('View Event', 'event_espresso'), |
@@ -889,31 +889,31 @@ discard block |
||
| 889 | 889 | $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
| 890 | 890 | $statuses = [ |
| 891 | 891 | 'sold_out_status' => [ |
| 892 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::sold_out, |
|
| 892 | + 'class' => 'ee-status-legend ee-status-bg--'.EE_Datetime::sold_out, |
|
| 893 | 893 | 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
| 894 | 894 | ], |
| 895 | 895 | 'active_status' => [ |
| 896 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::active, |
|
| 896 | + 'class' => 'ee-status-legend ee-status-bg--'.EE_Datetime::active, |
|
| 897 | 897 | 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
| 898 | 898 | ], |
| 899 | 899 | 'upcoming_status' => [ |
| 900 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::upcoming, |
|
| 900 | + 'class' => 'ee-status-legend ee-status-bg--'.EE_Datetime::upcoming, |
|
| 901 | 901 | 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
| 902 | 902 | ], |
| 903 | 903 | 'postponed_status' => [ |
| 904 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::postponed, |
|
| 904 | + 'class' => 'ee-status-legend ee-status-bg--'.EE_Datetime::postponed, |
|
| 905 | 905 | 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
| 906 | 906 | ], |
| 907 | 907 | 'cancelled_status' => [ |
| 908 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::cancelled, |
|
| 908 | + 'class' => 'ee-status-legend ee-status-bg--'.EE_Datetime::cancelled, |
|
| 909 | 909 | 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
| 910 | 910 | ], |
| 911 | 911 | 'expired_status' => [ |
| 912 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::expired, |
|
| 912 | + 'class' => 'ee-status-legend ee-status-bg--'.EE_Datetime::expired, |
|
| 913 | 913 | 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
| 914 | 914 | ], |
| 915 | 915 | 'inactive_status' => [ |
| 916 | - 'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::inactive, |
|
| 916 | + 'class' => 'ee-status-legend ee-status-bg--'.EE_Datetime::inactive, |
|
| 917 | 917 | 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
| 918 | 918 | ], |
| 919 | 919 | ]; |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | */ |
| 933 | 933 | private function _event_model() |
| 934 | 934 | { |
| 935 | - if (! $this->_event_model instanceof EEM_Event) { |
|
| 935 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
| 936 | 936 | $this->_event_model = EE_Registry::instance()->load_model('Event'); |
| 937 | 937 | } |
| 938 | 938 | return $this->_event_model; |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
| 953 | 953 | { |
| 954 | 954 | // make sure this is only when editing |
| 955 | - if (! empty($id)) { |
|
| 955 | + if ( ! empty($id)) { |
|
| 956 | 956 | $post = get_post($id); |
| 957 | 957 | $return .= '<a class="button button--small button--secondary" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
| 958 | 958 | . esc_html__('Shortcode', 'event_espresso') |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | */ |
| 980 | 980 | protected function _events_overview_list_table() |
| 981 | 981 | { |
| 982 | - $after_list_table = []; |
|
| 982 | + $after_list_table = []; |
|
| 983 | 983 | $links_html = EEH_HTML::div('', '', 'ee-admin-section ee-layout-stack'); |
| 984 | 984 | $links_html .= EEH_HTML::h3(esc_html__('Links', 'event_espresso')); |
| 985 | 985 | $links_html .= EEH_HTML::div( |
@@ -996,14 +996,14 @@ discard block |
||
| 996 | 996 | $after_list_table['view_event_list_button'] = $links_html; |
| 997 | 997 | |
| 998 | 998 | $after_list_table['legend'] = $this->_display_legend($this->_event_legend_items()); |
| 999 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 999 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 1000 | 1000 | 'create_new', |
| 1001 | 1001 | 'add', |
| 1002 | 1002 | [], |
| 1003 | 1003 | 'add-new-h2' |
| 1004 | 1004 | ); |
| 1005 | 1005 | |
| 1006 | - $this->_template_args['after_list_table'] = array_merge( |
|
| 1006 | + $this->_template_args['after_list_table'] = array_merge( |
|
| 1007 | 1007 | (array) $this->_template_args['after_list_table'], |
| 1008 | 1008 | $after_list_table |
| 1009 | 1009 | ); |
@@ -1060,13 +1060,13 @@ discard block |
||
| 1060 | 1060 | 'EVT_timezone_string' => $this->request->getRequestParam('timezone_string'), |
| 1061 | 1061 | ]; |
| 1062 | 1062 | // check if the new EDTR reg options meta box is being used, and if so, don't run updates for legacy version |
| 1063 | - if (! $this->admin_config->useAdvancedEditor() || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1064 | - $event_values['EVT_display_ticket_selector'] = $this->request->getRequestParam( |
|
| 1063 | + if ( ! $this->admin_config->useAdvancedEditor() || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1064 | + $event_values['EVT_display_ticket_selector'] = $this->request->getRequestParam( |
|
| 1065 | 1065 | 'display_ticket_selector', |
| 1066 | 1066 | false, |
| 1067 | 1067 | 'bool' |
| 1068 | 1068 | ); |
| 1069 | - $event_values['EVT_additional_limit'] = min( |
|
| 1069 | + $event_values['EVT_additional_limit'] = min( |
|
| 1070 | 1070 | apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
| 1071 | 1071 | $this->request->getRequestParam('additional_limit', null, 'int') |
| 1072 | 1072 | ); |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | // the following are default callbacks for event attachment updates |
| 1103 | 1103 | // that can be overridden by caffeinated functionality and/or addons. |
| 1104 | 1104 | $event_update_callbacks = []; |
| 1105 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
| 1105 | + if ( ! $this->admin_config->useAdvancedEditor()) { |
|
| 1106 | 1106 | $event_update_callbacks['_default_venue_update'] = [$this, '_default_venue_update']; |
| 1107 | 1107 | $event_update_callbacks['_default_tickets_update'] = [$this, '_default_tickets_update']; |
| 1108 | 1108 | } |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | */ |
| 1174 | 1174 | protected function _default_venue_update(EE_Event $event, $data) |
| 1175 | 1175 | { |
| 1176 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1176 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
| 1177 | 1177 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
| 1178 | 1178 | $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
| 1179 | 1179 | // very important. If we don't have a venue name... |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | 'status' => 'publish', |
| 1205 | 1205 | ]; |
| 1206 | 1206 | // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
| 1207 | - if (! empty($venue_id)) { |
|
| 1207 | + if ( ! empty($venue_id)) { |
|
| 1208 | 1208 | $update_where = [$venue_model->primary_key_name() => $venue_id]; |
| 1209 | 1209 | $rows_affected = $venue_model->update($venue_array, [$update_where]); |
| 1210 | 1210 | // we've gotta make sure that the venue is always attached to a revision.. |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | isset($datetime_data['DTT_EVT_end']) && ! empty($datetime_data['DTT_EVT_end']) |
| 1247 | 1247 | ? $datetime_data['DTT_EVT_end'] |
| 1248 | 1248 | : $datetime_data['DTT_EVT_start']; |
| 1249 | - $datetime_values = [ |
|
| 1249 | + $datetime_values = [ |
|
| 1250 | 1250 | 'DTT_ID' => ! empty($datetime_data['DTT_ID']) ? $datetime_data['DTT_ID'] : null, |
| 1251 | 1251 | 'DTT_EVT_start' => $datetime_data['DTT_EVT_start'], |
| 1252 | 1252 | 'DTT_EVT_end' => $datetime_data['DTT_EVT_end'], |
@@ -1255,9 +1255,9 @@ discard block |
||
| 1255 | 1255 | ]; |
| 1256 | 1256 | // if we have an id then let's get existing object first and then set the new values. |
| 1257 | 1257 | // Otherwise we instantiate a new object for save. |
| 1258 | - if (! empty($datetime_data['DTT_ID'])) { |
|
| 1258 | + if ( ! empty($datetime_data['DTT_ID'])) { |
|
| 1259 | 1259 | $datetime = EEM_Datetime::instance($event_timezone)->get_one_by_ID($datetime_data['DTT_ID']); |
| 1260 | - if (! $datetime instanceof EE_Ticket) { |
|
| 1260 | + if ( ! $datetime instanceof EE_Ticket) { |
|
| 1261 | 1261 | throw new RuntimeException( |
| 1262 | 1262 | sprintf( |
| 1263 | 1263 | esc_html__( |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | } else { |
| 1277 | 1277 | $datetime = EE_Datetime::new_instance($datetime_values, $event_timezone, $date_formats); |
| 1278 | 1278 | } |
| 1279 | - if (! $datetime instanceof EE_Datetime) { |
|
| 1279 | + if ( ! $datetime instanceof EE_Datetime) { |
|
| 1280 | 1280 | throw new RuntimeException( |
| 1281 | 1281 | sprintf( |
| 1282 | 1282 | esc_html__( |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | |
| 1303 | 1303 | // set up some default start and end dates in case those are not present in the incoming data |
| 1304 | 1304 | $default_start_date = new DateTime('now', new DateTimeZone($event->get_timezone())); |
| 1305 | - $default_start_date = $default_start_date->format($date_formats[0] . ' ' . $date_formats[1]); |
|
| 1305 | + $default_start_date = $default_start_date->format($date_formats[0].' '.$date_formats[1]); |
|
| 1306 | 1306 | // use the start date of the first datetime for the end date |
| 1307 | 1307 | $first_datetime = $event->first_datetime(); |
| 1308 | 1308 | $default_end_date = $first_datetime->start_date_and_time($date_formats[0], $date_formats[1]); |
@@ -1310,8 +1310,8 @@ discard block |
||
| 1310 | 1310 | // now process the incoming data |
| 1311 | 1311 | foreach ($data['edit_tickets'] as $row => $ticket_data) { |
| 1312 | 1312 | $update_prices = false; |
| 1313 | - $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount']) |
|
| 1314 | - ? $data['edit_prices'][ $row ][1]['PRC_amount'] |
|
| 1313 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
| 1314 | + ? $data['edit_prices'][$row][1]['PRC_amount'] |
|
| 1315 | 1315 | : 0; |
| 1316 | 1316 | // trim inputs to ensure any excess whitespace is removed. |
| 1317 | 1317 | $ticket_data = array_map('trim', $ticket_data); |
@@ -1352,9 +1352,9 @@ discard block |
||
| 1352 | 1352 | // ticket didn't get removed or added to any datetime in the session but DID have it's items modified. |
| 1353 | 1353 | // keep in mind that if the ticket has been sold (and we have changed pricing information), |
| 1354 | 1354 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
| 1355 | - if (! empty($ticket_data['TKT_ID'])) { |
|
| 1355 | + if ( ! empty($ticket_data['TKT_ID'])) { |
|
| 1356 | 1356 | $existing_ticket = EEM_Ticket::instance($event_timezone)->get_one_by_ID($ticket_data['TKT_ID']); |
| 1357 | - if (! $existing_ticket instanceof EE_Ticket) { |
|
| 1357 | + if ( ! $existing_ticket instanceof EE_Ticket) { |
|
| 1358 | 1358 | throw new RuntimeException( |
| 1359 | 1359 | sprintf( |
| 1360 | 1360 | esc_html__( |
@@ -1403,7 +1403,7 @@ discard block |
||
| 1403 | 1403 | $existing_ticket->save(); |
| 1404 | 1404 | // make sure this ticket is still recorded in our $saved_tickets |
| 1405 | 1405 | // so we don't run it through the regular trash routine. |
| 1406 | - $saved_tickets[ $existing_ticket->ID() ] = $existing_ticket; |
|
| 1406 | + $saved_tickets[$existing_ticket->ID()] = $existing_ticket; |
|
| 1407 | 1407 | // create new ticket that's a copy of the existing except, |
| 1408 | 1408 | // (a new id of course and not archived) AND has the new TKT_price associated with it. |
| 1409 | 1409 | $new_ticket = clone $existing_ticket; |
@@ -1420,7 +1420,7 @@ discard block |
||
| 1420 | 1420 | $ticket = EE_Ticket::new_instance($ticket_values, $event_timezone, $date_formats); |
| 1421 | 1421 | $update_prices = true; |
| 1422 | 1422 | } |
| 1423 | - if (! $ticket instanceof EE_Ticket) { |
|
| 1423 | + if ( ! $ticket instanceof EE_Ticket) { |
|
| 1424 | 1424 | throw new RuntimeException( |
| 1425 | 1425 | sprintf( |
| 1426 | 1426 | esc_html__( |
@@ -1444,9 +1444,9 @@ discard block |
||
| 1444 | 1444 | } |
| 1445 | 1445 | // initially let's add the ticket to the datetime |
| 1446 | 1446 | $datetime->_add_relation_to($ticket, 'Ticket'); |
| 1447 | - $saved_tickets[ $ticket->ID() ] = $ticket; |
|
| 1447 | + $saved_tickets[$ticket->ID()] = $ticket; |
|
| 1448 | 1448 | // add prices to ticket |
| 1449 | - $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $ticket, $update_prices); |
|
| 1449 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $ticket, $update_prices); |
|
| 1450 | 1450 | } |
| 1451 | 1451 | // however now we need to handle permanently deleting tickets via the ui. |
| 1452 | 1452 | // Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. |
@@ -1458,7 +1458,7 @@ discard block |
||
| 1458 | 1458 | $id = absint($id); |
| 1459 | 1459 | // get the ticket for this id |
| 1460 | 1460 | $ticket_to_remove = EEM_Ticket::instance()->get_one_by_ID($id); |
| 1461 | - if (! $ticket_to_remove instanceof EE_Ticket) { |
|
| 1461 | + if ( ! $ticket_to_remove instanceof EE_Ticket) { |
|
| 1462 | 1462 | continue; |
| 1463 | 1463 | } |
| 1464 | 1464 | // need to get all the related datetimes on this ticket and remove from every single one of them |
@@ -1515,7 +1515,7 @@ discard block |
||
| 1515 | 1515 | $price->set($field, $new_price); |
| 1516 | 1516 | } |
| 1517 | 1517 | } |
| 1518 | - if (! $price instanceof EE_Price) { |
|
| 1518 | + if ( ! $price instanceof EE_Price) { |
|
| 1519 | 1519 | throw new RuntimeException( |
| 1520 | 1520 | sprintf( |
| 1521 | 1521 | esc_html__( |
@@ -1557,13 +1557,13 @@ discard block |
||
| 1557 | 1557 | { |
| 1558 | 1558 | // load formatter helper |
| 1559 | 1559 | // args for getting related registrations |
| 1560 | - $approved_query_args = [ |
|
| 1560 | + $approved_query_args = [ |
|
| 1561 | 1561 | [ |
| 1562 | 1562 | 'REG_deleted' => 0, |
| 1563 | 1563 | 'STS_ID' => EEM_Registration::status_id_approved, |
| 1564 | 1564 | ], |
| 1565 | 1565 | ]; |
| 1566 | - $not_approved_query_args = [ |
|
| 1566 | + $not_approved_query_args = [ |
|
| 1567 | 1567 | [ |
| 1568 | 1568 | 'REG_deleted' => 0, |
| 1569 | 1569 | 'STS_ID' => EEM_Registration::status_id_not_approved, |
@@ -1626,7 +1626,7 @@ discard block |
||
| 1626 | 1626 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
| 1627 | 1627 | // load template |
| 1628 | 1628 | EEH_Template::display_template( |
| 1629 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1629 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
| 1630 | 1630 | $publish_box_extra_args |
| 1631 | 1631 | ); |
| 1632 | 1632 | } |
@@ -1657,7 +1657,7 @@ discard block |
||
| 1657 | 1657 | $this->verify_cpt_object(); |
| 1658 | 1658 | $use_advanced_editor = $this->admin_config->useAdvancedEditor(); |
| 1659 | 1659 | // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
| 1660 | - if (! $use_advanced_editor || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1660 | + if ( ! $use_advanced_editor || ! $this->feature->allowed('use_reg_options_meta_box')) { |
|
| 1661 | 1661 | $this->addMetaBox( |
| 1662 | 1662 | 'espresso_event_editor_event_options', |
| 1663 | 1663 | esc_html__('Event Registration Options', 'event_espresso'), |
@@ -1666,7 +1666,7 @@ discard block |
||
| 1666 | 1666 | 'side' |
| 1667 | 1667 | ); |
| 1668 | 1668 | } |
| 1669 | - if (! $use_advanced_editor) { |
|
| 1669 | + if ( ! $use_advanced_editor) { |
|
| 1670 | 1670 | $this->addMetaBox( |
| 1671 | 1671 | 'espresso_event_editor_tickets', |
| 1672 | 1672 | esc_html__('Event Datetime & Ticket', 'event_espresso'), |
@@ -1678,7 +1678,7 @@ discard block |
||
| 1678 | 1678 | } elseif ($this->feature->allowed('use_reg_options_meta_box')) { |
| 1679 | 1679 | add_action( |
| 1680 | 1680 | 'add_meta_boxes_espresso_events', |
| 1681 | - function () { |
|
| 1681 | + function() { |
|
| 1682 | 1682 | global $current_screen; |
| 1683 | 1683 | remove_meta_box('authordiv', $current_screen, 'normal'); |
| 1684 | 1684 | }, |
@@ -1713,7 +1713,7 @@ discard block |
||
| 1713 | 1713 | 'trash_icon' => 'dashicons dashicons-lock', |
| 1714 | 1714 | 'disabled' => '', |
| 1715 | 1715 | ]; |
| 1716 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1716 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1717 | 1717 | /** |
| 1718 | 1718 | * 1. Start with retrieving Datetimes |
| 1719 | 1719 | * 2. Fore each datetime get related tickets |
@@ -1739,24 +1739,24 @@ discard block |
||
| 1739 | 1739 | 'default_where_conditions' => 'none', |
| 1740 | 1740 | ] |
| 1741 | 1741 | ); |
| 1742 | - if (! empty($related_tickets)) { |
|
| 1742 | + if ( ! empty($related_tickets)) { |
|
| 1743 | 1743 | $template_args['total_ticket_rows'] = count($related_tickets); |
| 1744 | 1744 | $row = 0; |
| 1745 | 1745 | foreach ($related_tickets as $ticket) { |
| 1746 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1746 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1747 | 1747 | $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
| 1748 | 1748 | $row++; |
| 1749 | 1749 | } |
| 1750 | 1750 | } else { |
| 1751 | 1751 | $template_args['total_ticket_rows'] = 1; |
| 1752 | 1752 | /** @type EE_Ticket $ticket */ |
| 1753 | - $ticket = $ticket_model->create_default_object(); |
|
| 1753 | + $ticket = $ticket_model->create_default_object(); |
|
| 1754 | 1754 | $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
| 1755 | 1755 | } |
| 1756 | 1756 | } else { |
| 1757 | 1757 | $template_args['time'] = $times[0]; |
| 1758 | 1758 | /** @type EE_Ticket[] $tickets */ |
| 1759 | - $tickets = $ticket_model->get_all_default_tickets(); |
|
| 1759 | + $tickets = $ticket_model->get_all_default_tickets(); |
|
| 1760 | 1760 | $template_args['ticket_rows'] .= $this->_get_ticket_row($tickets[1]); |
| 1761 | 1761 | // NOTE: we're just sending the first default row |
| 1762 | 1762 | // (decaf can't manage default tickets so this should be sufficient); |
@@ -1771,9 +1771,9 @@ discard block |
||
| 1771 | 1771 | $ticket_model->create_default_object(), |
| 1772 | 1772 | true |
| 1773 | 1773 | ); |
| 1774 | - $template = apply_filters( |
|
| 1774 | + $template = apply_filters( |
|
| 1775 | 1775 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
| 1776 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1776 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
| 1777 | 1777 | ); |
| 1778 | 1778 | EEH_Template::display_template($template, $template_args); |
| 1779 | 1779 | } |
@@ -1793,7 +1793,7 @@ discard block |
||
| 1793 | 1793 | private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
| 1794 | 1794 | { |
| 1795 | 1795 | $template_args = [ |
| 1796 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1796 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
| 1797 | 1797 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
| 1798 | 1798 | : '', |
| 1799 | 1799 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
@@ -1805,10 +1805,10 @@ discard block |
||
| 1805 | 1805 | 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
| 1806 | 1806 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
| 1807 | 1807 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
| 1808 | - 'trash_icon' => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1809 | - && (! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1808 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1809 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1810 | 1810 | ? 'trash-icon dashicons dashicons-post-trash clickable' : 'dashicons dashicons-lock', |
| 1811 | - 'disabled' => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1811 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1812 | 1812 | : ' disabled=disabled', |
| 1813 | 1813 | ]; |
| 1814 | 1814 | $price = $ticket->ID() !== 0 |
@@ -1832,7 +1832,7 @@ discard block |
||
| 1832 | 1832 | } |
| 1833 | 1833 | if (empty($template_args['TKT_end_date'])) { |
| 1834 | 1834 | // get the earliest datetime (if present); |
| 1835 | - $earliest_datetime = $this->_cpt_model_obj->ID() > 0 |
|
| 1835 | + $earliest_datetime = $this->_cpt_model_obj->ID() > 0 |
|
| 1836 | 1836 | ? $this->_cpt_model_obj->get_first_related( |
| 1837 | 1837 | 'Datetime', |
| 1838 | 1838 | ['order_by' => ['DTT_EVT_start' => 'ASC']] |
@@ -1845,7 +1845,7 @@ discard block |
||
| 1845 | 1845 | $template_args = array_merge($template_args, $price_args); |
| 1846 | 1846 | $template = apply_filters( |
| 1847 | 1847 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
| 1848 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1848 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
| 1849 | 1849 | $ticket |
| 1850 | 1850 | ); |
| 1851 | 1851 | return EEH_Template::display_template($template, $template_args, true); |
@@ -1858,7 +1858,7 @@ discard block |
||
| 1858 | 1858 | */ |
| 1859 | 1859 | public function registration_options_meta_box() |
| 1860 | 1860 | { |
| 1861 | - $yes_no_values = [ |
|
| 1861 | + $yes_no_values = [ |
|
| 1862 | 1862 | ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
| 1863 | 1863 | ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
| 1864 | 1864 | ]; |
@@ -1880,12 +1880,12 @@ discard block |
||
| 1880 | 1880 | $default_reg_status_values, |
| 1881 | 1881 | $this->_cpt_model_obj->default_registration_status() |
| 1882 | 1882 | ); |
| 1883 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1883 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1884 | 1884 | 'display_desc', |
| 1885 | 1885 | $yes_no_values, |
| 1886 | 1886 | $this->_cpt_model_obj->display_description() |
| 1887 | 1887 | ); |
| 1888 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1888 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1889 | 1889 | 'display_ticket_selector', |
| 1890 | 1890 | $yes_no_values, |
| 1891 | 1891 | $this->_cpt_model_obj->display_ticket_selector(), |
@@ -1901,7 +1901,7 @@ discard block |
||
| 1901 | 1901 | $default_reg_status_values |
| 1902 | 1902 | ); |
| 1903 | 1903 | EEH_Template::display_template( |
| 1904 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1904 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
| 1905 | 1905 | $template_args |
| 1906 | 1906 | ); |
| 1907 | 1907 | } |
@@ -1924,7 +1924,7 @@ discard block |
||
| 1924 | 1924 | { |
| 1925 | 1925 | $EEM_Event = $this->_event_model(); |
| 1926 | 1926 | $offset = ($current_page - 1) * $per_page; |
| 1927 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1927 | + $limit = $count ? null : $offset.','.$per_page; |
|
| 1928 | 1928 | $orderby = $this->request->getRequestParam('orderby', 'EVT_ID'); |
| 1929 | 1929 | $order = $this->request->getRequestParam('order', 'DESC'); |
| 1930 | 1930 | $month_range = $this->request->getRequestParam('month_range'); |
@@ -1961,10 +1961,10 @@ discard block |
||
| 1961 | 1961 | $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
| 1962 | 1962 | if ($month_range) { |
| 1963 | 1963 | $DateTime = new DateTime( |
| 1964 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1964 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
| 1965 | 1965 | new DateTimeZone('UTC') |
| 1966 | 1966 | ); |
| 1967 | - $start = $DateTime->getTimestamp(); |
|
| 1967 | + $start = $DateTime->getTimestamp(); |
|
| 1968 | 1968 | // set the datetime to be the end of the month |
| 1969 | 1969 | $DateTime->setDate( |
| 1970 | 1970 | $year_r, |
@@ -1989,11 +1989,11 @@ discard block |
||
| 1989 | 1989 | ->format(implode(' ', $start_formats)); |
| 1990 | 1990 | $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]]; |
| 1991 | 1991 | } |
| 1992 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1992 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1993 | 1993 | $where['EVT_wp_user'] = get_current_user_id(); |
| 1994 | 1994 | } else { |
| 1995 | - if (! isset($where['status'])) { |
|
| 1996 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1995 | + if ( ! isset($where['status'])) { |
|
| 1996 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1997 | 1997 | $where['OR'] = [ |
| 1998 | 1998 | 'status*restrict_private' => ['!=', 'private'], |
| 1999 | 1999 | 'AND' => [ |
@@ -2015,7 +2015,7 @@ discard block |
||
| 2015 | 2015 | // search query handling |
| 2016 | 2016 | $search_term = $this->request->getRequestParam('s'); |
| 2017 | 2017 | if ($search_term) { |
| 2018 | - $search_term = '%' . $search_term . '%'; |
|
| 2018 | + $search_term = '%'.$search_term.'%'; |
|
| 2019 | 2019 | $where['OR'] = [ |
| 2020 | 2020 | 'EVT_name' => ['LIKE', $search_term], |
| 2021 | 2021 | 'EVT_desc' => ['LIKE', $search_term], |
@@ -2123,7 +2123,7 @@ discard block |
||
| 2123 | 2123 | // clean status |
| 2124 | 2124 | $event_status = sanitize_key($event_status); |
| 2125 | 2125 | // grab status |
| 2126 | - if (! empty($event_status)) { |
|
| 2126 | + if ( ! empty($event_status)) { |
|
| 2127 | 2127 | $success = $this->_change_event_status($EVT_ID, $event_status); |
| 2128 | 2128 | } else { |
| 2129 | 2129 | $success = false; |
@@ -2163,7 +2163,7 @@ discard block |
||
| 2163 | 2163 | // clean status |
| 2164 | 2164 | $event_status = sanitize_key($event_status); |
| 2165 | 2165 | // grab status |
| 2166 | - if (! empty($event_status)) { |
|
| 2166 | + if ( ! empty($event_status)) { |
|
| 2167 | 2167 | $success = true; |
| 2168 | 2168 | // determine the event id and set to array. |
| 2169 | 2169 | $EVT_IDs = $this->request->getRequestParam('EVT_IDs', [], 'int', true); |
@@ -2209,7 +2209,7 @@ discard block |
||
| 2209 | 2209 | private function _change_event_status($EVT_ID = 0, $event_status = '') |
| 2210 | 2210 | { |
| 2211 | 2211 | // grab event id |
| 2212 | - if (! $EVT_ID) { |
|
| 2212 | + if ( ! $EVT_ID) { |
|
| 2213 | 2213 | $msg = esc_html__( |
| 2214 | 2214 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
| 2215 | 2215 | 'event_espresso' |
@@ -2246,7 +2246,7 @@ discard block |
||
| 2246 | 2246 | // use class to change status |
| 2247 | 2247 | $this->_cpt_model_obj->set_status($event_status); |
| 2248 | 2248 | $success = $this->_cpt_model_obj->save(); |
| 2249 | - if (! $success) { |
|
| 2249 | + if ( ! $success) { |
|
| 2250 | 2250 | $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
| 2251 | 2251 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
| 2252 | 2252 | return false; |
@@ -2304,7 +2304,7 @@ discard block |
||
| 2304 | 2304 | */ |
| 2305 | 2305 | protected function getModelObjNodeGroupPersister() |
| 2306 | 2306 | { |
| 2307 | - if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) { |
|
| 2307 | + if ( ! $this->model_obj_node_group_persister instanceof NodeGroupDao) { |
|
| 2308 | 2308 | $this->model_obj_node_group_persister = |
| 2309 | 2309 | $this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao'); |
| 2310 | 2310 | } |
@@ -2607,7 +2607,7 @@ discard block |
||
| 2607 | 2607 | . esc_html__( |
| 2608 | 2608 | 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
| 2609 | 2609 | 'event_espresso' |
| 2610 | - ) . '</strong>'; |
|
| 2610 | + ).'</strong>'; |
|
| 2611 | 2611 | $this->display_admin_caf_preview_page('template_settings_tab'); |
| 2612 | 2612 | } |
| 2613 | 2613 | |
@@ -2628,11 +2628,11 @@ discard block |
||
| 2628 | 2628 | $this->_set_empty_category_object(); |
| 2629 | 2629 | // only set if we've got an id |
| 2630 | 2630 | $category_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
| 2631 | - if (! $category_ID) { |
|
| 2631 | + if ( ! $category_ID) { |
|
| 2632 | 2632 | return; |
| 2633 | 2633 | } |
| 2634 | 2634 | $term = get_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY); |
| 2635 | - if (! empty($term)) { |
|
| 2635 | + if ( ! empty($term)) { |
|
| 2636 | 2636 | $this->_category->category_name = $term->name; |
| 2637 | 2637 | $this->_category->category_identifier = $term->slug; |
| 2638 | 2638 | $this->_category->category_desc = $term->description; |
@@ -2736,7 +2736,7 @@ discard block |
||
| 2736 | 2736 | $category_select_values, |
| 2737 | 2737 | $this->_category->parent |
| 2738 | 2738 | ); |
| 2739 | - $template_args = [ |
|
| 2739 | + $template_args = [ |
|
| 2740 | 2740 | 'category' => $this->_category, |
| 2741 | 2741 | 'category_select' => $category_select, |
| 2742 | 2742 | 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
@@ -2744,7 +2744,7 @@ discard block |
||
| 2744 | 2744 | 'disable' => '', |
| 2745 | 2745 | 'disabled_message' => false, |
| 2746 | 2746 | ]; |
| 2747 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2747 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
| 2748 | 2748 | return EEH_Template::display_template($template, $template_args, true); |
| 2749 | 2749 | } |
| 2750 | 2750 | |
@@ -2834,7 +2834,7 @@ discard block |
||
| 2834 | 2834 | $insert_ids = $update |
| 2835 | 2835 | ? wp_update_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args) |
| 2836 | 2836 | : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args); |
| 2837 | - if (! is_array($insert_ids)) { |
|
| 2837 | + if ( ! is_array($insert_ids)) { |
|
| 2838 | 2838 | $msg = esc_html__( |
| 2839 | 2839 | 'An error occurred and the category has not been saved to the database.', |
| 2840 | 2840 | 'event_espresso' |
@@ -2870,7 +2870,7 @@ discard block |
||
| 2870 | 2870 | $where = ['taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]; |
| 2871 | 2871 | $search_term = $this->request->getRequestParam('s'); |
| 2872 | 2872 | if ($search_term) { |
| 2873 | - $search_term = '%' . $search_term . '%'; |
|
| 2873 | + $search_term = '%'.$search_term.'%'; |
|
| 2874 | 2874 | $where['OR'] = [ |
| 2875 | 2875 | 'Term.name' => ['LIKE', $search_term], |
| 2876 | 2876 | 'description' => ['LIKE', $search_term], |
@@ -2879,7 +2879,7 @@ discard block |
||
| 2879 | 2879 | $query_params = [ |
| 2880 | 2880 | $where, |
| 2881 | 2881 | 'order_by' => [$orderby => $order], |
| 2882 | - 'limit' => $limit . ',' . $per_page, |
|
| 2882 | + 'limit' => $limit.','.$per_page, |
|
| 2883 | 2883 | 'force_join' => ['Term'], |
| 2884 | 2884 | ]; |
| 2885 | 2885 | return $count |
@@ -14,177 +14,177 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class Events_Admin_List_Table extends EE_Admin_List_Table |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var Events_Admin_Page |
|
| 19 | - */ |
|
| 20 | - protected $_admin_page; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var EE_Datetime |
|
| 24 | - */ |
|
| 25 | - private $_dtt; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Initial setup of data properties for the list table. |
|
| 30 | - * |
|
| 31 | - * @throws Exception |
|
| 32 | - */ |
|
| 33 | - protected function _setup_data() |
|
| 34 | - { |
|
| 35 | - $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
| 36 | - $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Set up of additional properties for the list table. |
|
| 42 | - * |
|
| 43 | - * @throws EE_Error |
|
| 44 | - * @throws ReflectionException |
|
| 45 | - */ |
|
| 46 | - protected function _set_properties() |
|
| 47 | - { |
|
| 48 | - $this->_wp_list_args = [ |
|
| 49 | - 'singular' => esc_html__('event', 'event_espresso'), |
|
| 50 | - 'plural' => esc_html__('events', 'event_espresso'), |
|
| 51 | - 'ajax' => true, // for now |
|
| 52 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 53 | - ]; |
|
| 54 | - $approved_registrations = esc_html__('Approved Registrations', 'event_espresso'); |
|
| 55 | - $this->_columns = [ |
|
| 56 | - 'cb' => '<input type="checkbox" />', |
|
| 57 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 58 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
| 59 | - 'author' => esc_html__('Author', 'event_espresso'), |
|
| 60 | - 'venue' => esc_html__('Venue', 'event_espresso'), |
|
| 61 | - 'start_date_time' => esc_html__('Event Start', 'event_espresso'), |
|
| 62 | - 'reg_begins' => esc_html__('On Sale', 'event_espresso'), |
|
| 63 | - 'attendees' => ' |
|
| 17 | + /** |
|
| 18 | + * @var Events_Admin_Page |
|
| 19 | + */ |
|
| 20 | + protected $_admin_page; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var EE_Datetime |
|
| 24 | + */ |
|
| 25 | + private $_dtt; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Initial setup of data properties for the list table. |
|
| 30 | + * |
|
| 31 | + * @throws Exception |
|
| 32 | + */ |
|
| 33 | + protected function _setup_data() |
|
| 34 | + { |
|
| 35 | + $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
| 36 | + $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Set up of additional properties for the list table. |
|
| 42 | + * |
|
| 43 | + * @throws EE_Error |
|
| 44 | + * @throws ReflectionException |
|
| 45 | + */ |
|
| 46 | + protected function _set_properties() |
|
| 47 | + { |
|
| 48 | + $this->_wp_list_args = [ |
|
| 49 | + 'singular' => esc_html__('event', 'event_espresso'), |
|
| 50 | + 'plural' => esc_html__('events', 'event_espresso'), |
|
| 51 | + 'ajax' => true, // for now |
|
| 52 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 53 | + ]; |
|
| 54 | + $approved_registrations = esc_html__('Approved Registrations', 'event_espresso'); |
|
| 55 | + $this->_columns = [ |
|
| 56 | + 'cb' => '<input type="checkbox" />', |
|
| 57 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 58 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
| 59 | + 'author' => esc_html__('Author', 'event_espresso'), |
|
| 60 | + 'venue' => esc_html__('Venue', 'event_espresso'), |
|
| 61 | + 'start_date_time' => esc_html__('Event Start', 'event_espresso'), |
|
| 62 | + 'reg_begins' => esc_html__('On Sale', 'event_espresso'), |
|
| 63 | + 'attendees' => ' |
|
| 64 | 64 | <span class="show-on-mobile-view-only" aria-label="' . $approved_registrations . '"> |
| 65 | 65 | ' . $approved_registrations . ' |
| 66 | 66 | </span> |
| 67 | 67 | <span class="dashicons dashicons-groups ee-icon-color-ee-green"></span>', |
| 68 | - 'actions' => $this->actionsColumnHeader(), |
|
| 69 | - ]; |
|
| 70 | - $this->addConditionalColumns(); |
|
| 71 | - $this->_sortable_columns = [ |
|
| 72 | - 'id' => ['EVT_ID' => true], |
|
| 73 | - 'name' => ['EVT_name' => false], |
|
| 74 | - 'author' => ['EVT_wp_user' => false], |
|
| 75 | - 'venue' => ['Venue.VNU_name' => false], |
|
| 76 | - 'start_date_time' => ['Datetime.DTT_EVT_start' => false], |
|
| 77 | - 'reg_begins' => ['Datetime.Ticket.TKT_start_date' => false], |
|
| 78 | - ]; |
|
| 79 | - |
|
| 80 | - $this->_primary_column = 'id'; |
|
| 81 | - $this->_hidden_columns = ['author', 'event_category']; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @return array |
|
| 87 | - */ |
|
| 88 | - protected function _get_table_filters(): array |
|
| 89 | - { |
|
| 90 | - return []; // no filters with decaf |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Setup of views properties. |
|
| 96 | - * |
|
| 97 | - * @throws InvalidDataTypeException |
|
| 98 | - * @throws InvalidInterfaceException |
|
| 99 | - * @throws InvalidArgumentException |
|
| 100 | - * @throws EE_Error |
|
| 101 | - * @throws EE_Error |
|
| 102 | - * @throws EE_Error |
|
| 103 | - */ |
|
| 104 | - protected function _add_view_counts() |
|
| 105 | - { |
|
| 106 | - $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 107 | - $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 108 | - if ( |
|
| 109 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 110 | - 'ee_delete_events', |
|
| 111 | - 'espresso_events_trash_events' |
|
| 112 | - ) |
|
| 113 | - ) { |
|
| 114 | - $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @param EE_Event $item |
|
| 121 | - * @return string |
|
| 122 | - */ |
|
| 123 | - protected function _get_row_class($item): string |
|
| 124 | - { |
|
| 125 | - $class = parent::_get_row_class($item); |
|
| 126 | - if ($this->_has_checkbox_column) { |
|
| 127 | - $class .= ' has-checkbox-column'; |
|
| 128 | - } |
|
| 129 | - return $class; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @param EE_Event $item |
|
| 135 | - * @return string |
|
| 136 | - * @throws EE_Error |
|
| 137 | - * @throws ReflectionException |
|
| 138 | - */ |
|
| 139 | - public function column_cb($item): string |
|
| 140 | - { |
|
| 141 | - if (! $item instanceof EE_Event) { |
|
| 142 | - return ''; |
|
| 143 | - } |
|
| 144 | - $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
| 145 | - $content = sprintf( |
|
| 146 | - '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
| 147 | - $item->ID() |
|
| 148 | - ); |
|
| 149 | - return $this->columnContent('cb', $content, 'center'); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @param EE_Event $event |
|
| 155 | - * @return string |
|
| 156 | - * @throws EE_Error |
|
| 157 | - * @throws ReflectionException |
|
| 158 | - */ |
|
| 159 | - public function column_id(EE_Event $event): string |
|
| 160 | - { |
|
| 161 | - $content = $event->ID(); |
|
| 162 | - $content .= '<span class="show-on-mobile-view-only">'; |
|
| 163 | - $content .= $this->column_name($event, false); |
|
| 164 | - $content .= '</span>'; |
|
| 165 | - return $this->columnContent('id', $content, 'end'); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @param EE_Event $event |
|
| 171 | - * @param bool $prep_content |
|
| 172 | - * @return string |
|
| 173 | - * @throws EE_Error |
|
| 174 | - * @throws ReflectionException |
|
| 175 | - */ |
|
| 176 | - public function column_name(EE_Event $event, bool $prep_content = true): string |
|
| 177 | - { |
|
| 178 | - $edit_query_args = [ |
|
| 179 | - 'action' => 'edit', |
|
| 180 | - 'post' => $event->ID(), |
|
| 181 | - ]; |
|
| 182 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 183 | - $actions = $this->_column_name_action_setup($event); |
|
| 184 | - $status = esc_attr($event->get_active_status()); |
|
| 185 | - $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 186 | - $status_dot = '<span class="ee-status-dot ee-status-bg--' . $status . '"></span>'; |
|
| 187 | - $content = ' |
|
| 68 | + 'actions' => $this->actionsColumnHeader(), |
|
| 69 | + ]; |
|
| 70 | + $this->addConditionalColumns(); |
|
| 71 | + $this->_sortable_columns = [ |
|
| 72 | + 'id' => ['EVT_ID' => true], |
|
| 73 | + 'name' => ['EVT_name' => false], |
|
| 74 | + 'author' => ['EVT_wp_user' => false], |
|
| 75 | + 'venue' => ['Venue.VNU_name' => false], |
|
| 76 | + 'start_date_time' => ['Datetime.DTT_EVT_start' => false], |
|
| 77 | + 'reg_begins' => ['Datetime.Ticket.TKT_start_date' => false], |
|
| 78 | + ]; |
|
| 79 | + |
|
| 80 | + $this->_primary_column = 'id'; |
|
| 81 | + $this->_hidden_columns = ['author', 'event_category']; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @return array |
|
| 87 | + */ |
|
| 88 | + protected function _get_table_filters(): array |
|
| 89 | + { |
|
| 90 | + return []; // no filters with decaf |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Setup of views properties. |
|
| 96 | + * |
|
| 97 | + * @throws InvalidDataTypeException |
|
| 98 | + * @throws InvalidInterfaceException |
|
| 99 | + * @throws InvalidArgumentException |
|
| 100 | + * @throws EE_Error |
|
| 101 | + * @throws EE_Error |
|
| 102 | + * @throws EE_Error |
|
| 103 | + */ |
|
| 104 | + protected function _add_view_counts() |
|
| 105 | + { |
|
| 106 | + $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 107 | + $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 108 | + if ( |
|
| 109 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 110 | + 'ee_delete_events', |
|
| 111 | + 'espresso_events_trash_events' |
|
| 112 | + ) |
|
| 113 | + ) { |
|
| 114 | + $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @param EE_Event $item |
|
| 121 | + * @return string |
|
| 122 | + */ |
|
| 123 | + protected function _get_row_class($item): string |
|
| 124 | + { |
|
| 125 | + $class = parent::_get_row_class($item); |
|
| 126 | + if ($this->_has_checkbox_column) { |
|
| 127 | + $class .= ' has-checkbox-column'; |
|
| 128 | + } |
|
| 129 | + return $class; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @param EE_Event $item |
|
| 135 | + * @return string |
|
| 136 | + * @throws EE_Error |
|
| 137 | + * @throws ReflectionException |
|
| 138 | + */ |
|
| 139 | + public function column_cb($item): string |
|
| 140 | + { |
|
| 141 | + if (! $item instanceof EE_Event) { |
|
| 142 | + return ''; |
|
| 143 | + } |
|
| 144 | + $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
| 145 | + $content = sprintf( |
|
| 146 | + '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
| 147 | + $item->ID() |
|
| 148 | + ); |
|
| 149 | + return $this->columnContent('cb', $content, 'center'); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @param EE_Event $event |
|
| 155 | + * @return string |
|
| 156 | + * @throws EE_Error |
|
| 157 | + * @throws ReflectionException |
|
| 158 | + */ |
|
| 159 | + public function column_id(EE_Event $event): string |
|
| 160 | + { |
|
| 161 | + $content = $event->ID(); |
|
| 162 | + $content .= '<span class="show-on-mobile-view-only">'; |
|
| 163 | + $content .= $this->column_name($event, false); |
|
| 164 | + $content .= '</span>'; |
|
| 165 | + return $this->columnContent('id', $content, 'end'); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @param EE_Event $event |
|
| 171 | + * @param bool $prep_content |
|
| 172 | + * @return string |
|
| 173 | + * @throws EE_Error |
|
| 174 | + * @throws ReflectionException |
|
| 175 | + */ |
|
| 176 | + public function column_name(EE_Event $event, bool $prep_content = true): string |
|
| 177 | + { |
|
| 178 | + $edit_query_args = [ |
|
| 179 | + 'action' => 'edit', |
|
| 180 | + 'post' => $event->ID(), |
|
| 181 | + ]; |
|
| 182 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 183 | + $actions = $this->_column_name_action_setup($event); |
|
| 184 | + $status = esc_attr($event->get_active_status()); |
|
| 185 | + $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 186 | + $status_dot = '<span class="ee-status-dot ee-status-bg--' . $status . '"></span>'; |
|
| 187 | + $content = ' |
|
| 188 | 188 | <div class="ee-layout-row"> |
| 189 | 189 | <a class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" |
| 190 | 190 | aria-label="' . $pretty_status . '" |
@@ -194,409 +194,409 @@ discard block |
||
| 194 | 194 | </a> |
| 195 | 195 | </div>'; |
| 196 | 196 | |
| 197 | - $content .= $this->row_actions($actions); |
|
| 198 | - |
|
| 199 | - return $prep_content ? $this->columnContent('name', $content) : $content; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Just a method for setting up the actions for the name column |
|
| 205 | - * |
|
| 206 | - * @param EE_Event $event |
|
| 207 | - * @return array array of actions |
|
| 208 | - * @throws EE_Error |
|
| 209 | - * @throws InvalidArgumentException |
|
| 210 | - * @throws InvalidDataTypeException |
|
| 211 | - * @throws InvalidInterfaceException |
|
| 212 | - * @throws ReflectionException |
|
| 213 | - */ |
|
| 214 | - protected function _column_name_action_setup(EE_Event $event): array |
|
| 215 | - { |
|
| 216 | - // todo: remove when attendees is active |
|
| 217 | - if (! defined('REG_ADMIN_URL')) { |
|
| 218 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 219 | - } |
|
| 220 | - $actions = []; |
|
| 221 | - $restore_event_link = ''; |
|
| 222 | - $delete_event_link = ''; |
|
| 223 | - $trash_event_link = ''; |
|
| 224 | - if ( |
|
| 225 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 226 | - 'ee_edit_event', |
|
| 227 | - 'espresso_events_edit', |
|
| 228 | - $event->ID() |
|
| 229 | - ) |
|
| 230 | - ) { |
|
| 231 | - $edit_query_args = [ |
|
| 232 | - 'action' => 'edit', |
|
| 233 | - 'post' => $event->ID(), |
|
| 234 | - ]; |
|
| 235 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 236 | - $actions['edit'] = '<a href="' . $edit_link . '" class="ee-aria-tooltip" ' |
|
| 237 | - . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 238 | - . esc_html__('Edit', 'event_espresso') |
|
| 239 | - . '</a>'; |
|
| 240 | - } |
|
| 241 | - if ( |
|
| 242 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 243 | - 'ee_read_registrations', |
|
| 244 | - 'espresso_registrations_view_registration' |
|
| 245 | - ) |
|
| 246 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 247 | - 'ee_read_event', |
|
| 248 | - 'espresso_registrations_view_registration', |
|
| 249 | - $event->ID() |
|
| 250 | - ) |
|
| 251 | - ) { |
|
| 252 | - $attendees_query_args = [ |
|
| 253 | - 'action' => 'default', |
|
| 254 | - 'event_id' => $event->ID(), |
|
| 255 | - ]; |
|
| 256 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 257 | - $actions['attendees'] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip"' |
|
| 258 | - . ' aria-label="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
| 259 | - . esc_html__('Registrations', 'event_espresso') |
|
| 260 | - . '</a>'; |
|
| 261 | - } |
|
| 262 | - if ( |
|
| 263 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 264 | - 'ee_delete_event', |
|
| 265 | - 'espresso_events_trash_event', |
|
| 266 | - $event->ID() |
|
| 267 | - ) |
|
| 268 | - ) { |
|
| 269 | - $trash_event_query_args = [ |
|
| 270 | - 'action' => 'trash_event', |
|
| 271 | - 'EVT_ID' => $event->ID(), |
|
| 272 | - ]; |
|
| 273 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 274 | - $trash_event_query_args, |
|
| 275 | - EVENTS_ADMIN_URL |
|
| 276 | - ); |
|
| 277 | - } |
|
| 278 | - if ( |
|
| 279 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 280 | - 'ee_delete_event', |
|
| 281 | - 'espresso_events_restore_event', |
|
| 282 | - $event->ID() |
|
| 283 | - ) |
|
| 284 | - ) { |
|
| 285 | - $restore_event_query_args = [ |
|
| 286 | - 'action' => 'restore_event', |
|
| 287 | - 'EVT_ID' => $event->ID(), |
|
| 288 | - ]; |
|
| 289 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 290 | - $restore_event_query_args, |
|
| 291 | - EVENTS_ADMIN_URL |
|
| 292 | - ); |
|
| 293 | - } |
|
| 294 | - if ( |
|
| 295 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 296 | - 'ee_delete_event', |
|
| 297 | - 'espresso_events_delete_event', |
|
| 298 | - $event->ID() |
|
| 299 | - ) |
|
| 300 | - ) { |
|
| 301 | - $delete_event_query_args = [ |
|
| 302 | - 'action' => 'delete_event', |
|
| 303 | - 'EVT_ID' => $event->ID(), |
|
| 304 | - ]; |
|
| 305 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 306 | - $delete_event_query_args, |
|
| 307 | - EVENTS_ADMIN_URL |
|
| 308 | - ); |
|
| 309 | - } |
|
| 310 | - $view_link = get_permalink($event->ID()); |
|
| 311 | - $actions['view'] = '<a href="' . $view_link . '" class="ee-aria-tooltip"' |
|
| 312 | - . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
| 313 | - . esc_html__('View', 'event_espresso') |
|
| 314 | - . '</a>'; |
|
| 315 | - if ($event->get('status') === 'trash') { |
|
| 316 | - if ( |
|
| 317 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 318 | - 'ee_delete_event', |
|
| 319 | - 'espresso_events_restore_event', |
|
| 320 | - $event->ID() |
|
| 321 | - ) |
|
| 322 | - ) { |
|
| 323 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" class="ee-aria-tooltip"' |
|
| 324 | - . ' aria-label="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
| 325 | - . '">' |
|
| 326 | - . esc_html__('Restore from Trash', 'event_espresso') |
|
| 327 | - . '</a>'; |
|
| 328 | - } |
|
| 329 | - if ( |
|
| 330 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 331 | - 'ee_delete_event', |
|
| 332 | - 'espresso_events_delete_event', |
|
| 333 | - $event->ID() |
|
| 334 | - ) |
|
| 335 | - ) { |
|
| 336 | - $actions['delete'] = '<a href="' . $delete_event_link . '" class="ee-aria-tooltip"' |
|
| 337 | - . ' aria-label="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
| 338 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
| 339 | - . '</a>'; |
|
| 340 | - } |
|
| 341 | - } else { |
|
| 342 | - if ( |
|
| 343 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 344 | - 'ee_delete_event', |
|
| 345 | - 'espresso_events_trash_event', |
|
| 346 | - $event->ID() |
|
| 347 | - ) |
|
| 348 | - ) { |
|
| 349 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '" class="ee-aria-tooltip"' |
|
| 350 | - . ' aria-label="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
| 351 | - . esc_html__('Trash', 'event_espresso') |
|
| 352 | - . '</a>'; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - return $actions; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * @param EE_Event $event |
|
| 361 | - * @return string |
|
| 362 | - * @throws EE_Error |
|
| 363 | - * @throws ReflectionException |
|
| 364 | - */ |
|
| 365 | - public function column_author(EE_Event $event): string |
|
| 366 | - { |
|
| 367 | - // user author info |
|
| 368 | - $event_author = get_userdata($event->wp_user()); |
|
| 369 | - $gravatar = get_avatar($event->wp_user(), '24'); |
|
| 370 | - // filter link |
|
| 371 | - $query_args = [ |
|
| 372 | - 'action' => 'default', |
|
| 373 | - 'EVT_wp_user' => $event->wp_user(), |
|
| 374 | - ]; |
|
| 375 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 376 | - $content = '<div class="ee-layout-row">'; |
|
| 377 | - $content .= $gravatar . ' <a href="' . $filter_url . '" class="ee-aria-tooltip"' |
|
| 378 | - . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 379 | - . $event_author->display_name |
|
| 380 | - . '</a>'; |
|
| 381 | - $content .= '</div>'; |
|
| 382 | - return $this->columnContent('author', $content); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * @param EE_Event $event |
|
| 388 | - * @return string |
|
| 389 | - * @throws EE_Error |
|
| 390 | - * @throws ReflectionException |
|
| 391 | - */ |
|
| 392 | - public function column_event_category(EE_Event $event): string |
|
| 393 | - { |
|
| 394 | - $event_categories = $event->get_all_event_categories(); |
|
| 395 | - $content = implode( |
|
| 396 | - ', ', |
|
| 397 | - array_map( |
|
| 398 | - function (EE_Term $category) { |
|
| 399 | - return $category->name(); |
|
| 400 | - }, |
|
| 401 | - $event_categories |
|
| 402 | - ) |
|
| 403 | - ); |
|
| 404 | - return $this->columnContent('event_category', $content); |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * @param EE_Event $event |
|
| 410 | - * @return string |
|
| 411 | - * @throws EE_Error |
|
| 412 | - * @throws ReflectionException |
|
| 413 | - */ |
|
| 414 | - public function column_venue(EE_Event $event): string |
|
| 415 | - { |
|
| 416 | - $venue = $event->get_first_related('Venue'); |
|
| 417 | - $content = ! empty($venue) |
|
| 418 | - ? $venue->name() |
|
| 419 | - : ''; |
|
| 420 | - return $this->columnContent('venue', $content); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * @param EE_Event $event |
|
| 426 | - * @return string |
|
| 427 | - * @throws EE_Error |
|
| 428 | - * @throws ReflectionException |
|
| 429 | - */ |
|
| 430 | - public function column_start_date_time(EE_Event $event): string |
|
| 431 | - { |
|
| 432 | - $content = $this->_dtt instanceof EE_Datetime |
|
| 433 | - ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
| 434 | - : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
| 435 | - return $this->columnContent('start_date_time', $content); |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * @param EE_Event $event |
|
| 441 | - * @return string |
|
| 442 | - * @throws EE_Error |
|
| 443 | - * @throws ReflectionException |
|
| 444 | - */ |
|
| 445 | - public function column_reg_begins(EE_Event $event): string |
|
| 446 | - { |
|
| 447 | - $reg_start = $event->get_ticket_with_earliest_start_time(); |
|
| 448 | - $content = $reg_start instanceof EE_Ticket |
|
| 449 | - ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
| 450 | - : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
| 451 | - return $this->columnContent('reg_begins', $content); |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - |
|
| 455 | - /** |
|
| 456 | - * @param EE_Event $event |
|
| 457 | - * @return string |
|
| 458 | - * @throws EE_Error |
|
| 459 | - * @throws InvalidArgumentException |
|
| 460 | - * @throws InvalidDataTypeException |
|
| 461 | - * @throws InvalidInterfaceException |
|
| 462 | - * @throws ReflectionException |
|
| 463 | - */ |
|
| 464 | - public function column_attendees(EE_Event $event): string |
|
| 465 | - { |
|
| 466 | - $attendees_query_args = [ |
|
| 467 | - 'action' => 'default', |
|
| 468 | - 'event_id' => $event->ID(), |
|
| 469 | - ]; |
|
| 470 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 471 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count($event->ID()); |
|
| 472 | - |
|
| 473 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 474 | - 'ee_read_event', |
|
| 475 | - 'espresso_registrations_view_registration', |
|
| 476 | - $event->ID() |
|
| 477 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 478 | - 'ee_read_registrations', |
|
| 479 | - 'espresso_registrations_view_registration' |
|
| 480 | - ) |
|
| 481 | - ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 482 | - : $registered_attendees; |
|
| 483 | - return $this->columnContent('attendees', $content, 'center'); |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * @param EE_Event $event |
|
| 489 | - * @return float |
|
| 490 | - * @throws EE_Error |
|
| 491 | - * @throws InvalidArgumentException |
|
| 492 | - * @throws InvalidDataTypeException |
|
| 493 | - * @throws InvalidInterfaceException |
|
| 494 | - * @throws ReflectionException |
|
| 495 | - */ |
|
| 496 | - public function column_tkts_sold(EE_Event $event): float |
|
| 497 | - { |
|
| 498 | - $content = EEM_Ticket::instance()->sum([['Datetime.EVT_ID' => $event->ID()]], 'TKT_sold'); |
|
| 499 | - return $this->columnContent('tkts_sold', $content); |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * @param EE_Event $event |
|
| 505 | - * @return string |
|
| 506 | - * @throws EE_Error |
|
| 507 | - * @throws InvalidArgumentException |
|
| 508 | - * @throws InvalidDataTypeException |
|
| 509 | - * @throws InvalidInterfaceException |
|
| 510 | - * @throws ReflectionException |
|
| 511 | - */ |
|
| 512 | - public function column_actions(EE_Event $event): string |
|
| 513 | - { |
|
| 514 | - // todo: remove when attendees is active |
|
| 515 | - if (! defined('REG_ADMIN_URL')) { |
|
| 516 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 517 | - } |
|
| 518 | - $action_links = []; |
|
| 519 | - $view_link = get_permalink($event->ID()); |
|
| 520 | - $action_links[] = '<a href="' . $view_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 521 | - . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank"> |
|
| 197 | + $content .= $this->row_actions($actions); |
|
| 198 | + |
|
| 199 | + return $prep_content ? $this->columnContent('name', $content) : $content; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Just a method for setting up the actions for the name column |
|
| 205 | + * |
|
| 206 | + * @param EE_Event $event |
|
| 207 | + * @return array array of actions |
|
| 208 | + * @throws EE_Error |
|
| 209 | + * @throws InvalidArgumentException |
|
| 210 | + * @throws InvalidDataTypeException |
|
| 211 | + * @throws InvalidInterfaceException |
|
| 212 | + * @throws ReflectionException |
|
| 213 | + */ |
|
| 214 | + protected function _column_name_action_setup(EE_Event $event): array |
|
| 215 | + { |
|
| 216 | + // todo: remove when attendees is active |
|
| 217 | + if (! defined('REG_ADMIN_URL')) { |
|
| 218 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 219 | + } |
|
| 220 | + $actions = []; |
|
| 221 | + $restore_event_link = ''; |
|
| 222 | + $delete_event_link = ''; |
|
| 223 | + $trash_event_link = ''; |
|
| 224 | + if ( |
|
| 225 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 226 | + 'ee_edit_event', |
|
| 227 | + 'espresso_events_edit', |
|
| 228 | + $event->ID() |
|
| 229 | + ) |
|
| 230 | + ) { |
|
| 231 | + $edit_query_args = [ |
|
| 232 | + 'action' => 'edit', |
|
| 233 | + 'post' => $event->ID(), |
|
| 234 | + ]; |
|
| 235 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 236 | + $actions['edit'] = '<a href="' . $edit_link . '" class="ee-aria-tooltip" ' |
|
| 237 | + . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 238 | + . esc_html__('Edit', 'event_espresso') |
|
| 239 | + . '</a>'; |
|
| 240 | + } |
|
| 241 | + if ( |
|
| 242 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 243 | + 'ee_read_registrations', |
|
| 244 | + 'espresso_registrations_view_registration' |
|
| 245 | + ) |
|
| 246 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 247 | + 'ee_read_event', |
|
| 248 | + 'espresso_registrations_view_registration', |
|
| 249 | + $event->ID() |
|
| 250 | + ) |
|
| 251 | + ) { |
|
| 252 | + $attendees_query_args = [ |
|
| 253 | + 'action' => 'default', |
|
| 254 | + 'event_id' => $event->ID(), |
|
| 255 | + ]; |
|
| 256 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 257 | + $actions['attendees'] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip"' |
|
| 258 | + . ' aria-label="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
| 259 | + . esc_html__('Registrations', 'event_espresso') |
|
| 260 | + . '</a>'; |
|
| 261 | + } |
|
| 262 | + if ( |
|
| 263 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 264 | + 'ee_delete_event', |
|
| 265 | + 'espresso_events_trash_event', |
|
| 266 | + $event->ID() |
|
| 267 | + ) |
|
| 268 | + ) { |
|
| 269 | + $trash_event_query_args = [ |
|
| 270 | + 'action' => 'trash_event', |
|
| 271 | + 'EVT_ID' => $event->ID(), |
|
| 272 | + ]; |
|
| 273 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 274 | + $trash_event_query_args, |
|
| 275 | + EVENTS_ADMIN_URL |
|
| 276 | + ); |
|
| 277 | + } |
|
| 278 | + if ( |
|
| 279 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 280 | + 'ee_delete_event', |
|
| 281 | + 'espresso_events_restore_event', |
|
| 282 | + $event->ID() |
|
| 283 | + ) |
|
| 284 | + ) { |
|
| 285 | + $restore_event_query_args = [ |
|
| 286 | + 'action' => 'restore_event', |
|
| 287 | + 'EVT_ID' => $event->ID(), |
|
| 288 | + ]; |
|
| 289 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 290 | + $restore_event_query_args, |
|
| 291 | + EVENTS_ADMIN_URL |
|
| 292 | + ); |
|
| 293 | + } |
|
| 294 | + if ( |
|
| 295 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 296 | + 'ee_delete_event', |
|
| 297 | + 'espresso_events_delete_event', |
|
| 298 | + $event->ID() |
|
| 299 | + ) |
|
| 300 | + ) { |
|
| 301 | + $delete_event_query_args = [ |
|
| 302 | + 'action' => 'delete_event', |
|
| 303 | + 'EVT_ID' => $event->ID(), |
|
| 304 | + ]; |
|
| 305 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 306 | + $delete_event_query_args, |
|
| 307 | + EVENTS_ADMIN_URL |
|
| 308 | + ); |
|
| 309 | + } |
|
| 310 | + $view_link = get_permalink($event->ID()); |
|
| 311 | + $actions['view'] = '<a href="' . $view_link . '" class="ee-aria-tooltip"' |
|
| 312 | + . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
| 313 | + . esc_html__('View', 'event_espresso') |
|
| 314 | + . '</a>'; |
|
| 315 | + if ($event->get('status') === 'trash') { |
|
| 316 | + if ( |
|
| 317 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 318 | + 'ee_delete_event', |
|
| 319 | + 'espresso_events_restore_event', |
|
| 320 | + $event->ID() |
|
| 321 | + ) |
|
| 322 | + ) { |
|
| 323 | + $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" class="ee-aria-tooltip"' |
|
| 324 | + . ' aria-label="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
| 325 | + . '">' |
|
| 326 | + . esc_html__('Restore from Trash', 'event_espresso') |
|
| 327 | + . '</a>'; |
|
| 328 | + } |
|
| 329 | + if ( |
|
| 330 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 331 | + 'ee_delete_event', |
|
| 332 | + 'espresso_events_delete_event', |
|
| 333 | + $event->ID() |
|
| 334 | + ) |
|
| 335 | + ) { |
|
| 336 | + $actions['delete'] = '<a href="' . $delete_event_link . '" class="ee-aria-tooltip"' |
|
| 337 | + . ' aria-label="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
| 338 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
| 339 | + . '</a>'; |
|
| 340 | + } |
|
| 341 | + } else { |
|
| 342 | + if ( |
|
| 343 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 344 | + 'ee_delete_event', |
|
| 345 | + 'espresso_events_trash_event', |
|
| 346 | + $event->ID() |
|
| 347 | + ) |
|
| 348 | + ) { |
|
| 349 | + $actions['move to trash'] = '<a href="' . $trash_event_link . '" class="ee-aria-tooltip"' |
|
| 350 | + . ' aria-label="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
| 351 | + . esc_html__('Trash', 'event_espresso') |
|
| 352 | + . '</a>'; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + return $actions; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * @param EE_Event $event |
|
| 361 | + * @return string |
|
| 362 | + * @throws EE_Error |
|
| 363 | + * @throws ReflectionException |
|
| 364 | + */ |
|
| 365 | + public function column_author(EE_Event $event): string |
|
| 366 | + { |
|
| 367 | + // user author info |
|
| 368 | + $event_author = get_userdata($event->wp_user()); |
|
| 369 | + $gravatar = get_avatar($event->wp_user(), '24'); |
|
| 370 | + // filter link |
|
| 371 | + $query_args = [ |
|
| 372 | + 'action' => 'default', |
|
| 373 | + 'EVT_wp_user' => $event->wp_user(), |
|
| 374 | + ]; |
|
| 375 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 376 | + $content = '<div class="ee-layout-row">'; |
|
| 377 | + $content .= $gravatar . ' <a href="' . $filter_url . '" class="ee-aria-tooltip"' |
|
| 378 | + . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 379 | + . $event_author->display_name |
|
| 380 | + . '</a>'; |
|
| 381 | + $content .= '</div>'; |
|
| 382 | + return $this->columnContent('author', $content); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * @param EE_Event $event |
|
| 388 | + * @return string |
|
| 389 | + * @throws EE_Error |
|
| 390 | + * @throws ReflectionException |
|
| 391 | + */ |
|
| 392 | + public function column_event_category(EE_Event $event): string |
|
| 393 | + { |
|
| 394 | + $event_categories = $event->get_all_event_categories(); |
|
| 395 | + $content = implode( |
|
| 396 | + ', ', |
|
| 397 | + array_map( |
|
| 398 | + function (EE_Term $category) { |
|
| 399 | + return $category->name(); |
|
| 400 | + }, |
|
| 401 | + $event_categories |
|
| 402 | + ) |
|
| 403 | + ); |
|
| 404 | + return $this->columnContent('event_category', $content); |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * @param EE_Event $event |
|
| 410 | + * @return string |
|
| 411 | + * @throws EE_Error |
|
| 412 | + * @throws ReflectionException |
|
| 413 | + */ |
|
| 414 | + public function column_venue(EE_Event $event): string |
|
| 415 | + { |
|
| 416 | + $venue = $event->get_first_related('Venue'); |
|
| 417 | + $content = ! empty($venue) |
|
| 418 | + ? $venue->name() |
|
| 419 | + : ''; |
|
| 420 | + return $this->columnContent('venue', $content); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * @param EE_Event $event |
|
| 426 | + * @return string |
|
| 427 | + * @throws EE_Error |
|
| 428 | + * @throws ReflectionException |
|
| 429 | + */ |
|
| 430 | + public function column_start_date_time(EE_Event $event): string |
|
| 431 | + { |
|
| 432 | + $content = $this->_dtt instanceof EE_Datetime |
|
| 433 | + ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
| 434 | + : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
| 435 | + return $this->columnContent('start_date_time', $content); |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * @param EE_Event $event |
|
| 441 | + * @return string |
|
| 442 | + * @throws EE_Error |
|
| 443 | + * @throws ReflectionException |
|
| 444 | + */ |
|
| 445 | + public function column_reg_begins(EE_Event $event): string |
|
| 446 | + { |
|
| 447 | + $reg_start = $event->get_ticket_with_earliest_start_time(); |
|
| 448 | + $content = $reg_start instanceof EE_Ticket |
|
| 449 | + ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
| 450 | + : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
| 451 | + return $this->columnContent('reg_begins', $content); |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + |
|
| 455 | + /** |
|
| 456 | + * @param EE_Event $event |
|
| 457 | + * @return string |
|
| 458 | + * @throws EE_Error |
|
| 459 | + * @throws InvalidArgumentException |
|
| 460 | + * @throws InvalidDataTypeException |
|
| 461 | + * @throws InvalidInterfaceException |
|
| 462 | + * @throws ReflectionException |
|
| 463 | + */ |
|
| 464 | + public function column_attendees(EE_Event $event): string |
|
| 465 | + { |
|
| 466 | + $attendees_query_args = [ |
|
| 467 | + 'action' => 'default', |
|
| 468 | + 'event_id' => $event->ID(), |
|
| 469 | + ]; |
|
| 470 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 471 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($event->ID()); |
|
| 472 | + |
|
| 473 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 474 | + 'ee_read_event', |
|
| 475 | + 'espresso_registrations_view_registration', |
|
| 476 | + $event->ID() |
|
| 477 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 478 | + 'ee_read_registrations', |
|
| 479 | + 'espresso_registrations_view_registration' |
|
| 480 | + ) |
|
| 481 | + ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 482 | + : $registered_attendees; |
|
| 483 | + return $this->columnContent('attendees', $content, 'center'); |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * @param EE_Event $event |
|
| 489 | + * @return float |
|
| 490 | + * @throws EE_Error |
|
| 491 | + * @throws InvalidArgumentException |
|
| 492 | + * @throws InvalidDataTypeException |
|
| 493 | + * @throws InvalidInterfaceException |
|
| 494 | + * @throws ReflectionException |
|
| 495 | + */ |
|
| 496 | + public function column_tkts_sold(EE_Event $event): float |
|
| 497 | + { |
|
| 498 | + $content = EEM_Ticket::instance()->sum([['Datetime.EVT_ID' => $event->ID()]], 'TKT_sold'); |
|
| 499 | + return $this->columnContent('tkts_sold', $content); |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * @param EE_Event $event |
|
| 505 | + * @return string |
|
| 506 | + * @throws EE_Error |
|
| 507 | + * @throws InvalidArgumentException |
|
| 508 | + * @throws InvalidDataTypeException |
|
| 509 | + * @throws InvalidInterfaceException |
|
| 510 | + * @throws ReflectionException |
|
| 511 | + */ |
|
| 512 | + public function column_actions(EE_Event $event): string |
|
| 513 | + { |
|
| 514 | + // todo: remove when attendees is active |
|
| 515 | + if (! defined('REG_ADMIN_URL')) { |
|
| 516 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 517 | + } |
|
| 518 | + $action_links = []; |
|
| 519 | + $view_link = get_permalink($event->ID()); |
|
| 520 | + $action_links[] = '<a href="' . $view_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 521 | + . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank"> |
|
| 522 | 522 | <span class="dashicons dashicons-visibility"></span></a>'; |
| 523 | - if ( |
|
| 524 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 525 | - 'ee_edit_event', |
|
| 526 | - 'espresso_events_edit', |
|
| 527 | - $event->ID() |
|
| 528 | - ) |
|
| 529 | - ) { |
|
| 530 | - $edit_query_args = [ |
|
| 531 | - 'action' => 'edit', |
|
| 532 | - 'post' => $event->ID(), |
|
| 533 | - ]; |
|
| 534 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 535 | - $action_links[] = '<a href="' . $edit_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 536 | - . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 537 | - . '<span class="dashicons dashicons-calendar-alt"></span>' |
|
| 538 | - . '</a>'; |
|
| 539 | - } |
|
| 540 | - if ( |
|
| 541 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 542 | - 'ee_read_registrations', |
|
| 543 | - 'espresso_registrations_view_registration' |
|
| 544 | - ) |
|
| 545 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 546 | - 'ee_read_event', |
|
| 547 | - 'espresso_registrations_view_registration', |
|
| 548 | - $event->ID() |
|
| 549 | - ) |
|
| 550 | - ) { |
|
| 551 | - $attendees_query_args = [ |
|
| 552 | - 'action' => 'default', |
|
| 553 | - 'event_id' => $event->ID(), |
|
| 554 | - ]; |
|
| 555 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 556 | - $action_links[] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 557 | - . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 558 | - . '<span class="dashicons dashicons-groups"></span>' |
|
| 559 | - . '</a>'; |
|
| 560 | - } |
|
| 561 | - $action_links = apply_filters( |
|
| 562 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 563 | - $action_links, |
|
| 564 | - $event |
|
| 565 | - ); |
|
| 566 | - $content = $this->_action_string( |
|
| 567 | - implode("\n\t", $action_links), |
|
| 568 | - $event, |
|
| 569 | - 'div', |
|
| 570 | - 'event-overview-actions ee-list-table-actions' |
|
| 571 | - ); |
|
| 572 | - return $this->columnContent('actions', $this->actionsModalMenu($content)); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * Helper for adding columns conditionally |
|
| 578 | - * |
|
| 579 | - * @throws EE_Error |
|
| 580 | - * @throws InvalidArgumentException |
|
| 581 | - * @throws InvalidDataTypeException |
|
| 582 | - * @throws InvalidInterfaceException |
|
| 583 | - * @throws ReflectionException |
|
| 584 | - */ |
|
| 585 | - private function addConditionalColumns() |
|
| 586 | - { |
|
| 587 | - $event_category_count = EEM_Term::instance()->count( |
|
| 588 | - [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]] |
|
| 589 | - ); |
|
| 590 | - if ($event_category_count === 0) { |
|
| 591 | - return; |
|
| 592 | - } |
|
| 593 | - $column_array = []; |
|
| 594 | - foreach ($this->_columns as $column => $column_label) { |
|
| 595 | - $column_array[ $column ] = $column_label; |
|
| 596 | - if ($column === 'venue') { |
|
| 597 | - $column_array['event_category'] = esc_html__('Event Category', 'event_espresso'); |
|
| 598 | - } |
|
| 599 | - } |
|
| 600 | - $this->_columns = $column_array; |
|
| 601 | - } |
|
| 523 | + if ( |
|
| 524 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 525 | + 'ee_edit_event', |
|
| 526 | + 'espresso_events_edit', |
|
| 527 | + $event->ID() |
|
| 528 | + ) |
|
| 529 | + ) { |
|
| 530 | + $edit_query_args = [ |
|
| 531 | + 'action' => 'edit', |
|
| 532 | + 'post' => $event->ID(), |
|
| 533 | + ]; |
|
| 534 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 535 | + $action_links[] = '<a href="' . $edit_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 536 | + . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 537 | + . '<span class="dashicons dashicons-calendar-alt"></span>' |
|
| 538 | + . '</a>'; |
|
| 539 | + } |
|
| 540 | + if ( |
|
| 541 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 542 | + 'ee_read_registrations', |
|
| 543 | + 'espresso_registrations_view_registration' |
|
| 544 | + ) |
|
| 545 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 546 | + 'ee_read_event', |
|
| 547 | + 'espresso_registrations_view_registration', |
|
| 548 | + $event->ID() |
|
| 549 | + ) |
|
| 550 | + ) { |
|
| 551 | + $attendees_query_args = [ |
|
| 552 | + 'action' => 'default', |
|
| 553 | + 'event_id' => $event->ID(), |
|
| 554 | + ]; |
|
| 555 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 556 | + $action_links[] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 557 | + . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 558 | + . '<span class="dashicons dashicons-groups"></span>' |
|
| 559 | + . '</a>'; |
|
| 560 | + } |
|
| 561 | + $action_links = apply_filters( |
|
| 562 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 563 | + $action_links, |
|
| 564 | + $event |
|
| 565 | + ); |
|
| 566 | + $content = $this->_action_string( |
|
| 567 | + implode("\n\t", $action_links), |
|
| 568 | + $event, |
|
| 569 | + 'div', |
|
| 570 | + 'event-overview-actions ee-list-table-actions' |
|
| 571 | + ); |
|
| 572 | + return $this->columnContent('actions', $this->actionsModalMenu($content)); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * Helper for adding columns conditionally |
|
| 578 | + * |
|
| 579 | + * @throws EE_Error |
|
| 580 | + * @throws InvalidArgumentException |
|
| 581 | + * @throws InvalidDataTypeException |
|
| 582 | + * @throws InvalidInterfaceException |
|
| 583 | + * @throws ReflectionException |
|
| 584 | + */ |
|
| 585 | + private function addConditionalColumns() |
|
| 586 | + { |
|
| 587 | + $event_category_count = EEM_Term::instance()->count( |
|
| 588 | + [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]] |
|
| 589 | + ); |
|
| 590 | + if ($event_category_count === 0) { |
|
| 591 | + return; |
|
| 592 | + } |
|
| 593 | + $column_array = []; |
|
| 594 | + foreach ($this->_columns as $column => $column_label) { |
|
| 595 | + $column_array[ $column ] = $column_label; |
|
| 596 | + if ($column === 'venue') { |
|
| 597 | + $column_array['event_category'] = esc_html__('Event Category', 'event_espresso'); |
|
| 598 | + } |
|
| 599 | + } |
|
| 600 | + $this->_columns = $column_array; |
|
| 601 | + } |
|
| 602 | 602 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | protected function _set_properties() |
| 47 | 47 | { |
| 48 | - $this->_wp_list_args = [ |
|
| 48 | + $this->_wp_list_args = [ |
|
| 49 | 49 | 'singular' => esc_html__('event', 'event_espresso'), |
| 50 | 50 | 'plural' => esc_html__('events', 'event_espresso'), |
| 51 | 51 | 'ajax' => true, // for now |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | 'start_date_time' => esc_html__('Event Start', 'event_espresso'), |
| 62 | 62 | 'reg_begins' => esc_html__('On Sale', 'event_espresso'), |
| 63 | 63 | 'attendees' => ' |
| 64 | - <span class="show-on-mobile-view-only" aria-label="' . $approved_registrations . '"> |
|
| 65 | - ' . $approved_registrations . ' |
|
| 64 | + <span class="show-on-mobile-view-only" aria-label="' . $approved_registrations.'"> |
|
| 65 | + ' . $approved_registrations.' |
|
| 66 | 66 | </span> |
| 67 | 67 | <span class="dashicons dashicons-groups ee-icon-color-ee-green"></span>', |
| 68 | 68 | 'actions' => $this->actionsColumnHeader(), |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function column_cb($item): string |
| 140 | 140 | { |
| 141 | - if (! $item instanceof EE_Event) { |
|
| 141 | + if ( ! $item instanceof EE_Event) { |
|
| 142 | 142 | return ''; |
| 143 | 143 | } |
| 144 | 144 | $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | $actions = $this->_column_name_action_setup($event); |
| 184 | 184 | $status = esc_attr($event->get_active_status()); |
| 185 | 185 | $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
| 186 | - $status_dot = '<span class="ee-status-dot ee-status-bg--' . $status . '"></span>'; |
|
| 186 | + $status_dot = '<span class="ee-status-dot ee-status-bg--'.$status.'"></span>'; |
|
| 187 | 187 | $content = ' |
| 188 | 188 | <div class="ee-layout-row"> |
| 189 | - <a class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" |
|
| 190 | - aria-label="' . $pretty_status . '" |
|
| 191 | - href="' . $edit_link . '" |
|
| 189 | + <a class="row-title ee-status-color--' . $status.' ee-aria-tooltip" |
|
| 190 | + aria-label="' . $pretty_status.'" |
|
| 191 | + href="' . $edit_link.'" |
|
| 192 | 192 | > |
| 193 | - ' . $status_dot . $event->name() . ' |
|
| 193 | + ' . $status_dot.$event->name().' |
|
| 194 | 194 | </a> |
| 195 | 195 | </div>'; |
| 196 | 196 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | protected function _column_name_action_setup(EE_Event $event): array |
| 215 | 215 | { |
| 216 | 216 | // todo: remove when attendees is active |
| 217 | - if (! defined('REG_ADMIN_URL')) { |
|
| 217 | + if ( ! defined('REG_ADMIN_URL')) { |
|
| 218 | 218 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
| 219 | 219 | } |
| 220 | 220 | $actions = []; |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | 'post' => $event->ID(), |
| 234 | 234 | ]; |
| 235 | 235 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
| 236 | - $actions['edit'] = '<a href="' . $edit_link . '" class="ee-aria-tooltip" ' |
|
| 237 | - . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 236 | + $actions['edit'] = '<a href="'.$edit_link.'" class="ee-aria-tooltip" ' |
|
| 237 | + . ' aria-label="'.esc_attr__('Edit Event', 'event_espresso').'">' |
|
| 238 | 238 | . esc_html__('Edit', 'event_espresso') |
| 239 | 239 | . '</a>'; |
| 240 | 240 | } |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | 'event_id' => $event->ID(), |
| 255 | 255 | ]; |
| 256 | 256 | $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
| 257 | - $actions['attendees'] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip"' |
|
| 258 | - . ' aria-label="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
| 257 | + $actions['attendees'] = '<a href="'.$attendees_link.'" class="ee-aria-tooltip"' |
|
| 258 | + . ' aria-label="'.esc_attr__('View Registrations', 'event_espresso').'">' |
|
| 259 | 259 | . esc_html__('Registrations', 'event_espresso') |
| 260 | 260 | . '</a>'; |
| 261 | 261 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | 'action' => 'trash_event', |
| 271 | 271 | 'EVT_ID' => $event->ID(), |
| 272 | 272 | ]; |
| 273 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 273 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 274 | 274 | $trash_event_query_args, |
| 275 | 275 | EVENTS_ADMIN_URL |
| 276 | 276 | ); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | 'action' => 'restore_event', |
| 287 | 287 | 'EVT_ID' => $event->ID(), |
| 288 | 288 | ]; |
| 289 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 289 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 290 | 290 | $restore_event_query_args, |
| 291 | 291 | EVENTS_ADMIN_URL |
| 292 | 292 | ); |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | 'action' => 'delete_event', |
| 303 | 303 | 'EVT_ID' => $event->ID(), |
| 304 | 304 | ]; |
| 305 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 305 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 306 | 306 | $delete_event_query_args, |
| 307 | 307 | EVENTS_ADMIN_URL |
| 308 | 308 | ); |
| 309 | 309 | } |
| 310 | 310 | $view_link = get_permalink($event->ID()); |
| 311 | - $actions['view'] = '<a href="' . $view_link . '" class="ee-aria-tooltip"' |
|
| 312 | - . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
| 311 | + $actions['view'] = '<a href="'.$view_link.'" class="ee-aria-tooltip"' |
|
| 312 | + . ' aria-label="'.esc_attr__('View Event', 'event_espresso').'">' |
|
| 313 | 313 | . esc_html__('View', 'event_espresso') |
| 314 | 314 | . '</a>'; |
| 315 | 315 | if ($event->get('status') === 'trash') { |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | $event->ID() |
| 321 | 321 | ) |
| 322 | 322 | ) { |
| 323 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" class="ee-aria-tooltip"' |
|
| 324 | - . ' aria-label="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
| 323 | + $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'" class="ee-aria-tooltip"' |
|
| 324 | + . ' aria-label="'.esc_attr__('Restore from Trash', 'event_espresso') |
|
| 325 | 325 | . '">' |
| 326 | 326 | . esc_html__('Restore from Trash', 'event_espresso') |
| 327 | 327 | . '</a>'; |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | $event->ID() |
| 334 | 334 | ) |
| 335 | 335 | ) { |
| 336 | - $actions['delete'] = '<a href="' . $delete_event_link . '" class="ee-aria-tooltip"' |
|
| 337 | - . ' aria-label="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
| 336 | + $actions['delete'] = '<a href="'.$delete_event_link.'" class="ee-aria-tooltip"' |
|
| 337 | + . ' aria-label="'.esc_attr__('Delete Permanently', 'event_espresso').'">' |
|
| 338 | 338 | . esc_html__('Delete Permanently', 'event_espresso') |
| 339 | 339 | . '</a>'; |
| 340 | 340 | } |
@@ -346,8 +346,8 @@ discard block |
||
| 346 | 346 | $event->ID() |
| 347 | 347 | ) |
| 348 | 348 | ) { |
| 349 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '" class="ee-aria-tooltip"' |
|
| 350 | - . ' aria-label="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
| 349 | + $actions['move to trash'] = '<a href="'.$trash_event_link.'" class="ee-aria-tooltip"' |
|
| 350 | + . ' aria-label="'.esc_attr__('Trash Event', 'event_espresso').'">' |
|
| 351 | 351 | . esc_html__('Trash', 'event_espresso') |
| 352 | 352 | . '</a>'; |
| 353 | 353 | } |
@@ -374,11 +374,11 @@ discard block |
||
| 374 | 374 | ]; |
| 375 | 375 | $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
| 376 | 376 | $content = '<div class="ee-layout-row">'; |
| 377 | - $content .= $gravatar . ' <a href="' . $filter_url . '" class="ee-aria-tooltip"' |
|
| 378 | - . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 377 | + $content .= $gravatar.' <a href="'.$filter_url.'" class="ee-aria-tooltip"' |
|
| 378 | + . ' aria-label="'.esc_attr__('Click to filter events by this author.', 'event_espresso').'">' |
|
| 379 | 379 | . $event_author->display_name |
| 380 | 380 | . '</a>'; |
| 381 | - $content .= '</div>'; |
|
| 381 | + $content .= '</div>'; |
|
| 382 | 382 | return $this->columnContent('author', $content); |
| 383 | 383 | } |
| 384 | 384 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | $content = implode( |
| 396 | 396 | ', ', |
| 397 | 397 | array_map( |
| 398 | - function (EE_Term $category) { |
|
| 398 | + function(EE_Term $category) { |
|
| 399 | 399 | return $category->name(); |
| 400 | 400 | }, |
| 401 | 401 | $event_categories |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | 'ee_read_registrations', |
| 479 | 479 | 'espresso_registrations_view_registration' |
| 480 | 480 | ) |
| 481 | - ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 481 | + ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>' |
|
| 482 | 482 | : $registered_attendees; |
| 483 | 483 | return $this->columnContent('attendees', $content, 'center'); |
| 484 | 484 | } |
@@ -512,13 +512,13 @@ discard block |
||
| 512 | 512 | public function column_actions(EE_Event $event): string |
| 513 | 513 | { |
| 514 | 514 | // todo: remove when attendees is active |
| 515 | - if (! defined('REG_ADMIN_URL')) { |
|
| 515 | + if ( ! defined('REG_ADMIN_URL')) { |
|
| 516 | 516 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
| 517 | 517 | } |
| 518 | 518 | $action_links = []; |
| 519 | 519 | $view_link = get_permalink($event->ID()); |
| 520 | - $action_links[] = '<a href="' . $view_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 521 | - . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank"> |
|
| 520 | + $action_links[] = '<a href="'.$view_link.'" class="ee-aria-tooltip button button--icon-only"' |
|
| 521 | + . ' aria-label="'.esc_attr__('View Event', 'event_espresso').'" target="_blank"> |
|
| 522 | 522 | <span class="dashicons dashicons-visibility"></span></a>'; |
| 523 | 523 | if ( |
| 524 | 524 | EE_Registry::instance()->CAP->current_user_can( |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | 'post' => $event->ID(), |
| 533 | 533 | ]; |
| 534 | 534 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
| 535 | - $action_links[] = '<a href="' . $edit_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 536 | - . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 535 | + $action_links[] = '<a href="'.$edit_link.'" class="ee-aria-tooltip button button--icon-only"' |
|
| 536 | + . ' aria-label="'.esc_attr__('Edit Event', 'event_espresso').'">' |
|
| 537 | 537 | . '<span class="dashicons dashicons-calendar-alt"></span>' |
| 538 | 538 | . '</a>'; |
| 539 | 539 | } |
@@ -553,8 +553,8 @@ discard block |
||
| 553 | 553 | 'event_id' => $event->ID(), |
| 554 | 554 | ]; |
| 555 | 555 | $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
| 556 | - $action_links[] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
| 557 | - . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 556 | + $action_links[] = '<a href="'.$attendees_link.'" class="ee-aria-tooltip button button--icon-only"' |
|
| 557 | + . ' aria-label="'.esc_attr__('View Registrants', 'event_espresso').'">' |
|
| 558 | 558 | . '<span class="dashicons dashicons-groups"></span>' |
| 559 | 559 | . '</a>'; |
| 560 | 560 | } |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | $action_links, |
| 564 | 564 | $event |
| 565 | 565 | ); |
| 566 | - $content = $this->_action_string( |
|
| 566 | + $content = $this->_action_string( |
|
| 567 | 567 | implode("\n\t", $action_links), |
| 568 | 568 | $event, |
| 569 | 569 | 'div', |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | } |
| 593 | 593 | $column_array = []; |
| 594 | 594 | foreach ($this->_columns as $column => $column_label) { |
| 595 | - $column_array[ $column ] = $column_label; |
|
| 595 | + $column_array[$column] = $column_label; |
|
| 596 | 596 | if ($column === 'venue') { |
| 597 | 597 | $column_array['event_category'] = esc_html__('Event Category', 'event_espresso'); |
| 598 | 598 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv"> |
| 11 | 11 | <br /> |
| 12 | 12 | <?php echo esc_html($attendee_notice); ?> |
| 13 | - <?php if (! empty($attendees)) : ?> |
|
| 13 | + <?php if ( ! empty($attendees)) : ?> |
|
| 14 | 14 | <div class="admin-primary-mbox-tbl-wrap"> |
| 15 | 15 | <table id="reg-admin-transaction-attendees-table" class="admin-primary-mbox-tbl striped"> |
| 16 | 16 | <thead> |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | <tr> |
| 31 | 31 | <th class='jst-cntr no-pad'> |
| 32 | 32 | <span class="ee-status-dot ee-status-bg--<?php echo esc_attr($attendee['STS_ID']); ?> ee-aria-tooltip" |
| 33 | - aria-label="<?php echo esc_attr(EEH_Template::pretty_status($attendee['STS_ID'], false, "sentence"));?>"> |
|
| 33 | + aria-label="<?php echo esc_attr(EEH_Template::pretty_status($attendee['STS_ID'], false, "sentence")); ?>"> |
|
| 34 | 34 | </span> |
| 35 | 35 | </th> |
| 36 | 36 | <td class="jst-left"><?php echo esc_html($att_nmbr); ?></td> |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | aria-label="<?php esc_attr_e('View details for this attendee', 'event_espresso'); ?>" |
| 41 | 41 | class="ee-aria-tooltip" |
| 42 | 42 | > |
| 43 | - <?php echo esc_html($attendee['fname'] . ' ' . $attendee['lname']); ?> |
|
| 43 | + <?php echo esc_html($attendee['fname'].' '.$attendee['lname']); ?> |
|
| 44 | 44 | </a> |
| 45 | 45 | </td> |
| 46 | 46 | <td class="jst-rght"> |
@@ -14,583 +14,583 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class EE_Registrations_List_Table extends EE_Admin_List_Table |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var Registrations_Admin_Page |
|
| 19 | - */ |
|
| 20 | - protected $_admin_page; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var RegistrationsListTableUserCapabilities |
|
| 24 | - */ |
|
| 25 | - protected $caps_handler; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - private $_status; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * An array of transaction details for the related transaction to the registration being processed. |
|
| 34 | - * This is set via the _set_related_details method. |
|
| 35 | - * |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - protected $_transaction_details = []; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * An array of event details for the related event to the registration being processed. |
|
| 42 | - * This is set via the _set_related_details method. |
|
| 43 | - * |
|
| 44 | - * @var array |
|
| 45 | - */ |
|
| 46 | - protected $_event_details = []; |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param Registrations_Admin_Page $admin_page |
|
| 51 | - */ |
|
| 52 | - public function __construct(Registrations_Admin_Page $admin_page) |
|
| 53 | - { |
|
| 54 | - $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP); |
|
| 55 | - $req_data = $admin_page->get_request_data(); |
|
| 56 | - if (! empty($req_data['event_id'])) { |
|
| 57 | - $extra_query_args = []; |
|
| 58 | - foreach ($admin_page->get_views() as $view_details) { |
|
| 59 | - $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']]; |
|
| 60 | - } |
|
| 61 | - $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 62 | - } |
|
| 63 | - parent::__construct($admin_page); |
|
| 64 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * @return void |
|
| 70 | - * @throws EE_Error |
|
| 71 | - */ |
|
| 72 | - protected function _setup_data() |
|
| 73 | - { |
|
| 74 | - $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 75 | - $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @return void |
|
| 81 | - */ |
|
| 82 | - protected function _set_properties() |
|
| 83 | - { |
|
| 84 | - $return_url = $this->getReturnUrl(); |
|
| 85 | - $this->_wp_list_args = [ |
|
| 86 | - 'singular' => esc_html__('registration', 'event_espresso'), |
|
| 87 | - 'plural' => esc_html__('registrations', 'event_espresso'), |
|
| 88 | - 'ajax' => true, |
|
| 89 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 90 | - ]; |
|
| 91 | - $req_data = $this->_admin_page->get_request_data(); |
|
| 92 | - if (isset($req_data['event_id'])) { |
|
| 93 | - $this->_columns = [ |
|
| 94 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 95 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 96 | - 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 97 | - 'ATT_email' => esc_html__('Email', 'event_espresso'), |
|
| 98 | - '_REG_date' => esc_html__('Reg Date', 'event_espresso'), |
|
| 99 | - 'PRC_amount' => esc_html__('TKT Price', 'event_espresso'), |
|
| 100 | - '_REG_final_price' => esc_html__('Final Price', 'event_espresso'), |
|
| 101 | - 'TXN_total' => esc_html__('Total Txn', 'event_espresso'), |
|
| 102 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 103 | - 'actions' => $this->actionsColumnHeader(), |
|
| 104 | - ]; |
|
| 105 | - $this->_bottom_buttons = [ |
|
| 106 | - 'report' => [ |
|
| 107 | - 'route' => 'registrations_report', |
|
| 108 | - 'extra_request' => [ |
|
| 109 | - 'EVT_ID' => $this->_req_data['event_id'] ?? null, |
|
| 110 | - 'return_url' => $return_url, |
|
| 111 | - ], |
|
| 112 | - ], |
|
| 113 | - ]; |
|
| 114 | - } else { |
|
| 115 | - $this->_columns = [ |
|
| 116 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 117 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 118 | - 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 119 | - '_REG_date' => esc_html__('TXN Date', 'event_espresso'), |
|
| 120 | - 'event_name' => esc_html__('Event', 'event_espresso'), |
|
| 121 | - 'DTT_EVT_start' => esc_html__('Event Date', 'event_espresso'), |
|
| 122 | - '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 123 | - '_REG_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 124 | - 'actions' => $this->actionsColumnHeader(), |
|
| 125 | - ]; |
|
| 126 | - $this->_bottom_buttons = [ |
|
| 127 | - 'report_all' => [ |
|
| 128 | - 'route' => 'registrations_report', |
|
| 129 | - 'extra_request' => [ |
|
| 130 | - 'return_url' => $return_url, |
|
| 131 | - ], |
|
| 132 | - ], |
|
| 133 | - ]; |
|
| 134 | - } |
|
| 135 | - $this->_bottom_buttons['report_filtered'] = [ |
|
| 136 | - 'route' => 'registrations_report', |
|
| 137 | - 'extra_request' => [ |
|
| 138 | - 'use_filters' => true, |
|
| 139 | - 'return_url' => $return_url, |
|
| 140 | - ], |
|
| 141 | - ]; |
|
| 142 | - $filters = array_diff_key( |
|
| 143 | - $this->_req_data, |
|
| 144 | - array_flip( |
|
| 145 | - [ |
|
| 146 | - 'page', |
|
| 147 | - 'action', |
|
| 148 | - 'default_nonce', |
|
| 149 | - ] |
|
| 150 | - ) |
|
| 151 | - ); |
|
| 152 | - if (! empty($filters)) { |
|
| 153 | - $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters; |
|
| 154 | - } |
|
| 155 | - $this->_primary_column = 'id'; |
|
| 156 | - $this->_sortable_columns = [ |
|
| 157 | - '_REG_date' => ['_REG_date' => true], // true means its already sorted |
|
| 158 | - /** |
|
| 159 | - * Allows users to change the default sort if they wish. |
|
| 160 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
|
| 161 | - * name. |
|
| 162 | - */ |
|
| 163 | - 'ATT_fname' => [ |
|
| 164 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 165 | - true, |
|
| 166 | - $this, |
|
| 167 | - ] |
|
| 168 | - ? ['ATT_lname' => false] |
|
| 169 | - : ['ATT_fname' => false], |
|
| 170 | - 'event_name' => ['event_name' => false], |
|
| 171 | - 'DTT_EVT_start' => ['DTT_EVT_start' => false], |
|
| 172 | - 'id' => ['REG_ID' => false], |
|
| 173 | - ]; |
|
| 174 | - $this->_hidden_columns = []; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * This simply sets up the row class for the table rows. |
|
| 180 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 181 | - * |
|
| 182 | - * @param EE_Registration $item the current item |
|
| 183 | - * @return string |
|
| 184 | - */ |
|
| 185 | - protected function _get_row_class($item): string |
|
| 186 | - { |
|
| 187 | - $class = parent::_get_row_class($item); |
|
| 188 | - if ($this->_has_checkbox_column) { |
|
| 189 | - $class .= ' has-checkbox-column'; |
|
| 190 | - } |
|
| 191 | - return $class; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Set the $_transaction_details property if not set yet. |
|
| 197 | - * |
|
| 198 | - * @param EE_Registration $registration |
|
| 199 | - * @throws EE_Error |
|
| 200 | - * @throws InvalidArgumentException |
|
| 201 | - * @throws ReflectionException |
|
| 202 | - * @throws InvalidDataTypeException |
|
| 203 | - * @throws InvalidInterfaceException |
|
| 204 | - */ |
|
| 205 | - protected function _set_related_details(EE_Registration $registration) |
|
| 206 | - { |
|
| 207 | - $transaction = $registration->get_first_related('Transaction'); |
|
| 208 | - $status = $transaction instanceof EE_Transaction |
|
| 209 | - ? $transaction->status_ID() |
|
| 210 | - : EEM_Transaction::failed_status_code; |
|
| 211 | - $this->_transaction_details = [ |
|
| 212 | - 'transaction' => $transaction, |
|
| 213 | - 'status' => $status, |
|
| 214 | - 'id' => $transaction instanceof EE_Transaction |
|
| 215 | - ? $transaction->ID() |
|
| 216 | - : 0, |
|
| 217 | - 'title_attr' => sprintf( |
|
| 218 | - esc_html__('View Transaction Details (%s)', 'event_espresso'), |
|
| 219 | - EEH_Template::pretty_status($status, false, 'sentence') |
|
| 220 | - ), |
|
| 221 | - ]; |
|
| 222 | - try { |
|
| 223 | - $event = $registration->event(); |
|
| 224 | - } catch (EntityNotFoundException $e) { |
|
| 225 | - $event = null; |
|
| 226 | - } |
|
| 227 | - $status = $event instanceof EE_Event |
|
| 228 | - ? $event->get_active_status() |
|
| 229 | - : EE_Datetime::inactive; |
|
| 230 | - $this->_event_details = [ |
|
| 231 | - 'event' => $event, |
|
| 232 | - 'status' => $status, |
|
| 233 | - 'id' => $event instanceof EE_Event |
|
| 234 | - ? $event->ID() |
|
| 235 | - : 0, |
|
| 236 | - 'title_attr' => sprintf( |
|
| 237 | - esc_html__('Edit Event (%s)', 'event_espresso'), |
|
| 238 | - EEH_Template::pretty_status($status, false, 'sentence') |
|
| 239 | - ), |
|
| 240 | - ]; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * @return array |
|
| 246 | - * @throws EE_Error |
|
| 247 | - * @throws ReflectionException |
|
| 248 | - */ |
|
| 249 | - protected function _get_table_filters(): array |
|
| 250 | - { |
|
| 251 | - $filters = []; |
|
| 252 | - // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as |
|
| 253 | - // methods. |
|
| 254 | - $cur_date = $this->_req_data['month_range'] ?? ''; |
|
| 255 | - $cur_category = $this->_req_data['EVT_CAT'] ?? -1; |
|
| 256 | - $reg_status = $this->_req_data['_reg_status'] ?? ''; |
|
| 257 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 258 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 259 | - $status = []; |
|
| 260 | - $status[] = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')]; |
|
| 261 | - foreach ($this->_status as $key => $value) { |
|
| 262 | - $status[] = ['id' => $key, 'text' => $value]; |
|
| 263 | - } |
|
| 264 | - if ($this->_view !== 'incomplete') { |
|
| 265 | - $filters[] = EEH_Form_Fields::select_input( |
|
| 266 | - '_reg_status', |
|
| 267 | - $status, |
|
| 268 | - isset($this->_req_data['_reg_status']) |
|
| 269 | - ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 270 | - : '' |
|
| 271 | - ); |
|
| 272 | - } |
|
| 273 | - if (isset($this->_req_data['event_id'])) { |
|
| 274 | - $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 275 | - } |
|
| 276 | - return $filters; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * @return void |
|
| 282 | - * @throws EE_Error |
|
| 283 | - * @throws InvalidArgumentException |
|
| 284 | - * @throws InvalidDataTypeException |
|
| 285 | - * @throws InvalidInterfaceException |
|
| 286 | - * @throws ReflectionException |
|
| 287 | - */ |
|
| 288 | - protected function _add_view_counts() |
|
| 289 | - { |
|
| 290 | - $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 291 | - $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 292 | - $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 293 | - if ($this->caps_handler->userCanTrashRegistrations()) { |
|
| 294 | - $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 295 | - $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * @param string $view |
|
| 302 | - * @return int |
|
| 303 | - * @throws EE_Error |
|
| 304 | - * @throws ReflectionException |
|
| 305 | - */ |
|
| 306 | - protected function _total_registrations(string $view = ''): int |
|
| 307 | - { |
|
| 308 | - $_where = []; |
|
| 309 | - $EVT_ID = isset($this->_req_data['event_id']) |
|
| 310 | - ? absint($this->_req_data['event_id']) |
|
| 311 | - : false; |
|
| 312 | - if ($EVT_ID) { |
|
| 313 | - $_where['EVT_ID'] = $EVT_ID; |
|
| 314 | - } |
|
| 315 | - switch ($view) { |
|
| 316 | - case 'trash': |
|
| 317 | - return EEM_Registration::instance()->count_deleted([$_where]); |
|
| 318 | - case 'incomplete': |
|
| 319 | - $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 320 | - break; |
|
| 321 | - default: |
|
| 322 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 323 | - } |
|
| 324 | - return EEM_Registration::instance()->count([$_where]); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * @return int |
|
| 330 | - * @throws EE_Error |
|
| 331 | - * @throws ReflectionException |
|
| 332 | - */ |
|
| 333 | - protected function _total_registrations_this_month(): int |
|
| 334 | - { |
|
| 335 | - $EVT_ID = isset($this->_req_data['event_id']) |
|
| 336 | - ? absint($this->_req_data['event_id']) |
|
| 337 | - : false; |
|
| 338 | - $_where = $EVT_ID |
|
| 339 | - ? ['EVT_ID' => $EVT_ID] |
|
| 340 | - : []; |
|
| 341 | - $this_year_r = date('Y', current_time('timestamp')); |
|
| 342 | - $time_start = ' 00:00:00'; |
|
| 343 | - $time_end = ' 23:59:59'; |
|
| 344 | - $this_month_r = date('m', current_time('timestamp')); |
|
| 345 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 346 | - // setup date query. |
|
| 347 | - $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 348 | - 'REG_date', |
|
| 349 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 350 | - 'Y-m-d H:i:s' |
|
| 351 | - ); |
|
| 352 | - $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 353 | - 'REG_date', |
|
| 354 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 355 | - 'Y-m-d H:i:s' |
|
| 356 | - ); |
|
| 357 | - $_where['REG_date'] = [ |
|
| 358 | - 'BETWEEN', |
|
| 359 | - [ |
|
| 360 | - $beginning_string, |
|
| 361 | - $end_string, |
|
| 362 | - ], |
|
| 363 | - ]; |
|
| 364 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 365 | - return EEM_Registration::instance()->count([$_where]); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * @return int |
|
| 371 | - * @throws EE_Error |
|
| 372 | - * @throws ReflectionException |
|
| 373 | - */ |
|
| 374 | - protected function _total_registrations_today(): int |
|
| 375 | - { |
|
| 376 | - $EVT_ID = isset($this->_req_data['event_id']) |
|
| 377 | - ? absint($this->_req_data['event_id']) |
|
| 378 | - : false; |
|
| 379 | - $_where = $EVT_ID |
|
| 380 | - ? ['EVT_ID' => $EVT_ID] |
|
| 381 | - : []; |
|
| 382 | - $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 383 | - $time_start = ' 00:00:00'; |
|
| 384 | - $time_end = ' 23:59:59'; |
|
| 385 | - $_where['REG_date'] = [ |
|
| 386 | - 'BETWEEN', |
|
| 387 | - [ |
|
| 388 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 389 | - 'REG_date', |
|
| 390 | - $current_date . $time_start, |
|
| 391 | - 'Y-m-d H:i:s' |
|
| 392 | - ), |
|
| 393 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 394 | - 'REG_date', |
|
| 395 | - $current_date . $time_end, |
|
| 396 | - 'Y-m-d H:i:s' |
|
| 397 | - ), |
|
| 398 | - ], |
|
| 399 | - ]; |
|
| 400 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 401 | - return EEM_Registration::instance()->count([$_where]); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * @param EE_Registration $item |
|
| 407 | - * @return string |
|
| 408 | - * @throws EE_Error |
|
| 409 | - * @throws InvalidArgumentException |
|
| 410 | - * @throws InvalidDataTypeException |
|
| 411 | - * @throws InvalidInterfaceException |
|
| 412 | - * @throws ReflectionException |
|
| 413 | - */ |
|
| 414 | - public function column_cb($item): string |
|
| 415 | - { |
|
| 416 | - /** checkbox/lock **/ |
|
| 417 | - $REG_ID = $item->ID(); |
|
| 418 | - $transaction = $item->get_first_related('Transaction'); |
|
| 419 | - $payment_count = $transaction instanceof EE_Transaction |
|
| 420 | - ? $transaction->count_related('Payment') |
|
| 421 | - : 0; |
|
| 422 | - |
|
| 423 | - $content = $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item) |
|
| 424 | - ? '<input disabled type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" /> |
|
| 17 | + /** |
|
| 18 | + * @var Registrations_Admin_Page |
|
| 19 | + */ |
|
| 20 | + protected $_admin_page; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var RegistrationsListTableUserCapabilities |
|
| 24 | + */ |
|
| 25 | + protected $caps_handler; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + private $_status; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * An array of transaction details for the related transaction to the registration being processed. |
|
| 34 | + * This is set via the _set_related_details method. |
|
| 35 | + * |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + protected $_transaction_details = []; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * An array of event details for the related event to the registration being processed. |
|
| 42 | + * This is set via the _set_related_details method. |
|
| 43 | + * |
|
| 44 | + * @var array |
|
| 45 | + */ |
|
| 46 | + protected $_event_details = []; |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param Registrations_Admin_Page $admin_page |
|
| 51 | + */ |
|
| 52 | + public function __construct(Registrations_Admin_Page $admin_page) |
|
| 53 | + { |
|
| 54 | + $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP); |
|
| 55 | + $req_data = $admin_page->get_request_data(); |
|
| 56 | + if (! empty($req_data['event_id'])) { |
|
| 57 | + $extra_query_args = []; |
|
| 58 | + foreach ($admin_page->get_views() as $view_details) { |
|
| 59 | + $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']]; |
|
| 60 | + } |
|
| 61 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 62 | + } |
|
| 63 | + parent::__construct($admin_page); |
|
| 64 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @return void |
|
| 70 | + * @throws EE_Error |
|
| 71 | + */ |
|
| 72 | + protected function _setup_data() |
|
| 73 | + { |
|
| 74 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 75 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @return void |
|
| 81 | + */ |
|
| 82 | + protected function _set_properties() |
|
| 83 | + { |
|
| 84 | + $return_url = $this->getReturnUrl(); |
|
| 85 | + $this->_wp_list_args = [ |
|
| 86 | + 'singular' => esc_html__('registration', 'event_espresso'), |
|
| 87 | + 'plural' => esc_html__('registrations', 'event_espresso'), |
|
| 88 | + 'ajax' => true, |
|
| 89 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 90 | + ]; |
|
| 91 | + $req_data = $this->_admin_page->get_request_data(); |
|
| 92 | + if (isset($req_data['event_id'])) { |
|
| 93 | + $this->_columns = [ |
|
| 94 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 95 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 96 | + 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 97 | + 'ATT_email' => esc_html__('Email', 'event_espresso'), |
|
| 98 | + '_REG_date' => esc_html__('Reg Date', 'event_espresso'), |
|
| 99 | + 'PRC_amount' => esc_html__('TKT Price', 'event_espresso'), |
|
| 100 | + '_REG_final_price' => esc_html__('Final Price', 'event_espresso'), |
|
| 101 | + 'TXN_total' => esc_html__('Total Txn', 'event_espresso'), |
|
| 102 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 103 | + 'actions' => $this->actionsColumnHeader(), |
|
| 104 | + ]; |
|
| 105 | + $this->_bottom_buttons = [ |
|
| 106 | + 'report' => [ |
|
| 107 | + 'route' => 'registrations_report', |
|
| 108 | + 'extra_request' => [ |
|
| 109 | + 'EVT_ID' => $this->_req_data['event_id'] ?? null, |
|
| 110 | + 'return_url' => $return_url, |
|
| 111 | + ], |
|
| 112 | + ], |
|
| 113 | + ]; |
|
| 114 | + } else { |
|
| 115 | + $this->_columns = [ |
|
| 116 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 117 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 118 | + 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 119 | + '_REG_date' => esc_html__('TXN Date', 'event_espresso'), |
|
| 120 | + 'event_name' => esc_html__('Event', 'event_espresso'), |
|
| 121 | + 'DTT_EVT_start' => esc_html__('Event Date', 'event_espresso'), |
|
| 122 | + '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 123 | + '_REG_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 124 | + 'actions' => $this->actionsColumnHeader(), |
|
| 125 | + ]; |
|
| 126 | + $this->_bottom_buttons = [ |
|
| 127 | + 'report_all' => [ |
|
| 128 | + 'route' => 'registrations_report', |
|
| 129 | + 'extra_request' => [ |
|
| 130 | + 'return_url' => $return_url, |
|
| 131 | + ], |
|
| 132 | + ], |
|
| 133 | + ]; |
|
| 134 | + } |
|
| 135 | + $this->_bottom_buttons['report_filtered'] = [ |
|
| 136 | + 'route' => 'registrations_report', |
|
| 137 | + 'extra_request' => [ |
|
| 138 | + 'use_filters' => true, |
|
| 139 | + 'return_url' => $return_url, |
|
| 140 | + ], |
|
| 141 | + ]; |
|
| 142 | + $filters = array_diff_key( |
|
| 143 | + $this->_req_data, |
|
| 144 | + array_flip( |
|
| 145 | + [ |
|
| 146 | + 'page', |
|
| 147 | + 'action', |
|
| 148 | + 'default_nonce', |
|
| 149 | + ] |
|
| 150 | + ) |
|
| 151 | + ); |
|
| 152 | + if (! empty($filters)) { |
|
| 153 | + $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters; |
|
| 154 | + } |
|
| 155 | + $this->_primary_column = 'id'; |
|
| 156 | + $this->_sortable_columns = [ |
|
| 157 | + '_REG_date' => ['_REG_date' => true], // true means its already sorted |
|
| 158 | + /** |
|
| 159 | + * Allows users to change the default sort if they wish. |
|
| 160 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
|
| 161 | + * name. |
|
| 162 | + */ |
|
| 163 | + 'ATT_fname' => [ |
|
| 164 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 165 | + true, |
|
| 166 | + $this, |
|
| 167 | + ] |
|
| 168 | + ? ['ATT_lname' => false] |
|
| 169 | + : ['ATT_fname' => false], |
|
| 170 | + 'event_name' => ['event_name' => false], |
|
| 171 | + 'DTT_EVT_start' => ['DTT_EVT_start' => false], |
|
| 172 | + 'id' => ['REG_ID' => false], |
|
| 173 | + ]; |
|
| 174 | + $this->_hidden_columns = []; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * This simply sets up the row class for the table rows. |
|
| 180 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 181 | + * |
|
| 182 | + * @param EE_Registration $item the current item |
|
| 183 | + * @return string |
|
| 184 | + */ |
|
| 185 | + protected function _get_row_class($item): string |
|
| 186 | + { |
|
| 187 | + $class = parent::_get_row_class($item); |
|
| 188 | + if ($this->_has_checkbox_column) { |
|
| 189 | + $class .= ' has-checkbox-column'; |
|
| 190 | + } |
|
| 191 | + return $class; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Set the $_transaction_details property if not set yet. |
|
| 197 | + * |
|
| 198 | + * @param EE_Registration $registration |
|
| 199 | + * @throws EE_Error |
|
| 200 | + * @throws InvalidArgumentException |
|
| 201 | + * @throws ReflectionException |
|
| 202 | + * @throws InvalidDataTypeException |
|
| 203 | + * @throws InvalidInterfaceException |
|
| 204 | + */ |
|
| 205 | + protected function _set_related_details(EE_Registration $registration) |
|
| 206 | + { |
|
| 207 | + $transaction = $registration->get_first_related('Transaction'); |
|
| 208 | + $status = $transaction instanceof EE_Transaction |
|
| 209 | + ? $transaction->status_ID() |
|
| 210 | + : EEM_Transaction::failed_status_code; |
|
| 211 | + $this->_transaction_details = [ |
|
| 212 | + 'transaction' => $transaction, |
|
| 213 | + 'status' => $status, |
|
| 214 | + 'id' => $transaction instanceof EE_Transaction |
|
| 215 | + ? $transaction->ID() |
|
| 216 | + : 0, |
|
| 217 | + 'title_attr' => sprintf( |
|
| 218 | + esc_html__('View Transaction Details (%s)', 'event_espresso'), |
|
| 219 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
| 220 | + ), |
|
| 221 | + ]; |
|
| 222 | + try { |
|
| 223 | + $event = $registration->event(); |
|
| 224 | + } catch (EntityNotFoundException $e) { |
|
| 225 | + $event = null; |
|
| 226 | + } |
|
| 227 | + $status = $event instanceof EE_Event |
|
| 228 | + ? $event->get_active_status() |
|
| 229 | + : EE_Datetime::inactive; |
|
| 230 | + $this->_event_details = [ |
|
| 231 | + 'event' => $event, |
|
| 232 | + 'status' => $status, |
|
| 233 | + 'id' => $event instanceof EE_Event |
|
| 234 | + ? $event->ID() |
|
| 235 | + : 0, |
|
| 236 | + 'title_attr' => sprintf( |
|
| 237 | + esc_html__('Edit Event (%s)', 'event_espresso'), |
|
| 238 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
| 239 | + ), |
|
| 240 | + ]; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * @return array |
|
| 246 | + * @throws EE_Error |
|
| 247 | + * @throws ReflectionException |
|
| 248 | + */ |
|
| 249 | + protected function _get_table_filters(): array |
|
| 250 | + { |
|
| 251 | + $filters = []; |
|
| 252 | + // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as |
|
| 253 | + // methods. |
|
| 254 | + $cur_date = $this->_req_data['month_range'] ?? ''; |
|
| 255 | + $cur_category = $this->_req_data['EVT_CAT'] ?? -1; |
|
| 256 | + $reg_status = $this->_req_data['_reg_status'] ?? ''; |
|
| 257 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 258 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 259 | + $status = []; |
|
| 260 | + $status[] = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')]; |
|
| 261 | + foreach ($this->_status as $key => $value) { |
|
| 262 | + $status[] = ['id' => $key, 'text' => $value]; |
|
| 263 | + } |
|
| 264 | + if ($this->_view !== 'incomplete') { |
|
| 265 | + $filters[] = EEH_Form_Fields::select_input( |
|
| 266 | + '_reg_status', |
|
| 267 | + $status, |
|
| 268 | + isset($this->_req_data['_reg_status']) |
|
| 269 | + ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 270 | + : '' |
|
| 271 | + ); |
|
| 272 | + } |
|
| 273 | + if (isset($this->_req_data['event_id'])) { |
|
| 274 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 275 | + } |
|
| 276 | + return $filters; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * @return void |
|
| 282 | + * @throws EE_Error |
|
| 283 | + * @throws InvalidArgumentException |
|
| 284 | + * @throws InvalidDataTypeException |
|
| 285 | + * @throws InvalidInterfaceException |
|
| 286 | + * @throws ReflectionException |
|
| 287 | + */ |
|
| 288 | + protected function _add_view_counts() |
|
| 289 | + { |
|
| 290 | + $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 291 | + $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 292 | + $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 293 | + if ($this->caps_handler->userCanTrashRegistrations()) { |
|
| 294 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 295 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * @param string $view |
|
| 302 | + * @return int |
|
| 303 | + * @throws EE_Error |
|
| 304 | + * @throws ReflectionException |
|
| 305 | + */ |
|
| 306 | + protected function _total_registrations(string $view = ''): int |
|
| 307 | + { |
|
| 308 | + $_where = []; |
|
| 309 | + $EVT_ID = isset($this->_req_data['event_id']) |
|
| 310 | + ? absint($this->_req_data['event_id']) |
|
| 311 | + : false; |
|
| 312 | + if ($EVT_ID) { |
|
| 313 | + $_where['EVT_ID'] = $EVT_ID; |
|
| 314 | + } |
|
| 315 | + switch ($view) { |
|
| 316 | + case 'trash': |
|
| 317 | + return EEM_Registration::instance()->count_deleted([$_where]); |
|
| 318 | + case 'incomplete': |
|
| 319 | + $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 320 | + break; |
|
| 321 | + default: |
|
| 322 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 323 | + } |
|
| 324 | + return EEM_Registration::instance()->count([$_where]); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * @return int |
|
| 330 | + * @throws EE_Error |
|
| 331 | + * @throws ReflectionException |
|
| 332 | + */ |
|
| 333 | + protected function _total_registrations_this_month(): int |
|
| 334 | + { |
|
| 335 | + $EVT_ID = isset($this->_req_data['event_id']) |
|
| 336 | + ? absint($this->_req_data['event_id']) |
|
| 337 | + : false; |
|
| 338 | + $_where = $EVT_ID |
|
| 339 | + ? ['EVT_ID' => $EVT_ID] |
|
| 340 | + : []; |
|
| 341 | + $this_year_r = date('Y', current_time('timestamp')); |
|
| 342 | + $time_start = ' 00:00:00'; |
|
| 343 | + $time_end = ' 23:59:59'; |
|
| 344 | + $this_month_r = date('m', current_time('timestamp')); |
|
| 345 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 346 | + // setup date query. |
|
| 347 | + $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 348 | + 'REG_date', |
|
| 349 | + $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 350 | + 'Y-m-d H:i:s' |
|
| 351 | + ); |
|
| 352 | + $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 353 | + 'REG_date', |
|
| 354 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 355 | + 'Y-m-d H:i:s' |
|
| 356 | + ); |
|
| 357 | + $_where['REG_date'] = [ |
|
| 358 | + 'BETWEEN', |
|
| 359 | + [ |
|
| 360 | + $beginning_string, |
|
| 361 | + $end_string, |
|
| 362 | + ], |
|
| 363 | + ]; |
|
| 364 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 365 | + return EEM_Registration::instance()->count([$_where]); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * @return int |
|
| 371 | + * @throws EE_Error |
|
| 372 | + * @throws ReflectionException |
|
| 373 | + */ |
|
| 374 | + protected function _total_registrations_today(): int |
|
| 375 | + { |
|
| 376 | + $EVT_ID = isset($this->_req_data['event_id']) |
|
| 377 | + ? absint($this->_req_data['event_id']) |
|
| 378 | + : false; |
|
| 379 | + $_where = $EVT_ID |
|
| 380 | + ? ['EVT_ID' => $EVT_ID] |
|
| 381 | + : []; |
|
| 382 | + $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 383 | + $time_start = ' 00:00:00'; |
|
| 384 | + $time_end = ' 23:59:59'; |
|
| 385 | + $_where['REG_date'] = [ |
|
| 386 | + 'BETWEEN', |
|
| 387 | + [ |
|
| 388 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 389 | + 'REG_date', |
|
| 390 | + $current_date . $time_start, |
|
| 391 | + 'Y-m-d H:i:s' |
|
| 392 | + ), |
|
| 393 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 394 | + 'REG_date', |
|
| 395 | + $current_date . $time_end, |
|
| 396 | + 'Y-m-d H:i:s' |
|
| 397 | + ), |
|
| 398 | + ], |
|
| 399 | + ]; |
|
| 400 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 401 | + return EEM_Registration::instance()->count([$_where]); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * @param EE_Registration $item |
|
| 407 | + * @return string |
|
| 408 | + * @throws EE_Error |
|
| 409 | + * @throws InvalidArgumentException |
|
| 410 | + * @throws InvalidDataTypeException |
|
| 411 | + * @throws InvalidInterfaceException |
|
| 412 | + * @throws ReflectionException |
|
| 413 | + */ |
|
| 414 | + public function column_cb($item): string |
|
| 415 | + { |
|
| 416 | + /** checkbox/lock **/ |
|
| 417 | + $REG_ID = $item->ID(); |
|
| 418 | + $transaction = $item->get_first_related('Transaction'); |
|
| 419 | + $payment_count = $transaction instanceof EE_Transaction |
|
| 420 | + ? $transaction->count_related('Payment') |
|
| 421 | + : 0; |
|
| 422 | + |
|
| 423 | + $content = $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item) |
|
| 424 | + ? '<input disabled type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" /> |
|
| 425 | 425 | <span class="dashicons dashicons-lock"></span>' |
| 426 | - : '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />'; |
|
| 427 | - |
|
| 428 | - return $this->columnContent('cb', $content, 'center'); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - /** |
|
| 433 | - * @param EE_Registration $registration |
|
| 434 | - * @return string |
|
| 435 | - * @throws EE_Error |
|
| 436 | - * @throws InvalidArgumentException |
|
| 437 | - * @throws InvalidDataTypeException |
|
| 438 | - * @throws InvalidInterfaceException |
|
| 439 | - * @throws ReflectionException |
|
| 440 | - */ |
|
| 441 | - public function column_id(EE_Registration $registration): string |
|
| 442 | - { |
|
| 443 | - $content = $registration->ID(); |
|
| 444 | - $content .= '<span class="show-on-mobile-view-only">'; |
|
| 445 | - $content .= $this->column_ATT_fname($registration, false); |
|
| 446 | - $content .= '</span>'; |
|
| 447 | - |
|
| 448 | - return $this->columnContent('id', $content, 'end'); |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * @param EE_Registration $registration |
|
| 454 | - * @param bool $prep_content |
|
| 455 | - * @return string |
|
| 456 | - * @throws EE_Error |
|
| 457 | - * @throws ReflectionException |
|
| 458 | - */ |
|
| 459 | - public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string |
|
| 460 | - { |
|
| 461 | - |
|
| 462 | - $status = esc_attr($registration->status_ID()); |
|
| 463 | - $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 464 | - $prime_reg_star = $registration->count() === 1 |
|
| 465 | - ? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>' |
|
| 466 | - : ''; |
|
| 467 | - |
|
| 468 | - $group_count = ' |
|
| 426 | + : '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />'; |
|
| 427 | + |
|
| 428 | + return $this->columnContent('cb', $content, 'center'); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * @param EE_Registration $registration |
|
| 434 | + * @return string |
|
| 435 | + * @throws EE_Error |
|
| 436 | + * @throws InvalidArgumentException |
|
| 437 | + * @throws InvalidDataTypeException |
|
| 438 | + * @throws InvalidInterfaceException |
|
| 439 | + * @throws ReflectionException |
|
| 440 | + */ |
|
| 441 | + public function column_id(EE_Registration $registration): string |
|
| 442 | + { |
|
| 443 | + $content = $registration->ID(); |
|
| 444 | + $content .= '<span class="show-on-mobile-view-only">'; |
|
| 445 | + $content .= $this->column_ATT_fname($registration, false); |
|
| 446 | + $content .= '</span>'; |
|
| 447 | + |
|
| 448 | + return $this->columnContent('id', $content, 'end'); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * @param EE_Registration $registration |
|
| 454 | + * @param bool $prep_content |
|
| 455 | + * @return string |
|
| 456 | + * @throws EE_Error |
|
| 457 | + * @throws ReflectionException |
|
| 458 | + */ |
|
| 459 | + public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string |
|
| 460 | + { |
|
| 461 | + |
|
| 462 | + $status = esc_attr($registration->status_ID()); |
|
| 463 | + $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 464 | + $prime_reg_star = $registration->count() === 1 |
|
| 465 | + ? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>' |
|
| 466 | + : ''; |
|
| 467 | + |
|
| 468 | + $group_count = ' |
|
| 469 | 469 | <span class="reg-count-group-size" > |
| 470 | 470 | ' . sprintf( |
| 471 | - esc_html__('(%1$s / %2$s)', 'event_espresso'), |
|
| 472 | - $registration->count(), |
|
| 473 | - $registration->group_size() |
|
| 474 | - ) . ' |
|
| 471 | + esc_html__('(%1$s / %2$s)', 'event_espresso'), |
|
| 472 | + $registration->count(), |
|
| 473 | + $registration->group_size() |
|
| 474 | + ) . ' |
|
| 475 | 475 | </span >'; |
| 476 | 476 | |
| 477 | - $content = ' |
|
| 477 | + $content = ' |
|
| 478 | 478 | <div class="ee-layout-row"> |
| 479 | 479 | <span aria-label="' . $pretty_status . '" |
| 480 | 480 | class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip" |
| 481 | 481 | ></span> |
| 482 | 482 | ' . $this->viewRegistrationLink($registration, $status) |
| 483 | - . $prime_reg_star |
|
| 484 | - . $group_count . ' |
|
| 483 | + . $prime_reg_star |
|
| 484 | + . $group_count . ' |
|
| 485 | 485 | </div>'; |
| 486 | 486 | |
| 487 | - // append reg_code |
|
| 488 | - $content .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code')); |
|
| 489 | - $url_params = ['_REG_ID' => $registration->ID()]; |
|
| 490 | - if (isset($this->_req_data['event_id'])) { |
|
| 491 | - $url_params['event_id'] = $registration->event_ID(); |
|
| 492 | - } |
|
| 493 | - // trash/restore/delete actions |
|
| 494 | - $actions = $this->trashRegistrationLink($registration, $url_params); |
|
| 495 | - $actions = $this->restoreRegistrationLink($registration, $url_params, $actions); |
|
| 496 | - $actions = $this->deleteRegistrationLink($registration, $url_params, $actions); |
|
| 497 | - |
|
| 498 | - $content = sprintf('%1$s %2$s', $content, $this->row_actions($actions)); |
|
| 499 | - |
|
| 500 | - return $prep_content ? $this->columnContent('ATT_fname', $content) : $content; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - |
|
| 504 | - /** |
|
| 505 | - * @param EE_Registration $registration |
|
| 506 | - * @param bool $prep_content |
|
| 507 | - * @return string |
|
| 508 | - * @throws EE_Error |
|
| 509 | - * @throws ReflectionException |
|
| 510 | - */ |
|
| 511 | - public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string |
|
| 512 | - { |
|
| 513 | - $this->_set_related_details($registration); |
|
| 514 | - // Build row actions |
|
| 515 | - $content = $this->caps_handler->userCanViewTransaction() |
|
| 516 | - ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="' |
|
| 517 | - . $this->viewTransactionUrl() |
|
| 518 | - . '" aria-label="' |
|
| 519 | - . esc_attr($this->_transaction_details['title_attr']) |
|
| 520 | - . '">' |
|
| 521 | - . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a') |
|
| 522 | - . '</a>' |
|
| 523 | - : $registration->get_i18n_datetime('REG_date'); |
|
| 524 | - |
|
| 525 | - return $prep_content ? $this->columnContent('_REG_date', $content) : $content; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * @param EE_Registration $registration |
|
| 531 | - * @return string |
|
| 532 | - * @throws EE_Error |
|
| 533 | - * @throws InvalidArgumentException |
|
| 534 | - * @throws InvalidDataTypeException |
|
| 535 | - * @throws InvalidInterfaceException |
|
| 536 | - * @throws ReflectionException |
|
| 537 | - */ |
|
| 538 | - public function column_event_name(EE_Registration $registration): string |
|
| 539 | - { |
|
| 540 | - $this->_set_related_details($registration); |
|
| 541 | - // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 542 | - $EVT_ID = $registration->event_ID(); |
|
| 543 | - $event_name = $registration->event_name(); |
|
| 544 | - $event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso'); |
|
| 545 | - $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 546 | - $edit_event = $this->editEventLink($EVT_ID, $event_name); |
|
| 547 | - $actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name); |
|
| 548 | - $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 549 | - |
|
| 550 | - return $this->columnContent('event_name', $content); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * @param EE_Registration $registration |
|
| 556 | - * @return string |
|
| 557 | - * @throws EE_Error |
|
| 558 | - * @throws InvalidArgumentException |
|
| 559 | - * @throws InvalidDataTypeException |
|
| 560 | - * @throws InvalidInterfaceException |
|
| 561 | - * @throws ReflectionException |
|
| 562 | - */ |
|
| 563 | - public function column_DTT_EVT_start(EE_Registration $registration): string |
|
| 564 | - { |
|
| 565 | - $datetime_strings = []; |
|
| 566 | - $ticket = $registration->ticket(); |
|
| 567 | - if ($ticket instanceof EE_Ticket) { |
|
| 568 | - $remove_defaults = ['default_where_conditions' => 'none']; |
|
| 569 | - $datetimes = $ticket->datetimes($remove_defaults); |
|
| 570 | - foreach ($datetimes as $datetime) { |
|
| 571 | - $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
| 572 | - } |
|
| 573 | - $content = $this->generateDisplayForDatetimes($datetime_strings); |
|
| 574 | - } else { |
|
| 575 | - $content = esc_html__('There is no ticket on this registration', 'event_espresso'); |
|
| 576 | - } |
|
| 577 | - return $this->columnContent('DTT_EVT_start', $content); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - |
|
| 581 | - /** |
|
| 582 | - * Receives an array of datetime strings to display and converts them to the html container for the column. |
|
| 583 | - * |
|
| 584 | - * @param array $datetime_strings |
|
| 585 | - * @return string |
|
| 586 | - */ |
|
| 587 | - public function generateDisplayForDatetimes(array $datetime_strings): string |
|
| 588 | - { |
|
| 589 | - // $content = '<div class="ee-registration-event-datetimes-container">'; |
|
| 590 | - // get first item for initial visibility |
|
| 591 | - $content = array_shift($datetime_strings); |
|
| 592 | - if (! empty($datetime_strings)) { |
|
| 593 | - $content .= ' |
|
| 487 | + // append reg_code |
|
| 488 | + $content .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code')); |
|
| 489 | + $url_params = ['_REG_ID' => $registration->ID()]; |
|
| 490 | + if (isset($this->_req_data['event_id'])) { |
|
| 491 | + $url_params['event_id'] = $registration->event_ID(); |
|
| 492 | + } |
|
| 493 | + // trash/restore/delete actions |
|
| 494 | + $actions = $this->trashRegistrationLink($registration, $url_params); |
|
| 495 | + $actions = $this->restoreRegistrationLink($registration, $url_params, $actions); |
|
| 496 | + $actions = $this->deleteRegistrationLink($registration, $url_params, $actions); |
|
| 497 | + |
|
| 498 | + $content = sprintf('%1$s %2$s', $content, $this->row_actions($actions)); |
|
| 499 | + |
|
| 500 | + return $prep_content ? $this->columnContent('ATT_fname', $content) : $content; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + |
|
| 504 | + /** |
|
| 505 | + * @param EE_Registration $registration |
|
| 506 | + * @param bool $prep_content |
|
| 507 | + * @return string |
|
| 508 | + * @throws EE_Error |
|
| 509 | + * @throws ReflectionException |
|
| 510 | + */ |
|
| 511 | + public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string |
|
| 512 | + { |
|
| 513 | + $this->_set_related_details($registration); |
|
| 514 | + // Build row actions |
|
| 515 | + $content = $this->caps_handler->userCanViewTransaction() |
|
| 516 | + ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="' |
|
| 517 | + . $this->viewTransactionUrl() |
|
| 518 | + . '" aria-label="' |
|
| 519 | + . esc_attr($this->_transaction_details['title_attr']) |
|
| 520 | + . '">' |
|
| 521 | + . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a') |
|
| 522 | + . '</a>' |
|
| 523 | + : $registration->get_i18n_datetime('REG_date'); |
|
| 524 | + |
|
| 525 | + return $prep_content ? $this->columnContent('_REG_date', $content) : $content; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * @param EE_Registration $registration |
|
| 531 | + * @return string |
|
| 532 | + * @throws EE_Error |
|
| 533 | + * @throws InvalidArgumentException |
|
| 534 | + * @throws InvalidDataTypeException |
|
| 535 | + * @throws InvalidInterfaceException |
|
| 536 | + * @throws ReflectionException |
|
| 537 | + */ |
|
| 538 | + public function column_event_name(EE_Registration $registration): string |
|
| 539 | + { |
|
| 540 | + $this->_set_related_details($registration); |
|
| 541 | + // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 542 | + $EVT_ID = $registration->event_ID(); |
|
| 543 | + $event_name = $registration->event_name(); |
|
| 544 | + $event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso'); |
|
| 545 | + $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 546 | + $edit_event = $this->editEventLink($EVT_ID, $event_name); |
|
| 547 | + $actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name); |
|
| 548 | + $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 549 | + |
|
| 550 | + return $this->columnContent('event_name', $content); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * @param EE_Registration $registration |
|
| 556 | + * @return string |
|
| 557 | + * @throws EE_Error |
|
| 558 | + * @throws InvalidArgumentException |
|
| 559 | + * @throws InvalidDataTypeException |
|
| 560 | + * @throws InvalidInterfaceException |
|
| 561 | + * @throws ReflectionException |
|
| 562 | + */ |
|
| 563 | + public function column_DTT_EVT_start(EE_Registration $registration): string |
|
| 564 | + { |
|
| 565 | + $datetime_strings = []; |
|
| 566 | + $ticket = $registration->ticket(); |
|
| 567 | + if ($ticket instanceof EE_Ticket) { |
|
| 568 | + $remove_defaults = ['default_where_conditions' => 'none']; |
|
| 569 | + $datetimes = $ticket->datetimes($remove_defaults); |
|
| 570 | + foreach ($datetimes as $datetime) { |
|
| 571 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
| 572 | + } |
|
| 573 | + $content = $this->generateDisplayForDatetimes($datetime_strings); |
|
| 574 | + } else { |
|
| 575 | + $content = esc_html__('There is no ticket on this registration', 'event_espresso'); |
|
| 576 | + } |
|
| 577 | + return $this->columnContent('DTT_EVT_start', $content); |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + |
|
| 581 | + /** |
|
| 582 | + * Receives an array of datetime strings to display and converts them to the html container for the column. |
|
| 583 | + * |
|
| 584 | + * @param array $datetime_strings |
|
| 585 | + * @return string |
|
| 586 | + */ |
|
| 587 | + public function generateDisplayForDatetimes(array $datetime_strings): string |
|
| 588 | + { |
|
| 589 | + // $content = '<div class="ee-registration-event-datetimes-container">'; |
|
| 590 | + // get first item for initial visibility |
|
| 591 | + $content = array_shift($datetime_strings); |
|
| 592 | + if (! empty($datetime_strings)) { |
|
| 593 | + $content .= ' |
|
| 594 | 594 | <div class="ee-registration-event-datetimes-container-wrap"> |
| 595 | 595 | <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '" |
| 596 | 596 | class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle" |
@@ -601,540 +601,540 @@ discard block |
||
| 601 | 601 | ' . implode("", $datetime_strings) . ' |
| 602 | 602 | </div> |
| 603 | 603 | </div>'; |
| 604 | - } |
|
| 605 | - // $content .= '</div>'; |
|
| 606 | - return $content; |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * @param EE_Registration $registration |
|
| 612 | - * @return string |
|
| 613 | - * @throws EE_Error |
|
| 614 | - * @throws InvalidArgumentException |
|
| 615 | - * @throws InvalidDataTypeException |
|
| 616 | - * @throws InvalidInterfaceException |
|
| 617 | - * @throws ReflectionException |
|
| 618 | - */ |
|
| 619 | - public function column_ATT_email(EE_Registration $registration): string |
|
| 620 | - { |
|
| 621 | - $attendee = $registration->get_first_related('Attendee'); |
|
| 622 | - $content = ! $attendee instanceof EE_Attendee |
|
| 623 | - ? esc_html__('No attached contact record.', 'event_espresso') |
|
| 624 | - : $attendee->email(); |
|
| 625 | - return $this->columnContent('ATT_email', $content); |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - |
|
| 629 | - /** |
|
| 630 | - * @param EE_Registration $registration |
|
| 631 | - * @return string |
|
| 632 | - */ |
|
| 633 | - public function column__REG_count(EE_Registration $registration): string |
|
| 634 | - { |
|
| 635 | - $content = |
|
| 636 | - sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size()); |
|
| 637 | - return $this->columnContent('_REG_count', $content); |
|
| 638 | - } |
|
| 639 | - |
|
| 640 | - |
|
| 641 | - /** |
|
| 642 | - * @param EE_Registration $registration |
|
| 643 | - * @return string |
|
| 644 | - * @throws EE_Error |
|
| 645 | - * @throws ReflectionException |
|
| 646 | - */ |
|
| 647 | - public function column_PRC_amount(EE_Registration $registration): string |
|
| 648 | - { |
|
| 649 | - $ticket = $registration->ticket(); |
|
| 650 | - $req_data = $this->_admin_page->get_request_data(); |
|
| 651 | - |
|
| 652 | - $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket |
|
| 653 | - ? '<div class="TKT_name">' . $ticket->name() . '</div>' |
|
| 654 | - : ''; |
|
| 655 | - |
|
| 656 | - $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM'; |
|
| 657 | - $content .= $registration->final_price() > 0 |
|
| 658 | - ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '"> |
|
| 604 | + } |
|
| 605 | + // $content .= '</div>'; |
|
| 606 | + return $content; |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * @param EE_Registration $registration |
|
| 612 | + * @return string |
|
| 613 | + * @throws EE_Error |
|
| 614 | + * @throws InvalidArgumentException |
|
| 615 | + * @throws InvalidDataTypeException |
|
| 616 | + * @throws InvalidInterfaceException |
|
| 617 | + * @throws ReflectionException |
|
| 618 | + */ |
|
| 619 | + public function column_ATT_email(EE_Registration $registration): string |
|
| 620 | + { |
|
| 621 | + $attendee = $registration->get_first_related('Attendee'); |
|
| 622 | + $content = ! $attendee instanceof EE_Attendee |
|
| 623 | + ? esc_html__('No attached contact record.', 'event_espresso') |
|
| 624 | + : $attendee->email(); |
|
| 625 | + return $this->columnContent('ATT_email', $content); |
|
| 626 | + } |
|
| 627 | + |
|
| 628 | + |
|
| 629 | + /** |
|
| 630 | + * @param EE_Registration $registration |
|
| 631 | + * @return string |
|
| 632 | + */ |
|
| 633 | + public function column__REG_count(EE_Registration $registration): string |
|
| 634 | + { |
|
| 635 | + $content = |
|
| 636 | + sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size()); |
|
| 637 | + return $this->columnContent('_REG_count', $content); |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + |
|
| 641 | + /** |
|
| 642 | + * @param EE_Registration $registration |
|
| 643 | + * @return string |
|
| 644 | + * @throws EE_Error |
|
| 645 | + * @throws ReflectionException |
|
| 646 | + */ |
|
| 647 | + public function column_PRC_amount(EE_Registration $registration): string |
|
| 648 | + { |
|
| 649 | + $ticket = $registration->ticket(); |
|
| 650 | + $req_data = $this->_admin_page->get_request_data(); |
|
| 651 | + |
|
| 652 | + $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket |
|
| 653 | + ? '<div class="TKT_name">' . $ticket->name() . '</div>' |
|
| 654 | + : ''; |
|
| 655 | + |
|
| 656 | + $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM'; |
|
| 657 | + $content .= $registration->final_price() > 0 |
|
| 658 | + ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '"> |
|
| 659 | 659 | ' . $registration->pretty_final_price() . ' |
| 660 | 660 | </span>' |
| 661 | - // free event |
|
| 662 | - : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
| 663 | - |
|
| 664 | - return $this->columnContent('PRC_amount', $content, 'end'); |
|
| 665 | - } |
|
| 666 | - |
|
| 667 | - |
|
| 668 | - /** |
|
| 669 | - * @param EE_Registration $registration |
|
| 670 | - * @return string |
|
| 671 | - * @throws EE_Error |
|
| 672 | - * @throws ReflectionException |
|
| 673 | - */ |
|
| 674 | - public function column__REG_final_price(EE_Registration $registration): string |
|
| 675 | - { |
|
| 676 | - $ticket = $registration->ticket(); |
|
| 677 | - $req_data = $this->_admin_page->get_request_data(); |
|
| 678 | - $content = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 679 | - ? '' |
|
| 680 | - : '<span class="TKT_name ee-status-color--' |
|
| 681 | - . $ticket->ticket_status() |
|
| 682 | - . '">' |
|
| 683 | - . $ticket->name() |
|
| 684 | - . '</span> '; |
|
| 685 | - |
|
| 686 | - $content .= ' |
|
| 661 | + // free event |
|
| 662 | + : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
| 663 | + |
|
| 664 | + return $this->columnContent('PRC_amount', $content, 'end'); |
|
| 665 | + } |
|
| 666 | + |
|
| 667 | + |
|
| 668 | + /** |
|
| 669 | + * @param EE_Registration $registration |
|
| 670 | + * @return string |
|
| 671 | + * @throws EE_Error |
|
| 672 | + * @throws ReflectionException |
|
| 673 | + */ |
|
| 674 | + public function column__REG_final_price(EE_Registration $registration): string |
|
| 675 | + { |
|
| 676 | + $ticket = $registration->ticket(); |
|
| 677 | + $req_data = $this->_admin_page->get_request_data(); |
|
| 678 | + $content = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 679 | + ? '' |
|
| 680 | + : '<span class="TKT_name ee-status-color--' |
|
| 681 | + . $ticket->ticket_status() |
|
| 682 | + . '">' |
|
| 683 | + . $ticket->name() |
|
| 684 | + . '</span> '; |
|
| 685 | + |
|
| 686 | + $content .= ' |
|
| 687 | 687 | <span class="reg-overview-paid-event-spn"> |
| 688 | 688 | ' . $registration->pretty_final_price() . ' |
| 689 | 689 | </span>'; |
| 690 | - return $this->columnContent('_REG_final_price', $content, 'end'); |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - |
|
| 694 | - /** |
|
| 695 | - * @param EE_Registration $registration |
|
| 696 | - * @return string |
|
| 697 | - * @throws EE_Error |
|
| 698 | - */ |
|
| 699 | - public function column__REG_paid(EE_Registration $registration): string |
|
| 700 | - { |
|
| 701 | - $payment_method = $registration->payment_method(); |
|
| 702 | - $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
| 703 | - ? $payment_method->admin_name() |
|
| 704 | - : esc_html__('Unknown', 'event_espresso'); |
|
| 705 | - |
|
| 706 | - $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM'; |
|
| 707 | - $content = ' |
|
| 690 | + return $this->columnContent('_REG_final_price', $content, 'end'); |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + |
|
| 694 | + /** |
|
| 695 | + * @param EE_Registration $registration |
|
| 696 | + * @return string |
|
| 697 | + * @throws EE_Error |
|
| 698 | + */ |
|
| 699 | + public function column__REG_paid(EE_Registration $registration): string |
|
| 700 | + { |
|
| 701 | + $payment_method = $registration->payment_method(); |
|
| 702 | + $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
| 703 | + ? $payment_method->admin_name() |
|
| 704 | + : esc_html__('Unknown', 'event_espresso'); |
|
| 705 | + |
|
| 706 | + $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM'; |
|
| 707 | + $content = ' |
|
| 708 | 708 | <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '"> |
| 709 | 709 | ' . $registration->pretty_paid() . ' |
| 710 | 710 | </span>'; |
| 711 | - if ($registration->paid() > 0) { |
|
| 712 | - $content .= '<span class="ee-status-text-small">' |
|
| 713 | - . sprintf( |
|
| 714 | - esc_html__('...via %s', 'event_espresso'), |
|
| 715 | - $payment_method_name |
|
| 716 | - ) |
|
| 717 | - . '</span>'; |
|
| 718 | - } |
|
| 719 | - return $this->columnContent('_REG_paid', $content, 'end'); |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - |
|
| 723 | - /** |
|
| 724 | - * @param EE_Registration $registration |
|
| 725 | - * @return string |
|
| 726 | - * @throws EE_Error |
|
| 727 | - * @throws EntityNotFoundException |
|
| 728 | - * @throws InvalidArgumentException |
|
| 729 | - * @throws InvalidDataTypeException |
|
| 730 | - * @throws InvalidInterfaceException |
|
| 731 | - * @throws ReflectionException |
|
| 732 | - */ |
|
| 733 | - public function column_TXN_total(EE_Registration $registration): string |
|
| 734 | - { |
|
| 735 | - if ($registration->transaction()) { |
|
| 736 | - $content = $this->caps_handler->userCanViewTransaction() |
|
| 737 | - ? ' |
|
| 711 | + if ($registration->paid() > 0) { |
|
| 712 | + $content .= '<span class="ee-status-text-small">' |
|
| 713 | + . sprintf( |
|
| 714 | + esc_html__('...via %s', 'event_espresso'), |
|
| 715 | + $payment_method_name |
|
| 716 | + ) |
|
| 717 | + . '</span>'; |
|
| 718 | + } |
|
| 719 | + return $this->columnContent('_REG_paid', $content, 'end'); |
|
| 720 | + } |
|
| 721 | + |
|
| 722 | + |
|
| 723 | + /** |
|
| 724 | + * @param EE_Registration $registration |
|
| 725 | + * @return string |
|
| 726 | + * @throws EE_Error |
|
| 727 | + * @throws EntityNotFoundException |
|
| 728 | + * @throws InvalidArgumentException |
|
| 729 | + * @throws InvalidDataTypeException |
|
| 730 | + * @throws InvalidInterfaceException |
|
| 731 | + * @throws ReflectionException |
|
| 732 | + */ |
|
| 733 | + public function column_TXN_total(EE_Registration $registration): string |
|
| 734 | + { |
|
| 735 | + if ($registration->transaction()) { |
|
| 736 | + $content = $this->caps_handler->userCanViewTransaction() |
|
| 737 | + ? ' |
|
| 738 | 738 | <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '" |
| 739 | 739 | href="' . $this->viewTransactionUrl() . '" |
| 740 | 740 | aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '" |
| 741 | 741 | > |
| 742 | 742 | ' . $registration->transaction()->pretty_total() . ' |
| 743 | 743 | </a>' |
| 744 | - : $registration->transaction()->pretty_total(); |
|
| 745 | - } else { |
|
| 746 | - $content = esc_html__("None", "event_espresso"); |
|
| 747 | - } |
|
| 748 | - return $this->columnContent('TXN_total', $content, 'end'); |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - |
|
| 752 | - /** |
|
| 753 | - * @param EE_Registration $registration |
|
| 754 | - * @return string |
|
| 755 | - * @throws EE_Error |
|
| 756 | - * @throws EntityNotFoundException |
|
| 757 | - * @throws InvalidArgumentException |
|
| 758 | - * @throws InvalidDataTypeException |
|
| 759 | - * @throws InvalidInterfaceException |
|
| 760 | - * @throws ReflectionException |
|
| 761 | - */ |
|
| 762 | - public function column_TXN_paid(EE_Registration $registration): string |
|
| 763 | - { |
|
| 764 | - $content = ' '; |
|
| 765 | - $align = 'end'; |
|
| 766 | - if ($registration->count() === 1) { |
|
| 767 | - $transaction = $registration->transaction() |
|
| 768 | - ? $registration->transaction() |
|
| 769 | - : EE_Transaction::new_instance(); |
|
| 770 | - if ($transaction->paid() >= $transaction->total()) { |
|
| 771 | - $align = 'center'; |
|
| 772 | - $content = '<span class="dashicons dashicons-yes green-icon"></span>'; |
|
| 773 | - } else { |
|
| 774 | - $content = $this->caps_handler->userCanViewTransaction() |
|
| 775 | - ? ' |
|
| 744 | + : $registration->transaction()->pretty_total(); |
|
| 745 | + } else { |
|
| 746 | + $content = esc_html__("None", "event_espresso"); |
|
| 747 | + } |
|
| 748 | + return $this->columnContent('TXN_total', $content, 'end'); |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + |
|
| 752 | + /** |
|
| 753 | + * @param EE_Registration $registration |
|
| 754 | + * @return string |
|
| 755 | + * @throws EE_Error |
|
| 756 | + * @throws EntityNotFoundException |
|
| 757 | + * @throws InvalidArgumentException |
|
| 758 | + * @throws InvalidDataTypeException |
|
| 759 | + * @throws InvalidInterfaceException |
|
| 760 | + * @throws ReflectionException |
|
| 761 | + */ |
|
| 762 | + public function column_TXN_paid(EE_Registration $registration): string |
|
| 763 | + { |
|
| 764 | + $content = ' '; |
|
| 765 | + $align = 'end'; |
|
| 766 | + if ($registration->count() === 1) { |
|
| 767 | + $transaction = $registration->transaction() |
|
| 768 | + ? $registration->transaction() |
|
| 769 | + : EE_Transaction::new_instance(); |
|
| 770 | + if ($transaction->paid() >= $transaction->total()) { |
|
| 771 | + $align = 'center'; |
|
| 772 | + $content = '<span class="dashicons dashicons-yes green-icon"></span>'; |
|
| 773 | + } else { |
|
| 774 | + $content = $this->caps_handler->userCanViewTransaction() |
|
| 775 | + ? ' |
|
| 776 | 776 | <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '" |
| 777 | 777 | href="' . $this->viewTransactionUrl() . '" |
| 778 | 778 | aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '" |
| 779 | 779 | > |
| 780 | 780 | ' . $registration->transaction()->pretty_paid() . ' |
| 781 | 781 | </a>' |
| 782 | - : $registration->transaction()->pretty_paid(); |
|
| 783 | - } |
|
| 784 | - } |
|
| 785 | - return $this->columnContent('TXN_paid', $content, $align); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - |
|
| 789 | - /** |
|
| 790 | - * @param EE_Registration $registration |
|
| 791 | - * @return string |
|
| 792 | - * @throws EE_Error |
|
| 793 | - * @throws InvalidArgumentException |
|
| 794 | - * @throws InvalidDataTypeException |
|
| 795 | - * @throws InvalidInterfaceException |
|
| 796 | - * @throws ReflectionException |
|
| 797 | - */ |
|
| 798 | - public function column_actions(EE_Registration $registration): string |
|
| 799 | - { |
|
| 800 | - $attendee = $registration->attendee(); |
|
| 801 | - $this->_set_related_details($registration); |
|
| 802 | - |
|
| 803 | - // Build and filter row actions |
|
| 804 | - $actions = apply_filters( |
|
| 805 | - 'FHEE__EE_Registrations_List_Table__column_actions__actions', |
|
| 806 | - [ |
|
| 807 | - 'view_lnk' => $this->viewRegistrationAction($registration), |
|
| 808 | - 'edit_lnk' => $this->editContactAction($registration, $attendee), |
|
| 809 | - 'resend_reg_lnk' => $this->resendRegistrationMessageAction($registration, $attendee), |
|
| 810 | - 'view_txn_lnk' => $this->viewTransactionAction(), |
|
| 811 | - 'dl_invoice_lnk' => $this->viewTransactionInvoiceAction($registration, $attendee), |
|
| 812 | - 'filtered_messages_link' => $this->viewNotificationsAction($registration), |
|
| 813 | - ], |
|
| 814 | - $registration, |
|
| 815 | - $this |
|
| 816 | - ); |
|
| 817 | - |
|
| 818 | - $content = $this->_action_string( |
|
| 819 | - implode('', $actions), |
|
| 820 | - $registration, |
|
| 821 | - 'div', |
|
| 822 | - 'reg-overview-actions ee-list-table-actions' |
|
| 823 | - ); |
|
| 824 | - |
|
| 825 | - return $this->columnContent('actions', $this->actionsModalMenu($content)); |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - |
|
| 829 | - /** |
|
| 830 | - * @throws EE_Error |
|
| 831 | - * @throws ReflectionException |
|
| 832 | - */ |
|
| 833 | - private function viewRegistrationUrl(EE_Registration $registration): string |
|
| 834 | - { |
|
| 835 | - return EE_Admin_Page::add_query_args_and_nonce( |
|
| 836 | - [ |
|
| 837 | - 'action' => 'view_registration', |
|
| 838 | - '_REG_ID' => $registration->ID(), |
|
| 839 | - ], |
|
| 840 | - REG_ADMIN_URL |
|
| 841 | - ); |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - |
|
| 845 | - /** |
|
| 846 | - * @throws EE_Error |
|
| 847 | - * @throws ReflectionException |
|
| 848 | - */ |
|
| 849 | - private function viewRegistrationLink( |
|
| 850 | - EE_Registration $registration, |
|
| 851 | - string $status |
|
| 852 | - ): string { |
|
| 853 | - $attendee = $registration->attendee(); |
|
| 854 | - $attendee_name = $attendee instanceof EE_Attendee |
|
| 855 | - ? $attendee->full_name() |
|
| 856 | - : ''; |
|
| 857 | - return $this->caps_handler->userCanReadRegistration($registration) |
|
| 858 | - ? ' |
|
| 782 | + : $registration->transaction()->pretty_paid(); |
|
| 783 | + } |
|
| 784 | + } |
|
| 785 | + return $this->columnContent('TXN_paid', $content, $align); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * @param EE_Registration $registration |
|
| 791 | + * @return string |
|
| 792 | + * @throws EE_Error |
|
| 793 | + * @throws InvalidArgumentException |
|
| 794 | + * @throws InvalidDataTypeException |
|
| 795 | + * @throws InvalidInterfaceException |
|
| 796 | + * @throws ReflectionException |
|
| 797 | + */ |
|
| 798 | + public function column_actions(EE_Registration $registration): string |
|
| 799 | + { |
|
| 800 | + $attendee = $registration->attendee(); |
|
| 801 | + $this->_set_related_details($registration); |
|
| 802 | + |
|
| 803 | + // Build and filter row actions |
|
| 804 | + $actions = apply_filters( |
|
| 805 | + 'FHEE__EE_Registrations_List_Table__column_actions__actions', |
|
| 806 | + [ |
|
| 807 | + 'view_lnk' => $this->viewRegistrationAction($registration), |
|
| 808 | + 'edit_lnk' => $this->editContactAction($registration, $attendee), |
|
| 809 | + 'resend_reg_lnk' => $this->resendRegistrationMessageAction($registration, $attendee), |
|
| 810 | + 'view_txn_lnk' => $this->viewTransactionAction(), |
|
| 811 | + 'dl_invoice_lnk' => $this->viewTransactionInvoiceAction($registration, $attendee), |
|
| 812 | + 'filtered_messages_link' => $this->viewNotificationsAction($registration), |
|
| 813 | + ], |
|
| 814 | + $registration, |
|
| 815 | + $this |
|
| 816 | + ); |
|
| 817 | + |
|
| 818 | + $content = $this->_action_string( |
|
| 819 | + implode('', $actions), |
|
| 820 | + $registration, |
|
| 821 | + 'div', |
|
| 822 | + 'reg-overview-actions ee-list-table-actions' |
|
| 823 | + ); |
|
| 824 | + |
|
| 825 | + return $this->columnContent('actions', $this->actionsModalMenu($content)); |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + |
|
| 829 | + /** |
|
| 830 | + * @throws EE_Error |
|
| 831 | + * @throws ReflectionException |
|
| 832 | + */ |
|
| 833 | + private function viewRegistrationUrl(EE_Registration $registration): string |
|
| 834 | + { |
|
| 835 | + return EE_Admin_Page::add_query_args_and_nonce( |
|
| 836 | + [ |
|
| 837 | + 'action' => 'view_registration', |
|
| 838 | + '_REG_ID' => $registration->ID(), |
|
| 839 | + ], |
|
| 840 | + REG_ADMIN_URL |
|
| 841 | + ); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + |
|
| 845 | + /** |
|
| 846 | + * @throws EE_Error |
|
| 847 | + * @throws ReflectionException |
|
| 848 | + */ |
|
| 849 | + private function viewRegistrationLink( |
|
| 850 | + EE_Registration $registration, |
|
| 851 | + string $status |
|
| 852 | + ): string { |
|
| 853 | + $attendee = $registration->attendee(); |
|
| 854 | + $attendee_name = $attendee instanceof EE_Attendee |
|
| 855 | + ? $attendee->full_name() |
|
| 856 | + : ''; |
|
| 857 | + return $this->caps_handler->userCanReadRegistration($registration) |
|
| 858 | + ? ' |
|
| 859 | 859 | <a href="' . $this->viewRegistrationUrl($registration) . '" |
| 860 | 860 | class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" |
| 861 | 861 | aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" |
| 862 | 862 | > |
| 863 | 863 | ' . $attendee_name . ' |
| 864 | 864 | </a>' |
| 865 | - : $attendee_name; |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - |
|
| 869 | - /** |
|
| 870 | - * @throws EE_Error |
|
| 871 | - * @throws ReflectionException |
|
| 872 | - */ |
|
| 873 | - private function viewRegistrationAction(EE_Registration $registration): string |
|
| 874 | - { |
|
| 875 | - return $this->caps_handler->userCanReadRegistration($registration) |
|
| 876 | - ? ' |
|
| 865 | + : $attendee_name; |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + |
|
| 869 | + /** |
|
| 870 | + * @throws EE_Error |
|
| 871 | + * @throws ReflectionException |
|
| 872 | + */ |
|
| 873 | + private function viewRegistrationAction(EE_Registration $registration): string |
|
| 874 | + { |
|
| 875 | + return $this->caps_handler->userCanReadRegistration($registration) |
|
| 876 | + ? ' |
|
| 877 | 877 | <a href="' . $this->viewRegistrationUrl($registration) . '" |
| 878 | 878 | class="ee-aria-tooltip button button--icon-only" |
| 879 | 879 | aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" |
| 880 | 880 | > |
| 881 | 881 | <span class="dashicons dashicons-clipboard"></span> |
| 882 | 882 | </a>' |
| 883 | - : ''; |
|
| 884 | - } |
|
| 885 | - |
|
| 886 | - |
|
| 887 | - private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string |
|
| 888 | - { |
|
| 889 | - |
|
| 890 | - if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) { |
|
| 891 | - $edit_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 892 | - [ |
|
| 893 | - 'action' => 'edit_attendee', |
|
| 894 | - 'post' => $registration->attendee_ID(), |
|
| 895 | - ], |
|
| 896 | - REG_ADMIN_URL |
|
| 897 | - ); |
|
| 898 | - return ' |
|
| 883 | + : ''; |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + |
|
| 887 | + private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string |
|
| 888 | + { |
|
| 889 | + |
|
| 890 | + if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) { |
|
| 891 | + $edit_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 892 | + [ |
|
| 893 | + 'action' => 'edit_attendee', |
|
| 894 | + 'post' => $registration->attendee_ID(), |
|
| 895 | + ], |
|
| 896 | + REG_ADMIN_URL |
|
| 897 | + ); |
|
| 898 | + return ' |
|
| 899 | 899 | <a href="' . $edit_link_url . '" |
| 900 | 900 | aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" |
| 901 | 901 | class="ee-aria-tooltip button button--secondary button--icon-only" |
| 902 | 902 | > |
| 903 | 903 | <span class="dashicons dashicons-admin-users"></span> |
| 904 | 904 | </a>'; |
| 905 | - } |
|
| 906 | - return ''; |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - |
|
| 910 | - /** |
|
| 911 | - * @throws EE_Error |
|
| 912 | - * @throws ReflectionException |
|
| 913 | - */ |
|
| 914 | - private function resendRegistrationMessageAction( |
|
| 915 | - EE_Registration $registration, |
|
| 916 | - ?EE_Attendee $attendee = null |
|
| 917 | - ): string { |
|
| 918 | - if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) { |
|
| 919 | - $resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 920 | - [ |
|
| 921 | - 'action' => 'resend_registration', |
|
| 922 | - '_REG_ID' => $registration->ID(), |
|
| 923 | - ], |
|
| 924 | - REG_ADMIN_URL, |
|
| 925 | - true |
|
| 926 | - ); |
|
| 927 | - return ' |
|
| 905 | + } |
|
| 906 | + return ''; |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + |
|
| 910 | + /** |
|
| 911 | + * @throws EE_Error |
|
| 912 | + * @throws ReflectionException |
|
| 913 | + */ |
|
| 914 | + private function resendRegistrationMessageAction( |
|
| 915 | + EE_Registration $registration, |
|
| 916 | + ?EE_Attendee $attendee = null |
|
| 917 | + ): string { |
|
| 918 | + if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) { |
|
| 919 | + $resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 920 | + [ |
|
| 921 | + 'action' => 'resend_registration', |
|
| 922 | + '_REG_ID' => $registration->ID(), |
|
| 923 | + ], |
|
| 924 | + REG_ADMIN_URL, |
|
| 925 | + true |
|
| 926 | + ); |
|
| 927 | + return ' |
|
| 928 | 928 | <a href="' . $resend_reg_link_url . '" aria-label="' |
| 929 | - . esc_attr__('Resend Registration Details', 'event_espresso') |
|
| 930 | - . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 929 | + . esc_attr__('Resend Registration Details', 'event_espresso') |
|
| 930 | + . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 931 | 931 | <span class="dashicons dashicons-email-alt"></span> |
| 932 | 932 | </a>'; |
| 933 | - } |
|
| 934 | - return ''; |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - |
|
| 938 | - private function viewTransactionUrl(): string |
|
| 939 | - { |
|
| 940 | - return EE_Admin_Page::add_query_args_and_nonce( |
|
| 941 | - [ |
|
| 942 | - 'action' => 'view_transaction', |
|
| 943 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
| 944 | - ], |
|
| 945 | - TXN_ADMIN_URL |
|
| 946 | - ); |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - |
|
| 950 | - private function viewTransactionAction(): string |
|
| 951 | - { |
|
| 952 | - if ($this->caps_handler->userCanViewTransaction()) { |
|
| 953 | - return ' |
|
| 933 | + } |
|
| 934 | + return ''; |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + |
|
| 938 | + private function viewTransactionUrl(): string |
|
| 939 | + { |
|
| 940 | + return EE_Admin_Page::add_query_args_and_nonce( |
|
| 941 | + [ |
|
| 942 | + 'action' => 'view_transaction', |
|
| 943 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
| 944 | + ], |
|
| 945 | + TXN_ADMIN_URL |
|
| 946 | + ); |
|
| 947 | + } |
|
| 948 | + |
|
| 949 | + |
|
| 950 | + private function viewTransactionAction(): string |
|
| 951 | + { |
|
| 952 | + if ($this->caps_handler->userCanViewTransaction()) { |
|
| 953 | + return ' |
|
| 954 | 954 | <a class="ee-aria-tooltip button button--icon-only" |
| 955 | 955 | href="' . $this->viewTransactionUrl() . '" |
| 956 | 956 | aria-label="' . $this->_transaction_details['title_attr'] . '" |
| 957 | 957 | > |
| 958 | 958 | <span class="dashicons dashicons-cart"></span> |
| 959 | 959 | </a>'; |
| 960 | - } |
|
| 961 | - return ''; |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - |
|
| 965 | - /** |
|
| 966 | - * @throws EE_Error |
|
| 967 | - * @throws ReflectionException |
|
| 968 | - */ |
|
| 969 | - private function viewTransactionInvoiceAction( |
|
| 970 | - EE_Registration $registration, |
|
| 971 | - ?EE_Attendee $attendee = null |
|
| 972 | - ): string { |
|
| 973 | - // only show invoice link if message type is active. |
|
| 974 | - if ( |
|
| 975 | - $attendee instanceof EE_Attendee |
|
| 976 | - && $registration->is_primary_registrant() |
|
| 977 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
| 978 | - ) { |
|
| 979 | - return ' |
|
| 960 | + } |
|
| 961 | + return ''; |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + |
|
| 965 | + /** |
|
| 966 | + * @throws EE_Error |
|
| 967 | + * @throws ReflectionException |
|
| 968 | + */ |
|
| 969 | + private function viewTransactionInvoiceAction( |
|
| 970 | + EE_Registration $registration, |
|
| 971 | + ?EE_Attendee $attendee = null |
|
| 972 | + ): string { |
|
| 973 | + // only show invoice link if message type is active. |
|
| 974 | + if ( |
|
| 975 | + $attendee instanceof EE_Attendee |
|
| 976 | + && $registration->is_primary_registrant() |
|
| 977 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
| 978 | + ) { |
|
| 979 | + return ' |
|
| 980 | 980 | <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') |
| 981 | - . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 981 | + . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 982 | 982 | <span class="dashicons dashicons-media-spreadsheet"></span> |
| 983 | 983 | </a>'; |
| 984 | - } |
|
| 985 | - return ''; |
|
| 986 | - } |
|
| 987 | - |
|
| 988 | - |
|
| 989 | - /** |
|
| 990 | - * @throws ReflectionException |
|
| 991 | - * @throws EE_Error |
|
| 992 | - */ |
|
| 993 | - private function viewNotificationsAction(EE_Registration $registration): string |
|
| 994 | - { |
|
| 995 | - // message list table link (filtered by REG_ID |
|
| 996 | - return $this->caps_handler->userCanReadGlobalMessages() |
|
| 997 | - ? EEH_MSG_Template::get_message_action_link( |
|
| 998 | - 'see_notifications_for', |
|
| 999 | - null, |
|
| 1000 | - ['_REG_ID' => $registration->ID()] |
|
| 1001 | - ) |
|
| 1002 | - : ''; |
|
| 1003 | - } |
|
| 1004 | - |
|
| 1005 | - |
|
| 1006 | - /** |
|
| 1007 | - * @throws EE_Error |
|
| 1008 | - * @throws ReflectionException |
|
| 1009 | - */ |
|
| 1010 | - private function trashRegistrationLink( |
|
| 1011 | - EE_Registration $registration, |
|
| 1012 | - array $url_params |
|
| 1013 | - ): array { |
|
| 1014 | - $actions = []; |
|
| 1015 | - // can't trash what's already trashed |
|
| 1016 | - if ($this->_view === 'trash') { |
|
| 1017 | - return $actions; |
|
| 1018 | - } |
|
| 1019 | - |
|
| 1020 | - // check caps |
|
| 1021 | - if (! $this->caps_handler->userCanTrashRegistration($registration)) { |
|
| 1022 | - return $actions; |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - // don't delete registrations that have payments applied |
|
| 1026 | - $transaction = $registration->get_first_related('Transaction'); |
|
| 1027 | - $payment_count = $transaction instanceof EE_Transaction |
|
| 1028 | - ? $transaction->count_related('Payment') |
|
| 1029 | - : 0; |
|
| 1030 | - |
|
| 1031 | - if ($payment_count > 0) { |
|
| 1032 | - return $actions; |
|
| 1033 | - } |
|
| 1034 | - |
|
| 1035 | - $url_params['action'] = 'trash_registrations'; |
|
| 1036 | - $trash_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
| 1037 | - $actions['trash'] = ' |
|
| 984 | + } |
|
| 985 | + return ''; |
|
| 986 | + } |
|
| 987 | + |
|
| 988 | + |
|
| 989 | + /** |
|
| 990 | + * @throws ReflectionException |
|
| 991 | + * @throws EE_Error |
|
| 992 | + */ |
|
| 993 | + private function viewNotificationsAction(EE_Registration $registration): string |
|
| 994 | + { |
|
| 995 | + // message list table link (filtered by REG_ID |
|
| 996 | + return $this->caps_handler->userCanReadGlobalMessages() |
|
| 997 | + ? EEH_MSG_Template::get_message_action_link( |
|
| 998 | + 'see_notifications_for', |
|
| 999 | + null, |
|
| 1000 | + ['_REG_ID' => $registration->ID()] |
|
| 1001 | + ) |
|
| 1002 | + : ''; |
|
| 1003 | + } |
|
| 1004 | + |
|
| 1005 | + |
|
| 1006 | + /** |
|
| 1007 | + * @throws EE_Error |
|
| 1008 | + * @throws ReflectionException |
|
| 1009 | + */ |
|
| 1010 | + private function trashRegistrationLink( |
|
| 1011 | + EE_Registration $registration, |
|
| 1012 | + array $url_params |
|
| 1013 | + ): array { |
|
| 1014 | + $actions = []; |
|
| 1015 | + // can't trash what's already trashed |
|
| 1016 | + if ($this->_view === 'trash') { |
|
| 1017 | + return $actions; |
|
| 1018 | + } |
|
| 1019 | + |
|
| 1020 | + // check caps |
|
| 1021 | + if (! $this->caps_handler->userCanTrashRegistration($registration)) { |
|
| 1022 | + return $actions; |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + // don't delete registrations that have payments applied |
|
| 1026 | + $transaction = $registration->get_first_related('Transaction'); |
|
| 1027 | + $payment_count = $transaction instanceof EE_Transaction |
|
| 1028 | + ? $transaction->count_related('Payment') |
|
| 1029 | + : 0; |
|
| 1030 | + |
|
| 1031 | + if ($payment_count > 0) { |
|
| 1032 | + return $actions; |
|
| 1033 | + } |
|
| 1034 | + |
|
| 1035 | + $url_params['action'] = 'trash_registrations'; |
|
| 1036 | + $trash_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
| 1037 | + $actions['trash'] = ' |
|
| 1038 | 1038 | <a class="ee-aria-tooltip" |
| 1039 | 1039 | href="' . $trash_link_url . '" |
| 1040 | 1040 | aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '" |
| 1041 | 1041 | > |
| 1042 | 1042 | ' . esc_html__('Trash', 'event_espresso') . ' |
| 1043 | 1043 | </a>'; |
| 1044 | - return $actions; |
|
| 1045 | - } |
|
| 1046 | - |
|
| 1047 | - |
|
| 1048 | - /** |
|
| 1049 | - * @throws EE_Error |
|
| 1050 | - * @throws ReflectionException |
|
| 1051 | - */ |
|
| 1052 | - private function restoreRegistrationLink( |
|
| 1053 | - EE_Registration $registration, |
|
| 1054 | - array $url_params, |
|
| 1055 | - array $actions |
|
| 1056 | - ): array { |
|
| 1057 | - // can't restore what's not trashed |
|
| 1058 | - if ($this->_view !== 'trash') { |
|
| 1059 | - return $actions; |
|
| 1060 | - } |
|
| 1061 | - |
|
| 1062 | - // restore registration link |
|
| 1063 | - if ($this->caps_handler->userCanRestoreRegistration($registration)) { |
|
| 1064 | - $url_params['action'] = 'restore_registrations'; |
|
| 1065 | - $restore_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
| 1066 | - $actions['restore'] = ' |
|
| 1044 | + return $actions; |
|
| 1045 | + } |
|
| 1046 | + |
|
| 1047 | + |
|
| 1048 | + /** |
|
| 1049 | + * @throws EE_Error |
|
| 1050 | + * @throws ReflectionException |
|
| 1051 | + */ |
|
| 1052 | + private function restoreRegistrationLink( |
|
| 1053 | + EE_Registration $registration, |
|
| 1054 | + array $url_params, |
|
| 1055 | + array $actions |
|
| 1056 | + ): array { |
|
| 1057 | + // can't restore what's not trashed |
|
| 1058 | + if ($this->_view !== 'trash') { |
|
| 1059 | + return $actions; |
|
| 1060 | + } |
|
| 1061 | + |
|
| 1062 | + // restore registration link |
|
| 1063 | + if ($this->caps_handler->userCanRestoreRegistration($registration)) { |
|
| 1064 | + $url_params['action'] = 'restore_registrations'; |
|
| 1065 | + $restore_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
| 1066 | + $actions['restore'] = ' |
|
| 1067 | 1067 | <a class="ee-aria-tooltip" |
| 1068 | 1068 | href="' . $restore_link_url . '" |
| 1069 | 1069 | aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '" |
| 1070 | 1070 | > |
| 1071 | 1071 | ' . esc_html__('Restore', 'event_espresso') . ' |
| 1072 | 1072 | </a>'; |
| 1073 | - } |
|
| 1074 | - |
|
| 1075 | - return $actions; |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - |
|
| 1079 | - /** |
|
| 1080 | - * @throws EE_Error |
|
| 1081 | - * @throws ReflectionException |
|
| 1082 | - */ |
|
| 1083 | - private function deleteRegistrationLink( |
|
| 1084 | - EE_Registration $registration, |
|
| 1085 | - array $url_params, |
|
| 1086 | - array $actions |
|
| 1087 | - ): array { |
|
| 1088 | - if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) { |
|
| 1089 | - $url_params['action'] = 'delete_registrations'; |
|
| 1090 | - $delete_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
| 1091 | - $actions['delete'] = ' |
|
| 1073 | + } |
|
| 1074 | + |
|
| 1075 | + return $actions; |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + |
|
| 1079 | + /** |
|
| 1080 | + * @throws EE_Error |
|
| 1081 | + * @throws ReflectionException |
|
| 1082 | + */ |
|
| 1083 | + private function deleteRegistrationLink( |
|
| 1084 | + EE_Registration $registration, |
|
| 1085 | + array $url_params, |
|
| 1086 | + array $actions |
|
| 1087 | + ): array { |
|
| 1088 | + if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) { |
|
| 1089 | + $url_params['action'] = 'delete_registrations'; |
|
| 1090 | + $delete_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
|
| 1091 | + $actions['delete'] = ' |
|
| 1092 | 1092 | <a class="ee-aria-tooltip" |
| 1093 | 1093 | href="' . $delete_link_url . '" |
| 1094 | 1094 | aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '" |
| 1095 | 1095 | > |
| 1096 | 1096 | ' . esc_html__('Delete', 'event_espresso') . ' |
| 1097 | 1097 | </a>'; |
| 1098 | - } |
|
| 1099 | - return $actions; |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - |
|
| 1103 | - private function editEventLink(int $EVT_ID, string $event_name): string |
|
| 1104 | - { |
|
| 1105 | - if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) { |
|
| 1106 | - return $event_name; |
|
| 1107 | - } |
|
| 1108 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1109 | - ['action' => 'edit', 'post' => $EVT_ID], |
|
| 1110 | - EVENTS_ADMIN_URL |
|
| 1111 | - ); |
|
| 1112 | - return ' |
|
| 1098 | + } |
|
| 1099 | + return $actions; |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + |
|
| 1103 | + private function editEventLink(int $EVT_ID, string $event_name): string |
|
| 1104 | + { |
|
| 1105 | + if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) { |
|
| 1106 | + return $event_name; |
|
| 1107 | + } |
|
| 1108 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1109 | + ['action' => 'edit', 'post' => $EVT_ID], |
|
| 1110 | + EVENTS_ADMIN_URL |
|
| 1111 | + ); |
|
| 1112 | + return ' |
|
| 1113 | 1113 | <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '" |
| 1114 | 1114 | href="' . $edit_event_url . '" |
| 1115 | 1115 | aria-label="' . esc_attr($this->_event_details['title_attr']) . '" |
| 1116 | 1116 | > |
| 1117 | 1117 | ' . $event_name . ' |
| 1118 | 1118 | </a>'; |
| 1119 | - } |
|
| 1119 | + } |
|
| 1120 | 1120 | |
| 1121 | 1121 | |
| 1122 | - private function eventFilterLink(int $EVT_ID, string $event_name): string |
|
| 1123 | - { |
|
| 1124 | - if (!$EVT_ID) { |
|
| 1125 | - return ''; |
|
| 1126 | - } |
|
| 1127 | - $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL); |
|
| 1128 | - return ' |
|
| 1122 | + private function eventFilterLink(int $EVT_ID, string $event_name): string |
|
| 1123 | + { |
|
| 1124 | + if (!$EVT_ID) { |
|
| 1125 | + return ''; |
|
| 1126 | + } |
|
| 1127 | + $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL); |
|
| 1128 | + return ' |
|
| 1129 | 1129 | <a class="ee-aria-tooltip ee-event-filter-link" |
| 1130 | 1130 | href="' . $event_filter_url . '" |
| 1131 | 1131 | aria-label="' . sprintf( |
| 1132 | - esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
| 1133 | - $event_name |
|
| 1134 | - ) . '" |
|
| 1132 | + esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
| 1133 | + $event_name |
|
| 1134 | + ) . '" |
|
| 1135 | 1135 | > |
| 1136 | 1136 | <span class="dashicons dashicons-groups dashicons--small"></span>' |
| 1137 | - . esc_html__('View Registrations', 'event_espresso') . ' |
|
| 1137 | + . esc_html__('View Registrations', 'event_espresso') . ' |
|
| 1138 | 1138 | </a>'; |
| 1139 | - } |
|
| 1139 | + } |
|
| 1140 | 1140 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP); |
| 55 | 55 | $req_data = $admin_page->get_request_data(); |
| 56 | - if (! empty($req_data['event_id'])) { |
|
| 56 | + if ( ! empty($req_data['event_id'])) { |
|
| 57 | 57 | $extra_query_args = []; |
| 58 | 58 | foreach ($admin_page->get_views() as $view_details) { |
| 59 | - $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']]; |
|
| 59 | + $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']]; |
|
| 60 | 60 | } |
| 61 | 61 | $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
| 62 | 62 | } |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | 'ajax' => true, |
| 89 | 89 | 'screen' => $this->_admin_page->get_current_screen()->id, |
| 90 | 90 | ]; |
| 91 | - $req_data = $this->_admin_page->get_request_data(); |
|
| 91 | + $req_data = $this->_admin_page->get_request_data(); |
|
| 92 | 92 | if (isset($req_data['event_id'])) { |
| 93 | - $this->_columns = [ |
|
| 93 | + $this->_columns = [ |
|
| 94 | 94 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
| 95 | 95 | 'id' => esc_html__('ID', 'event_espresso'), |
| 96 | 96 | 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | ], |
| 113 | 113 | ]; |
| 114 | 114 | } else { |
| 115 | - $this->_columns = [ |
|
| 115 | + $this->_columns = [ |
|
| 116 | 116 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
| 117 | 117 | 'id' => esc_html__('ID', 'event_espresso'), |
| 118 | 118 | 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | 'return_url' => $return_url, |
| 140 | 140 | ], |
| 141 | 141 | ]; |
| 142 | - $filters = array_diff_key( |
|
| 142 | + $filters = array_diff_key( |
|
| 143 | 143 | $this->_req_data, |
| 144 | 144 | array_flip( |
| 145 | 145 | [ |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | ] |
| 150 | 150 | ) |
| 151 | 151 | ); |
| 152 | - if (! empty($filters)) { |
|
| 152 | + if ( ! empty($filters)) { |
|
| 153 | 153 | $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters; |
| 154 | 154 | } |
| 155 | 155 | $this->_primary_column = 'id'; |
| 156 | 156 | $this->_sortable_columns = [ |
| 157 | - '_REG_date' => ['_REG_date' => true], // true means its already sorted |
|
| 157 | + '_REG_date' => ['_REG_date' => true], // true means its already sorted |
|
| 158 | 158 | /** |
| 159 | 159 | * Allows users to change the default sort if they wish. |
| 160 | 160 | * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | 'DTT_EVT_start' => ['DTT_EVT_start' => false], |
| 172 | 172 | 'id' => ['REG_ID' => false], |
| 173 | 173 | ]; |
| 174 | - $this->_hidden_columns = []; |
|
| 174 | + $this->_hidden_columns = []; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | $this_month_r = date('m', current_time('timestamp')); |
| 345 | 345 | $days_this_month = date('t', current_time('timestamp')); |
| 346 | 346 | // setup date query. |
| 347 | - $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 347 | + $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 348 | 348 | 'REG_date', |
| 349 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 349 | + $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, |
|
| 350 | 350 | 'Y-m-d H:i:s' |
| 351 | 351 | ); |
| 352 | - $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 352 | + $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 353 | 353 | 'REG_date', |
| 354 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 354 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, |
|
| 355 | 355 | 'Y-m-d H:i:s' |
| 356 | 356 | ); |
| 357 | 357 | $_where['REG_date'] = [ |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | $end_string, |
| 362 | 362 | ], |
| 363 | 363 | ]; |
| 364 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 364 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 365 | 365 | return EEM_Registration::instance()->count([$_where]); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -387,17 +387,17 @@ discard block |
||
| 387 | 387 | [ |
| 388 | 388 | EEM_Registration::instance()->convert_datetime_for_query( |
| 389 | 389 | 'REG_date', |
| 390 | - $current_date . $time_start, |
|
| 390 | + $current_date.$time_start, |
|
| 391 | 391 | 'Y-m-d H:i:s' |
| 392 | 392 | ), |
| 393 | 393 | EEM_Registration::instance()->convert_datetime_for_query( |
| 394 | 394 | 'REG_date', |
| 395 | - $current_date . $time_end, |
|
| 395 | + $current_date.$time_end, |
|
| 396 | 396 | 'Y-m-d H:i:s' |
| 397 | 397 | ), |
| 398 | 398 | ], |
| 399 | 399 | ]; |
| 400 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 400 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 401 | 401 | return EEM_Registration::instance()->count([$_where]); |
| 402 | 402 | } |
| 403 | 403 | |
@@ -421,9 +421,9 @@ discard block |
||
| 421 | 421 | : 0; |
| 422 | 422 | |
| 423 | 423 | $content = $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item) |
| 424 | - ? '<input disabled type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" /> |
|
| 424 | + ? '<input disabled type="checkbox" name="_REG_ID[]" value="'.$REG_ID.'" /> |
|
| 425 | 425 | <span class="dashicons dashicons-lock"></span>' |
| 426 | - : '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />'; |
|
| 426 | + : '<input type="checkbox" name="_REG_ID[]" value="'.$REG_ID.'" />'; |
|
| 427 | 427 | |
| 428 | 428 | return $this->columnContent('cb', $content, 'center'); |
| 429 | 429 | } |
@@ -471,21 +471,21 @@ discard block |
||
| 471 | 471 | esc_html__('(%1$s / %2$s)', 'event_espresso'), |
| 472 | 472 | $registration->count(), |
| 473 | 473 | $registration->group_size() |
| 474 | - ) . ' |
|
| 474 | + ).' |
|
| 475 | 475 | </span >'; |
| 476 | 476 | |
| 477 | 477 | $content = ' |
| 478 | 478 | <div class="ee-layout-row"> |
| 479 | - <span aria-label="' . $pretty_status . '" |
|
| 480 | - class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip" |
|
| 479 | + <span aria-label="' . $pretty_status.'" |
|
| 480 | + class="ee-status-dot ee-status-bg--' . $status.' ee-aria-tooltip" |
|
| 481 | 481 | ></span> |
| 482 | 482 | ' . $this->viewRegistrationLink($registration, $status) |
| 483 | 483 | . $prime_reg_star |
| 484 | - . $group_count . ' |
|
| 484 | + . $group_count.' |
|
| 485 | 485 | </div>'; |
| 486 | 486 | |
| 487 | 487 | // append reg_code |
| 488 | - $content .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code')); |
|
| 488 | + $content .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code')); |
|
| 489 | 489 | $url_params = ['_REG_ID' => $registration->ID()]; |
| 490 | 490 | if (isset($this->_req_data['event_id'])) { |
| 491 | 491 | $url_params['event_id'] = $registration->event_ID(); |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | $this->_set_related_details($registration); |
| 514 | 514 | // Build row actions |
| 515 | 515 | $content = $this->caps_handler->userCanViewTransaction() |
| 516 | - ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="' |
|
| 516 | + ? '<a class="ee-aria-tooltip ee-status-color--'.$this->_transaction_details['status'].'" href="' |
|
| 517 | 517 | . $this->viewTransactionUrl() |
| 518 | 518 | . '" aria-label="' |
| 519 | 519 | . esc_attr($this->_transaction_details['title_attr']) |
@@ -589,16 +589,16 @@ discard block |
||
| 589 | 589 | // $content = '<div class="ee-registration-event-datetimes-container">'; |
| 590 | 590 | // get first item for initial visibility |
| 591 | 591 | $content = array_shift($datetime_strings); |
| 592 | - if (! empty($datetime_strings)) { |
|
| 592 | + if ( ! empty($datetime_strings)) { |
|
| 593 | 593 | $content .= ' |
| 594 | 594 | <div class="ee-registration-event-datetimes-container-wrap"> |
| 595 | - <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '" |
|
| 595 | + <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso').'" |
|
| 596 | 596 | class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle" |
| 597 | 597 | > |
| 598 | 598 | <span class="dashicons dashicons-admin-collapse"></span> |
| 599 | 599 | </button> |
| 600 | 600 | <div class="ee-registration-event-datetimes-container more-items hidden"> |
| 601 | - ' . implode("", $datetime_strings) . ' |
|
| 601 | + ' . implode("", $datetime_strings).' |
|
| 602 | 602 | </div> |
| 603 | 603 | </div>'; |
| 604 | 604 | } |
@@ -650,16 +650,16 @@ discard block |
||
| 650 | 650 | $req_data = $this->_admin_page->get_request_data(); |
| 651 | 651 | |
| 652 | 652 | $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket |
| 653 | - ? '<div class="TKT_name">' . $ticket->name() . '</div>' |
|
| 653 | + ? '<div class="TKT_name">'.$ticket->name().'</div>' |
|
| 654 | 654 | : ''; |
| 655 | 655 | |
| 656 | 656 | $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM'; |
| 657 | - $content .= $registration->final_price() > 0 |
|
| 658 | - ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '"> |
|
| 659 | - ' . $registration->pretty_final_price() . ' |
|
| 657 | + $content .= $registration->final_price() > 0 |
|
| 658 | + ? '<span class="reg-overview-paid-event-spn ee-status-color--'.$payment_status.'"> |
|
| 659 | + ' . $registration->pretty_final_price().' |
|
| 660 | 660 | </span>' |
| 661 | 661 | // free event |
| 662 | - : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
| 662 | + : '<span class="reg-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>'; |
|
| 663 | 663 | |
| 664 | 664 | return $this->columnContent('PRC_amount', $content, 'end'); |
| 665 | 665 | } |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | |
| 686 | 686 | $content .= ' |
| 687 | 687 | <span class="reg-overview-paid-event-spn"> |
| 688 | - ' . $registration->pretty_final_price() . ' |
|
| 688 | + ' . $registration->pretty_final_price().' |
|
| 689 | 689 | </span>'; |
| 690 | 690 | return $this->columnContent('_REG_final_price', $content, 'end'); |
| 691 | 691 | } |
@@ -705,8 +705,8 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM'; |
| 707 | 707 | $content = ' |
| 708 | - <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '"> |
|
| 709 | - ' . $registration->pretty_paid() . ' |
|
| 708 | + <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status.'"> |
|
| 709 | + ' . $registration->pretty_paid().' |
|
| 710 | 710 | </span>'; |
| 711 | 711 | if ($registration->paid() > 0) { |
| 712 | 712 | $content .= '<span class="ee-status-text-small">' |
@@ -735,11 +735,11 @@ discard block |
||
| 735 | 735 | if ($registration->transaction()) { |
| 736 | 736 | $content = $this->caps_handler->userCanViewTransaction() |
| 737 | 737 | ? ' |
| 738 | - <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '" |
|
| 739 | - href="' . $this->viewTransactionUrl() . '" |
|
| 740 | - aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '" |
|
| 738 | + <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID().'" |
|
| 739 | + href="' . $this->viewTransactionUrl().'" |
|
| 740 | + aria-label="' . esc_attr__('View Transaction', 'event_espresso').'" |
|
| 741 | 741 | > |
| 742 | - ' . $registration->transaction()->pretty_total() . ' |
|
| 742 | + ' . $registration->transaction()->pretty_total().' |
|
| 743 | 743 | </a>' |
| 744 | 744 | : $registration->transaction()->pretty_total(); |
| 745 | 745 | } else { |
@@ -773,11 +773,11 @@ discard block |
||
| 773 | 773 | } else { |
| 774 | 774 | $content = $this->caps_handler->userCanViewTransaction() |
| 775 | 775 | ? ' |
| 776 | - <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '" |
|
| 777 | - href="' . $this->viewTransactionUrl() . '" |
|
| 778 | - aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '" |
|
| 776 | + <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID().'" |
|
| 777 | + href="' . $this->viewTransactionUrl().'" |
|
| 778 | + aria-label="' . esc_attr__('View Transaction', 'event_espresso').'" |
|
| 779 | 779 | > |
| 780 | - ' . $registration->transaction()->pretty_paid() . ' |
|
| 780 | + ' . $registration->transaction()->pretty_paid().' |
|
| 781 | 781 | </a>' |
| 782 | 782 | : $registration->transaction()->pretty_paid(); |
| 783 | 783 | } |
@@ -856,11 +856,11 @@ discard block |
||
| 856 | 856 | : ''; |
| 857 | 857 | return $this->caps_handler->userCanReadRegistration($registration) |
| 858 | 858 | ? ' |
| 859 | - <a href="' . $this->viewRegistrationUrl($registration) . '" |
|
| 860 | - class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" |
|
| 861 | - aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" |
|
| 859 | + <a href="' . $this->viewRegistrationUrl($registration).'" |
|
| 860 | + class="row-title ee-status-color--' . $status.' ee-aria-tooltip" |
|
| 861 | + aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'" |
|
| 862 | 862 | > |
| 863 | - ' . $attendee_name . ' |
|
| 863 | + ' . $attendee_name.' |
|
| 864 | 864 | </a>' |
| 865 | 865 | : $attendee_name; |
| 866 | 866 | } |
@@ -874,9 +874,9 @@ discard block |
||
| 874 | 874 | { |
| 875 | 875 | return $this->caps_handler->userCanReadRegistration($registration) |
| 876 | 876 | ? ' |
| 877 | - <a href="' . $this->viewRegistrationUrl($registration) . '" |
|
| 877 | + <a href="' . $this->viewRegistrationUrl($registration).'" |
|
| 878 | 878 | class="ee-aria-tooltip button button--icon-only" |
| 879 | - aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" |
|
| 879 | + aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'" |
|
| 880 | 880 | > |
| 881 | 881 | <span class="dashicons dashicons-clipboard"></span> |
| 882 | 882 | </a>' |
@@ -896,8 +896,8 @@ discard block |
||
| 896 | 896 | REG_ADMIN_URL |
| 897 | 897 | ); |
| 898 | 898 | return ' |
| 899 | - <a href="' . $edit_link_url . '" |
|
| 900 | - aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" |
|
| 899 | + <a href="' . $edit_link_url.'" |
|
| 900 | + aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso').'" |
|
| 901 | 901 | class="ee-aria-tooltip button button--secondary button--icon-only" |
| 902 | 902 | > |
| 903 | 903 | <span class="dashicons dashicons-admin-users"></span> |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | true |
| 926 | 926 | ); |
| 927 | 927 | return ' |
| 928 | - <a href="' . $resend_reg_link_url . '" aria-label="' |
|
| 928 | + <a href="' . $resend_reg_link_url.'" aria-label="' |
|
| 929 | 929 | . esc_attr__('Resend Registration Details', 'event_espresso') |
| 930 | 930 | . '" class="ee-aria-tooltip button button--icon-only"> |
| 931 | 931 | <span class="dashicons dashicons-email-alt"></span> |
@@ -952,8 +952,8 @@ discard block |
||
| 952 | 952 | if ($this->caps_handler->userCanViewTransaction()) { |
| 953 | 953 | return ' |
| 954 | 954 | <a class="ee-aria-tooltip button button--icon-only" |
| 955 | - href="' . $this->viewTransactionUrl() . '" |
|
| 956 | - aria-label="' . $this->_transaction_details['title_attr'] . '" |
|
| 955 | + href="' . $this->viewTransactionUrl().'" |
|
| 956 | + aria-label="' . $this->_transaction_details['title_attr'].'" |
|
| 957 | 957 | > |
| 958 | 958 | <span class="dashicons dashicons-cart"></span> |
| 959 | 959 | </a>'; |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | ) { |
| 979 | 979 | return ' |
| 980 | 980 | <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') |
| 981 | - . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only"> |
|
| 981 | + . '" target="_blank" href="'.$registration->invoice_url().'" class="ee-aria-tooltip button button--icon-only"> |
|
| 982 | 982 | <span class="dashicons dashicons-media-spreadsheet"></span> |
| 983 | 983 | </a>'; |
| 984 | 984 | } |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | // check caps |
| 1021 | - if (! $this->caps_handler->userCanTrashRegistration($registration)) { |
|
| 1021 | + if ( ! $this->caps_handler->userCanTrashRegistration($registration)) { |
|
| 1022 | 1022 | return $actions; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
@@ -1036,10 +1036,10 @@ discard block |
||
| 1036 | 1036 | $trash_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
| 1037 | 1037 | $actions['trash'] = ' |
| 1038 | 1038 | <a class="ee-aria-tooltip" |
| 1039 | - href="' . $trash_link_url . '" |
|
| 1040 | - aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '" |
|
| 1039 | + href="' . $trash_link_url.'" |
|
| 1040 | + aria-label="' . esc_attr__('Trash Registration', 'event_espresso').'" |
|
| 1041 | 1041 | > |
| 1042 | - ' . esc_html__('Trash', 'event_espresso') . ' |
|
| 1042 | + ' . esc_html__('Trash', 'event_espresso').' |
|
| 1043 | 1043 | </a>'; |
| 1044 | 1044 | return $actions; |
| 1045 | 1045 | } |
@@ -1065,10 +1065,10 @@ discard block |
||
| 1065 | 1065 | $restore_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
| 1066 | 1066 | $actions['restore'] = ' |
| 1067 | 1067 | <a class="ee-aria-tooltip" |
| 1068 | - href="' . $restore_link_url . '" |
|
| 1069 | - aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '" |
|
| 1068 | + href="' . $restore_link_url.'" |
|
| 1069 | + aria-label="' . esc_attr__('Restore Registration', 'event_espresso').'" |
|
| 1070 | 1070 | > |
| 1071 | - ' . esc_html__('Restore', 'event_espresso') . ' |
|
| 1071 | + ' . esc_html__('Restore', 'event_espresso').' |
|
| 1072 | 1072 | </a>'; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
@@ -1090,10 +1090,10 @@ discard block |
||
| 1090 | 1090 | $delete_link_url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL); |
| 1091 | 1091 | $actions['delete'] = ' |
| 1092 | 1092 | <a class="ee-aria-tooltip" |
| 1093 | - href="' . $delete_link_url . '" |
|
| 1094 | - aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '" |
|
| 1093 | + href="' . $delete_link_url.'" |
|
| 1094 | + aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso').'" |
|
| 1095 | 1095 | > |
| 1096 | - ' . esc_html__('Delete', 'event_espresso') . ' |
|
| 1096 | + ' . esc_html__('Delete', 'event_espresso').' |
|
| 1097 | 1097 | </a>'; |
| 1098 | 1098 | } |
| 1099 | 1099 | return $actions; |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | |
| 1103 | 1103 | private function editEventLink(int $EVT_ID, string $event_name): string |
| 1104 | 1104 | { |
| 1105 | - if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) { |
|
| 1105 | + if ( ! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) { |
|
| 1106 | 1106 | return $event_name; |
| 1107 | 1107 | } |
| 1108 | 1108 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
@@ -1110,31 +1110,31 @@ discard block |
||
| 1110 | 1110 | EVENTS_ADMIN_URL |
| 1111 | 1111 | ); |
| 1112 | 1112 | return ' |
| 1113 | - <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '" |
|
| 1114 | - href="' . $edit_event_url . '" |
|
| 1115 | - aria-label="' . esc_attr($this->_event_details['title_attr']) . '" |
|
| 1113 | + <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'].'" |
|
| 1114 | + href="' . $edit_event_url.'" |
|
| 1115 | + aria-label="' . esc_attr($this->_event_details['title_attr']).'" |
|
| 1116 | 1116 | > |
| 1117 | - ' . $event_name . ' |
|
| 1117 | + ' . $event_name.' |
|
| 1118 | 1118 | </a>'; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | |
| 1122 | 1122 | private function eventFilterLink(int $EVT_ID, string $event_name): string |
| 1123 | 1123 | { |
| 1124 | - if (!$EVT_ID) { |
|
| 1124 | + if ( ! $EVT_ID) { |
|
| 1125 | 1125 | return ''; |
| 1126 | 1126 | } |
| 1127 | 1127 | $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL); |
| 1128 | 1128 | return ' |
| 1129 | 1129 | <a class="ee-aria-tooltip ee-event-filter-link" |
| 1130 | - href="' . $event_filter_url . '" |
|
| 1130 | + href="' . $event_filter_url.'" |
|
| 1131 | 1131 | aria-label="' . sprintf( |
| 1132 | 1132 | esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
| 1133 | 1133 | $event_name |
| 1134 | - ) . '" |
|
| 1134 | + ).'" |
|
| 1135 | 1135 | > |
| 1136 | 1136 | <span class="dashicons dashicons-groups dashicons--small"></span>' |
| 1137 | - . esc_html__('View Registrations', 'event_espresso') . ' |
|
| 1137 | + . esc_html__('View Registrations', 'event_espresso').' |
|
| 1138 | 1138 | </a>'; |
| 1139 | 1139 | } |
| 1140 | 1140 | } |
@@ -12,402 +12,402 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var Registrations_Admin_Page |
|
| 17 | - */ |
|
| 18 | - protected $_admin_page; |
|
| 19 | - |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Initial setup of data (called by parent). |
|
| 23 | - * |
|
| 24 | - * @throws EE_Error |
|
| 25 | - */ |
|
| 26 | - protected function _setup_data() |
|
| 27 | - { |
|
| 28 | - $this->_data = $this->_view !== 'trash' |
|
| 29 | - ? $this->_admin_page->get_attendees($this->_per_page) |
|
| 30 | - : $this->_admin_page->get_attendees($this->_per_page, false, true); |
|
| 31 | - |
|
| 32 | - $this->_all_data_count = $this->_view !== 'trash' |
|
| 33 | - ? $this->_admin_page->get_attendees($this->_per_page, true) |
|
| 34 | - : $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Initial setup of properties. |
|
| 40 | - */ |
|
| 41 | - protected function _set_properties() |
|
| 42 | - { |
|
| 43 | - $this->_wp_list_args = [ |
|
| 44 | - 'singular' => esc_html__('attendee', 'event_espresso'), |
|
| 45 | - 'plural' => esc_html__('attendees', 'event_espresso'), |
|
| 46 | - 'ajax' => true, |
|
| 47 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 48 | - ]; |
|
| 49 | - |
|
| 50 | - $this->_columns = [ |
|
| 51 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 52 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 53 | - 'ATT_fname' => esc_html__('First Name', 'event_espresso'), |
|
| 54 | - 'ATT_lname' => esc_html__('Last Name', 'event_espresso'), |
|
| 55 | - 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 56 | - 'Registration_Count' => esc_html__('# Registrations', 'event_espresso'), |
|
| 57 | - 'ATT_phone' => esc_html__('Phone', 'event_espresso'), |
|
| 58 | - 'ATT_address' => esc_html__('Address', 'event_espresso'), |
|
| 59 | - 'ATT_city' => esc_html__('City', 'event_espresso'), |
|
| 60 | - 'STA_ID' => esc_html__('State/Province', 'event_espresso'), |
|
| 61 | - 'CNT_ISO' => esc_html__('Country', 'event_espresso'), |
|
| 62 | - ]; |
|
| 63 | - |
|
| 64 | - $this->_sortable_columns = [ |
|
| 65 | - 'id' => ['id' => false], |
|
| 66 | - 'ATT_lname' => ['ATT_lname' => true], // true means its already sorted |
|
| 67 | - 'ATT_fname' => ['ATT_fname' => false], |
|
| 68 | - 'ATT_email' => ['ATT_email' => false], |
|
| 69 | - 'Registration_Count' => ['Registration_Count' => false], |
|
| 70 | - 'ATT_city' => ['ATT_city' => false], |
|
| 71 | - 'STA_ID' => ['STA_ID' => false], |
|
| 72 | - 'CNT_ISO' => ['CNT_ISO' => false], |
|
| 73 | - ]; |
|
| 74 | - |
|
| 75 | - $this->_hidden_columns = [ |
|
| 76 | - 'ATT_phone', |
|
| 77 | - 'ATT_address', |
|
| 78 | - 'ATT_city', |
|
| 79 | - 'STA_ID', |
|
| 80 | - 'CNT_ISO', |
|
| 81 | - ]; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Initial setup of filters |
|
| 87 | - * |
|
| 88 | - * @return array |
|
| 89 | - */ |
|
| 90 | - protected function _get_table_filters(): array |
|
| 91 | - { |
|
| 92 | - return []; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Initial setup of counts for views |
|
| 98 | - * |
|
| 99 | - * @throws InvalidArgumentException |
|
| 100 | - * @throws InvalidDataTypeException |
|
| 101 | - * @throws InvalidInterfaceException |
|
| 102 | - * @throws EE_Error |
|
| 103 | - * @throws EE_Error |
|
| 104 | - */ |
|
| 105 | - protected function _add_view_counts() |
|
| 106 | - { |
|
| 107 | - $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true); |
|
| 108 | - if ( |
|
| 109 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 110 | - 'ee_delete_contacts', |
|
| 111 | - 'espresso_registrations_delete_registration' |
|
| 112 | - ) |
|
| 113 | - ) { |
|
| 114 | - $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Get count of attendees. |
|
| 121 | - * |
|
| 122 | - * @return int |
|
| 123 | - * @throws EE_Error |
|
| 124 | - * @throws InvalidArgumentException |
|
| 125 | - * @throws InvalidDataTypeException |
|
| 126 | - * @throws InvalidInterfaceException |
|
| 127 | - * @throws ReflectionException |
|
| 128 | - */ |
|
| 129 | - protected function _get_attendees_count(): int |
|
| 130 | - { |
|
| 131 | - return EEM_Attendee::instance()->count(); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Checkbox column |
|
| 137 | - * |
|
| 138 | - * @param EE_Attendee $item Unable to typehint this method because overrides parent. |
|
| 139 | - * @return string |
|
| 140 | - * @throws EE_Error |
|
| 141 | - * @throws ReflectionException |
|
| 142 | - */ |
|
| 143 | - public function column_cb($item): string |
|
| 144 | - { |
|
| 145 | - if (! $item instanceof EE_Attendee) { |
|
| 146 | - return ''; |
|
| 147 | - } |
|
| 148 | - return sprintf( |
|
| 149 | - '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
| 150 | - $item->ID() |
|
| 151 | - ); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @param EE_Attendee|null $attendee |
|
| 157 | - * @return string |
|
| 158 | - * @throws EE_Error |
|
| 159 | - * @throws ReflectionException |
|
| 160 | - */ |
|
| 161 | - public function column_id(?EE_Attendee $attendee): string |
|
| 162 | - { |
|
| 163 | - $content = $attendee->ID(); |
|
| 164 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 165 | - $content .= ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 166 | - return $this->columnContent('id', $content, 'center'); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * ATT_lname column |
|
| 172 | - * |
|
| 173 | - * @param EE_Attendee $attendee |
|
| 174 | - * @return string |
|
| 175 | - * @throws InvalidArgumentException |
|
| 176 | - * @throws InvalidDataTypeException |
|
| 177 | - * @throws InvalidInterfaceException |
|
| 178 | - * @throws EE_Error |
|
| 179 | - * @throws ReflectionException |
|
| 180 | - */ |
|
| 181 | - public function column_ATT_lname(EE_Attendee $attendee): string |
|
| 182 | - { |
|
| 183 | - // edit attendee link |
|
| 184 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 185 | - [ |
|
| 186 | - 'action' => 'edit_attendee', |
|
| 187 | - 'post' => $attendee->ID(), |
|
| 188 | - ], |
|
| 189 | - REG_ADMIN_URL |
|
| 190 | - ); |
|
| 191 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 192 | - 'ee_edit_contacts', |
|
| 193 | - 'espresso_registrations_edit_attendee' |
|
| 194 | - ) |
|
| 195 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 196 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 197 | - . $attendee->lname() . '</a>' |
|
| 198 | - : $attendee->lname(); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * ATT_fname column |
|
| 204 | - * |
|
| 205 | - * @param EE_Attendee $attendee |
|
| 206 | - * @return string |
|
| 207 | - * @throws InvalidArgumentException |
|
| 208 | - * @throws InvalidDataTypeException |
|
| 209 | - * @throws InvalidInterfaceException |
|
| 210 | - * @throws EE_Error |
|
| 211 | - * @throws ReflectionException |
|
| 212 | - * @throws ReflectionException |
|
| 213 | - * @throws ReflectionException |
|
| 214 | - * @throws ReflectionException |
|
| 215 | - */ |
|
| 216 | - public function column_ATT_fname(EE_Attendee $attendee): string |
|
| 217 | - { |
|
| 218 | - // Build row actions |
|
| 219 | - $actions = []; |
|
| 220 | - // edit attendee link |
|
| 221 | - if ( |
|
| 222 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 223 | - 'ee_edit_contacts', |
|
| 224 | - 'espresso_registrations_edit_attendee' |
|
| 225 | - ) |
|
| 226 | - ) { |
|
| 227 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 228 | - [ |
|
| 229 | - 'action' => 'edit_attendee', |
|
| 230 | - 'post' => $attendee->ID(), |
|
| 231 | - ], |
|
| 232 | - REG_ADMIN_URL |
|
| 233 | - ); |
|
| 234 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
| 235 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 236 | - . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - if ($this->_view === 'in_use') { |
|
| 240 | - // trash attendee link |
|
| 241 | - if ( |
|
| 242 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 243 | - 'ee_delete_contacts', |
|
| 244 | - 'espresso_registrations_trash_attendees' |
|
| 245 | - ) |
|
| 246 | - ) { |
|
| 247 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 248 | - [ |
|
| 249 | - 'action' => 'trash_attendee', |
|
| 250 | - 'ATT_ID' => $attendee->ID(), |
|
| 251 | - ], |
|
| 252 | - REG_ADMIN_URL |
|
| 253 | - ); |
|
| 254 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
| 255 | - . esc_attr__('Move Contact to Trash', 'event_espresso') |
|
| 256 | - . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 257 | - } |
|
| 258 | - } else { |
|
| 259 | - if ( |
|
| 260 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 261 | - 'ee_delete_contacts', |
|
| 262 | - 'espresso_registrations_restore_attendees' |
|
| 263 | - ) |
|
| 264 | - ) { |
|
| 265 | - // restore attendee link |
|
| 266 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 267 | - [ |
|
| 268 | - 'action' => 'restore_attendees', |
|
| 269 | - 'ATT_ID' => $attendee->ID(), |
|
| 270 | - ], |
|
| 271 | - REG_ADMIN_URL |
|
| 272 | - ); |
|
| 273 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
| 274 | - . esc_attr__('Restore Contact', 'event_espresso') . '">' |
|
| 275 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 280 | - [ |
|
| 281 | - 'action' => 'edit_attendee', |
|
| 282 | - 'post' => $attendee->ID(), |
|
| 283 | - ], |
|
| 284 | - REG_ADMIN_URL |
|
| 285 | - ); |
|
| 286 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 287 | - 'ee_edit_contacts', |
|
| 288 | - 'espresso_registrations_edit_attendee' |
|
| 289 | - ) |
|
| 290 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 291 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>' |
|
| 292 | - : $attendee->fname(); |
|
| 293 | - |
|
| 294 | - // Return the name contents |
|
| 295 | - return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * Email Column |
|
| 301 | - * |
|
| 302 | - * @param EE_Attendee $attendee |
|
| 303 | - * @return string |
|
| 304 | - * @throws EE_Error |
|
| 305 | - */ |
|
| 306 | - public function column_ATT_email(EE_Attendee $attendee): string |
|
| 307 | - { |
|
| 308 | - return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>'; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Column displaying count of registrations attached to Attendee. |
|
| 314 | - * |
|
| 315 | - * @param EE_Attendee $attendee |
|
| 316 | - * @return string |
|
| 317 | - * @throws EE_Error |
|
| 318 | - * @throws ReflectionException |
|
| 319 | - */ |
|
| 320 | - public function column_Registration_Count(EE_Attendee $attendee): string |
|
| 321 | - { |
|
| 322 | - $link = EEH_URL::add_query_args_and_nonce( |
|
| 323 | - [ |
|
| 324 | - 'action' => 'default', |
|
| 325 | - 'ATT_ID' => $attendee->ID(), |
|
| 326 | - ], |
|
| 327 | - REG_ADMIN_URL |
|
| 328 | - ); |
|
| 329 | - return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>'; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * ATT_address column |
|
| 335 | - * |
|
| 336 | - * @param EE_Attendee $attendee |
|
| 337 | - * @return string |
|
| 338 | - * @throws EE_Error |
|
| 339 | - */ |
|
| 340 | - public function column_ATT_address(EE_Attendee $attendee): string |
|
| 341 | - { |
|
| 342 | - return $attendee->address(); |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * ATT_city column |
|
| 348 | - * |
|
| 349 | - * @param EE_Attendee $attendee |
|
| 350 | - * @return string |
|
| 351 | - * @throws EE_Error |
|
| 352 | - */ |
|
| 353 | - public function column_ATT_city(EE_Attendee $attendee): string |
|
| 354 | - { |
|
| 355 | - return $attendee->city(); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * State Column |
|
| 361 | - * |
|
| 362 | - * @param EE_Attendee $attendee |
|
| 363 | - * @return string |
|
| 364 | - * @throws EE_Error |
|
| 365 | - * @throws InvalidArgumentException |
|
| 366 | - * @throws InvalidDataTypeException |
|
| 367 | - * @throws InvalidInterfaceException |
|
| 368 | - * @throws ReflectionException |
|
| 369 | - */ |
|
| 370 | - public function column_STA_ID(EE_Attendee $attendee): string |
|
| 371 | - { |
|
| 372 | - $states = EEM_State::instance()->get_all_states(); |
|
| 373 | - $state = isset($states[ $attendee->state_ID() ]) |
|
| 374 | - ? $states[ $attendee->state_ID() ]->get('STA_name') |
|
| 375 | - : $attendee->state_ID(); |
|
| 376 | - return ! is_numeric($state) ? $state : ''; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Country Column |
|
| 382 | - * |
|
| 383 | - * @param EE_Attendee $attendee |
|
| 384 | - * @return string |
|
| 385 | - * @throws EE_Error |
|
| 386 | - * @throws InvalidArgumentException |
|
| 387 | - * @throws InvalidDataTypeException |
|
| 388 | - * @throws InvalidInterfaceException |
|
| 389 | - * @throws ReflectionException |
|
| 390 | - * @throws ReflectionException |
|
| 391 | - */ |
|
| 392 | - public function column_CNT_ISO(EE_Attendee $attendee): string |
|
| 393 | - { |
|
| 394 | - $countries = EEM_Country::instance()->get_all_countries(); |
|
| 395 | - $country = isset($countries[ $attendee->country_ID() ]) |
|
| 396 | - ? $countries[ $attendee->country_ID() ]->get('CNT_name') |
|
| 397 | - : $attendee->country_ID(); |
|
| 398 | - return ! is_numeric($country) ? $country : ''; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * Phone Number column |
|
| 404 | - * |
|
| 405 | - * @param EE_Attendee $attendee |
|
| 406 | - * @return string |
|
| 407 | - * @throws EE_Error |
|
| 408 | - */ |
|
| 409 | - public function column_ATT_phone(EE_Attendee $attendee): string |
|
| 410 | - { |
|
| 411 | - return $attendee->phone(); |
|
| 412 | - } |
|
| 15 | + /** |
|
| 16 | + * @var Registrations_Admin_Page |
|
| 17 | + */ |
|
| 18 | + protected $_admin_page; |
|
| 19 | + |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Initial setup of data (called by parent). |
|
| 23 | + * |
|
| 24 | + * @throws EE_Error |
|
| 25 | + */ |
|
| 26 | + protected function _setup_data() |
|
| 27 | + { |
|
| 28 | + $this->_data = $this->_view !== 'trash' |
|
| 29 | + ? $this->_admin_page->get_attendees($this->_per_page) |
|
| 30 | + : $this->_admin_page->get_attendees($this->_per_page, false, true); |
|
| 31 | + |
|
| 32 | + $this->_all_data_count = $this->_view !== 'trash' |
|
| 33 | + ? $this->_admin_page->get_attendees($this->_per_page, true) |
|
| 34 | + : $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Initial setup of properties. |
|
| 40 | + */ |
|
| 41 | + protected function _set_properties() |
|
| 42 | + { |
|
| 43 | + $this->_wp_list_args = [ |
|
| 44 | + 'singular' => esc_html__('attendee', 'event_espresso'), |
|
| 45 | + 'plural' => esc_html__('attendees', 'event_espresso'), |
|
| 46 | + 'ajax' => true, |
|
| 47 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 48 | + ]; |
|
| 49 | + |
|
| 50 | + $this->_columns = [ |
|
| 51 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 52 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 53 | + 'ATT_fname' => esc_html__('First Name', 'event_espresso'), |
|
| 54 | + 'ATT_lname' => esc_html__('Last Name', 'event_espresso'), |
|
| 55 | + 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 56 | + 'Registration_Count' => esc_html__('# Registrations', 'event_espresso'), |
|
| 57 | + 'ATT_phone' => esc_html__('Phone', 'event_espresso'), |
|
| 58 | + 'ATT_address' => esc_html__('Address', 'event_espresso'), |
|
| 59 | + 'ATT_city' => esc_html__('City', 'event_espresso'), |
|
| 60 | + 'STA_ID' => esc_html__('State/Province', 'event_espresso'), |
|
| 61 | + 'CNT_ISO' => esc_html__('Country', 'event_espresso'), |
|
| 62 | + ]; |
|
| 63 | + |
|
| 64 | + $this->_sortable_columns = [ |
|
| 65 | + 'id' => ['id' => false], |
|
| 66 | + 'ATT_lname' => ['ATT_lname' => true], // true means its already sorted |
|
| 67 | + 'ATT_fname' => ['ATT_fname' => false], |
|
| 68 | + 'ATT_email' => ['ATT_email' => false], |
|
| 69 | + 'Registration_Count' => ['Registration_Count' => false], |
|
| 70 | + 'ATT_city' => ['ATT_city' => false], |
|
| 71 | + 'STA_ID' => ['STA_ID' => false], |
|
| 72 | + 'CNT_ISO' => ['CNT_ISO' => false], |
|
| 73 | + ]; |
|
| 74 | + |
|
| 75 | + $this->_hidden_columns = [ |
|
| 76 | + 'ATT_phone', |
|
| 77 | + 'ATT_address', |
|
| 78 | + 'ATT_city', |
|
| 79 | + 'STA_ID', |
|
| 80 | + 'CNT_ISO', |
|
| 81 | + ]; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Initial setup of filters |
|
| 87 | + * |
|
| 88 | + * @return array |
|
| 89 | + */ |
|
| 90 | + protected function _get_table_filters(): array |
|
| 91 | + { |
|
| 92 | + return []; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Initial setup of counts for views |
|
| 98 | + * |
|
| 99 | + * @throws InvalidArgumentException |
|
| 100 | + * @throws InvalidDataTypeException |
|
| 101 | + * @throws InvalidInterfaceException |
|
| 102 | + * @throws EE_Error |
|
| 103 | + * @throws EE_Error |
|
| 104 | + */ |
|
| 105 | + protected function _add_view_counts() |
|
| 106 | + { |
|
| 107 | + $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true); |
|
| 108 | + if ( |
|
| 109 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 110 | + 'ee_delete_contacts', |
|
| 111 | + 'espresso_registrations_delete_registration' |
|
| 112 | + ) |
|
| 113 | + ) { |
|
| 114 | + $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Get count of attendees. |
|
| 121 | + * |
|
| 122 | + * @return int |
|
| 123 | + * @throws EE_Error |
|
| 124 | + * @throws InvalidArgumentException |
|
| 125 | + * @throws InvalidDataTypeException |
|
| 126 | + * @throws InvalidInterfaceException |
|
| 127 | + * @throws ReflectionException |
|
| 128 | + */ |
|
| 129 | + protected function _get_attendees_count(): int |
|
| 130 | + { |
|
| 131 | + return EEM_Attendee::instance()->count(); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Checkbox column |
|
| 137 | + * |
|
| 138 | + * @param EE_Attendee $item Unable to typehint this method because overrides parent. |
|
| 139 | + * @return string |
|
| 140 | + * @throws EE_Error |
|
| 141 | + * @throws ReflectionException |
|
| 142 | + */ |
|
| 143 | + public function column_cb($item): string |
|
| 144 | + { |
|
| 145 | + if (! $item instanceof EE_Attendee) { |
|
| 146 | + return ''; |
|
| 147 | + } |
|
| 148 | + return sprintf( |
|
| 149 | + '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
| 150 | + $item->ID() |
|
| 151 | + ); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @param EE_Attendee|null $attendee |
|
| 157 | + * @return string |
|
| 158 | + * @throws EE_Error |
|
| 159 | + * @throws ReflectionException |
|
| 160 | + */ |
|
| 161 | + public function column_id(?EE_Attendee $attendee): string |
|
| 162 | + { |
|
| 163 | + $content = $attendee->ID(); |
|
| 164 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 165 | + $content .= ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 166 | + return $this->columnContent('id', $content, 'center'); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * ATT_lname column |
|
| 172 | + * |
|
| 173 | + * @param EE_Attendee $attendee |
|
| 174 | + * @return string |
|
| 175 | + * @throws InvalidArgumentException |
|
| 176 | + * @throws InvalidDataTypeException |
|
| 177 | + * @throws InvalidInterfaceException |
|
| 178 | + * @throws EE_Error |
|
| 179 | + * @throws ReflectionException |
|
| 180 | + */ |
|
| 181 | + public function column_ATT_lname(EE_Attendee $attendee): string |
|
| 182 | + { |
|
| 183 | + // edit attendee link |
|
| 184 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 185 | + [ |
|
| 186 | + 'action' => 'edit_attendee', |
|
| 187 | + 'post' => $attendee->ID(), |
|
| 188 | + ], |
|
| 189 | + REG_ADMIN_URL |
|
| 190 | + ); |
|
| 191 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 192 | + 'ee_edit_contacts', |
|
| 193 | + 'espresso_registrations_edit_attendee' |
|
| 194 | + ) |
|
| 195 | + ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 196 | + . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 197 | + . $attendee->lname() . '</a>' |
|
| 198 | + : $attendee->lname(); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * ATT_fname column |
|
| 204 | + * |
|
| 205 | + * @param EE_Attendee $attendee |
|
| 206 | + * @return string |
|
| 207 | + * @throws InvalidArgumentException |
|
| 208 | + * @throws InvalidDataTypeException |
|
| 209 | + * @throws InvalidInterfaceException |
|
| 210 | + * @throws EE_Error |
|
| 211 | + * @throws ReflectionException |
|
| 212 | + * @throws ReflectionException |
|
| 213 | + * @throws ReflectionException |
|
| 214 | + * @throws ReflectionException |
|
| 215 | + */ |
|
| 216 | + public function column_ATT_fname(EE_Attendee $attendee): string |
|
| 217 | + { |
|
| 218 | + // Build row actions |
|
| 219 | + $actions = []; |
|
| 220 | + // edit attendee link |
|
| 221 | + if ( |
|
| 222 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 223 | + 'ee_edit_contacts', |
|
| 224 | + 'espresso_registrations_edit_attendee' |
|
| 225 | + ) |
|
| 226 | + ) { |
|
| 227 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 228 | + [ |
|
| 229 | + 'action' => 'edit_attendee', |
|
| 230 | + 'post' => $attendee->ID(), |
|
| 231 | + ], |
|
| 232 | + REG_ADMIN_URL |
|
| 233 | + ); |
|
| 234 | + $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
| 235 | + . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 236 | + . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + if ($this->_view === 'in_use') { |
|
| 240 | + // trash attendee link |
|
| 241 | + if ( |
|
| 242 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 243 | + 'ee_delete_contacts', |
|
| 244 | + 'espresso_registrations_trash_attendees' |
|
| 245 | + ) |
|
| 246 | + ) { |
|
| 247 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 248 | + [ |
|
| 249 | + 'action' => 'trash_attendee', |
|
| 250 | + 'ATT_ID' => $attendee->ID(), |
|
| 251 | + ], |
|
| 252 | + REG_ADMIN_URL |
|
| 253 | + ); |
|
| 254 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
| 255 | + . esc_attr__('Move Contact to Trash', 'event_espresso') |
|
| 256 | + . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 257 | + } |
|
| 258 | + } else { |
|
| 259 | + if ( |
|
| 260 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 261 | + 'ee_delete_contacts', |
|
| 262 | + 'espresso_registrations_restore_attendees' |
|
| 263 | + ) |
|
| 264 | + ) { |
|
| 265 | + // restore attendee link |
|
| 266 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 267 | + [ |
|
| 268 | + 'action' => 'restore_attendees', |
|
| 269 | + 'ATT_ID' => $attendee->ID(), |
|
| 270 | + ], |
|
| 271 | + REG_ADMIN_URL |
|
| 272 | + ); |
|
| 273 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
| 274 | + . esc_attr__('Restore Contact', 'event_espresso') . '">' |
|
| 275 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 280 | + [ |
|
| 281 | + 'action' => 'edit_attendee', |
|
| 282 | + 'post' => $attendee->ID(), |
|
| 283 | + ], |
|
| 284 | + REG_ADMIN_URL |
|
| 285 | + ); |
|
| 286 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 287 | + 'ee_edit_contacts', |
|
| 288 | + 'espresso_registrations_edit_attendee' |
|
| 289 | + ) |
|
| 290 | + ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 291 | + . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>' |
|
| 292 | + : $attendee->fname(); |
|
| 293 | + |
|
| 294 | + // Return the name contents |
|
| 295 | + return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * Email Column |
|
| 301 | + * |
|
| 302 | + * @param EE_Attendee $attendee |
|
| 303 | + * @return string |
|
| 304 | + * @throws EE_Error |
|
| 305 | + */ |
|
| 306 | + public function column_ATT_email(EE_Attendee $attendee): string |
|
| 307 | + { |
|
| 308 | + return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>'; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Column displaying count of registrations attached to Attendee. |
|
| 314 | + * |
|
| 315 | + * @param EE_Attendee $attendee |
|
| 316 | + * @return string |
|
| 317 | + * @throws EE_Error |
|
| 318 | + * @throws ReflectionException |
|
| 319 | + */ |
|
| 320 | + public function column_Registration_Count(EE_Attendee $attendee): string |
|
| 321 | + { |
|
| 322 | + $link = EEH_URL::add_query_args_and_nonce( |
|
| 323 | + [ |
|
| 324 | + 'action' => 'default', |
|
| 325 | + 'ATT_ID' => $attendee->ID(), |
|
| 326 | + ], |
|
| 327 | + REG_ADMIN_URL |
|
| 328 | + ); |
|
| 329 | + return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>'; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * ATT_address column |
|
| 335 | + * |
|
| 336 | + * @param EE_Attendee $attendee |
|
| 337 | + * @return string |
|
| 338 | + * @throws EE_Error |
|
| 339 | + */ |
|
| 340 | + public function column_ATT_address(EE_Attendee $attendee): string |
|
| 341 | + { |
|
| 342 | + return $attendee->address(); |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * ATT_city column |
|
| 348 | + * |
|
| 349 | + * @param EE_Attendee $attendee |
|
| 350 | + * @return string |
|
| 351 | + * @throws EE_Error |
|
| 352 | + */ |
|
| 353 | + public function column_ATT_city(EE_Attendee $attendee): string |
|
| 354 | + { |
|
| 355 | + return $attendee->city(); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * State Column |
|
| 361 | + * |
|
| 362 | + * @param EE_Attendee $attendee |
|
| 363 | + * @return string |
|
| 364 | + * @throws EE_Error |
|
| 365 | + * @throws InvalidArgumentException |
|
| 366 | + * @throws InvalidDataTypeException |
|
| 367 | + * @throws InvalidInterfaceException |
|
| 368 | + * @throws ReflectionException |
|
| 369 | + */ |
|
| 370 | + public function column_STA_ID(EE_Attendee $attendee): string |
|
| 371 | + { |
|
| 372 | + $states = EEM_State::instance()->get_all_states(); |
|
| 373 | + $state = isset($states[ $attendee->state_ID() ]) |
|
| 374 | + ? $states[ $attendee->state_ID() ]->get('STA_name') |
|
| 375 | + : $attendee->state_ID(); |
|
| 376 | + return ! is_numeric($state) ? $state : ''; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Country Column |
|
| 382 | + * |
|
| 383 | + * @param EE_Attendee $attendee |
|
| 384 | + * @return string |
|
| 385 | + * @throws EE_Error |
|
| 386 | + * @throws InvalidArgumentException |
|
| 387 | + * @throws InvalidDataTypeException |
|
| 388 | + * @throws InvalidInterfaceException |
|
| 389 | + * @throws ReflectionException |
|
| 390 | + * @throws ReflectionException |
|
| 391 | + */ |
|
| 392 | + public function column_CNT_ISO(EE_Attendee $attendee): string |
|
| 393 | + { |
|
| 394 | + $countries = EEM_Country::instance()->get_all_countries(); |
|
| 395 | + $country = isset($countries[ $attendee->country_ID() ]) |
|
| 396 | + ? $countries[ $attendee->country_ID() ]->get('CNT_name') |
|
| 397 | + : $attendee->country_ID(); |
|
| 398 | + return ! is_numeric($country) ? $country : ''; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * Phone Number column |
|
| 404 | + * |
|
| 405 | + * @param EE_Attendee $attendee |
|
| 406 | + * @return string |
|
| 407 | + * @throws EE_Error |
|
| 408 | + */ |
|
| 409 | + public function column_ATT_phone(EE_Attendee $attendee): string |
|
| 410 | + { |
|
| 411 | + return $attendee->phone(); |
|
| 412 | + } |
|
| 413 | 413 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function column_cb($item): string |
| 144 | 144 | { |
| 145 | - if (! $item instanceof EE_Attendee) { |
|
| 145 | + if ( ! $item instanceof EE_Attendee) { |
|
| 146 | 146 | return ''; |
| 147 | 147 | } |
| 148 | 148 | return sprintf( |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $content = $attendee->ID(); |
| 164 | 164 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
| 165 | - $content .= ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 165 | + $content .= ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
| 166 | 166 | return $this->columnContent('id', $content, 'center'); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | 'ee_edit_contacts', |
| 193 | 193 | 'espresso_registrations_edit_attendee' |
| 194 | 194 | ) |
| 195 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 196 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 197 | - . $attendee->lname() . '</a>' |
|
| 195 | + ? '<a href="'.$edit_lnk_url.'" title="' |
|
| 196 | + . esc_attr__('Edit Contact', 'event_espresso').'">' |
|
| 197 | + . $attendee->lname().'</a>' |
|
| 198 | 198 | : $attendee->lname(); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -224,16 +224,16 @@ discard block |
||
| 224 | 224 | 'espresso_registrations_edit_attendee' |
| 225 | 225 | ) |
| 226 | 226 | ) { |
| 227 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 227 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 228 | 228 | [ |
| 229 | 229 | 'action' => 'edit_attendee', |
| 230 | 230 | 'post' => $attendee->ID(), |
| 231 | 231 | ], |
| 232 | 232 | REG_ADMIN_URL |
| 233 | 233 | ); |
| 234 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
| 235 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 236 | - . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
| 234 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' |
|
| 235 | + . esc_attr__('Edit Contact', 'event_espresso').'">' |
|
| 236 | + . esc_html__('Edit', 'event_espresso').'</a>'; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if ($this->_view === 'in_use') { |
@@ -244,16 +244,16 @@ discard block |
||
| 244 | 244 | 'espresso_registrations_trash_attendees' |
| 245 | 245 | ) |
| 246 | 246 | ) { |
| 247 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 247 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 248 | 248 | [ |
| 249 | 249 | 'action' => 'trash_attendee', |
| 250 | 250 | 'ATT_ID' => $attendee->ID(), |
| 251 | 251 | ], |
| 252 | 252 | REG_ADMIN_URL |
| 253 | 253 | ); |
| 254 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
| 254 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' |
|
| 255 | 255 | . esc_attr__('Move Contact to Trash', 'event_espresso') |
| 256 | - . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 256 | + . '">'.esc_html__('Trash', 'event_espresso').'</a>'; |
|
| 257 | 257 | } |
| 258 | 258 | } else { |
| 259 | 259 | if ( |
@@ -263,16 +263,16 @@ discard block |
||
| 263 | 263 | ) |
| 264 | 264 | ) { |
| 265 | 265 | // restore attendee link |
| 266 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 266 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 267 | 267 | [ |
| 268 | 268 | 'action' => 'restore_attendees', |
| 269 | 269 | 'ATT_ID' => $attendee->ID(), |
| 270 | 270 | ], |
| 271 | 271 | REG_ADMIN_URL |
| 272 | 272 | ); |
| 273 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
| 274 | - . esc_attr__('Restore Contact', 'event_espresso') . '">' |
|
| 275 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 273 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' |
|
| 274 | + . esc_attr__('Restore Contact', 'event_espresso').'">' |
|
| 275 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | ], |
| 284 | 284 | REG_ADMIN_URL |
| 285 | 285 | ); |
| 286 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 286 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 287 | 287 | 'ee_edit_contacts', |
| 288 | 288 | 'espresso_registrations_edit_attendee' |
| 289 | 289 | ) |
| 290 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 291 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>' |
|
| 290 | + ? '<a href="'.$edit_lnk_url.'" title="' |
|
| 291 | + . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>' |
|
| 292 | 292 | : $attendee->fname(); |
| 293 | 293 | |
| 294 | 294 | // Return the name contents |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | public function column_ATT_email(EE_Attendee $attendee): string |
| 307 | 307 | { |
| 308 | - return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>'; |
|
| 308 | + return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>'; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | ], |
| 327 | 327 | REG_ADMIN_URL |
| 328 | 328 | ); |
| 329 | - return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>'; |
|
| 329 | + return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>'; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | public function column_STA_ID(EE_Attendee $attendee): string |
| 371 | 371 | { |
| 372 | 372 | $states = EEM_State::instance()->get_all_states(); |
| 373 | - $state = isset($states[ $attendee->state_ID() ]) |
|
| 374 | - ? $states[ $attendee->state_ID() ]->get('STA_name') |
|
| 373 | + $state = isset($states[$attendee->state_ID()]) |
|
| 374 | + ? $states[$attendee->state_ID()]->get('STA_name') |
|
| 375 | 375 | : $attendee->state_ID(); |
| 376 | 376 | return ! is_numeric($state) ? $state : ''; |
| 377 | 377 | } |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | public function column_CNT_ISO(EE_Attendee $attendee): string |
| 393 | 393 | { |
| 394 | 394 | $countries = EEM_Country::instance()->get_all_countries(); |
| 395 | - $country = isset($countries[ $attendee->country_ID() ]) |
|
| 396 | - ? $countries[ $attendee->country_ID() ]->get('CNT_name') |
|
| 395 | + $country = isset($countries[$attendee->country_ID()]) |
|
| 396 | + ? $countries[$attendee->country_ID()]->get('CNT_name') |
|
| 397 | 397 | : $attendee->country_ID(); |
| 398 | 398 | return ! is_numeric($country) ? $country : ''; |
| 399 | 399 | } |
@@ -17,186 +17,186 @@ |
||
| 17 | 17 | class RegistrationsListTableUserCapabilities |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var EE_Capabilities |
|
| 22 | - */ |
|
| 23 | - protected $capabilities; |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - protected $caps = []; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @param EE_Capabilities $capabilities |
|
| 34 | - */ |
|
| 35 | - public function __construct(EE_Capabilities $capabilities) |
|
| 36 | - { |
|
| 37 | - $this->capabilities = $capabilities; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param string $cap |
|
| 43 | - * @param string $context |
|
| 44 | - * @param int|string $ID |
|
| 45 | - * @return bool |
|
| 46 | - */ |
|
| 47 | - private function hasEntityCap(string $cap, string $context, $ID): bool |
|
| 48 | - { |
|
| 49 | - if (! isset($this->caps[ $cap ][ $context ][ $ID ])) { |
|
| 50 | - $this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID); |
|
| 51 | - } |
|
| 52 | - return $this->caps[ $cap ][ $context ][ $ID ]; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @param string $cap |
|
| 58 | - * @param string $context |
|
| 59 | - * @return bool |
|
| 60 | - */ |
|
| 61 | - private function hasGlobalCap(string $cap, string $context): bool |
|
| 62 | - { |
|
| 63 | - if (! isset($this->caps[ $cap ][ $context ])) { |
|
| 64 | - $this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context); |
|
| 65 | - } |
|
| 66 | - return $this->caps[ $cap ][ $context ]; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @throws EE_Error |
|
| 72 | - * @throws ReflectionException |
|
| 73 | - */ |
|
| 74 | - public function userCanReadRegistration(EE_Registration $registration): bool |
|
| 75 | - { |
|
| 76 | - return $this->hasEntityCap( |
|
| 77 | - 'ee_read_registration', |
|
| 78 | - 'espresso_registrations_view_registration', |
|
| 79 | - $registration->ID() |
|
| 80 | - ); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @throws EE_Error |
|
| 86 | - * @throws ReflectionException |
|
| 87 | - */ |
|
| 88 | - public function userCanEditRegistration(EE_Registration $registration): bool |
|
| 89 | - { |
|
| 90 | - return $this->hasEntityCap( |
|
| 91 | - 'ee_edit_registration', |
|
| 92 | - 'registration_list_table_checkbox_input', |
|
| 93 | - $registration->ID() |
|
| 94 | - ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - public function userCanTrashRegistrations(): bool |
|
| 99 | - { |
|
| 100 | - return $this->hasGlobalCap('ee_delete_registrations', 'espresso_registrations_trash_registrations'); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @throws EE_Error |
|
| 106 | - * @throws ReflectionException |
|
| 107 | - */ |
|
| 108 | - public function userCanTrashRegistration(EE_Registration $registration): bool |
|
| 109 | - { |
|
| 110 | - return $this->hasEntityCap( |
|
| 111 | - 'ee_delete_registration', |
|
| 112 | - 'espresso_registrations_trash_registrations', |
|
| 113 | - $registration->ID() |
|
| 114 | - ); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @throws EE_Error |
|
| 120 | - * @throws ReflectionException |
|
| 121 | - */ |
|
| 122 | - public function userCanDeleteRegistration(EE_Registration $registration): bool |
|
| 123 | - { |
|
| 124 | - return $this->hasEntityCap( |
|
| 125 | - 'ee_delete_registration', |
|
| 126 | - 'espresso_registrations_ee_delete_registrations', |
|
| 127 | - $registration->ID() |
|
| 128 | - ); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @throws EE_Error |
|
| 134 | - * @throws ReflectionException |
|
| 135 | - */ |
|
| 136 | - public function userCanRestoreRegistration(EE_Registration $registration): bool |
|
| 137 | - { |
|
| 138 | - return $this->hasEntityCap( |
|
| 139 | - 'ee_delete_registration', |
|
| 140 | - 'espresso_registrations_restore_registrations', |
|
| 141 | - $registration->ID() |
|
| 142 | - ); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - public function userCanViewTransaction(): bool |
|
| 147 | - { |
|
| 148 | - return $this->hasGlobalCap('ee_read_transaction', 'espresso_transactions_view_transaction'); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - public function userCanReadGlobalMessages(): bool |
|
| 153 | - { |
|
| 154 | - return $this->hasGlobalCap('ee_read_global_messages', 'view_filtered_messages'); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @throws EE_Error |
|
| 160 | - * @throws ReflectionException |
|
| 161 | - */ |
|
| 162 | - public function userCanResendMessage(EE_Registration $registration): bool |
|
| 163 | - { |
|
| 164 | - return $this->hasEntityCap( |
|
| 165 | - 'ee_send_message', |
|
| 166 | - 'espresso_registrations_resend_registration', |
|
| 167 | - $registration->ID() |
|
| 168 | - ); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - public function userCanEditEvent(int $EVT_ID): bool |
|
| 173 | - { |
|
| 174 | - return $this->hasEntityCap('ee_edit_event', 'edit_event', $EVT_ID); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - public function userCanEditContacts(): bool |
|
| 179 | - { |
|
| 180 | - return $this->hasGlobalCap('ee_edit_contacts', 'espresso_registrations_edit_attendee'); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - public function userCanReadRegistrationCheckins(): bool |
|
| 185 | - { |
|
| 186 | - return $this->hasGlobalCap('ee_read_registration', 'espresso_registrations_registration_checkins'); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @throws EE_Error |
|
| 192 | - * @throws ReflectionException |
|
| 193 | - */ |
|
| 194 | - public function userCanReadRegistrationCheckin(EE_Registration $registration): bool |
|
| 195 | - { |
|
| 196 | - return $this->hasEntityCap( |
|
| 197 | - 'ee_read_checkins', |
|
| 198 | - 'espresso_registrations_registration_checkins', |
|
| 199 | - $registration->ID() |
|
| 200 | - ); |
|
| 201 | - } |
|
| 20 | + /** |
|
| 21 | + * @var EE_Capabilities |
|
| 22 | + */ |
|
| 23 | + protected $capabilities; |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + protected $caps = []; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @param EE_Capabilities $capabilities |
|
| 34 | + */ |
|
| 35 | + public function __construct(EE_Capabilities $capabilities) |
|
| 36 | + { |
|
| 37 | + $this->capabilities = $capabilities; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param string $cap |
|
| 43 | + * @param string $context |
|
| 44 | + * @param int|string $ID |
|
| 45 | + * @return bool |
|
| 46 | + */ |
|
| 47 | + private function hasEntityCap(string $cap, string $context, $ID): bool |
|
| 48 | + { |
|
| 49 | + if (! isset($this->caps[ $cap ][ $context ][ $ID ])) { |
|
| 50 | + $this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID); |
|
| 51 | + } |
|
| 52 | + return $this->caps[ $cap ][ $context ][ $ID ]; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @param string $cap |
|
| 58 | + * @param string $context |
|
| 59 | + * @return bool |
|
| 60 | + */ |
|
| 61 | + private function hasGlobalCap(string $cap, string $context): bool |
|
| 62 | + { |
|
| 63 | + if (! isset($this->caps[ $cap ][ $context ])) { |
|
| 64 | + $this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context); |
|
| 65 | + } |
|
| 66 | + return $this->caps[ $cap ][ $context ]; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @throws EE_Error |
|
| 72 | + * @throws ReflectionException |
|
| 73 | + */ |
|
| 74 | + public function userCanReadRegistration(EE_Registration $registration): bool |
|
| 75 | + { |
|
| 76 | + return $this->hasEntityCap( |
|
| 77 | + 'ee_read_registration', |
|
| 78 | + 'espresso_registrations_view_registration', |
|
| 79 | + $registration->ID() |
|
| 80 | + ); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @throws EE_Error |
|
| 86 | + * @throws ReflectionException |
|
| 87 | + */ |
|
| 88 | + public function userCanEditRegistration(EE_Registration $registration): bool |
|
| 89 | + { |
|
| 90 | + return $this->hasEntityCap( |
|
| 91 | + 'ee_edit_registration', |
|
| 92 | + 'registration_list_table_checkbox_input', |
|
| 93 | + $registration->ID() |
|
| 94 | + ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + public function userCanTrashRegistrations(): bool |
|
| 99 | + { |
|
| 100 | + return $this->hasGlobalCap('ee_delete_registrations', 'espresso_registrations_trash_registrations'); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @throws EE_Error |
|
| 106 | + * @throws ReflectionException |
|
| 107 | + */ |
|
| 108 | + public function userCanTrashRegistration(EE_Registration $registration): bool |
|
| 109 | + { |
|
| 110 | + return $this->hasEntityCap( |
|
| 111 | + 'ee_delete_registration', |
|
| 112 | + 'espresso_registrations_trash_registrations', |
|
| 113 | + $registration->ID() |
|
| 114 | + ); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @throws EE_Error |
|
| 120 | + * @throws ReflectionException |
|
| 121 | + */ |
|
| 122 | + public function userCanDeleteRegistration(EE_Registration $registration): bool |
|
| 123 | + { |
|
| 124 | + return $this->hasEntityCap( |
|
| 125 | + 'ee_delete_registration', |
|
| 126 | + 'espresso_registrations_ee_delete_registrations', |
|
| 127 | + $registration->ID() |
|
| 128 | + ); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @throws EE_Error |
|
| 134 | + * @throws ReflectionException |
|
| 135 | + */ |
|
| 136 | + public function userCanRestoreRegistration(EE_Registration $registration): bool |
|
| 137 | + { |
|
| 138 | + return $this->hasEntityCap( |
|
| 139 | + 'ee_delete_registration', |
|
| 140 | + 'espresso_registrations_restore_registrations', |
|
| 141 | + $registration->ID() |
|
| 142 | + ); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + public function userCanViewTransaction(): bool |
|
| 147 | + { |
|
| 148 | + return $this->hasGlobalCap('ee_read_transaction', 'espresso_transactions_view_transaction'); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + public function userCanReadGlobalMessages(): bool |
|
| 153 | + { |
|
| 154 | + return $this->hasGlobalCap('ee_read_global_messages', 'view_filtered_messages'); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @throws EE_Error |
|
| 160 | + * @throws ReflectionException |
|
| 161 | + */ |
|
| 162 | + public function userCanResendMessage(EE_Registration $registration): bool |
|
| 163 | + { |
|
| 164 | + return $this->hasEntityCap( |
|
| 165 | + 'ee_send_message', |
|
| 166 | + 'espresso_registrations_resend_registration', |
|
| 167 | + $registration->ID() |
|
| 168 | + ); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + public function userCanEditEvent(int $EVT_ID): bool |
|
| 173 | + { |
|
| 174 | + return $this->hasEntityCap('ee_edit_event', 'edit_event', $EVT_ID); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + public function userCanEditContacts(): bool |
|
| 179 | + { |
|
| 180 | + return $this->hasGlobalCap('ee_edit_contacts', 'espresso_registrations_edit_attendee'); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + public function userCanReadRegistrationCheckins(): bool |
|
| 185 | + { |
|
| 186 | + return $this->hasGlobalCap('ee_read_registration', 'espresso_registrations_registration_checkins'); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @throws EE_Error |
|
| 192 | + * @throws ReflectionException |
|
| 193 | + */ |
|
| 194 | + public function userCanReadRegistrationCheckin(EE_Registration $registration): bool |
|
| 195 | + { |
|
| 196 | + return $this->hasEntityCap( |
|
| 197 | + 'ee_read_checkins', |
|
| 198 | + 'espresso_registrations_registration_checkins', |
|
| 199 | + $registration->ID() |
|
| 200 | + ); |
|
| 201 | + } |
|
| 202 | 202 | } |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | private function hasEntityCap(string $cap, string $context, $ID): bool |
| 48 | 48 | { |
| 49 | - if (! isset($this->caps[ $cap ][ $context ][ $ID ])) { |
|
| 50 | - $this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID); |
|
| 49 | + if ( ! isset($this->caps[$cap][$context][$ID])) { |
|
| 50 | + $this->caps[$cap][$context][$ID] = $this->capabilities->current_user_can($cap, $context, $ID); |
|
| 51 | 51 | } |
| 52 | - return $this->caps[ $cap ][ $context ][ $ID ]; |
|
| 52 | + return $this->caps[$cap][$context][$ID]; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | private function hasGlobalCap(string $cap, string $context): bool |
| 62 | 62 | { |
| 63 | - if (! isset($this->caps[ $cap ][ $context ])) { |
|
| 64 | - $this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context); |
|
| 63 | + if ( ! isset($this->caps[$cap][$context])) { |
|
| 64 | + $this->caps[$cap][$context] = $this->capabilities->current_user_can($cap, $context); |
|
| 65 | 65 | } |
| 66 | - return $this->caps[ $cap ][ $context ]; |
|
| 66 | + return $this->caps[$cap][$context]; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
@@ -13,219 +13,219 @@ |
||
| 13 | 13 | { |
| 14 | 14 | |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays |
|
| 18 | - * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects |
|
| 19 | - * |
|
| 20 | - * @uses array_udiff core php function for setting up our own array comparison |
|
| 21 | - * @uses self::_compare_objects as the custom method for array_udiff |
|
| 22 | - * @param array $array1 an array of objects |
|
| 23 | - * @param array $array2 an array of objects |
|
| 24 | - * @return array an array of objects found in array 1 that aren't found in array 2. |
|
| 25 | - */ |
|
| 26 | - public static function object_array_diff($array1, $array2) |
|
| 27 | - { |
|
| 28 | - return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed |
|
| 33 | - * |
|
| 34 | - * @param array $array |
|
| 35 | - * @return boolean |
|
| 36 | - */ |
|
| 37 | - public static function is_associative_array(array $array): bool |
|
| 38 | - { |
|
| 39 | - return ! empty($array) && array_keys($array) !== range(0, count($array) - 1); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Gets an item from the array and leave the array intact. Use in place of end() |
|
| 44 | - * when you don't want to change the array |
|
| 45 | - * |
|
| 46 | - * @param array $arr |
|
| 47 | - * @return mixed what ever is in the array |
|
| 48 | - */ |
|
| 49 | - public static function get_one_item_from_array($arr) |
|
| 50 | - { |
|
| 51 | - $item = end($arr); |
|
| 52 | - reset($arr); |
|
| 53 | - return $item; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Detects if this is a multi-dimensional array |
|
| 58 | - * meaning that at least one top-level value is an array. Eg [ [], ...] |
|
| 59 | - * |
|
| 60 | - * @param mixed $arr |
|
| 61 | - * @return boolean |
|
| 62 | - */ |
|
| 63 | - public static function is_multi_dimensional_array($arr) |
|
| 64 | - { |
|
| 65 | - if (is_array($arr)) { |
|
| 66 | - foreach ($arr as $item) { |
|
| 67 | - if (is_array($item)) { |
|
| 68 | - return true; // yep, there's at least 2 levels to this array |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - return false; // there's only 1 level, or it's not an array at all! |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default |
|
| 77 | - * |
|
| 78 | - * @param array $arr |
|
| 79 | - * @param mixed $index |
|
| 80 | - * @param mixed $default |
|
| 81 | - * @return mixed |
|
| 82 | - */ |
|
| 83 | - public static function is_set($arr, $index, $default) |
|
| 84 | - { |
|
| 85 | - return isset($arr[ $index ]) ? $arr[ $index ] : $default; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118 |
|
| 90 | - * |
|
| 91 | - * @param mixed $value usually a string, but could be an array or object |
|
| 92 | - * @return mixed the UN-serialized data |
|
| 93 | - */ |
|
| 94 | - public static function maybe_unserialize($value) |
|
| 95 | - { |
|
| 96 | - $data = maybe_unserialize($value); |
|
| 97 | - // it's possible that this still has serialized data if it's the session. |
|
| 98 | - // WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesn't unserialize this automatically. |
|
| 99 | - $token = 'C'; |
|
| 100 | - $data = is_string($data) ? trim($data) : $data; |
|
| 101 | - if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) { |
|
| 102 | - return unserialize($data); |
|
| 103 | - } else { |
|
| 104 | - return $data; |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * insert_into_array |
|
| 111 | - * |
|
| 112 | - * @param array $target_array the array to insert new data into |
|
| 113 | - * @param array $array_to_insert the new data to be inserted |
|
| 114 | - * @param int|string|null $offset a known key within $target_array where new data will be inserted |
|
| 115 | - * @param bool $add_before whether to add new data before or after the offset key |
|
| 116 | - * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
|
| 117 | - * @return array |
|
| 118 | - */ |
|
| 119 | - public static function insert_into_array( |
|
| 120 | - array $target_array = array(), |
|
| 121 | - array $array_to_insert = array(), |
|
| 122 | - $offset = null, |
|
| 123 | - bool $add_before = true, |
|
| 124 | - bool $preserve_keys = true |
|
| 125 | - ) { |
|
| 126 | - $target_array_keys = array_keys($target_array); |
|
| 127 | - // if no offset key was supplied |
|
| 128 | - if (empty($offset)) { |
|
| 129 | - // use start or end of $target_array based on whether we are adding before or not |
|
| 130 | - $offset = $add_before ? 0 : count($target_array); |
|
| 131 | - } |
|
| 132 | - // if offset key is a string, then find the corresponding numeric location for that element |
|
| 133 | - $offset = is_int($offset) ? $offset : array_search($offset, $target_array_keys, true); |
|
| 134 | - // add one to the offset if adding after |
|
| 135 | - $offset = $add_before ? $offset : $offset + 1; |
|
| 136 | - // but ensure offset does not exceed the length of the array |
|
| 137 | - $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
| 138 | - // reindex array ??? |
|
| 139 | - if ($preserve_keys) { |
|
| 140 | - // take a slice of the target array from the beginning till the offset, |
|
| 141 | - // then add the new data |
|
| 142 | - // then add another slice that starts at the offset and goes till the end |
|
| 143 | - return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice( |
|
| 144 | - $target_array, |
|
| 145 | - $offset, |
|
| 146 | - null, |
|
| 147 | - true |
|
| 148 | - ); |
|
| 149 | - } else { |
|
| 150 | - // since we don't want to preserve keys, we can use array_splice |
|
| 151 | - array_splice($target_array, $offset, 0, $array_to_insert); |
|
| 152 | - return $target_array; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * array_merge() is slow and should never be used while looping over data |
|
| 159 | - * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster |
|
| 160 | - * so really this acts more like array_replace( $array1, $array2 ) |
|
| 161 | - * or a union with the arrays flipped ( $array2 + $array1 ) |
|
| 162 | - * this saves a few lines of code and improves readability |
|
| 163 | - * |
|
| 164 | - * @param array $array1 |
|
| 165 | - * @param array $array2 |
|
| 166 | - * @return array |
|
| 167 | - */ |
|
| 168 | - public static function merge_arrays_and_overwrite_keys(array $array1, array $array2) |
|
| 169 | - { |
|
| 170 | - foreach ($array2 as $key => $value) { |
|
| 171 | - $array1[ $key ] = $value; |
|
| 172 | - } |
|
| 173 | - return $array1; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * given a flat array like $array = array('A', 'B', 'C') |
|
| 179 | - * will convert into a multidimensional array like $array[A][B][C] |
|
| 180 | - * if $final_value is provided and is anything other than null, |
|
| 181 | - * then that will be set as the value for the innermost array key |
|
| 182 | - * like so: $array[A][B][C] = $final_value |
|
| 183 | - * |
|
| 184 | - * @param array $flat_array |
|
| 185 | - * @param mixed $final_value |
|
| 186 | - * @return array |
|
| 187 | - */ |
|
| 188 | - public static function convert_array_values_to_keys(array $flat_array, $final_value = null) |
|
| 189 | - { |
|
| 190 | - $multidimensional = array(); |
|
| 191 | - $reference = &$multidimensional; |
|
| 192 | - foreach ($flat_array as $key) { |
|
| 193 | - $reference[ $key ] = array(); |
|
| 194 | - $reference = &$reference[ $key ]; |
|
| 195 | - } |
|
| 196 | - if ($final_value !== null) { |
|
| 197 | - $reference = $final_value; |
|
| 198 | - } |
|
| 199 | - return $multidimensional; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential |
|
| 205 | - * @param array $array |
|
| 206 | - * @return bool |
|
| 207 | - */ |
|
| 208 | - public static function is_array_numerically_and_sequentially_indexed(array $array) |
|
| 209 | - { |
|
| 210 | - return empty($array) || array_keys($array) === range(0, count($array) - 1); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * recursively walks through an array and adds slashes to all no array elements |
|
| 216 | - * |
|
| 217 | - * @param mixed $element |
|
| 218 | - * @return array|string |
|
| 219 | - * @since $VID:$ |
|
| 220 | - */ |
|
| 221 | - public static function addSlashesRecursively($element) |
|
| 222 | - { |
|
| 223 | - if (is_array($element)) { |
|
| 224 | - foreach ($element as $key => $value) { |
|
| 225 | - $element[ $key ] = EEH_Array::addSlashesRecursively($value); |
|
| 226 | - } |
|
| 227 | - return $element; |
|
| 228 | - } |
|
| 229 | - return is_string($element) ? addslashes($element) : $element; |
|
| 230 | - } |
|
| 16 | + /** |
|
| 17 | + * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays |
|
| 18 | + * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects |
|
| 19 | + * |
|
| 20 | + * @uses array_udiff core php function for setting up our own array comparison |
|
| 21 | + * @uses self::_compare_objects as the custom method for array_udiff |
|
| 22 | + * @param array $array1 an array of objects |
|
| 23 | + * @param array $array2 an array of objects |
|
| 24 | + * @return array an array of objects found in array 1 that aren't found in array 2. |
|
| 25 | + */ |
|
| 26 | + public static function object_array_diff($array1, $array2) |
|
| 27 | + { |
|
| 28 | + return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed |
|
| 33 | + * |
|
| 34 | + * @param array $array |
|
| 35 | + * @return boolean |
|
| 36 | + */ |
|
| 37 | + public static function is_associative_array(array $array): bool |
|
| 38 | + { |
|
| 39 | + return ! empty($array) && array_keys($array) !== range(0, count($array) - 1); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Gets an item from the array and leave the array intact. Use in place of end() |
|
| 44 | + * when you don't want to change the array |
|
| 45 | + * |
|
| 46 | + * @param array $arr |
|
| 47 | + * @return mixed what ever is in the array |
|
| 48 | + */ |
|
| 49 | + public static function get_one_item_from_array($arr) |
|
| 50 | + { |
|
| 51 | + $item = end($arr); |
|
| 52 | + reset($arr); |
|
| 53 | + return $item; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Detects if this is a multi-dimensional array |
|
| 58 | + * meaning that at least one top-level value is an array. Eg [ [], ...] |
|
| 59 | + * |
|
| 60 | + * @param mixed $arr |
|
| 61 | + * @return boolean |
|
| 62 | + */ |
|
| 63 | + public static function is_multi_dimensional_array($arr) |
|
| 64 | + { |
|
| 65 | + if (is_array($arr)) { |
|
| 66 | + foreach ($arr as $item) { |
|
| 67 | + if (is_array($item)) { |
|
| 68 | + return true; // yep, there's at least 2 levels to this array |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + return false; // there's only 1 level, or it's not an array at all! |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default |
|
| 77 | + * |
|
| 78 | + * @param array $arr |
|
| 79 | + * @param mixed $index |
|
| 80 | + * @param mixed $default |
|
| 81 | + * @return mixed |
|
| 82 | + */ |
|
| 83 | + public static function is_set($arr, $index, $default) |
|
| 84 | + { |
|
| 85 | + return isset($arr[ $index ]) ? $arr[ $index ] : $default; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118 |
|
| 90 | + * |
|
| 91 | + * @param mixed $value usually a string, but could be an array or object |
|
| 92 | + * @return mixed the UN-serialized data |
|
| 93 | + */ |
|
| 94 | + public static function maybe_unserialize($value) |
|
| 95 | + { |
|
| 96 | + $data = maybe_unserialize($value); |
|
| 97 | + // it's possible that this still has serialized data if it's the session. |
|
| 98 | + // WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesn't unserialize this automatically. |
|
| 99 | + $token = 'C'; |
|
| 100 | + $data = is_string($data) ? trim($data) : $data; |
|
| 101 | + if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) { |
|
| 102 | + return unserialize($data); |
|
| 103 | + } else { |
|
| 104 | + return $data; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * insert_into_array |
|
| 111 | + * |
|
| 112 | + * @param array $target_array the array to insert new data into |
|
| 113 | + * @param array $array_to_insert the new data to be inserted |
|
| 114 | + * @param int|string|null $offset a known key within $target_array where new data will be inserted |
|
| 115 | + * @param bool $add_before whether to add new data before or after the offset key |
|
| 116 | + * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
|
| 117 | + * @return array |
|
| 118 | + */ |
|
| 119 | + public static function insert_into_array( |
|
| 120 | + array $target_array = array(), |
|
| 121 | + array $array_to_insert = array(), |
|
| 122 | + $offset = null, |
|
| 123 | + bool $add_before = true, |
|
| 124 | + bool $preserve_keys = true |
|
| 125 | + ) { |
|
| 126 | + $target_array_keys = array_keys($target_array); |
|
| 127 | + // if no offset key was supplied |
|
| 128 | + if (empty($offset)) { |
|
| 129 | + // use start or end of $target_array based on whether we are adding before or not |
|
| 130 | + $offset = $add_before ? 0 : count($target_array); |
|
| 131 | + } |
|
| 132 | + // if offset key is a string, then find the corresponding numeric location for that element |
|
| 133 | + $offset = is_int($offset) ? $offset : array_search($offset, $target_array_keys, true); |
|
| 134 | + // add one to the offset if adding after |
|
| 135 | + $offset = $add_before ? $offset : $offset + 1; |
|
| 136 | + // but ensure offset does not exceed the length of the array |
|
| 137 | + $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
| 138 | + // reindex array ??? |
|
| 139 | + if ($preserve_keys) { |
|
| 140 | + // take a slice of the target array from the beginning till the offset, |
|
| 141 | + // then add the new data |
|
| 142 | + // then add another slice that starts at the offset and goes till the end |
|
| 143 | + return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice( |
|
| 144 | + $target_array, |
|
| 145 | + $offset, |
|
| 146 | + null, |
|
| 147 | + true |
|
| 148 | + ); |
|
| 149 | + } else { |
|
| 150 | + // since we don't want to preserve keys, we can use array_splice |
|
| 151 | + array_splice($target_array, $offset, 0, $array_to_insert); |
|
| 152 | + return $target_array; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * array_merge() is slow and should never be used while looping over data |
|
| 159 | + * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster |
|
| 160 | + * so really this acts more like array_replace( $array1, $array2 ) |
|
| 161 | + * or a union with the arrays flipped ( $array2 + $array1 ) |
|
| 162 | + * this saves a few lines of code and improves readability |
|
| 163 | + * |
|
| 164 | + * @param array $array1 |
|
| 165 | + * @param array $array2 |
|
| 166 | + * @return array |
|
| 167 | + */ |
|
| 168 | + public static function merge_arrays_and_overwrite_keys(array $array1, array $array2) |
|
| 169 | + { |
|
| 170 | + foreach ($array2 as $key => $value) { |
|
| 171 | + $array1[ $key ] = $value; |
|
| 172 | + } |
|
| 173 | + return $array1; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * given a flat array like $array = array('A', 'B', 'C') |
|
| 179 | + * will convert into a multidimensional array like $array[A][B][C] |
|
| 180 | + * if $final_value is provided and is anything other than null, |
|
| 181 | + * then that will be set as the value for the innermost array key |
|
| 182 | + * like so: $array[A][B][C] = $final_value |
|
| 183 | + * |
|
| 184 | + * @param array $flat_array |
|
| 185 | + * @param mixed $final_value |
|
| 186 | + * @return array |
|
| 187 | + */ |
|
| 188 | + public static function convert_array_values_to_keys(array $flat_array, $final_value = null) |
|
| 189 | + { |
|
| 190 | + $multidimensional = array(); |
|
| 191 | + $reference = &$multidimensional; |
|
| 192 | + foreach ($flat_array as $key) { |
|
| 193 | + $reference[ $key ] = array(); |
|
| 194 | + $reference = &$reference[ $key ]; |
|
| 195 | + } |
|
| 196 | + if ($final_value !== null) { |
|
| 197 | + $reference = $final_value; |
|
| 198 | + } |
|
| 199 | + return $multidimensional; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential |
|
| 205 | + * @param array $array |
|
| 206 | + * @return bool |
|
| 207 | + */ |
|
| 208 | + public static function is_array_numerically_and_sequentially_indexed(array $array) |
|
| 209 | + { |
|
| 210 | + return empty($array) || array_keys($array) === range(0, count($array) - 1); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * recursively walks through an array and adds slashes to all no array elements |
|
| 216 | + * |
|
| 217 | + * @param mixed $element |
|
| 218 | + * @return array|string |
|
| 219 | + * @since $VID:$ |
|
| 220 | + */ |
|
| 221 | + public static function addSlashesRecursively($element) |
|
| 222 | + { |
|
| 223 | + if (is_array($element)) { |
|
| 224 | + foreach ($element as $key => $value) { |
|
| 225 | + $element[ $key ] = EEH_Array::addSlashesRecursively($value); |
|
| 226 | + } |
|
| 227 | + return $element; |
|
| 228 | + } |
|
| 229 | + return is_string($element) ? addslashes($element) : $element; |
|
| 230 | + } |
|
| 231 | 231 | } |
@@ -23,19 +23,19 @@ |
||
| 23 | 23 | <div id="post-body" class="metabox-holder columns-2"> |
| 24 | 24 | |
| 25 | 25 | <?php |
| 26 | - if (! empty($post_body_content)) : |
|
| 27 | - if ($add_page_frame) { |
|
| 28 | - if ( |
|
| 29 | - strpos($post_body_content, 'class="padding"') === false |
|
| 30 | - || strpos($post_body_content, 'class="padding"') < 120 |
|
| 31 | - ) { |
|
| 32 | - $post_body_content = '<div class="padding">' . $post_body_content . '</div>'; |
|
| 33 | - } |
|
| 34 | - if (strpos($post_body_content, '<div class="ee-admin-container">') === false) { |
|
| 35 | - $post_body_content = '<div class="ee-admin-container">' . $post_body_content . '</div>'; |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - ?> |
|
| 26 | + if (! empty($post_body_content)) : |
|
| 27 | + if ($add_page_frame) { |
|
| 28 | + if ( |
|
| 29 | + strpos($post_body_content, 'class="padding"') === false |
|
| 30 | + || strpos($post_body_content, 'class="padding"') < 120 |
|
| 31 | + ) { |
|
| 32 | + $post_body_content = '<div class="padding">' . $post_body_content . '</div>'; |
|
| 33 | + } |
|
| 34 | + if (strpos($post_body_content, '<div class="ee-admin-container">') === false) { |
|
| 35 | + $post_body_content = '<div class="ee-admin-container">' . $post_body_content . '</div>'; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + ?> |
|
| 39 | 39 | <div id="post-body-content"> |
| 40 | 40 | <?php echo $post_body_content; // already escaped ?> |
| 41 | 41 | </div> |
@@ -13,26 +13,26 @@ |
||
| 13 | 13 | do_action('add_meta_boxes', (string) $post_type, $post); |
| 14 | 14 | ?> |
| 15 | 15 | |
| 16 | -<?php if (! empty($admin_page_header)) : ?> |
|
| 16 | +<?php if ( ! empty($admin_page_header)) : ?> |
|
| 17 | 17 | <div id="admin-page-header"> |
| 18 | 18 | <?php echo $admin_page_header; // already escaped ?> |
| 19 | 19 | </div> |
| 20 | 20 | <?php endif; ?> |
| 21 | -<div id="<?php echo esc_attr($admin_page_wrapper_div_id);?>" class="<?php echo esc_attr($admin_page_wrapper_div_class);?>"> |
|
| 21 | +<div id="<?php echo esc_attr($admin_page_wrapper_div_id); ?>" class="<?php echo esc_attr($admin_page_wrapper_div_class); ?>"> |
|
| 22 | 22 | <!-- admin-page-header --> |
| 23 | 23 | <div id="post-body" class="metabox-holder columns-2"> |
| 24 | 24 | |
| 25 | 25 | <?php |
| 26 | - if (! empty($post_body_content)) : |
|
| 26 | + if ( ! empty($post_body_content)) : |
|
| 27 | 27 | if ($add_page_frame) { |
| 28 | 28 | if ( |
| 29 | 29 | strpos($post_body_content, 'class="padding"') === false |
| 30 | 30 | || strpos($post_body_content, 'class="padding"') < 120 |
| 31 | 31 | ) { |
| 32 | - $post_body_content = '<div class="padding">' . $post_body_content . '</div>'; |
|
| 32 | + $post_body_content = '<div class="padding">'.$post_body_content.'</div>'; |
|
| 33 | 33 | } |
| 34 | 34 | if (strpos($post_body_content, '<div class="ee-admin-container">') === false) { |
| 35 | - $post_body_content = '<div class="ee-admin-container">' . $post_body_content . '</div>'; |
|
| 35 | + $post_body_content = '<div class="ee-admin-container">'.$post_body_content.'</div>'; |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | ?> |