@@ -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 | } |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | public function __construct($routing = true) |
33 | 33 | { |
34 | 34 | parent::__construct($routing); |
35 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
36 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
37 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
38 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
35 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
36 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
37 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
38 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function _extend_page_config() |
47 | 47 | { |
48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
49 | 49 | $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
50 | 50 | ? $this->_req_data['_REG_ID'] |
51 | 51 | : 0; |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | // enqueue newsletter js |
187 | 187 | wp_enqueue_script( |
188 | 188 | 'ee-newsletter-trigger', |
189 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
189 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
190 | 190 | array('ee-dialog'), |
191 | 191 | EVENT_ESPRESSO_VERSION, |
192 | 192 | true |
193 | 193 | ); |
194 | 194 | wp_enqueue_style( |
195 | 195 | 'ee-newsletter-trigger-css', |
196 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
196 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', |
|
197 | 197 | array(), |
198 | 198 | EVENT_ESPRESSO_VERSION |
199 | 199 | ); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | { |
215 | 215 | wp_register_script( |
216 | 216 | 'ee-reg-reports-js', |
217 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
217 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
218 | 218 | array('google-charts'), |
219 | 219 | EVENT_ESPRESSO_VERSION, |
220 | 220 | true |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
301 | 301 | $this->_verify_nonce($nonce, $nonce_ref); |
302 | 302 | // let's get the mtp for the incoming MTP_ ID |
303 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
303 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
304 | 304 | EE_Error::add_error( |
305 | 305 | esc_html__( |
306 | 306 | 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $this->_return_json(); |
316 | 316 | } |
317 | 317 | $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
318 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
318 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
319 | 319 | EE_Error::add_error( |
320 | 320 | sprintf( |
321 | 321 | esc_html__( |
@@ -340,12 +340,12 @@ discard block |
||
340 | 340 | $field = $MTP->get('MTP_template_field'); |
341 | 341 | if ($field === 'content') { |
342 | 342 | $content = $MTP->get('MTP_content'); |
343 | - if (! empty($content['newsletter_content'])) { |
|
343 | + if ( ! empty($content['newsletter_content'])) { |
|
344 | 344 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
345 | 345 | } |
346 | 346 | continue; |
347 | 347 | } |
348 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
348 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
349 | 349 | } |
350 | 350 | $this->_template_args['success'] = true; |
351 | 351 | $this->_template_args['error'] = false; |
@@ -447,17 +447,17 @@ discard block |
||
447 | 447 | $field_id = $field === '[NEWSLETTER_CONTENT]' |
448 | 448 | ? 'content' |
449 | 449 | : $field; |
450 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
450 | + $field_id = 'batch-message-'.strtolower($field_id); |
|
451 | 451 | $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
452 | 452 | . $shortcode |
453 | - . '" data-linked-input-id="' . $field_id . '">' |
|
453 | + . '" data-linked-input-id="'.$field_id.'">' |
|
454 | 454 | . $shortcode |
455 | 455 | . '</span>'; |
456 | 456 | } |
457 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
457 | + $codes[$field] = implode(', ', $available_shortcodes); |
|
458 | 458 | } |
459 | 459 | $shortcodes = $codes; |
460 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
460 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
461 | 461 | $form_template_args = array( |
462 | 462 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
463 | 463 | 'form_route' => 'newsletter_selected_send', |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | */ |
626 | 626 | protected function _registration_reports() |
627 | 627 | { |
628 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
628 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
629 | 629 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
630 | 630 | $template_path, |
631 | 631 | $this->_reports_template_data, |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | array_unshift($regs, $column_titles); |
681 | 681 | // setup the date range. |
682 | 682 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
683 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
683 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
684 | 684 | $ending_date = new DateTime("now", $DateTimeZone); |
685 | 685 | $subtitle = sprintf( |
686 | 686 | wp_strip_all_tags( |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | 'event_espresso' |
705 | 705 | ) |
706 | 706 | ), |
707 | - '<h2>' . $report_title . '</h2><p>', |
|
707 | + '<h2>'.$report_title.'</h2><p>', |
|
708 | 708 | '</p>' |
709 | 709 | ), |
710 | 710 | ); |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | array_unshift($regs, $column_titles); |
758 | 758 | // setup the date range. |
759 | 759 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
760 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
760 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
761 | 761 | $ending_date = new DateTime("now", $DateTimeZone); |
762 | 762 | $subtitle = sprintf( |
763 | 763 | wp_strip_all_tags( |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | 'event_espresso' |
782 | 782 | ) |
783 | 783 | ), |
784 | - '<h2>' . $report_title . '</h2><p>', |
|
784 | + '<h2>'.$report_title.'</h2><p>', |
|
785 | 785 | '</p>' |
786 | 786 | ), |
787 | 787 | ); |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
808 | 808 | /** @var EE_Registration $registration */ |
809 | 809 | $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
810 | - if (! $registration instanceof EE_Registration) { |
|
810 | + if ( ! $registration instanceof EE_Registration) { |
|
811 | 811 | throw new EE_Error( |
812 | 812 | sprintf( |
813 | 813 | esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | if ($datetime instanceof EE_Datetime) { |
843 | 843 | $datetime_label = $datetime->get_dtt_display_name(true); |
844 | 844 | $datetime_label .= ! empty($datetime_label) |
845 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
845 | + ? ' ('.$datetime->get_dtt_display_name().')' |
|
846 | 846 | : $datetime->get_dtt_display_name(); |
847 | 847 | } |
848 | 848 | $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | ) |
857 | 857 | : ''; |
858 | 858 | $datetime_link = ! empty($datetime_link) |
859 | - ? '<a href="' . $datetime_link . '">' |
|
859 | + ? '<a href="'.$datetime_link.'">' |
|
860 | 860 | . '<span id="checkin-dtt">' |
861 | 861 | . $datetime_label |
862 | 862 | . '</span></a>' |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | ? $attendee->get_admin_details_link() |
869 | 869 | : ''; |
870 | 870 | $attendee_link = ! empty($attendee_link) |
871 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
872 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
871 | + ? '<a href="'.$attendee->get_admin_details_link().'"' |
|
872 | + . ' title="'.esc_html__('Click for attendee details', 'event_espresso').'">' |
|
873 | 873 | . '<span id="checkin-attendee-name">' |
874 | 874 | . $attendee_name |
875 | 875 | . '</span></a>' |
@@ -878,25 +878,25 @@ discard block |
||
878 | 878 | ? $registration->event()->get_admin_details_link() |
879 | 879 | : ''; |
880 | 880 | $event_link = ! empty($event_link) |
881 | - ? '<a href="' . $event_link . '"' |
|
882 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
881 | + ? '<a href="'.$event_link.'"' |
|
882 | + . ' title="'.esc_html__('Click here to edit event.', 'event_espresso').'">' |
|
883 | 883 | . '<span id="checkin-event-name">' |
884 | 884 | . $registration->event_name() |
885 | 885 | . '</span>' |
886 | 886 | . '</a>' |
887 | 887 | : ''; |
888 | 888 | $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
889 | - ? '<h2>' . sprintf( |
|
889 | + ? '<h2>'.sprintf( |
|
890 | 890 | esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
891 | 891 | $attendee_link, |
892 | 892 | $datetime_link, |
893 | 893 | $event_link |
894 | - ) . '</h2>' |
|
894 | + ).'</h2>' |
|
895 | 895 | : ''; |
896 | 896 | $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
897 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
897 | + ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : ''; |
|
898 | 898 | $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
899 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
899 | + ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
900 | 900 | $this->display_admin_list_table_page_with_no_sidebar(); |
901 | 901 | } |
902 | 902 | |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | public function toggle_checkin_status() |
914 | 914 | { |
915 | 915 | // first make sure we have the necessary data |
916 | - if (! isset($this->_req_data['_regid'])) { |
|
916 | + if ( ! isset($this->_req_data['_regid'])) { |
|
917 | 917 | EE_Error::add_error( |
918 | 918 | esc_html__( |
919 | 919 | 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | // beautiful! Made it this far so let's get the status. |
936 | 936 | $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
937 | 937 | // setup new class to return via ajax |
938 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
938 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses(); |
|
939 | 939 | $this->_template_args['success'] = true; |
940 | 940 | $this->_return_json(); |
941 | 941 | } |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | ); |
962 | 962 | $new_status = false; |
963 | 963 | // bulk action check in toggle |
964 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
964 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
965 | 965 | // cycle thru checkboxes |
966 | 966 | while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
967 | 967 | $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
@@ -1031,9 +1031,9 @@ discard block |
||
1031 | 1031 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
1032 | 1032 | ); |
1033 | 1033 | $errors = 0; |
1034 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1034 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1035 | 1035 | while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
1036 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1036 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1037 | 1037 | $errors++; |
1038 | 1038 | } |
1039 | 1039 | } |
@@ -1079,8 +1079,8 @@ discard block |
||
1079 | 1079 | 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
1080 | 1080 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
1081 | 1081 | ); |
1082 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1083 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1082 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
1083 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1084 | 1084 | EE_Error::add_error( |
1085 | 1085 | esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
1086 | 1086 | __FILE__, |
@@ -1149,27 +1149,27 @@ discard block |
||
1149 | 1149 | 'desc' => $checked_never->legendLabel(), |
1150 | 1150 | ), |
1151 | 1151 | 'approved_status' => array( |
1152 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1152 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
1153 | 1153 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
1154 | 1154 | ), |
1155 | 1155 | 'cancelled_status' => array( |
1156 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1156 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
1157 | 1157 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
1158 | 1158 | ), |
1159 | 1159 | 'declined_status' => array( |
1160 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1160 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
1161 | 1161 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
1162 | 1162 | ), |
1163 | 1163 | 'not_approved' => array( |
1164 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1164 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
1165 | 1165 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
1166 | 1166 | ), |
1167 | 1167 | 'pending_status' => array( |
1168 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1168 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
1169 | 1169 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
1170 | 1170 | ), |
1171 | 1171 | 'wait_list' => array( |
1172 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1172 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
1173 | 1173 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
1174 | 1174 | ), |
1175 | 1175 | ); |
@@ -1178,10 +1178,10 @@ discard block |
||
1178 | 1178 | /** @var EE_Event $event */ |
1179 | 1179 | $event = EEM_Event::instance()->get_one_by_ID($event_id); |
1180 | 1180 | $this->_template_args['before_list_table'] = $event instanceof EE_Event |
1181 | - ? '<h2>' . sprintf( |
|
1181 | + ? '<h2>'.sprintf( |
|
1182 | 1182 | esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
1183 | 1183 | EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
1184 | - ) . '</h2>' |
|
1184 | + ).'</h2>' |
|
1185 | 1185 | : ''; |
1186 | 1186 | // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
1187 | 1187 | // the event. |
@@ -1199,12 +1199,12 @@ discard block |
||
1199 | 1199 | $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
1200 | 1200 | $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
1201 | 1201 | $this->_template_args['before_list_table'] .= $datetime->name(); |
1202 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1202 | + $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )'; |
|
1203 | 1203 | $this->_template_args['before_list_table'] .= '</span></h2>'; |
1204 | 1204 | } |
1205 | 1205 | // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
1206 | 1206 | // column represents |
1207 | - if (! $datetime instanceof EE_Datetime) { |
|
1207 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1208 | 1208 | $this->_template_args['before_list_table'] .= '<br><p class="description">' |
1209 | 1209 | . esc_html__( |
1210 | 1210 | 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
@@ -14,1276 +14,1276 @@ |
||
14 | 14 | */ |
15 | 15 | class Extend_Registrations_Admin_Page extends Registrations_Admin_Page |
16 | 16 | { |
17 | - /** |
|
18 | - * This is used to hold the reports template data which is setup early in the request. |
|
19 | - * |
|
20 | - * @type array |
|
21 | - */ |
|
22 | - protected $_reports_template_data = array(); |
|
17 | + /** |
|
18 | + * This is used to hold the reports template data which is setup early in the request. |
|
19 | + * |
|
20 | + * @type array |
|
21 | + */ |
|
22 | + protected $_reports_template_data = array(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Extend_Registrations_Admin_Page constructor. |
|
27 | - * |
|
28 | - * @param bool $routing |
|
29 | - */ |
|
30 | - public function __construct($routing = true) |
|
31 | - { |
|
32 | - parent::__construct($routing); |
|
33 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
35 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
36 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
37 | - } |
|
38 | - } |
|
25 | + /** |
|
26 | + * Extend_Registrations_Admin_Page constructor. |
|
27 | + * |
|
28 | + * @param bool $routing |
|
29 | + */ |
|
30 | + public function __construct($routing = true) |
|
31 | + { |
|
32 | + parent::__construct($routing); |
|
33 | + if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
35 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
36 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
37 | + } |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Extending page configuration. |
|
43 | - */ |
|
44 | - protected function _extend_page_config() |
|
45 | - { |
|
46 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
47 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
48 | - ? $this->_req_data['_REG_ID'] |
|
49 | - : 0; |
|
50 | - $new_page_routes = array( |
|
51 | - 'reports' => array( |
|
52 | - 'func' => '_registration_reports', |
|
53 | - 'capability' => 'ee_read_registrations', |
|
54 | - ), |
|
55 | - 'registration_checkins' => array( |
|
56 | - 'func' => '_registration_checkin_list_table', |
|
57 | - 'capability' => 'ee_read_checkins', |
|
58 | - ), |
|
59 | - 'newsletter_selected_send' => array( |
|
60 | - 'func' => '_newsletter_selected_send', |
|
61 | - 'noheader' => true, |
|
62 | - 'capability' => 'ee_send_message', |
|
63 | - ), |
|
64 | - 'delete_checkin_rows' => array( |
|
65 | - 'func' => '_delete_checkin_rows', |
|
66 | - 'noheader' => true, |
|
67 | - 'capability' => 'ee_delete_checkins', |
|
68 | - ), |
|
69 | - 'delete_checkin_row' => array( |
|
70 | - 'func' => '_delete_checkin_row', |
|
71 | - 'noheader' => true, |
|
72 | - 'capability' => 'ee_delete_checkin', |
|
73 | - 'obj_id' => $reg_id, |
|
74 | - ), |
|
75 | - 'toggle_checkin_status' => array( |
|
76 | - 'func' => '_toggle_checkin_status', |
|
77 | - 'noheader' => true, |
|
78 | - 'capability' => 'ee_edit_checkin', |
|
79 | - 'obj_id' => $reg_id, |
|
80 | - ), |
|
81 | - 'toggle_checkin_status_bulk' => array( |
|
82 | - 'func' => '_toggle_checkin_status', |
|
83 | - 'noheader' => true, |
|
84 | - 'capability' => 'ee_edit_checkins', |
|
85 | - ), |
|
86 | - 'event_registrations' => array( |
|
87 | - 'func' => '_event_registrations_list_table', |
|
88 | - 'capability' => 'ee_read_checkins', |
|
89 | - ), |
|
90 | - 'registrations_checkin_report' => array( |
|
91 | - 'func' => '_registrations_checkin_report', |
|
92 | - 'noheader' => true, |
|
93 | - 'capability' => 'ee_read_registrations', |
|
94 | - ), |
|
95 | - ); |
|
96 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
97 | - $new_page_config = array( |
|
98 | - 'reports' => array( |
|
99 | - 'nav' => array( |
|
100 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
101 | - 'order' => 30, |
|
102 | - ), |
|
103 | - 'help_tabs' => array( |
|
104 | - 'registrations_reports_help_tab' => array( |
|
105 | - 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
106 | - 'filename' => 'registrations_reports', |
|
107 | - ), |
|
108 | - ), |
|
109 | - 'require_nonce' => false, |
|
110 | - ), |
|
111 | - 'event_registrations' => array( |
|
112 | - 'nav' => array( |
|
113 | - 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
114 | - 'order' => 10, |
|
115 | - 'persistent' => true, |
|
116 | - ), |
|
117 | - 'help_tabs' => array( |
|
118 | - 'registrations_event_checkin_help_tab' => array( |
|
119 | - 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
120 | - 'filename' => 'registrations_event_checkin', |
|
121 | - ), |
|
122 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
123 | - 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
124 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
125 | - ), |
|
126 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
127 | - 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
128 | - 'filename' => 'registrations_event_checkin_filters', |
|
129 | - ), |
|
130 | - 'registrations_event_checkin_views_help_tab' => array( |
|
131 | - 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
132 | - 'filename' => 'registrations_event_checkin_views', |
|
133 | - ), |
|
134 | - 'registrations_event_checkin_other_help_tab' => array( |
|
135 | - 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
136 | - 'filename' => 'registrations_event_checkin_other', |
|
137 | - ), |
|
138 | - ), |
|
139 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
140 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
141 | - 'metaboxes' => array(), |
|
142 | - 'require_nonce' => false, |
|
143 | - ), |
|
144 | - 'registration_checkins' => array( |
|
145 | - 'nav' => array( |
|
146 | - 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
147 | - 'order' => 15, |
|
148 | - 'persistent' => false, |
|
149 | - 'url' => '', |
|
150 | - ), |
|
151 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
152 | - 'metaboxes' => array(), |
|
153 | - 'require_nonce' => false, |
|
154 | - ), |
|
155 | - ); |
|
156 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
157 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
158 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
159 | - } |
|
41 | + /** |
|
42 | + * Extending page configuration. |
|
43 | + */ |
|
44 | + protected function _extend_page_config() |
|
45 | + { |
|
46 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
47 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
48 | + ? $this->_req_data['_REG_ID'] |
|
49 | + : 0; |
|
50 | + $new_page_routes = array( |
|
51 | + 'reports' => array( |
|
52 | + 'func' => '_registration_reports', |
|
53 | + 'capability' => 'ee_read_registrations', |
|
54 | + ), |
|
55 | + 'registration_checkins' => array( |
|
56 | + 'func' => '_registration_checkin_list_table', |
|
57 | + 'capability' => 'ee_read_checkins', |
|
58 | + ), |
|
59 | + 'newsletter_selected_send' => array( |
|
60 | + 'func' => '_newsletter_selected_send', |
|
61 | + 'noheader' => true, |
|
62 | + 'capability' => 'ee_send_message', |
|
63 | + ), |
|
64 | + 'delete_checkin_rows' => array( |
|
65 | + 'func' => '_delete_checkin_rows', |
|
66 | + 'noheader' => true, |
|
67 | + 'capability' => 'ee_delete_checkins', |
|
68 | + ), |
|
69 | + 'delete_checkin_row' => array( |
|
70 | + 'func' => '_delete_checkin_row', |
|
71 | + 'noheader' => true, |
|
72 | + 'capability' => 'ee_delete_checkin', |
|
73 | + 'obj_id' => $reg_id, |
|
74 | + ), |
|
75 | + 'toggle_checkin_status' => array( |
|
76 | + 'func' => '_toggle_checkin_status', |
|
77 | + 'noheader' => true, |
|
78 | + 'capability' => 'ee_edit_checkin', |
|
79 | + 'obj_id' => $reg_id, |
|
80 | + ), |
|
81 | + 'toggle_checkin_status_bulk' => array( |
|
82 | + 'func' => '_toggle_checkin_status', |
|
83 | + 'noheader' => true, |
|
84 | + 'capability' => 'ee_edit_checkins', |
|
85 | + ), |
|
86 | + 'event_registrations' => array( |
|
87 | + 'func' => '_event_registrations_list_table', |
|
88 | + 'capability' => 'ee_read_checkins', |
|
89 | + ), |
|
90 | + 'registrations_checkin_report' => array( |
|
91 | + 'func' => '_registrations_checkin_report', |
|
92 | + 'noheader' => true, |
|
93 | + 'capability' => 'ee_read_registrations', |
|
94 | + ), |
|
95 | + ); |
|
96 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
97 | + $new_page_config = array( |
|
98 | + 'reports' => array( |
|
99 | + 'nav' => array( |
|
100 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
101 | + 'order' => 30, |
|
102 | + ), |
|
103 | + 'help_tabs' => array( |
|
104 | + 'registrations_reports_help_tab' => array( |
|
105 | + 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
106 | + 'filename' => 'registrations_reports', |
|
107 | + ), |
|
108 | + ), |
|
109 | + 'require_nonce' => false, |
|
110 | + ), |
|
111 | + 'event_registrations' => array( |
|
112 | + 'nav' => array( |
|
113 | + 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
114 | + 'order' => 10, |
|
115 | + 'persistent' => true, |
|
116 | + ), |
|
117 | + 'help_tabs' => array( |
|
118 | + 'registrations_event_checkin_help_tab' => array( |
|
119 | + 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
120 | + 'filename' => 'registrations_event_checkin', |
|
121 | + ), |
|
122 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
123 | + 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
124 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
125 | + ), |
|
126 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
127 | + 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
128 | + 'filename' => 'registrations_event_checkin_filters', |
|
129 | + ), |
|
130 | + 'registrations_event_checkin_views_help_tab' => array( |
|
131 | + 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
132 | + 'filename' => 'registrations_event_checkin_views', |
|
133 | + ), |
|
134 | + 'registrations_event_checkin_other_help_tab' => array( |
|
135 | + 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
136 | + 'filename' => 'registrations_event_checkin_other', |
|
137 | + ), |
|
138 | + ), |
|
139 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
140 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
141 | + 'metaboxes' => array(), |
|
142 | + 'require_nonce' => false, |
|
143 | + ), |
|
144 | + 'registration_checkins' => array( |
|
145 | + 'nav' => array( |
|
146 | + 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
147 | + 'order' => 15, |
|
148 | + 'persistent' => false, |
|
149 | + 'url' => '', |
|
150 | + ), |
|
151 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
152 | + 'metaboxes' => array(), |
|
153 | + 'require_nonce' => false, |
|
154 | + ), |
|
155 | + ); |
|
156 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
157 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
158 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * Ajax hooks for all routes in this page. |
|
164 | - */ |
|
165 | - protected function _ajax_hooks() |
|
166 | - { |
|
167 | - parent::_ajax_hooks(); |
|
168 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
169 | - } |
|
162 | + /** |
|
163 | + * Ajax hooks for all routes in this page. |
|
164 | + */ |
|
165 | + protected function _ajax_hooks() |
|
166 | + { |
|
167 | + parent::_ajax_hooks(); |
|
168 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
169 | + } |
|
170 | 170 | |
171 | 171 | |
172 | - /** |
|
173 | - * Global scripts for all routes in this page. |
|
174 | - */ |
|
175 | - public function load_scripts_styles() |
|
176 | - { |
|
177 | - parent::load_scripts_styles(); |
|
178 | - // if newsletter message type is active then let's add filter and load js for it. |
|
179 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
180 | - // enqueue newsletter js |
|
181 | - wp_enqueue_script( |
|
182 | - 'ee-newsletter-trigger', |
|
183 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
184 | - array('ee-dialog'), |
|
185 | - EVENT_ESPRESSO_VERSION, |
|
186 | - true |
|
187 | - ); |
|
188 | - wp_enqueue_style( |
|
189 | - 'ee-newsletter-trigger-css', |
|
190 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
191 | - array(), |
|
192 | - EVENT_ESPRESSO_VERSION |
|
193 | - ); |
|
194 | - // hook in buttons for newsletter message type trigger. |
|
195 | - add_action( |
|
196 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
197 | - array($this, 'add_newsletter_action_buttons'), |
|
198 | - 10 |
|
199 | - ); |
|
200 | - } |
|
201 | - } |
|
172 | + /** |
|
173 | + * Global scripts for all routes in this page. |
|
174 | + */ |
|
175 | + public function load_scripts_styles() |
|
176 | + { |
|
177 | + parent::load_scripts_styles(); |
|
178 | + // if newsletter message type is active then let's add filter and load js for it. |
|
179 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
180 | + // enqueue newsletter js |
|
181 | + wp_enqueue_script( |
|
182 | + 'ee-newsletter-trigger', |
|
183 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
184 | + array('ee-dialog'), |
|
185 | + EVENT_ESPRESSO_VERSION, |
|
186 | + true |
|
187 | + ); |
|
188 | + wp_enqueue_style( |
|
189 | + 'ee-newsletter-trigger-css', |
|
190 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
191 | + array(), |
|
192 | + EVENT_ESPRESSO_VERSION |
|
193 | + ); |
|
194 | + // hook in buttons for newsletter message type trigger. |
|
195 | + add_action( |
|
196 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
197 | + array($this, 'add_newsletter_action_buttons'), |
|
198 | + 10 |
|
199 | + ); |
|
200 | + } |
|
201 | + } |
|
202 | 202 | |
203 | 203 | |
204 | - /** |
|
205 | - * Scripts and styles for just the reports route. |
|
206 | - */ |
|
207 | - public function load_scripts_styles_reports() |
|
208 | - { |
|
209 | - wp_register_script( |
|
210 | - 'ee-reg-reports-js', |
|
211 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
212 | - array('google-charts'), |
|
213 | - EVENT_ESPRESSO_VERSION, |
|
214 | - true |
|
215 | - ); |
|
216 | - wp_enqueue_script('ee-reg-reports-js'); |
|
217 | - $this->_registration_reports_js_setup(); |
|
218 | - } |
|
204 | + /** |
|
205 | + * Scripts and styles for just the reports route. |
|
206 | + */ |
|
207 | + public function load_scripts_styles_reports() |
|
208 | + { |
|
209 | + wp_register_script( |
|
210 | + 'ee-reg-reports-js', |
|
211 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
212 | + array('google-charts'), |
|
213 | + EVENT_ESPRESSO_VERSION, |
|
214 | + true |
|
215 | + ); |
|
216 | + wp_enqueue_script('ee-reg-reports-js'); |
|
217 | + $this->_registration_reports_js_setup(); |
|
218 | + } |
|
219 | 219 | |
220 | 220 | |
221 | - /** |
|
222 | - * Register screen options for event_registrations route. |
|
223 | - */ |
|
224 | - protected function _add_screen_options_event_registrations() |
|
225 | - { |
|
226 | - $this->_per_page_screen_option(); |
|
227 | - } |
|
221 | + /** |
|
222 | + * Register screen options for event_registrations route. |
|
223 | + */ |
|
224 | + protected function _add_screen_options_event_registrations() |
|
225 | + { |
|
226 | + $this->_per_page_screen_option(); |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | - /** |
|
231 | - * Register screen options for registration_checkins route |
|
232 | - */ |
|
233 | - protected function _add_screen_options_registration_checkins() |
|
234 | - { |
|
235 | - $page_title = $this->_admin_page_title; |
|
236 | - $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
237 | - $this->_per_page_screen_option(); |
|
238 | - $this->_admin_page_title = $page_title; |
|
239 | - } |
|
230 | + /** |
|
231 | + * Register screen options for registration_checkins route |
|
232 | + */ |
|
233 | + protected function _add_screen_options_registration_checkins() |
|
234 | + { |
|
235 | + $page_title = $this->_admin_page_title; |
|
236 | + $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
237 | + $this->_per_page_screen_option(); |
|
238 | + $this->_admin_page_title = $page_title; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * Set views property for event_registrations route. |
|
244 | - */ |
|
245 | - protected function _set_list_table_views_event_registrations() |
|
246 | - { |
|
247 | - $this->_views = array( |
|
248 | - 'all' => array( |
|
249 | - 'slug' => 'all', |
|
250 | - 'label' => esc_html__('All', 'event_espresso'), |
|
251 | - 'count' => 0, |
|
252 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
253 | - ? array() |
|
254 | - : array( |
|
255 | - 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
256 | - ), |
|
257 | - ), |
|
258 | - ); |
|
259 | - } |
|
242 | + /** |
|
243 | + * Set views property for event_registrations route. |
|
244 | + */ |
|
245 | + protected function _set_list_table_views_event_registrations() |
|
246 | + { |
|
247 | + $this->_views = array( |
|
248 | + 'all' => array( |
|
249 | + 'slug' => 'all', |
|
250 | + 'label' => esc_html__('All', 'event_espresso'), |
|
251 | + 'count' => 0, |
|
252 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
253 | + ? array() |
|
254 | + : array( |
|
255 | + 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
256 | + ), |
|
257 | + ), |
|
258 | + ); |
|
259 | + } |
|
260 | 260 | |
261 | 261 | |
262 | - /** |
|
263 | - * Set views property for registration_checkins route. |
|
264 | - */ |
|
265 | - protected function _set_list_table_views_registration_checkins() |
|
266 | - { |
|
267 | - $this->_views = array( |
|
268 | - 'all' => array( |
|
269 | - 'slug' => 'all', |
|
270 | - 'label' => esc_html__('All', 'event_espresso'), |
|
271 | - 'count' => 0, |
|
272 | - 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
273 | - ), |
|
274 | - ); |
|
275 | - } |
|
262 | + /** |
|
263 | + * Set views property for registration_checkins route. |
|
264 | + */ |
|
265 | + protected function _set_list_table_views_registration_checkins() |
|
266 | + { |
|
267 | + $this->_views = array( |
|
268 | + 'all' => array( |
|
269 | + 'slug' => 'all', |
|
270 | + 'label' => esc_html__('All', 'event_espresso'), |
|
271 | + 'count' => 0, |
|
272 | + 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
273 | + ), |
|
274 | + ); |
|
275 | + } |
|
276 | 276 | |
277 | 277 | |
278 | - /** |
|
279 | - * callback for ajax action. |
|
280 | - * |
|
281 | - * @since 4.3.0 |
|
282 | - * @return void (JSON) |
|
283 | - * @throws EE_Error |
|
284 | - * @throws InvalidArgumentException |
|
285 | - * @throws InvalidDataTypeException |
|
286 | - * @throws InvalidInterfaceException |
|
287 | - */ |
|
288 | - public function get_newsletter_form_content() |
|
289 | - { |
|
290 | - // do a nonce check cause we're not coming in from an normal route here. |
|
291 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
292 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
293 | - ) : ''; |
|
294 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
295 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
296 | - // let's get the mtp for the incoming MTP_ ID |
|
297 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
298 | - EE_Error::add_error( |
|
299 | - esc_html__( |
|
300 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
301 | - 'event_espresso' |
|
302 | - ), |
|
303 | - __FILE__, |
|
304 | - __FUNCTION__, |
|
305 | - __LINE__ |
|
306 | - ); |
|
307 | - $this->_template_args['success'] = false; |
|
308 | - $this->_template_args['error'] = true; |
|
309 | - $this->_return_json(); |
|
310 | - } |
|
311 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
312 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
313 | - EE_Error::add_error( |
|
314 | - sprintf( |
|
315 | - esc_html__( |
|
316 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
317 | - 'event_espresso' |
|
318 | - ), |
|
319 | - $this->_req_data['GRP_ID'] |
|
320 | - ), |
|
321 | - __FILE__, |
|
322 | - __FUNCTION__, |
|
323 | - __LINE__ |
|
324 | - ); |
|
325 | - $this->_template_args['success'] = false; |
|
326 | - $this->_template_args['error'] = true; |
|
327 | - $this->_return_json(); |
|
328 | - } |
|
329 | - $MTPs = $MTPG->context_templates(); |
|
330 | - $MTPs = $MTPs['attendee']; |
|
331 | - $template_fields = array(); |
|
332 | - /** @var EE_Message_Template $MTP */ |
|
333 | - foreach ($MTPs as $MTP) { |
|
334 | - $field = $MTP->get('MTP_template_field'); |
|
335 | - if ($field === 'content') { |
|
336 | - $content = $MTP->get('MTP_content'); |
|
337 | - if (! empty($content['newsletter_content'])) { |
|
338 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
339 | - } |
|
340 | - continue; |
|
341 | - } |
|
342 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
343 | - } |
|
344 | - $this->_template_args['success'] = true; |
|
345 | - $this->_template_args['error'] = false; |
|
346 | - $this->_template_args['data'] = array( |
|
347 | - 'batch_message_from' => isset($template_fields['from']) |
|
348 | - ? $template_fields['from'] |
|
349 | - : '', |
|
350 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
351 | - ? $template_fields['subject'] |
|
352 | - : '', |
|
353 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
354 | - ? $template_fields['newsletter_content'] |
|
355 | - : '', |
|
356 | - ); |
|
357 | - $this->_return_json(); |
|
358 | - } |
|
278 | + /** |
|
279 | + * callback for ajax action. |
|
280 | + * |
|
281 | + * @since 4.3.0 |
|
282 | + * @return void (JSON) |
|
283 | + * @throws EE_Error |
|
284 | + * @throws InvalidArgumentException |
|
285 | + * @throws InvalidDataTypeException |
|
286 | + * @throws InvalidInterfaceException |
|
287 | + */ |
|
288 | + public function get_newsletter_form_content() |
|
289 | + { |
|
290 | + // do a nonce check cause we're not coming in from an normal route here. |
|
291 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
292 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
293 | + ) : ''; |
|
294 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
295 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
296 | + // let's get the mtp for the incoming MTP_ ID |
|
297 | + if (! isset($this->_req_data['GRP_ID'])) { |
|
298 | + EE_Error::add_error( |
|
299 | + esc_html__( |
|
300 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
301 | + 'event_espresso' |
|
302 | + ), |
|
303 | + __FILE__, |
|
304 | + __FUNCTION__, |
|
305 | + __LINE__ |
|
306 | + ); |
|
307 | + $this->_template_args['success'] = false; |
|
308 | + $this->_template_args['error'] = true; |
|
309 | + $this->_return_json(); |
|
310 | + } |
|
311 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
312 | + if (! $MTPG instanceof EE_Message_Template_Group) { |
|
313 | + EE_Error::add_error( |
|
314 | + sprintf( |
|
315 | + esc_html__( |
|
316 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
317 | + 'event_espresso' |
|
318 | + ), |
|
319 | + $this->_req_data['GRP_ID'] |
|
320 | + ), |
|
321 | + __FILE__, |
|
322 | + __FUNCTION__, |
|
323 | + __LINE__ |
|
324 | + ); |
|
325 | + $this->_template_args['success'] = false; |
|
326 | + $this->_template_args['error'] = true; |
|
327 | + $this->_return_json(); |
|
328 | + } |
|
329 | + $MTPs = $MTPG->context_templates(); |
|
330 | + $MTPs = $MTPs['attendee']; |
|
331 | + $template_fields = array(); |
|
332 | + /** @var EE_Message_Template $MTP */ |
|
333 | + foreach ($MTPs as $MTP) { |
|
334 | + $field = $MTP->get('MTP_template_field'); |
|
335 | + if ($field === 'content') { |
|
336 | + $content = $MTP->get('MTP_content'); |
|
337 | + if (! empty($content['newsletter_content'])) { |
|
338 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
339 | + } |
|
340 | + continue; |
|
341 | + } |
|
342 | + $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
343 | + } |
|
344 | + $this->_template_args['success'] = true; |
|
345 | + $this->_template_args['error'] = false; |
|
346 | + $this->_template_args['data'] = array( |
|
347 | + 'batch_message_from' => isset($template_fields['from']) |
|
348 | + ? $template_fields['from'] |
|
349 | + : '', |
|
350 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
351 | + ? $template_fields['subject'] |
|
352 | + : '', |
|
353 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
354 | + ? $template_fields['newsletter_content'] |
|
355 | + : '', |
|
356 | + ); |
|
357 | + $this->_return_json(); |
|
358 | + } |
|
359 | 359 | |
360 | 360 | |
361 | - /** |
|
362 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
363 | - * |
|
364 | - * @since 4.3.0 |
|
365 | - * @param EE_Admin_List_Table $list_table |
|
366 | - * @return void |
|
367 | - * @throws InvalidArgumentException |
|
368 | - * @throws InvalidDataTypeException |
|
369 | - * @throws InvalidInterfaceException |
|
370 | - */ |
|
371 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
372 | - { |
|
373 | - if ( |
|
374 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
375 | - 'ee_send_message', |
|
376 | - 'espresso_registrations_newsletter_selected_send' |
|
377 | - ) |
|
378 | - ) { |
|
379 | - return; |
|
380 | - } |
|
381 | - $routes_to_add_to = array( |
|
382 | - 'contact_list', |
|
383 | - 'event_registrations', |
|
384 | - 'default', |
|
385 | - ); |
|
386 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
387 | - if ( |
|
388 | - ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
389 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
390 | - ) { |
|
391 | - echo ''; |
|
392 | - } else { |
|
393 | - $button_text = sprintf( |
|
394 | - esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
395 | - '<span class="send-selected-newsletter-count">0</span>' |
|
396 | - ); |
|
397 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button">' |
|
398 | - . '<span class="dashicons dashicons-email "></span>' |
|
399 | - . $button_text |
|
400 | - . '</button>'; |
|
401 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
402 | - } |
|
403 | - } |
|
404 | - } |
|
361 | + /** |
|
362 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
363 | + * |
|
364 | + * @since 4.3.0 |
|
365 | + * @param EE_Admin_List_Table $list_table |
|
366 | + * @return void |
|
367 | + * @throws InvalidArgumentException |
|
368 | + * @throws InvalidDataTypeException |
|
369 | + * @throws InvalidInterfaceException |
|
370 | + */ |
|
371 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
372 | + { |
|
373 | + if ( |
|
374 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
375 | + 'ee_send_message', |
|
376 | + 'espresso_registrations_newsletter_selected_send' |
|
377 | + ) |
|
378 | + ) { |
|
379 | + return; |
|
380 | + } |
|
381 | + $routes_to_add_to = array( |
|
382 | + 'contact_list', |
|
383 | + 'event_registrations', |
|
384 | + 'default', |
|
385 | + ); |
|
386 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
387 | + if ( |
|
388 | + ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
389 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
390 | + ) { |
|
391 | + echo ''; |
|
392 | + } else { |
|
393 | + $button_text = sprintf( |
|
394 | + esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
395 | + '<span class="send-selected-newsletter-count">0</span>' |
|
396 | + ); |
|
397 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button">' |
|
398 | + . '<span class="dashicons dashicons-email "></span>' |
|
399 | + . $button_text |
|
400 | + . '</button>'; |
|
401 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
402 | + } |
|
403 | + } |
|
404 | + } |
|
405 | 405 | |
406 | 406 | |
407 | - /** |
|
408 | - * @throws DomainException |
|
409 | - * @throws EE_Error |
|
410 | - * @throws InvalidArgumentException |
|
411 | - * @throws InvalidDataTypeException |
|
412 | - * @throws InvalidInterfaceException |
|
413 | - */ |
|
414 | - public function newsletter_send_form_skeleton() |
|
415 | - { |
|
416 | - $list_table = $this->_list_table_object; |
|
417 | - $codes = array(); |
|
418 | - // need to templates for the newsletter message type for the template selector. |
|
419 | - $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
420 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
421 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
422 | - ); |
|
423 | - foreach ($mtps as $mtp) { |
|
424 | - $name = $mtp->name(); |
|
425 | - $values[] = array( |
|
426 | - 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
427 | - 'id' => $mtp->ID(), |
|
428 | - ); |
|
429 | - } |
|
430 | - // need to get a list of shortcodes that are available for the newsletter message type. |
|
431 | - $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
432 | - 'newsletter', |
|
433 | - 'email', |
|
434 | - array(), |
|
435 | - 'attendee', |
|
436 | - false |
|
437 | - ); |
|
438 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
439 | - $available_shortcodes = array(); |
|
440 | - foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
441 | - $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
442 | - ? 'content' |
|
443 | - : $field; |
|
444 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
445 | - $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
446 | - . $shortcode |
|
447 | - . '" data-linked-input-id="' . $field_id . '">' |
|
448 | - . $shortcode |
|
449 | - . '</span>'; |
|
450 | - } |
|
451 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
452 | - } |
|
453 | - $shortcodes = $codes; |
|
454 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
455 | - $form_template_args = array( |
|
456 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
457 | - 'form_route' => 'newsletter_selected_send', |
|
458 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
459 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
460 | - 'redirect_back_to' => $this->_req_action, |
|
461 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
462 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
463 | - 'shortcodes' => $shortcodes, |
|
464 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
465 | - ); |
|
466 | - EEH_Template::display_template($form_template, $form_template_args); |
|
467 | - } |
|
407 | + /** |
|
408 | + * @throws DomainException |
|
409 | + * @throws EE_Error |
|
410 | + * @throws InvalidArgumentException |
|
411 | + * @throws InvalidDataTypeException |
|
412 | + * @throws InvalidInterfaceException |
|
413 | + */ |
|
414 | + public function newsletter_send_form_skeleton() |
|
415 | + { |
|
416 | + $list_table = $this->_list_table_object; |
|
417 | + $codes = array(); |
|
418 | + // need to templates for the newsletter message type for the template selector. |
|
419 | + $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
420 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
421 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
422 | + ); |
|
423 | + foreach ($mtps as $mtp) { |
|
424 | + $name = $mtp->name(); |
|
425 | + $values[] = array( |
|
426 | + 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
427 | + 'id' => $mtp->ID(), |
|
428 | + ); |
|
429 | + } |
|
430 | + // need to get a list of shortcodes that are available for the newsletter message type. |
|
431 | + $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
432 | + 'newsletter', |
|
433 | + 'email', |
|
434 | + array(), |
|
435 | + 'attendee', |
|
436 | + false |
|
437 | + ); |
|
438 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
439 | + $available_shortcodes = array(); |
|
440 | + foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
441 | + $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
442 | + ? 'content' |
|
443 | + : $field; |
|
444 | + $field_id = 'batch-message-' . strtolower($field_id); |
|
445 | + $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
446 | + . $shortcode |
|
447 | + . '" data-linked-input-id="' . $field_id . '">' |
|
448 | + . $shortcode |
|
449 | + . '</span>'; |
|
450 | + } |
|
451 | + $codes[ $field ] = implode(', ', $available_shortcodes); |
|
452 | + } |
|
453 | + $shortcodes = $codes; |
|
454 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
455 | + $form_template_args = array( |
|
456 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
457 | + 'form_route' => 'newsletter_selected_send', |
|
458 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
459 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
460 | + 'redirect_back_to' => $this->_req_action, |
|
461 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
462 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
463 | + 'shortcodes' => $shortcodes, |
|
464 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
465 | + ); |
|
466 | + EEH_Template::display_template($form_template, $form_template_args); |
|
467 | + } |
|
468 | 468 | |
469 | 469 | |
470 | - /** |
|
471 | - * Handles sending selected registrations/contacts a newsletter. |
|
472 | - * |
|
473 | - * @since 4.3.0 |
|
474 | - * @return void |
|
475 | - * @throws EE_Error |
|
476 | - * @throws InvalidArgumentException |
|
477 | - * @throws InvalidDataTypeException |
|
478 | - * @throws InvalidInterfaceException |
|
479 | - */ |
|
480 | - protected function _newsletter_selected_send() |
|
481 | - { |
|
482 | - $success = true; |
|
483 | - // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
484 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
485 | - EE_Error::add_error( |
|
486 | - esc_html__( |
|
487 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
488 | - 'event_espresso' |
|
489 | - ), |
|
490 | - __FILE__, |
|
491 | - __FUNCTION__, |
|
492 | - __LINE__ |
|
493 | - ); |
|
494 | - $success = false; |
|
495 | - } |
|
496 | - if ($success) { |
|
497 | - // update Message template in case there are any changes |
|
498 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
499 | - $this->_req_data['newsletter_mtp_selected'] |
|
500 | - ); |
|
501 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
502 | - ? $Message_Template_Group->context_templates() |
|
503 | - : array(); |
|
504 | - if (empty($Message_Templates)) { |
|
505 | - EE_Error::add_error( |
|
506 | - esc_html__( |
|
507 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
508 | - 'event_espresso' |
|
509 | - ), |
|
510 | - __FILE__, |
|
511 | - __FUNCTION__, |
|
512 | - __LINE__ |
|
513 | - ); |
|
514 | - } |
|
515 | - // let's just update the specific fields |
|
516 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
517 | - if ($Message_Template instanceof EE_Message_Template) { |
|
518 | - $field = $Message_Template->get('MTP_template_field'); |
|
519 | - $content = $Message_Template->get('MTP_content'); |
|
520 | - $new_content = $content; |
|
521 | - switch ($field) { |
|
522 | - case 'from': |
|
523 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
524 | - ? $this->_req_data['batch_message']['from'] |
|
525 | - : $content; |
|
526 | - break; |
|
527 | - case 'subject': |
|
528 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
529 | - ? $this->_req_data['batch_message']['subject'] |
|
530 | - : $content; |
|
531 | - break; |
|
532 | - case 'content': |
|
533 | - $new_content = $content; |
|
534 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
535 | - ? $this->_req_data['batch_message']['content'] |
|
536 | - : $content['newsletter_content']; |
|
537 | - break; |
|
538 | - default: |
|
539 | - // continue the foreach loop, we don't want to set $new_content nor save. |
|
540 | - continue 2; |
|
541 | - } |
|
542 | - $Message_Template->set('MTP_content', $new_content); |
|
543 | - $Message_Template->save(); |
|
544 | - } |
|
545 | - } |
|
546 | - // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
547 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
548 | - ? $this->_req_data['batch_message']['id_type'] |
|
549 | - : 'registration'; |
|
550 | - // id_type will affect how we assemble the ids. |
|
551 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
552 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
553 | - : array(); |
|
554 | - $registrations_used_for_contact_data = array(); |
|
555 | - // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
556 | - switch ($id_type) { |
|
557 | - case 'registration': |
|
558 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
559 | - array( |
|
560 | - array( |
|
561 | - 'REG_ID' => array('IN', $ids), |
|
562 | - ), |
|
563 | - ) |
|
564 | - ); |
|
565 | - break; |
|
566 | - case 'contact': |
|
567 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
568 | - ->get_latest_registration_for_each_of_given_contacts( |
|
569 | - $ids |
|
570 | - ); |
|
571 | - break; |
|
572 | - } |
|
573 | - do_action_ref_array( |
|
574 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
575 | - array( |
|
576 | - $registrations_used_for_contact_data, |
|
577 | - $Message_Template_Group->ID(), |
|
578 | - ) |
|
579 | - ); |
|
580 | - // kept for backward compat, internally we no longer use this action. |
|
581 | - // @deprecated 4.8.36.rc.002 |
|
582 | - $contacts = $id_type === 'registration' |
|
583 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
584 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
585 | - do_action_ref_array( |
|
586 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
587 | - array( |
|
588 | - $contacts, |
|
589 | - $Message_Template_Group->ID(), |
|
590 | - ) |
|
591 | - ); |
|
592 | - } |
|
593 | - $query_args = array( |
|
594 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
595 | - ? $this->_req_data['redirect_back_to'] |
|
596 | - : 'default', |
|
597 | - ); |
|
598 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
599 | - } |
|
470 | + /** |
|
471 | + * Handles sending selected registrations/contacts a newsletter. |
|
472 | + * |
|
473 | + * @since 4.3.0 |
|
474 | + * @return void |
|
475 | + * @throws EE_Error |
|
476 | + * @throws InvalidArgumentException |
|
477 | + * @throws InvalidDataTypeException |
|
478 | + * @throws InvalidInterfaceException |
|
479 | + */ |
|
480 | + protected function _newsletter_selected_send() |
|
481 | + { |
|
482 | + $success = true; |
|
483 | + // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
484 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
485 | + EE_Error::add_error( |
|
486 | + esc_html__( |
|
487 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
488 | + 'event_espresso' |
|
489 | + ), |
|
490 | + __FILE__, |
|
491 | + __FUNCTION__, |
|
492 | + __LINE__ |
|
493 | + ); |
|
494 | + $success = false; |
|
495 | + } |
|
496 | + if ($success) { |
|
497 | + // update Message template in case there are any changes |
|
498 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
499 | + $this->_req_data['newsletter_mtp_selected'] |
|
500 | + ); |
|
501 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
502 | + ? $Message_Template_Group->context_templates() |
|
503 | + : array(); |
|
504 | + if (empty($Message_Templates)) { |
|
505 | + EE_Error::add_error( |
|
506 | + esc_html__( |
|
507 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
508 | + 'event_espresso' |
|
509 | + ), |
|
510 | + __FILE__, |
|
511 | + __FUNCTION__, |
|
512 | + __LINE__ |
|
513 | + ); |
|
514 | + } |
|
515 | + // let's just update the specific fields |
|
516 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
517 | + if ($Message_Template instanceof EE_Message_Template) { |
|
518 | + $field = $Message_Template->get('MTP_template_field'); |
|
519 | + $content = $Message_Template->get('MTP_content'); |
|
520 | + $new_content = $content; |
|
521 | + switch ($field) { |
|
522 | + case 'from': |
|
523 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
524 | + ? $this->_req_data['batch_message']['from'] |
|
525 | + : $content; |
|
526 | + break; |
|
527 | + case 'subject': |
|
528 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
529 | + ? $this->_req_data['batch_message']['subject'] |
|
530 | + : $content; |
|
531 | + break; |
|
532 | + case 'content': |
|
533 | + $new_content = $content; |
|
534 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
535 | + ? $this->_req_data['batch_message']['content'] |
|
536 | + : $content['newsletter_content']; |
|
537 | + break; |
|
538 | + default: |
|
539 | + // continue the foreach loop, we don't want to set $new_content nor save. |
|
540 | + continue 2; |
|
541 | + } |
|
542 | + $Message_Template->set('MTP_content', $new_content); |
|
543 | + $Message_Template->save(); |
|
544 | + } |
|
545 | + } |
|
546 | + // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
547 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
548 | + ? $this->_req_data['batch_message']['id_type'] |
|
549 | + : 'registration'; |
|
550 | + // id_type will affect how we assemble the ids. |
|
551 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
552 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
553 | + : array(); |
|
554 | + $registrations_used_for_contact_data = array(); |
|
555 | + // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
556 | + switch ($id_type) { |
|
557 | + case 'registration': |
|
558 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
559 | + array( |
|
560 | + array( |
|
561 | + 'REG_ID' => array('IN', $ids), |
|
562 | + ), |
|
563 | + ) |
|
564 | + ); |
|
565 | + break; |
|
566 | + case 'contact': |
|
567 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
568 | + ->get_latest_registration_for_each_of_given_contacts( |
|
569 | + $ids |
|
570 | + ); |
|
571 | + break; |
|
572 | + } |
|
573 | + do_action_ref_array( |
|
574 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
575 | + array( |
|
576 | + $registrations_used_for_contact_data, |
|
577 | + $Message_Template_Group->ID(), |
|
578 | + ) |
|
579 | + ); |
|
580 | + // kept for backward compat, internally we no longer use this action. |
|
581 | + // @deprecated 4.8.36.rc.002 |
|
582 | + $contacts = $id_type === 'registration' |
|
583 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
584 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
585 | + do_action_ref_array( |
|
586 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
587 | + array( |
|
588 | + $contacts, |
|
589 | + $Message_Template_Group->ID(), |
|
590 | + ) |
|
591 | + ); |
|
592 | + } |
|
593 | + $query_args = array( |
|
594 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
595 | + ? $this->_req_data['redirect_back_to'] |
|
596 | + : 'default', |
|
597 | + ); |
|
598 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
599 | + } |
|
600 | 600 | |
601 | 601 | |
602 | - /** |
|
603 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
604 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
605 | - */ |
|
606 | - protected function _registration_reports_js_setup() |
|
607 | - { |
|
608 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
609 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
610 | - } |
|
602 | + /** |
|
603 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
604 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
605 | + */ |
|
606 | + protected function _registration_reports_js_setup() |
|
607 | + { |
|
608 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
609 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
610 | + } |
|
611 | 611 | |
612 | 612 | |
613 | - /** |
|
614 | - * generates Business Reports regarding Registrations |
|
615 | - * |
|
616 | - * @access protected |
|
617 | - * @return void |
|
618 | - * @throws DomainException |
|
619 | - */ |
|
620 | - protected function _registration_reports() |
|
621 | - { |
|
622 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
623 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
624 | - $template_path, |
|
625 | - $this->_reports_template_data, |
|
626 | - true |
|
627 | - ); |
|
628 | - // the final template wrapper |
|
629 | - $this->display_admin_page_with_no_sidebar(); |
|
630 | - } |
|
613 | + /** |
|
614 | + * generates Business Reports regarding Registrations |
|
615 | + * |
|
616 | + * @access protected |
|
617 | + * @return void |
|
618 | + * @throws DomainException |
|
619 | + */ |
|
620 | + protected function _registration_reports() |
|
621 | + { |
|
622 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
623 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
624 | + $template_path, |
|
625 | + $this->_reports_template_data, |
|
626 | + true |
|
627 | + ); |
|
628 | + // the final template wrapper |
|
629 | + $this->display_admin_page_with_no_sidebar(); |
|
630 | + } |
|
631 | 631 | |
632 | 632 | |
633 | - /** |
|
634 | - * Generates Business Report showing total registrations per day. |
|
635 | - * |
|
636 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
637 | - * @return string |
|
638 | - * @throws EE_Error |
|
639 | - * @throws InvalidArgumentException |
|
640 | - * @throws InvalidDataTypeException |
|
641 | - * @throws InvalidInterfaceException |
|
642 | - */ |
|
643 | - private function _registrations_per_day_report($period = '-1 month') |
|
644 | - { |
|
645 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
646 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
647 | - $results = (array) $results; |
|
648 | - $regs = array(); |
|
649 | - $subtitle = ''; |
|
650 | - if ($results) { |
|
651 | - $column_titles = array(); |
|
652 | - $tracker = 0; |
|
653 | - foreach ($results as $result) { |
|
654 | - $report_column_values = array(); |
|
655 | - foreach ($result as $property_name => $property_value) { |
|
656 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
657 | - : (int) $property_value; |
|
658 | - $report_column_values[] = $property_value; |
|
659 | - if ($tracker === 0) { |
|
660 | - if ($property_name === 'Registration_REG_date') { |
|
661 | - $column_titles[] = esc_html__( |
|
662 | - 'Date (only days with registrations are shown)', |
|
663 | - 'event_espresso' |
|
664 | - ); |
|
665 | - } else { |
|
666 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
667 | - } |
|
668 | - } |
|
669 | - } |
|
670 | - $tracker++; |
|
671 | - $regs[] = $report_column_values; |
|
672 | - } |
|
673 | - // make sure the column_titles is pushed to the beginning of the array |
|
674 | - array_unshift($regs, $column_titles); |
|
675 | - // setup the date range. |
|
676 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
677 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
678 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
679 | - $subtitle = sprintf( |
|
680 | - wp_strip_all_tags( |
|
681 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
682 | - ), |
|
683 | - $beginning_date->format('Y-m-d'), |
|
684 | - $ending_date->format('Y-m-d') |
|
685 | - ); |
|
686 | - } |
|
687 | - $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
688 | - $report_params = array( |
|
689 | - 'title' => $report_title, |
|
690 | - 'subtitle' => $subtitle, |
|
691 | - 'id' => $report_ID, |
|
692 | - 'regs' => $regs, |
|
693 | - 'noResults' => empty($regs), |
|
694 | - 'noRegsMsg' => sprintf( |
|
695 | - wp_strip_all_tags( |
|
696 | - __( |
|
697 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
698 | - 'event_espresso' |
|
699 | - ) |
|
700 | - ), |
|
701 | - '<h2>' . $report_title . '</h2><p>', |
|
702 | - '</p>' |
|
703 | - ), |
|
704 | - ); |
|
705 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
706 | - return $report_ID; |
|
707 | - } |
|
633 | + /** |
|
634 | + * Generates Business Report showing total registrations per day. |
|
635 | + * |
|
636 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
637 | + * @return string |
|
638 | + * @throws EE_Error |
|
639 | + * @throws InvalidArgumentException |
|
640 | + * @throws InvalidDataTypeException |
|
641 | + * @throws InvalidInterfaceException |
|
642 | + */ |
|
643 | + private function _registrations_per_day_report($period = '-1 month') |
|
644 | + { |
|
645 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
646 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
647 | + $results = (array) $results; |
|
648 | + $regs = array(); |
|
649 | + $subtitle = ''; |
|
650 | + if ($results) { |
|
651 | + $column_titles = array(); |
|
652 | + $tracker = 0; |
|
653 | + foreach ($results as $result) { |
|
654 | + $report_column_values = array(); |
|
655 | + foreach ($result as $property_name => $property_value) { |
|
656 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
657 | + : (int) $property_value; |
|
658 | + $report_column_values[] = $property_value; |
|
659 | + if ($tracker === 0) { |
|
660 | + if ($property_name === 'Registration_REG_date') { |
|
661 | + $column_titles[] = esc_html__( |
|
662 | + 'Date (only days with registrations are shown)', |
|
663 | + 'event_espresso' |
|
664 | + ); |
|
665 | + } else { |
|
666 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
667 | + } |
|
668 | + } |
|
669 | + } |
|
670 | + $tracker++; |
|
671 | + $regs[] = $report_column_values; |
|
672 | + } |
|
673 | + // make sure the column_titles is pushed to the beginning of the array |
|
674 | + array_unshift($regs, $column_titles); |
|
675 | + // setup the date range. |
|
676 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
677 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
678 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
679 | + $subtitle = sprintf( |
|
680 | + wp_strip_all_tags( |
|
681 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
682 | + ), |
|
683 | + $beginning_date->format('Y-m-d'), |
|
684 | + $ending_date->format('Y-m-d') |
|
685 | + ); |
|
686 | + } |
|
687 | + $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
688 | + $report_params = array( |
|
689 | + 'title' => $report_title, |
|
690 | + 'subtitle' => $subtitle, |
|
691 | + 'id' => $report_ID, |
|
692 | + 'regs' => $regs, |
|
693 | + 'noResults' => empty($regs), |
|
694 | + 'noRegsMsg' => sprintf( |
|
695 | + wp_strip_all_tags( |
|
696 | + __( |
|
697 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
698 | + 'event_espresso' |
|
699 | + ) |
|
700 | + ), |
|
701 | + '<h2>' . $report_title . '</h2><p>', |
|
702 | + '</p>' |
|
703 | + ), |
|
704 | + ); |
|
705 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
706 | + return $report_ID; |
|
707 | + } |
|
708 | 708 | |
709 | 709 | |
710 | - /** |
|
711 | - * Generates Business Report showing total registrations per event. |
|
712 | - * |
|
713 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
714 | - * @return string |
|
715 | - * @throws EE_Error |
|
716 | - * @throws InvalidArgumentException |
|
717 | - * @throws InvalidDataTypeException |
|
718 | - * @throws InvalidInterfaceException |
|
719 | - */ |
|
720 | - private function _registrations_per_event_report($period = '-1 month') |
|
721 | - { |
|
722 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
723 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
724 | - $results = (array) $results; |
|
725 | - $regs = array(); |
|
726 | - $subtitle = ''; |
|
727 | - if ($results) { |
|
728 | - $column_titles = array(); |
|
729 | - $tracker = 0; |
|
730 | - foreach ($results as $result) { |
|
731 | - $report_column_values = array(); |
|
732 | - foreach ($result as $property_name => $property_value) { |
|
733 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
734 | - $property_value, |
|
735 | - 4, |
|
736 | - '...' |
|
737 | - ) : (int) $property_value; |
|
738 | - $report_column_values[] = $property_value; |
|
739 | - if ($tracker === 0) { |
|
740 | - if ($property_name === 'Registration_Event') { |
|
741 | - $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
742 | - } else { |
|
743 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
744 | - } |
|
745 | - } |
|
746 | - } |
|
747 | - $tracker++; |
|
748 | - $regs[] = $report_column_values; |
|
749 | - } |
|
750 | - // make sure the column_titles is pushed to the beginning of the array |
|
751 | - array_unshift($regs, $column_titles); |
|
752 | - // setup the date range. |
|
753 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
754 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
755 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
756 | - $subtitle = sprintf( |
|
757 | - wp_strip_all_tags( |
|
758 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
759 | - ), |
|
760 | - $beginning_date->format('Y-m-d'), |
|
761 | - $ending_date->format('Y-m-d') |
|
762 | - ); |
|
763 | - } |
|
764 | - $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
765 | - $report_params = array( |
|
766 | - 'title' => $report_title, |
|
767 | - 'subtitle' => $subtitle, |
|
768 | - 'id' => $report_ID, |
|
769 | - 'regs' => $regs, |
|
770 | - 'noResults' => empty($regs), |
|
771 | - 'noRegsMsg' => sprintf( |
|
772 | - wp_strip_all_tags( |
|
773 | - __( |
|
774 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
775 | - 'event_espresso' |
|
776 | - ) |
|
777 | - ), |
|
778 | - '<h2>' . $report_title . '</h2><p>', |
|
779 | - '</p>' |
|
780 | - ), |
|
781 | - ); |
|
782 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
783 | - return $report_ID; |
|
784 | - } |
|
710 | + /** |
|
711 | + * Generates Business Report showing total registrations per event. |
|
712 | + * |
|
713 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
714 | + * @return string |
|
715 | + * @throws EE_Error |
|
716 | + * @throws InvalidArgumentException |
|
717 | + * @throws InvalidDataTypeException |
|
718 | + * @throws InvalidInterfaceException |
|
719 | + */ |
|
720 | + private function _registrations_per_event_report($period = '-1 month') |
|
721 | + { |
|
722 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
723 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
724 | + $results = (array) $results; |
|
725 | + $regs = array(); |
|
726 | + $subtitle = ''; |
|
727 | + if ($results) { |
|
728 | + $column_titles = array(); |
|
729 | + $tracker = 0; |
|
730 | + foreach ($results as $result) { |
|
731 | + $report_column_values = array(); |
|
732 | + foreach ($result as $property_name => $property_value) { |
|
733 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
734 | + $property_value, |
|
735 | + 4, |
|
736 | + '...' |
|
737 | + ) : (int) $property_value; |
|
738 | + $report_column_values[] = $property_value; |
|
739 | + if ($tracker === 0) { |
|
740 | + if ($property_name === 'Registration_Event') { |
|
741 | + $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
742 | + } else { |
|
743 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
744 | + } |
|
745 | + } |
|
746 | + } |
|
747 | + $tracker++; |
|
748 | + $regs[] = $report_column_values; |
|
749 | + } |
|
750 | + // make sure the column_titles is pushed to the beginning of the array |
|
751 | + array_unshift($regs, $column_titles); |
|
752 | + // setup the date range. |
|
753 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
754 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
755 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
756 | + $subtitle = sprintf( |
|
757 | + wp_strip_all_tags( |
|
758 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
759 | + ), |
|
760 | + $beginning_date->format('Y-m-d'), |
|
761 | + $ending_date->format('Y-m-d') |
|
762 | + ); |
|
763 | + } |
|
764 | + $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
765 | + $report_params = array( |
|
766 | + 'title' => $report_title, |
|
767 | + 'subtitle' => $subtitle, |
|
768 | + 'id' => $report_ID, |
|
769 | + 'regs' => $regs, |
|
770 | + 'noResults' => empty($regs), |
|
771 | + 'noRegsMsg' => sprintf( |
|
772 | + wp_strip_all_tags( |
|
773 | + __( |
|
774 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
775 | + 'event_espresso' |
|
776 | + ) |
|
777 | + ), |
|
778 | + '<h2>' . $report_title . '</h2><p>', |
|
779 | + '</p>' |
|
780 | + ), |
|
781 | + ); |
|
782 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
783 | + return $report_ID; |
|
784 | + } |
|
785 | 785 | |
786 | 786 | |
787 | - /** |
|
788 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
789 | - * |
|
790 | - * @access protected |
|
791 | - * @return void |
|
792 | - * @throws EE_Error |
|
793 | - * @throws InvalidArgumentException |
|
794 | - * @throws InvalidDataTypeException |
|
795 | - * @throws InvalidInterfaceException |
|
796 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
797 | - */ |
|
798 | - protected function _registration_checkin_list_table() |
|
799 | - { |
|
800 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
801 | - $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
802 | - /** @var EE_Registration $registration */ |
|
803 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
804 | - if (! $registration instanceof EE_Registration) { |
|
805 | - throw new EE_Error( |
|
806 | - sprintf( |
|
807 | - esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
808 | - $reg_id |
|
809 | - ) |
|
810 | - ); |
|
811 | - } |
|
812 | - $attendee = $registration->attendee(); |
|
813 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
814 | - 'new_registration', |
|
815 | - 'add-registrant', |
|
816 | - array('event_id' => $registration->event_ID()), |
|
817 | - 'add-new-h2' |
|
818 | - ); |
|
819 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
820 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
821 | - $legend_items = array( |
|
822 | - 'checkin' => array( |
|
823 | - 'class' => $checked_in->cssClasses(), |
|
824 | - 'desc' => $checked_in->legendLabel(), |
|
825 | - ), |
|
826 | - 'checkout' => array( |
|
827 | - 'class' => $checked_out->cssClasses(), |
|
828 | - 'desc' => $checked_out->legendLabel(), |
|
829 | - ), |
|
830 | - ); |
|
831 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
832 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
833 | - /** @var EE_Datetime $datetime */ |
|
834 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
835 | - $datetime_label = ''; |
|
836 | - if ($datetime instanceof EE_Datetime) { |
|
837 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
838 | - $datetime_label .= ! empty($datetime_label) |
|
839 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
840 | - : $datetime->get_dtt_display_name(); |
|
841 | - } |
|
842 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
843 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
844 | - array( |
|
845 | - 'action' => 'event_registrations', |
|
846 | - 'event_id' => $registration->event_ID(), |
|
847 | - 'DTT_ID' => $dtt_id, |
|
848 | - ), |
|
849 | - $this->_admin_base_url |
|
850 | - ) |
|
851 | - : ''; |
|
852 | - $datetime_link = ! empty($datetime_link) |
|
853 | - ? '<a href="' . $datetime_link . '">' |
|
854 | - . '<span id="checkin-dtt">' |
|
855 | - . $datetime_label |
|
856 | - . '</span></a>' |
|
857 | - : $datetime_label; |
|
858 | - $attendee_name = $attendee instanceof EE_Attendee |
|
859 | - ? $attendee->full_name() |
|
860 | - : ''; |
|
861 | - $attendee_link = $attendee instanceof EE_Attendee |
|
862 | - ? $attendee->get_admin_details_link() |
|
863 | - : ''; |
|
864 | - $attendee_link = ! empty($attendee_link) |
|
865 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
866 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
867 | - . '<span id="checkin-attendee-name">' |
|
868 | - . $attendee_name |
|
869 | - . '</span></a>' |
|
870 | - : ''; |
|
871 | - $event_link = $registration->event() instanceof EE_Event |
|
872 | - ? $registration->event()->get_admin_details_link() |
|
873 | - : ''; |
|
874 | - $event_link = ! empty($event_link) |
|
875 | - ? '<a href="' . $event_link . '"' |
|
876 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
877 | - . '<span id="checkin-event-name">' |
|
878 | - . $registration->event_name() |
|
879 | - . '</span>' |
|
880 | - . '</a>' |
|
881 | - : ''; |
|
882 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
883 | - ? '<h2>' . sprintf( |
|
884 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
885 | - $attendee_link, |
|
886 | - $datetime_link, |
|
887 | - $event_link |
|
888 | - ) . '</h2>' |
|
889 | - : ''; |
|
890 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
891 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
892 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
893 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
894 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
895 | - } |
|
787 | + /** |
|
788 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
789 | + * |
|
790 | + * @access protected |
|
791 | + * @return void |
|
792 | + * @throws EE_Error |
|
793 | + * @throws InvalidArgumentException |
|
794 | + * @throws InvalidDataTypeException |
|
795 | + * @throws InvalidInterfaceException |
|
796 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
797 | + */ |
|
798 | + protected function _registration_checkin_list_table() |
|
799 | + { |
|
800 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
801 | + $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
802 | + /** @var EE_Registration $registration */ |
|
803 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
804 | + if (! $registration instanceof EE_Registration) { |
|
805 | + throw new EE_Error( |
|
806 | + sprintf( |
|
807 | + esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
808 | + $reg_id |
|
809 | + ) |
|
810 | + ); |
|
811 | + } |
|
812 | + $attendee = $registration->attendee(); |
|
813 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
814 | + 'new_registration', |
|
815 | + 'add-registrant', |
|
816 | + array('event_id' => $registration->event_ID()), |
|
817 | + 'add-new-h2' |
|
818 | + ); |
|
819 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
820 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
821 | + $legend_items = array( |
|
822 | + 'checkin' => array( |
|
823 | + 'class' => $checked_in->cssClasses(), |
|
824 | + 'desc' => $checked_in->legendLabel(), |
|
825 | + ), |
|
826 | + 'checkout' => array( |
|
827 | + 'class' => $checked_out->cssClasses(), |
|
828 | + 'desc' => $checked_out->legendLabel(), |
|
829 | + ), |
|
830 | + ); |
|
831 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
832 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
833 | + /** @var EE_Datetime $datetime */ |
|
834 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
835 | + $datetime_label = ''; |
|
836 | + if ($datetime instanceof EE_Datetime) { |
|
837 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
838 | + $datetime_label .= ! empty($datetime_label) |
|
839 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
840 | + : $datetime->get_dtt_display_name(); |
|
841 | + } |
|
842 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
843 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
844 | + array( |
|
845 | + 'action' => 'event_registrations', |
|
846 | + 'event_id' => $registration->event_ID(), |
|
847 | + 'DTT_ID' => $dtt_id, |
|
848 | + ), |
|
849 | + $this->_admin_base_url |
|
850 | + ) |
|
851 | + : ''; |
|
852 | + $datetime_link = ! empty($datetime_link) |
|
853 | + ? '<a href="' . $datetime_link . '">' |
|
854 | + . '<span id="checkin-dtt">' |
|
855 | + . $datetime_label |
|
856 | + . '</span></a>' |
|
857 | + : $datetime_label; |
|
858 | + $attendee_name = $attendee instanceof EE_Attendee |
|
859 | + ? $attendee->full_name() |
|
860 | + : ''; |
|
861 | + $attendee_link = $attendee instanceof EE_Attendee |
|
862 | + ? $attendee->get_admin_details_link() |
|
863 | + : ''; |
|
864 | + $attendee_link = ! empty($attendee_link) |
|
865 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
866 | + . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
867 | + . '<span id="checkin-attendee-name">' |
|
868 | + . $attendee_name |
|
869 | + . '</span></a>' |
|
870 | + : ''; |
|
871 | + $event_link = $registration->event() instanceof EE_Event |
|
872 | + ? $registration->event()->get_admin_details_link() |
|
873 | + : ''; |
|
874 | + $event_link = ! empty($event_link) |
|
875 | + ? '<a href="' . $event_link . '"' |
|
876 | + . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
877 | + . '<span id="checkin-event-name">' |
|
878 | + . $registration->event_name() |
|
879 | + . '</span>' |
|
880 | + . '</a>' |
|
881 | + : ''; |
|
882 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
883 | + ? '<h2>' . sprintf( |
|
884 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
885 | + $attendee_link, |
|
886 | + $datetime_link, |
|
887 | + $event_link |
|
888 | + ) . '</h2>' |
|
889 | + : ''; |
|
890 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
891 | + ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
892 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
893 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
894 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
895 | + } |
|
896 | 896 | |
897 | 897 | |
898 | - /** |
|
899 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
900 | - * |
|
901 | - * @return void (JSON) |
|
902 | - * @throws EE_Error |
|
903 | - * @throws InvalidArgumentException |
|
904 | - * @throws InvalidDataTypeException |
|
905 | - * @throws InvalidInterfaceException |
|
906 | - */ |
|
907 | - public function toggle_checkin_status() |
|
908 | - { |
|
909 | - // first make sure we have the necessary data |
|
910 | - if (! isset($this->_req_data['_regid'])) { |
|
911 | - EE_Error::add_error( |
|
912 | - esc_html__( |
|
913 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
914 | - 'event_espresso' |
|
915 | - ), |
|
916 | - __FILE__, |
|
917 | - __FUNCTION__, |
|
918 | - __LINE__ |
|
919 | - ); |
|
920 | - $this->_template_args['success'] = false; |
|
921 | - $this->_template_args['error'] = true; |
|
922 | - $this->_return_json(); |
|
923 | - }; |
|
924 | - // do a nonce check cause we're not coming in from an normal route here. |
|
925 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
926 | - : ''; |
|
927 | - $nonce_ref = 'checkin_nonce'; |
|
928 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
929 | - // beautiful! Made it this far so let's get the status. |
|
930 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
931 | - // setup new class to return via ajax |
|
932 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
933 | - $this->_template_args['success'] = true; |
|
934 | - $this->_return_json(); |
|
935 | - } |
|
898 | + /** |
|
899 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
900 | + * |
|
901 | + * @return void (JSON) |
|
902 | + * @throws EE_Error |
|
903 | + * @throws InvalidArgumentException |
|
904 | + * @throws InvalidDataTypeException |
|
905 | + * @throws InvalidInterfaceException |
|
906 | + */ |
|
907 | + public function toggle_checkin_status() |
|
908 | + { |
|
909 | + // first make sure we have the necessary data |
|
910 | + if (! isset($this->_req_data['_regid'])) { |
|
911 | + EE_Error::add_error( |
|
912 | + esc_html__( |
|
913 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
914 | + 'event_espresso' |
|
915 | + ), |
|
916 | + __FILE__, |
|
917 | + __FUNCTION__, |
|
918 | + __LINE__ |
|
919 | + ); |
|
920 | + $this->_template_args['success'] = false; |
|
921 | + $this->_template_args['error'] = true; |
|
922 | + $this->_return_json(); |
|
923 | + }; |
|
924 | + // do a nonce check cause we're not coming in from an normal route here. |
|
925 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
926 | + : ''; |
|
927 | + $nonce_ref = 'checkin_nonce'; |
|
928 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
929 | + // beautiful! Made it this far so let's get the status. |
|
930 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
931 | + // setup new class to return via ajax |
|
932 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
933 | + $this->_template_args['success'] = true; |
|
934 | + $this->_return_json(); |
|
935 | + } |
|
936 | 936 | |
937 | 937 | |
938 | - /** |
|
939 | - * handles toggling the checkin status for the registration, |
|
940 | - * |
|
941 | - * @access protected |
|
942 | - * @return int|void |
|
943 | - * @throws EE_Error |
|
944 | - * @throws InvalidArgumentException |
|
945 | - * @throws InvalidDataTypeException |
|
946 | - * @throws InvalidInterfaceException |
|
947 | - */ |
|
948 | - protected function _toggle_checkin_status() |
|
949 | - { |
|
950 | - // first let's get the query args out of the way for the redirect |
|
951 | - $query_args = array( |
|
952 | - 'action' => 'event_registrations', |
|
953 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
954 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
955 | - ); |
|
956 | - $new_status = false; |
|
957 | - // bulk action check in toggle |
|
958 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
959 | - // cycle thru checkboxes |
|
960 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
961 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
962 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
963 | - } |
|
964 | - } elseif (isset($this->_req_data['_regid'])) { |
|
965 | - // coming from ajax request |
|
966 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
967 | - $query_args['DTT_ID'] = $DTT_ID; |
|
968 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
969 | - } else { |
|
970 | - EE_Error::add_error( |
|
971 | - esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
972 | - __FILE__, |
|
973 | - __FUNCTION__, |
|
974 | - __LINE__ |
|
975 | - ); |
|
976 | - } |
|
977 | - if (defined('DOING_AJAX')) { |
|
978 | - return $new_status; |
|
979 | - } |
|
980 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
981 | - } |
|
938 | + /** |
|
939 | + * handles toggling the checkin status for the registration, |
|
940 | + * |
|
941 | + * @access protected |
|
942 | + * @return int|void |
|
943 | + * @throws EE_Error |
|
944 | + * @throws InvalidArgumentException |
|
945 | + * @throws InvalidDataTypeException |
|
946 | + * @throws InvalidInterfaceException |
|
947 | + */ |
|
948 | + protected function _toggle_checkin_status() |
|
949 | + { |
|
950 | + // first let's get the query args out of the way for the redirect |
|
951 | + $query_args = array( |
|
952 | + 'action' => 'event_registrations', |
|
953 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
954 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
955 | + ); |
|
956 | + $new_status = false; |
|
957 | + // bulk action check in toggle |
|
958 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
959 | + // cycle thru checkboxes |
|
960 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
961 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
962 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
963 | + } |
|
964 | + } elseif (isset($this->_req_data['_regid'])) { |
|
965 | + // coming from ajax request |
|
966 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
967 | + $query_args['DTT_ID'] = $DTT_ID; |
|
968 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
969 | + } else { |
|
970 | + EE_Error::add_error( |
|
971 | + esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
972 | + __FILE__, |
|
973 | + __FUNCTION__, |
|
974 | + __LINE__ |
|
975 | + ); |
|
976 | + } |
|
977 | + if (defined('DOING_AJAX')) { |
|
978 | + return $new_status; |
|
979 | + } |
|
980 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
981 | + } |
|
982 | 982 | |
983 | 983 | |
984 | - /** |
|
985 | - * This is toggles a single Check-in for the given registration and datetime. |
|
986 | - * |
|
987 | - * @param int $REG_ID The registration we're toggling |
|
988 | - * @param int $DTT_ID The datetime we're toggling |
|
989 | - * @return int The new status toggled to. |
|
990 | - * @throws EE_Error |
|
991 | - * @throws InvalidArgumentException |
|
992 | - * @throws InvalidDataTypeException |
|
993 | - * @throws InvalidInterfaceException |
|
994 | - */ |
|
995 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
996 | - { |
|
997 | - /** @var EE_Registration $REG */ |
|
998 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
999 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
1000 | - if ($new_status !== false) { |
|
1001 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1002 | - } else { |
|
1003 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1004 | - $new_status = false; |
|
1005 | - } |
|
1006 | - return $new_status; |
|
1007 | - } |
|
984 | + /** |
|
985 | + * This is toggles a single Check-in for the given registration and datetime. |
|
986 | + * |
|
987 | + * @param int $REG_ID The registration we're toggling |
|
988 | + * @param int $DTT_ID The datetime we're toggling |
|
989 | + * @return int The new status toggled to. |
|
990 | + * @throws EE_Error |
|
991 | + * @throws InvalidArgumentException |
|
992 | + * @throws InvalidDataTypeException |
|
993 | + * @throws InvalidInterfaceException |
|
994 | + */ |
|
995 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
996 | + { |
|
997 | + /** @var EE_Registration $REG */ |
|
998 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
999 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
1000 | + if ($new_status !== false) { |
|
1001 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1002 | + } else { |
|
1003 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1004 | + $new_status = false; |
|
1005 | + } |
|
1006 | + return $new_status; |
|
1007 | + } |
|
1008 | 1008 | |
1009 | 1009 | |
1010 | - /** |
|
1011 | - * Takes care of deleting multiple EE_Checkin table rows |
|
1012 | - * |
|
1013 | - * @access protected |
|
1014 | - * @return void |
|
1015 | - * @throws EE_Error |
|
1016 | - * @throws InvalidArgumentException |
|
1017 | - * @throws InvalidDataTypeException |
|
1018 | - * @throws InvalidInterfaceException |
|
1019 | - */ |
|
1020 | - protected function _delete_checkin_rows() |
|
1021 | - { |
|
1022 | - $query_args = array( |
|
1023 | - 'action' => 'registration_checkins', |
|
1024 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1025 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1026 | - ); |
|
1027 | - $errors = 0; |
|
1028 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1029 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1030 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1031 | - $errors++; |
|
1032 | - } |
|
1033 | - } |
|
1034 | - } else { |
|
1035 | - EE_Error::add_error( |
|
1036 | - esc_html__( |
|
1037 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1038 | - 'event_espresso' |
|
1039 | - ), |
|
1040 | - __FILE__, |
|
1041 | - __FUNCTION__, |
|
1042 | - __LINE__ |
|
1043 | - ); |
|
1044 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1045 | - } |
|
1046 | - if ($errors > 0) { |
|
1047 | - EE_Error::add_error( |
|
1048 | - sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1049 | - __FILE__, |
|
1050 | - __FUNCTION__, |
|
1051 | - __LINE__ |
|
1052 | - ); |
|
1053 | - } else { |
|
1054 | - EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1055 | - } |
|
1056 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1057 | - } |
|
1010 | + /** |
|
1011 | + * Takes care of deleting multiple EE_Checkin table rows |
|
1012 | + * |
|
1013 | + * @access protected |
|
1014 | + * @return void |
|
1015 | + * @throws EE_Error |
|
1016 | + * @throws InvalidArgumentException |
|
1017 | + * @throws InvalidDataTypeException |
|
1018 | + * @throws InvalidInterfaceException |
|
1019 | + */ |
|
1020 | + protected function _delete_checkin_rows() |
|
1021 | + { |
|
1022 | + $query_args = array( |
|
1023 | + 'action' => 'registration_checkins', |
|
1024 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1025 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1026 | + ); |
|
1027 | + $errors = 0; |
|
1028 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1029 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1030 | + if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1031 | + $errors++; |
|
1032 | + } |
|
1033 | + } |
|
1034 | + } else { |
|
1035 | + EE_Error::add_error( |
|
1036 | + esc_html__( |
|
1037 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1038 | + 'event_espresso' |
|
1039 | + ), |
|
1040 | + __FILE__, |
|
1041 | + __FUNCTION__, |
|
1042 | + __LINE__ |
|
1043 | + ); |
|
1044 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1045 | + } |
|
1046 | + if ($errors > 0) { |
|
1047 | + EE_Error::add_error( |
|
1048 | + sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1049 | + __FILE__, |
|
1050 | + __FUNCTION__, |
|
1051 | + __LINE__ |
|
1052 | + ); |
|
1053 | + } else { |
|
1054 | + EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1055 | + } |
|
1056 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1057 | + } |
|
1058 | 1058 | |
1059 | 1059 | |
1060 | - /** |
|
1061 | - * Deletes a single EE_Checkin row |
|
1062 | - * |
|
1063 | - * @return void |
|
1064 | - * @throws EE_Error |
|
1065 | - * @throws InvalidArgumentException |
|
1066 | - * @throws InvalidDataTypeException |
|
1067 | - * @throws InvalidInterfaceException |
|
1068 | - */ |
|
1069 | - protected function _delete_checkin_row() |
|
1070 | - { |
|
1071 | - $query_args = array( |
|
1072 | - 'action' => 'registration_checkins', |
|
1073 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1074 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1075 | - ); |
|
1076 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1077 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1078 | - EE_Error::add_error( |
|
1079 | - esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1080 | - __FILE__, |
|
1081 | - __FUNCTION__, |
|
1082 | - __LINE__ |
|
1083 | - ); |
|
1084 | - } else { |
|
1085 | - EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1086 | - } |
|
1087 | - } else { |
|
1088 | - EE_Error::add_error( |
|
1089 | - esc_html__( |
|
1090 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1091 | - 'event_espresso' |
|
1092 | - ), |
|
1093 | - __FILE__, |
|
1094 | - __FUNCTION__, |
|
1095 | - __LINE__ |
|
1096 | - ); |
|
1097 | - } |
|
1098 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1099 | - } |
|
1060 | + /** |
|
1061 | + * Deletes a single EE_Checkin row |
|
1062 | + * |
|
1063 | + * @return void |
|
1064 | + * @throws EE_Error |
|
1065 | + * @throws InvalidArgumentException |
|
1066 | + * @throws InvalidDataTypeException |
|
1067 | + * @throws InvalidInterfaceException |
|
1068 | + */ |
|
1069 | + protected function _delete_checkin_row() |
|
1070 | + { |
|
1071 | + $query_args = array( |
|
1072 | + 'action' => 'registration_checkins', |
|
1073 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1074 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1075 | + ); |
|
1076 | + if (! empty($this->_req_data['CHK_ID'])) { |
|
1077 | + if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1078 | + EE_Error::add_error( |
|
1079 | + esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1080 | + __FILE__, |
|
1081 | + __FUNCTION__, |
|
1082 | + __LINE__ |
|
1083 | + ); |
|
1084 | + } else { |
|
1085 | + EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1086 | + } |
|
1087 | + } else { |
|
1088 | + EE_Error::add_error( |
|
1089 | + esc_html__( |
|
1090 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1091 | + 'event_espresso' |
|
1092 | + ), |
|
1093 | + __FILE__, |
|
1094 | + __FUNCTION__, |
|
1095 | + __LINE__ |
|
1096 | + ); |
|
1097 | + } |
|
1098 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1099 | + } |
|
1100 | 1100 | |
1101 | 1101 | |
1102 | - /** |
|
1103 | - * generates HTML for the Event Registrations List Table |
|
1104 | - * |
|
1105 | - * @access protected |
|
1106 | - * @return void |
|
1107 | - * @throws EE_Error |
|
1108 | - * @throws InvalidArgumentException |
|
1109 | - * @throws InvalidDataTypeException |
|
1110 | - * @throws InvalidInterfaceException |
|
1111 | - */ |
|
1112 | - protected function _event_registrations_list_table() |
|
1113 | - { |
|
1114 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1115 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1116 | - ? $this->get_action_link_or_button( |
|
1117 | - 'new_registration', |
|
1118 | - 'add-registrant', |
|
1119 | - array('event_id' => $this->_req_data['event_id']), |
|
1120 | - 'add-new-h2', |
|
1121 | - '', |
|
1122 | - false |
|
1123 | - ) |
|
1124 | - : ''; |
|
1125 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1126 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1127 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1128 | - $legend_items = array( |
|
1129 | - 'star-icon' => array( |
|
1130 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
1131 | - 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1132 | - ), |
|
1133 | - 'checkin' => array( |
|
1134 | - 'class' => $checked_in->cssClasses(), |
|
1135 | - 'desc' => $checked_in->legendLabel(), |
|
1136 | - ), |
|
1137 | - 'checkout' => array( |
|
1138 | - 'class' => $checked_out->cssClasses(), |
|
1139 | - 'desc' => $checked_out->legendLabel(), |
|
1140 | - ), |
|
1141 | - 'nocheckinrecord' => array( |
|
1142 | - 'class' => $checked_never->cssClasses(), |
|
1143 | - 'desc' => $checked_never->legendLabel(), |
|
1144 | - ), |
|
1145 | - 'approved_status' => array( |
|
1146 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1147 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1148 | - ), |
|
1149 | - 'cancelled_status' => array( |
|
1150 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1151 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1152 | - ), |
|
1153 | - 'declined_status' => array( |
|
1154 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1155 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1156 | - ), |
|
1157 | - 'not_approved' => array( |
|
1158 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1159 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1160 | - ), |
|
1161 | - 'pending_status' => array( |
|
1162 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1163 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1164 | - ), |
|
1165 | - 'wait_list' => array( |
|
1166 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1167 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1168 | - ), |
|
1169 | - ); |
|
1170 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1171 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
1172 | - /** @var EE_Event $event */ |
|
1173 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1174 | - $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1175 | - ? '<h2>' . sprintf( |
|
1176 | - esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1177 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
1178 | - ) . '</h2>' |
|
1179 | - : ''; |
|
1180 | - // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1181 | - // the event. |
|
1182 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1183 | - $datetime = null; |
|
1184 | - if ($event instanceof EE_Event) { |
|
1185 | - $datetimes_on_event = $event->datetimes(); |
|
1186 | - if (count($datetimes_on_event) === 1) { |
|
1187 | - $datetime = reset($datetimes_on_event); |
|
1188 | - } |
|
1189 | - } |
|
1190 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1191 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1192 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
1193 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
1194 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
1195 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1196 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1197 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
1198 | - } |
|
1199 | - // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1200 | - // column represents |
|
1201 | - if (! $datetime instanceof EE_Datetime) { |
|
1202 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
1203 | - . esc_html__( |
|
1204 | - 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1205 | - 'event_espresso' |
|
1206 | - ) |
|
1207 | - . '</p>'; |
|
1208 | - } |
|
1209 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1210 | - } |
|
1102 | + /** |
|
1103 | + * generates HTML for the Event Registrations List Table |
|
1104 | + * |
|
1105 | + * @access protected |
|
1106 | + * @return void |
|
1107 | + * @throws EE_Error |
|
1108 | + * @throws InvalidArgumentException |
|
1109 | + * @throws InvalidDataTypeException |
|
1110 | + * @throws InvalidInterfaceException |
|
1111 | + */ |
|
1112 | + protected function _event_registrations_list_table() |
|
1113 | + { |
|
1114 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1115 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1116 | + ? $this->get_action_link_or_button( |
|
1117 | + 'new_registration', |
|
1118 | + 'add-registrant', |
|
1119 | + array('event_id' => $this->_req_data['event_id']), |
|
1120 | + 'add-new-h2', |
|
1121 | + '', |
|
1122 | + false |
|
1123 | + ) |
|
1124 | + : ''; |
|
1125 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1126 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1127 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1128 | + $legend_items = array( |
|
1129 | + 'star-icon' => array( |
|
1130 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
1131 | + 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1132 | + ), |
|
1133 | + 'checkin' => array( |
|
1134 | + 'class' => $checked_in->cssClasses(), |
|
1135 | + 'desc' => $checked_in->legendLabel(), |
|
1136 | + ), |
|
1137 | + 'checkout' => array( |
|
1138 | + 'class' => $checked_out->cssClasses(), |
|
1139 | + 'desc' => $checked_out->legendLabel(), |
|
1140 | + ), |
|
1141 | + 'nocheckinrecord' => array( |
|
1142 | + 'class' => $checked_never->cssClasses(), |
|
1143 | + 'desc' => $checked_never->legendLabel(), |
|
1144 | + ), |
|
1145 | + 'approved_status' => array( |
|
1146 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1147 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1148 | + ), |
|
1149 | + 'cancelled_status' => array( |
|
1150 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1151 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1152 | + ), |
|
1153 | + 'declined_status' => array( |
|
1154 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1155 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1156 | + ), |
|
1157 | + 'not_approved' => array( |
|
1158 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1159 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1160 | + ), |
|
1161 | + 'pending_status' => array( |
|
1162 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1163 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1164 | + ), |
|
1165 | + 'wait_list' => array( |
|
1166 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1167 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1168 | + ), |
|
1169 | + ); |
|
1170 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1171 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
1172 | + /** @var EE_Event $event */ |
|
1173 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1174 | + $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1175 | + ? '<h2>' . sprintf( |
|
1176 | + esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1177 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
1178 | + ) . '</h2>' |
|
1179 | + : ''; |
|
1180 | + // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1181 | + // the event. |
|
1182 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1183 | + $datetime = null; |
|
1184 | + if ($event instanceof EE_Event) { |
|
1185 | + $datetimes_on_event = $event->datetimes(); |
|
1186 | + if (count($datetimes_on_event) === 1) { |
|
1187 | + $datetime = reset($datetimes_on_event); |
|
1188 | + } |
|
1189 | + } |
|
1190 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1191 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1192 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
1193 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
1194 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
1195 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1196 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1197 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
1198 | + } |
|
1199 | + // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1200 | + // column represents |
|
1201 | + if (! $datetime instanceof EE_Datetime) { |
|
1202 | + $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
1203 | + . esc_html__( |
|
1204 | + 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1205 | + 'event_espresso' |
|
1206 | + ) |
|
1207 | + . '</p>'; |
|
1208 | + } |
|
1209 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1210 | + } |
|
1211 | 1211 | |
1212 | - /** |
|
1213 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1214 | - * conditions) |
|
1215 | - * |
|
1216 | - * @return void ends the request by a redirect or download |
|
1217 | - */ |
|
1218 | - public function _registrations_checkin_report() |
|
1219 | - { |
|
1220 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1221 | - } |
|
1212 | + /** |
|
1213 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1214 | + * conditions) |
|
1215 | + * |
|
1216 | + * @return void ends the request by a redirect or download |
|
1217 | + */ |
|
1218 | + public function _registrations_checkin_report() |
|
1219 | + { |
|
1220 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1221 | + } |
|
1222 | 1222 | |
1223 | - /** |
|
1224 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1225 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1226 | - * |
|
1227 | - * @param array $request |
|
1228 | - * @param int $per_page |
|
1229 | - * @param bool $count |
|
1230 | - * @return array |
|
1231 | - * @throws EE_Error |
|
1232 | - */ |
|
1233 | - protected function _get_checkin_query_params_from_request( |
|
1234 | - $request, |
|
1235 | - $per_page = 10, |
|
1236 | - $count = false |
|
1237 | - ) { |
|
1238 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1239 | - // unlike the regular registrations list table, |
|
1240 | - $status_ids_array = apply_filters( |
|
1241 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1242 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1243 | - ); |
|
1244 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1245 | - return $query_params; |
|
1246 | - } |
|
1223 | + /** |
|
1224 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1225 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1226 | + * |
|
1227 | + * @param array $request |
|
1228 | + * @param int $per_page |
|
1229 | + * @param bool $count |
|
1230 | + * @return array |
|
1231 | + * @throws EE_Error |
|
1232 | + */ |
|
1233 | + protected function _get_checkin_query_params_from_request( |
|
1234 | + $request, |
|
1235 | + $per_page = 10, |
|
1236 | + $count = false |
|
1237 | + ) { |
|
1238 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1239 | + // unlike the regular registrations list table, |
|
1240 | + $status_ids_array = apply_filters( |
|
1241 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1242 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1243 | + ); |
|
1244 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1245 | + return $query_params; |
|
1246 | + } |
|
1247 | 1247 | |
1248 | 1248 | |
1249 | - /** |
|
1250 | - * Gets registrations for an event |
|
1251 | - * |
|
1252 | - * @param int $per_page |
|
1253 | - * @param bool $count whether to return count or data. |
|
1254 | - * @param bool $trash |
|
1255 | - * @param string $orderby |
|
1256 | - * @return EE_Registration[]|int |
|
1257 | - * @throws EE_Error |
|
1258 | - * @throws InvalidArgumentException |
|
1259 | - * @throws InvalidDataTypeException |
|
1260 | - * @throws InvalidInterfaceException |
|
1261 | - */ |
|
1262 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1263 | - { |
|
1264 | - // set some defaults, these will get overridden if included in the actual request parameters |
|
1265 | - $defaults = [ |
|
1266 | - 'orderby' => $orderby, |
|
1267 | - 'order' => 'ASC', |
|
1268 | - ]; |
|
1269 | - if ($trash) { |
|
1270 | - $defaults['status'] = 'trash'; |
|
1271 | - } |
|
1272 | - $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
1249 | + /** |
|
1250 | + * Gets registrations for an event |
|
1251 | + * |
|
1252 | + * @param int $per_page |
|
1253 | + * @param bool $count whether to return count or data. |
|
1254 | + * @param bool $trash |
|
1255 | + * @param string $orderby |
|
1256 | + * @return EE_Registration[]|int |
|
1257 | + * @throws EE_Error |
|
1258 | + * @throws InvalidArgumentException |
|
1259 | + * @throws InvalidDataTypeException |
|
1260 | + * @throws InvalidInterfaceException |
|
1261 | + */ |
|
1262 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1263 | + { |
|
1264 | + // set some defaults, these will get overridden if included in the actual request parameters |
|
1265 | + $defaults = [ |
|
1266 | + 'orderby' => $orderby, |
|
1267 | + 'order' => 'ASC', |
|
1268 | + ]; |
|
1269 | + if ($trash) { |
|
1270 | + $defaults['status'] = 'trash'; |
|
1271 | + } |
|
1272 | + $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
1273 | 1273 | |
1274 | - /** |
|
1275 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1276 | - * |
|
1277 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1278 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1279 | - * or if you have the development copy of EE you can view this at the path: |
|
1280 | - * /docs/G--Model-System/model-query-params.md |
|
1281 | - */ |
|
1282 | - $query_params['group_by'] = ''; |
|
1274 | + /** |
|
1275 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1276 | + * |
|
1277 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1278 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1279 | + * or if you have the development copy of EE you can view this at the path: |
|
1280 | + * /docs/G--Model-System/model-query-params.md |
|
1281 | + */ |
|
1282 | + $query_params['group_by'] = ''; |
|
1283 | 1283 | |
1284 | - return $count |
|
1285 | - ? EEM_Registration::instance()->count($query_params) |
|
1286 | - /** @type EE_Registration[] */ |
|
1287 | - : EEM_Registration::instance()->get_all($query_params); |
|
1288 | - } |
|
1284 | + return $count |
|
1285 | + ? EEM_Registration::instance()->count($query_params) |
|
1286 | + /** @type EE_Registration[] */ |
|
1287 | + : EEM_Registration::instance()->get_all($query_params); |
|
1288 | + } |
|
1289 | 1289 | } |