@@ -21,13 +21,13 @@ |
||
21 | 21 | * define some events related constants but only if not defined (need to check because unit tests |
22 | 22 | * may load) |
23 | 23 | */ |
24 | - if (! defined('EVENTS_PG_SLUG')) { |
|
24 | + if ( ! defined('EVENTS_PG_SLUG')) { |
|
25 | 25 | define('EVENTS_PG_SLUG', 'espresso_events'); |
26 | 26 | define('EVENTS_LABEL', esc_html__('Events', 'event_espresso')); |
27 | - define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/'); |
|
28 | - define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG)); |
|
29 | - define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/'); |
|
30 | - define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/'); |
|
27 | + define('EVENTS_ADMIN', EE_ADMIN_PAGES.'events/'); |
|
28 | + define('EVENTS_ADMIN_URL', admin_url('admin.php?page='.EVENTS_PG_SLUG)); |
|
29 | + define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN.'templates/'); |
|
30 | + define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'events/assets/'); |
|
31 | 31 | } |
32 | 32 | parent::__construct(); |
33 | 33 | } |
@@ -14,42 +14,42 @@ |
||
14 | 14 | */ |
15 | 15 | class Events_Admin_Page_Init extends EE_Admin_Page_CPT_Init |
16 | 16 | { |
17 | - public function __construct() |
|
18 | - { |
|
19 | - /** |
|
20 | - * define some events related constants but only if not defined (need to check because unit tests |
|
21 | - * may load) |
|
22 | - */ |
|
23 | - if (! defined('EVENTS_PG_SLUG')) { |
|
24 | - define('EVENTS_PG_SLUG', 'espresso_events'); |
|
25 | - define('EVENTS_LABEL', esc_html__('Events', 'event_espresso')); |
|
26 | - define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/'); |
|
27 | - define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG)); |
|
28 | - define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/'); |
|
29 | - define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/'); |
|
30 | - } |
|
31 | - parent::__construct(); |
|
32 | - } |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + /** |
|
20 | + * define some events related constants but only if not defined (need to check because unit tests |
|
21 | + * may load) |
|
22 | + */ |
|
23 | + if (! defined('EVENTS_PG_SLUG')) { |
|
24 | + define('EVENTS_PG_SLUG', 'espresso_events'); |
|
25 | + define('EVENTS_LABEL', esc_html__('Events', 'event_espresso')); |
|
26 | + define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/'); |
|
27 | + define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG)); |
|
28 | + define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/'); |
|
29 | + define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/'); |
|
30 | + } |
|
31 | + parent::__construct(); |
|
32 | + } |
|
33 | 33 | |
34 | - protected function _set_init_properties() |
|
35 | - { |
|
36 | - $this->label = esc_html__('Event Espresso - Event Details', 'event_espresso'); |
|
37 | - } |
|
34 | + protected function _set_init_properties() |
|
35 | + { |
|
36 | + $this->label = esc_html__('Event Espresso - Event Details', 'event_espresso'); |
|
37 | + } |
|
38 | 38 | |
39 | - protected function _set_menu_map() |
|
40 | - { |
|
41 | - $this->_menu_map = new EE_Admin_Page_Main_Menu( |
|
42 | - array( |
|
43 | - 'menu_group' => 'main', |
|
44 | - 'menu_order' => 10, |
|
45 | - 'subtitle' => esc_html__('Events', 'event_espresso'), |
|
46 | - 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
47 | - 'parent_slug' => 'espresso_events', |
|
48 | - 'menu_slug' => 'espresso_events', |
|
49 | - 'menu_label' => esc_html__('Event Espresso', 'event_espresso'), |
|
50 | - 'capability' => 'ee_read_events', |
|
51 | - 'admin_init_page' => $this, |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
39 | + protected function _set_menu_map() |
|
40 | + { |
|
41 | + $this->_menu_map = new EE_Admin_Page_Main_Menu( |
|
42 | + array( |
|
43 | + 'menu_group' => 'main', |
|
44 | + 'menu_order' => 10, |
|
45 | + 'subtitle' => esc_html__('Events', 'event_espresso'), |
|
46 | + 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
47 | + 'parent_slug' => 'espresso_events', |
|
48 | + 'menu_slug' => 'espresso_events', |
|
49 | + 'menu_label' => esc_html__('Event Espresso', 'event_espresso'), |
|
50 | + 'capability' => 'ee_read_events', |
|
51 | + 'admin_init_page' => $this, |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function column_id($item) |
91 | 91 | { |
92 | 92 | $content = $item->ID(); |
93 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
93 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->name().'</span>'; |
|
94 | 94 | return $content; |
95 | 95 | } |
96 | 96 | |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | $statuses = EEM_Venue::instance()->get_status_array(); |
108 | 108 | $actions = $this->_column_name_action_setup($item); |
109 | 109 | $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID()) |
110 | - ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep( |
|
110 | + ? '<strong><a class="row-title" href="'.$edit_link.'">'.stripslashes_deep( |
|
111 | 111 | $item->name() |
112 | - ) . '</a></strong>' : $item->name(); |
|
113 | - $content .= $item->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : ''; |
|
112 | + ).'</a></strong>' : $item->name(); |
|
113 | + $content .= $item->status() == 'draft' ? ' - <span class="post-state">'.$statuses['draft'].'</span>' : ''; |
|
114 | 114 | $content .= $this->row_actions($actions); |
115 | 115 | return $content; |
116 | 116 | } |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | 'post' => $item->ID(), |
133 | 133 | ); |
134 | 134 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
135 | - $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
135 | + $actions['edit'] = '<a href="'.$edit_link.'" title="'.esc_attr__( |
|
136 | 136 | 'Edit Venue', |
137 | 137 | 'event_espresso' |
138 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
138 | + ).'">'.esc_html__('Edit', 'event_espresso').'</a>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | $item->ID() |
196 | 196 | ) |
197 | 197 | ) { |
198 | - $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '" title="' . esc_attr__( |
|
198 | + $actions['restore_from_trash'] = '<a href="'.$restore_venue_link.'" title="'.esc_attr__( |
|
199 | 199 | 'Restore from Trash', |
200 | 200 | 'event_espresso' |
201 | - ) . '">' . esc_html__('Restore from Trash', 'event_espresso') . '</a>'; |
|
201 | + ).'">'.esc_html__('Restore from Trash', 'event_espresso').'</a>'; |
|
202 | 202 | } |
203 | 203 | if ( |
204 | 204 | $item->count_related('Event') === 0 && EE_Registry::instance()->CAP->current_user_can( |
@@ -207,17 +207,17 @@ discard block |
||
207 | 207 | $item->ID() |
208 | 208 | ) |
209 | 209 | ) { |
210 | - $actions['delete permanently'] = '<a href="' . $delete_venue_link . '" title="' . esc_attr__( |
|
210 | + $actions['delete permanently'] = '<a href="'.$delete_venue_link.'" title="'.esc_attr__( |
|
211 | 211 | 'Delete Permanently', |
212 | 212 | 'event_espresso' |
213 | - ) . '">' . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
213 | + ).'">'.esc_html__('Delete Permanently', 'event_espresso').'</a>'; |
|
214 | 214 | } |
215 | 215 | break; |
216 | 216 | default: |
217 | - $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__( |
|
217 | + $actions['view'] = '<a href="'.$view_link.'" title="'.esc_attr__( |
|
218 | 218 | 'View Venue', |
219 | 219 | 'event_espresso' |
220 | - ) . '">' . esc_html__('View', 'event_espresso') . '</a>'; |
|
220 | + ).'">'.esc_html__('View', 'event_espresso').'</a>'; |
|
221 | 221 | if ( |
222 | 222 | EE_Registry::instance()->CAP->current_user_can( |
223 | 223 | 'ee_delete_venue', |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | $item->ID() |
226 | 226 | ) |
227 | 227 | ) { |
228 | - $actions['move to trash'] = '<a href="' . $trash_venue_link . '" title="' . esc_attr__( |
|
228 | + $actions['move to trash'] = '<a href="'.$trash_venue_link.'" title="'.esc_attr__( |
|
229 | 229 | 'Trash Event', |
230 | 230 | 'event_espresso' |
231 | - ) . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
231 | + ).'">'.esc_html__('Trash', 'event_espresso').'</a>'; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | return $actions; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | public function column_shortcode($item) |
257 | 257 | { |
258 | - $content = '[ESPRESSO_VENUE id=' . $item->ID() . ']'; |
|
258 | + $content = '[ESPRESSO_VENUE id='.$item->ID().']'; |
|
259 | 259 | return $content; |
260 | 260 | } |
261 | 261 | } |
@@ -15,246 +15,246 @@ |
||
15 | 15 | */ |
16 | 16 | class Venues_Admin_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - public function __construct($admin_page) |
|
19 | - { |
|
20 | - parent::__construct($admin_page); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - protected function _setup_data() |
|
25 | - { |
|
26 | - $this->_data = $this->_admin_page->get_venues($this->_per_page); |
|
27 | - $this->_all_data_count = $this->_admin_page->get_venues($this->_per_page, true); |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - protected function _set_properties() |
|
32 | - { |
|
33 | - $this->_wp_list_args = array( |
|
34 | - 'singular' => esc_html__('Event Venue', 'event_espresso'), |
|
35 | - 'plural' => esc_html__('Event Venues', 'event_espresso'), |
|
36 | - 'ajax' => true, // for now, |
|
37 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
38 | - ); |
|
39 | - |
|
40 | - $this->_columns = array( |
|
41 | - 'cb' => '<input type="checkbox" />', |
|
42 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
43 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
44 | - 'address' => esc_html__('Address', 'event_espresso'), |
|
45 | - 'city' => esc_html__('City', 'event_espresso'), |
|
46 | - 'capacity' => esc_html__('Capacity', 'event_espresso'), |
|
47 | - // 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
48 | - ); |
|
49 | - |
|
50 | - $this->_sortable_columns = array( |
|
51 | - 'id' => array('id' => true), |
|
52 | - 'name' => array('name' => false), |
|
53 | - 'city' => array('city' => false), |
|
54 | - 'capacity' => array('capacity' => false), |
|
55 | - ); |
|
56 | - |
|
57 | - $this->_hidden_columns = array(); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - // todo... add _venue_status in here (which we'll define a EE_Admin_CPT_List_Table for common properties) |
|
62 | - protected function _get_table_filters() |
|
63 | - { |
|
64 | - return array(); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - protected function _add_view_counts() |
|
69 | - { |
|
70 | - $this->_views['all']['count'] = EEM_Venue::instance()->count(); |
|
71 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) { |
|
72 | - $this->_views['trash']['count'] = EEM_Venue::instance()->count_deleted(); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - public function column_cb($item) |
|
78 | - { |
|
79 | - |
|
80 | - return $item->count_related('Event') > 0 && $item->get('status') === 'trash' |
|
81 | - ? '<span class="ee-lock-icon"></span>' |
|
82 | - : sprintf( |
|
83 | - '<input type="checkbox" name="venue_id[]" value="%s" />', |
|
84 | - $item->ID() |
|
85 | - ); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - public function column_id($item) |
|
90 | - { |
|
91 | - $content = $item->ID(); |
|
92 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
93 | - return $content; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - public function column_name($item) |
|
98 | - { |
|
99 | - $edit_query_args = array( |
|
100 | - 'action' => 'edit', |
|
101 | - 'post' => $item->ID(), |
|
102 | - ); |
|
103 | - |
|
104 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
105 | - |
|
106 | - $statuses = EEM_Venue::instance()->get_status_array(); |
|
107 | - $actions = $this->_column_name_action_setup($item); |
|
108 | - $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID()) |
|
109 | - ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep( |
|
110 | - $item->name() |
|
111 | - ) . '</a></strong>' : $item->name(); |
|
112 | - $content .= $item->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : ''; |
|
113 | - $content .= $this->row_actions($actions); |
|
114 | - return $content; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * Used to setup the actions for the Venue name column |
|
120 | - * |
|
121 | - * @param EE_Venue $item |
|
122 | - * @return array() |
|
123 | - */ |
|
124 | - protected function _column_name_action_setup(EE_Venue $item) |
|
125 | - { |
|
126 | - $actions = array(); |
|
127 | - |
|
128 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID())) { |
|
129 | - $edit_query_args = array( |
|
130 | - 'action' => 'edit', |
|
131 | - 'post' => $item->ID(), |
|
132 | - ); |
|
133 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
134 | - $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
135 | - 'Edit Venue', |
|
136 | - 'event_espresso' |
|
137 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - if ( |
|
142 | - EE_Registry::instance()->CAP->current_user_can( |
|
143 | - 'ee_delete_venue', |
|
144 | - 'espresso_venues_trash_venue', |
|
145 | - $item->ID() |
|
146 | - ) |
|
147 | - ) { |
|
148 | - $trash_event_query_arg = array( |
|
149 | - 'action' => 'trash_venue', |
|
150 | - 'VNU_ID' => $item->ID(), |
|
151 | - ); |
|
152 | - $trash_venue_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_arg, EE_VENUES_ADMIN_URL); |
|
153 | - } |
|
154 | - |
|
155 | - if ( |
|
156 | - EE_Registry::instance()->CAP->current_user_can( |
|
157 | - 'ee_delete_venue', |
|
158 | - 'espresso_venues_restore_venue', |
|
159 | - $item->ID() |
|
160 | - ) |
|
161 | - ) { |
|
162 | - $restore_venue_query_args = array( |
|
163 | - 'action' => 'restore_venue', |
|
164 | - 'VNU_ID' => $item->ID(), |
|
165 | - ); |
|
166 | - $restore_venue_link = EE_Admin_Page::add_query_args_and_nonce( |
|
167 | - $restore_venue_query_args, |
|
168 | - EE_VENUES_ADMIN_URL |
|
169 | - ); |
|
170 | - } |
|
171 | - |
|
172 | - if ( |
|
173 | - EE_Registry::instance()->CAP->current_user_can( |
|
174 | - 'ee_delete_venue', |
|
175 | - 'espresso_venues_delete_venue', |
|
176 | - $item->ID() |
|
177 | - ) |
|
178 | - ) { |
|
179 | - $delete_venue_query_args = array( |
|
180 | - 'action' => 'delete_venue', |
|
181 | - 'VNU_ID' => $item->ID(), |
|
182 | - ); |
|
183 | - $delete_venue_link = EE_Admin_Page::add_query_args_and_nonce($delete_venue_query_args, EE_VENUES_ADMIN_URL); |
|
184 | - } |
|
185 | - |
|
186 | - $view_link = get_permalink($item->ID()); |
|
187 | - |
|
188 | - switch ($item->get('status')) { |
|
189 | - case 'trash': |
|
190 | - if ( |
|
191 | - EE_Registry::instance()->CAP->current_user_can( |
|
192 | - 'ee_delete_venue', |
|
193 | - 'espresso_venues_restore_venue', |
|
194 | - $item->ID() |
|
195 | - ) |
|
196 | - ) { |
|
197 | - $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '" title="' . esc_attr__( |
|
198 | - 'Restore from Trash', |
|
199 | - 'event_espresso' |
|
200 | - ) . '">' . esc_html__('Restore from Trash', 'event_espresso') . '</a>'; |
|
201 | - } |
|
202 | - if ( |
|
203 | - $item->count_related('Event') === 0 && EE_Registry::instance()->CAP->current_user_can( |
|
204 | - 'ee_delete_venue', |
|
205 | - 'espresso_venues_delete_venue', |
|
206 | - $item->ID() |
|
207 | - ) |
|
208 | - ) { |
|
209 | - $actions['delete permanently'] = '<a href="' . $delete_venue_link . '" title="' . esc_attr__( |
|
210 | - 'Delete Permanently', |
|
211 | - 'event_espresso' |
|
212 | - ) . '">' . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
213 | - } |
|
214 | - break; |
|
215 | - default: |
|
216 | - $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__( |
|
217 | - 'View Venue', |
|
218 | - 'event_espresso' |
|
219 | - ) . '">' . esc_html__('View', 'event_espresso') . '</a>'; |
|
220 | - if ( |
|
221 | - EE_Registry::instance()->CAP->current_user_can( |
|
222 | - 'ee_delete_venue', |
|
223 | - 'espresso_venues_trash_venue', |
|
224 | - $item->ID() |
|
225 | - ) |
|
226 | - ) { |
|
227 | - $actions['move to trash'] = '<a href="' . $trash_venue_link . '" title="' . esc_attr__( |
|
228 | - 'Trash Event', |
|
229 | - 'event_espresso' |
|
230 | - ) . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
231 | - } |
|
232 | - } |
|
233 | - return $actions; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - public function column_address($item) |
|
238 | - { |
|
239 | - return $item->address(); |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - public function column_city($item) |
|
244 | - { |
|
245 | - return $item->city(); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - public function column_capacity($item) |
|
250 | - { |
|
251 | - return $item->capacity(); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - public function column_shortcode($item) |
|
256 | - { |
|
257 | - $content = '[ESPRESSO_VENUE id=' . $item->ID() . ']'; |
|
258 | - return $content; |
|
259 | - } |
|
18 | + public function __construct($admin_page) |
|
19 | + { |
|
20 | + parent::__construct($admin_page); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + protected function _setup_data() |
|
25 | + { |
|
26 | + $this->_data = $this->_admin_page->get_venues($this->_per_page); |
|
27 | + $this->_all_data_count = $this->_admin_page->get_venues($this->_per_page, true); |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + protected function _set_properties() |
|
32 | + { |
|
33 | + $this->_wp_list_args = array( |
|
34 | + 'singular' => esc_html__('Event Venue', 'event_espresso'), |
|
35 | + 'plural' => esc_html__('Event Venues', 'event_espresso'), |
|
36 | + 'ajax' => true, // for now, |
|
37 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
38 | + ); |
|
39 | + |
|
40 | + $this->_columns = array( |
|
41 | + 'cb' => '<input type="checkbox" />', |
|
42 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
43 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
44 | + 'address' => esc_html__('Address', 'event_espresso'), |
|
45 | + 'city' => esc_html__('City', 'event_espresso'), |
|
46 | + 'capacity' => esc_html__('Capacity', 'event_espresso'), |
|
47 | + // 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
48 | + ); |
|
49 | + |
|
50 | + $this->_sortable_columns = array( |
|
51 | + 'id' => array('id' => true), |
|
52 | + 'name' => array('name' => false), |
|
53 | + 'city' => array('city' => false), |
|
54 | + 'capacity' => array('capacity' => false), |
|
55 | + ); |
|
56 | + |
|
57 | + $this->_hidden_columns = array(); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + // todo... add _venue_status in here (which we'll define a EE_Admin_CPT_List_Table for common properties) |
|
62 | + protected function _get_table_filters() |
|
63 | + { |
|
64 | + return array(); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + protected function _add_view_counts() |
|
69 | + { |
|
70 | + $this->_views['all']['count'] = EEM_Venue::instance()->count(); |
|
71 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) { |
|
72 | + $this->_views['trash']['count'] = EEM_Venue::instance()->count_deleted(); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + public function column_cb($item) |
|
78 | + { |
|
79 | + |
|
80 | + return $item->count_related('Event') > 0 && $item->get('status') === 'trash' |
|
81 | + ? '<span class="ee-lock-icon"></span>' |
|
82 | + : sprintf( |
|
83 | + '<input type="checkbox" name="venue_id[]" value="%s" />', |
|
84 | + $item->ID() |
|
85 | + ); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + public function column_id($item) |
|
90 | + { |
|
91 | + $content = $item->ID(); |
|
92 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
93 | + return $content; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + public function column_name($item) |
|
98 | + { |
|
99 | + $edit_query_args = array( |
|
100 | + 'action' => 'edit', |
|
101 | + 'post' => $item->ID(), |
|
102 | + ); |
|
103 | + |
|
104 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
105 | + |
|
106 | + $statuses = EEM_Venue::instance()->get_status_array(); |
|
107 | + $actions = $this->_column_name_action_setup($item); |
|
108 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID()) |
|
109 | + ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep( |
|
110 | + $item->name() |
|
111 | + ) . '</a></strong>' : $item->name(); |
|
112 | + $content .= $item->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : ''; |
|
113 | + $content .= $this->row_actions($actions); |
|
114 | + return $content; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * Used to setup the actions for the Venue name column |
|
120 | + * |
|
121 | + * @param EE_Venue $item |
|
122 | + * @return array() |
|
123 | + */ |
|
124 | + protected function _column_name_action_setup(EE_Venue $item) |
|
125 | + { |
|
126 | + $actions = array(); |
|
127 | + |
|
128 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID())) { |
|
129 | + $edit_query_args = array( |
|
130 | + 'action' => 'edit', |
|
131 | + 'post' => $item->ID(), |
|
132 | + ); |
|
133 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
134 | + $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
135 | + 'Edit Venue', |
|
136 | + 'event_espresso' |
|
137 | + ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + if ( |
|
142 | + EE_Registry::instance()->CAP->current_user_can( |
|
143 | + 'ee_delete_venue', |
|
144 | + 'espresso_venues_trash_venue', |
|
145 | + $item->ID() |
|
146 | + ) |
|
147 | + ) { |
|
148 | + $trash_event_query_arg = array( |
|
149 | + 'action' => 'trash_venue', |
|
150 | + 'VNU_ID' => $item->ID(), |
|
151 | + ); |
|
152 | + $trash_venue_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_arg, EE_VENUES_ADMIN_URL); |
|
153 | + } |
|
154 | + |
|
155 | + if ( |
|
156 | + EE_Registry::instance()->CAP->current_user_can( |
|
157 | + 'ee_delete_venue', |
|
158 | + 'espresso_venues_restore_venue', |
|
159 | + $item->ID() |
|
160 | + ) |
|
161 | + ) { |
|
162 | + $restore_venue_query_args = array( |
|
163 | + 'action' => 'restore_venue', |
|
164 | + 'VNU_ID' => $item->ID(), |
|
165 | + ); |
|
166 | + $restore_venue_link = EE_Admin_Page::add_query_args_and_nonce( |
|
167 | + $restore_venue_query_args, |
|
168 | + EE_VENUES_ADMIN_URL |
|
169 | + ); |
|
170 | + } |
|
171 | + |
|
172 | + if ( |
|
173 | + EE_Registry::instance()->CAP->current_user_can( |
|
174 | + 'ee_delete_venue', |
|
175 | + 'espresso_venues_delete_venue', |
|
176 | + $item->ID() |
|
177 | + ) |
|
178 | + ) { |
|
179 | + $delete_venue_query_args = array( |
|
180 | + 'action' => 'delete_venue', |
|
181 | + 'VNU_ID' => $item->ID(), |
|
182 | + ); |
|
183 | + $delete_venue_link = EE_Admin_Page::add_query_args_and_nonce($delete_venue_query_args, EE_VENUES_ADMIN_URL); |
|
184 | + } |
|
185 | + |
|
186 | + $view_link = get_permalink($item->ID()); |
|
187 | + |
|
188 | + switch ($item->get('status')) { |
|
189 | + case 'trash': |
|
190 | + if ( |
|
191 | + EE_Registry::instance()->CAP->current_user_can( |
|
192 | + 'ee_delete_venue', |
|
193 | + 'espresso_venues_restore_venue', |
|
194 | + $item->ID() |
|
195 | + ) |
|
196 | + ) { |
|
197 | + $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '" title="' . esc_attr__( |
|
198 | + 'Restore from Trash', |
|
199 | + 'event_espresso' |
|
200 | + ) . '">' . esc_html__('Restore from Trash', 'event_espresso') . '</a>'; |
|
201 | + } |
|
202 | + if ( |
|
203 | + $item->count_related('Event') === 0 && EE_Registry::instance()->CAP->current_user_can( |
|
204 | + 'ee_delete_venue', |
|
205 | + 'espresso_venues_delete_venue', |
|
206 | + $item->ID() |
|
207 | + ) |
|
208 | + ) { |
|
209 | + $actions['delete permanently'] = '<a href="' . $delete_venue_link . '" title="' . esc_attr__( |
|
210 | + 'Delete Permanently', |
|
211 | + 'event_espresso' |
|
212 | + ) . '">' . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
213 | + } |
|
214 | + break; |
|
215 | + default: |
|
216 | + $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__( |
|
217 | + 'View Venue', |
|
218 | + 'event_espresso' |
|
219 | + ) . '">' . esc_html__('View', 'event_espresso') . '</a>'; |
|
220 | + if ( |
|
221 | + EE_Registry::instance()->CAP->current_user_can( |
|
222 | + 'ee_delete_venue', |
|
223 | + 'espresso_venues_trash_venue', |
|
224 | + $item->ID() |
|
225 | + ) |
|
226 | + ) { |
|
227 | + $actions['move to trash'] = '<a href="' . $trash_venue_link . '" title="' . esc_attr__( |
|
228 | + 'Trash Event', |
|
229 | + 'event_espresso' |
|
230 | + ) . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
231 | + } |
|
232 | + } |
|
233 | + return $actions; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + public function column_address($item) |
|
238 | + { |
|
239 | + return $item->address(); |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + public function column_city($item) |
|
244 | + { |
|
245 | + return $item->city(); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + public function column_capacity($item) |
|
250 | + { |
|
251 | + return $item->capacity(); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + public function column_shortcode($item) |
|
256 | + { |
|
257 | + $content = '[ESPRESSO_VENUE id=' . $item->ID() . ']'; |
|
258 | + return $content; |
|
259 | + } |
|
260 | 260 | } |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | public function column_id($item) |
74 | 74 | { |
75 | 75 | $content = $item->get('term_id'); |
76 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
76 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->get_first_related('Term')->get( |
|
77 | 77 | 'name' |
78 | - ) . '</span>'; |
|
78 | + ).'</span>'; |
|
79 | 79 | return $content; |
80 | 80 | } |
81 | 81 | |
@@ -96,21 +96,21 @@ discard block |
||
96 | 96 | $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_VENUES_ADMIN_URL); |
97 | 97 | |
98 | 98 | $actions = array( |
99 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
99 | + 'edit' => '<a href="'.$edit_link.'" title="'.esc_attr__( |
|
100 | 100 | 'Edit Category', |
101 | 101 | 'event_espresso' |
102 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
102 | + ).'">'.esc_html__('Edit', 'event_espresso').'</a>', |
|
103 | 103 | ); |
104 | 104 | |
105 | 105 | |
106 | - $actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__( |
|
106 | + $actions['delete'] = '<a href="'.$delete_link.'" title="'.esc_attr__( |
|
107 | 107 | 'Delete Category', |
108 | 108 | 'event_espresso' |
109 | - ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
109 | + ).'">'.esc_html__('Delete', 'event_espresso').'</a>'; |
|
110 | 110 | |
111 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get( |
|
111 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->get_first_related('Term')->get( |
|
112 | 112 | 'name' |
113 | - ) . '</a></strong>'; |
|
113 | + ).'</a></strong>'; |
|
114 | 114 | $content .= $this->row_actions($actions); |
115 | 115 | return $content; |
116 | 116 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | public function column_shortcode($item) |
120 | 120 | { |
121 | - $content = '[EVENT_ESPRESSO_CATEGORY category_id="' . $item->get_first_related('Term')->get('slug') . '"]'; |
|
121 | + $content = '[EVENT_ESPRESSO_CATEGORY category_id="'.$item->get_first_related('Term')->get('slug').'"]'; |
|
122 | 122 | return $content; |
123 | 123 | } |
124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | 'category' => $item->get_first_related('Term')->ID(), |
131 | 131 | ); |
132 | 132 | $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EE_VENUES_ADMIN_URL); |
133 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
133 | + $content = '<a href="'.$e_link.'">'.$item->get('term_count').'</a>'; |
|
134 | 134 | return $content; |
135 | 135 | } |
136 | 136 | } |
@@ -15,120 +15,120 @@ |
||
15 | 15 | */ |
16 | 16 | class Venue_Categories_Admin_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - protected function _setup_data() |
|
19 | - { |
|
20 | - $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
21 | - $this->_all_data_count = $this->_admin_page->get_categories($this->_per_page, $this->_current_page, true); |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - protected function _set_properties() |
|
26 | - { |
|
27 | - $this->_wp_list_args = array( |
|
28 | - 'singular' => esc_html__('venue category', 'event_espresso'), |
|
29 | - 'plural' => esc_html__('venue categories', 'event_espresso'), |
|
30 | - 'ajax' => true, // for now, |
|
31 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
32 | - ); |
|
33 | - |
|
34 | - $this->_columns = array( |
|
35 | - 'cb' => '<input type="checkbox" />', |
|
36 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
37 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
38 | - // 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
39 | - 'count' => esc_html__('Venues', 'event_espresso'), |
|
40 | - ); |
|
41 | - |
|
42 | - $this->_sortable_columns = array( |
|
43 | - 'id' => array('Term.term_id' => true), |
|
44 | - 'name' => array('Term.slug' => false), |
|
45 | - 'count' => array('term_count' => false), |
|
46 | - ); |
|
47 | - |
|
48 | - $this->_hidden_columns = array(); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - // not needed |
|
53 | - protected function _get_table_filters() |
|
54 | - { |
|
55 | - return array(); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - protected function _add_view_counts() |
|
60 | - { |
|
61 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - public function column_cb($item) |
|
66 | - { |
|
67 | - return sprintf('<input type="checkbox" name="VEN_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - public function column_id($item) |
|
72 | - { |
|
73 | - $content = $item->get('term_id'); |
|
74 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
75 | - 'name' |
|
76 | - ) . '</span>'; |
|
77 | - return $content; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - public function column_name($item) |
|
82 | - { |
|
83 | - $edit_query_args = array( |
|
84 | - 'action' => 'edit_category', |
|
85 | - 'VEN_CAT_ID' => $item->get('term_id'), |
|
86 | - ); |
|
87 | - |
|
88 | - $delete_query_args = array( |
|
89 | - 'action' => 'delete_category', |
|
90 | - 'VEN_CAT_ID' => $item->get('term_id'), |
|
91 | - ); |
|
92 | - |
|
93 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
94 | - $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_VENUES_ADMIN_URL); |
|
95 | - |
|
96 | - $actions = array( |
|
97 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
98 | - 'Edit Category', |
|
99 | - 'event_espresso' |
|
100 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
101 | - ); |
|
102 | - |
|
103 | - |
|
104 | - $actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__( |
|
105 | - 'Delete Category', |
|
106 | - 'event_espresso' |
|
107 | - ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
108 | - |
|
109 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get( |
|
110 | - 'name' |
|
111 | - ) . '</a></strong>'; |
|
112 | - $content .= $this->row_actions($actions); |
|
113 | - return $content; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - public function column_shortcode($item) |
|
118 | - { |
|
119 | - $content = '[EVENT_ESPRESSO_CATEGORY category_id="' . $item->get_first_related('Term')->get('slug') . '"]'; |
|
120 | - return $content; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - public function column_count($item) |
|
125 | - { |
|
126 | - $e_args = array( |
|
127 | - 'action' => 'default', |
|
128 | - 'category' => $item->get_first_related('Term')->ID(), |
|
129 | - ); |
|
130 | - $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EE_VENUES_ADMIN_URL); |
|
131 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
132 | - return $content; |
|
133 | - } |
|
18 | + protected function _setup_data() |
|
19 | + { |
|
20 | + $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
21 | + $this->_all_data_count = $this->_admin_page->get_categories($this->_per_page, $this->_current_page, true); |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + protected function _set_properties() |
|
26 | + { |
|
27 | + $this->_wp_list_args = array( |
|
28 | + 'singular' => esc_html__('venue category', 'event_espresso'), |
|
29 | + 'plural' => esc_html__('venue categories', 'event_espresso'), |
|
30 | + 'ajax' => true, // for now, |
|
31 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
32 | + ); |
|
33 | + |
|
34 | + $this->_columns = array( |
|
35 | + 'cb' => '<input type="checkbox" />', |
|
36 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
37 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
38 | + // 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
39 | + 'count' => esc_html__('Venues', 'event_espresso'), |
|
40 | + ); |
|
41 | + |
|
42 | + $this->_sortable_columns = array( |
|
43 | + 'id' => array('Term.term_id' => true), |
|
44 | + 'name' => array('Term.slug' => false), |
|
45 | + 'count' => array('term_count' => false), |
|
46 | + ); |
|
47 | + |
|
48 | + $this->_hidden_columns = array(); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + // not needed |
|
53 | + protected function _get_table_filters() |
|
54 | + { |
|
55 | + return array(); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + protected function _add_view_counts() |
|
60 | + { |
|
61 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + public function column_cb($item) |
|
66 | + { |
|
67 | + return sprintf('<input type="checkbox" name="VEN_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + public function column_id($item) |
|
72 | + { |
|
73 | + $content = $item->get('term_id'); |
|
74 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
75 | + 'name' |
|
76 | + ) . '</span>'; |
|
77 | + return $content; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + public function column_name($item) |
|
82 | + { |
|
83 | + $edit_query_args = array( |
|
84 | + 'action' => 'edit_category', |
|
85 | + 'VEN_CAT_ID' => $item->get('term_id'), |
|
86 | + ); |
|
87 | + |
|
88 | + $delete_query_args = array( |
|
89 | + 'action' => 'delete_category', |
|
90 | + 'VEN_CAT_ID' => $item->get('term_id'), |
|
91 | + ); |
|
92 | + |
|
93 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
94 | + $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_VENUES_ADMIN_URL); |
|
95 | + |
|
96 | + $actions = array( |
|
97 | + 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
98 | + 'Edit Category', |
|
99 | + 'event_espresso' |
|
100 | + ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
101 | + ); |
|
102 | + |
|
103 | + |
|
104 | + $actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__( |
|
105 | + 'Delete Category', |
|
106 | + 'event_espresso' |
|
107 | + ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
108 | + |
|
109 | + $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get( |
|
110 | + 'name' |
|
111 | + ) . '</a></strong>'; |
|
112 | + $content .= $this->row_actions($actions); |
|
113 | + return $content; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + public function column_shortcode($item) |
|
118 | + { |
|
119 | + $content = '[EVENT_ESPRESSO_CATEGORY category_id="' . $item->get_first_related('Term')->get('slug') . '"]'; |
|
120 | + return $content; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + public function column_count($item) |
|
125 | + { |
|
126 | + $e_args = array( |
|
127 | + 'action' => 'default', |
|
128 | + 'category' => $item->get_first_related('Term')->ID(), |
|
129 | + ); |
|
130 | + $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EE_VENUES_ADMIN_URL); |
|
131 | + $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
132 | + return $content; |
|
133 | + } |
|
134 | 134 | } |
@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | 'priority' => 'high', |
38 | 38 | 'context' => 'normal', |
39 | 39 | ), |
40 | - );/**/ |
|
40 | + ); /**/ |
|
41 | 41 | |
42 | 42 | $this->_scripts_styles = array( |
43 | 43 | 'registers' => array( |
44 | 44 | 'ee_event_venues' => array( |
45 | 45 | 'type' => 'js', |
46 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
46 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.js', |
|
47 | 47 | 'depends' => array('jquery'), |
48 | 48 | ), |
49 | 49 | 'ee_event_venues_css' => array( |
50 | 50 | 'type' => 'css', |
51 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
51 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.css', |
|
52 | 52 | ), |
53 | 53 | ), |
54 | 54 | 'enqueues' => array( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // first remove default venue callback |
75 | 75 | foreach ($callbacks as $key => $callback) { |
76 | 76 | if ($callback[1] == '_default_venue_update') { |
77 | - unset($callbacks[ $key ]); |
|
77 | + unset($callbacks[$key]); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | // cap checks |
105 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
105 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | 106 | $vnu_where['VNU_wp_user'] = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | $ven_select[0] = esc_html__('Select a Venue', 'event_espresso'); |
114 | 114 | // setup venues for selector |
115 | 115 | foreach ($venues as $venue) { |
116 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
116 | + $ven_select[$venue->ID()] = $venue->name(); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
120 | 120 | // show existing attached venues even if it's trashed (or some other restricted status). |
121 | 121 | |
122 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
122 | + if ($evt_venue_id && ! isset($ven_select[$evt_venue_id])) { |
|
123 | + $ven_select[$evt_venue_id] = $evt_venue->name(); |
|
124 | 124 | $venues = array_merge($venues, array($evt_venue)); |
125 | 125 | } |
126 | 126 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ); |
185 | 185 | |
186 | 186 | $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
187 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
187 | + : EE_VENUES_TEMPLATE_PATH.'event_venues_metabox_content_from_manager.template.php'; |
|
188 | 188 | |
189 | 189 | // Allow events venue metabox template args filtering. |
190 | 190 | $template_args = apply_filters( |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $evt_venue = $evtobj->venues(); |
208 | 208 | $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
209 | 209 | |
210 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
210 | + if ( ! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | 211 | $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
212 | 212 | } |
213 | 213 |
@@ -14,207 +14,207 @@ |
||
14 | 14 | */ |
15 | 15 | class espresso_events_Venues_Hooks extends EE_Admin_Hooks |
16 | 16 | { |
17 | - protected $_event; |
|
18 | - |
|
19 | - |
|
20 | - public function __construct(EE_Admin_Page $admin_page) |
|
21 | - { |
|
22 | - parent::__construct($admin_page); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - protected function _set_hooks_properties() |
|
27 | - { |
|
28 | - $this->_name = 'venues'; |
|
29 | - |
|
30 | - $this->_metaboxes = array( |
|
31 | - 0 => array( |
|
32 | - 'page_route' => array('edit', 'create_new'), |
|
33 | - 'func' => 'venue_metabox', |
|
34 | - 'label' => esc_html__('Venue Details', 'event_espresso'), |
|
35 | - 'priority' => 'high', |
|
36 | - 'context' => 'normal', |
|
37 | - ), |
|
38 | - );/**/ |
|
39 | - |
|
40 | - $this->_scripts_styles = array( |
|
41 | - 'registers' => array( |
|
42 | - 'ee_event_venues' => array( |
|
43 | - 'type' => 'js', |
|
44 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
45 | - 'depends' => array('jquery'), |
|
46 | - ), |
|
47 | - 'ee_event_venues_css' => array( |
|
48 | - 'type' => 'css', |
|
49 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
50 | - ), |
|
51 | - ), |
|
52 | - 'enqueues' => array( |
|
53 | - 'ee_event_venues' => array('edit', 'create_new'), |
|
54 | - 'ee_event_venues_css' => array('edit', 'create_new'), |
|
55 | - ), |
|
56 | - ); |
|
57 | - |
|
58 | - // hook into the handler for saving venue |
|
59 | - add_filter( |
|
60 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
61 | - array($this, 'modify_callbacks'), |
|
62 | - 10 |
|
63 | - ); |
|
64 | - |
|
65 | - // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
66 | - add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - public function modify_callbacks($callbacks) |
|
71 | - { |
|
72 | - // first remove default venue callback |
|
73 | - foreach ($callbacks as $key => $callback) { |
|
74 | - if ($callback[1] == '_default_venue_update') { |
|
75 | - unset($callbacks[ $key ]); |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - // now let's add the caf version |
|
80 | - $callbacks[] = array($this, 'caf_venue_update'); |
|
81 | - return $callbacks; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - public function venue_metabox() |
|
86 | - { |
|
87 | - $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
88 | - $evt_id = $evt_obj->ID(); |
|
89 | - |
|
90 | - // first let's see if we have a venue already |
|
91 | - $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
92 | - $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
93 | - $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
94 | - |
|
95 | - // possibly private venues. |
|
96 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
97 | - $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
98 | - } else { |
|
99 | - $vnu_where['status'] = 'publish'; |
|
100 | - } |
|
101 | - |
|
102 | - // cap checks |
|
103 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
104 | - $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
105 | - } |
|
106 | - |
|
107 | - $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
108 | - $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
109 | - |
|
110 | - $ven_select = array(); |
|
111 | - $ven_select[0] = esc_html__('Select a Venue', 'event_espresso'); |
|
112 | - // setup venues for selector |
|
113 | - foreach ($venues as $venue) { |
|
114 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
115 | - } |
|
116 | - |
|
117 | - // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
118 | - // show existing attached venues even if it's trashed (or some other restricted status). |
|
119 | - |
|
120 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
121 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
122 | - $venues = array_merge($venues, array($evt_venue)); |
|
123 | - } |
|
124 | - |
|
125 | - $template_args['venues'] = $venues; |
|
126 | - $template_args['evt_venue_id'] = $evt_venue_id; |
|
127 | - $venue_selector = new EE_Select_Input( |
|
128 | - $ven_select, |
|
129 | - array( |
|
130 | - 'html_name' => 'venue_id', |
|
131 | - 'html_id' => 'venue_id', |
|
132 | - 'html_class' => 'wide', |
|
133 | - 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
134 | - ) |
|
135 | - ); |
|
136 | - $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
137 | - $enable_for_gmap = new EE_Yes_No_Input( |
|
138 | - array( |
|
139 | - 'html_name' => 'enable_for_gmap', |
|
140 | - 'html_id' => 'enable_for_gmap', |
|
141 | - 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
142 | - ) |
|
143 | - ); |
|
144 | - $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
145 | - $template_args['new_venue_link'] = EEH_HTML::link( |
|
146 | - EE_Admin_Page::add_query_args_and_nonce( |
|
147 | - array('action' => 'create_new'), |
|
148 | - EE_VENUES_ADMIN_URL |
|
149 | - ), |
|
150 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
151 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
152 | - 'ev_new_venue_link', |
|
153 | - 'button', |
|
154 | - 'margin-left:10px;', |
|
155 | - 'target="_blank"' |
|
156 | - ); |
|
157 | - |
|
158 | - // Decide on an info text when there are no venues to display. |
|
159 | - $no_venues_info_txt = esc_html_x( |
|
160 | - 'You have not created any venues yet.', |
|
161 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
162 | - 'event_espresso' |
|
163 | - ); |
|
164 | - if (empty($venues)) { |
|
165 | - $unpublished_where = $vnu_where; |
|
166 | - $unpublished_where['status'] = 'draft'; |
|
167 | - $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
168 | - if (count($unpublished_venues) > 0) { |
|
169 | - $no_venues_info_txt = esc_html_x( |
|
170 | - // @codingStandardsIgnoreStart |
|
171 | - 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
172 | - // @codingStandardsIgnoreEnd |
|
173 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
174 | - 'event_espresso' |
|
175 | - ); |
|
176 | - } |
|
177 | - } |
|
178 | - $template_args['no_venues_info'] = EEH_HTML::p( |
|
179 | - EEH_HTML::strong($no_venues_info_txt), |
|
180 | - 'no_venues_info', |
|
181 | - 'info' |
|
182 | - ); |
|
183 | - |
|
184 | - $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
185 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
186 | - |
|
187 | - // Allow events venue metabox template args filtering. |
|
188 | - $template_args = apply_filters( |
|
189 | - 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
190 | - $template_args, |
|
191 | - $template_path |
|
192 | - ); |
|
193 | - |
|
194 | - EEH_Template::display_template($template_path, $template_args); |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - public function caf_venue_update($evtobj, $data) |
|
199 | - { |
|
200 | - EE_Registry::instance()->load_model('Venue'); |
|
201 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
202 | - |
|
203 | - |
|
204 | - // first let's check if the selected venue matches any existing venue attached to the event |
|
205 | - $evt_venue = $evtobj->venues(); |
|
206 | - $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
207 | - |
|
208 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
209 | - $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
210 | - } |
|
211 | - |
|
212 | - if (empty($venue_id)) { |
|
213 | - return true; |
|
214 | - } //no venue to attach |
|
215 | - |
|
216 | - // this should take care of adding to revisions as well as main post object |
|
217 | - $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
218 | - return ! empty($success) ? true : false; |
|
219 | - } |
|
17 | + protected $_event; |
|
18 | + |
|
19 | + |
|
20 | + public function __construct(EE_Admin_Page $admin_page) |
|
21 | + { |
|
22 | + parent::__construct($admin_page); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + protected function _set_hooks_properties() |
|
27 | + { |
|
28 | + $this->_name = 'venues'; |
|
29 | + |
|
30 | + $this->_metaboxes = array( |
|
31 | + 0 => array( |
|
32 | + 'page_route' => array('edit', 'create_new'), |
|
33 | + 'func' => 'venue_metabox', |
|
34 | + 'label' => esc_html__('Venue Details', 'event_espresso'), |
|
35 | + 'priority' => 'high', |
|
36 | + 'context' => 'normal', |
|
37 | + ), |
|
38 | + );/**/ |
|
39 | + |
|
40 | + $this->_scripts_styles = array( |
|
41 | + 'registers' => array( |
|
42 | + 'ee_event_venues' => array( |
|
43 | + 'type' => 'js', |
|
44 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
45 | + 'depends' => array('jquery'), |
|
46 | + ), |
|
47 | + 'ee_event_venues_css' => array( |
|
48 | + 'type' => 'css', |
|
49 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
50 | + ), |
|
51 | + ), |
|
52 | + 'enqueues' => array( |
|
53 | + 'ee_event_venues' => array('edit', 'create_new'), |
|
54 | + 'ee_event_venues_css' => array('edit', 'create_new'), |
|
55 | + ), |
|
56 | + ); |
|
57 | + |
|
58 | + // hook into the handler for saving venue |
|
59 | + add_filter( |
|
60 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
61 | + array($this, 'modify_callbacks'), |
|
62 | + 10 |
|
63 | + ); |
|
64 | + |
|
65 | + // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
66 | + add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + public function modify_callbacks($callbacks) |
|
71 | + { |
|
72 | + // first remove default venue callback |
|
73 | + foreach ($callbacks as $key => $callback) { |
|
74 | + if ($callback[1] == '_default_venue_update') { |
|
75 | + unset($callbacks[ $key ]); |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + // now let's add the caf version |
|
80 | + $callbacks[] = array($this, 'caf_venue_update'); |
|
81 | + return $callbacks; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + public function venue_metabox() |
|
86 | + { |
|
87 | + $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
88 | + $evt_id = $evt_obj->ID(); |
|
89 | + |
|
90 | + // first let's see if we have a venue already |
|
91 | + $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
92 | + $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
93 | + $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
94 | + |
|
95 | + // possibly private venues. |
|
96 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
97 | + $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
98 | + } else { |
|
99 | + $vnu_where['status'] = 'publish'; |
|
100 | + } |
|
101 | + |
|
102 | + // cap checks |
|
103 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
104 | + $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
105 | + } |
|
106 | + |
|
107 | + $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
108 | + $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
109 | + |
|
110 | + $ven_select = array(); |
|
111 | + $ven_select[0] = esc_html__('Select a Venue', 'event_espresso'); |
|
112 | + // setup venues for selector |
|
113 | + foreach ($venues as $venue) { |
|
114 | + $ven_select[ $venue->ID() ] = $venue->name(); |
|
115 | + } |
|
116 | + |
|
117 | + // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
118 | + // show existing attached venues even if it's trashed (or some other restricted status). |
|
119 | + |
|
120 | + if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
121 | + $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
122 | + $venues = array_merge($venues, array($evt_venue)); |
|
123 | + } |
|
124 | + |
|
125 | + $template_args['venues'] = $venues; |
|
126 | + $template_args['evt_venue_id'] = $evt_venue_id; |
|
127 | + $venue_selector = new EE_Select_Input( |
|
128 | + $ven_select, |
|
129 | + array( |
|
130 | + 'html_name' => 'venue_id', |
|
131 | + 'html_id' => 'venue_id', |
|
132 | + 'html_class' => 'wide', |
|
133 | + 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
134 | + ) |
|
135 | + ); |
|
136 | + $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
137 | + $enable_for_gmap = new EE_Yes_No_Input( |
|
138 | + array( |
|
139 | + 'html_name' => 'enable_for_gmap', |
|
140 | + 'html_id' => 'enable_for_gmap', |
|
141 | + 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
142 | + ) |
|
143 | + ); |
|
144 | + $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
145 | + $template_args['new_venue_link'] = EEH_HTML::link( |
|
146 | + EE_Admin_Page::add_query_args_and_nonce( |
|
147 | + array('action' => 'create_new'), |
|
148 | + EE_VENUES_ADMIN_URL |
|
149 | + ), |
|
150 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
151 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
152 | + 'ev_new_venue_link', |
|
153 | + 'button', |
|
154 | + 'margin-left:10px;', |
|
155 | + 'target="_blank"' |
|
156 | + ); |
|
157 | + |
|
158 | + // Decide on an info text when there are no venues to display. |
|
159 | + $no_venues_info_txt = esc_html_x( |
|
160 | + 'You have not created any venues yet.', |
|
161 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
162 | + 'event_espresso' |
|
163 | + ); |
|
164 | + if (empty($venues)) { |
|
165 | + $unpublished_where = $vnu_where; |
|
166 | + $unpublished_where['status'] = 'draft'; |
|
167 | + $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
168 | + if (count($unpublished_venues) > 0) { |
|
169 | + $no_venues_info_txt = esc_html_x( |
|
170 | + // @codingStandardsIgnoreStart |
|
171 | + 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
172 | + // @codingStandardsIgnoreEnd |
|
173 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
174 | + 'event_espresso' |
|
175 | + ); |
|
176 | + } |
|
177 | + } |
|
178 | + $template_args['no_venues_info'] = EEH_HTML::p( |
|
179 | + EEH_HTML::strong($no_venues_info_txt), |
|
180 | + 'no_venues_info', |
|
181 | + 'info' |
|
182 | + ); |
|
183 | + |
|
184 | + $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
185 | + : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
186 | + |
|
187 | + // Allow events venue metabox template args filtering. |
|
188 | + $template_args = apply_filters( |
|
189 | + 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
190 | + $template_args, |
|
191 | + $template_path |
|
192 | + ); |
|
193 | + |
|
194 | + EEH_Template::display_template($template_path, $template_args); |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + public function caf_venue_update($evtobj, $data) |
|
199 | + { |
|
200 | + EE_Registry::instance()->load_model('Venue'); |
|
201 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
202 | + |
|
203 | + |
|
204 | + // first let's check if the selected venue matches any existing venue attached to the event |
|
205 | + $evt_venue = $evtobj->venues(); |
|
206 | + $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
207 | + |
|
208 | + if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
209 | + $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
210 | + } |
|
211 | + |
|
212 | + if (empty($venue_id)) { |
|
213 | + return true; |
|
214 | + } //no venue to attach |
|
215 | + |
|
216 | + // this should take care of adding to revisions as well as main post object |
|
217 | + $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
218 | + return ! empty($success) ? true : false; |
|
219 | + } |
|
220 | 220 | } |
@@ -20,10 +20,10 @@ |
||
20 | 20 | // define some events related constants |
21 | 21 | define('EE_ABOUT_PG_SLUG', 'espresso_about'); |
22 | 22 | define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso')); |
23 | - define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/'); |
|
24 | - define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG)); |
|
25 | - define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/'); |
|
26 | - define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/'); |
|
23 | + define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES.'about/'); |
|
24 | + define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page='.EE_ABOUT_PG_SLUG)); |
|
25 | + define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN.'templates/'); |
|
26 | + define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL.'about/assets/'); |
|
27 | 27 | parent::__construct(); |
28 | 28 | } |
29 | 29 |
@@ -14,37 +14,37 @@ |
||
14 | 14 | */ |
15 | 15 | class About_Admin_Page_Init extends EE_Admin_Page_Init |
16 | 16 | { |
17 | - public function __construct() |
|
18 | - { |
|
19 | - // define some events related constants |
|
20 | - define('EE_ABOUT_PG_SLUG', 'espresso_about'); |
|
21 | - define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso')); |
|
22 | - define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/'); |
|
23 | - define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG)); |
|
24 | - define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/'); |
|
25 | - define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/'); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + // define some events related constants |
|
20 | + define('EE_ABOUT_PG_SLUG', 'espresso_about'); |
|
21 | + define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso')); |
|
22 | + define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/'); |
|
23 | + define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG)); |
|
24 | + define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/'); |
|
25 | + define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/'); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | - protected function _set_init_properties() |
|
30 | - { |
|
31 | - $this->label = esc_html__('About Event Espresso', 'event_espresso'); |
|
32 | - } |
|
29 | + protected function _set_init_properties() |
|
30 | + { |
|
31 | + $this->label = esc_html__('About Event Espresso', 'event_espresso'); |
|
32 | + } |
|
33 | 33 | |
34 | - protected function _set_menu_map() |
|
35 | - { |
|
36 | - $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
37 | - array( |
|
38 | - 'menu_group' => 'extras', |
|
39 | - 'menu_order' => 40, |
|
40 | - 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN, |
|
41 | - 'parent_slug' => 'espresso_events', |
|
42 | - 'menu_slug' => 'espresso_about', |
|
43 | - 'menu_label' => EE_ABOUT_LABEL, |
|
44 | - 'capability' => 'manage_options', |
|
45 | - 'maintenance_mode_parent' => 'espresso_maintenance_settings', |
|
46 | - 'admin_init_page' => $this, |
|
47 | - ) |
|
48 | - ); |
|
49 | - } |
|
34 | + protected function _set_menu_map() |
|
35 | + { |
|
36 | + $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
37 | + array( |
|
38 | + 'menu_group' => 'extras', |
|
39 | + 'menu_order' => 40, |
|
40 | + 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN, |
|
41 | + 'parent_slug' => 'espresso_events', |
|
42 | + 'menu_slug' => 'espresso_about', |
|
43 | + 'menu_label' => EE_ABOUT_LABEL, |
|
44 | + 'capability' => 'manage_options', |
|
45 | + 'maintenance_mode_parent' => 'espresso_maintenance_settings', |
|
46 | + 'admin_init_page' => $this, |
|
47 | + ) |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | // define some constants |
24 | 24 | define('GEN_SET_PG_SLUG', 'espresso_general_settings'); |
25 | 25 | define('GEN_SET_LABEL', esc_html__('General Settings', 'event_espresso')); |
26 | - define('GEN_SET_ADMIN', EE_ADMIN_PAGES . 'general_settings/'); |
|
27 | - define('GEN_SET_ADMIN_URL', admin_url('admin.php?page=' . GEN_SET_PG_SLUG)); |
|
28 | - define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN . 'templates/'); |
|
29 | - define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL . 'general_settings/assets/'); |
|
26 | + define('GEN_SET_ADMIN', EE_ADMIN_PAGES.'general_settings/'); |
|
27 | + define('GEN_SET_ADMIN_URL', admin_url('admin.php?page='.GEN_SET_PG_SLUG)); |
|
28 | + define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN.'templates/'); |
|
29 | + define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL.'general_settings/assets/'); |
|
30 | 30 | |
31 | 31 | parent::__construct(); |
32 | 32 | } |
@@ -17,37 +17,37 @@ |
||
17 | 17 | */ |
18 | 18 | class General_Settings_Admin_Page_Init extends EE_Admin_Page_Init |
19 | 19 | { |
20 | - public function __construct() |
|
21 | - { |
|
22 | - // define some constants |
|
23 | - define('GEN_SET_PG_SLUG', 'espresso_general_settings'); |
|
24 | - define('GEN_SET_LABEL', esc_html__('General Settings', 'event_espresso')); |
|
25 | - define('GEN_SET_ADMIN', EE_ADMIN_PAGES . 'general_settings/'); |
|
26 | - define('GEN_SET_ADMIN_URL', admin_url('admin.php?page=' . GEN_SET_PG_SLUG)); |
|
27 | - define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN . 'templates/'); |
|
28 | - define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL . 'general_settings/assets/'); |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + // define some constants |
|
23 | + define('GEN_SET_PG_SLUG', 'espresso_general_settings'); |
|
24 | + define('GEN_SET_LABEL', esc_html__('General Settings', 'event_espresso')); |
|
25 | + define('GEN_SET_ADMIN', EE_ADMIN_PAGES . 'general_settings/'); |
|
26 | + define('GEN_SET_ADMIN_URL', admin_url('admin.php?page=' . GEN_SET_PG_SLUG)); |
|
27 | + define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN . 'templates/'); |
|
28 | + define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL . 'general_settings/assets/'); |
|
29 | 29 | |
30 | - parent::__construct(); |
|
31 | - } |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | - protected function _set_init_properties() |
|
34 | - { |
|
35 | - $this->label = GEN_SET_LABEL; |
|
36 | - } |
|
33 | + protected function _set_init_properties() |
|
34 | + { |
|
35 | + $this->label = GEN_SET_LABEL; |
|
36 | + } |
|
37 | 37 | |
38 | - protected function _set_menu_map() |
|
39 | - { |
|
40 | - $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
41 | - array( |
|
42 | - 'menu_group' => 'settings', |
|
43 | - 'menu_order' => 20, |
|
44 | - 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
45 | - 'parent_slug' => 'espresso_events', |
|
46 | - 'menu_slug' => GEN_SET_PG_SLUG, |
|
47 | - 'menu_label' => GEN_SET_LABEL, |
|
48 | - 'capability' => 'manage_options', |
|
49 | - 'admin_init_page' => $this, |
|
50 | - ) |
|
51 | - ); |
|
52 | - } |
|
38 | + protected function _set_menu_map() |
|
39 | + { |
|
40 | + $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
41 | + array( |
|
42 | + 'menu_group' => 'settings', |
|
43 | + 'menu_order' => 20, |
|
44 | + 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
45 | + 'parent_slug' => 'espresso_events', |
|
46 | + 'menu_slug' => GEN_SET_PG_SLUG, |
|
47 | + 'menu_label' => GEN_SET_LABEL, |
|
48 | + 'capability' => 'manage_options', |
|
49 | + 'admin_init_page' => $this, |
|
50 | + ) |
|
51 | + ); |
|
52 | + } |
|
53 | 53 | } |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | { |
88 | 88 | $system_question = $item->is_system_question(); |
89 | 89 | $related_answer_count = $item->count_related('Answer'); |
90 | - $lock_icon = (! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
90 | + $lock_icon = ( ! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
91 | 91 | ? 'ee-lock-icon ee-alternate-color' : 'ee-lock-icon ee-system-lock'; |
92 | - return $system_question || (! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
93 | - ? '<span class="' . $lock_icon . '"></span>' . sprintf( |
|
92 | + return $system_question || ( ! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
93 | + ? '<span class="'.$lock_icon.'"></span>'.sprintf( |
|
94 | 94 | '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', |
95 | 95 | $item->ID() |
96 | 96 | ) : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID()); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public function column_id(EE_Question $item) |
101 | 101 | { |
102 | 102 | $content = $item->ID(); |
103 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->display_text() . '</span>'; |
|
103 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->display_text().'</span>'; |
|
104 | 104 | return $content; |
105 | 105 | } |
106 | 106 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | $system_question = $item->is_system_question(); |
111 | 111 | |
112 | - if (! defined('REG_ADMIN_URL')) { |
|
112 | + if ( ! defined('REG_ADMIN_URL')) { |
|
113 | 113 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
114 | 114 | } |
115 | 115 | |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL); |
129 | 129 | |
130 | 130 | $actions = array( |
131 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
131 | + 'edit' => '<a href="'.$edit_link.'" title="'.esc_attr__( |
|
132 | 132 | 'Edit Event', |
133 | 133 | 'event_espresso' |
134 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
134 | + ).'">'.esc_html__('Edit', 'event_espresso').'</a>', |
|
135 | 135 | ); |
136 | 136 | } |
137 | 137 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'ee_edit_question', |
141 | 141 | 'espresso_registration_form_edit_question', |
142 | 142 | $item->ID() |
143 | - ) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>' |
|
143 | + ) ? '<strong><a class="row-title" href="'.$edit_link.'">'.$item->display_text().'</a></strong>' |
|
144 | 144 | : $item->display_text(); |
145 | 145 | $content .= $this->row_actions($actions); |
146 | 146 | return $content; |
@@ -15,166 +15,166 @@ |
||
15 | 15 | */ |
16 | 16 | class Registration_Form_Questions_Admin_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - public function __construct($admin_page) |
|
19 | - { |
|
20 | - parent::__construct($admin_page); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - protected function _setup_data() |
|
25 | - { |
|
26 | - if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') { |
|
27 | - $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false); |
|
28 | - } else { |
|
29 | - $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false); |
|
30 | - } |
|
31 | - $this->_all_data_count = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - protected function _set_properties() |
|
36 | - { |
|
37 | - $this->_wp_list_args = array( |
|
38 | - 'singular' => esc_html__('question', 'event_espresso'), |
|
39 | - 'plural' => esc_html__('questions', 'event_espresso'), |
|
40 | - 'ajax' => true, // for now, |
|
41 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
42 | - ); |
|
43 | - |
|
44 | - $this->_columns = array( |
|
45 | - 'cb' => '<input type="checkbox" />', |
|
46 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
47 | - 'display_text' => esc_html__('Question', 'event_espresso'), |
|
48 | - 'admin_label' => esc_html__('Admin Label', 'event_espresso'), |
|
49 | - 'type' => esc_html__('Type', 'event_espresso'), |
|
50 | - 'values' => esc_html__('Values', 'event_espresso'), |
|
51 | - 'required' => esc_html__('Req', 'event_espresso'), |
|
52 | - ); |
|
53 | - |
|
54 | - $this->_sortable_columns = array( |
|
55 | - 'id' => array('QST_ID' => false), |
|
56 | - 'display_text' => array('QST_display_text' => false), |
|
57 | - ); |
|
58 | - |
|
59 | - $this->_hidden_columns = array(); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - // not needed |
|
64 | - protected function _get_table_filters() |
|
65 | - { |
|
66 | - return array(); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - protected function _add_view_counts() |
|
71 | - { |
|
72 | - $this->_views['all']['count'] = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
73 | - if ( |
|
74 | - EE_Registry::instance()->CAP->current_user_can( |
|
75 | - 'ee_delete_questions', |
|
76 | - 'espresso_registration_form_trash_question' |
|
77 | - ) |
|
78 | - ) { |
|
79 | - $this->_views['trash']['count'] = $this->_admin_page->get_trashed_questions(-1, $this->_current_page, true); |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - public function column_cb($item) |
|
85 | - { |
|
86 | - $system_question = $item->is_system_question(); |
|
87 | - $related_answer_count = $item->count_related('Answer'); |
|
88 | - $lock_icon = (! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
89 | - ? 'ee-lock-icon ee-alternate-color' : 'ee-lock-icon ee-system-lock'; |
|
90 | - return $system_question || (! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
91 | - ? '<span class="' . $lock_icon . '"></span>' . sprintf( |
|
92 | - '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', |
|
93 | - $item->ID() |
|
94 | - ) : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID()); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - public function column_id(EE_Question $item) |
|
99 | - { |
|
100 | - $content = $item->ID(); |
|
101 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->display_text() . '</span>'; |
|
102 | - return $content; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - public function column_display_text(EE_Question $item) |
|
107 | - { |
|
108 | - $system_question = $item->is_system_question(); |
|
109 | - |
|
110 | - if (! defined('REG_ADMIN_URL')) { |
|
111 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
112 | - } |
|
113 | - |
|
114 | - $edit_query_args = array( |
|
115 | - 'action' => 'edit_question', |
|
116 | - 'QST_ID' => $item->ID(), |
|
117 | - ); |
|
118 | - |
|
119 | - if ( |
|
120 | - EE_Registry::instance()->CAP->current_user_can( |
|
121 | - 'ee_edit_question', |
|
122 | - 'espresso_registration_form_edit_question', |
|
123 | - $item->ID() |
|
124 | - ) |
|
125 | - ) { |
|
126 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL); |
|
127 | - |
|
128 | - $actions = array( |
|
129 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
130 | - 'Edit Event', |
|
131 | - 'event_espresso' |
|
132 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
133 | - ); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
138 | - 'ee_edit_question', |
|
139 | - 'espresso_registration_form_edit_question', |
|
140 | - $item->ID() |
|
141 | - ) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>' |
|
142 | - : $item->display_text(); |
|
143 | - $content .= $this->row_actions($actions); |
|
144 | - return $content; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - public function column_admin_label(EE_Question $item) |
|
149 | - { |
|
150 | - return $item->admin_label(); |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - public function column_values(EE_Question $item) |
|
155 | - { |
|
156 | - $optionNames = array(); |
|
157 | - $options = $item->options(); |
|
158 | - if (empty($options)) { |
|
159 | - return "N/A"; |
|
160 | - } else { |
|
161 | - foreach ($options as $optionID => $option) { |
|
162 | - /* @var $option EE_Question_Option */ |
|
163 | - $optionNames[] = $option->value(); |
|
164 | - } |
|
165 | - return implode(', ', $optionNames); |
|
166 | - } |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - public function column_type(EE_Question $item) |
|
171 | - { |
|
172 | - return $item->type(); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - public function column_required(EE_Question $item) |
|
177 | - { |
|
178 | - return $item->required() ? 'Yes' : ''; |
|
179 | - } |
|
18 | + public function __construct($admin_page) |
|
19 | + { |
|
20 | + parent::__construct($admin_page); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + protected function _setup_data() |
|
25 | + { |
|
26 | + if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') { |
|
27 | + $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false); |
|
28 | + } else { |
|
29 | + $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false); |
|
30 | + } |
|
31 | + $this->_all_data_count = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + protected function _set_properties() |
|
36 | + { |
|
37 | + $this->_wp_list_args = array( |
|
38 | + 'singular' => esc_html__('question', 'event_espresso'), |
|
39 | + 'plural' => esc_html__('questions', 'event_espresso'), |
|
40 | + 'ajax' => true, // for now, |
|
41 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
42 | + ); |
|
43 | + |
|
44 | + $this->_columns = array( |
|
45 | + 'cb' => '<input type="checkbox" />', |
|
46 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
47 | + 'display_text' => esc_html__('Question', 'event_espresso'), |
|
48 | + 'admin_label' => esc_html__('Admin Label', 'event_espresso'), |
|
49 | + 'type' => esc_html__('Type', 'event_espresso'), |
|
50 | + 'values' => esc_html__('Values', 'event_espresso'), |
|
51 | + 'required' => esc_html__('Req', 'event_espresso'), |
|
52 | + ); |
|
53 | + |
|
54 | + $this->_sortable_columns = array( |
|
55 | + 'id' => array('QST_ID' => false), |
|
56 | + 'display_text' => array('QST_display_text' => false), |
|
57 | + ); |
|
58 | + |
|
59 | + $this->_hidden_columns = array(); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + // not needed |
|
64 | + protected function _get_table_filters() |
|
65 | + { |
|
66 | + return array(); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + protected function _add_view_counts() |
|
71 | + { |
|
72 | + $this->_views['all']['count'] = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
73 | + if ( |
|
74 | + EE_Registry::instance()->CAP->current_user_can( |
|
75 | + 'ee_delete_questions', |
|
76 | + 'espresso_registration_form_trash_question' |
|
77 | + ) |
|
78 | + ) { |
|
79 | + $this->_views['trash']['count'] = $this->_admin_page->get_trashed_questions(-1, $this->_current_page, true); |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + public function column_cb($item) |
|
85 | + { |
|
86 | + $system_question = $item->is_system_question(); |
|
87 | + $related_answer_count = $item->count_related('Answer'); |
|
88 | + $lock_icon = (! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
89 | + ? 'ee-lock-icon ee-alternate-color' : 'ee-lock-icon ee-system-lock'; |
|
90 | + return $system_question || (! $system_question && $related_answer_count > 0 && $this->_view == 'trash') |
|
91 | + ? '<span class="' . $lock_icon . '"></span>' . sprintf( |
|
92 | + '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', |
|
93 | + $item->ID() |
|
94 | + ) : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID()); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + public function column_id(EE_Question $item) |
|
99 | + { |
|
100 | + $content = $item->ID(); |
|
101 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->display_text() . '</span>'; |
|
102 | + return $content; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + public function column_display_text(EE_Question $item) |
|
107 | + { |
|
108 | + $system_question = $item->is_system_question(); |
|
109 | + |
|
110 | + if (! defined('REG_ADMIN_URL')) { |
|
111 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
112 | + } |
|
113 | + |
|
114 | + $edit_query_args = array( |
|
115 | + 'action' => 'edit_question', |
|
116 | + 'QST_ID' => $item->ID(), |
|
117 | + ); |
|
118 | + |
|
119 | + if ( |
|
120 | + EE_Registry::instance()->CAP->current_user_can( |
|
121 | + 'ee_edit_question', |
|
122 | + 'espresso_registration_form_edit_question', |
|
123 | + $item->ID() |
|
124 | + ) |
|
125 | + ) { |
|
126 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL); |
|
127 | + |
|
128 | + $actions = array( |
|
129 | + 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__( |
|
130 | + 'Edit Event', |
|
131 | + 'event_espresso' |
|
132 | + ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
133 | + ); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
138 | + 'ee_edit_question', |
|
139 | + 'espresso_registration_form_edit_question', |
|
140 | + $item->ID() |
|
141 | + ) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>' |
|
142 | + : $item->display_text(); |
|
143 | + $content .= $this->row_actions($actions); |
|
144 | + return $content; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + public function column_admin_label(EE_Question $item) |
|
149 | + { |
|
150 | + return $item->admin_label(); |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + public function column_values(EE_Question $item) |
|
155 | + { |
|
156 | + $optionNames = array(); |
|
157 | + $options = $item->options(); |
|
158 | + if (empty($options)) { |
|
159 | + return "N/A"; |
|
160 | + } else { |
|
161 | + foreach ($options as $optionID => $option) { |
|
162 | + /* @var $option EE_Question_Option */ |
|
163 | + $optionNames[] = $option->value(); |
|
164 | + } |
|
165 | + return implode(', ', $optionNames); |
|
166 | + } |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + public function column_type(EE_Question $item) |
|
171 | + { |
|
172 | + return $item->type(); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + public function column_required(EE_Question $item) |
|
177 | + { |
|
178 | + return $item->required() ? 'Yes' : ''; |
|
179 | + } |
|
180 | 180 | } |
@@ -24,13 +24,13 @@ |
||
24 | 24 | define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form'); |
25 | 25 | define('REGISTRATION_FORM_LABEL', esc_html__('Registration Form', 'event_espresso')); |
26 | 26 | define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL); |
27 | - define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/'); |
|
28 | - define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG)); |
|
29 | - define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG)); |
|
30 | - define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/'); |
|
31 | - define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/'); |
|
32 | - define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/'); |
|
33 | - define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/'); |
|
27 | + define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES.'registration_form/'); |
|
28 | + define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG)); |
|
29 | + define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG)); |
|
30 | + define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN.'assets/'); |
|
31 | + define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL.'registration_form/assets/'); |
|
32 | + define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN.'templates/'); |
|
33 | + define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registration_form/templates/'); |
|
34 | 34 | parent::__construct(); |
35 | 35 | } |
36 | 36 |
@@ -17,41 +17,41 @@ |
||
17 | 17 | */ |
18 | 18 | class Registration_Form_Admin_Page_Init extends EE_Admin_Page_Init |
19 | 19 | { |
20 | - public function __construct() |
|
21 | - { |
|
22 | - // define some constants |
|
23 | - define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form'); |
|
24 | - define('REGISTRATION_FORM_LABEL', esc_html__('Registration Form', 'event_espresso')); |
|
25 | - define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL); |
|
26 | - define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/'); |
|
27 | - define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG)); |
|
28 | - define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG)); |
|
29 | - define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/'); |
|
30 | - define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/'); |
|
31 | - define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/'); |
|
32 | - define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/'); |
|
33 | - parent::__construct(); |
|
34 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + // define some constants |
|
23 | + define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form'); |
|
24 | + define('REGISTRATION_FORM_LABEL', esc_html__('Registration Form', 'event_espresso')); |
|
25 | + define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL); |
|
26 | + define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/'); |
|
27 | + define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG)); |
|
28 | + define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG)); |
|
29 | + define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/'); |
|
30 | + define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/'); |
|
31 | + define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/'); |
|
32 | + define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/'); |
|
33 | + parent::__construct(); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function _set_init_properties() |
|
37 | - { |
|
38 | - $this->label = esc_html__('Registration Form Overview', 'event_espresso'); |
|
39 | - } |
|
36 | + protected function _set_init_properties() |
|
37 | + { |
|
38 | + $this->label = esc_html__('Registration Form Overview', 'event_espresso'); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - protected function _set_menu_map() |
|
43 | - { |
|
44 | - $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
45 | - array( |
|
46 | - 'menu_group' => 'management', |
|
47 | - 'menu_order' => 30, |
|
48 | - 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
49 | - 'parent_slug' => 'espresso_events', |
|
50 | - 'menu_slug' => REGISTRATION_FORM_PG_SLUG, |
|
51 | - 'menu_label' => esc_html__('Registration Form', 'event_espresso'), |
|
52 | - 'capability' => 'ee_read_questions', |
|
53 | - 'admin_init_page' => $this, |
|
54 | - ) |
|
55 | - ); |
|
56 | - } |
|
42 | + protected function _set_menu_map() |
|
43 | + { |
|
44 | + $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
45 | + array( |
|
46 | + 'menu_group' => 'management', |
|
47 | + 'menu_order' => 30, |
|
48 | + 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
49 | + 'parent_slug' => 'espresso_events', |
|
50 | + 'menu_slug' => REGISTRATION_FORM_PG_SLUG, |
|
51 | + 'menu_label' => esc_html__('Registration Form', 'event_espresso'), |
|
52 | + 'capability' => 'ee_read_questions', |
|
53 | + 'admin_init_page' => $this, |
|
54 | + ) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | 'ee_delete_checkins', |
158 | 158 | 'espresso_registrations_delete_checkin_row' |
159 | 159 | ) |
160 | - ? '<a href="' . $delete_url . '" title="' |
|
161 | - . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
162 | - . esc_html__('Delete', 'event_espresso') . '</a>' |
|
160 | + ? '<a href="'.$delete_url.'" title="' |
|
161 | + . esc_attr__('Click here to delete this check-in record', 'event_espresso').'">' |
|
162 | + . esc_html__('Delete', 'event_espresso').'</a>' |
|
163 | 163 | : ''; |
164 | 164 | |
165 | 165 | return sprintf( |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | ? $this->_req_data['perpage'] |
222 | 222 | : $per_page; |
223 | 223 | $limit = null; |
224 | - if (! $count) { |
|
224 | + if ( ! $count) { |
|
225 | 225 | $offset = ($current_page - 1) * $per_page; |
226 | 226 | $limit = array($offset, $per_page); |
227 | 227 | } |
@@ -17,228 +17,228 @@ |
||
17 | 17 | */ |
18 | 18 | class EE_Registration_CheckIn_List_Table extends EE_Admin_List_Table |
19 | 19 | { |
20 | - /** |
|
21 | - * EE_Registration_CheckIn_List_Table constructor. |
|
22 | - * |
|
23 | - * @param EE_Admin_Page $admin_page |
|
24 | - */ |
|
25 | - public function __construct($admin_page) |
|
26 | - { |
|
27 | - parent::__construct($admin_page); |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @throws EE_Error |
|
33 | - */ |
|
34 | - protected function _setup_data() |
|
35 | - { |
|
36 | - $this->_data = $this->_get_checkins($this->_per_page); |
|
37 | - $this->_all_data_count = $this->_get_checkins($this->_per_page, true); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Sets up the properties for the list table. |
|
43 | - */ |
|
44 | - protected function _set_properties() |
|
45 | - { |
|
46 | - $this->_wp_list_args = array( |
|
47 | - 'singular' => esc_html__('check-in', 'event_espresso'), |
|
48 | - 'plural' => esc_html__('check-ins', 'event_espresso'), |
|
49 | - 'ajax' => true, |
|
50 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
51 | - ); |
|
52 | - |
|
53 | - $this->_columns = array( |
|
54 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
55 | - 'CHK_in' => esc_html__('Check-In', 'event_espresso'), |
|
56 | - 'CHK_timestamp' => esc_html__('Timestamp', 'event_espresso'), |
|
57 | - ); |
|
58 | - |
|
59 | - $this->_sortable_columns = array( |
|
60 | - 'CHK_timestamp' => array('CHK_timestamp' => true), |
|
61 | - ); |
|
62 | - |
|
63 | - $this->_primary_column = 'CHK_in'; |
|
64 | - |
|
65 | - $this->_hidden_columns = array(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - protected function _get_table_filters() |
|
73 | - { |
|
74 | - return []; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * Returning an empty string to remove the search box for this view. |
|
80 | - * |
|
81 | - * @param string $text |
|
82 | - * @param string $input_id |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function search_box($text, $input_id) |
|
86 | - { |
|
87 | - return ''; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @throws EE_Error |
|
93 | - */ |
|
94 | - protected function _add_view_counts() |
|
95 | - { |
|
96 | - $this->_views['all']['count'] = $this->_get_checkins(null, true); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @param EE_Checkin $item |
|
102 | - * @return string |
|
103 | - * @throws EE_Error |
|
104 | - * @throws InvalidArgumentException |
|
105 | - * @throws ReflectionException |
|
106 | - * @throws InvalidDataTypeException |
|
107 | - * @throws InvalidInterfaceException |
|
108 | - */ |
|
109 | - public function column_cb($item) |
|
110 | - { |
|
111 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID()); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @param EE_Checkin $item |
|
117 | - * @return string |
|
118 | - * @throws EE_Error |
|
119 | - * @throws InvalidArgumentException |
|
120 | - * @throws InvalidDataTypeException |
|
121 | - * @throws InvalidInterfaceException |
|
122 | - * @throws ReflectionException |
|
123 | - */ |
|
124 | - public function column_CHK_in(EE_Checkin $item) |
|
125 | - { |
|
126 | - $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
|
127 | - return '<span class="' |
|
128 | - . $checkin_status_dashicon->cssClasses() |
|
129 | - . '"></span><span class="show-on-mobile-view-only">' |
|
130 | - . $item->get_datetime('CHK_timestamp') |
|
131 | - . '</span>'; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param EE_Checkin $item |
|
137 | - * @return string |
|
138 | - * @throws EE_Error |
|
139 | - * @throws InvalidArgumentException |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidInterfaceException |
|
142 | - * @throws ReflectionException |
|
143 | - */ |
|
144 | - public function column_CHK_timestamp(EE_Checkin $item) |
|
145 | - { |
|
146 | - $actions = array(); |
|
147 | - $delete_url = EE_Admin_Page::add_query_args_and_nonce( |
|
148 | - array( |
|
149 | - 'action' => 'delete_checkin_row', |
|
150 | - 'DTT_ID' => $this->_req_data['DTT_ID'], |
|
151 | - '_REG_ID' => $this->_req_data['_REG_ID'], |
|
152 | - 'CHK_ID' => $item->ID(), |
|
153 | - ) |
|
154 | - ); |
|
155 | - $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( |
|
156 | - 'ee_delete_checkins', |
|
157 | - 'espresso_registrations_delete_checkin_row' |
|
158 | - ) |
|
159 | - ? '<a href="' . $delete_url . '" title="' |
|
160 | - . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
161 | - . esc_html__('Delete', 'event_espresso') . '</a>' |
|
162 | - : ''; |
|
163 | - |
|
164 | - return sprintf( |
|
165 | - '%1$s %2$s', |
|
166 | - $item->get_datetime('CHK_timestamp', '', 'H:i:s a'), |
|
167 | - $this->row_actions($actions) |
|
168 | - ); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * This retrieves all the Check-ins for the given parameters. |
|
174 | - * experimenting with having the query for the table values within the list table. |
|
175 | - * |
|
176 | - * @param int $per_page How many to retrieve per page |
|
177 | - * @param bool $count Whether to return a count or not |
|
178 | - * @return EE_Checkin[]|int |
|
179 | - * @throws EE_Error |
|
180 | - * @throws InvalidArgumentException |
|
181 | - * @throws InvalidDataTypeException |
|
182 | - * @throws InvalidInterfaceException |
|
183 | - */ |
|
184 | - protected function _get_checkins($per_page = 10, $count = false) |
|
185 | - { |
|
186 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false; |
|
187 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false; |
|
188 | - |
|
189 | - // if user does not have the capability for the checkins for this registration then get out! |
|
190 | - if ( |
|
191 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
192 | - 'ee_read_checkin', |
|
193 | - 'espresso_registrations_registration_checkins', |
|
194 | - $REG_ID |
|
195 | - ) |
|
196 | - ) { |
|
197 | - return $count ? 0 : array(); |
|
198 | - } |
|
199 | - |
|
200 | - // if no reg id then get out cause need a reg id |
|
201 | - if (empty($REG_ID) || empty($DTT_ID)) { |
|
202 | - throw new EE_Error( |
|
203 | - esc_html__( |
|
204 | - 'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', |
|
205 | - 'event_espresso' |
|
206 | - ) |
|
207 | - ); |
|
208 | - } |
|
209 | - |
|
210 | - // set orderby |
|
211 | - // note that with this table we're only providing the option to orderby the timestamp value. |
|
212 | - $orderby = 'CHK_timestamp'; |
|
213 | - |
|
214 | - $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
215 | - |
|
216 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
217 | - ? $this->_req_data['paged'] |
|
218 | - : 1; |
|
219 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
220 | - ? $this->_req_data['perpage'] |
|
221 | - : $per_page; |
|
222 | - $limit = null; |
|
223 | - if (! $count) { |
|
224 | - $offset = ($current_page - 1) * $per_page; |
|
225 | - $limit = array($offset, $per_page); |
|
226 | - } |
|
227 | - |
|
228 | - $_where = array( |
|
229 | - 'REG_ID' => $REG_ID, |
|
230 | - 'DTT_ID' => $DTT_ID, |
|
231 | - ); |
|
232 | - |
|
233 | - $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
234 | - |
|
235 | - // if no per_page value then we just want to return a count of all Check-ins |
|
236 | - if ($count) { |
|
237 | - return EEM_Checkin::instance()->count(array($_where)); |
|
238 | - } |
|
239 | - |
|
240 | - return $count |
|
241 | - ? EEM_Checkin::instance()->count(array($_where)) |
|
242 | - : EEM_Checkin::instance()->get_all($query_params); |
|
243 | - } |
|
20 | + /** |
|
21 | + * EE_Registration_CheckIn_List_Table constructor. |
|
22 | + * |
|
23 | + * @param EE_Admin_Page $admin_page |
|
24 | + */ |
|
25 | + public function __construct($admin_page) |
|
26 | + { |
|
27 | + parent::__construct($admin_page); |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @throws EE_Error |
|
33 | + */ |
|
34 | + protected function _setup_data() |
|
35 | + { |
|
36 | + $this->_data = $this->_get_checkins($this->_per_page); |
|
37 | + $this->_all_data_count = $this->_get_checkins($this->_per_page, true); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Sets up the properties for the list table. |
|
43 | + */ |
|
44 | + protected function _set_properties() |
|
45 | + { |
|
46 | + $this->_wp_list_args = array( |
|
47 | + 'singular' => esc_html__('check-in', 'event_espresso'), |
|
48 | + 'plural' => esc_html__('check-ins', 'event_espresso'), |
|
49 | + 'ajax' => true, |
|
50 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
51 | + ); |
|
52 | + |
|
53 | + $this->_columns = array( |
|
54 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
55 | + 'CHK_in' => esc_html__('Check-In', 'event_espresso'), |
|
56 | + 'CHK_timestamp' => esc_html__('Timestamp', 'event_espresso'), |
|
57 | + ); |
|
58 | + |
|
59 | + $this->_sortable_columns = array( |
|
60 | + 'CHK_timestamp' => array('CHK_timestamp' => true), |
|
61 | + ); |
|
62 | + |
|
63 | + $this->_primary_column = 'CHK_in'; |
|
64 | + |
|
65 | + $this->_hidden_columns = array(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + protected function _get_table_filters() |
|
73 | + { |
|
74 | + return []; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * Returning an empty string to remove the search box for this view. |
|
80 | + * |
|
81 | + * @param string $text |
|
82 | + * @param string $input_id |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function search_box($text, $input_id) |
|
86 | + { |
|
87 | + return ''; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @throws EE_Error |
|
93 | + */ |
|
94 | + protected function _add_view_counts() |
|
95 | + { |
|
96 | + $this->_views['all']['count'] = $this->_get_checkins(null, true); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @param EE_Checkin $item |
|
102 | + * @return string |
|
103 | + * @throws EE_Error |
|
104 | + * @throws InvalidArgumentException |
|
105 | + * @throws ReflectionException |
|
106 | + * @throws InvalidDataTypeException |
|
107 | + * @throws InvalidInterfaceException |
|
108 | + */ |
|
109 | + public function column_cb($item) |
|
110 | + { |
|
111 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID()); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @param EE_Checkin $item |
|
117 | + * @return string |
|
118 | + * @throws EE_Error |
|
119 | + * @throws InvalidArgumentException |
|
120 | + * @throws InvalidDataTypeException |
|
121 | + * @throws InvalidInterfaceException |
|
122 | + * @throws ReflectionException |
|
123 | + */ |
|
124 | + public function column_CHK_in(EE_Checkin $item) |
|
125 | + { |
|
126 | + $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
|
127 | + return '<span class="' |
|
128 | + . $checkin_status_dashicon->cssClasses() |
|
129 | + . '"></span><span class="show-on-mobile-view-only">' |
|
130 | + . $item->get_datetime('CHK_timestamp') |
|
131 | + . '</span>'; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param EE_Checkin $item |
|
137 | + * @return string |
|
138 | + * @throws EE_Error |
|
139 | + * @throws InvalidArgumentException |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidInterfaceException |
|
142 | + * @throws ReflectionException |
|
143 | + */ |
|
144 | + public function column_CHK_timestamp(EE_Checkin $item) |
|
145 | + { |
|
146 | + $actions = array(); |
|
147 | + $delete_url = EE_Admin_Page::add_query_args_and_nonce( |
|
148 | + array( |
|
149 | + 'action' => 'delete_checkin_row', |
|
150 | + 'DTT_ID' => $this->_req_data['DTT_ID'], |
|
151 | + '_REG_ID' => $this->_req_data['_REG_ID'], |
|
152 | + 'CHK_ID' => $item->ID(), |
|
153 | + ) |
|
154 | + ); |
|
155 | + $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( |
|
156 | + 'ee_delete_checkins', |
|
157 | + 'espresso_registrations_delete_checkin_row' |
|
158 | + ) |
|
159 | + ? '<a href="' . $delete_url . '" title="' |
|
160 | + . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
161 | + . esc_html__('Delete', 'event_espresso') . '</a>' |
|
162 | + : ''; |
|
163 | + |
|
164 | + return sprintf( |
|
165 | + '%1$s %2$s', |
|
166 | + $item->get_datetime('CHK_timestamp', '', 'H:i:s a'), |
|
167 | + $this->row_actions($actions) |
|
168 | + ); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * This retrieves all the Check-ins for the given parameters. |
|
174 | + * experimenting with having the query for the table values within the list table. |
|
175 | + * |
|
176 | + * @param int $per_page How many to retrieve per page |
|
177 | + * @param bool $count Whether to return a count or not |
|
178 | + * @return EE_Checkin[]|int |
|
179 | + * @throws EE_Error |
|
180 | + * @throws InvalidArgumentException |
|
181 | + * @throws InvalidDataTypeException |
|
182 | + * @throws InvalidInterfaceException |
|
183 | + */ |
|
184 | + protected function _get_checkins($per_page = 10, $count = false) |
|
185 | + { |
|
186 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false; |
|
187 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false; |
|
188 | + |
|
189 | + // if user does not have the capability for the checkins for this registration then get out! |
|
190 | + if ( |
|
191 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
192 | + 'ee_read_checkin', |
|
193 | + 'espresso_registrations_registration_checkins', |
|
194 | + $REG_ID |
|
195 | + ) |
|
196 | + ) { |
|
197 | + return $count ? 0 : array(); |
|
198 | + } |
|
199 | + |
|
200 | + // if no reg id then get out cause need a reg id |
|
201 | + if (empty($REG_ID) || empty($DTT_ID)) { |
|
202 | + throw new EE_Error( |
|
203 | + esc_html__( |
|
204 | + 'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', |
|
205 | + 'event_espresso' |
|
206 | + ) |
|
207 | + ); |
|
208 | + } |
|
209 | + |
|
210 | + // set orderby |
|
211 | + // note that with this table we're only providing the option to orderby the timestamp value. |
|
212 | + $orderby = 'CHK_timestamp'; |
|
213 | + |
|
214 | + $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
215 | + |
|
216 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
217 | + ? $this->_req_data['paged'] |
|
218 | + : 1; |
|
219 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
220 | + ? $this->_req_data['perpage'] |
|
221 | + : $per_page; |
|
222 | + $limit = null; |
|
223 | + if (! $count) { |
|
224 | + $offset = ($current_page - 1) * $per_page; |
|
225 | + $limit = array($offset, $per_page); |
|
226 | + } |
|
227 | + |
|
228 | + $_where = array( |
|
229 | + 'REG_ID' => $REG_ID, |
|
230 | + 'DTT_ID' => $DTT_ID, |
|
231 | + ); |
|
232 | + |
|
233 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
234 | + |
|
235 | + // if no per_page value then we just want to return a count of all Check-ins |
|
236 | + if ($count) { |
|
237 | + return EEM_Checkin::instance()->count(array($_where)); |
|
238 | + } |
|
239 | + |
|
240 | + return $count |
|
241 | + ? EEM_Checkin::instance()->count(array($_where)) |
|
242 | + : EEM_Checkin::instance()->get_all($query_params); |
|
243 | + } |
|
244 | 244 | } |