@@ -13,274 +13,274 @@ |
||
13 | 13 | */ |
14 | 14 | class Prices_List_Table extends EE_Admin_List_Table |
15 | 15 | { |
16 | - private $_PRT; |
|
17 | - |
|
18 | - /** |
|
19 | - * Array of price types. |
|
20 | - * |
|
21 | - * @var EE_Price_Type[] |
|
22 | - */ |
|
23 | - protected $_price_types = []; |
|
24 | - |
|
25 | - |
|
26 | - public function __construct(EE_Admin_Page $admin_page) |
|
27 | - { |
|
28 | - parent::__construct($admin_page); |
|
29 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
30 | - $this->_PRT = EEM_Price_Type::instance(); |
|
31 | - $this->_price_types = $this->_PRT->get_all_deleted_and_undeleted(); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - protected function _setup_data() |
|
36 | - { |
|
37 | - $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
38 | - $this->_data = $this->_admin_page->get_prices_overview_data($this->_per_page, false, $trashed); |
|
39 | - $this->_all_data_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, false); |
|
40 | - $this->_trashed_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, true); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - protected function _set_properties() |
|
45 | - { |
|
46 | - $this->_wp_list_args = [ |
|
47 | - 'singular' => esc_html__('price', 'event_espresso'), |
|
48 | - 'plural' => esc_html__('prices', 'event_espresso'), |
|
49 | - 'ajax' => true, |
|
50 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
51 | - ]; |
|
52 | - |
|
53 | - $this->_columns = [ |
|
54 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
55 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
56 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
57 | - 'type' => esc_html__('Price Type', 'event_espresso'), |
|
58 | - 'description' => esc_html__('Description', 'event_espresso'), |
|
59 | - 'amount' => esc_html__('Amount', 'event_espresso'), |
|
60 | - ]; |
|
61 | - $this->_primary_column = 'id'; |
|
62 | - |
|
63 | - $this->_sortable_columns = [ |
|
64 | - // true means its already sorted |
|
65 | - 'name' => ['name' => false], |
|
66 | - 'type' => ['type' => false], |
|
67 | - 'amount' => ['amount' => false], |
|
68 | - ]; |
|
69 | - |
|
70 | - $this->_hidden_columns = []; |
|
71 | - |
|
72 | - $this->_ajax_sorting_callback = 'update_prices_order'; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - protected function _get_table_filters() |
|
77 | - { |
|
78 | - return []; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - protected function _add_view_counts() |
|
83 | - { |
|
84 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
85 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
86 | - $this->_views['trashed']['count'] = $this->_trashed_count; |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * overriding parent method so that we can make sure the row isn't sortable for certain items |
|
93 | - * |
|
94 | - * @param object $item the current item |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - protected function _get_row_class($item) |
|
98 | - { |
|
99 | - return $item->type_obj() instanceof EE_Price_Type |
|
100 | - && $item->type_obj()->base_type() !== 1 |
|
101 | - && $item->type_obj()->base_type() !== 4 |
|
102 | - ? ' class="rowsortable"' |
|
103 | - : ''; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param EE_Price $price |
|
109 | - * @param string $action |
|
110 | - * @return string |
|
111 | - * @throws EE_Error |
|
112 | - * @throws ReflectionException |
|
113 | - * @since $VID:$ |
|
114 | - */ |
|
115 | - protected function getActionUrl(EE_Price $price, string $action): string |
|
116 | - { |
|
117 | - if (! in_array($action, self::$actions)) { |
|
118 | - throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
119 | - } |
|
120 | - return EE_Admin_Page::add_query_args_and_nonce( |
|
121 | - [ |
|
122 | - 'action' => "{$action}_price", |
|
123 | - 'id' => $price->ID(), |
|
124 | - 'noheader' => $action !== self::ACTION_EDIT, |
|
125 | - ], |
|
126 | - PRICING_ADMIN_URL |
|
127 | - ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - public function column_cb($item) |
|
132 | - { |
|
133 | - return $item->type_obj() instanceof EE_Price_Type && $item->type_obj()->base_type() !== 1 |
|
134 | - ? sprintf( |
|
135 | - '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
136 | - $item->ID() |
|
137 | - ) |
|
138 | - : ''; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param EE_Price $item |
|
144 | - * @return string |
|
145 | - * @throws EE_Error |
|
146 | - * @throws ReflectionException |
|
147 | - */ |
|
148 | - public function column_id($item) |
|
149 | - { |
|
150 | - $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
151 | - $content .= '<span class="show-on-mobile-view-only">' . $this->column_name($item, false) . '</span>'; |
|
152 | - return $this->columnContent('id', $content, 'end'); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @param EE_Price $price |
|
158 | - * @param bool $prep_content |
|
159 | - * @return string |
|
160 | - * @throws EE_Error |
|
161 | - * @throws ReflectionException |
|
162 | - */ |
|
163 | - public function column_name(EE_Price $price, bool $prep_content = true): string |
|
164 | - { |
|
165 | - |
|
166 | - // Build row actions |
|
167 | - $actions = []; |
|
168 | - // edit price link |
|
169 | - if ( |
|
170 | - EE_Registry::instance()->CAP->current_user_can( |
|
171 | - 'ee_edit_default_price', |
|
172 | - 'pricing_edit_price', |
|
173 | - $price->ID() |
|
174 | - ) |
|
175 | - ) { |
|
176 | - $actions['edit'] = $this->getActionLink( |
|
177 | - $this->getActionUrl($price, self::ACTION_EDIT), |
|
178 | - esc_html__('Edit', 'event_espresso'), |
|
179 | - esc_attr__('Edit Price', 'event_espresso') |
|
180 | - ); |
|
181 | - } |
|
182 | - |
|
183 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
184 | - 'ee_edit_default_price', |
|
185 | - 'edit_price', |
|
186 | - $price->ID() |
|
187 | - ) |
|
188 | - ? $this->getActionLink( |
|
189 | - $this->getActionUrl($price, self::ACTION_EDIT), |
|
190 | - stripslashes($price->name()), |
|
191 | - esc_attr__('Edit Price', 'event_espresso') |
|
192 | - ) |
|
193 | - : $price->name(); |
|
194 | - |
|
195 | - if ($price->type_obj() instanceof EE_Price_Type && $price->type_obj()->base_type() !== 1) { |
|
196 | - if ($this->_view == 'all') { |
|
197 | - // trash price link |
|
198 | - if ( |
|
199 | - EE_Registry::instance()->CAP->current_user_can( |
|
200 | - 'ee_delete_default_price', |
|
201 | - 'pricing_trash_price', |
|
202 | - $price->ID() |
|
203 | - ) |
|
204 | - ) { |
|
205 | - $actions['trash'] = $this->getActionLink( |
|
206 | - $this->getActionUrl($price, self::ACTION_TRASH), |
|
207 | - esc_html__('Trash', 'event_espresso'), |
|
208 | - esc_attr__('Move Price to Trash', 'event_espresso') |
|
209 | - ); |
|
210 | - } |
|
211 | - } else { |
|
212 | - if ( |
|
213 | - EE_Registry::instance()->CAP->current_user_can( |
|
214 | - 'ee_delete_default_price', |
|
215 | - 'pricing_restore_price', |
|
216 | - $price->ID() |
|
217 | - ) |
|
218 | - ) { |
|
219 | - $actions['restore'] = $this->getActionLink( |
|
220 | - $this->getActionUrl($price, self::ACTION_RESTORE), |
|
221 | - esc_html__('Restore', 'event_espresso'), |
|
222 | - esc_attr__('Restore Price', 'event_espresso') |
|
223 | - ); |
|
224 | - } |
|
225 | - |
|
226 | - // delete price link |
|
227 | - if ( |
|
228 | - EE_Registry::instance()->CAP->current_user_can( |
|
229 | - 'ee_delete_default_price', |
|
230 | - 'pricing_delete_price', |
|
231 | - $price->ID() |
|
232 | - ) |
|
233 | - ) { |
|
234 | - $actions['delete'] = $this->getActionLink( |
|
235 | - $this->getActionUrl($price, self::ACTION_DELETE), |
|
236 | - esc_html__('Delete Permanently', 'event_espresso'), |
|
237 | - esc_attr__('Delete Price Permanently', 'event_espresso') |
|
238 | - ); |
|
239 | - } |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - $content = $prep_content ? $name_link . $this->row_actions($actions) : $name_link; |
|
244 | - return $prep_content ? $this->columnContent('name', $content) : $content; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * @throws EE_Error |
|
250 | - * @throws ReflectionException |
|
251 | - */ |
|
252 | - public function column_type(EE_Price $price): string |
|
253 | - { |
|
254 | - $content = isset($this->_price_types[ $price->type() ]) |
|
255 | - ? $this->_price_types[ $price->type() ]->name() |
|
256 | - : ''; |
|
257 | - return $this->columnContent('type', $content); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * @throws EE_Error |
|
263 | - * @throws ReflectionException |
|
264 | - */ |
|
265 | - public function column_description(EE_Price $price): string |
|
266 | - { |
|
267 | - $content = stripslashes($price->desc()); |
|
268 | - return $this->columnContent('description', $content); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * @throws EE_Error |
|
274 | - * @throws ReflectionException |
|
275 | - */ |
|
276 | - public function column_amount(EE_Price $price): string |
|
277 | - { |
|
278 | - $price_type = isset($this->_price_types[ $price->type() ]) |
|
279 | - ? $this->_price_types[ $price->type() ] |
|
280 | - : null; |
|
281 | - $content = $price_type instanceof EE_Price_Type && $price_type->is_percent() ? |
|
282 | - '<div class="pad-amnt-rght">' . number_format($price->amount(), 1) . '%</div>' |
|
283 | - : '<div class="pad-amnt-rght">' . EEH_Template::format_currency($price->amount()) . '</div>'; |
|
284 | - return $this->columnContent('amount', $content, 'end'); |
|
285 | - } |
|
16 | + private $_PRT; |
|
17 | + |
|
18 | + /** |
|
19 | + * Array of price types. |
|
20 | + * |
|
21 | + * @var EE_Price_Type[] |
|
22 | + */ |
|
23 | + protected $_price_types = []; |
|
24 | + |
|
25 | + |
|
26 | + public function __construct(EE_Admin_Page $admin_page) |
|
27 | + { |
|
28 | + parent::__construct($admin_page); |
|
29 | + require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
30 | + $this->_PRT = EEM_Price_Type::instance(); |
|
31 | + $this->_price_types = $this->_PRT->get_all_deleted_and_undeleted(); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + protected function _setup_data() |
|
36 | + { |
|
37 | + $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
38 | + $this->_data = $this->_admin_page->get_prices_overview_data($this->_per_page, false, $trashed); |
|
39 | + $this->_all_data_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, false); |
|
40 | + $this->_trashed_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, true); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + protected function _set_properties() |
|
45 | + { |
|
46 | + $this->_wp_list_args = [ |
|
47 | + 'singular' => esc_html__('price', 'event_espresso'), |
|
48 | + 'plural' => esc_html__('prices', 'event_espresso'), |
|
49 | + 'ajax' => true, |
|
50 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
51 | + ]; |
|
52 | + |
|
53 | + $this->_columns = [ |
|
54 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
55 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
56 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
57 | + 'type' => esc_html__('Price Type', 'event_espresso'), |
|
58 | + 'description' => esc_html__('Description', 'event_espresso'), |
|
59 | + 'amount' => esc_html__('Amount', 'event_espresso'), |
|
60 | + ]; |
|
61 | + $this->_primary_column = 'id'; |
|
62 | + |
|
63 | + $this->_sortable_columns = [ |
|
64 | + // true means its already sorted |
|
65 | + 'name' => ['name' => false], |
|
66 | + 'type' => ['type' => false], |
|
67 | + 'amount' => ['amount' => false], |
|
68 | + ]; |
|
69 | + |
|
70 | + $this->_hidden_columns = []; |
|
71 | + |
|
72 | + $this->_ajax_sorting_callback = 'update_prices_order'; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + protected function _get_table_filters() |
|
77 | + { |
|
78 | + return []; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + protected function _add_view_counts() |
|
83 | + { |
|
84 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
86 | + $this->_views['trashed']['count'] = $this->_trashed_count; |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * overriding parent method so that we can make sure the row isn't sortable for certain items |
|
93 | + * |
|
94 | + * @param object $item the current item |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + protected function _get_row_class($item) |
|
98 | + { |
|
99 | + return $item->type_obj() instanceof EE_Price_Type |
|
100 | + && $item->type_obj()->base_type() !== 1 |
|
101 | + && $item->type_obj()->base_type() !== 4 |
|
102 | + ? ' class="rowsortable"' |
|
103 | + : ''; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param EE_Price $price |
|
109 | + * @param string $action |
|
110 | + * @return string |
|
111 | + * @throws EE_Error |
|
112 | + * @throws ReflectionException |
|
113 | + * @since $VID:$ |
|
114 | + */ |
|
115 | + protected function getActionUrl(EE_Price $price, string $action): string |
|
116 | + { |
|
117 | + if (! in_array($action, self::$actions)) { |
|
118 | + throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
119 | + } |
|
120 | + return EE_Admin_Page::add_query_args_and_nonce( |
|
121 | + [ |
|
122 | + 'action' => "{$action}_price", |
|
123 | + 'id' => $price->ID(), |
|
124 | + 'noheader' => $action !== self::ACTION_EDIT, |
|
125 | + ], |
|
126 | + PRICING_ADMIN_URL |
|
127 | + ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + public function column_cb($item) |
|
132 | + { |
|
133 | + return $item->type_obj() instanceof EE_Price_Type && $item->type_obj()->base_type() !== 1 |
|
134 | + ? sprintf( |
|
135 | + '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
136 | + $item->ID() |
|
137 | + ) |
|
138 | + : ''; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param EE_Price $item |
|
144 | + * @return string |
|
145 | + * @throws EE_Error |
|
146 | + * @throws ReflectionException |
|
147 | + */ |
|
148 | + public function column_id($item) |
|
149 | + { |
|
150 | + $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
151 | + $content .= '<span class="show-on-mobile-view-only">' . $this->column_name($item, false) . '</span>'; |
|
152 | + return $this->columnContent('id', $content, 'end'); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @param EE_Price $price |
|
158 | + * @param bool $prep_content |
|
159 | + * @return string |
|
160 | + * @throws EE_Error |
|
161 | + * @throws ReflectionException |
|
162 | + */ |
|
163 | + public function column_name(EE_Price $price, bool $prep_content = true): string |
|
164 | + { |
|
165 | + |
|
166 | + // Build row actions |
|
167 | + $actions = []; |
|
168 | + // edit price link |
|
169 | + if ( |
|
170 | + EE_Registry::instance()->CAP->current_user_can( |
|
171 | + 'ee_edit_default_price', |
|
172 | + 'pricing_edit_price', |
|
173 | + $price->ID() |
|
174 | + ) |
|
175 | + ) { |
|
176 | + $actions['edit'] = $this->getActionLink( |
|
177 | + $this->getActionUrl($price, self::ACTION_EDIT), |
|
178 | + esc_html__('Edit', 'event_espresso'), |
|
179 | + esc_attr__('Edit Price', 'event_espresso') |
|
180 | + ); |
|
181 | + } |
|
182 | + |
|
183 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
184 | + 'ee_edit_default_price', |
|
185 | + 'edit_price', |
|
186 | + $price->ID() |
|
187 | + ) |
|
188 | + ? $this->getActionLink( |
|
189 | + $this->getActionUrl($price, self::ACTION_EDIT), |
|
190 | + stripslashes($price->name()), |
|
191 | + esc_attr__('Edit Price', 'event_espresso') |
|
192 | + ) |
|
193 | + : $price->name(); |
|
194 | + |
|
195 | + if ($price->type_obj() instanceof EE_Price_Type && $price->type_obj()->base_type() !== 1) { |
|
196 | + if ($this->_view == 'all') { |
|
197 | + // trash price link |
|
198 | + if ( |
|
199 | + EE_Registry::instance()->CAP->current_user_can( |
|
200 | + 'ee_delete_default_price', |
|
201 | + 'pricing_trash_price', |
|
202 | + $price->ID() |
|
203 | + ) |
|
204 | + ) { |
|
205 | + $actions['trash'] = $this->getActionLink( |
|
206 | + $this->getActionUrl($price, self::ACTION_TRASH), |
|
207 | + esc_html__('Trash', 'event_espresso'), |
|
208 | + esc_attr__('Move Price to Trash', 'event_espresso') |
|
209 | + ); |
|
210 | + } |
|
211 | + } else { |
|
212 | + if ( |
|
213 | + EE_Registry::instance()->CAP->current_user_can( |
|
214 | + 'ee_delete_default_price', |
|
215 | + 'pricing_restore_price', |
|
216 | + $price->ID() |
|
217 | + ) |
|
218 | + ) { |
|
219 | + $actions['restore'] = $this->getActionLink( |
|
220 | + $this->getActionUrl($price, self::ACTION_RESTORE), |
|
221 | + esc_html__('Restore', 'event_espresso'), |
|
222 | + esc_attr__('Restore Price', 'event_espresso') |
|
223 | + ); |
|
224 | + } |
|
225 | + |
|
226 | + // delete price link |
|
227 | + if ( |
|
228 | + EE_Registry::instance()->CAP->current_user_can( |
|
229 | + 'ee_delete_default_price', |
|
230 | + 'pricing_delete_price', |
|
231 | + $price->ID() |
|
232 | + ) |
|
233 | + ) { |
|
234 | + $actions['delete'] = $this->getActionLink( |
|
235 | + $this->getActionUrl($price, self::ACTION_DELETE), |
|
236 | + esc_html__('Delete Permanently', 'event_espresso'), |
|
237 | + esc_attr__('Delete Price Permanently', 'event_espresso') |
|
238 | + ); |
|
239 | + } |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + $content = $prep_content ? $name_link . $this->row_actions($actions) : $name_link; |
|
244 | + return $prep_content ? $this->columnContent('name', $content) : $content; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * @throws EE_Error |
|
250 | + * @throws ReflectionException |
|
251 | + */ |
|
252 | + public function column_type(EE_Price $price): string |
|
253 | + { |
|
254 | + $content = isset($this->_price_types[ $price->type() ]) |
|
255 | + ? $this->_price_types[ $price->type() ]->name() |
|
256 | + : ''; |
|
257 | + return $this->columnContent('type', $content); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * @throws EE_Error |
|
263 | + * @throws ReflectionException |
|
264 | + */ |
|
265 | + public function column_description(EE_Price $price): string |
|
266 | + { |
|
267 | + $content = stripslashes($price->desc()); |
|
268 | + return $this->columnContent('description', $content); |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * @throws EE_Error |
|
274 | + * @throws ReflectionException |
|
275 | + */ |
|
276 | + public function column_amount(EE_Price $price): string |
|
277 | + { |
|
278 | + $price_type = isset($this->_price_types[ $price->type() ]) |
|
279 | + ? $this->_price_types[ $price->type() ] |
|
280 | + : null; |
|
281 | + $content = $price_type instanceof EE_Price_Type && $price_type->is_percent() ? |
|
282 | + '<div class="pad-amnt-rght">' . number_format($price->amount(), 1) . '%</div>' |
|
283 | + : '<div class="pad-amnt-rght">' . EEH_Template::format_currency($price->amount()) . '</div>'; |
|
284 | + return $this->columnContent('amount', $content, 'end'); |
|
285 | + } |
|
286 | 286 | } |
@@ -13,254 +13,254 @@ |
||
13 | 13 | */ |
14 | 14 | class Price_Types_List_Table extends EE_Admin_List_Table |
15 | 15 | { |
16 | - /** |
|
17 | - * @var Pricing_Admin_Page |
|
18 | - */ |
|
19 | - protected $_admin_page; |
|
20 | - |
|
21 | - |
|
22 | - public function __construct($admin_page) |
|
23 | - { |
|
24 | - parent::__construct($admin_page); |
|
25 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
26 | - $this->_PRT = EEM_Price_Type::instance(); |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - protected function _setup_data() |
|
31 | - { |
|
32 | - $trashed = $this->_admin_page->get_view() == 'trashed'; |
|
33 | - $this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed); |
|
34 | - $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true); |
|
35 | - $this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - protected function _set_properties() |
|
40 | - { |
|
41 | - $this->_wp_list_args = [ |
|
42 | - 'singular' => esc_html__('price type', 'event_espresso'), |
|
43 | - 'plural' => esc_html__('price types', 'event_espresso'), |
|
44 | - 'ajax' => true, |
|
45 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
46 | - ]; |
|
47 | - |
|
48 | - $this->_columns = [ |
|
49 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
50 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
51 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
52 | - 'base_type' => esc_html__('Base Type', 'event_espresso'), |
|
53 | - 'percent' => sprintf( |
|
54 | - /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */ |
|
55 | - esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'), |
|
56 | - '', |
|
57 | - '<span class="big-text">', |
|
58 | - '</span>' |
|
59 | - ), |
|
60 | - 'order' => esc_html__('Order of Application', 'event_espresso'), |
|
61 | - ]; |
|
62 | - |
|
63 | - $this->_sortable_columns = [ |
|
64 | - // TRUE means its already sorted |
|
65 | - 'name' => ['name' => false], |
|
66 | - ]; |
|
67 | - |
|
68 | - $this->_hidden_columns = []; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - protected function _get_table_filters() |
|
73 | - { |
|
74 | - return []; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - protected function _add_view_counts() |
|
79 | - { |
|
80 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
81 | - if ( |
|
82 | - EE_Registry::instance()->CAP->current_user_can( |
|
83 | - 'ee_delete_default_price_types', |
|
84 | - 'pricing_trash_price_type' |
|
85 | - ) |
|
86 | - ) { |
|
87 | - $this->_views['trashed']['count'] = $this->_trashed_count; |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @param EE_Price_Type $price_type |
|
94 | - * @param string $action |
|
95 | - * @return string |
|
96 | - * @throws EE_Error |
|
97 | - * @throws ReflectionException |
|
98 | - * @since $VID:$ |
|
99 | - */ |
|
100 | - protected function getActionUrl(EE_Price_Type $price_type, string $action): string |
|
101 | - { |
|
102 | - if (! in_array($action, self::$actions)) { |
|
103 | - throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
104 | - } |
|
105 | - return EE_Admin_Page::add_query_args_and_nonce( |
|
106 | - [ |
|
107 | - 'action' => "{$action}_price_type", |
|
108 | - 'id' => $price_type->ID(), |
|
109 | - 'noheader' => $action !== self::ACTION_EDIT, |
|
110 | - ], |
|
111 | - PRICING_ADMIN_URL |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - public function column_cb($item): string |
|
117 | - { |
|
118 | - if ($item->base_type() !== 1) { |
|
119 | - return sprintf( |
|
120 | - '<input type="checkbox" name="checkbox[%1$s]" />', |
|
121 | - $item->ID() |
|
122 | - ); |
|
123 | - } |
|
124 | - return ''; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @param EE_Price_Type $item |
|
130 | - * @return string |
|
131 | - * @throws EE_Error |
|
132 | - * @throws ReflectionException |
|
133 | - */ |
|
134 | - public function column_id($item): string |
|
135 | - { |
|
136 | - $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
137 | - $content .= '<span class="show-on-mobile-view-only">' . $this->column_name($item, false) . '</span>'; |
|
138 | - return $this->columnContent('id', $content, 'end'); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param EE_Price_Type $price_type |
|
144 | - * @param bool $prep_content |
|
145 | - * @return string |
|
146 | - * @throws EE_Error |
|
147 | - * @throws ReflectionException |
|
148 | - */ |
|
149 | - public function column_name(EE_Price_Type $price_type, bool $prep_content = true): string |
|
150 | - { |
|
151 | - |
|
152 | - // Build row actions |
|
153 | - $actions = []; |
|
154 | - $name_link = $price_type->name(); |
|
155 | - // edit price link |
|
156 | - if ( |
|
157 | - EE_Registry::instance()->CAP->current_user_can( |
|
158 | - 'ee_edit_default_price_type', |
|
159 | - 'pricing_edit_price_type', |
|
160 | - $price_type->ID() |
|
161 | - ) |
|
162 | - ) { |
|
163 | - $name_link = $this->getActionLink( |
|
164 | - $this->getActionUrl($price_type, self::ACTION_EDIT), |
|
165 | - stripslashes($price_type->name()), |
|
166 | - sprintf( |
|
167 | - /* translators: The name of the price type */ |
|
168 | - esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
169 | - $price_type->name() |
|
170 | - ) |
|
171 | - ); |
|
172 | - |
|
173 | - $actions['edit'] = $this->getActionLink( |
|
174 | - $this->getActionUrl($price_type, self::ACTION_EDIT), |
|
175 | - esc_html__('Edit', 'event_espresso'), |
|
176 | - sprintf( |
|
177 | - /* translators: The name of the price type */ |
|
178 | - esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
179 | - $price_type->name() |
|
180 | - ) |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - if ($price_type->base_type() !== 1) { |
|
185 | - if ($this->_view == 'all') { |
|
186 | - // trash price link |
|
187 | - if ( |
|
188 | - EE_Registry::instance()->CAP->current_user_can( |
|
189 | - 'ee_delete_default_price_type', |
|
190 | - 'pricing_trash_price_type', |
|
191 | - $price_type->ID() |
|
192 | - ) |
|
193 | - ) { |
|
194 | - $actions['trash'] = $this->getActionLink( |
|
195 | - $this->getActionUrl($price_type, self::ACTION_TRASH), |
|
196 | - esc_html__('Trash', 'event_espresso'), |
|
197 | - sprintf( |
|
198 | - /* translators: The name of the price type */ |
|
199 | - esc_attr__('Move Price Type %s to Trash', 'event_espresso'), |
|
200 | - $price_type->name() |
|
201 | - ) |
|
202 | - ); |
|
203 | - } |
|
204 | - } else { |
|
205 | - // restore price link |
|
206 | - if ( |
|
207 | - EE_Registry::instance()->CAP->current_user_can( |
|
208 | - 'ee_delete_default_price_type', |
|
209 | - 'pricing_restore_price_type', |
|
210 | - $price_type->ID() |
|
211 | - ) |
|
212 | - ) { |
|
213 | - $actions['restore'] = $this->getActionLink( |
|
214 | - $this->getActionUrl($price_type, self::ACTION_RESTORE), |
|
215 | - esc_html__('Restore', 'event_espresso'), |
|
216 | - sprintf( |
|
217 | - /* translators: The name of the price type */ |
|
218 | - esc_attr__('Restore Price Type (%s)', 'event_espresso'), |
|
219 | - $price_type->name() |
|
220 | - ) |
|
221 | - ); |
|
222 | - } |
|
223 | - // delete price link |
|
224 | - if ( |
|
225 | - EE_Registry::instance()->CAP->current_user_can( |
|
226 | - 'ee_delete_default_price_type', |
|
227 | - 'pricing_delete_price_type', |
|
228 | - $price_type->ID() |
|
229 | - ) |
|
230 | - ) { |
|
231 | - $actions['delete'] = $this->getActionLink( |
|
232 | - $this->getActionUrl($price_type, self::ACTION_DELETE), |
|
233 | - esc_html__('Delete Permanently', 'event_espresso'), |
|
234 | - sprintf( |
|
235 | - /* translators: The name of the price type */ |
|
236 | - esc_attr__('Delete Price Type %s Permanently', 'event_espresso'), |
|
237 | - $price_type->name() |
|
238 | - ) |
|
239 | - ); |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - $content = $prep_content ? $name_link . $this->row_actions($actions) : $name_link; |
|
245 | - return $prep_content ? $this->columnContent('name', $content) : $content; |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - public function column_base_type($price_type): string |
|
250 | - { |
|
251 | - return $this->columnContent('base_type', $price_type->base_type_name()); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - public function column_percent($price_type): string |
|
256 | - { |
|
257 | - $content = $price_type->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign; |
|
258 | - return $this->columnContent('percent', $content, 'center'); |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - public function column_order($price_type): string |
|
263 | - { |
|
264 | - return $this->columnContent('order', $price_type->order(), 'end'); |
|
265 | - } |
|
16 | + /** |
|
17 | + * @var Pricing_Admin_Page |
|
18 | + */ |
|
19 | + protected $_admin_page; |
|
20 | + |
|
21 | + |
|
22 | + public function __construct($admin_page) |
|
23 | + { |
|
24 | + parent::__construct($admin_page); |
|
25 | + require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
26 | + $this->_PRT = EEM_Price_Type::instance(); |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + protected function _setup_data() |
|
31 | + { |
|
32 | + $trashed = $this->_admin_page->get_view() == 'trashed'; |
|
33 | + $this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed); |
|
34 | + $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true); |
|
35 | + $this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + protected function _set_properties() |
|
40 | + { |
|
41 | + $this->_wp_list_args = [ |
|
42 | + 'singular' => esc_html__('price type', 'event_espresso'), |
|
43 | + 'plural' => esc_html__('price types', 'event_espresso'), |
|
44 | + 'ajax' => true, |
|
45 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
46 | + ]; |
|
47 | + |
|
48 | + $this->_columns = [ |
|
49 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
50 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
51 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
52 | + 'base_type' => esc_html__('Base Type', 'event_espresso'), |
|
53 | + 'percent' => sprintf( |
|
54 | + /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */ |
|
55 | + esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'), |
|
56 | + '', |
|
57 | + '<span class="big-text">', |
|
58 | + '</span>' |
|
59 | + ), |
|
60 | + 'order' => esc_html__('Order of Application', 'event_espresso'), |
|
61 | + ]; |
|
62 | + |
|
63 | + $this->_sortable_columns = [ |
|
64 | + // TRUE means its already sorted |
|
65 | + 'name' => ['name' => false], |
|
66 | + ]; |
|
67 | + |
|
68 | + $this->_hidden_columns = []; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + protected function _get_table_filters() |
|
73 | + { |
|
74 | + return []; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + protected function _add_view_counts() |
|
79 | + { |
|
80 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
81 | + if ( |
|
82 | + EE_Registry::instance()->CAP->current_user_can( |
|
83 | + 'ee_delete_default_price_types', |
|
84 | + 'pricing_trash_price_type' |
|
85 | + ) |
|
86 | + ) { |
|
87 | + $this->_views['trashed']['count'] = $this->_trashed_count; |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @param EE_Price_Type $price_type |
|
94 | + * @param string $action |
|
95 | + * @return string |
|
96 | + * @throws EE_Error |
|
97 | + * @throws ReflectionException |
|
98 | + * @since $VID:$ |
|
99 | + */ |
|
100 | + protected function getActionUrl(EE_Price_Type $price_type, string $action): string |
|
101 | + { |
|
102 | + if (! in_array($action, self::$actions)) { |
|
103 | + throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
104 | + } |
|
105 | + return EE_Admin_Page::add_query_args_and_nonce( |
|
106 | + [ |
|
107 | + 'action' => "{$action}_price_type", |
|
108 | + 'id' => $price_type->ID(), |
|
109 | + 'noheader' => $action !== self::ACTION_EDIT, |
|
110 | + ], |
|
111 | + PRICING_ADMIN_URL |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + public function column_cb($item): string |
|
117 | + { |
|
118 | + if ($item->base_type() !== 1) { |
|
119 | + return sprintf( |
|
120 | + '<input type="checkbox" name="checkbox[%1$s]" />', |
|
121 | + $item->ID() |
|
122 | + ); |
|
123 | + } |
|
124 | + return ''; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @param EE_Price_Type $item |
|
130 | + * @return string |
|
131 | + * @throws EE_Error |
|
132 | + * @throws ReflectionException |
|
133 | + */ |
|
134 | + public function column_id($item): string |
|
135 | + { |
|
136 | + $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
137 | + $content .= '<span class="show-on-mobile-view-only">' . $this->column_name($item, false) . '</span>'; |
|
138 | + return $this->columnContent('id', $content, 'end'); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param EE_Price_Type $price_type |
|
144 | + * @param bool $prep_content |
|
145 | + * @return string |
|
146 | + * @throws EE_Error |
|
147 | + * @throws ReflectionException |
|
148 | + */ |
|
149 | + public function column_name(EE_Price_Type $price_type, bool $prep_content = true): string |
|
150 | + { |
|
151 | + |
|
152 | + // Build row actions |
|
153 | + $actions = []; |
|
154 | + $name_link = $price_type->name(); |
|
155 | + // edit price link |
|
156 | + if ( |
|
157 | + EE_Registry::instance()->CAP->current_user_can( |
|
158 | + 'ee_edit_default_price_type', |
|
159 | + 'pricing_edit_price_type', |
|
160 | + $price_type->ID() |
|
161 | + ) |
|
162 | + ) { |
|
163 | + $name_link = $this->getActionLink( |
|
164 | + $this->getActionUrl($price_type, self::ACTION_EDIT), |
|
165 | + stripslashes($price_type->name()), |
|
166 | + sprintf( |
|
167 | + /* translators: The name of the price type */ |
|
168 | + esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
169 | + $price_type->name() |
|
170 | + ) |
|
171 | + ); |
|
172 | + |
|
173 | + $actions['edit'] = $this->getActionLink( |
|
174 | + $this->getActionUrl($price_type, self::ACTION_EDIT), |
|
175 | + esc_html__('Edit', 'event_espresso'), |
|
176 | + sprintf( |
|
177 | + /* translators: The name of the price type */ |
|
178 | + esc_attr__('Edit Price Type (%s)', 'event_espresso'), |
|
179 | + $price_type->name() |
|
180 | + ) |
|
181 | + ); |
|
182 | + } |
|
183 | + |
|
184 | + if ($price_type->base_type() !== 1) { |
|
185 | + if ($this->_view == 'all') { |
|
186 | + // trash price link |
|
187 | + if ( |
|
188 | + EE_Registry::instance()->CAP->current_user_can( |
|
189 | + 'ee_delete_default_price_type', |
|
190 | + 'pricing_trash_price_type', |
|
191 | + $price_type->ID() |
|
192 | + ) |
|
193 | + ) { |
|
194 | + $actions['trash'] = $this->getActionLink( |
|
195 | + $this->getActionUrl($price_type, self::ACTION_TRASH), |
|
196 | + esc_html__('Trash', 'event_espresso'), |
|
197 | + sprintf( |
|
198 | + /* translators: The name of the price type */ |
|
199 | + esc_attr__('Move Price Type %s to Trash', 'event_espresso'), |
|
200 | + $price_type->name() |
|
201 | + ) |
|
202 | + ); |
|
203 | + } |
|
204 | + } else { |
|
205 | + // restore price link |
|
206 | + if ( |
|
207 | + EE_Registry::instance()->CAP->current_user_can( |
|
208 | + 'ee_delete_default_price_type', |
|
209 | + 'pricing_restore_price_type', |
|
210 | + $price_type->ID() |
|
211 | + ) |
|
212 | + ) { |
|
213 | + $actions['restore'] = $this->getActionLink( |
|
214 | + $this->getActionUrl($price_type, self::ACTION_RESTORE), |
|
215 | + esc_html__('Restore', 'event_espresso'), |
|
216 | + sprintf( |
|
217 | + /* translators: The name of the price type */ |
|
218 | + esc_attr__('Restore Price Type (%s)', 'event_espresso'), |
|
219 | + $price_type->name() |
|
220 | + ) |
|
221 | + ); |
|
222 | + } |
|
223 | + // delete price link |
|
224 | + if ( |
|
225 | + EE_Registry::instance()->CAP->current_user_can( |
|
226 | + 'ee_delete_default_price_type', |
|
227 | + 'pricing_delete_price_type', |
|
228 | + $price_type->ID() |
|
229 | + ) |
|
230 | + ) { |
|
231 | + $actions['delete'] = $this->getActionLink( |
|
232 | + $this->getActionUrl($price_type, self::ACTION_DELETE), |
|
233 | + esc_html__('Delete Permanently', 'event_espresso'), |
|
234 | + sprintf( |
|
235 | + /* translators: The name of the price type */ |
|
236 | + esc_attr__('Delete Price Type %s Permanently', 'event_espresso'), |
|
237 | + $price_type->name() |
|
238 | + ) |
|
239 | + ); |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + $content = $prep_content ? $name_link . $this->row_actions($actions) : $name_link; |
|
245 | + return $prep_content ? $this->columnContent('name', $content) : $content; |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + public function column_base_type($price_type): string |
|
250 | + { |
|
251 | + return $this->columnContent('base_type', $price_type->base_type_name()); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + public function column_percent($price_type): string |
|
256 | + { |
|
257 | + $content = $price_type->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign; |
|
258 | + return $this->columnContent('percent', $content, 'center'); |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + public function column_order($price_type): string |
|
263 | + { |
|
264 | + return $this->columnContent('order', $price_type->order(), 'end'); |
|
265 | + } |
|
266 | 266 | } |
@@ -16,174 +16,174 @@ |
||
16 | 16 | */ |
17 | 17 | class Tickets_List_Table extends EE_Admin_List_Table |
18 | 18 | { |
19 | - protected function _setup_data() |
|
20 | - { |
|
21 | - \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
22 | - $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
23 | - $this->_data = $this->_admin_page->get_default_tickets($this->_per_page, false, $trashed); |
|
24 | - $this->_all_data_count = $this->_admin_page->get_default_tickets($this->_per_page, true, false); |
|
25 | - $this->_trashed_count = $this->_admin_page->get_default_tickets($this->_per_page, true, true); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - protected function _set_properties() |
|
30 | - { |
|
31 | - $this->_wp_list_args = array( |
|
32 | - 'singular' => esc_html__('ticket', 'event_espresso'), |
|
33 | - 'plural' => esc_html__('tickets', 'event_espresso'), |
|
34 | - 'ajax' => true, |
|
35 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
36 | - ); |
|
37 | - |
|
38 | - $this->_columns = array( |
|
39 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
40 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
41 | - 'TKT_name' => esc_html__('Name', 'event_espresso'), |
|
42 | - 'TKT_description' => esc_html__('Description', 'event_espresso'), |
|
43 | - 'TKT_qty' => esc_html__('Quantity', 'event_espresso'), |
|
44 | - 'TKT_uses' => esc_html__('Uses', 'event_espresso'), |
|
45 | - 'TKT_min' => esc_html__('Minimum', 'event_espresso'), |
|
46 | - 'TKT_max' => esc_html__('Maximum', 'event_espresso'), |
|
47 | - 'TKT_price' => esc_html__('Price', 'event_espresso'), |
|
48 | - 'TKT_taxable' => esc_html__('Taxable', 'event_espresso'), |
|
49 | - ); |
|
50 | - |
|
51 | - $this->_sortable_columns = array( |
|
52 | - // TRUE means its already sorted |
|
53 | - 'id' => array('TKT_ID', false), |
|
54 | - 'TKT_name' => array('TKT_name', true), |
|
55 | - 'TKT_description' => array('TKT_description', false), |
|
56 | - 'TKT_qty' => array('TKT_qty', false), |
|
57 | - 'TKT_uses' => array('TKT_uses', false), |
|
58 | - 'TKT_min' => array('TKT_min', false), |
|
59 | - 'TKT_max' => array('TKT_max', false), |
|
60 | - 'TKT_price' => array('TKT_price', false), |
|
61 | - ); |
|
62 | - |
|
63 | - $this->_hidden_columns = array(); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - protected function _get_table_filters() |
|
68 | - { |
|
69 | - return []; |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - protected function _add_view_counts() |
|
74 | - { |
|
75 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
76 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_tickets', 'trash_ticket')) { |
|
77 | - $this->_views['trashed']['count'] = $this->_trashed_count; |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - public function column_cb($item) |
|
83 | - { |
|
84 | - return $item->ID() === 1 |
|
85 | - ? '<span class="dashicons dashicons-lock"></span>' |
|
86 | - : sprintf( |
|
87 | - '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
88 | - $item->ID() |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @param EE_Ticket $item |
|
95 | - * @return string |
|
96 | - * @throws EE_Error |
|
97 | - * @throws ReflectionException |
|
98 | - */ |
|
99 | - public function column_id($item): string |
|
100 | - { |
|
101 | - $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
102 | - $content .= '<span class="show-on-mobile-view-only">' . $this->column_TKT_name($item, false) . '</span>'; |
|
103 | - return $this->columnContent('id', $content, 'end'); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - public function column_TKT_name(EE_Ticket $ticket, bool $prep_content = true): string |
|
108 | - { |
|
109 | - // build row actions |
|
110 | - $actions = array(); |
|
111 | - |
|
112 | - // trash links |
|
113 | - if ($ticket->ID() !== 1) { |
|
114 | - if ($this->_view == 'all') { |
|
115 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
116 | - 'action' => 'trash_ticket', |
|
117 | - 'TKT_ID' => $ticket->ID(), |
|
118 | - ), TICKETS_ADMIN_URL); |
|
119 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
120 | - . esc_attr__('Move Ticket to trash', 'event_espresso') . '">' |
|
121 | - . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
122 | - } else { |
|
123 | - // restore price link |
|
124 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
125 | - 'action' => 'restore_ticket', |
|
126 | - 'TKT_ID' => $ticket->ID(), |
|
127 | - ), TICKETS_ADMIN_URL); |
|
128 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
129 | - . esc_attr__('Restore Ticket', 'event_espresso') . '">' |
|
130 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
131 | - // delete price link |
|
132 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
133 | - 'action' => 'delete_ticket', |
|
134 | - 'TKT_ID' => $ticket->ID(), |
|
135 | - ), TICKETS_ADMIN_URL); |
|
136 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
137 | - . esc_attr__('Delete Ticket Permanently', 'event_espresso') . '">' |
|
138 | - . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
139 | - } |
|
140 | - } |
|
141 | - // return $ticket->get('TKT_name') . $this->row_actions($actions); |
|
142 | - $content = $prep_content ? $ticket->name() . $this->row_actions($actions) : $ticket->name(); |
|
143 | - return $prep_content ? $this->columnContent('TKT_name', $content) : $content; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - public function column_TKT_description(EE_Ticket $ticket) |
|
148 | - { |
|
149 | - return $this->columnContent('TKT_description', $ticket->description()); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - public function column_TKT_qty(EE_Ticket $ticket) |
|
154 | - { |
|
155 | - |
|
156 | - return $ticket->get_pretty('TKT_qty', 'text'); |
|
157 | - // return $this->columnContent('TKT_qty', $ticket->qty()); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - public function column_TKT_uses(EE_Ticket $ticket) |
|
162 | - { |
|
163 | - return $ticket->get_pretty('TKT_uses', 'text'); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - public function column_TKT_min(EE_Ticket $ticket) |
|
168 | - { |
|
169 | - return $ticket->get('TKT_min'); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - public function column_TKT_max(EE_Ticket $ticket) |
|
174 | - { |
|
175 | - return $ticket->get_pretty('TKT_max', 'text'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - public function column_TKT_price(EE_Ticket $ticket) |
|
180 | - { |
|
181 | - return EEH_Template::format_currency($ticket->get('TKT_price')); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - public function column_TKT_taxable(EE_Ticket $ticket) |
|
186 | - { |
|
187 | - return $ticket->get('TKT_taxable') ? esc_html__('Yes', 'event_espresso') : esc_html__('No', 'event_espresso'); |
|
188 | - } |
|
19 | + protected function _setup_data() |
|
20 | + { |
|
21 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
22 | + $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
23 | + $this->_data = $this->_admin_page->get_default_tickets($this->_per_page, false, $trashed); |
|
24 | + $this->_all_data_count = $this->_admin_page->get_default_tickets($this->_per_page, true, false); |
|
25 | + $this->_trashed_count = $this->_admin_page->get_default_tickets($this->_per_page, true, true); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + protected function _set_properties() |
|
30 | + { |
|
31 | + $this->_wp_list_args = array( |
|
32 | + 'singular' => esc_html__('ticket', 'event_espresso'), |
|
33 | + 'plural' => esc_html__('tickets', 'event_espresso'), |
|
34 | + 'ajax' => true, |
|
35 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
36 | + ); |
|
37 | + |
|
38 | + $this->_columns = array( |
|
39 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
40 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
41 | + 'TKT_name' => esc_html__('Name', 'event_espresso'), |
|
42 | + 'TKT_description' => esc_html__('Description', 'event_espresso'), |
|
43 | + 'TKT_qty' => esc_html__('Quantity', 'event_espresso'), |
|
44 | + 'TKT_uses' => esc_html__('Uses', 'event_espresso'), |
|
45 | + 'TKT_min' => esc_html__('Minimum', 'event_espresso'), |
|
46 | + 'TKT_max' => esc_html__('Maximum', 'event_espresso'), |
|
47 | + 'TKT_price' => esc_html__('Price', 'event_espresso'), |
|
48 | + 'TKT_taxable' => esc_html__('Taxable', 'event_espresso'), |
|
49 | + ); |
|
50 | + |
|
51 | + $this->_sortable_columns = array( |
|
52 | + // TRUE means its already sorted |
|
53 | + 'id' => array('TKT_ID', false), |
|
54 | + 'TKT_name' => array('TKT_name', true), |
|
55 | + 'TKT_description' => array('TKT_description', false), |
|
56 | + 'TKT_qty' => array('TKT_qty', false), |
|
57 | + 'TKT_uses' => array('TKT_uses', false), |
|
58 | + 'TKT_min' => array('TKT_min', false), |
|
59 | + 'TKT_max' => array('TKT_max', false), |
|
60 | + 'TKT_price' => array('TKT_price', false), |
|
61 | + ); |
|
62 | + |
|
63 | + $this->_hidden_columns = array(); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + protected function _get_table_filters() |
|
68 | + { |
|
69 | + return []; |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + protected function _add_view_counts() |
|
74 | + { |
|
75 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
76 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_tickets', 'trash_ticket')) { |
|
77 | + $this->_views['trashed']['count'] = $this->_trashed_count; |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + public function column_cb($item) |
|
83 | + { |
|
84 | + return $item->ID() === 1 |
|
85 | + ? '<span class="dashicons dashicons-lock"></span>' |
|
86 | + : sprintf( |
|
87 | + '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
88 | + $item->ID() |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @param EE_Ticket $item |
|
95 | + * @return string |
|
96 | + * @throws EE_Error |
|
97 | + * @throws ReflectionException |
|
98 | + */ |
|
99 | + public function column_id($item): string |
|
100 | + { |
|
101 | + $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
102 | + $content .= '<span class="show-on-mobile-view-only">' . $this->column_TKT_name($item, false) . '</span>'; |
|
103 | + return $this->columnContent('id', $content, 'end'); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + public function column_TKT_name(EE_Ticket $ticket, bool $prep_content = true): string |
|
108 | + { |
|
109 | + // build row actions |
|
110 | + $actions = array(); |
|
111 | + |
|
112 | + // trash links |
|
113 | + if ($ticket->ID() !== 1) { |
|
114 | + if ($this->_view == 'all') { |
|
115 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
116 | + 'action' => 'trash_ticket', |
|
117 | + 'TKT_ID' => $ticket->ID(), |
|
118 | + ), TICKETS_ADMIN_URL); |
|
119 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
120 | + . esc_attr__('Move Ticket to trash', 'event_espresso') . '">' |
|
121 | + . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
122 | + } else { |
|
123 | + // restore price link |
|
124 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
125 | + 'action' => 'restore_ticket', |
|
126 | + 'TKT_ID' => $ticket->ID(), |
|
127 | + ), TICKETS_ADMIN_URL); |
|
128 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
129 | + . esc_attr__('Restore Ticket', 'event_espresso') . '">' |
|
130 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
131 | + // delete price link |
|
132 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
133 | + 'action' => 'delete_ticket', |
|
134 | + 'TKT_ID' => $ticket->ID(), |
|
135 | + ), TICKETS_ADMIN_URL); |
|
136 | + $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
137 | + . esc_attr__('Delete Ticket Permanently', 'event_espresso') . '">' |
|
138 | + . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
139 | + } |
|
140 | + } |
|
141 | + // return $ticket->get('TKT_name') . $this->row_actions($actions); |
|
142 | + $content = $prep_content ? $ticket->name() . $this->row_actions($actions) : $ticket->name(); |
|
143 | + return $prep_content ? $this->columnContent('TKT_name', $content) : $content; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + public function column_TKT_description(EE_Ticket $ticket) |
|
148 | + { |
|
149 | + return $this->columnContent('TKT_description', $ticket->description()); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + public function column_TKT_qty(EE_Ticket $ticket) |
|
154 | + { |
|
155 | + |
|
156 | + return $ticket->get_pretty('TKT_qty', 'text'); |
|
157 | + // return $this->columnContent('TKT_qty', $ticket->qty()); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + public function column_TKT_uses(EE_Ticket $ticket) |
|
162 | + { |
|
163 | + return $ticket->get_pretty('TKT_uses', 'text'); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + public function column_TKT_min(EE_Ticket $ticket) |
|
168 | + { |
|
169 | + return $ticket->get('TKT_min'); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + public function column_TKT_max(EE_Ticket $ticket) |
|
174 | + { |
|
175 | + return $ticket->get_pretty('TKT_max', 'text'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + public function column_TKT_price(EE_Ticket $ticket) |
|
180 | + { |
|
181 | + return EEH_Template::format_currency($ticket->get('TKT_price')); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + public function column_TKT_taxable(EE_Ticket $ticket) |
|
186 | + { |
|
187 | + return $ticket->get('TKT_taxable') ? esc_html__('Yes', 'event_espresso') : esc_html__('No', 'event_espresso'); |
|
188 | + } |
|
189 | 189 | } |
@@ -15,172 +15,172 @@ |
||
15 | 15 | */ |
16 | 16 | class Tickets_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - protected function _setup_data() |
|
19 | - { |
|
20 | - $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
21 | - $this->_data = $this->_admin_page->get_default_tickets($this->_per_page, false, $trashed); |
|
22 | - $this->_all_data_count = $this->_admin_page->get_default_tickets($this->_per_page, true, false); |
|
23 | - $this->_trashed_count = $this->_admin_page->get_default_tickets($this->_per_page, true, true); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _set_properties() |
|
28 | - { |
|
29 | - $this->_wp_list_args = array( |
|
30 | - 'singular' => esc_html__('ticket', 'event_espresso'), |
|
31 | - 'plural' => esc_html__('tickets', 'event_espresso'), |
|
32 | - 'ajax' => true, |
|
33 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
34 | - ); |
|
35 | - |
|
36 | - $this->_columns = array( |
|
37 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
38 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
39 | - 'TKT_name' => esc_html__('Name', 'event_espresso'), |
|
40 | - 'TKT_description' => esc_html__('Description', 'event_espresso'), |
|
41 | - 'TKT_qty' => esc_html__('Quantity', 'event_espresso'), |
|
42 | - 'TKT_uses' => esc_html__('Datetimes', 'event_espresso'), |
|
43 | - 'TKT_min' => esc_html__('Minimum', 'event_espresso'), |
|
44 | - 'TKT_max' => esc_html__('Maximum', 'event_espresso'), |
|
45 | - 'TKT_price' => esc_html__('Price', 'event_espresso'), |
|
46 | - 'TKT_taxable' => esc_html__('Taxable', 'event_espresso'), |
|
47 | - ); |
|
48 | - |
|
49 | - $this->_sortable_columns = array( |
|
50 | - // TRUE means its already sorted |
|
51 | - 'id' => array('TKT_ID', false), |
|
52 | - 'TKT_name' => array('TKT_name' => true), |
|
53 | - 'TKT_description' => array('TKT_description' => false), |
|
54 | - 'TKT_qty' => array('TKT_qty' => false), |
|
55 | - 'TKT_uses' => array('TKT_uses' => false), |
|
56 | - 'TKT_min' => array('TKT_min' => false), |
|
57 | - 'TKT_max' => array('TKT_max' => false), |
|
58 | - 'TKT_price' => array('TKT_price' => false), |
|
59 | - ); |
|
60 | - |
|
61 | - $this->_hidden_columns = array(); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - protected function _get_table_filters() |
|
66 | - { |
|
67 | - return []; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - protected function _add_view_counts() |
|
72 | - { |
|
73 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
74 | - $this->_views['trashed']['count'] = $this->_trashed_count; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - public function column_cb($item) |
|
79 | - { |
|
80 | - return $item->ID() === 1 |
|
81 | - ? '<span class="dashicons dashicons-lock"></span>' |
|
82 | - : sprintf( |
|
83 | - '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
84 | - $item->ID() |
|
85 | - ); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @param EE_Ticket $item |
|
91 | - * @return string |
|
92 | - * @throws EE_Error |
|
93 | - * @throws ReflectionException |
|
94 | - */ |
|
95 | - public function column_id($item): string |
|
96 | - { |
|
97 | - $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
98 | - $content .= '<span class="show-on-mobile-view-only">' . $this->column_TKT_name($item, false) . '</span>'; |
|
99 | - return $this->columnContent('id', $content, 'end'); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - public function column_TKT_name(EE_Ticket $ticket, bool $prep_content = true): string |
|
104 | - { |
|
105 | - // build row actions |
|
106 | - $actions = array(); |
|
107 | - |
|
108 | - // trash links |
|
109 | - if ($ticket->ID() !== 1) { |
|
110 | - if ($this->_view == 'all') { |
|
111 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
112 | - 'action' => 'trash_ticket', |
|
113 | - 'TKT_ID' => $ticket->ID(), |
|
114 | - ), EVENTS_ADMIN_URL); |
|
115 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
116 | - . esc_attr__('Move Ticket to trash', 'event_espresso') . '">' |
|
117 | - . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
118 | - } else { |
|
119 | - // restore price link |
|
120 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
121 | - 'action' => 'restore_ticket', |
|
122 | - 'TKT_ID' => $ticket->ID(), |
|
123 | - ), EVENTS_ADMIN_URL); |
|
124 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
125 | - . esc_attr__('Restore Ticket', 'event_espresso') . '">' |
|
126 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
127 | - // delete price link |
|
128 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
129 | - 'action' => 'delete_ticket', |
|
130 | - 'TKT_ID' => $ticket->ID(), |
|
131 | - ), EVENTS_ADMIN_URL); |
|
132 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
133 | - . esc_attr__('Delete Ticket Permanently', 'event_espresso') . '">' |
|
134 | - . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - $content = $prep_content ? $ticket->name() . $this->row_actions($actions) : $ticket->name(); |
|
139 | - return $prep_content ? $this->columnContent('TKT_name', $content) : $content; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - public function column_TKT_description(EE_Ticket $ticket): string |
|
144 | - { |
|
145 | - return $this->columnContent('TKT_description', $ticket->description()); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - public function column_TKT_qty(EE_Ticket $ticket): string |
|
150 | - { |
|
151 | - return $this->columnContent('TKT_qty', $ticket->qty(), 'end'); |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - public function column_TKT_uses(EE_Ticket $ticket): string |
|
156 | - { |
|
157 | - return $this->columnContent('TKT_uses', $ticket->uses(), 'end'); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - public function column_TKT_min(EE_Ticket $ticket): string |
|
162 | - { |
|
163 | - return $this->columnContent('TKT_min', $ticket->min(), 'end'); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - public function column_TKT_max(EE_Ticket $ticket): string |
|
168 | - { |
|
169 | - return $this->columnContent('TKT_max', $ticket->max(), 'end'); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - public function column_TKT_price(EE_Ticket $ticket): string |
|
174 | - { |
|
175 | - return $this->columnContent('TKT_price', $ticket->pretty_price(), 'end'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - public function column_TKT_taxable(EE_Ticket $ticket): string |
|
180 | - { |
|
181 | - $content = $ticket->taxable() |
|
182 | - ? esc_html__('Yes', 'event_espresso') |
|
183 | - : esc_html__('No', 'event_espresso'); |
|
184 | - return $this->columnContent('TKT_taxable', $content, 'center'); |
|
185 | - } |
|
18 | + protected function _setup_data() |
|
19 | + { |
|
20 | + $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
21 | + $this->_data = $this->_admin_page->get_default_tickets($this->_per_page, false, $trashed); |
|
22 | + $this->_all_data_count = $this->_admin_page->get_default_tickets($this->_per_page, true, false); |
|
23 | + $this->_trashed_count = $this->_admin_page->get_default_tickets($this->_per_page, true, true); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _set_properties() |
|
28 | + { |
|
29 | + $this->_wp_list_args = array( |
|
30 | + 'singular' => esc_html__('ticket', 'event_espresso'), |
|
31 | + 'plural' => esc_html__('tickets', 'event_espresso'), |
|
32 | + 'ajax' => true, |
|
33 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
34 | + ); |
|
35 | + |
|
36 | + $this->_columns = array( |
|
37 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
38 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
39 | + 'TKT_name' => esc_html__('Name', 'event_espresso'), |
|
40 | + 'TKT_description' => esc_html__('Description', 'event_espresso'), |
|
41 | + 'TKT_qty' => esc_html__('Quantity', 'event_espresso'), |
|
42 | + 'TKT_uses' => esc_html__('Datetimes', 'event_espresso'), |
|
43 | + 'TKT_min' => esc_html__('Minimum', 'event_espresso'), |
|
44 | + 'TKT_max' => esc_html__('Maximum', 'event_espresso'), |
|
45 | + 'TKT_price' => esc_html__('Price', 'event_espresso'), |
|
46 | + 'TKT_taxable' => esc_html__('Taxable', 'event_espresso'), |
|
47 | + ); |
|
48 | + |
|
49 | + $this->_sortable_columns = array( |
|
50 | + // TRUE means its already sorted |
|
51 | + 'id' => array('TKT_ID', false), |
|
52 | + 'TKT_name' => array('TKT_name' => true), |
|
53 | + 'TKT_description' => array('TKT_description' => false), |
|
54 | + 'TKT_qty' => array('TKT_qty' => false), |
|
55 | + 'TKT_uses' => array('TKT_uses' => false), |
|
56 | + 'TKT_min' => array('TKT_min' => false), |
|
57 | + 'TKT_max' => array('TKT_max' => false), |
|
58 | + 'TKT_price' => array('TKT_price' => false), |
|
59 | + ); |
|
60 | + |
|
61 | + $this->_hidden_columns = array(); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + protected function _get_table_filters() |
|
66 | + { |
|
67 | + return []; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + protected function _add_view_counts() |
|
72 | + { |
|
73 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
74 | + $this->_views['trashed']['count'] = $this->_trashed_count; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + public function column_cb($item) |
|
79 | + { |
|
80 | + return $item->ID() === 1 |
|
81 | + ? '<span class="dashicons dashicons-lock"></span>' |
|
82 | + : sprintf( |
|
83 | + '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
84 | + $item->ID() |
|
85 | + ); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @param EE_Ticket $item |
|
91 | + * @return string |
|
92 | + * @throws EE_Error |
|
93 | + * @throws ReflectionException |
|
94 | + */ |
|
95 | + public function column_id($item): string |
|
96 | + { |
|
97 | + $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
98 | + $content .= '<span class="show-on-mobile-view-only">' . $this->column_TKT_name($item, false) . '</span>'; |
|
99 | + return $this->columnContent('id', $content, 'end'); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + public function column_TKT_name(EE_Ticket $ticket, bool $prep_content = true): string |
|
104 | + { |
|
105 | + // build row actions |
|
106 | + $actions = array(); |
|
107 | + |
|
108 | + // trash links |
|
109 | + if ($ticket->ID() !== 1) { |
|
110 | + if ($this->_view == 'all') { |
|
111 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
112 | + 'action' => 'trash_ticket', |
|
113 | + 'TKT_ID' => $ticket->ID(), |
|
114 | + ), EVENTS_ADMIN_URL); |
|
115 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
116 | + . esc_attr__('Move Ticket to trash', 'event_espresso') . '">' |
|
117 | + . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
118 | + } else { |
|
119 | + // restore price link |
|
120 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
121 | + 'action' => 'restore_ticket', |
|
122 | + 'TKT_ID' => $ticket->ID(), |
|
123 | + ), EVENTS_ADMIN_URL); |
|
124 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
125 | + . esc_attr__('Restore Ticket', 'event_espresso') . '">' |
|
126 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
127 | + // delete price link |
|
128 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
129 | + 'action' => 'delete_ticket', |
|
130 | + 'TKT_ID' => $ticket->ID(), |
|
131 | + ), EVENTS_ADMIN_URL); |
|
132 | + $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
133 | + . esc_attr__('Delete Ticket Permanently', 'event_espresso') . '">' |
|
134 | + . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + $content = $prep_content ? $ticket->name() . $this->row_actions($actions) : $ticket->name(); |
|
139 | + return $prep_content ? $this->columnContent('TKT_name', $content) : $content; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + public function column_TKT_description(EE_Ticket $ticket): string |
|
144 | + { |
|
145 | + return $this->columnContent('TKT_description', $ticket->description()); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + public function column_TKT_qty(EE_Ticket $ticket): string |
|
150 | + { |
|
151 | + return $this->columnContent('TKT_qty', $ticket->qty(), 'end'); |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + public function column_TKT_uses(EE_Ticket $ticket): string |
|
156 | + { |
|
157 | + return $this->columnContent('TKT_uses', $ticket->uses(), 'end'); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + public function column_TKT_min(EE_Ticket $ticket): string |
|
162 | + { |
|
163 | + return $this->columnContent('TKT_min', $ticket->min(), 'end'); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + public function column_TKT_max(EE_Ticket $ticket): string |
|
168 | + { |
|
169 | + return $this->columnContent('TKT_max', $ticket->max(), 'end'); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + public function column_TKT_price(EE_Ticket $ticket): string |
|
174 | + { |
|
175 | + return $this->columnContent('TKT_price', $ticket->pretty_price(), 'end'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + public function column_TKT_taxable(EE_Ticket $ticket): string |
|
180 | + { |
|
181 | + $content = $ticket->taxable() |
|
182 | + ? esc_html__('Yes', 'event_espresso') |
|
183 | + : esc_html__('No', 'event_espresso'); |
|
184 | + return $this->columnContent('TKT_taxable', $content, 'center'); |
|
185 | + } |
|
186 | 186 | } |
@@ -11,114 +11,114 @@ |
||
11 | 11 | */ |
12 | 12 | class Extend_Events_Admin_List_Table extends Events_Admin_List_Table |
13 | 13 | { |
14 | - protected function _column_name_action_setup(EE_Event $event): array |
|
15 | - { |
|
16 | - $export_query_args = [ |
|
17 | - 'action' => 'export_events', |
|
18 | - 'EVT_ID' => $event->ID(), |
|
19 | - ]; |
|
20 | - $export_event_link = EE_Admin_Page::add_query_args_and_nonce($export_query_args, EVENTS_ADMIN_URL); |
|
14 | + protected function _column_name_action_setup(EE_Event $event): array |
|
15 | + { |
|
16 | + $export_query_args = [ |
|
17 | + 'action' => 'export_events', |
|
18 | + 'EVT_ID' => $event->ID(), |
|
19 | + ]; |
|
20 | + $export_event_link = EE_Admin_Page::add_query_args_and_nonce($export_query_args, EVENTS_ADMIN_URL); |
|
21 | 21 | |
22 | - return parent::_column_name_action_setup($event); |
|
23 | - } |
|
22 | + return parent::_column_name_action_setup($event); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * hook into list table filters and provide filters for caffeinated list table |
|
28 | - * |
|
29 | - * @return array new filters |
|
30 | - * @throws EE_Error |
|
31 | - * @throws ReflectionException |
|
32 | - */ |
|
33 | - protected function _get_table_filters() |
|
34 | - { |
|
35 | - // first month/year filters |
|
36 | - $filters[] = $this->espresso_event_months_dropdown(); |
|
37 | - $status = $this->_req_data['status'] ?? ''; |
|
38 | - // active status dropdown |
|
39 | - if ($status !== 'draft') { |
|
40 | - $filters[] = $this->active_status_dropdown($this->_req_data['active_status'] ?? ''); |
|
41 | - $filters[] = $this->venuesDropdown($this->_req_data['venue'] ?? ''); |
|
42 | - } |
|
43 | - // category filter |
|
44 | - $filters[] = $this->category_dropdown(); |
|
45 | - return $filters; |
|
46 | - } |
|
26 | + /** |
|
27 | + * hook into list table filters and provide filters for caffeinated list table |
|
28 | + * |
|
29 | + * @return array new filters |
|
30 | + * @throws EE_Error |
|
31 | + * @throws ReflectionException |
|
32 | + */ |
|
33 | + protected function _get_table_filters() |
|
34 | + { |
|
35 | + // first month/year filters |
|
36 | + $filters[] = $this->espresso_event_months_dropdown(); |
|
37 | + $status = $this->_req_data['status'] ?? ''; |
|
38 | + // active status dropdown |
|
39 | + if ($status !== 'draft') { |
|
40 | + $filters[] = $this->active_status_dropdown($this->_req_data['active_status'] ?? ''); |
|
41 | + $filters[] = $this->venuesDropdown($this->_req_data['venue'] ?? ''); |
|
42 | + } |
|
43 | + // category filter |
|
44 | + $filters[] = $this->category_dropdown(); |
|
45 | + return $filters; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * espresso_event_months_dropdown |
|
51 | - * |
|
52 | - * @return string dropdown listing month/year selections for events. |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - public function espresso_event_months_dropdown(): string |
|
56 | - { |
|
57 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
58 | - // Note we need to include any other filters that are set! |
|
59 | - return EEH_Form_Fields::generate_event_months_dropdown( |
|
60 | - $this->_req_data['month_range'] ?? null, |
|
61 | - $this->_req_data['status'] ?? null, |
|
62 | - $this->_req_data['EVT_CAT'] ?? 0, |
|
63 | - $this->_req_data['active_status'] ?? null |
|
64 | - ); |
|
65 | - } |
|
49 | + /** |
|
50 | + * espresso_event_months_dropdown |
|
51 | + * |
|
52 | + * @return string dropdown listing month/year selections for events. |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + public function espresso_event_months_dropdown(): string |
|
56 | + { |
|
57 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
58 | + // Note we need to include any other filters that are set! |
|
59 | + return EEH_Form_Fields::generate_event_months_dropdown( |
|
60 | + $this->_req_data['month_range'] ?? null, |
|
61 | + $this->_req_data['status'] ?? null, |
|
62 | + $this->_req_data['EVT_CAT'] ?? 0, |
|
63 | + $this->_req_data['active_status'] ?? null |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * returns a list of "active" statuses on the event |
|
70 | - * |
|
71 | - * @param string $current_value whatever the current active status is |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function active_status_dropdown(string $current_value = ''): string |
|
75 | - { |
|
76 | - $select_name = 'active_status'; |
|
77 | - $values = [ |
|
78 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
79 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
80 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
81 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
82 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
83 | - ]; |
|
68 | + /** |
|
69 | + * returns a list of "active" statuses on the event |
|
70 | + * |
|
71 | + * @param string $current_value whatever the current active status is |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function active_status_dropdown(string $current_value = ''): string |
|
75 | + { |
|
76 | + $select_name = 'active_status'; |
|
77 | + $values = [ |
|
78 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
79 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
80 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
81 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
82 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
83 | + ]; |
|
84 | 84 | |
85 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
86 | - } |
|
85 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * returns a list of "venues" |
|
91 | - * |
|
92 | - * @param string $current_value whatever the current active status is |
|
93 | - * @return string |
|
94 | - * @throws EE_Error |
|
95 | - * @throws ReflectionException |
|
96 | - */ |
|
97 | - protected function venuesDropdown(string $current_value = ''): string |
|
98 | - { |
|
99 | - $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
100 | - // populate the list of venues. |
|
101 | - $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
89 | + /** |
|
90 | + * returns a list of "venues" |
|
91 | + * |
|
92 | + * @param string $current_value whatever the current active status is |
|
93 | + * @return string |
|
94 | + * @throws EE_Error |
|
95 | + * @throws ReflectionException |
|
96 | + */ |
|
97 | + protected function venuesDropdown(string $current_value = ''): string |
|
98 | + { |
|
99 | + $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
100 | + // populate the list of venues. |
|
101 | + $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
102 | 102 | |
103 | - foreach ($venues as $venue) { |
|
104 | - $values[ $venue->ID() ] = $venue->name(); |
|
105 | - } |
|
103 | + foreach ($venues as $venue) { |
|
104 | + $values[ $venue->ID() ] = $venue->name(); |
|
105 | + } |
|
106 | 106 | |
107 | - return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
108 | - } |
|
107 | + return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
113 | - * |
|
114 | - * @return string html |
|
115 | - * @throws EE_Error |
|
116 | - * @throws ReflectionException |
|
117 | - */ |
|
118 | - public function category_dropdown(): string |
|
119 | - { |
|
120 | - return EEH_Form_Fields::generate_event_category_dropdown( |
|
121 | - $this->_req_data['EVT_CAT'] ?? -1 |
|
122 | - ); |
|
123 | - } |
|
111 | + /** |
|
112 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
113 | + * |
|
114 | + * @return string html |
|
115 | + * @throws EE_Error |
|
116 | + * @throws ReflectionException |
|
117 | + */ |
|
118 | + public function category_dropdown(): string |
|
119 | + { |
|
120 | + return EEH_Form_Fields::generate_event_category_dropdown( |
|
121 | + $this->_req_data['EVT_CAT'] ?? -1 |
|
122 | + ); |
|
123 | + } |
|
124 | 124 | } |
@@ -101,7 +101,7 @@ |
||
101 | 101 | $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
102 | 102 | |
103 | 103 | foreach ($venues as $venue) { |
104 | - $values[ $venue->ID() ] = $venue->name(); |
|
104 | + $values[$venue->ID()] = $venue->name(); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return EEH_Form_Fields::select_input('venue', $values, $current_value); |
@@ -16,1289 +16,1289 @@ |
||
16 | 16 | */ |
17 | 17 | class Extend_Events_Admin_Page extends Events_Admin_Page |
18 | 18 | { |
19 | - /** |
|
20 | - * @var EE_Admin_Config |
|
21 | - */ |
|
22 | - protected $admin_config; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Extend_Events_Admin_Page constructor. |
|
27 | - * |
|
28 | - * @param bool $routing |
|
29 | - * @throws ReflectionException |
|
30 | - */ |
|
31 | - public function __construct($routing = true) |
|
32 | - { |
|
33 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
34 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
35 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
36 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
37 | - } |
|
38 | - parent::__construct($routing); |
|
39 | - $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - protected function _set_page_config() |
|
44 | - { |
|
45 | - parent::_set_page_config(); |
|
46 | - |
|
47 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
48 | - // is there a evt_id in the request? |
|
49 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
50 | - $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
51 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
52 | - $new_page_routes = [ |
|
53 | - 'duplicate_event' => [ |
|
54 | - 'func' => '_duplicate_event', |
|
55 | - 'capability' => 'ee_edit_event', |
|
56 | - 'obj_id' => $EVT_ID, |
|
57 | - 'noheader' => true, |
|
58 | - ], |
|
59 | - 'import_page' => [ |
|
60 | - 'func' => '_import_page', |
|
61 | - 'capability' => 'import', |
|
62 | - ], |
|
63 | - 'import' => [ |
|
64 | - 'func' => '_import_events', |
|
65 | - 'capability' => 'import', |
|
66 | - 'noheader' => true, |
|
67 | - ], |
|
68 | - 'import_events' => [ |
|
69 | - 'func' => '_import_events', |
|
70 | - 'capability' => 'import', |
|
71 | - 'noheader' => true, |
|
72 | - ], |
|
73 | - 'export_events' => [ |
|
74 | - 'func' => '_events_export', |
|
75 | - 'capability' => 'export', |
|
76 | - 'noheader' => true, |
|
77 | - ], |
|
78 | - 'export_categories' => [ |
|
79 | - 'func' => '_categories_export', |
|
80 | - 'capability' => 'export', |
|
81 | - 'noheader' => true, |
|
82 | - ], |
|
83 | - 'sample_export_file' => [ |
|
84 | - 'func' => '_sample_export_file', |
|
85 | - 'capability' => 'export', |
|
86 | - 'noheader' => true, |
|
87 | - ], |
|
88 | - 'update_template_settings' => [ |
|
89 | - 'func' => '_update_template_settings', |
|
90 | - 'capability' => 'manage_options', |
|
91 | - 'noheader' => true, |
|
92 | - ], |
|
93 | - 'ticket_list_table' => [ |
|
94 | - 'func' => '_tickets_overview_list_table', |
|
95 | - 'capability' => 'ee_read_default_tickets', |
|
96 | - ], |
|
97 | - ]; |
|
98 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
99 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
100 | - // don't load these meta boxes if using the advanced editor |
|
101 | - if ( |
|
102 | - ! $this->admin_config->useAdvancedEditor() |
|
103 | - || ! $this->feature->allowed('use_default_ticket_manager') |
|
104 | - ) { |
|
105 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
106 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
107 | - |
|
108 | - $legacy_editor_page_routes = [ |
|
109 | - 'trash_ticket' => [ |
|
110 | - 'func' => '_trash_or_restore_ticket', |
|
111 | - 'capability' => 'ee_delete_default_ticket', |
|
112 | - 'obj_id' => $TKT_ID, |
|
113 | - 'noheader' => true, |
|
114 | - 'args' => ['trash' => true], |
|
115 | - ], |
|
116 | - 'trash_tickets' => [ |
|
117 | - 'func' => '_trash_or_restore_ticket', |
|
118 | - 'capability' => 'ee_delete_default_tickets', |
|
119 | - 'noheader' => true, |
|
120 | - 'args' => ['trash' => true], |
|
121 | - ], |
|
122 | - 'restore_ticket' => [ |
|
123 | - 'func' => '_trash_or_restore_ticket', |
|
124 | - 'capability' => 'ee_delete_default_ticket', |
|
125 | - 'obj_id' => $TKT_ID, |
|
126 | - 'noheader' => true, |
|
127 | - ], |
|
128 | - 'restore_tickets' => [ |
|
129 | - 'func' => '_trash_or_restore_ticket', |
|
130 | - 'capability' => 'ee_delete_default_tickets', |
|
131 | - 'noheader' => true, |
|
132 | - ], |
|
133 | - 'delete_ticket' => [ |
|
134 | - 'func' => '_delete_ticket', |
|
135 | - 'capability' => 'ee_delete_default_ticket', |
|
136 | - 'obj_id' => $TKT_ID, |
|
137 | - 'noheader' => true, |
|
138 | - ], |
|
139 | - 'delete_tickets' => [ |
|
140 | - 'func' => '_delete_ticket', |
|
141 | - 'capability' => 'ee_delete_default_tickets', |
|
142 | - 'noheader' => true, |
|
143 | - ], |
|
144 | - ]; |
|
145 | - $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
146 | - } |
|
147 | - |
|
148 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
149 | - // partial route/config override |
|
150 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
151 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
152 | - |
|
153 | - // add default tickets tab and template settings nav tabs (note union at end) |
|
154 | - $this->_page_config = [ |
|
155 | - 'ticket_list_table' => [ |
|
156 | - 'nav' => [ |
|
157 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
158 | - 'icon' => 'dashicons-tickets-alt', |
|
159 | - 'order' => 60, |
|
160 | - ], |
|
161 | - 'list_table' => 'Tickets_List_Table', |
|
162 | - 'require_nonce' => false, |
|
163 | - ], |
|
164 | - 'template_settings' => [ |
|
165 | - 'nav' => [ |
|
166 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
167 | - 'icon' => 'dashicons-layout', |
|
168 | - 'order' => 30, |
|
169 | - ], |
|
170 | - 'metaboxes' => array_merge( |
|
171 | - ['_publish_post_box'], |
|
172 | - $this->_default_espresso_metaboxes |
|
173 | - ), |
|
174 | - 'help_tabs' => [ |
|
175 | - 'general_settings_templates_help_tab' => [ |
|
176 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
177 | - 'filename' => 'general_settings_templates', |
|
178 | - ], |
|
179 | - ], |
|
180 | - 'require_nonce' => false, |
|
181 | - ], |
|
182 | - ] + $this->_page_config; |
|
183 | - |
|
184 | - // add filters and actions |
|
185 | - // modifying _views |
|
186 | - add_filter( |
|
187 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
188 | - [$this, 'add_additional_datetime_button'], |
|
189 | - 10, |
|
190 | - 2 |
|
191 | - ); |
|
192 | - add_filter( |
|
193 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
194 | - [$this, 'add_datetime_clone_button'], |
|
195 | - 10, |
|
196 | - 2 |
|
197 | - ); |
|
198 | - add_filter( |
|
199 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
200 | - [$this, 'datetime_timezones_template'], |
|
201 | - 10, |
|
202 | - 2 |
|
203 | - ); |
|
204 | - // filters for event list table |
|
205 | - add_filter( |
|
206 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
207 | - [$this, 'extra_list_table_actions'], |
|
208 | - 10, |
|
209 | - 2 |
|
210 | - ); |
|
211 | - // legend item |
|
212 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']); |
|
213 | - add_action('admin_init', [$this, 'admin_init']); |
|
214 | - // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
|
215 | - add_filter('get_sample_permalink_html', [DuplicateEventButton::class, 'addButton'], 8, 4); |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * admin_init |
|
221 | - */ |
|
222 | - public function admin_init() |
|
223 | - { |
|
224 | - EE_Registry::$i18n_js_strings = array_merge( |
|
225 | - EE_Registry::$i18n_js_strings, |
|
226 | - [ |
|
227 | - 'image_confirm' => esc_html__( |
|
228 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
229 | - 'event_espresso' |
|
230 | - ), |
|
231 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
232 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
233 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
234 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
235 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
236 | - ] |
|
237 | - ); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * Add per page screen options to the default ticket list table view. |
|
243 | - * |
|
244 | - * @throws InvalidArgumentException |
|
245 | - * @throws InvalidDataTypeException |
|
246 | - * @throws InvalidInterfaceException |
|
247 | - */ |
|
248 | - protected function _add_screen_options_ticket_list_table() |
|
249 | - { |
|
250 | - $this->_per_page_screen_option(); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * @param string $return the current html |
|
256 | - * @param int $id the post id for the page |
|
257 | - * @param string|null $new_title What the title is |
|
258 | - * @param string|null $new_slug what the slug is |
|
259 | - * @return string |
|
260 | - * @deprecated $VID:$ |
|
261 | - */ |
|
262 | - public function extra_permalink_field_buttons( |
|
263 | - string $return, |
|
264 | - int $id, |
|
265 | - ?string $new_title, |
|
266 | - ?string $new_slug |
|
267 | - ): string { |
|
268 | - $return = DuplicateEventButton::addButton($return, $id, $new_title, $new_slug); |
|
269 | - return TicketSelectorShortcodeButton::addButton($return, $id, $new_title, $new_slug); |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * Set the list table views for the default ticket list table view. |
|
275 | - */ |
|
276 | - public function _set_list_table_views_ticket_list_table() |
|
277 | - { |
|
278 | - $this->_views = [ |
|
279 | - 'all' => [ |
|
280 | - 'slug' => 'all', |
|
281 | - 'label' => esc_html__('All', 'event_espresso'), |
|
282 | - 'count' => 0, |
|
283 | - 'bulk_action' => [ |
|
284 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
285 | - ], |
|
286 | - ], |
|
287 | - 'trashed' => [ |
|
288 | - 'slug' => 'trashed', |
|
289 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
290 | - 'count' => 0, |
|
291 | - 'bulk_action' => [ |
|
292 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
293 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
294 | - ], |
|
295 | - ], |
|
296 | - ]; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * Enqueue scripts and styles for the event editor. |
|
302 | - */ |
|
303 | - public function load_scripts_styles_edit() |
|
304 | - { |
|
305 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
306 | - wp_register_script( |
|
307 | - 'ee-event-editor-heartbeat', |
|
308 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
309 | - ['ee_admin_js', 'heartbeat'], |
|
310 | - EVENT_ESPRESSO_VERSION, |
|
311 | - true |
|
312 | - ); |
|
313 | - wp_enqueue_script('ee-accounting'); |
|
314 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
315 | - } |
|
316 | - wp_enqueue_script('event_editor_js'); |
|
317 | - wp_register_style( |
|
318 | - 'event-editor-css', |
|
319 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
320 | - ['ee-admin-css'], |
|
321 | - EVENT_ESPRESSO_VERSION |
|
322 | - ); |
|
323 | - wp_enqueue_style('event-editor-css'); |
|
324 | - // styles |
|
325 | - wp_enqueue_style('espresso-ui-theme'); |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * Sets the views for the default list table view. |
|
331 | - * |
|
332 | - * @throws EE_Error |
|
333 | - * @throws ReflectionException |
|
334 | - */ |
|
335 | - protected function _set_list_table_views_default() |
|
336 | - { |
|
337 | - parent::_set_list_table_views_default(); |
|
338 | - $new_views = [ |
|
339 | - 'today' => [ |
|
340 | - 'slug' => 'today', |
|
341 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
342 | - 'count' => $this->total_events_today(), |
|
343 | - 'bulk_action' => [ |
|
344 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
345 | - ], |
|
346 | - ], |
|
347 | - 'month' => [ |
|
348 | - 'slug' => 'month', |
|
349 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
350 | - 'count' => $this->total_events_this_month(), |
|
351 | - 'bulk_action' => [ |
|
352 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
353 | - ], |
|
354 | - ], |
|
355 | - ]; |
|
356 | - $this->_views = array_merge($this->_views, $new_views); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * Returns the extra action links for the default list table view. |
|
362 | - * |
|
363 | - * @param array $action_links |
|
364 | - * @param EE_Event $event |
|
365 | - * @return array |
|
366 | - * @throws EE_Error |
|
367 | - * @throws ReflectionException |
|
368 | - */ |
|
369 | - public function extra_list_table_actions(array $action_links, EE_Event $event): array |
|
370 | - { |
|
371 | - if ( |
|
372 | - EE_Registry::instance()->CAP->current_user_can( |
|
373 | - 'ee_read_registrations', |
|
374 | - 'espresso_registrations_reports', |
|
375 | - $event->ID() |
|
376 | - ) |
|
377 | - ) { |
|
378 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce( |
|
379 | - [ |
|
380 | - 'action' => 'reports', |
|
381 | - 'EVT_ID' => $event->ID(), |
|
382 | - ], |
|
383 | - REG_ADMIN_URL |
|
384 | - ); |
|
385 | - |
|
386 | - $action_links[] = ' |
|
19 | + /** |
|
20 | + * @var EE_Admin_Config |
|
21 | + */ |
|
22 | + protected $admin_config; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Extend_Events_Admin_Page constructor. |
|
27 | + * |
|
28 | + * @param bool $routing |
|
29 | + * @throws ReflectionException |
|
30 | + */ |
|
31 | + public function __construct($routing = true) |
|
32 | + { |
|
33 | + if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
34 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
35 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
36 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
37 | + } |
|
38 | + parent::__construct($routing); |
|
39 | + $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + protected function _set_page_config() |
|
44 | + { |
|
45 | + parent::_set_page_config(); |
|
46 | + |
|
47 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
48 | + // is there a evt_id in the request? |
|
49 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
50 | + $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
51 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
52 | + $new_page_routes = [ |
|
53 | + 'duplicate_event' => [ |
|
54 | + 'func' => '_duplicate_event', |
|
55 | + 'capability' => 'ee_edit_event', |
|
56 | + 'obj_id' => $EVT_ID, |
|
57 | + 'noheader' => true, |
|
58 | + ], |
|
59 | + 'import_page' => [ |
|
60 | + 'func' => '_import_page', |
|
61 | + 'capability' => 'import', |
|
62 | + ], |
|
63 | + 'import' => [ |
|
64 | + 'func' => '_import_events', |
|
65 | + 'capability' => 'import', |
|
66 | + 'noheader' => true, |
|
67 | + ], |
|
68 | + 'import_events' => [ |
|
69 | + 'func' => '_import_events', |
|
70 | + 'capability' => 'import', |
|
71 | + 'noheader' => true, |
|
72 | + ], |
|
73 | + 'export_events' => [ |
|
74 | + 'func' => '_events_export', |
|
75 | + 'capability' => 'export', |
|
76 | + 'noheader' => true, |
|
77 | + ], |
|
78 | + 'export_categories' => [ |
|
79 | + 'func' => '_categories_export', |
|
80 | + 'capability' => 'export', |
|
81 | + 'noheader' => true, |
|
82 | + ], |
|
83 | + 'sample_export_file' => [ |
|
84 | + 'func' => '_sample_export_file', |
|
85 | + 'capability' => 'export', |
|
86 | + 'noheader' => true, |
|
87 | + ], |
|
88 | + 'update_template_settings' => [ |
|
89 | + 'func' => '_update_template_settings', |
|
90 | + 'capability' => 'manage_options', |
|
91 | + 'noheader' => true, |
|
92 | + ], |
|
93 | + 'ticket_list_table' => [ |
|
94 | + 'func' => '_tickets_overview_list_table', |
|
95 | + 'capability' => 'ee_read_default_tickets', |
|
96 | + ], |
|
97 | + ]; |
|
98 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
99 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
100 | + // don't load these meta boxes if using the advanced editor |
|
101 | + if ( |
|
102 | + ! $this->admin_config->useAdvancedEditor() |
|
103 | + || ! $this->feature->allowed('use_default_ticket_manager') |
|
104 | + ) { |
|
105 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
106 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
107 | + |
|
108 | + $legacy_editor_page_routes = [ |
|
109 | + 'trash_ticket' => [ |
|
110 | + 'func' => '_trash_or_restore_ticket', |
|
111 | + 'capability' => 'ee_delete_default_ticket', |
|
112 | + 'obj_id' => $TKT_ID, |
|
113 | + 'noheader' => true, |
|
114 | + 'args' => ['trash' => true], |
|
115 | + ], |
|
116 | + 'trash_tickets' => [ |
|
117 | + 'func' => '_trash_or_restore_ticket', |
|
118 | + 'capability' => 'ee_delete_default_tickets', |
|
119 | + 'noheader' => true, |
|
120 | + 'args' => ['trash' => true], |
|
121 | + ], |
|
122 | + 'restore_ticket' => [ |
|
123 | + 'func' => '_trash_or_restore_ticket', |
|
124 | + 'capability' => 'ee_delete_default_ticket', |
|
125 | + 'obj_id' => $TKT_ID, |
|
126 | + 'noheader' => true, |
|
127 | + ], |
|
128 | + 'restore_tickets' => [ |
|
129 | + 'func' => '_trash_or_restore_ticket', |
|
130 | + 'capability' => 'ee_delete_default_tickets', |
|
131 | + 'noheader' => true, |
|
132 | + ], |
|
133 | + 'delete_ticket' => [ |
|
134 | + 'func' => '_delete_ticket', |
|
135 | + 'capability' => 'ee_delete_default_ticket', |
|
136 | + 'obj_id' => $TKT_ID, |
|
137 | + 'noheader' => true, |
|
138 | + ], |
|
139 | + 'delete_tickets' => [ |
|
140 | + 'func' => '_delete_ticket', |
|
141 | + 'capability' => 'ee_delete_default_tickets', |
|
142 | + 'noheader' => true, |
|
143 | + ], |
|
144 | + ]; |
|
145 | + $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
146 | + } |
|
147 | + |
|
148 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
149 | + // partial route/config override |
|
150 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
151 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
152 | + |
|
153 | + // add default tickets tab and template settings nav tabs (note union at end) |
|
154 | + $this->_page_config = [ |
|
155 | + 'ticket_list_table' => [ |
|
156 | + 'nav' => [ |
|
157 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
158 | + 'icon' => 'dashicons-tickets-alt', |
|
159 | + 'order' => 60, |
|
160 | + ], |
|
161 | + 'list_table' => 'Tickets_List_Table', |
|
162 | + 'require_nonce' => false, |
|
163 | + ], |
|
164 | + 'template_settings' => [ |
|
165 | + 'nav' => [ |
|
166 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
167 | + 'icon' => 'dashicons-layout', |
|
168 | + 'order' => 30, |
|
169 | + ], |
|
170 | + 'metaboxes' => array_merge( |
|
171 | + ['_publish_post_box'], |
|
172 | + $this->_default_espresso_metaboxes |
|
173 | + ), |
|
174 | + 'help_tabs' => [ |
|
175 | + 'general_settings_templates_help_tab' => [ |
|
176 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
177 | + 'filename' => 'general_settings_templates', |
|
178 | + ], |
|
179 | + ], |
|
180 | + 'require_nonce' => false, |
|
181 | + ], |
|
182 | + ] + $this->_page_config; |
|
183 | + |
|
184 | + // add filters and actions |
|
185 | + // modifying _views |
|
186 | + add_filter( |
|
187 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
188 | + [$this, 'add_additional_datetime_button'], |
|
189 | + 10, |
|
190 | + 2 |
|
191 | + ); |
|
192 | + add_filter( |
|
193 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
194 | + [$this, 'add_datetime_clone_button'], |
|
195 | + 10, |
|
196 | + 2 |
|
197 | + ); |
|
198 | + add_filter( |
|
199 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
200 | + [$this, 'datetime_timezones_template'], |
|
201 | + 10, |
|
202 | + 2 |
|
203 | + ); |
|
204 | + // filters for event list table |
|
205 | + add_filter( |
|
206 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
207 | + [$this, 'extra_list_table_actions'], |
|
208 | + 10, |
|
209 | + 2 |
|
210 | + ); |
|
211 | + // legend item |
|
212 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']); |
|
213 | + add_action('admin_init', [$this, 'admin_init']); |
|
214 | + // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
|
215 | + add_filter('get_sample_permalink_html', [DuplicateEventButton::class, 'addButton'], 8, 4); |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * admin_init |
|
221 | + */ |
|
222 | + public function admin_init() |
|
223 | + { |
|
224 | + EE_Registry::$i18n_js_strings = array_merge( |
|
225 | + EE_Registry::$i18n_js_strings, |
|
226 | + [ |
|
227 | + 'image_confirm' => esc_html__( |
|
228 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
229 | + 'event_espresso' |
|
230 | + ), |
|
231 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
232 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
233 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
234 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
235 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
236 | + ] |
|
237 | + ); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * Add per page screen options to the default ticket list table view. |
|
243 | + * |
|
244 | + * @throws InvalidArgumentException |
|
245 | + * @throws InvalidDataTypeException |
|
246 | + * @throws InvalidInterfaceException |
|
247 | + */ |
|
248 | + protected function _add_screen_options_ticket_list_table() |
|
249 | + { |
|
250 | + $this->_per_page_screen_option(); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * @param string $return the current html |
|
256 | + * @param int $id the post id for the page |
|
257 | + * @param string|null $new_title What the title is |
|
258 | + * @param string|null $new_slug what the slug is |
|
259 | + * @return string |
|
260 | + * @deprecated $VID:$ |
|
261 | + */ |
|
262 | + public function extra_permalink_field_buttons( |
|
263 | + string $return, |
|
264 | + int $id, |
|
265 | + ?string $new_title, |
|
266 | + ?string $new_slug |
|
267 | + ): string { |
|
268 | + $return = DuplicateEventButton::addButton($return, $id, $new_title, $new_slug); |
|
269 | + return TicketSelectorShortcodeButton::addButton($return, $id, $new_title, $new_slug); |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * Set the list table views for the default ticket list table view. |
|
275 | + */ |
|
276 | + public function _set_list_table_views_ticket_list_table() |
|
277 | + { |
|
278 | + $this->_views = [ |
|
279 | + 'all' => [ |
|
280 | + 'slug' => 'all', |
|
281 | + 'label' => esc_html__('All', 'event_espresso'), |
|
282 | + 'count' => 0, |
|
283 | + 'bulk_action' => [ |
|
284 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
285 | + ], |
|
286 | + ], |
|
287 | + 'trashed' => [ |
|
288 | + 'slug' => 'trashed', |
|
289 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
290 | + 'count' => 0, |
|
291 | + 'bulk_action' => [ |
|
292 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
293 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
294 | + ], |
|
295 | + ], |
|
296 | + ]; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * Enqueue scripts and styles for the event editor. |
|
302 | + */ |
|
303 | + public function load_scripts_styles_edit() |
|
304 | + { |
|
305 | + if (! $this->admin_config->useAdvancedEditor()) { |
|
306 | + wp_register_script( |
|
307 | + 'ee-event-editor-heartbeat', |
|
308 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
309 | + ['ee_admin_js', 'heartbeat'], |
|
310 | + EVENT_ESPRESSO_VERSION, |
|
311 | + true |
|
312 | + ); |
|
313 | + wp_enqueue_script('ee-accounting'); |
|
314 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
315 | + } |
|
316 | + wp_enqueue_script('event_editor_js'); |
|
317 | + wp_register_style( |
|
318 | + 'event-editor-css', |
|
319 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
320 | + ['ee-admin-css'], |
|
321 | + EVENT_ESPRESSO_VERSION |
|
322 | + ); |
|
323 | + wp_enqueue_style('event-editor-css'); |
|
324 | + // styles |
|
325 | + wp_enqueue_style('espresso-ui-theme'); |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * Sets the views for the default list table view. |
|
331 | + * |
|
332 | + * @throws EE_Error |
|
333 | + * @throws ReflectionException |
|
334 | + */ |
|
335 | + protected function _set_list_table_views_default() |
|
336 | + { |
|
337 | + parent::_set_list_table_views_default(); |
|
338 | + $new_views = [ |
|
339 | + 'today' => [ |
|
340 | + 'slug' => 'today', |
|
341 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
342 | + 'count' => $this->total_events_today(), |
|
343 | + 'bulk_action' => [ |
|
344 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
345 | + ], |
|
346 | + ], |
|
347 | + 'month' => [ |
|
348 | + 'slug' => 'month', |
|
349 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
350 | + 'count' => $this->total_events_this_month(), |
|
351 | + 'bulk_action' => [ |
|
352 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
353 | + ], |
|
354 | + ], |
|
355 | + ]; |
|
356 | + $this->_views = array_merge($this->_views, $new_views); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * Returns the extra action links for the default list table view. |
|
362 | + * |
|
363 | + * @param array $action_links |
|
364 | + * @param EE_Event $event |
|
365 | + * @return array |
|
366 | + * @throws EE_Error |
|
367 | + * @throws ReflectionException |
|
368 | + */ |
|
369 | + public function extra_list_table_actions(array $action_links, EE_Event $event): array |
|
370 | + { |
|
371 | + if ( |
|
372 | + EE_Registry::instance()->CAP->current_user_can( |
|
373 | + 'ee_read_registrations', |
|
374 | + 'espresso_registrations_reports', |
|
375 | + $event->ID() |
|
376 | + ) |
|
377 | + ) { |
|
378 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce( |
|
379 | + [ |
|
380 | + 'action' => 'reports', |
|
381 | + 'EVT_ID' => $event->ID(), |
|
382 | + ], |
|
383 | + REG_ADMIN_URL |
|
384 | + ); |
|
385 | + |
|
386 | + $action_links[] = ' |
|
387 | 387 | <a href="' . $reports_link . '" |
388 | 388 | aria-label="' . esc_attr__('View Report', 'event_espresso') . '" |
389 | 389 | class="ee-aria-tooltip button button--icon-only" |
390 | 390 | > |
391 | 391 | <span class="dashicons dashicons-chart-bar"></span> |
392 | 392 | </a>'; |
393 | - } |
|
394 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
395 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
396 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
397 | - 'see_notifications_for', |
|
398 | - null, |
|
399 | - ['EVT_ID' => $event->ID()] |
|
400 | - ); |
|
401 | - } |
|
402 | - return $action_links; |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - /** |
|
407 | - * @param $items |
|
408 | - * @return mixed |
|
409 | - */ |
|
410 | - public function additional_legend_items($items) |
|
411 | - { |
|
412 | - if ( |
|
413 | - EE_Registry::instance()->CAP->current_user_can( |
|
414 | - 'ee_read_registrations', |
|
415 | - 'espresso_registrations_reports' |
|
416 | - ) |
|
417 | - ) { |
|
418 | - $items['reports'] = [ |
|
419 | - 'class' => 'dashicons dashicons-chart-bar', |
|
420 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
421 | - ]; |
|
422 | - } |
|
423 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
424 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
425 | - // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
426 | - // (can only use numeric offsets when treating strings as arrays) |
|
427 | - if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
428 | - $items['view_related_messages'] = [ |
|
429 | - 'class' => $related_for_icon['css_class'], |
|
430 | - 'desc' => $related_for_icon['label'], |
|
431 | - ]; |
|
432 | - } |
|
433 | - } |
|
434 | - return $items; |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * This is the callback method for the duplicate event route |
|
440 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
441 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
442 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
443 | - * After duplication the redirect is to the new event edit page. |
|
444 | - * |
|
445 | - * @return void |
|
446 | - * @throws EE_Error If EE_Event is not available with given ID |
|
447 | - * @throws ReflectionException |
|
448 | - * @access protected |
|
449 | - */ |
|
450 | - protected function _duplicate_event() |
|
451 | - { |
|
452 | - // first make sure the ID for the event is in the request. |
|
453 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
454 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
455 | - if (! $EVT_ID) { |
|
456 | - EE_Error::add_error( |
|
457 | - esc_html__( |
|
458 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
459 | - 'event_espresso' |
|
460 | - ), |
|
461 | - __FILE__, |
|
462 | - __FUNCTION__, |
|
463 | - __LINE__ |
|
464 | - ); |
|
465 | - $this->_redirect_after_action(false, '', '', [], true); |
|
466 | - return; |
|
467 | - } |
|
468 | - // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
469 | - $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
470 | - if (! $orig_event instanceof EE_Event) { |
|
471 | - throw new EE_Error( |
|
472 | - sprintf( |
|
473 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
474 | - $EVT_ID |
|
475 | - ) |
|
476 | - ); |
|
477 | - } |
|
478 | - // k now let's clone the $orig_event before getting relations |
|
479 | - $new_event = clone $orig_event; |
|
480 | - // original datetimes |
|
481 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
482 | - // other original relations |
|
483 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
484 | - // reset the ID and modify other details to make it clear this is a dupe |
|
485 | - $new_event->set('EVT_ID', 0); |
|
486 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
487 | - $new_event->set('EVT_name', $new_name); |
|
488 | - $new_event->set( |
|
489 | - 'EVT_slug', |
|
490 | - wp_unique_post_slug( |
|
491 | - sanitize_title($orig_event->name()), |
|
492 | - 0, |
|
493 | - 'publish', |
|
494 | - 'espresso_events', |
|
495 | - 0 |
|
496 | - ) |
|
497 | - ); |
|
498 | - $new_event->set('status', 'draft'); |
|
499 | - // duplicate discussion settings |
|
500 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
501 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
502 | - // save the new event |
|
503 | - $new_event->save(); |
|
504 | - // venues |
|
505 | - foreach ($orig_ven as $ven) { |
|
506 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
507 | - } |
|
508 | - $new_event->save(); |
|
509 | - // now we need to get the question group relations and handle that |
|
510 | - // first primary question groups |
|
511 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
512 | - 'Question_Group', |
|
513 | - [['Event_Question_Group.EQG_primary' => true]] |
|
514 | - ); |
|
515 | - if (! empty($orig_primary_qgs)) { |
|
516 | - foreach ($orig_primary_qgs as $obj) { |
|
517 | - if ($obj instanceof EE_Question_Group) { |
|
518 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
519 | - } |
|
520 | - } |
|
521 | - } |
|
522 | - // next additional attendee question groups |
|
523 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
524 | - 'Question_Group', |
|
525 | - [['Event_Question_Group.EQG_additional' => true]] |
|
526 | - ); |
|
527 | - if (! empty($orig_additional_qgs)) { |
|
528 | - foreach ($orig_additional_qgs as $obj) { |
|
529 | - if ($obj instanceof EE_Question_Group) { |
|
530 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
531 | - } |
|
532 | - } |
|
533 | - } |
|
534 | - |
|
535 | - $new_event->save(); |
|
536 | - |
|
537 | - // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
538 | - $cloned_tickets = []; |
|
539 | - foreach ($orig_datetimes as $orig_dtt) { |
|
540 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
541 | - continue; |
|
542 | - } |
|
543 | - $new_dtt = clone $orig_dtt; |
|
544 | - $orig_tickets = $orig_dtt->tickets(); |
|
545 | - // save new dtt then add to event |
|
546 | - $new_dtt->set('DTT_ID', 0); |
|
547 | - $new_dtt->set('DTT_sold', 0); |
|
548 | - $new_dtt->set_reserved(0); |
|
549 | - $new_dtt->save(); |
|
550 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
551 | - $new_event->save(); |
|
552 | - // now let's get the ticket relations setup. |
|
553 | - foreach ((array) $orig_tickets as $orig_ticket) { |
|
554 | - // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
555 | - if (! $orig_ticket instanceof EE_Ticket) { |
|
556 | - continue; |
|
557 | - } |
|
558 | - // is this ticket archived? If it is then let's skip |
|
559 | - if ($orig_ticket->get('TKT_deleted')) { |
|
560 | - continue; |
|
561 | - } |
|
562 | - // does this original ticket already exist in the clone_tickets cache? |
|
563 | - // If so we'll just use the new ticket from it. |
|
564 | - if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
565 | - $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
566 | - } else { |
|
567 | - $new_ticket = clone $orig_ticket; |
|
568 | - // get relations on the $orig_ticket that we need to setup. |
|
569 | - $orig_prices = $orig_ticket->prices(); |
|
570 | - $new_ticket->set('TKT_ID', 0); |
|
571 | - $new_ticket->set('TKT_sold', 0); |
|
572 | - $new_ticket->set('TKT_reserved', 0); |
|
573 | - $new_ticket->save(); // make sure new ticket has ID. |
|
574 | - // price relations on new ticket need to be setup. |
|
575 | - foreach ($orig_prices as $orig_price) { |
|
576 | - $new_price = clone $orig_price; |
|
577 | - $new_price->set('PRC_ID', 0); |
|
578 | - $new_price->save(); |
|
579 | - $new_ticket->_add_relation_to($new_price, 'Price'); |
|
580 | - $new_ticket->save(); |
|
581 | - } |
|
582 | - |
|
583 | - do_action( |
|
584 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
585 | - $orig_ticket, |
|
586 | - $new_ticket, |
|
587 | - $orig_prices, |
|
588 | - $orig_event, |
|
589 | - $orig_dtt, |
|
590 | - $new_dtt |
|
591 | - ); |
|
592 | - } |
|
593 | - // k now we can add the new ticket as a relation to the new datetime |
|
594 | - // and make sure its added to our cached $cloned_tickets array |
|
595 | - // for use with later datetimes that have the same ticket. |
|
596 | - $new_dtt->_add_relation_to($new_ticket, 'Ticket'); |
|
597 | - $new_dtt->save(); |
|
598 | - $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
599 | - } |
|
600 | - } |
|
601 | - // clone taxonomy information |
|
602 | - $taxonomies_to_clone_with = apply_filters( |
|
603 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
604 | - ['espresso_event_categories', 'espresso_event_type', 'post_tag'] |
|
605 | - ); |
|
606 | - // get terms for original event (notice) |
|
607 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
608 | - // loop through terms and add them to new event. |
|
609 | - foreach ($orig_terms as $term) { |
|
610 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
611 | - } |
|
612 | - |
|
613 | - // duplicate other core WP_Post items for this event. |
|
614 | - // post thumbnail (feature image). |
|
615 | - $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
616 | - if ($feature_image_id) { |
|
617 | - update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
618 | - } |
|
619 | - |
|
620 | - // duplicate page_template setting |
|
621 | - $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
622 | - if ($page_template) { |
|
623 | - update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
624 | - } |
|
625 | - |
|
626 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
627 | - // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
628 | - if ($new_event->ID()) { |
|
629 | - $redirect_args = [ |
|
630 | - 'post' => $new_event->ID(), |
|
631 | - 'action' => 'edit', |
|
632 | - ]; |
|
633 | - EE_Error::add_success( |
|
634 | - esc_html__( |
|
635 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
636 | - 'event_espresso' |
|
637 | - ) |
|
638 | - ); |
|
639 | - } else { |
|
640 | - $redirect_args = [ |
|
641 | - 'action' => 'default', |
|
642 | - ]; |
|
643 | - EE_Error::add_error( |
|
644 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
645 | - __FILE__, |
|
646 | - __FUNCTION__, |
|
647 | - __LINE__ |
|
648 | - ); |
|
649 | - } |
|
650 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
651 | - } |
|
652 | - |
|
653 | - |
|
654 | - /** |
|
655 | - * Generates output for the import page. |
|
656 | - * |
|
657 | - * @throws EE_Error |
|
658 | - */ |
|
659 | - protected function _import_page() |
|
660 | - { |
|
661 | - $title = esc_html__('Import', 'event_espresso'); |
|
662 | - $intro = esc_html__( |
|
663 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
664 | - 'event_espresso' |
|
665 | - ); |
|
666 | - |
|
667 | - $form_url = EVENTS_ADMIN_URL; |
|
668 | - $action = 'import_events'; |
|
669 | - $type = 'csv'; |
|
670 | - |
|
671 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
672 | - $title, |
|
673 | - $intro, |
|
674 | - $form_url, |
|
675 | - $action, |
|
676 | - $type |
|
677 | - ); |
|
678 | - |
|
679 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
680 | - ['action' => 'sample_export_file'], |
|
681 | - $this->_admin_base_url |
|
682 | - ); |
|
683 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
684 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
685 | - $this->_template_args, |
|
686 | - true |
|
687 | - ); |
|
688 | - $this->display_admin_page_with_sidebar(); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - /** |
|
693 | - * _import_events |
|
694 | - * This handles displaying the screen and running imports for importing events. |
|
695 | - * |
|
696 | - * @return void |
|
697 | - * @throws EE_Error |
|
698 | - */ |
|
699 | - protected function _import_events() |
|
700 | - { |
|
701 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
702 | - $success = EE_Import::instance()->import(); |
|
703 | - $this->_redirect_after_action( |
|
704 | - $success, |
|
705 | - esc_html__('Import File', 'event_espresso'), |
|
706 | - 'ran', |
|
707 | - ['action' => 'import_page'], |
|
708 | - true |
|
709 | - ); |
|
710 | - } |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * _events_export |
|
715 | - * Will export all (or just the given event) to a Excel compatible file. |
|
716 | - * |
|
717 | - * @access protected |
|
718 | - * @return void |
|
719 | - */ |
|
720 | - protected function _events_export() |
|
721 | - { |
|
722 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
723 | - $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int'); |
|
724 | - $this->request->mergeRequestParams( |
|
725 | - [ |
|
726 | - 'export' => 'report', |
|
727 | - 'action' => 'all_event_data', |
|
728 | - 'EVT_ID' => $EVT_ID, |
|
729 | - ] |
|
730 | - ); |
|
731 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
732 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
733 | - $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
734 | - $EE_Export->export(); |
|
735 | - } |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * handle category exports() |
|
741 | - * |
|
742 | - * @return void |
|
743 | - */ |
|
744 | - protected function _categories_export() |
|
745 | - { |
|
746 | - $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
747 | - $this->request->mergeRequestParams( |
|
748 | - [ |
|
749 | - 'export' => 'report', |
|
750 | - 'action' => 'categories', |
|
751 | - 'EVT_ID' => $EVT_ID, |
|
752 | - ] |
|
753 | - ); |
|
754 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
755 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
756 | - $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
757 | - $EE_Export->export(); |
|
758 | - } |
|
759 | - } |
|
760 | - |
|
761 | - |
|
762 | - /** |
|
763 | - * Creates a sample CSV file for importing |
|
764 | - */ |
|
765 | - protected function _sample_export_file() |
|
766 | - { |
|
767 | - $EE_Export = EE_Export::instance(); |
|
768 | - if ($EE_Export instanceof EE_Export) { |
|
769 | - $EE_Export->export(); |
|
770 | - } |
|
771 | - } |
|
772 | - |
|
773 | - |
|
774 | - /************* Template Settings *************/ |
|
775 | - /** |
|
776 | - * Generates template settings page output |
|
777 | - * |
|
778 | - * @throws DomainException |
|
779 | - * @throws EE_Error |
|
780 | - * @throws InvalidArgumentException |
|
781 | - * @throws InvalidDataTypeException |
|
782 | - * @throws InvalidInterfaceException |
|
783 | - */ |
|
784 | - protected function _template_settings() |
|
785 | - { |
|
786 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
787 | - /** |
|
788 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
789 | - * from General_Settings_Admin_Page to here. |
|
790 | - */ |
|
791 | - $this->_template_args = apply_filters( |
|
792 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
793 | - $this->_template_args |
|
794 | - ); |
|
795 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
796 | - $this->_set_publish_post_box_vars(); |
|
797 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
798 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
799 | - $this->_template_args, |
|
800 | - true |
|
801 | - ); |
|
802 | - $this->display_admin_page_with_sidebar(); |
|
803 | - } |
|
804 | - |
|
805 | - |
|
806 | - /** |
|
807 | - * Handler for updating template settings. |
|
808 | - * |
|
809 | - * @throws EE_Error |
|
810 | - */ |
|
811 | - protected function _update_template_settings() |
|
812 | - { |
|
813 | - /** |
|
814 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
815 | - * from General_Settings_Admin_Page to here. |
|
816 | - */ |
|
817 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
818 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
819 | - EE_Registry::instance()->CFG->template_settings, |
|
820 | - $this->request->requestParams() |
|
821 | - ); |
|
822 | - // update custom post type slugs and detect if we need to flush rewrite rules |
|
823 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
824 | - |
|
825 | - $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug'); |
|
826 | - |
|
827 | - EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug |
|
828 | - ? EEH_URL::slugify($event_cpt_slug, 'events') |
|
829 | - : EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
830 | - |
|
831 | - $what = esc_html__('Template Settings', 'event_espresso'); |
|
832 | - $success = $this->_update_espresso_configuration( |
|
833 | - $what, |
|
834 | - EE_Registry::instance()->CFG->template_settings, |
|
835 | - __FILE__, |
|
836 | - __FUNCTION__, |
|
837 | - __LINE__ |
|
838 | - ); |
|
839 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
840 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
841 | - $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
842 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
843 | - ); |
|
844 | - $rewrite_rules->flush(); |
|
845 | - } |
|
846 | - $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']); |
|
847 | - } |
|
848 | - |
|
849 | - |
|
850 | - /** |
|
851 | - * _premium_event_editor_meta_boxes |
|
852 | - * add all metaboxes related to the event_editor |
|
853 | - * |
|
854 | - * @access protected |
|
855 | - * @return void |
|
856 | - * @throws EE_Error |
|
857 | - * @throws ReflectionException |
|
858 | - */ |
|
859 | - protected function _premium_event_editor_meta_boxes() |
|
860 | - { |
|
861 | - $this->verify_cpt_object(); |
|
862 | - // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
863 | - if ( |
|
864 | - ! $this->admin_config->useAdvancedEditor() |
|
865 | - || ! $this->feature->allowed('use_reg_options_meta_box') |
|
866 | - ) { |
|
867 | - $this->addMetaBox( |
|
868 | - 'espresso_event_editor_event_options', |
|
869 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
870 | - [$this, 'registration_options_meta_box'], |
|
871 | - $this->page_slug, |
|
872 | - 'side', |
|
873 | - 'core' |
|
874 | - ); |
|
875 | - } |
|
876 | - } |
|
877 | - |
|
878 | - |
|
879 | - /** |
|
880 | - * override caf metabox |
|
881 | - * |
|
882 | - * @return void |
|
883 | - * @throws EE_Error |
|
884 | - * @throws ReflectionException |
|
885 | - */ |
|
886 | - public function registration_options_meta_box() |
|
887 | - { |
|
888 | - $yes_no_values = [ |
|
889 | - ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
890 | - ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
891 | - ]; |
|
892 | - |
|
893 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
894 | - [ |
|
895 | - EEM_Registration::status_id_cancelled, |
|
896 | - EEM_Registration::status_id_declined, |
|
897 | - EEM_Registration::status_id_incomplete, |
|
898 | - EEM_Registration::status_id_wait_list, |
|
899 | - ], |
|
900 | - true |
|
901 | - ); |
|
902 | - |
|
903 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
904 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
905 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
906 | - |
|
907 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
908 | - 'default_reg_status', |
|
909 | - $default_reg_status_values, |
|
910 | - $this->_cpt_model_obj->default_registration_status() |
|
911 | - ); |
|
912 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
913 | - 'display_desc', |
|
914 | - $yes_no_values, |
|
915 | - $this->_cpt_model_obj->display_description() |
|
916 | - ); |
|
917 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
918 | - 'display_ticket_selector', |
|
919 | - $yes_no_values, |
|
920 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
921 | - '', |
|
922 | - '', |
|
923 | - false |
|
924 | - ); |
|
925 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
926 | - 'EVT_default_registration_status', |
|
927 | - $default_reg_status_values, |
|
928 | - $this->_cpt_model_obj->default_registration_status() |
|
929 | - ); |
|
930 | - $template_args['additional_registration_options'] = apply_filters( |
|
931 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
932 | - '', |
|
933 | - $template_args, |
|
934 | - $yes_no_values, |
|
935 | - $default_reg_status_values |
|
936 | - ); |
|
937 | - EEH_Template::display_template( |
|
938 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
939 | - $template_args |
|
940 | - ); |
|
941 | - } |
|
942 | - |
|
943 | - |
|
944 | - |
|
945 | - /** |
|
946 | - * wp_list_table_mods for caf |
|
947 | - * ============================ |
|
948 | - */ |
|
949 | - |
|
950 | - |
|
951 | - /** |
|
952 | - * espresso_event_months_dropdown |
|
953 | - * |
|
954 | - * @deprecatd $VID:$ |
|
955 | - * @access public |
|
956 | - * @return string dropdown listing month/year selections for events. |
|
957 | - * @throws EE_Error |
|
958 | - */ |
|
959 | - public function espresso_event_months_dropdown(): string |
|
960 | - { |
|
961 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
962 | - // Note we need to include any other filters that are set! |
|
963 | - return EEH_Form_Fields::generate_event_months_dropdown( |
|
964 | - $this->request->getRequestParam('month_range'), |
|
965 | - $this->request->getRequestParam('status'), |
|
966 | - $this->request->getRequestParam('EVT_CAT', 0, 'int'), |
|
967 | - $this->request->getRequestParam('active_status') |
|
968 | - ); |
|
969 | - } |
|
970 | - |
|
971 | - |
|
972 | - /** |
|
973 | - * returns a list of "active" statuses on the event |
|
974 | - * |
|
975 | - * @deprecatd $VID:$ |
|
976 | - * @param string $current_value whatever the current active status is |
|
977 | - * @return string |
|
978 | - */ |
|
979 | - public function active_status_dropdown(string $current_value = ''): string |
|
980 | - { |
|
981 | - $select_name = 'active_status'; |
|
982 | - $values = [ |
|
983 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
984 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
985 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
986 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
987 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
988 | - ]; |
|
989 | - |
|
990 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
991 | - } |
|
992 | - |
|
993 | - |
|
994 | - /** |
|
995 | - * returns a list of "venues" |
|
996 | - * |
|
997 | - * @deprecatd $VID:$ |
|
998 | - * @param string $current_value whatever the current active status is |
|
999 | - * @return string |
|
1000 | - * @throws EE_Error |
|
1001 | - * @throws ReflectionException |
|
1002 | - */ |
|
1003 | - protected function venuesDropdown(string $current_value = ''): string |
|
1004 | - { |
|
1005 | - $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
1006 | - // populate the list of venues. |
|
1007 | - $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
1008 | - |
|
1009 | - foreach ($venues as $venue) { |
|
1010 | - $values[ $venue->ID() ] = $venue->name(); |
|
1011 | - } |
|
1012 | - |
|
1013 | - return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
1014 | - } |
|
1015 | - |
|
1016 | - |
|
1017 | - /** |
|
1018 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
1019 | - * |
|
1020 | - * @deprecatd $VID:$ |
|
1021 | - * @access public |
|
1022 | - * @return string html |
|
1023 | - * @throws EE_Error |
|
1024 | - * @throws ReflectionException |
|
1025 | - */ |
|
1026 | - public function category_dropdown(): string |
|
1027 | - { |
|
1028 | - return EEH_Form_Fields::generate_event_category_dropdown( |
|
1029 | - $this->request->getRequestParam('EVT_CAT', -1, 'int') |
|
1030 | - ); |
|
1031 | - } |
|
1032 | - |
|
1033 | - |
|
1034 | - /** |
|
1035 | - * get total number of events today |
|
1036 | - * |
|
1037 | - * @access public |
|
1038 | - * @return int |
|
1039 | - * @throws EE_Error |
|
1040 | - * @throws InvalidArgumentException |
|
1041 | - * @throws InvalidDataTypeException |
|
1042 | - * @throws InvalidInterfaceException |
|
1043 | - * @throws ReflectionException |
|
1044 | - */ |
|
1045 | - public function total_events_today(): int |
|
1046 | - { |
|
1047 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1048 | - 'DTT_EVT_start', |
|
1049 | - date('Y-m-d') . ' 00:00:00', |
|
1050 | - 'Y-m-d H:i:s', |
|
1051 | - 'UTC' |
|
1052 | - ); |
|
1053 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1054 | - 'DTT_EVT_start', |
|
1055 | - date('Y-m-d') . ' 23:59:59', |
|
1056 | - 'Y-m-d H:i:s', |
|
1057 | - 'UTC' |
|
1058 | - ); |
|
1059 | - $where = [ |
|
1060 | - 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1061 | - ]; |
|
1062 | - return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1063 | - } |
|
1064 | - |
|
1065 | - |
|
1066 | - /** |
|
1067 | - * get total number of events this month |
|
1068 | - * |
|
1069 | - * @access public |
|
1070 | - * @return int |
|
1071 | - * @throws EE_Error |
|
1072 | - * @throws InvalidArgumentException |
|
1073 | - * @throws InvalidDataTypeException |
|
1074 | - * @throws InvalidInterfaceException |
|
1075 | - * @throws ReflectionException |
|
1076 | - */ |
|
1077 | - public function total_events_this_month(): int |
|
1078 | - { |
|
1079 | - // Dates |
|
1080 | - $this_year_r = date('Y'); |
|
1081 | - $this_month_r = date('m'); |
|
1082 | - $days_this_month = date('t'); |
|
1083 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1084 | - 'DTT_EVT_start', |
|
1085 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1086 | - 'Y-m-d H:i:s', |
|
1087 | - 'UTC' |
|
1088 | - ); |
|
1089 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1090 | - 'DTT_EVT_start', |
|
1091 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1092 | - 'Y-m-d H:i:s', |
|
1093 | - 'UTC' |
|
1094 | - ); |
|
1095 | - $where = [ |
|
1096 | - 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1097 | - ]; |
|
1098 | - return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1099 | - } |
|
1100 | - |
|
1101 | - |
|
1102 | - /** DEFAULT TICKETS STUFF **/ |
|
1103 | - |
|
1104 | - /** |
|
1105 | - * Output default tickets list table view. |
|
1106 | - * |
|
1107 | - * @throws EE_Error |
|
1108 | - */ |
|
1109 | - public function _tickets_overview_list_table() |
|
1110 | - { |
|
1111 | - if ( |
|
1112 | - $this->admin_config->useAdvancedEditor() |
|
1113 | - && $this->feature->allowed('use_default_ticket_manager') |
|
1114 | - ) { |
|
1115 | - // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
1116 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1117 | - EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
1118 | - [], |
|
1119 | - true |
|
1120 | - ); |
|
1121 | - $this->display_admin_page_with_no_sidebar(); |
|
1122 | - } else { |
|
1123 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1124 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1125 | - } |
|
1126 | - } |
|
1127 | - |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * @param int $per_page |
|
1131 | - * @param bool $count |
|
1132 | - * @param bool $trashed |
|
1133 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1134 | - * @throws EE_Error |
|
1135 | - * @throws ReflectionException |
|
1136 | - */ |
|
1137 | - public function get_default_tickets(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
1138 | - { |
|
1139 | - $orderby = $this->request->getRequestParam('orderby', 'TKT_name'); |
|
1140 | - $order = $this->request->getRequestParam('order', 'ASC'); |
|
1141 | - switch ($orderby) { |
|
1142 | - case 'TKT_name': |
|
1143 | - $orderby = ['TKT_name' => $order]; |
|
1144 | - break; |
|
1145 | - case 'TKT_price': |
|
1146 | - $orderby = ['TKT_price' => $order]; |
|
1147 | - break; |
|
1148 | - case 'TKT_uses': |
|
1149 | - $orderby = ['TKT_uses' => $order]; |
|
1150 | - break; |
|
1151 | - case 'TKT_min': |
|
1152 | - $orderby = ['TKT_min' => $order]; |
|
1153 | - break; |
|
1154 | - case 'TKT_max': |
|
1155 | - $orderby = ['TKT_max' => $order]; |
|
1156 | - break; |
|
1157 | - case 'TKT_qty': |
|
1158 | - $orderby = ['TKT_qty' => $order]; |
|
1159 | - break; |
|
1160 | - } |
|
1161 | - |
|
1162 | - $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
1163 | - $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
1164 | - $offset = ($current_page - 1) * $per_page; |
|
1165 | - |
|
1166 | - $where = [ |
|
1167 | - 'TKT_is_default' => 1, |
|
1168 | - 'TKT_deleted' => $trashed, |
|
1169 | - ]; |
|
1170 | - |
|
1171 | - $search_term = $this->request->getRequestParam('s'); |
|
1172 | - if ($search_term) { |
|
1173 | - $search_term = '%' . $search_term . '%'; |
|
1174 | - $where['OR'] = [ |
|
1175 | - 'TKT_name' => ['LIKE', $search_term], |
|
1176 | - 'TKT_description' => ['LIKE', $search_term], |
|
1177 | - ]; |
|
1178 | - } |
|
1179 | - |
|
1180 | - return $count |
|
1181 | - ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where]) |
|
1182 | - : EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
1183 | - [ |
|
1184 | - $where, |
|
1185 | - 'order_by' => $orderby, |
|
1186 | - 'limit' => [$offset, $per_page], |
|
1187 | - 'group_by' => 'TKT_ID', |
|
1188 | - ] |
|
1189 | - ); |
|
1190 | - } |
|
1191 | - |
|
1192 | - |
|
1193 | - /** |
|
1194 | - * @param bool $trash |
|
1195 | - * @throws EE_Error |
|
1196 | - * @throws InvalidArgumentException |
|
1197 | - * @throws InvalidDataTypeException |
|
1198 | - * @throws InvalidInterfaceException |
|
1199 | - * @throws ReflectionException |
|
1200 | - */ |
|
1201 | - protected function _trash_or_restore_ticket(bool $trash = false) |
|
1202 | - { |
|
1203 | - $success = 1; |
|
1204 | - $TKT = EEM_Ticket::instance(); |
|
1205 | - // checkboxes? |
|
1206 | - $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1207 | - if (! empty($checkboxes)) { |
|
1208 | - // if array has more than one element then success message should be plural |
|
1209 | - $success = count($checkboxes) > 1 ? 2 : 1; |
|
1210 | - // cycle thru the boxes |
|
1211 | - foreach ($checkboxes as $TKT_ID => $value) { |
|
1212 | - if ($trash) { |
|
1213 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1214 | - $success = 0; |
|
1215 | - } |
|
1216 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1217 | - $success = 0; |
|
1218 | - } |
|
1219 | - } |
|
1220 | - } else { |
|
1221 | - // grab single id and trash |
|
1222 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1223 | - if ($trash) { |
|
1224 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1225 | - $success = 0; |
|
1226 | - } |
|
1227 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1228 | - $success = 0; |
|
1229 | - } |
|
1230 | - } |
|
1231 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1232 | - $query_args = [ |
|
1233 | - 'action' => 'ticket_list_table', |
|
1234 | - 'status' => $trash ? '' : 'trashed', |
|
1235 | - ]; |
|
1236 | - $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1237 | - } |
|
1238 | - |
|
1239 | - |
|
1240 | - /** |
|
1241 | - * Handles trashing default ticket. |
|
1242 | - * |
|
1243 | - * @throws EE_Error |
|
1244 | - * @throws ReflectionException |
|
1245 | - */ |
|
1246 | - protected function _delete_ticket() |
|
1247 | - { |
|
1248 | - $success = 1; |
|
1249 | - // checkboxes? |
|
1250 | - $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1251 | - if (! empty($checkboxes)) { |
|
1252 | - // if array has more than one element then success message should be plural |
|
1253 | - $success = count($checkboxes) > 1 ? 2 : 1; |
|
1254 | - // cycle thru the boxes |
|
1255 | - foreach ($checkboxes as $TKT_ID => $value) { |
|
1256 | - // delete |
|
1257 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1258 | - $success = 0; |
|
1259 | - } |
|
1260 | - } |
|
1261 | - } else { |
|
1262 | - // grab single id and trash |
|
1263 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1264 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1265 | - $success = 0; |
|
1266 | - } |
|
1267 | - } |
|
1268 | - $action_desc = 'deleted'; |
|
1269 | - $query_args = [ |
|
1270 | - 'action' => 'ticket_list_table', |
|
1271 | - 'status' => 'trashed', |
|
1272 | - ]; |
|
1273 | - // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1274 | - if ( |
|
1275 | - EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1276 | - [['TKT_is_default' => 1]], |
|
1277 | - 'TKT_ID', |
|
1278 | - true |
|
1279 | - ) |
|
1280 | - ) { |
|
1281 | - $query_args = []; |
|
1282 | - } |
|
1283 | - $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1284 | - } |
|
1285 | - |
|
1286 | - |
|
1287 | - /** |
|
1288 | - * @param int $TKT_ID |
|
1289 | - * @return bool|int |
|
1290 | - * @throws EE_Error |
|
1291 | - * @throws ReflectionException |
|
1292 | - */ |
|
1293 | - protected function _delete_the_ticket(int $TKT_ID) |
|
1294 | - { |
|
1295 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1296 | - if (! $ticket instanceof EE_Ticket) { |
|
1297 | - return false; |
|
1298 | - } |
|
1299 | - $ticket->_remove_relations('Datetime'); |
|
1300 | - // delete all related prices first |
|
1301 | - $ticket->delete_related_permanently('Price'); |
|
1302 | - return $ticket->delete_permanently(); |
|
1303 | - } |
|
393 | + } |
|
394 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
395 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
396 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
397 | + 'see_notifications_for', |
|
398 | + null, |
|
399 | + ['EVT_ID' => $event->ID()] |
|
400 | + ); |
|
401 | + } |
|
402 | + return $action_links; |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + /** |
|
407 | + * @param $items |
|
408 | + * @return mixed |
|
409 | + */ |
|
410 | + public function additional_legend_items($items) |
|
411 | + { |
|
412 | + if ( |
|
413 | + EE_Registry::instance()->CAP->current_user_can( |
|
414 | + 'ee_read_registrations', |
|
415 | + 'espresso_registrations_reports' |
|
416 | + ) |
|
417 | + ) { |
|
418 | + $items['reports'] = [ |
|
419 | + 'class' => 'dashicons dashicons-chart-bar', |
|
420 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
421 | + ]; |
|
422 | + } |
|
423 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
424 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
425 | + // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
426 | + // (can only use numeric offsets when treating strings as arrays) |
|
427 | + if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
428 | + $items['view_related_messages'] = [ |
|
429 | + 'class' => $related_for_icon['css_class'], |
|
430 | + 'desc' => $related_for_icon['label'], |
|
431 | + ]; |
|
432 | + } |
|
433 | + } |
|
434 | + return $items; |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * This is the callback method for the duplicate event route |
|
440 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
441 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
442 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
443 | + * After duplication the redirect is to the new event edit page. |
|
444 | + * |
|
445 | + * @return void |
|
446 | + * @throws EE_Error If EE_Event is not available with given ID |
|
447 | + * @throws ReflectionException |
|
448 | + * @access protected |
|
449 | + */ |
|
450 | + protected function _duplicate_event() |
|
451 | + { |
|
452 | + // first make sure the ID for the event is in the request. |
|
453 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
454 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
455 | + if (! $EVT_ID) { |
|
456 | + EE_Error::add_error( |
|
457 | + esc_html__( |
|
458 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
459 | + 'event_espresso' |
|
460 | + ), |
|
461 | + __FILE__, |
|
462 | + __FUNCTION__, |
|
463 | + __LINE__ |
|
464 | + ); |
|
465 | + $this->_redirect_after_action(false, '', '', [], true); |
|
466 | + return; |
|
467 | + } |
|
468 | + // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
469 | + $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
470 | + if (! $orig_event instanceof EE_Event) { |
|
471 | + throw new EE_Error( |
|
472 | + sprintf( |
|
473 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
474 | + $EVT_ID |
|
475 | + ) |
|
476 | + ); |
|
477 | + } |
|
478 | + // k now let's clone the $orig_event before getting relations |
|
479 | + $new_event = clone $orig_event; |
|
480 | + // original datetimes |
|
481 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
482 | + // other original relations |
|
483 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
484 | + // reset the ID and modify other details to make it clear this is a dupe |
|
485 | + $new_event->set('EVT_ID', 0); |
|
486 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
487 | + $new_event->set('EVT_name', $new_name); |
|
488 | + $new_event->set( |
|
489 | + 'EVT_slug', |
|
490 | + wp_unique_post_slug( |
|
491 | + sanitize_title($orig_event->name()), |
|
492 | + 0, |
|
493 | + 'publish', |
|
494 | + 'espresso_events', |
|
495 | + 0 |
|
496 | + ) |
|
497 | + ); |
|
498 | + $new_event->set('status', 'draft'); |
|
499 | + // duplicate discussion settings |
|
500 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
501 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
502 | + // save the new event |
|
503 | + $new_event->save(); |
|
504 | + // venues |
|
505 | + foreach ($orig_ven as $ven) { |
|
506 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
507 | + } |
|
508 | + $new_event->save(); |
|
509 | + // now we need to get the question group relations and handle that |
|
510 | + // first primary question groups |
|
511 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
512 | + 'Question_Group', |
|
513 | + [['Event_Question_Group.EQG_primary' => true]] |
|
514 | + ); |
|
515 | + if (! empty($orig_primary_qgs)) { |
|
516 | + foreach ($orig_primary_qgs as $obj) { |
|
517 | + if ($obj instanceof EE_Question_Group) { |
|
518 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
519 | + } |
|
520 | + } |
|
521 | + } |
|
522 | + // next additional attendee question groups |
|
523 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
524 | + 'Question_Group', |
|
525 | + [['Event_Question_Group.EQG_additional' => true]] |
|
526 | + ); |
|
527 | + if (! empty($orig_additional_qgs)) { |
|
528 | + foreach ($orig_additional_qgs as $obj) { |
|
529 | + if ($obj instanceof EE_Question_Group) { |
|
530 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
531 | + } |
|
532 | + } |
|
533 | + } |
|
534 | + |
|
535 | + $new_event->save(); |
|
536 | + |
|
537 | + // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
538 | + $cloned_tickets = []; |
|
539 | + foreach ($orig_datetimes as $orig_dtt) { |
|
540 | + if (! $orig_dtt instanceof EE_Datetime) { |
|
541 | + continue; |
|
542 | + } |
|
543 | + $new_dtt = clone $orig_dtt; |
|
544 | + $orig_tickets = $orig_dtt->tickets(); |
|
545 | + // save new dtt then add to event |
|
546 | + $new_dtt->set('DTT_ID', 0); |
|
547 | + $new_dtt->set('DTT_sold', 0); |
|
548 | + $new_dtt->set_reserved(0); |
|
549 | + $new_dtt->save(); |
|
550 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
551 | + $new_event->save(); |
|
552 | + // now let's get the ticket relations setup. |
|
553 | + foreach ((array) $orig_tickets as $orig_ticket) { |
|
554 | + // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
555 | + if (! $orig_ticket instanceof EE_Ticket) { |
|
556 | + continue; |
|
557 | + } |
|
558 | + // is this ticket archived? If it is then let's skip |
|
559 | + if ($orig_ticket->get('TKT_deleted')) { |
|
560 | + continue; |
|
561 | + } |
|
562 | + // does this original ticket already exist in the clone_tickets cache? |
|
563 | + // If so we'll just use the new ticket from it. |
|
564 | + if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
565 | + $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
566 | + } else { |
|
567 | + $new_ticket = clone $orig_ticket; |
|
568 | + // get relations on the $orig_ticket that we need to setup. |
|
569 | + $orig_prices = $orig_ticket->prices(); |
|
570 | + $new_ticket->set('TKT_ID', 0); |
|
571 | + $new_ticket->set('TKT_sold', 0); |
|
572 | + $new_ticket->set('TKT_reserved', 0); |
|
573 | + $new_ticket->save(); // make sure new ticket has ID. |
|
574 | + // price relations on new ticket need to be setup. |
|
575 | + foreach ($orig_prices as $orig_price) { |
|
576 | + $new_price = clone $orig_price; |
|
577 | + $new_price->set('PRC_ID', 0); |
|
578 | + $new_price->save(); |
|
579 | + $new_ticket->_add_relation_to($new_price, 'Price'); |
|
580 | + $new_ticket->save(); |
|
581 | + } |
|
582 | + |
|
583 | + do_action( |
|
584 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
585 | + $orig_ticket, |
|
586 | + $new_ticket, |
|
587 | + $orig_prices, |
|
588 | + $orig_event, |
|
589 | + $orig_dtt, |
|
590 | + $new_dtt |
|
591 | + ); |
|
592 | + } |
|
593 | + // k now we can add the new ticket as a relation to the new datetime |
|
594 | + // and make sure its added to our cached $cloned_tickets array |
|
595 | + // for use with later datetimes that have the same ticket. |
|
596 | + $new_dtt->_add_relation_to($new_ticket, 'Ticket'); |
|
597 | + $new_dtt->save(); |
|
598 | + $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
599 | + } |
|
600 | + } |
|
601 | + // clone taxonomy information |
|
602 | + $taxonomies_to_clone_with = apply_filters( |
|
603 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
604 | + ['espresso_event_categories', 'espresso_event_type', 'post_tag'] |
|
605 | + ); |
|
606 | + // get terms for original event (notice) |
|
607 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
608 | + // loop through terms and add them to new event. |
|
609 | + foreach ($orig_terms as $term) { |
|
610 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
611 | + } |
|
612 | + |
|
613 | + // duplicate other core WP_Post items for this event. |
|
614 | + // post thumbnail (feature image). |
|
615 | + $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
616 | + if ($feature_image_id) { |
|
617 | + update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
618 | + } |
|
619 | + |
|
620 | + // duplicate page_template setting |
|
621 | + $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
622 | + if ($page_template) { |
|
623 | + update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
624 | + } |
|
625 | + |
|
626 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
627 | + // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
628 | + if ($new_event->ID()) { |
|
629 | + $redirect_args = [ |
|
630 | + 'post' => $new_event->ID(), |
|
631 | + 'action' => 'edit', |
|
632 | + ]; |
|
633 | + EE_Error::add_success( |
|
634 | + esc_html__( |
|
635 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
636 | + 'event_espresso' |
|
637 | + ) |
|
638 | + ); |
|
639 | + } else { |
|
640 | + $redirect_args = [ |
|
641 | + 'action' => 'default', |
|
642 | + ]; |
|
643 | + EE_Error::add_error( |
|
644 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
645 | + __FILE__, |
|
646 | + __FUNCTION__, |
|
647 | + __LINE__ |
|
648 | + ); |
|
649 | + } |
|
650 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
651 | + } |
|
652 | + |
|
653 | + |
|
654 | + /** |
|
655 | + * Generates output for the import page. |
|
656 | + * |
|
657 | + * @throws EE_Error |
|
658 | + */ |
|
659 | + protected function _import_page() |
|
660 | + { |
|
661 | + $title = esc_html__('Import', 'event_espresso'); |
|
662 | + $intro = esc_html__( |
|
663 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
664 | + 'event_espresso' |
|
665 | + ); |
|
666 | + |
|
667 | + $form_url = EVENTS_ADMIN_URL; |
|
668 | + $action = 'import_events'; |
|
669 | + $type = 'csv'; |
|
670 | + |
|
671 | + $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
672 | + $title, |
|
673 | + $intro, |
|
674 | + $form_url, |
|
675 | + $action, |
|
676 | + $type |
|
677 | + ); |
|
678 | + |
|
679 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
680 | + ['action' => 'sample_export_file'], |
|
681 | + $this->_admin_base_url |
|
682 | + ); |
|
683 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
684 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
685 | + $this->_template_args, |
|
686 | + true |
|
687 | + ); |
|
688 | + $this->display_admin_page_with_sidebar(); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + /** |
|
693 | + * _import_events |
|
694 | + * This handles displaying the screen and running imports for importing events. |
|
695 | + * |
|
696 | + * @return void |
|
697 | + * @throws EE_Error |
|
698 | + */ |
|
699 | + protected function _import_events() |
|
700 | + { |
|
701 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
702 | + $success = EE_Import::instance()->import(); |
|
703 | + $this->_redirect_after_action( |
|
704 | + $success, |
|
705 | + esc_html__('Import File', 'event_espresso'), |
|
706 | + 'ran', |
|
707 | + ['action' => 'import_page'], |
|
708 | + true |
|
709 | + ); |
|
710 | + } |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * _events_export |
|
715 | + * Will export all (or just the given event) to a Excel compatible file. |
|
716 | + * |
|
717 | + * @access protected |
|
718 | + * @return void |
|
719 | + */ |
|
720 | + protected function _events_export() |
|
721 | + { |
|
722 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
723 | + $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int'); |
|
724 | + $this->request->mergeRequestParams( |
|
725 | + [ |
|
726 | + 'export' => 'report', |
|
727 | + 'action' => 'all_event_data', |
|
728 | + 'EVT_ID' => $EVT_ID, |
|
729 | + ] |
|
730 | + ); |
|
731 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
732 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
733 | + $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
734 | + $EE_Export->export(); |
|
735 | + } |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * handle category exports() |
|
741 | + * |
|
742 | + * @return void |
|
743 | + */ |
|
744 | + protected function _categories_export() |
|
745 | + { |
|
746 | + $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
747 | + $this->request->mergeRequestParams( |
|
748 | + [ |
|
749 | + 'export' => 'report', |
|
750 | + 'action' => 'categories', |
|
751 | + 'EVT_ID' => $EVT_ID, |
|
752 | + ] |
|
753 | + ); |
|
754 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
755 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
756 | + $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
757 | + $EE_Export->export(); |
|
758 | + } |
|
759 | + } |
|
760 | + |
|
761 | + |
|
762 | + /** |
|
763 | + * Creates a sample CSV file for importing |
|
764 | + */ |
|
765 | + protected function _sample_export_file() |
|
766 | + { |
|
767 | + $EE_Export = EE_Export::instance(); |
|
768 | + if ($EE_Export instanceof EE_Export) { |
|
769 | + $EE_Export->export(); |
|
770 | + } |
|
771 | + } |
|
772 | + |
|
773 | + |
|
774 | + /************* Template Settings *************/ |
|
775 | + /** |
|
776 | + * Generates template settings page output |
|
777 | + * |
|
778 | + * @throws DomainException |
|
779 | + * @throws EE_Error |
|
780 | + * @throws InvalidArgumentException |
|
781 | + * @throws InvalidDataTypeException |
|
782 | + * @throws InvalidInterfaceException |
|
783 | + */ |
|
784 | + protected function _template_settings() |
|
785 | + { |
|
786 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
787 | + /** |
|
788 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
789 | + * from General_Settings_Admin_Page to here. |
|
790 | + */ |
|
791 | + $this->_template_args = apply_filters( |
|
792 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
793 | + $this->_template_args |
|
794 | + ); |
|
795 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
796 | + $this->_set_publish_post_box_vars(); |
|
797 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
798 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
799 | + $this->_template_args, |
|
800 | + true |
|
801 | + ); |
|
802 | + $this->display_admin_page_with_sidebar(); |
|
803 | + } |
|
804 | + |
|
805 | + |
|
806 | + /** |
|
807 | + * Handler for updating template settings. |
|
808 | + * |
|
809 | + * @throws EE_Error |
|
810 | + */ |
|
811 | + protected function _update_template_settings() |
|
812 | + { |
|
813 | + /** |
|
814 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
815 | + * from General_Settings_Admin_Page to here. |
|
816 | + */ |
|
817 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
818 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
819 | + EE_Registry::instance()->CFG->template_settings, |
|
820 | + $this->request->requestParams() |
|
821 | + ); |
|
822 | + // update custom post type slugs and detect if we need to flush rewrite rules |
|
823 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
824 | + |
|
825 | + $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug'); |
|
826 | + |
|
827 | + EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug |
|
828 | + ? EEH_URL::slugify($event_cpt_slug, 'events') |
|
829 | + : EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
830 | + |
|
831 | + $what = esc_html__('Template Settings', 'event_espresso'); |
|
832 | + $success = $this->_update_espresso_configuration( |
|
833 | + $what, |
|
834 | + EE_Registry::instance()->CFG->template_settings, |
|
835 | + __FILE__, |
|
836 | + __FUNCTION__, |
|
837 | + __LINE__ |
|
838 | + ); |
|
839 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
840 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
841 | + $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
842 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
843 | + ); |
|
844 | + $rewrite_rules->flush(); |
|
845 | + } |
|
846 | + $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']); |
|
847 | + } |
|
848 | + |
|
849 | + |
|
850 | + /** |
|
851 | + * _premium_event_editor_meta_boxes |
|
852 | + * add all metaboxes related to the event_editor |
|
853 | + * |
|
854 | + * @access protected |
|
855 | + * @return void |
|
856 | + * @throws EE_Error |
|
857 | + * @throws ReflectionException |
|
858 | + */ |
|
859 | + protected function _premium_event_editor_meta_boxes() |
|
860 | + { |
|
861 | + $this->verify_cpt_object(); |
|
862 | + // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
863 | + if ( |
|
864 | + ! $this->admin_config->useAdvancedEditor() |
|
865 | + || ! $this->feature->allowed('use_reg_options_meta_box') |
|
866 | + ) { |
|
867 | + $this->addMetaBox( |
|
868 | + 'espresso_event_editor_event_options', |
|
869 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
870 | + [$this, 'registration_options_meta_box'], |
|
871 | + $this->page_slug, |
|
872 | + 'side', |
|
873 | + 'core' |
|
874 | + ); |
|
875 | + } |
|
876 | + } |
|
877 | + |
|
878 | + |
|
879 | + /** |
|
880 | + * override caf metabox |
|
881 | + * |
|
882 | + * @return void |
|
883 | + * @throws EE_Error |
|
884 | + * @throws ReflectionException |
|
885 | + */ |
|
886 | + public function registration_options_meta_box() |
|
887 | + { |
|
888 | + $yes_no_values = [ |
|
889 | + ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
890 | + ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
891 | + ]; |
|
892 | + |
|
893 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
894 | + [ |
|
895 | + EEM_Registration::status_id_cancelled, |
|
896 | + EEM_Registration::status_id_declined, |
|
897 | + EEM_Registration::status_id_incomplete, |
|
898 | + EEM_Registration::status_id_wait_list, |
|
899 | + ], |
|
900 | + true |
|
901 | + ); |
|
902 | + |
|
903 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
904 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
905 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
906 | + |
|
907 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
908 | + 'default_reg_status', |
|
909 | + $default_reg_status_values, |
|
910 | + $this->_cpt_model_obj->default_registration_status() |
|
911 | + ); |
|
912 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
913 | + 'display_desc', |
|
914 | + $yes_no_values, |
|
915 | + $this->_cpt_model_obj->display_description() |
|
916 | + ); |
|
917 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
918 | + 'display_ticket_selector', |
|
919 | + $yes_no_values, |
|
920 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
921 | + '', |
|
922 | + '', |
|
923 | + false |
|
924 | + ); |
|
925 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
926 | + 'EVT_default_registration_status', |
|
927 | + $default_reg_status_values, |
|
928 | + $this->_cpt_model_obj->default_registration_status() |
|
929 | + ); |
|
930 | + $template_args['additional_registration_options'] = apply_filters( |
|
931 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
932 | + '', |
|
933 | + $template_args, |
|
934 | + $yes_no_values, |
|
935 | + $default_reg_status_values |
|
936 | + ); |
|
937 | + EEH_Template::display_template( |
|
938 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
939 | + $template_args |
|
940 | + ); |
|
941 | + } |
|
942 | + |
|
943 | + |
|
944 | + |
|
945 | + /** |
|
946 | + * wp_list_table_mods for caf |
|
947 | + * ============================ |
|
948 | + */ |
|
949 | + |
|
950 | + |
|
951 | + /** |
|
952 | + * espresso_event_months_dropdown |
|
953 | + * |
|
954 | + * @deprecatd $VID:$ |
|
955 | + * @access public |
|
956 | + * @return string dropdown listing month/year selections for events. |
|
957 | + * @throws EE_Error |
|
958 | + */ |
|
959 | + public function espresso_event_months_dropdown(): string |
|
960 | + { |
|
961 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
962 | + // Note we need to include any other filters that are set! |
|
963 | + return EEH_Form_Fields::generate_event_months_dropdown( |
|
964 | + $this->request->getRequestParam('month_range'), |
|
965 | + $this->request->getRequestParam('status'), |
|
966 | + $this->request->getRequestParam('EVT_CAT', 0, 'int'), |
|
967 | + $this->request->getRequestParam('active_status') |
|
968 | + ); |
|
969 | + } |
|
970 | + |
|
971 | + |
|
972 | + /** |
|
973 | + * returns a list of "active" statuses on the event |
|
974 | + * |
|
975 | + * @deprecatd $VID:$ |
|
976 | + * @param string $current_value whatever the current active status is |
|
977 | + * @return string |
|
978 | + */ |
|
979 | + public function active_status_dropdown(string $current_value = ''): string |
|
980 | + { |
|
981 | + $select_name = 'active_status'; |
|
982 | + $values = [ |
|
983 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
984 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
985 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
986 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
987 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
988 | + ]; |
|
989 | + |
|
990 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
991 | + } |
|
992 | + |
|
993 | + |
|
994 | + /** |
|
995 | + * returns a list of "venues" |
|
996 | + * |
|
997 | + * @deprecatd $VID:$ |
|
998 | + * @param string $current_value whatever the current active status is |
|
999 | + * @return string |
|
1000 | + * @throws EE_Error |
|
1001 | + * @throws ReflectionException |
|
1002 | + */ |
|
1003 | + protected function venuesDropdown(string $current_value = ''): string |
|
1004 | + { |
|
1005 | + $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
1006 | + // populate the list of venues. |
|
1007 | + $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
1008 | + |
|
1009 | + foreach ($venues as $venue) { |
|
1010 | + $values[ $venue->ID() ] = $venue->name(); |
|
1011 | + } |
|
1012 | + |
|
1013 | + return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
1014 | + } |
|
1015 | + |
|
1016 | + |
|
1017 | + /** |
|
1018 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
1019 | + * |
|
1020 | + * @deprecatd $VID:$ |
|
1021 | + * @access public |
|
1022 | + * @return string html |
|
1023 | + * @throws EE_Error |
|
1024 | + * @throws ReflectionException |
|
1025 | + */ |
|
1026 | + public function category_dropdown(): string |
|
1027 | + { |
|
1028 | + return EEH_Form_Fields::generate_event_category_dropdown( |
|
1029 | + $this->request->getRequestParam('EVT_CAT', -1, 'int') |
|
1030 | + ); |
|
1031 | + } |
|
1032 | + |
|
1033 | + |
|
1034 | + /** |
|
1035 | + * get total number of events today |
|
1036 | + * |
|
1037 | + * @access public |
|
1038 | + * @return int |
|
1039 | + * @throws EE_Error |
|
1040 | + * @throws InvalidArgumentException |
|
1041 | + * @throws InvalidDataTypeException |
|
1042 | + * @throws InvalidInterfaceException |
|
1043 | + * @throws ReflectionException |
|
1044 | + */ |
|
1045 | + public function total_events_today(): int |
|
1046 | + { |
|
1047 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1048 | + 'DTT_EVT_start', |
|
1049 | + date('Y-m-d') . ' 00:00:00', |
|
1050 | + 'Y-m-d H:i:s', |
|
1051 | + 'UTC' |
|
1052 | + ); |
|
1053 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1054 | + 'DTT_EVT_start', |
|
1055 | + date('Y-m-d') . ' 23:59:59', |
|
1056 | + 'Y-m-d H:i:s', |
|
1057 | + 'UTC' |
|
1058 | + ); |
|
1059 | + $where = [ |
|
1060 | + 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1061 | + ]; |
|
1062 | + return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1063 | + } |
|
1064 | + |
|
1065 | + |
|
1066 | + /** |
|
1067 | + * get total number of events this month |
|
1068 | + * |
|
1069 | + * @access public |
|
1070 | + * @return int |
|
1071 | + * @throws EE_Error |
|
1072 | + * @throws InvalidArgumentException |
|
1073 | + * @throws InvalidDataTypeException |
|
1074 | + * @throws InvalidInterfaceException |
|
1075 | + * @throws ReflectionException |
|
1076 | + */ |
|
1077 | + public function total_events_this_month(): int |
|
1078 | + { |
|
1079 | + // Dates |
|
1080 | + $this_year_r = date('Y'); |
|
1081 | + $this_month_r = date('m'); |
|
1082 | + $days_this_month = date('t'); |
|
1083 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1084 | + 'DTT_EVT_start', |
|
1085 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1086 | + 'Y-m-d H:i:s', |
|
1087 | + 'UTC' |
|
1088 | + ); |
|
1089 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1090 | + 'DTT_EVT_start', |
|
1091 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1092 | + 'Y-m-d H:i:s', |
|
1093 | + 'UTC' |
|
1094 | + ); |
|
1095 | + $where = [ |
|
1096 | + 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1097 | + ]; |
|
1098 | + return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1099 | + } |
|
1100 | + |
|
1101 | + |
|
1102 | + /** DEFAULT TICKETS STUFF **/ |
|
1103 | + |
|
1104 | + /** |
|
1105 | + * Output default tickets list table view. |
|
1106 | + * |
|
1107 | + * @throws EE_Error |
|
1108 | + */ |
|
1109 | + public function _tickets_overview_list_table() |
|
1110 | + { |
|
1111 | + if ( |
|
1112 | + $this->admin_config->useAdvancedEditor() |
|
1113 | + && $this->feature->allowed('use_default_ticket_manager') |
|
1114 | + ) { |
|
1115 | + // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
1116 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1117 | + EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
1118 | + [], |
|
1119 | + true |
|
1120 | + ); |
|
1121 | + $this->display_admin_page_with_no_sidebar(); |
|
1122 | + } else { |
|
1123 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1124 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1125 | + } |
|
1126 | + } |
|
1127 | + |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * @param int $per_page |
|
1131 | + * @param bool $count |
|
1132 | + * @param bool $trashed |
|
1133 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1134 | + * @throws EE_Error |
|
1135 | + * @throws ReflectionException |
|
1136 | + */ |
|
1137 | + public function get_default_tickets(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
1138 | + { |
|
1139 | + $orderby = $this->request->getRequestParam('orderby', 'TKT_name'); |
|
1140 | + $order = $this->request->getRequestParam('order', 'ASC'); |
|
1141 | + switch ($orderby) { |
|
1142 | + case 'TKT_name': |
|
1143 | + $orderby = ['TKT_name' => $order]; |
|
1144 | + break; |
|
1145 | + case 'TKT_price': |
|
1146 | + $orderby = ['TKT_price' => $order]; |
|
1147 | + break; |
|
1148 | + case 'TKT_uses': |
|
1149 | + $orderby = ['TKT_uses' => $order]; |
|
1150 | + break; |
|
1151 | + case 'TKT_min': |
|
1152 | + $orderby = ['TKT_min' => $order]; |
|
1153 | + break; |
|
1154 | + case 'TKT_max': |
|
1155 | + $orderby = ['TKT_max' => $order]; |
|
1156 | + break; |
|
1157 | + case 'TKT_qty': |
|
1158 | + $orderby = ['TKT_qty' => $order]; |
|
1159 | + break; |
|
1160 | + } |
|
1161 | + |
|
1162 | + $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
1163 | + $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
1164 | + $offset = ($current_page - 1) * $per_page; |
|
1165 | + |
|
1166 | + $where = [ |
|
1167 | + 'TKT_is_default' => 1, |
|
1168 | + 'TKT_deleted' => $trashed, |
|
1169 | + ]; |
|
1170 | + |
|
1171 | + $search_term = $this->request->getRequestParam('s'); |
|
1172 | + if ($search_term) { |
|
1173 | + $search_term = '%' . $search_term . '%'; |
|
1174 | + $where['OR'] = [ |
|
1175 | + 'TKT_name' => ['LIKE', $search_term], |
|
1176 | + 'TKT_description' => ['LIKE', $search_term], |
|
1177 | + ]; |
|
1178 | + } |
|
1179 | + |
|
1180 | + return $count |
|
1181 | + ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where]) |
|
1182 | + : EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
1183 | + [ |
|
1184 | + $where, |
|
1185 | + 'order_by' => $orderby, |
|
1186 | + 'limit' => [$offset, $per_page], |
|
1187 | + 'group_by' => 'TKT_ID', |
|
1188 | + ] |
|
1189 | + ); |
|
1190 | + } |
|
1191 | + |
|
1192 | + |
|
1193 | + /** |
|
1194 | + * @param bool $trash |
|
1195 | + * @throws EE_Error |
|
1196 | + * @throws InvalidArgumentException |
|
1197 | + * @throws InvalidDataTypeException |
|
1198 | + * @throws InvalidInterfaceException |
|
1199 | + * @throws ReflectionException |
|
1200 | + */ |
|
1201 | + protected function _trash_or_restore_ticket(bool $trash = false) |
|
1202 | + { |
|
1203 | + $success = 1; |
|
1204 | + $TKT = EEM_Ticket::instance(); |
|
1205 | + // checkboxes? |
|
1206 | + $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1207 | + if (! empty($checkboxes)) { |
|
1208 | + // if array has more than one element then success message should be plural |
|
1209 | + $success = count($checkboxes) > 1 ? 2 : 1; |
|
1210 | + // cycle thru the boxes |
|
1211 | + foreach ($checkboxes as $TKT_ID => $value) { |
|
1212 | + if ($trash) { |
|
1213 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1214 | + $success = 0; |
|
1215 | + } |
|
1216 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1217 | + $success = 0; |
|
1218 | + } |
|
1219 | + } |
|
1220 | + } else { |
|
1221 | + // grab single id and trash |
|
1222 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1223 | + if ($trash) { |
|
1224 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1225 | + $success = 0; |
|
1226 | + } |
|
1227 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1228 | + $success = 0; |
|
1229 | + } |
|
1230 | + } |
|
1231 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1232 | + $query_args = [ |
|
1233 | + 'action' => 'ticket_list_table', |
|
1234 | + 'status' => $trash ? '' : 'trashed', |
|
1235 | + ]; |
|
1236 | + $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1237 | + } |
|
1238 | + |
|
1239 | + |
|
1240 | + /** |
|
1241 | + * Handles trashing default ticket. |
|
1242 | + * |
|
1243 | + * @throws EE_Error |
|
1244 | + * @throws ReflectionException |
|
1245 | + */ |
|
1246 | + protected function _delete_ticket() |
|
1247 | + { |
|
1248 | + $success = 1; |
|
1249 | + // checkboxes? |
|
1250 | + $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1251 | + if (! empty($checkboxes)) { |
|
1252 | + // if array has more than one element then success message should be plural |
|
1253 | + $success = count($checkboxes) > 1 ? 2 : 1; |
|
1254 | + // cycle thru the boxes |
|
1255 | + foreach ($checkboxes as $TKT_ID => $value) { |
|
1256 | + // delete |
|
1257 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1258 | + $success = 0; |
|
1259 | + } |
|
1260 | + } |
|
1261 | + } else { |
|
1262 | + // grab single id and trash |
|
1263 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1264 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1265 | + $success = 0; |
|
1266 | + } |
|
1267 | + } |
|
1268 | + $action_desc = 'deleted'; |
|
1269 | + $query_args = [ |
|
1270 | + 'action' => 'ticket_list_table', |
|
1271 | + 'status' => 'trashed', |
|
1272 | + ]; |
|
1273 | + // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1274 | + if ( |
|
1275 | + EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1276 | + [['TKT_is_default' => 1]], |
|
1277 | + 'TKT_ID', |
|
1278 | + true |
|
1279 | + ) |
|
1280 | + ) { |
|
1281 | + $query_args = []; |
|
1282 | + } |
|
1283 | + $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1284 | + } |
|
1285 | + |
|
1286 | + |
|
1287 | + /** |
|
1288 | + * @param int $TKT_ID |
|
1289 | + * @return bool|int |
|
1290 | + * @throws EE_Error |
|
1291 | + * @throws ReflectionException |
|
1292 | + */ |
|
1293 | + protected function _delete_the_ticket(int $TKT_ID) |
|
1294 | + { |
|
1295 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1296 | + if (! $ticket instanceof EE_Ticket) { |
|
1297 | + return false; |
|
1298 | + } |
|
1299 | + $ticket->_remove_relations('Datetime'); |
|
1300 | + // delete all related prices first |
|
1301 | + $ticket->delete_related_permanently('Price'); |
|
1302 | + return $ticket->delete_permanently(); |
|
1303 | + } |
|
1304 | 1304 | } |
@@ -15,240 +15,240 @@ |
||
15 | 15 | */ |
16 | 16 | class Registration_Form_Question_Groups_Admin_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - /** |
|
19 | - * @var RegFormListTableUserCapabilities |
|
20 | - */ |
|
21 | - protected $caps_handler; |
|
22 | - |
|
23 | - |
|
24 | - public function __construct($admin_page) |
|
25 | - { |
|
26 | - $this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP); |
|
27 | - parent::__construct($admin_page); |
|
28 | - |
|
29 | - if (! defined('REG_ADMIN_URL')) { |
|
30 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
31 | - } |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - protected function _setup_data() |
|
36 | - { |
|
37 | - $this->_data = $this->_view != 'trash' |
|
38 | - ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, false) |
|
39 | - : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, false); |
|
40 | - $this->_all_data_count = $this->_view != 'trash' |
|
41 | - ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, true) |
|
42 | - : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, true); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - protected function _set_properties() |
|
47 | - { |
|
48 | - $this->_wp_list_args = array( |
|
49 | - 'singular' => esc_html__('question group', 'event_espresso'), |
|
50 | - 'plural' => esc_html__('question groups', 'event_espresso'), |
|
51 | - 'ajax' => true, // for now, |
|
52 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
53 | - ); |
|
54 | - |
|
55 | - $this->_columns = array( |
|
56 | - 'cb' => '<input type="checkbox" />', |
|
57 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
58 | - 'name' => esc_html__('Group Name', 'event_espresso'), |
|
59 | - 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | - 'show_group_name' => esc_html__('Show Name', 'event_espresso'), |
|
61 | - 'show_group_desc' => esc_html__('Show Desc', 'event_espresso'), |
|
62 | - ); |
|
63 | - |
|
64 | - $this->_sortable_columns = array( |
|
65 | - 'id' => array('QSG_ID' => false), |
|
66 | - 'name' => array('QSG_name' => false), |
|
67 | - ); |
|
68 | - |
|
69 | - $this->_hidden_columns = array( |
|
70 | - 'id', |
|
71 | - ); |
|
72 | - |
|
73 | - $this->_ajax_sorting_callback = 'update_question_group_order'; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - // not needed |
|
78 | - protected function _get_table_filters() |
|
79 | - { |
|
80 | - return []; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - protected function _add_view_counts() |
|
85 | - { |
|
86 | - $this->_views['all']['count'] = $this->_admin_page->get_question_groups( |
|
87 | - $this->_per_page, |
|
88 | - $this->_current_page, |
|
89 | - true |
|
90 | - ); |
|
91 | - if ($this->caps_handler->userCanTrashQuestionGroups()) { |
|
92 | - $this->_views['trash']['count'] = $this->_admin_page->get_trashed_question_groups( |
|
93 | - $this->_per_page, |
|
94 | - $this->_current_page, |
|
95 | - true |
|
96 | - ); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @throws ReflectionException |
|
103 | - * @throws EE_Error |
|
104 | - */ |
|
105 | - public function column_cb($item) |
|
106 | - { |
|
107 | - $system_group = $item->get('QSG_system'); |
|
108 | - $user_can_trash_it = $this->caps_handler->userCanTrashQuestionGroup($item); |
|
109 | - $has_questions_with_answers = ! $system_group && $this->_view == 'trash' && $item->has_questions_with_answers(); |
|
110 | - $notice = ! $user_can_trash_it |
|
111 | - ? esc_html__('You do not have the required permissions to trash this question group', 'event_espresso') |
|
112 | - : ''; |
|
113 | - $notice = $has_questions_with_answers |
|
114 | - ? esc_html__('This question group is a system group and cannot be trashed', 'event_espresso') |
|
115 | - : $notice; |
|
116 | - $notice = $has_questions_with_answers |
|
117 | - ? esc_html__( |
|
118 | - 'This question group has questions that have answers attached to it from registrations that have the question. It cannot be permanently deleted.', |
|
119 | - 'event_espresso' |
|
120 | - ) |
|
121 | - : $notice; |
|
122 | - return $system_group || $has_questions_with_answers || ! $user_can_trash_it |
|
123 | - ? '<span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" aria-label="' . $notice . '"></span>' |
|
124 | - . sprintf( |
|
125 | - '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', |
|
126 | - $item->ID() |
|
127 | - ) |
|
128 | - : sprintf( |
|
129 | - '<input type="checkbox" id="QSG_ID[%1$d]" name="checkbox[%1$d]" value="%1$d" />', |
|
130 | - $item->ID() |
|
131 | - ); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - public function column_id(EE_Question_Group $item) |
|
136 | - { |
|
137 | - $content = ' |
|
18 | + /** |
|
19 | + * @var RegFormListTableUserCapabilities |
|
20 | + */ |
|
21 | + protected $caps_handler; |
|
22 | + |
|
23 | + |
|
24 | + public function __construct($admin_page) |
|
25 | + { |
|
26 | + $this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP); |
|
27 | + parent::__construct($admin_page); |
|
28 | + |
|
29 | + if (! defined('REG_ADMIN_URL')) { |
|
30 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
31 | + } |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + protected function _setup_data() |
|
36 | + { |
|
37 | + $this->_data = $this->_view != 'trash' |
|
38 | + ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, false) |
|
39 | + : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, false); |
|
40 | + $this->_all_data_count = $this->_view != 'trash' |
|
41 | + ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, true) |
|
42 | + : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, true); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + protected function _set_properties() |
|
47 | + { |
|
48 | + $this->_wp_list_args = array( |
|
49 | + 'singular' => esc_html__('question group', 'event_espresso'), |
|
50 | + 'plural' => esc_html__('question groups', 'event_espresso'), |
|
51 | + 'ajax' => true, // for now, |
|
52 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
53 | + ); |
|
54 | + |
|
55 | + $this->_columns = array( |
|
56 | + 'cb' => '<input type="checkbox" />', |
|
57 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
58 | + 'name' => esc_html__('Group Name', 'event_espresso'), |
|
59 | + 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | + 'show_group_name' => esc_html__('Show Name', 'event_espresso'), |
|
61 | + 'show_group_desc' => esc_html__('Show Desc', 'event_espresso'), |
|
62 | + ); |
|
63 | + |
|
64 | + $this->_sortable_columns = array( |
|
65 | + 'id' => array('QSG_ID' => false), |
|
66 | + 'name' => array('QSG_name' => false), |
|
67 | + ); |
|
68 | + |
|
69 | + $this->_hidden_columns = array( |
|
70 | + 'id', |
|
71 | + ); |
|
72 | + |
|
73 | + $this->_ajax_sorting_callback = 'update_question_group_order'; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + // not needed |
|
78 | + protected function _get_table_filters() |
|
79 | + { |
|
80 | + return []; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + protected function _add_view_counts() |
|
85 | + { |
|
86 | + $this->_views['all']['count'] = $this->_admin_page->get_question_groups( |
|
87 | + $this->_per_page, |
|
88 | + $this->_current_page, |
|
89 | + true |
|
90 | + ); |
|
91 | + if ($this->caps_handler->userCanTrashQuestionGroups()) { |
|
92 | + $this->_views['trash']['count'] = $this->_admin_page->get_trashed_question_groups( |
|
93 | + $this->_per_page, |
|
94 | + $this->_current_page, |
|
95 | + true |
|
96 | + ); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @throws ReflectionException |
|
103 | + * @throws EE_Error |
|
104 | + */ |
|
105 | + public function column_cb($item) |
|
106 | + { |
|
107 | + $system_group = $item->get('QSG_system'); |
|
108 | + $user_can_trash_it = $this->caps_handler->userCanTrashQuestionGroup($item); |
|
109 | + $has_questions_with_answers = ! $system_group && $this->_view == 'trash' && $item->has_questions_with_answers(); |
|
110 | + $notice = ! $user_can_trash_it |
|
111 | + ? esc_html__('You do not have the required permissions to trash this question group', 'event_espresso') |
|
112 | + : ''; |
|
113 | + $notice = $has_questions_with_answers |
|
114 | + ? esc_html__('This question group is a system group and cannot be trashed', 'event_espresso') |
|
115 | + : $notice; |
|
116 | + $notice = $has_questions_with_answers |
|
117 | + ? esc_html__( |
|
118 | + 'This question group has questions that have answers attached to it from registrations that have the question. It cannot be permanently deleted.', |
|
119 | + 'event_espresso' |
|
120 | + ) |
|
121 | + : $notice; |
|
122 | + return $system_group || $has_questions_with_answers || ! $user_can_trash_it |
|
123 | + ? '<span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" aria-label="' . $notice . '"></span>' |
|
124 | + . sprintf( |
|
125 | + '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', |
|
126 | + $item->ID() |
|
127 | + ) |
|
128 | + : sprintf( |
|
129 | + '<input type="checkbox" id="QSG_ID[%1$d]" name="checkbox[%1$d]" value="%1$d" />', |
|
130 | + $item->ID() |
|
131 | + ); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + public function column_id(EE_Question_Group $item) |
|
136 | + { |
|
137 | + $content = ' |
|
138 | 138 | <span class="ee-entity-id">' . $item->ID() . '</span> |
139 | 139 | <span class="show-on-mobile-view-only"> |
140 | 140 | ' . $item->name() . ' |
141 | 141 | </span>'; |
142 | - return $this->columnContent('id', $content, 'end'); |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @throws EE_Error |
|
148 | - * @throws ReflectionException |
|
149 | - */ |
|
150 | - public function column_name(EE_Question_Group $question_group, bool $prep_content = true): string |
|
151 | - { |
|
152 | - $actions = array(); |
|
153 | - |
|
154 | - if ($this->caps_handler->userCanEditQuestionGroup($question_group)) { |
|
155 | - $actions['edit'] = $this->getActionLink( |
|
156 | - $this->getActionUrl($question_group, self::ACTION_EDIT), |
|
157 | - esc_html__('Edit', 'event_espresso'), |
|
158 | - esc_attr__('Edit Question Group', 'event_espresso') |
|
159 | - ); |
|
160 | - } |
|
161 | - if ( |
|
162 | - $question_group->get('QSG_system') < 1 |
|
163 | - && $this->_view != 'trash' |
|
164 | - && $this->caps_handler->userCanEditQuestionGroup($question_group) |
|
165 | - ) { |
|
166 | - $actions['delete'] = $this->getActionLink( |
|
167 | - $this->getActionUrl($question_group, self::ACTION_TRASH), |
|
168 | - esc_html__('Trash', 'event_espresso'), |
|
169 | - esc_attr__('Trash Question Group', 'event_espresso') |
|
170 | - ); |
|
171 | - } |
|
172 | - |
|
173 | - if ($this->_view == 'trash') { |
|
174 | - if ($this->caps_handler->userCanRestoreQuestionGroup($question_group)) { |
|
175 | - $actions['restore'] = $this->getActionLink( |
|
176 | - $this->getActionUrl($question_group, self::ACTION_RESTORE), |
|
177 | - esc_html__('Restore', 'event_espresso'), |
|
178 | - esc_attr__('Restore Question Group', 'event_espresso') |
|
179 | - ); |
|
180 | - } |
|
181 | - |
|
182 | - if ( |
|
183 | - ! $question_group->has_questions_with_answers() |
|
184 | - && $this->caps_handler->userCanDeleteQuestionGroup($question_group) |
|
185 | - ) { |
|
186 | - $actions['delete'] = $this->getActionLink( |
|
187 | - $this->getActionUrl($question_group, self::ACTION_DELETE), |
|
188 | - esc_html__('Delete Permanently', 'event_espresso'), |
|
189 | - esc_attr__('Delete Question Group Permanently', 'event_espresso') |
|
190 | - ); |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - $content = $this->caps_handler->userCanEditQuestionGroup($question_group) |
|
195 | - ? $this->getActionLink( |
|
196 | - $this->getActionUrl($question_group, self::ACTION_EDIT), |
|
197 | - $question_group->name(), |
|
198 | - esc_attr__('Edit Question Group', 'event_espresso'), |
|
199 | - 'row-title' |
|
200 | - ) |
|
201 | - : $question_group->name(); |
|
202 | - $content .= $this->row_actions($actions); |
|
203 | - |
|
204 | - return $prep_content ? $this->columnContent('name', $content) : $content; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * @param EE_Question_Group $question_group |
|
210 | - * @param $action |
|
211 | - * @return string |
|
212 | - * @throws EE_Error |
|
213 | - * @throws ReflectionException |
|
214 | - * @since $VID:$ |
|
215 | - */ |
|
216 | - protected function getActionUrl(EE_Question_Group $question_group, $action): string |
|
217 | - { |
|
218 | - if (! in_array($action, self::$actions)) { |
|
219 | - throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
220 | - } |
|
221 | - return EE_Admin_Page::add_query_args_and_nonce( |
|
222 | - [ |
|
223 | - 'action' => "{$action}_question_group", |
|
224 | - 'QSG_ID' => $question_group->ID(), |
|
225 | - 'noheader' => $action !== self::ACTION_EDIT, |
|
226 | - ], |
|
227 | - EE_FORMS_ADMIN_URL |
|
228 | - ); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - public function column_identifier(EE_Question_Group $question_group): string |
|
233 | - { |
|
234 | - return $this->columnContent('identifier', $question_group->identifier()); |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - public function column_description(EE_Question_Group $question_group): string |
|
239 | - { |
|
240 | - return $this->columnContent('description', $question_group->desc()); |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - public function column_show_group_name(EE_Question_Group $question_group): string |
|
245 | - { |
|
246 | - return $this->columnContent('show_group_name', $this->_yes_no[ $question_group->show_group_name() ]); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - public function column_show_group_desc(EE_Question_Group $question_group): string |
|
251 | - { |
|
252 | - return $this->columnContent('show_group_desc', $this->_yes_no[ $question_group->show_group_desc() ]); |
|
253 | - } |
|
142 | + return $this->columnContent('id', $content, 'end'); |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @throws EE_Error |
|
148 | + * @throws ReflectionException |
|
149 | + */ |
|
150 | + public function column_name(EE_Question_Group $question_group, bool $prep_content = true): string |
|
151 | + { |
|
152 | + $actions = array(); |
|
153 | + |
|
154 | + if ($this->caps_handler->userCanEditQuestionGroup($question_group)) { |
|
155 | + $actions['edit'] = $this->getActionLink( |
|
156 | + $this->getActionUrl($question_group, self::ACTION_EDIT), |
|
157 | + esc_html__('Edit', 'event_espresso'), |
|
158 | + esc_attr__('Edit Question Group', 'event_espresso') |
|
159 | + ); |
|
160 | + } |
|
161 | + if ( |
|
162 | + $question_group->get('QSG_system') < 1 |
|
163 | + && $this->_view != 'trash' |
|
164 | + && $this->caps_handler->userCanEditQuestionGroup($question_group) |
|
165 | + ) { |
|
166 | + $actions['delete'] = $this->getActionLink( |
|
167 | + $this->getActionUrl($question_group, self::ACTION_TRASH), |
|
168 | + esc_html__('Trash', 'event_espresso'), |
|
169 | + esc_attr__('Trash Question Group', 'event_espresso') |
|
170 | + ); |
|
171 | + } |
|
172 | + |
|
173 | + if ($this->_view == 'trash') { |
|
174 | + if ($this->caps_handler->userCanRestoreQuestionGroup($question_group)) { |
|
175 | + $actions['restore'] = $this->getActionLink( |
|
176 | + $this->getActionUrl($question_group, self::ACTION_RESTORE), |
|
177 | + esc_html__('Restore', 'event_espresso'), |
|
178 | + esc_attr__('Restore Question Group', 'event_espresso') |
|
179 | + ); |
|
180 | + } |
|
181 | + |
|
182 | + if ( |
|
183 | + ! $question_group->has_questions_with_answers() |
|
184 | + && $this->caps_handler->userCanDeleteQuestionGroup($question_group) |
|
185 | + ) { |
|
186 | + $actions['delete'] = $this->getActionLink( |
|
187 | + $this->getActionUrl($question_group, self::ACTION_DELETE), |
|
188 | + esc_html__('Delete Permanently', 'event_espresso'), |
|
189 | + esc_attr__('Delete Question Group Permanently', 'event_espresso') |
|
190 | + ); |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + $content = $this->caps_handler->userCanEditQuestionGroup($question_group) |
|
195 | + ? $this->getActionLink( |
|
196 | + $this->getActionUrl($question_group, self::ACTION_EDIT), |
|
197 | + $question_group->name(), |
|
198 | + esc_attr__('Edit Question Group', 'event_espresso'), |
|
199 | + 'row-title' |
|
200 | + ) |
|
201 | + : $question_group->name(); |
|
202 | + $content .= $this->row_actions($actions); |
|
203 | + |
|
204 | + return $prep_content ? $this->columnContent('name', $content) : $content; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * @param EE_Question_Group $question_group |
|
210 | + * @param $action |
|
211 | + * @return string |
|
212 | + * @throws EE_Error |
|
213 | + * @throws ReflectionException |
|
214 | + * @since $VID:$ |
|
215 | + */ |
|
216 | + protected function getActionUrl(EE_Question_Group $question_group, $action): string |
|
217 | + { |
|
218 | + if (! in_array($action, self::$actions)) { |
|
219 | + throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
220 | + } |
|
221 | + return EE_Admin_Page::add_query_args_and_nonce( |
|
222 | + [ |
|
223 | + 'action' => "{$action}_question_group", |
|
224 | + 'QSG_ID' => $question_group->ID(), |
|
225 | + 'noheader' => $action !== self::ACTION_EDIT, |
|
226 | + ], |
|
227 | + EE_FORMS_ADMIN_URL |
|
228 | + ); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + public function column_identifier(EE_Question_Group $question_group): string |
|
233 | + { |
|
234 | + return $this->columnContent('identifier', $question_group->identifier()); |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + public function column_description(EE_Question_Group $question_group): string |
|
239 | + { |
|
240 | + return $this->columnContent('description', $question_group->desc()); |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + public function column_show_group_name(EE_Question_Group $question_group): string |
|
245 | + { |
|
246 | + return $this->columnContent('show_group_name', $this->_yes_no[ $question_group->show_group_name() ]); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + public function column_show_group_desc(EE_Question_Group $question_group): string |
|
251 | + { |
|
252 | + return $this->columnContent('show_group_desc', $this->_yes_no[ $question_group->show_group_desc() ]); |
|
253 | + } |
|
254 | 254 | } |
@@ -16,255 +16,255 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class EE_Event_Registrations_List_Table extends EE_Admin_List_Table |
18 | 18 | { |
19 | - /** |
|
20 | - * @var RequestInterface |
|
21 | - */ |
|
22 | - protected $request; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var Extend_Registrations_Admin_Page |
|
26 | - */ |
|
27 | - protected $_admin_page; |
|
28 | - |
|
29 | - /** |
|
30 | - * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
31 | - * |
|
32 | - * @var DatetimesForEventCheckIn |
|
33 | - */ |
|
34 | - protected $datetimes_for_event; |
|
35 | - |
|
36 | - /** |
|
37 | - * The DTT_ID if the current view has a specified datetime. |
|
38 | - * |
|
39 | - * @var int |
|
40 | - */ |
|
41 | - protected $datetime_id = 0; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var EE_Datetime |
|
45 | - */ |
|
46 | - protected $datetime; |
|
47 | - |
|
48 | - /** |
|
49 | - * The event ID if one is specified in the request |
|
50 | - * |
|
51 | - * @var int |
|
52 | - */ |
|
53 | - protected $event_id = 0; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var EE_Event |
|
57 | - */ |
|
58 | - protected $event; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var DatetimesForEventCheckIn |
|
62 | - */ |
|
63 | - protected $datetimes_for_current_row; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var bool |
|
67 | - */ |
|
68 | - protected $hide_expired; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var bool |
|
72 | - */ |
|
73 | - protected $hide_upcoming; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var array |
|
77 | - * @since 4.10.31.p |
|
78 | - */ |
|
79 | - protected $_status; |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * EE_Event_Registrations_List_Table constructor. |
|
84 | - * |
|
85 | - * @param Registrations_Admin_Page $admin_page |
|
86 | - * @throws EE_Error |
|
87 | - * @throws ReflectionException |
|
88 | - */ |
|
89 | - public function __construct($admin_page) |
|
90 | - { |
|
91 | - $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
92 | - $this->resolveRequestVars(); |
|
93 | - parent::__construct($admin_page); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @throws EE_Error |
|
99 | - * @throws ReflectionException |
|
100 | - * @since $VID:$ |
|
101 | - */ |
|
102 | - private function resolveRequestVars() |
|
103 | - { |
|
104 | - $this->event_id = $this->request->getRequestParam('event_id', 0, 'int'); |
|
105 | - $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id); |
|
106 | - // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
107 | - $datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
108 | - $this->datetime_id = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
109 | - // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
110 | - $this->datetime_id = $this->request->getRequestParam( |
|
111 | - 'DTT_ID', |
|
112 | - $this->datetime_id, |
|
113 | - 'int' |
|
114 | - ); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @throws EE_Error |
|
120 | - */ |
|
121 | - protected function _setup_data() |
|
122 | - { |
|
123 | - $this->_data = $this->_view !== 'trash' |
|
124 | - ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
125 | - : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
126 | - |
|
127 | - $this->_all_data_count = $this->_view !== 'trash' |
|
128 | - ? $this->_admin_page->get_event_attendees($this->_per_page, true) |
|
129 | - : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @throws ReflectionException |
|
135 | - * @throws EE_Error |
|
136 | - */ |
|
137 | - protected function _set_properties() |
|
138 | - { |
|
139 | - $return_url = $this->getReturnUrl(); |
|
140 | - |
|
141 | - $this->_wp_list_args = [ |
|
142 | - 'singular' => esc_html__('registrant', 'event_espresso'), |
|
143 | - 'plural' => esc_html__('registrants', 'event_espresso'), |
|
144 | - 'ajax' => true, |
|
145 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
146 | - ]; |
|
147 | - $columns = []; |
|
148 | - |
|
149 | - $this->_columns = [ |
|
150 | - '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
151 | - 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
152 | - 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
153 | - 'Event' => esc_html__('Event', 'event_espresso'), |
|
154 | - 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
155 | - '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
156 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
157 | - 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
158 | - ]; |
|
159 | - // Add/remove columns when an event has been selected |
|
160 | - if (! empty($this->event_id)) { |
|
161 | - // Render a checkbox column |
|
162 | - $columns['cb'] = '<input type="checkbox" />'; |
|
163 | - $this->_has_checkbox_column = true; |
|
164 | - // Remove the 'Event' column |
|
165 | - unset($this->_columns['Event']); |
|
166 | - $this->setBottomButtons(); |
|
167 | - } |
|
168 | - $this->_columns = array_merge($columns, $this->_columns); |
|
169 | - $this->_primary_column = '_REG_att_checked_in'; |
|
170 | - |
|
171 | - $csv_report = RegistrationsCsvReportParams::getRequestParams( |
|
172 | - $return_url, |
|
173 | - $this->_req_data, |
|
174 | - $this->event_id, |
|
175 | - $this->datetime_id |
|
176 | - ); |
|
177 | - if (! empty($csv_report)) { |
|
178 | - $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
|
179 | - } |
|
180 | - |
|
181 | - $this->_sortable_columns = [ |
|
182 | - /** |
|
183 | - * Allows users to change the default sort if they wish. |
|
184 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
185 | - * |
|
186 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
187 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
188 | - * for a specific list table you can use the provided reference to this object instance. |
|
189 | - */ |
|
190 | - 'ATT_name' => [ |
|
191 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
192 | - true, |
|
193 | - $this, |
|
194 | - ] |
|
195 | - ? ['ATT_lname' => true] |
|
196 | - : ['ATT_fname' => true], |
|
197 | - 'Event' => ['Event.EVT_name' => false], |
|
198 | - ]; |
|
199 | - $this->_hidden_columns = []; |
|
200 | - $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
201 | - if ($this->event instanceof EE_Event) { |
|
202 | - $this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event); |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * @param EE_Registration $item |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - protected function _get_row_class($item): string |
|
212 | - { |
|
213 | - $class = parent::_get_row_class($item); |
|
214 | - if ($this->_has_checkbox_column) { |
|
215 | - $class .= ' has-checkbox-column'; |
|
216 | - } |
|
217 | - return $class; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @return array |
|
223 | - * @throws EE_Error |
|
224 | - * @throws ReflectionException |
|
225 | - */ |
|
226 | - protected function _get_table_filters() |
|
227 | - { |
|
228 | - $filters = []; |
|
229 | - $this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool'); |
|
230 | - $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool'); |
|
231 | - $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
232 | - $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
233 | - // get datetimes for ALL active events (note possible capability restrictions) |
|
234 | - $events = $this->datetimes_for_event->getAllEvents(); |
|
235 | - $event_options[] = [ |
|
236 | - 'id' => 0, |
|
237 | - 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
238 | - ]; |
|
239 | - foreach ($events as $event) { |
|
240 | - // any registrations for this event? |
|
241 | - if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
242 | - continue; |
|
243 | - } |
|
244 | - $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
245 | - $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
246 | - |
|
247 | - $event_options[] = [ |
|
248 | - 'id' => $event->ID(), |
|
249 | - 'text' => apply_filters( |
|
250 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
251 | - $event->name(), |
|
252 | - $event |
|
253 | - ), |
|
254 | - 'class' => $expired_class . $upcoming_class, |
|
255 | - ]; |
|
256 | - if ($event->ID() === $this->event_id) { |
|
257 | - $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
258 | - $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
259 | - $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
260 | - $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
261 | - } |
|
262 | - } |
|
263 | - |
|
264 | - $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
265 | - $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
266 | - |
|
267 | - $filters[] = ' |
|
19 | + /** |
|
20 | + * @var RequestInterface |
|
21 | + */ |
|
22 | + protected $request; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var Extend_Registrations_Admin_Page |
|
26 | + */ |
|
27 | + protected $_admin_page; |
|
28 | + |
|
29 | + /** |
|
30 | + * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
31 | + * |
|
32 | + * @var DatetimesForEventCheckIn |
|
33 | + */ |
|
34 | + protected $datetimes_for_event; |
|
35 | + |
|
36 | + /** |
|
37 | + * The DTT_ID if the current view has a specified datetime. |
|
38 | + * |
|
39 | + * @var int |
|
40 | + */ |
|
41 | + protected $datetime_id = 0; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var EE_Datetime |
|
45 | + */ |
|
46 | + protected $datetime; |
|
47 | + |
|
48 | + /** |
|
49 | + * The event ID if one is specified in the request |
|
50 | + * |
|
51 | + * @var int |
|
52 | + */ |
|
53 | + protected $event_id = 0; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var EE_Event |
|
57 | + */ |
|
58 | + protected $event; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var DatetimesForEventCheckIn |
|
62 | + */ |
|
63 | + protected $datetimes_for_current_row; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var bool |
|
67 | + */ |
|
68 | + protected $hide_expired; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var bool |
|
72 | + */ |
|
73 | + protected $hide_upcoming; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var array |
|
77 | + * @since 4.10.31.p |
|
78 | + */ |
|
79 | + protected $_status; |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * EE_Event_Registrations_List_Table constructor. |
|
84 | + * |
|
85 | + * @param Registrations_Admin_Page $admin_page |
|
86 | + * @throws EE_Error |
|
87 | + * @throws ReflectionException |
|
88 | + */ |
|
89 | + public function __construct($admin_page) |
|
90 | + { |
|
91 | + $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
92 | + $this->resolveRequestVars(); |
|
93 | + parent::__construct($admin_page); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @throws EE_Error |
|
99 | + * @throws ReflectionException |
|
100 | + * @since $VID:$ |
|
101 | + */ |
|
102 | + private function resolveRequestVars() |
|
103 | + { |
|
104 | + $this->event_id = $this->request->getRequestParam('event_id', 0, 'int'); |
|
105 | + $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id); |
|
106 | + // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
107 | + $datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
108 | + $this->datetime_id = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
109 | + // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
110 | + $this->datetime_id = $this->request->getRequestParam( |
|
111 | + 'DTT_ID', |
|
112 | + $this->datetime_id, |
|
113 | + 'int' |
|
114 | + ); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @throws EE_Error |
|
120 | + */ |
|
121 | + protected function _setup_data() |
|
122 | + { |
|
123 | + $this->_data = $this->_view !== 'trash' |
|
124 | + ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
125 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
126 | + |
|
127 | + $this->_all_data_count = $this->_view !== 'trash' |
|
128 | + ? $this->_admin_page->get_event_attendees($this->_per_page, true) |
|
129 | + : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @throws ReflectionException |
|
135 | + * @throws EE_Error |
|
136 | + */ |
|
137 | + protected function _set_properties() |
|
138 | + { |
|
139 | + $return_url = $this->getReturnUrl(); |
|
140 | + |
|
141 | + $this->_wp_list_args = [ |
|
142 | + 'singular' => esc_html__('registrant', 'event_espresso'), |
|
143 | + 'plural' => esc_html__('registrants', 'event_espresso'), |
|
144 | + 'ajax' => true, |
|
145 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
146 | + ]; |
|
147 | + $columns = []; |
|
148 | + |
|
149 | + $this->_columns = [ |
|
150 | + '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
151 | + 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
152 | + 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
153 | + 'Event' => esc_html__('Event', 'event_espresso'), |
|
154 | + 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
155 | + '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
156 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
157 | + 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
158 | + ]; |
|
159 | + // Add/remove columns when an event has been selected |
|
160 | + if (! empty($this->event_id)) { |
|
161 | + // Render a checkbox column |
|
162 | + $columns['cb'] = '<input type="checkbox" />'; |
|
163 | + $this->_has_checkbox_column = true; |
|
164 | + // Remove the 'Event' column |
|
165 | + unset($this->_columns['Event']); |
|
166 | + $this->setBottomButtons(); |
|
167 | + } |
|
168 | + $this->_columns = array_merge($columns, $this->_columns); |
|
169 | + $this->_primary_column = '_REG_att_checked_in'; |
|
170 | + |
|
171 | + $csv_report = RegistrationsCsvReportParams::getRequestParams( |
|
172 | + $return_url, |
|
173 | + $this->_req_data, |
|
174 | + $this->event_id, |
|
175 | + $this->datetime_id |
|
176 | + ); |
|
177 | + if (! empty($csv_report)) { |
|
178 | + $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
|
179 | + } |
|
180 | + |
|
181 | + $this->_sortable_columns = [ |
|
182 | + /** |
|
183 | + * Allows users to change the default sort if they wish. |
|
184 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
185 | + * |
|
186 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
187 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
188 | + * for a specific list table you can use the provided reference to this object instance. |
|
189 | + */ |
|
190 | + 'ATT_name' => [ |
|
191 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
192 | + true, |
|
193 | + $this, |
|
194 | + ] |
|
195 | + ? ['ATT_lname' => true] |
|
196 | + : ['ATT_fname' => true], |
|
197 | + 'Event' => ['Event.EVT_name' => false], |
|
198 | + ]; |
|
199 | + $this->_hidden_columns = []; |
|
200 | + $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
201 | + if ($this->event instanceof EE_Event) { |
|
202 | + $this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event); |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * @param EE_Registration $item |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + protected function _get_row_class($item): string |
|
212 | + { |
|
213 | + $class = parent::_get_row_class($item); |
|
214 | + if ($this->_has_checkbox_column) { |
|
215 | + $class .= ' has-checkbox-column'; |
|
216 | + } |
|
217 | + return $class; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @return array |
|
223 | + * @throws EE_Error |
|
224 | + * @throws ReflectionException |
|
225 | + */ |
|
226 | + protected function _get_table_filters() |
|
227 | + { |
|
228 | + $filters = []; |
|
229 | + $this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool'); |
|
230 | + $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool'); |
|
231 | + $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
232 | + $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
233 | + // get datetimes for ALL active events (note possible capability restrictions) |
|
234 | + $events = $this->datetimes_for_event->getAllEvents(); |
|
235 | + $event_options[] = [ |
|
236 | + 'id' => 0, |
|
237 | + 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
238 | + ]; |
|
239 | + foreach ($events as $event) { |
|
240 | + // any registrations for this event? |
|
241 | + if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
242 | + continue; |
|
243 | + } |
|
244 | + $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
245 | + $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
246 | + |
|
247 | + $event_options[] = [ |
|
248 | + 'id' => $event->ID(), |
|
249 | + 'text' => apply_filters( |
|
250 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
251 | + $event->name(), |
|
252 | + $event |
|
253 | + ), |
|
254 | + 'class' => $expired_class . $upcoming_class, |
|
255 | + ]; |
|
256 | + if ($event->ID() === $this->event_id) { |
|
257 | + $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
258 | + $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
259 | + $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
260 | + $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
261 | + } |
|
262 | + } |
|
263 | + |
|
264 | + $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
265 | + $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
266 | + |
|
267 | + $filters[] = ' |
|
268 | 268 | <div class="ee-event-filter__wrapper"> |
269 | 269 | <label class="ee-event-filter-main-label"> |
270 | 270 | ' . esc_html__('Check-in Status for', 'event_espresso') . ' |
@@ -273,439 +273,439 @@ discard block |
||
273 | 273 | <span class="ee-event-selector"> |
274 | 274 | <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label> |
275 | 275 | ' . EEH_Form_Fields::select_input( |
276 | - 'event_id', |
|
277 | - $event_options, |
|
278 | - $this->event_id, |
|
279 | - '', |
|
280 | - $select_class |
|
281 | - ) . ' |
|
276 | + 'event_id', |
|
277 | + $event_options, |
|
278 | + $this->event_id, |
|
279 | + '', |
|
280 | + $select_class |
|
281 | + ) . ' |
|
282 | 282 | </span>'; |
283 | - // DTT datetimes filter |
|
284 | - $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
|
285 | - $hide_upcoming_checked === 'checked' |
|
286 | - ); |
|
287 | - if (count($datetimes_for_event) > 1) { |
|
288 | - $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
289 | - foreach ($datetimes_for_event as $datetime) { |
|
290 | - if ($datetime instanceof EE_Datetime) { |
|
291 | - $datetime_string = $datetime->name(); |
|
292 | - $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
293 | - $datetime_string .= $datetime->date_and_time_range(); |
|
294 | - $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
295 | - $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
296 | - $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
297 | - // now put it all together |
|
298 | - $datetimes[ $datetime->ID() ] = $datetime_string; |
|
299 | - } |
|
300 | - } |
|
301 | - $filters[] = ' |
|
283 | + // DTT datetimes filter |
|
284 | + $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
|
285 | + $hide_upcoming_checked === 'checked' |
|
286 | + ); |
|
287 | + if (count($datetimes_for_event) > 1) { |
|
288 | + $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
289 | + foreach ($datetimes_for_event as $datetime) { |
|
290 | + if ($datetime instanceof EE_Datetime) { |
|
291 | + $datetime_string = $datetime->name(); |
|
292 | + $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
293 | + $datetime_string .= $datetime->date_and_time_range(); |
|
294 | + $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
295 | + $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
296 | + $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
297 | + // now put it all together |
|
298 | + $datetimes[ $datetime->ID() ] = $datetime_string; |
|
299 | + } |
|
300 | + } |
|
301 | + $filters[] = ' |
|
302 | 302 | <span class="ee-datetime-selector"> |
303 | 303 | <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label> |
304 | 304 | ' . EEH_Form_Fields::select_input( |
305 | - 'DTT_ID', |
|
306 | - $datetimes, |
|
307 | - $this->datetime_id |
|
308 | - ) . ' |
|
305 | + 'DTT_ID', |
|
306 | + $datetimes, |
|
307 | + $this->datetime_id |
|
308 | + ) . ' |
|
309 | 309 | </span>'; |
310 | - } |
|
311 | - $filters[] = ' |
|
310 | + } |
|
311 | + $filters[] = ' |
|
312 | 312 | <span class="ee-hide-upcoming-check"> |
313 | 313 | <label for="js-ee-hide-upcoming-events"> |
314 | 314 | <input type="checkbox" id="js-ee-hide-upcoming-events" name="hide_upcoming" ' |
315 | - . $hide_upcoming_checked |
|
316 | - . '> |
|
315 | + . $hide_upcoming_checked |
|
316 | + . '> |
|
317 | 317 | ' |
318 | - . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
319 | - . ' |
|
318 | + . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
319 | + . ' |
|
320 | 320 | </label> |
321 | 321 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" aria-label="' |
322 | - . esc_html__( |
|
323 | - 'Will not display events with start dates in the future (ie: have not yet begun)', |
|
324 | - 'event_espresso' |
|
325 | - ) |
|
326 | - . '"></span> |
|
322 | + . esc_html__( |
|
323 | + 'Will not display events with start dates in the future (ie: have not yet begun)', |
|
324 | + 'event_espresso' |
|
325 | + ) |
|
326 | + . '"></span> |
|
327 | 327 | </span> |
328 | 328 | <span class="ee-hide-expired-check"> |
329 | 329 | <label for="js-ee-hide-expired-events"> |
330 | 330 | <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" ' |
331 | - . $hide_expired_checked |
|
332 | - . '> |
|
331 | + . $hide_expired_checked |
|
332 | + . '> |
|
333 | 333 | ' |
334 | - . esc_html__('Hide Expired Events', 'event_espresso') |
|
335 | - . ' |
|
334 | + . esc_html__('Hide Expired Events', 'event_espresso') |
|
335 | + . ' |
|
336 | 336 | </label> |
337 | 337 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" aria-label="' |
338 | - . esc_html__( |
|
339 | - 'Will not display events with end dates in the past (ie: have already finished)', |
|
340 | - 'event_espresso' |
|
341 | - ) |
|
342 | - . '"></span> |
|
338 | + . esc_html__( |
|
339 | + 'Will not display events with end dates in the past (ie: have already finished)', |
|
340 | + 'event_espresso' |
|
341 | + ) |
|
342 | + . '"></span> |
|
343 | 343 | </span> |
344 | 344 | </div> |
345 | 345 | </div>'; |
346 | - return $filters; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * @throws EE_Error |
|
352 | - * @throws ReflectionException |
|
353 | - */ |
|
354 | - protected function _add_view_counts() |
|
355 | - { |
|
356 | - $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * @return int |
|
362 | - * @throws EE_Error |
|
363 | - * @throws ReflectionException |
|
364 | - */ |
|
365 | - protected function _get_total_event_attendees(): int |
|
366 | - { |
|
367 | - $query_params = []; |
|
368 | - if ($this->event_id) { |
|
369 | - $query_params[0]['EVT_ID'] = $this->event_id; |
|
370 | - } |
|
371 | - // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
372 | - if ($this->datetime_id) { |
|
373 | - $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
|
374 | - } |
|
375 | - $status_ids_array = apply_filters( |
|
376 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
377 | - [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
|
378 | - ); |
|
379 | - $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
380 | - return EEM_Registration::instance()->count($query_params); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * @param EE_Registration $item |
|
386 | - * @return string |
|
387 | - * @throws EE_Error |
|
388 | - * @throws ReflectionException |
|
389 | - */ |
|
390 | - public function column_cb($item): string |
|
391 | - { |
|
392 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * column_REG_att_checked_in |
|
398 | - * |
|
399 | - * @param EE_Registration $registration |
|
400 | - * @return string |
|
401 | - * @throws EE_Error |
|
402 | - * @throws InvalidArgumentException |
|
403 | - * @throws InvalidDataTypeException |
|
404 | - * @throws InvalidInterfaceException |
|
405 | - * @throws ReflectionException |
|
406 | - */ |
|
407 | - public function column__REG_att_checked_in(EE_Registration $registration): string |
|
408 | - { |
|
409 | - // we need a local variable for the datetime for each row |
|
410 | - // (so that we don't pollute state for the entire table) |
|
411 | - // so let's try to get it from the registration's event |
|
412 | - $DTT_ID = $this->datetime_id; |
|
413 | - if (! $DTT_ID) { |
|
414 | - $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
|
415 | - if (count($reg_ticket_datetimes) === 1) { |
|
416 | - $reg_ticket_datetime = reset($reg_ticket_datetimes); |
|
417 | - $DTT_ID = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0; |
|
418 | - } |
|
419 | - } |
|
420 | - |
|
421 | - if (! $DTT_ID) { |
|
422 | - $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
|
423 | - $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
|
424 | - $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
425 | - } |
|
426 | - |
|
427 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
428 | - $registration, |
|
429 | - $DTT_ID |
|
430 | - ); |
|
431 | - |
|
432 | - $aria_label = $checkin_status_dashicon->ariaLabel(); |
|
433 | - $dashicon_class = $checkin_status_dashicon->cssClasses(); |
|
434 | - $attributes = ' onClick="return false"'; |
|
435 | - $button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box'; |
|
436 | - |
|
437 | - if ( |
|
438 | - $DTT_ID |
|
439 | - && EE_Registry::instance()->CAP->current_user_can( |
|
440 | - 'ee_edit_checkin', |
|
441 | - 'espresso_registrations_toggle_checkin_status', |
|
442 | - $registration->ID() |
|
443 | - ) |
|
444 | - ) { |
|
445 | - // overwrite the disabled attribute with data attributes for performing checkin |
|
446 | - $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
447 | - $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
448 | - $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
449 | - $button_class .= ' clickable trigger-checkin'; |
|
450 | - } |
|
451 | - |
|
452 | - $content = ' |
|
346 | + return $filters; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * @throws EE_Error |
|
352 | + * @throws ReflectionException |
|
353 | + */ |
|
354 | + protected function _add_view_counts() |
|
355 | + { |
|
356 | + $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * @return int |
|
362 | + * @throws EE_Error |
|
363 | + * @throws ReflectionException |
|
364 | + */ |
|
365 | + protected function _get_total_event_attendees(): int |
|
366 | + { |
|
367 | + $query_params = []; |
|
368 | + if ($this->event_id) { |
|
369 | + $query_params[0]['EVT_ID'] = $this->event_id; |
|
370 | + } |
|
371 | + // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
372 | + if ($this->datetime_id) { |
|
373 | + $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
|
374 | + } |
|
375 | + $status_ids_array = apply_filters( |
|
376 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
377 | + [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
|
378 | + ); |
|
379 | + $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
380 | + return EEM_Registration::instance()->count($query_params); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * @param EE_Registration $item |
|
386 | + * @return string |
|
387 | + * @throws EE_Error |
|
388 | + * @throws ReflectionException |
|
389 | + */ |
|
390 | + public function column_cb($item): string |
|
391 | + { |
|
392 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * column_REG_att_checked_in |
|
398 | + * |
|
399 | + * @param EE_Registration $registration |
|
400 | + * @return string |
|
401 | + * @throws EE_Error |
|
402 | + * @throws InvalidArgumentException |
|
403 | + * @throws InvalidDataTypeException |
|
404 | + * @throws InvalidInterfaceException |
|
405 | + * @throws ReflectionException |
|
406 | + */ |
|
407 | + public function column__REG_att_checked_in(EE_Registration $registration): string |
|
408 | + { |
|
409 | + // we need a local variable for the datetime for each row |
|
410 | + // (so that we don't pollute state for the entire table) |
|
411 | + // so let's try to get it from the registration's event |
|
412 | + $DTT_ID = $this->datetime_id; |
|
413 | + if (! $DTT_ID) { |
|
414 | + $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
|
415 | + if (count($reg_ticket_datetimes) === 1) { |
|
416 | + $reg_ticket_datetime = reset($reg_ticket_datetimes); |
|
417 | + $DTT_ID = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0; |
|
418 | + } |
|
419 | + } |
|
420 | + |
|
421 | + if (! $DTT_ID) { |
|
422 | + $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
|
423 | + $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
|
424 | + $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
425 | + } |
|
426 | + |
|
427 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
428 | + $registration, |
|
429 | + $DTT_ID |
|
430 | + ); |
|
431 | + |
|
432 | + $aria_label = $checkin_status_dashicon->ariaLabel(); |
|
433 | + $dashicon_class = $checkin_status_dashicon->cssClasses(); |
|
434 | + $attributes = ' onClick="return false"'; |
|
435 | + $button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box'; |
|
436 | + |
|
437 | + if ( |
|
438 | + $DTT_ID |
|
439 | + && EE_Registry::instance()->CAP->current_user_can( |
|
440 | + 'ee_edit_checkin', |
|
441 | + 'espresso_registrations_toggle_checkin_status', |
|
442 | + $registration->ID() |
|
443 | + ) |
|
444 | + ) { |
|
445 | + // overwrite the disabled attribute with data attributes for performing checkin |
|
446 | + $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
447 | + $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
448 | + $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
449 | + $button_class .= ' clickable trigger-checkin'; |
|
450 | + } |
|
451 | + |
|
452 | + $content = ' |
|
453 | 453 | <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '> |
454 | 454 | <span class="' . $dashicon_class . '" ></span> |
455 | 455 | </button> |
456 | 456 | <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>'; |
457 | - return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * @param EE_Registration $registration |
|
463 | - * @return string |
|
464 | - * @throws EE_Error |
|
465 | - * @throws ReflectionException |
|
466 | - */ |
|
467 | - public function column_ATT_name(EE_Registration $registration): string |
|
468 | - { |
|
469 | - $attendee = $registration->attendee(); |
|
470 | - if (! $attendee instanceof EE_Attendee) { |
|
471 | - return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
472 | - } |
|
473 | - // edit attendee link |
|
474 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
475 | - ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
476 | - REG_ADMIN_URL |
|
477 | - ); |
|
478 | - $name_link = ' |
|
457 | + return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * @param EE_Registration $registration |
|
463 | + * @return string |
|
464 | + * @throws EE_Error |
|
465 | + * @throws ReflectionException |
|
466 | + */ |
|
467 | + public function column_ATT_name(EE_Registration $registration): string |
|
468 | + { |
|
469 | + $attendee = $registration->attendee(); |
|
470 | + if (! $attendee instanceof EE_Attendee) { |
|
471 | + return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
472 | + } |
|
473 | + // edit attendee link |
|
474 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
475 | + ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
476 | + REG_ADMIN_URL |
|
477 | + ); |
|
478 | + $name_link = ' |
|
479 | 479 | <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" |
480 | 480 | aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '"> |
481 | 481 | </span>'; |
482 | - $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
483 | - 'ee_edit_contacts', |
|
484 | - 'espresso_registrations_edit_attendee' |
|
485 | - ) |
|
486 | - ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
487 | - 'View Registration Details', |
|
488 | - 'event_espresso' |
|
489 | - ) . '">' |
|
490 | - . $registration->attendee()->full_name() |
|
491 | - . '</a>' |
|
492 | - : $registration->attendee()->full_name(); |
|
493 | - $name_link .= $registration->count() === 1 |
|
494 | - ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
495 | - : ''; |
|
496 | - // add group details |
|
497 | - $name_link .= ' ' . sprintf( |
|
498 | - esc_html__('(%s of %s)', 'event_espresso'), |
|
499 | - $registration->count(), |
|
500 | - $registration->group_size() |
|
501 | - ); |
|
502 | - // add regcode |
|
503 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
504 | - ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
505 | - REG_ADMIN_URL |
|
506 | - ); |
|
507 | - $name_link .= '<br>'; |
|
508 | - $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
509 | - 'ee_read_registration', |
|
510 | - 'view_registration', |
|
511 | - $registration->ID() |
|
512 | - ) |
|
513 | - ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
514 | - 'View Registration Details', |
|
515 | - 'event_espresso' |
|
516 | - ) . '">' |
|
517 | - . $registration->reg_code() |
|
518 | - . '</a>' |
|
519 | - : $registration->reg_code(); |
|
520 | - |
|
521 | - $actions = []; |
|
522 | - if ( |
|
523 | - $this->datetime_id |
|
524 | - && EE_Registry::instance()->CAP->current_user_can( |
|
525 | - 'ee_read_checkins', |
|
526 | - 'espresso_registrations_registration_checkins' |
|
527 | - ) |
|
528 | - ) { |
|
529 | - $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
530 | - ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id], |
|
531 | - REG_ADMIN_URL |
|
532 | - ); |
|
533 | - // get the timestamps for this registration's checkins, related to the selected datetime |
|
534 | - /** @var EE_Checkin[] $checkins */ |
|
535 | - $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
|
536 | - if (! empty($checkins)) { |
|
537 | - // get the last timestamp |
|
538 | - $last_checkin = end($checkins); |
|
539 | - // get timestamp string |
|
540 | - $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
|
541 | - $actions['checkin'] = ' |
|
482 | + $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
483 | + 'ee_edit_contacts', |
|
484 | + 'espresso_registrations_edit_attendee' |
|
485 | + ) |
|
486 | + ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
487 | + 'View Registration Details', |
|
488 | + 'event_espresso' |
|
489 | + ) . '">' |
|
490 | + . $registration->attendee()->full_name() |
|
491 | + . '</a>' |
|
492 | + : $registration->attendee()->full_name(); |
|
493 | + $name_link .= $registration->count() === 1 |
|
494 | + ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
495 | + : ''; |
|
496 | + // add group details |
|
497 | + $name_link .= ' ' . sprintf( |
|
498 | + esc_html__('(%s of %s)', 'event_espresso'), |
|
499 | + $registration->count(), |
|
500 | + $registration->group_size() |
|
501 | + ); |
|
502 | + // add regcode |
|
503 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
504 | + ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
505 | + REG_ADMIN_URL |
|
506 | + ); |
|
507 | + $name_link .= '<br>'; |
|
508 | + $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
509 | + 'ee_read_registration', |
|
510 | + 'view_registration', |
|
511 | + $registration->ID() |
|
512 | + ) |
|
513 | + ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
514 | + 'View Registration Details', |
|
515 | + 'event_espresso' |
|
516 | + ) . '">' |
|
517 | + . $registration->reg_code() |
|
518 | + . '</a>' |
|
519 | + : $registration->reg_code(); |
|
520 | + |
|
521 | + $actions = []; |
|
522 | + if ( |
|
523 | + $this->datetime_id |
|
524 | + && EE_Registry::instance()->CAP->current_user_can( |
|
525 | + 'ee_read_checkins', |
|
526 | + 'espresso_registrations_registration_checkins' |
|
527 | + ) |
|
528 | + ) { |
|
529 | + $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
530 | + ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id], |
|
531 | + REG_ADMIN_URL |
|
532 | + ); |
|
533 | + // get the timestamps for this registration's checkins, related to the selected datetime |
|
534 | + /** @var EE_Checkin[] $checkins */ |
|
535 | + $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
|
536 | + if (! empty($checkins)) { |
|
537 | + // get the last timestamp |
|
538 | + $last_checkin = end($checkins); |
|
539 | + // get timestamp string |
|
540 | + $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
|
541 | + $actions['checkin'] = ' |
|
542 | 542 | <a class="ee-aria-tooltip" |
543 | 543 | href="' . $checkin_list_url . '" |
544 | 544 | aria-label="' . esc_attr__( |
545 | - 'View this registrant\'s check-ins/checkouts for the datetime', |
|
546 | - 'event_espresso' |
|
547 | - ) . '" |
|
545 | + 'View this registrant\'s check-ins/checkouts for the datetime', |
|
546 | + 'event_espresso' |
|
547 | + ) . '" |
|
548 | 548 | > |
549 | 549 | ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . ' |
550 | 550 | </a>'; |
551 | - } |
|
552 | - } |
|
553 | - $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
554 | - ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
555 | - : $name_link; |
|
556 | - return $this->columnContent('ATT_name', $content); |
|
557 | - } |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * @param EE_Registration $registration |
|
562 | - * @return string |
|
563 | - * @throws EE_Error |
|
564 | - * @throws EE_Error |
|
565 | - * @throws ReflectionException |
|
566 | - */ |
|
567 | - public function column_ATT_email(EE_Registration $registration): string |
|
568 | - { |
|
569 | - $attendee = $registration->attendee(); |
|
570 | - $content = $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
571 | - return $this->columnContent('ATT_email', $content); |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - /** |
|
576 | - * @param EE_Registration $registration |
|
577 | - * @return string |
|
578 | - * @throws EE_Error |
|
579 | - * @throws ReflectionException |
|
580 | - */ |
|
581 | - public function column_Event(EE_Registration $registration): string |
|
582 | - { |
|
583 | - try { |
|
584 | - $event = $this->event instanceof EE_Event ? $this->event : $registration->event(); |
|
585 | - $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
586 | - ['action' => 'event_registrations', 'event_id' => $event->ID()], |
|
587 | - REG_ADMIN_URL |
|
588 | - ); |
|
589 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
590 | - 'ee_read_checkins', |
|
591 | - 'espresso_registrations_registration_checkins' |
|
592 | - ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
593 | - . esc_attr__( |
|
594 | - 'View Checkins for this Event', |
|
595 | - 'event_espresso' |
|
596 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
597 | - } catch (EntityNotFoundException $e) { |
|
598 | - $content = esc_html__('Unknown', 'event_espresso'); |
|
599 | - } |
|
600 | - return $this->columnContent('Event', $content); |
|
601 | - } |
|
602 | - |
|
603 | - |
|
604 | - /** |
|
605 | - * @param EE_Registration $registration |
|
606 | - * @return string |
|
607 | - * @throws EE_Error |
|
608 | - * @throws ReflectionException |
|
609 | - */ |
|
610 | - public function column_PRC_name(EE_Registration $registration): string |
|
611 | - { |
|
612 | - $content = $registration->ticket() instanceof EE_Ticket |
|
613 | - ? $registration->ticket()->name() |
|
614 | - : esc_html__( |
|
615 | - "Unknown", |
|
616 | - "event_espresso" |
|
617 | - ); |
|
618 | - return $this->columnContent('PRC_name', $content); |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - /** |
|
623 | - * column_REG_final_price |
|
624 | - * |
|
625 | - * @param EE_Registration $registration |
|
626 | - * @return string |
|
627 | - * @throws EE_Error |
|
628 | - */ |
|
629 | - public function column__REG_final_price(EE_Registration $registration): string |
|
630 | - { |
|
631 | - return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end'); |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - /** |
|
636 | - * column_TXN_paid |
|
637 | - * |
|
638 | - * @param EE_Registration $registration |
|
639 | - * @return string |
|
640 | - * @throws EE_Error |
|
641 | - * @throws ReflectionException |
|
642 | - */ |
|
643 | - public function column_TXN_paid(EE_Registration $registration): string |
|
644 | - { |
|
645 | - $content = ''; |
|
646 | - if ($registration->count() === 1) { |
|
647 | - if ($registration->transaction()->paid() >= $registration->transaction()->total()) { |
|
648 | - return '<div class="dashicons dashicons-yes green-icon"></div>'; |
|
649 | - } else { |
|
650 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
651 | - ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()], |
|
652 | - TXN_ADMIN_URL |
|
653 | - ); |
|
654 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
655 | - 'ee_read_transaction', |
|
656 | - 'espresso_transactions_view_transaction' |
|
657 | - ) ? ' |
|
551 | + } |
|
552 | + } |
|
553 | + $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
554 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
555 | + : $name_link; |
|
556 | + return $this->columnContent('ATT_name', $content); |
|
557 | + } |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * @param EE_Registration $registration |
|
562 | + * @return string |
|
563 | + * @throws EE_Error |
|
564 | + * @throws EE_Error |
|
565 | + * @throws ReflectionException |
|
566 | + */ |
|
567 | + public function column_ATT_email(EE_Registration $registration): string |
|
568 | + { |
|
569 | + $attendee = $registration->attendee(); |
|
570 | + $content = $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
571 | + return $this->columnContent('ATT_email', $content); |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + /** |
|
576 | + * @param EE_Registration $registration |
|
577 | + * @return string |
|
578 | + * @throws EE_Error |
|
579 | + * @throws ReflectionException |
|
580 | + */ |
|
581 | + public function column_Event(EE_Registration $registration): string |
|
582 | + { |
|
583 | + try { |
|
584 | + $event = $this->event instanceof EE_Event ? $this->event : $registration->event(); |
|
585 | + $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
586 | + ['action' => 'event_registrations', 'event_id' => $event->ID()], |
|
587 | + REG_ADMIN_URL |
|
588 | + ); |
|
589 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
590 | + 'ee_read_checkins', |
|
591 | + 'espresso_registrations_registration_checkins' |
|
592 | + ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
593 | + . esc_attr__( |
|
594 | + 'View Checkins for this Event', |
|
595 | + 'event_espresso' |
|
596 | + ) . '">' . $event->name() . '</a>' : $event->name(); |
|
597 | + } catch (EntityNotFoundException $e) { |
|
598 | + $content = esc_html__('Unknown', 'event_espresso'); |
|
599 | + } |
|
600 | + return $this->columnContent('Event', $content); |
|
601 | + } |
|
602 | + |
|
603 | + |
|
604 | + /** |
|
605 | + * @param EE_Registration $registration |
|
606 | + * @return string |
|
607 | + * @throws EE_Error |
|
608 | + * @throws ReflectionException |
|
609 | + */ |
|
610 | + public function column_PRC_name(EE_Registration $registration): string |
|
611 | + { |
|
612 | + $content = $registration->ticket() instanceof EE_Ticket |
|
613 | + ? $registration->ticket()->name() |
|
614 | + : esc_html__( |
|
615 | + "Unknown", |
|
616 | + "event_espresso" |
|
617 | + ); |
|
618 | + return $this->columnContent('PRC_name', $content); |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * column_REG_final_price |
|
624 | + * |
|
625 | + * @param EE_Registration $registration |
|
626 | + * @return string |
|
627 | + * @throws EE_Error |
|
628 | + */ |
|
629 | + public function column__REG_final_price(EE_Registration $registration): string |
|
630 | + { |
|
631 | + return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end'); |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + /** |
|
636 | + * column_TXN_paid |
|
637 | + * |
|
638 | + * @param EE_Registration $registration |
|
639 | + * @return string |
|
640 | + * @throws EE_Error |
|
641 | + * @throws ReflectionException |
|
642 | + */ |
|
643 | + public function column_TXN_paid(EE_Registration $registration): string |
|
644 | + { |
|
645 | + $content = ''; |
|
646 | + if ($registration->count() === 1) { |
|
647 | + if ($registration->transaction()->paid() >= $registration->transaction()->total()) { |
|
648 | + return '<div class="dashicons dashicons-yes green-icon"></div>'; |
|
649 | + } else { |
|
650 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
651 | + ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()], |
|
652 | + TXN_ADMIN_URL |
|
653 | + ); |
|
654 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
655 | + 'ee_read_transaction', |
|
656 | + 'espresso_transactions_view_transaction' |
|
657 | + ) ? ' |
|
658 | 658 | <a class="ee-aria-tooltip ee-status-color--' |
659 | - . $registration->transaction()->status_ID() |
|
660 | - . '" href="' |
|
661 | - . $view_txn_lnk_url |
|
662 | - . '" aria-label="' |
|
663 | - . esc_attr__('View Transaction', 'event_espresso') |
|
664 | - . '"> |
|
659 | + . $registration->transaction()->status_ID() |
|
660 | + . '" href="' |
|
661 | + . $view_txn_lnk_url |
|
662 | + . '" aria-label="' |
|
663 | + . esc_attr__('View Transaction', 'event_espresso') |
|
664 | + . '"> |
|
665 | 665 | ' |
666 | - . $registration->transaction()->pretty_paid() |
|
667 | - . ' |
|
666 | + . $registration->transaction()->pretty_paid() |
|
667 | + . ' |
|
668 | 668 | </a> |
669 | 669 | ' : $registration->transaction()->pretty_paid(); |
670 | - } |
|
671 | - } |
|
672 | - return $this->columnContent('TXN_paid', $content, 'end'); |
|
673 | - } |
|
674 | - |
|
675 | - |
|
676 | - /** |
|
677 | - * column_TXN_total |
|
678 | - * |
|
679 | - * @param EE_Registration $registration |
|
680 | - * @return string |
|
681 | - * @throws EE_Error |
|
682 | - * @throws ReflectionException |
|
683 | - */ |
|
684 | - public function column_TXN_total(EE_Registration $registration): string |
|
685 | - { |
|
686 | - $content = ''; |
|
687 | - $txn = $registration->transaction(); |
|
688 | - $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL); |
|
689 | - if ($registration->get('REG_count') === 1) { |
|
690 | - $line_total_obj = $txn->total_line_item(); |
|
691 | - $txn_total = $line_total_obj instanceof EE_Line_Item |
|
692 | - ? $line_total_obj->get_pretty('LIN_total') |
|
693 | - : esc_html__( |
|
694 | - 'View Transaction', |
|
695 | - 'event_espresso' |
|
696 | - ); |
|
697 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
698 | - 'ee_read_transaction', |
|
699 | - 'espresso_transactions_view_transaction' |
|
700 | - ) ? '<a class="ee-aria-tooltip" href="' |
|
701 | - . $view_txn_url |
|
702 | - . '" aria-label="' |
|
703 | - . esc_attr__('View Transaction', 'event_espresso') |
|
704 | - . '">' |
|
705 | - . $txn_total |
|
706 | - . '</a>' |
|
707 | - : $txn_total; |
|
708 | - } |
|
709 | - return $this->columnContent('TXN_total', $content, 'end'); |
|
710 | - } |
|
670 | + } |
|
671 | + } |
|
672 | + return $this->columnContent('TXN_paid', $content, 'end'); |
|
673 | + } |
|
674 | + |
|
675 | + |
|
676 | + /** |
|
677 | + * column_TXN_total |
|
678 | + * |
|
679 | + * @param EE_Registration $registration |
|
680 | + * @return string |
|
681 | + * @throws EE_Error |
|
682 | + * @throws ReflectionException |
|
683 | + */ |
|
684 | + public function column_TXN_total(EE_Registration $registration): string |
|
685 | + { |
|
686 | + $content = ''; |
|
687 | + $txn = $registration->transaction(); |
|
688 | + $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL); |
|
689 | + if ($registration->get('REG_count') === 1) { |
|
690 | + $line_total_obj = $txn->total_line_item(); |
|
691 | + $txn_total = $line_total_obj instanceof EE_Line_Item |
|
692 | + ? $line_total_obj->get_pretty('LIN_total') |
|
693 | + : esc_html__( |
|
694 | + 'View Transaction', |
|
695 | + 'event_espresso' |
|
696 | + ); |
|
697 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
698 | + 'ee_read_transaction', |
|
699 | + 'espresso_transactions_view_transaction' |
|
700 | + ) ? '<a class="ee-aria-tooltip" href="' |
|
701 | + . $view_txn_url |
|
702 | + . '" aria-label="' |
|
703 | + . esc_attr__('View Transaction', 'event_espresso') |
|
704 | + . '">' |
|
705 | + . $txn_total |
|
706 | + . '</a>' |
|
707 | + : $txn_total; |
|
708 | + } |
|
709 | + return $this->columnContent('TXN_total', $content, 'end'); |
|
710 | + } |
|
711 | 711 | } |
@@ -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="dashicons dashicons-groups ee-status-color--RAP ee-aria-tooltip" |
65 | 65 | aria-label="' . $approved_registrations . '"></span> |
66 | 66 | <span class="screen-reader-text">' . $approved_registrations . '</span>', |
67 | - 'actions' => $this->actionsColumnHeader(), |
|
68 | - ]; |
|
69 | - $this->addConditionalColumns(); |
|
70 | - $this->_sortable_columns = [ |
|
71 | - 'id' => ['EVT_ID' => true], |
|
72 | - 'name' => ['EVT_name' => false], |
|
73 | - 'author' => ['EVT_wp_user' => false], |
|
74 | - 'venue' => ['Venue.VNU_name' => false], |
|
75 | - 'start_date_time' => ['Datetime.DTT_EVT_start' => false], |
|
76 | - 'reg_begins' => ['Datetime.Ticket.TKT_start_date' => false], |
|
77 | - ]; |
|
78 | - |
|
79 | - $this->_primary_column = 'id'; |
|
80 | - $this->_hidden_columns = ['author', 'event_category']; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @return array |
|
86 | - */ |
|
87 | - protected function _get_table_filters() |
|
88 | - { |
|
89 | - return []; // no filters with decaf |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Setup of views properties. |
|
95 | - * |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - * @throws InvalidInterfaceException |
|
98 | - * @throws InvalidArgumentException |
|
99 | - * @throws EE_Error |
|
100 | - * @throws EE_Error |
|
101 | - * @throws EE_Error |
|
102 | - */ |
|
103 | - protected function _add_view_counts() |
|
104 | - { |
|
105 | - $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
106 | - $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
107 | - if ( |
|
108 | - EE_Registry::instance()->CAP->current_user_can( |
|
109 | - 'ee_delete_events', |
|
110 | - 'espresso_events_trash_events' |
|
111 | - ) |
|
112 | - ) { |
|
113 | - $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
114 | - } |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @param EE_Event $item |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - protected function _get_row_class($item): string |
|
123 | - { |
|
124 | - $class = parent::_get_row_class($item); |
|
125 | - if ($this->_has_checkbox_column) { |
|
126 | - $class .= ' has-checkbox-column'; |
|
127 | - } |
|
128 | - return $class; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @param EE_Event $item |
|
134 | - * @return string |
|
135 | - * @throws EE_Error |
|
136 | - * @throws ReflectionException |
|
137 | - */ |
|
138 | - public function column_cb($item): string |
|
139 | - { |
|
140 | - if (! $item instanceof EE_Event) { |
|
141 | - return ''; |
|
142 | - } |
|
143 | - $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
144 | - $content = sprintf( |
|
145 | - '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
146 | - $item->ID() |
|
147 | - ); |
|
148 | - return $this->columnContent('cb', $content, 'center'); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @param EE_Event $event |
|
154 | - * @return string |
|
155 | - * @throws EE_Error |
|
156 | - * @throws ReflectionException |
|
157 | - */ |
|
158 | - public function column_id(EE_Event $event): string |
|
159 | - { |
|
160 | - $content = '<span class="ee-entity-id">' . $event->ID() . '</span>'; |
|
161 | - $content .= '<span class="show-on-mobile-view-only">'; |
|
162 | - $content .= $this->column_name($event, false); |
|
163 | - $content .= '</span>'; |
|
164 | - return $this->columnContent('id', $content, 'end'); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * @param EE_Event $event |
|
170 | - * @param bool $prep_content |
|
171 | - * @return string |
|
172 | - * @throws EE_Error |
|
173 | - * @throws ReflectionException |
|
174 | - */ |
|
175 | - public function column_name(EE_Event $event, bool $prep_content = true): string |
|
176 | - { |
|
177 | - $edit_query_args = [ |
|
178 | - 'action' => 'edit', |
|
179 | - 'post' => $event->ID(), |
|
180 | - ]; |
|
181 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
182 | - $actions = $this->_column_name_action_setup($event); |
|
183 | - $status = esc_attr($event->get_active_status()); |
|
184 | - $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
185 | - $status_dot = '<span class="ee-status-dot ee-status-bg--' . $status . '"></span>'; |
|
186 | - $visibility = $event->get_visibility_status(); |
|
187 | - $content = ' |
|
67 | + 'actions' => $this->actionsColumnHeader(), |
|
68 | + ]; |
|
69 | + $this->addConditionalColumns(); |
|
70 | + $this->_sortable_columns = [ |
|
71 | + 'id' => ['EVT_ID' => true], |
|
72 | + 'name' => ['EVT_name' => false], |
|
73 | + 'author' => ['EVT_wp_user' => false], |
|
74 | + 'venue' => ['Venue.VNU_name' => false], |
|
75 | + 'start_date_time' => ['Datetime.DTT_EVT_start' => false], |
|
76 | + 'reg_begins' => ['Datetime.Ticket.TKT_start_date' => false], |
|
77 | + ]; |
|
78 | + |
|
79 | + $this->_primary_column = 'id'; |
|
80 | + $this->_hidden_columns = ['author', 'event_category']; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @return array |
|
86 | + */ |
|
87 | + protected function _get_table_filters() |
|
88 | + { |
|
89 | + return []; // no filters with decaf |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Setup of views properties. |
|
95 | + * |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + * @throws InvalidInterfaceException |
|
98 | + * @throws InvalidArgumentException |
|
99 | + * @throws EE_Error |
|
100 | + * @throws EE_Error |
|
101 | + * @throws EE_Error |
|
102 | + */ |
|
103 | + protected function _add_view_counts() |
|
104 | + { |
|
105 | + $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
106 | + $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
107 | + if ( |
|
108 | + EE_Registry::instance()->CAP->current_user_can( |
|
109 | + 'ee_delete_events', |
|
110 | + 'espresso_events_trash_events' |
|
111 | + ) |
|
112 | + ) { |
|
113 | + $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
114 | + } |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @param EE_Event $item |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + protected function _get_row_class($item): string |
|
123 | + { |
|
124 | + $class = parent::_get_row_class($item); |
|
125 | + if ($this->_has_checkbox_column) { |
|
126 | + $class .= ' has-checkbox-column'; |
|
127 | + } |
|
128 | + return $class; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @param EE_Event $item |
|
134 | + * @return string |
|
135 | + * @throws EE_Error |
|
136 | + * @throws ReflectionException |
|
137 | + */ |
|
138 | + public function column_cb($item): string |
|
139 | + { |
|
140 | + if (! $item instanceof EE_Event) { |
|
141 | + return ''; |
|
142 | + } |
|
143 | + $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
144 | + $content = sprintf( |
|
145 | + '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
146 | + $item->ID() |
|
147 | + ); |
|
148 | + return $this->columnContent('cb', $content, 'center'); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @param EE_Event $event |
|
154 | + * @return string |
|
155 | + * @throws EE_Error |
|
156 | + * @throws ReflectionException |
|
157 | + */ |
|
158 | + public function column_id(EE_Event $event): string |
|
159 | + { |
|
160 | + $content = '<span class="ee-entity-id">' . $event->ID() . '</span>'; |
|
161 | + $content .= '<span class="show-on-mobile-view-only">'; |
|
162 | + $content .= $this->column_name($event, false); |
|
163 | + $content .= '</span>'; |
|
164 | + return $this->columnContent('id', $content, 'end'); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * @param EE_Event $event |
|
170 | + * @param bool $prep_content |
|
171 | + * @return string |
|
172 | + * @throws EE_Error |
|
173 | + * @throws ReflectionException |
|
174 | + */ |
|
175 | + public function column_name(EE_Event $event, bool $prep_content = true): string |
|
176 | + { |
|
177 | + $edit_query_args = [ |
|
178 | + 'action' => 'edit', |
|
179 | + 'post' => $event->ID(), |
|
180 | + ]; |
|
181 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
182 | + $actions = $this->_column_name_action_setup($event); |
|
183 | + $status = esc_attr($event->get_active_status()); |
|
184 | + $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
185 | + $status_dot = '<span class="ee-status-dot ee-status-bg--' . $status . '"></span>'; |
|
186 | + $visibility = $event->get_visibility_status(); |
|
187 | + $content = ' |
|
188 | 188 | <div class="ee-layout-row ee-layout-row--fixed"> |
189 | 189 | <a class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" |
190 | 190 | aria-label="' . $pretty_status . '" |
@@ -193,415 +193,415 @@ discard block |
||
193 | 193 | ' . $status_dot . $event->name() . ' |
194 | 194 | </a> |
195 | 195 | ' . ( |
196 | - $visibility |
|
197 | - ? '<span class="ee-event-visibility-status ee-status-text-small">(' . esc_html($visibility) . ')</span>' |
|
198 | - : '' |
|
199 | - ) . ' |
|
196 | + $visibility |
|
197 | + ? '<span class="ee-event-visibility-status ee-status-text-small">(' . esc_html($visibility) . ')</span>' |
|
198 | + : '' |
|
199 | + ) . ' |
|
200 | 200 | </div>'; |
201 | 201 | |
202 | - $content .= $this->row_actions($actions); |
|
203 | - |
|
204 | - return $prep_content ? $this->columnContent('name', $content) : $content; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * Just a method for setting up the actions for the name column |
|
210 | - * |
|
211 | - * @param EE_Event $event |
|
212 | - * @return array array of actions |
|
213 | - * @throws EE_Error |
|
214 | - * @throws InvalidArgumentException |
|
215 | - * @throws InvalidDataTypeException |
|
216 | - * @throws InvalidInterfaceException |
|
217 | - * @throws ReflectionException |
|
218 | - */ |
|
219 | - protected function _column_name_action_setup(EE_Event $event): array |
|
220 | - { |
|
221 | - // todo: remove when attendees is active |
|
222 | - if (! defined('REG_ADMIN_URL')) { |
|
223 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
224 | - } |
|
225 | - $actions = []; |
|
226 | - $restore_event_link = ''; |
|
227 | - $delete_event_link = ''; |
|
228 | - $trash_event_link = ''; |
|
229 | - if ( |
|
230 | - EE_Registry::instance()->CAP->current_user_can( |
|
231 | - 'ee_edit_event', |
|
232 | - 'espresso_events_edit', |
|
233 | - $event->ID() |
|
234 | - ) |
|
235 | - ) { |
|
236 | - $edit_query_args = [ |
|
237 | - 'action' => 'edit', |
|
238 | - 'post' => $event->ID(), |
|
239 | - ]; |
|
240 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
241 | - $actions['edit'] = '<a href="' . $edit_link . '" class="ee-aria-tooltip" ' |
|
242 | - . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
243 | - . esc_html__('Edit', 'event_espresso') |
|
244 | - . '</a>'; |
|
245 | - } |
|
246 | - if ( |
|
247 | - EE_Registry::instance()->CAP->current_user_can( |
|
248 | - 'ee_read_registrations', |
|
249 | - 'espresso_registrations_view_registration' |
|
250 | - ) |
|
251 | - && EE_Registry::instance()->CAP->current_user_can( |
|
252 | - 'ee_read_event', |
|
253 | - 'espresso_registrations_view_registration', |
|
254 | - $event->ID() |
|
255 | - ) |
|
256 | - ) { |
|
257 | - $attendees_query_args = [ |
|
258 | - 'action' => 'default', |
|
259 | - 'event_id' => $event->ID(), |
|
260 | - ]; |
|
261 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
262 | - $actions['attendees'] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip"' |
|
263 | - . ' aria-label="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
264 | - . esc_html__('Registrations', 'event_espresso') |
|
265 | - . '</a>'; |
|
266 | - } |
|
267 | - if ( |
|
268 | - EE_Registry::instance()->CAP->current_user_can( |
|
269 | - 'ee_delete_event', |
|
270 | - 'espresso_events_trash_event', |
|
271 | - $event->ID() |
|
272 | - ) |
|
273 | - ) { |
|
274 | - $trash_event_query_args = [ |
|
275 | - 'action' => 'trash_event', |
|
276 | - 'EVT_ID' => $event->ID(), |
|
277 | - ]; |
|
278 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
279 | - $trash_event_query_args, |
|
280 | - EVENTS_ADMIN_URL |
|
281 | - ); |
|
282 | - } |
|
283 | - if ( |
|
284 | - EE_Registry::instance()->CAP->current_user_can( |
|
285 | - 'ee_delete_event', |
|
286 | - 'espresso_events_restore_event', |
|
287 | - $event->ID() |
|
288 | - ) |
|
289 | - ) { |
|
290 | - $restore_event_query_args = [ |
|
291 | - 'action' => 'restore_event', |
|
292 | - 'EVT_ID' => $event->ID(), |
|
293 | - ]; |
|
294 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
295 | - $restore_event_query_args, |
|
296 | - EVENTS_ADMIN_URL |
|
297 | - ); |
|
298 | - } |
|
299 | - if ( |
|
300 | - EE_Registry::instance()->CAP->current_user_can( |
|
301 | - 'ee_delete_event', |
|
302 | - 'espresso_events_delete_event', |
|
303 | - $event->ID() |
|
304 | - ) |
|
305 | - ) { |
|
306 | - $delete_event_query_args = [ |
|
307 | - 'action' => 'delete_event', |
|
308 | - 'EVT_ID' => $event->ID(), |
|
309 | - ]; |
|
310 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
311 | - $delete_event_query_args, |
|
312 | - EVENTS_ADMIN_URL |
|
313 | - ); |
|
314 | - } |
|
315 | - $view_link = get_permalink($event->ID()); |
|
316 | - $actions['view'] = '<a href="' . $view_link . '" class="ee-aria-tooltip"' |
|
317 | - . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
318 | - . esc_html__('View', 'event_espresso') |
|
319 | - . '</a>'; |
|
320 | - if ($event->get('status') === 'trash') { |
|
321 | - if ( |
|
322 | - EE_Registry::instance()->CAP->current_user_can( |
|
323 | - 'ee_delete_event', |
|
324 | - 'espresso_events_restore_event', |
|
325 | - $event->ID() |
|
326 | - ) |
|
327 | - ) { |
|
328 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" class="ee-aria-tooltip"' |
|
329 | - . ' aria-label="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
330 | - . '">' |
|
331 | - . esc_html__('Restore from Trash', 'event_espresso') |
|
332 | - . '</a>'; |
|
333 | - } |
|
334 | - if ( |
|
335 | - EE_Registry::instance()->CAP->current_user_can( |
|
336 | - 'ee_delete_event', |
|
337 | - 'espresso_events_delete_event', |
|
338 | - $event->ID() |
|
339 | - ) |
|
340 | - ) { |
|
341 | - $actions['delete'] = '<a href="' . $delete_event_link . '" class="ee-aria-tooltip"' |
|
342 | - . ' aria-label="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
343 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
344 | - . '</a>'; |
|
345 | - } |
|
346 | - } else { |
|
347 | - if ( |
|
348 | - EE_Registry::instance()->CAP->current_user_can( |
|
349 | - 'ee_delete_event', |
|
350 | - 'espresso_events_trash_event', |
|
351 | - $event->ID() |
|
352 | - ) |
|
353 | - ) { |
|
354 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '" class="ee-aria-tooltip"' |
|
355 | - . ' aria-label="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
356 | - . esc_html__('Trash', 'event_espresso') |
|
357 | - . '</a>'; |
|
358 | - } |
|
359 | - } |
|
360 | - return $actions; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * @param EE_Event $event |
|
366 | - * @return string |
|
367 | - * @throws EE_Error |
|
368 | - * @throws ReflectionException |
|
369 | - */ |
|
370 | - public function column_author(EE_Event $event): string |
|
371 | - { |
|
372 | - // user author info |
|
373 | - $event_author = get_userdata($event->wp_user()); |
|
374 | - $gravatar = get_avatar($event->wp_user(), '24'); |
|
375 | - // filter link |
|
376 | - $query_args = [ |
|
377 | - 'action' => 'default', |
|
378 | - 'EVT_wp_user' => $event->wp_user(), |
|
379 | - ]; |
|
380 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
381 | - $content = '<div class="ee-layout-row ee-layout-row--fixed">'; |
|
382 | - $content .= $gravatar . ' <a href="' . $filter_url . '" class="ee-aria-tooltip"' |
|
383 | - . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
384 | - . $event_author->display_name |
|
385 | - . '</a>'; |
|
386 | - $content .= '</div>'; |
|
387 | - return $this->columnContent('author', $content); |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * @param EE_Event $event |
|
393 | - * @return string |
|
394 | - * @throws EE_Error |
|
395 | - * @throws ReflectionException |
|
396 | - */ |
|
397 | - public function column_event_category(EE_Event $event): string |
|
398 | - { |
|
399 | - $event_categories = $event->get_all_event_categories(); |
|
400 | - $content = implode( |
|
401 | - ', ', |
|
402 | - array_map( |
|
403 | - function (EE_Term $category) { |
|
404 | - return $category->name(); |
|
405 | - }, |
|
406 | - $event_categories |
|
407 | - ) |
|
408 | - ); |
|
409 | - return $this->columnContent('event_category', $content); |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * @param EE_Event $event |
|
415 | - * @return string |
|
416 | - * @throws EE_Error |
|
417 | - * @throws ReflectionException |
|
418 | - */ |
|
419 | - public function column_venue(EE_Event $event): string |
|
420 | - { |
|
421 | - $venue = $event->get_first_related('Venue'); |
|
422 | - $content = ! empty($venue) |
|
423 | - ? $venue->name() |
|
424 | - : ''; |
|
425 | - return $this->columnContent('venue', $content); |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * @param EE_Event $event |
|
431 | - * @return string |
|
432 | - * @throws EE_Error |
|
433 | - * @throws ReflectionException |
|
434 | - */ |
|
435 | - public function column_start_date_time(EE_Event $event): string |
|
436 | - { |
|
437 | - $content = $this->_dtt instanceof EE_Datetime |
|
438 | - ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
439 | - : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
440 | - return $this->columnContent('start_date_time', $content); |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * @param EE_Event $event |
|
446 | - * @return string |
|
447 | - * @throws EE_Error |
|
448 | - * @throws ReflectionException |
|
449 | - */ |
|
450 | - public function column_reg_begins(EE_Event $event): string |
|
451 | - { |
|
452 | - $reg_start = $event->get_ticket_with_earliest_start_time(); |
|
453 | - $content = $reg_start instanceof EE_Ticket |
|
454 | - ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
455 | - : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
456 | - return $this->columnContent('reg_begins', $content); |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - /** |
|
461 | - * @param EE_Event $event |
|
462 | - * @return string |
|
463 | - * @throws EE_Error |
|
464 | - * @throws InvalidArgumentException |
|
465 | - * @throws InvalidDataTypeException |
|
466 | - * @throws InvalidInterfaceException |
|
467 | - * @throws ReflectionException |
|
468 | - */ |
|
469 | - public function column_attendees(EE_Event $event): string |
|
470 | - { |
|
471 | - $attendees_query_args = [ |
|
472 | - 'action' => 'default', |
|
473 | - 'event_id' => $event->ID(), |
|
474 | - ]; |
|
475 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
476 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count($event->ID()); |
|
477 | - |
|
478 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
479 | - 'ee_read_event', |
|
480 | - 'espresso_registrations_view_registration', |
|
481 | - $event->ID() |
|
482 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
483 | - 'ee_read_registrations', |
|
484 | - 'espresso_registrations_view_registration' |
|
485 | - ) |
|
486 | - ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
487 | - : $registered_attendees; |
|
488 | - return $this->columnContent('attendees', $content, 'center'); |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * @param EE_Event $event |
|
494 | - * @return float |
|
495 | - * @throws EE_Error |
|
496 | - * @throws InvalidArgumentException |
|
497 | - * @throws InvalidDataTypeException |
|
498 | - * @throws InvalidInterfaceException |
|
499 | - * @throws ReflectionException |
|
500 | - */ |
|
501 | - public function column_tkts_sold(EE_Event $event): float |
|
502 | - { |
|
503 | - $content = EEM_Ticket::instance()->sum([['Datetime.EVT_ID' => $event->ID()]], 'TKT_sold'); |
|
504 | - return $this->columnContent('tkts_sold', $content); |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * @param EE_Event $event |
|
510 | - * @return string |
|
511 | - * @throws EE_Error |
|
512 | - * @throws InvalidArgumentException |
|
513 | - * @throws InvalidDataTypeException |
|
514 | - * @throws InvalidInterfaceException |
|
515 | - * @throws ReflectionException |
|
516 | - */ |
|
517 | - public function column_actions(EE_Event $event): string |
|
518 | - { |
|
519 | - // todo: remove when attendees is active |
|
520 | - if (! defined('REG_ADMIN_URL')) { |
|
521 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
522 | - } |
|
523 | - $action_links = []; |
|
524 | - $view_link = get_permalink($event->ID()); |
|
525 | - $action_links[] = '<a href="' . $view_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
526 | - . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank"> |
|
202 | + $content .= $this->row_actions($actions); |
|
203 | + |
|
204 | + return $prep_content ? $this->columnContent('name', $content) : $content; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * Just a method for setting up the actions for the name column |
|
210 | + * |
|
211 | + * @param EE_Event $event |
|
212 | + * @return array array of actions |
|
213 | + * @throws EE_Error |
|
214 | + * @throws InvalidArgumentException |
|
215 | + * @throws InvalidDataTypeException |
|
216 | + * @throws InvalidInterfaceException |
|
217 | + * @throws ReflectionException |
|
218 | + */ |
|
219 | + protected function _column_name_action_setup(EE_Event $event): array |
|
220 | + { |
|
221 | + // todo: remove when attendees is active |
|
222 | + if (! defined('REG_ADMIN_URL')) { |
|
223 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
224 | + } |
|
225 | + $actions = []; |
|
226 | + $restore_event_link = ''; |
|
227 | + $delete_event_link = ''; |
|
228 | + $trash_event_link = ''; |
|
229 | + if ( |
|
230 | + EE_Registry::instance()->CAP->current_user_can( |
|
231 | + 'ee_edit_event', |
|
232 | + 'espresso_events_edit', |
|
233 | + $event->ID() |
|
234 | + ) |
|
235 | + ) { |
|
236 | + $edit_query_args = [ |
|
237 | + 'action' => 'edit', |
|
238 | + 'post' => $event->ID(), |
|
239 | + ]; |
|
240 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
241 | + $actions['edit'] = '<a href="' . $edit_link . '" class="ee-aria-tooltip" ' |
|
242 | + . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
243 | + . esc_html__('Edit', 'event_espresso') |
|
244 | + . '</a>'; |
|
245 | + } |
|
246 | + if ( |
|
247 | + EE_Registry::instance()->CAP->current_user_can( |
|
248 | + 'ee_read_registrations', |
|
249 | + 'espresso_registrations_view_registration' |
|
250 | + ) |
|
251 | + && EE_Registry::instance()->CAP->current_user_can( |
|
252 | + 'ee_read_event', |
|
253 | + 'espresso_registrations_view_registration', |
|
254 | + $event->ID() |
|
255 | + ) |
|
256 | + ) { |
|
257 | + $attendees_query_args = [ |
|
258 | + 'action' => 'default', |
|
259 | + 'event_id' => $event->ID(), |
|
260 | + ]; |
|
261 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
262 | + $actions['attendees'] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip"' |
|
263 | + . ' aria-label="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
264 | + . esc_html__('Registrations', 'event_espresso') |
|
265 | + . '</a>'; |
|
266 | + } |
|
267 | + if ( |
|
268 | + EE_Registry::instance()->CAP->current_user_can( |
|
269 | + 'ee_delete_event', |
|
270 | + 'espresso_events_trash_event', |
|
271 | + $event->ID() |
|
272 | + ) |
|
273 | + ) { |
|
274 | + $trash_event_query_args = [ |
|
275 | + 'action' => 'trash_event', |
|
276 | + 'EVT_ID' => $event->ID(), |
|
277 | + ]; |
|
278 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
279 | + $trash_event_query_args, |
|
280 | + EVENTS_ADMIN_URL |
|
281 | + ); |
|
282 | + } |
|
283 | + if ( |
|
284 | + EE_Registry::instance()->CAP->current_user_can( |
|
285 | + 'ee_delete_event', |
|
286 | + 'espresso_events_restore_event', |
|
287 | + $event->ID() |
|
288 | + ) |
|
289 | + ) { |
|
290 | + $restore_event_query_args = [ |
|
291 | + 'action' => 'restore_event', |
|
292 | + 'EVT_ID' => $event->ID(), |
|
293 | + ]; |
|
294 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
295 | + $restore_event_query_args, |
|
296 | + EVENTS_ADMIN_URL |
|
297 | + ); |
|
298 | + } |
|
299 | + if ( |
|
300 | + EE_Registry::instance()->CAP->current_user_can( |
|
301 | + 'ee_delete_event', |
|
302 | + 'espresso_events_delete_event', |
|
303 | + $event->ID() |
|
304 | + ) |
|
305 | + ) { |
|
306 | + $delete_event_query_args = [ |
|
307 | + 'action' => 'delete_event', |
|
308 | + 'EVT_ID' => $event->ID(), |
|
309 | + ]; |
|
310 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
311 | + $delete_event_query_args, |
|
312 | + EVENTS_ADMIN_URL |
|
313 | + ); |
|
314 | + } |
|
315 | + $view_link = get_permalink($event->ID()); |
|
316 | + $actions['view'] = '<a href="' . $view_link . '" class="ee-aria-tooltip"' |
|
317 | + . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
318 | + . esc_html__('View', 'event_espresso') |
|
319 | + . '</a>'; |
|
320 | + if ($event->get('status') === 'trash') { |
|
321 | + if ( |
|
322 | + EE_Registry::instance()->CAP->current_user_can( |
|
323 | + 'ee_delete_event', |
|
324 | + 'espresso_events_restore_event', |
|
325 | + $event->ID() |
|
326 | + ) |
|
327 | + ) { |
|
328 | + $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" class="ee-aria-tooltip"' |
|
329 | + . ' aria-label="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
330 | + . '">' |
|
331 | + . esc_html__('Restore from Trash', 'event_espresso') |
|
332 | + . '</a>'; |
|
333 | + } |
|
334 | + if ( |
|
335 | + EE_Registry::instance()->CAP->current_user_can( |
|
336 | + 'ee_delete_event', |
|
337 | + 'espresso_events_delete_event', |
|
338 | + $event->ID() |
|
339 | + ) |
|
340 | + ) { |
|
341 | + $actions['delete'] = '<a href="' . $delete_event_link . '" class="ee-aria-tooltip"' |
|
342 | + . ' aria-label="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
343 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
344 | + . '</a>'; |
|
345 | + } |
|
346 | + } else { |
|
347 | + if ( |
|
348 | + EE_Registry::instance()->CAP->current_user_can( |
|
349 | + 'ee_delete_event', |
|
350 | + 'espresso_events_trash_event', |
|
351 | + $event->ID() |
|
352 | + ) |
|
353 | + ) { |
|
354 | + $actions['move to trash'] = '<a href="' . $trash_event_link . '" class="ee-aria-tooltip"' |
|
355 | + . ' aria-label="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
356 | + . esc_html__('Trash', 'event_espresso') |
|
357 | + . '</a>'; |
|
358 | + } |
|
359 | + } |
|
360 | + return $actions; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * @param EE_Event $event |
|
366 | + * @return string |
|
367 | + * @throws EE_Error |
|
368 | + * @throws ReflectionException |
|
369 | + */ |
|
370 | + public function column_author(EE_Event $event): string |
|
371 | + { |
|
372 | + // user author info |
|
373 | + $event_author = get_userdata($event->wp_user()); |
|
374 | + $gravatar = get_avatar($event->wp_user(), '24'); |
|
375 | + // filter link |
|
376 | + $query_args = [ |
|
377 | + 'action' => 'default', |
|
378 | + 'EVT_wp_user' => $event->wp_user(), |
|
379 | + ]; |
|
380 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
381 | + $content = '<div class="ee-layout-row ee-layout-row--fixed">'; |
|
382 | + $content .= $gravatar . ' <a href="' . $filter_url . '" class="ee-aria-tooltip"' |
|
383 | + . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
384 | + . $event_author->display_name |
|
385 | + . '</a>'; |
|
386 | + $content .= '</div>'; |
|
387 | + return $this->columnContent('author', $content); |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * @param EE_Event $event |
|
393 | + * @return string |
|
394 | + * @throws EE_Error |
|
395 | + * @throws ReflectionException |
|
396 | + */ |
|
397 | + public function column_event_category(EE_Event $event): string |
|
398 | + { |
|
399 | + $event_categories = $event->get_all_event_categories(); |
|
400 | + $content = implode( |
|
401 | + ', ', |
|
402 | + array_map( |
|
403 | + function (EE_Term $category) { |
|
404 | + return $category->name(); |
|
405 | + }, |
|
406 | + $event_categories |
|
407 | + ) |
|
408 | + ); |
|
409 | + return $this->columnContent('event_category', $content); |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * @param EE_Event $event |
|
415 | + * @return string |
|
416 | + * @throws EE_Error |
|
417 | + * @throws ReflectionException |
|
418 | + */ |
|
419 | + public function column_venue(EE_Event $event): string |
|
420 | + { |
|
421 | + $venue = $event->get_first_related('Venue'); |
|
422 | + $content = ! empty($venue) |
|
423 | + ? $venue->name() |
|
424 | + : ''; |
|
425 | + return $this->columnContent('venue', $content); |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * @param EE_Event $event |
|
431 | + * @return string |
|
432 | + * @throws EE_Error |
|
433 | + * @throws ReflectionException |
|
434 | + */ |
|
435 | + public function column_start_date_time(EE_Event $event): string |
|
436 | + { |
|
437 | + $content = $this->_dtt instanceof EE_Datetime |
|
438 | + ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
439 | + : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
440 | + return $this->columnContent('start_date_time', $content); |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * @param EE_Event $event |
|
446 | + * @return string |
|
447 | + * @throws EE_Error |
|
448 | + * @throws ReflectionException |
|
449 | + */ |
|
450 | + public function column_reg_begins(EE_Event $event): string |
|
451 | + { |
|
452 | + $reg_start = $event->get_ticket_with_earliest_start_time(); |
|
453 | + $content = $reg_start instanceof EE_Ticket |
|
454 | + ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
455 | + : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
456 | + return $this->columnContent('reg_begins', $content); |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * @param EE_Event $event |
|
462 | + * @return string |
|
463 | + * @throws EE_Error |
|
464 | + * @throws InvalidArgumentException |
|
465 | + * @throws InvalidDataTypeException |
|
466 | + * @throws InvalidInterfaceException |
|
467 | + * @throws ReflectionException |
|
468 | + */ |
|
469 | + public function column_attendees(EE_Event $event): string |
|
470 | + { |
|
471 | + $attendees_query_args = [ |
|
472 | + 'action' => 'default', |
|
473 | + 'event_id' => $event->ID(), |
|
474 | + ]; |
|
475 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
476 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($event->ID()); |
|
477 | + |
|
478 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
479 | + 'ee_read_event', |
|
480 | + 'espresso_registrations_view_registration', |
|
481 | + $event->ID() |
|
482 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
483 | + 'ee_read_registrations', |
|
484 | + 'espresso_registrations_view_registration' |
|
485 | + ) |
|
486 | + ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
487 | + : $registered_attendees; |
|
488 | + return $this->columnContent('attendees', $content, 'center'); |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * @param EE_Event $event |
|
494 | + * @return float |
|
495 | + * @throws EE_Error |
|
496 | + * @throws InvalidArgumentException |
|
497 | + * @throws InvalidDataTypeException |
|
498 | + * @throws InvalidInterfaceException |
|
499 | + * @throws ReflectionException |
|
500 | + */ |
|
501 | + public function column_tkts_sold(EE_Event $event): float |
|
502 | + { |
|
503 | + $content = EEM_Ticket::instance()->sum([['Datetime.EVT_ID' => $event->ID()]], 'TKT_sold'); |
|
504 | + return $this->columnContent('tkts_sold', $content); |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * @param EE_Event $event |
|
510 | + * @return string |
|
511 | + * @throws EE_Error |
|
512 | + * @throws InvalidArgumentException |
|
513 | + * @throws InvalidDataTypeException |
|
514 | + * @throws InvalidInterfaceException |
|
515 | + * @throws ReflectionException |
|
516 | + */ |
|
517 | + public function column_actions(EE_Event $event): string |
|
518 | + { |
|
519 | + // todo: remove when attendees is active |
|
520 | + if (! defined('REG_ADMIN_URL')) { |
|
521 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
522 | + } |
|
523 | + $action_links = []; |
|
524 | + $view_link = get_permalink($event->ID()); |
|
525 | + $action_links[] = '<a href="' . $view_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
526 | + . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank"> |
|
527 | 527 | <span class="dashicons dashicons-visibility"></span></a>'; |
528 | - if ( |
|
529 | - EE_Registry::instance()->CAP->current_user_can( |
|
530 | - 'ee_edit_event', |
|
531 | - 'espresso_events_edit', |
|
532 | - $event->ID() |
|
533 | - ) |
|
534 | - ) { |
|
535 | - $edit_query_args = [ |
|
536 | - 'action' => 'edit', |
|
537 | - 'post' => $event->ID(), |
|
538 | - ]; |
|
539 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
540 | - $action_links[] = '<a href="' . $edit_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
541 | - . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
542 | - . '<span class="dashicons dashicons-calendar-alt"></span>' |
|
543 | - . '</a>'; |
|
544 | - } |
|
545 | - if ( |
|
546 | - EE_Registry::instance()->CAP->current_user_can( |
|
547 | - 'ee_read_registrations', |
|
548 | - 'espresso_registrations_view_registration' |
|
549 | - ) |
|
550 | - && EE_Registry::instance()->CAP->current_user_can( |
|
551 | - 'ee_read_event', |
|
552 | - 'espresso_registrations_view_registration', |
|
553 | - $event->ID() |
|
554 | - ) |
|
555 | - ) { |
|
556 | - $attendees_query_args = [ |
|
557 | - 'action' => 'default', |
|
558 | - 'event_id' => $event->ID(), |
|
559 | - ]; |
|
560 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
561 | - $action_links[] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
562 | - . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
563 | - . '<span class="dashicons dashicons-groups"></span>' |
|
564 | - . '</a>'; |
|
565 | - } |
|
566 | - $action_links = apply_filters( |
|
567 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
568 | - $action_links, |
|
569 | - $event |
|
570 | - ); |
|
571 | - $content = $this->_action_string( |
|
572 | - implode("\n\t", $action_links), |
|
573 | - $event, |
|
574 | - 'div', |
|
575 | - 'event-overview-actions ee-list-table-actions' |
|
576 | - ); |
|
577 | - return $this->columnContent('actions', $this->actionsModalMenu($content)); |
|
578 | - } |
|
579 | - |
|
580 | - |
|
581 | - /** |
|
582 | - * Helper for adding columns conditionally |
|
583 | - * |
|
584 | - * @throws EE_Error |
|
585 | - * @throws InvalidArgumentException |
|
586 | - * @throws InvalidDataTypeException |
|
587 | - * @throws InvalidInterfaceException |
|
588 | - * @throws ReflectionException |
|
589 | - */ |
|
590 | - private function addConditionalColumns() |
|
591 | - { |
|
592 | - $event_category_count = EEM_Term::instance()->count( |
|
593 | - [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]] |
|
594 | - ); |
|
595 | - if ($event_category_count === 0) { |
|
596 | - return; |
|
597 | - } |
|
598 | - $column_array = []; |
|
599 | - foreach ($this->_columns as $column => $column_label) { |
|
600 | - $column_array[ $column ] = $column_label; |
|
601 | - if ($column === 'venue') { |
|
602 | - $column_array['event_category'] = esc_html__('Event Category', 'event_espresso'); |
|
603 | - } |
|
604 | - } |
|
605 | - $this->_columns = $column_array; |
|
606 | - } |
|
528 | + if ( |
|
529 | + EE_Registry::instance()->CAP->current_user_can( |
|
530 | + 'ee_edit_event', |
|
531 | + 'espresso_events_edit', |
|
532 | + $event->ID() |
|
533 | + ) |
|
534 | + ) { |
|
535 | + $edit_query_args = [ |
|
536 | + 'action' => 'edit', |
|
537 | + 'post' => $event->ID(), |
|
538 | + ]; |
|
539 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
540 | + $action_links[] = '<a href="' . $edit_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
541 | + . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
542 | + . '<span class="dashicons dashicons-calendar-alt"></span>' |
|
543 | + . '</a>'; |
|
544 | + } |
|
545 | + if ( |
|
546 | + EE_Registry::instance()->CAP->current_user_can( |
|
547 | + 'ee_read_registrations', |
|
548 | + 'espresso_registrations_view_registration' |
|
549 | + ) |
|
550 | + && EE_Registry::instance()->CAP->current_user_can( |
|
551 | + 'ee_read_event', |
|
552 | + 'espresso_registrations_view_registration', |
|
553 | + $event->ID() |
|
554 | + ) |
|
555 | + ) { |
|
556 | + $attendees_query_args = [ |
|
557 | + 'action' => 'default', |
|
558 | + 'event_id' => $event->ID(), |
|
559 | + ]; |
|
560 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
561 | + $action_links[] = '<a href="' . $attendees_link . '" class="ee-aria-tooltip button button--icon-only"' |
|
562 | + . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
563 | + . '<span class="dashicons dashicons-groups"></span>' |
|
564 | + . '</a>'; |
|
565 | + } |
|
566 | + $action_links = apply_filters( |
|
567 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
568 | + $action_links, |
|
569 | + $event |
|
570 | + ); |
|
571 | + $content = $this->_action_string( |
|
572 | + implode("\n\t", $action_links), |
|
573 | + $event, |
|
574 | + 'div', |
|
575 | + 'event-overview-actions ee-list-table-actions' |
|
576 | + ); |
|
577 | + return $this->columnContent('actions', $this->actionsModalMenu($content)); |
|
578 | + } |
|
579 | + |
|
580 | + |
|
581 | + /** |
|
582 | + * Helper for adding columns conditionally |
|
583 | + * |
|
584 | + * @throws EE_Error |
|
585 | + * @throws InvalidArgumentException |
|
586 | + * @throws InvalidDataTypeException |
|
587 | + * @throws InvalidInterfaceException |
|
588 | + * @throws ReflectionException |
|
589 | + */ |
|
590 | + private function addConditionalColumns() |
|
591 | + { |
|
592 | + $event_category_count = EEM_Term::instance()->count( |
|
593 | + [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]] |
|
594 | + ); |
|
595 | + if ($event_category_count === 0) { |
|
596 | + return; |
|
597 | + } |
|
598 | + $column_array = []; |
|
599 | + foreach ($this->_columns as $column => $column_label) { |
|
600 | + $column_array[ $column ] = $column_label; |
|
601 | + if ($column === 'venue') { |
|
602 | + $column_array['event_category'] = esc_html__('Event Category', 'event_espresso'); |
|
603 | + } |
|
604 | + } |
|
605 | + $this->_columns = $column_array; |
|
606 | + } |
|
607 | 607 | } |