|
1
|
|
|
<?php |
|
2
|
|
|
if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3
|
|
|
exit('NO direct script access allowed'); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Event Espresso |
|
7
|
|
|
* |
|
8
|
|
|
* Event Registration and Management Plugin for Wordpress |
|
9
|
|
|
* |
|
10
|
|
|
* @package Event Espresso |
|
11
|
|
|
* @author Seth Shoultes |
|
12
|
|
|
* @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
|
13
|
|
|
* @license http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing ** |
|
14
|
|
|
* @link http://www.eventespresso.com |
|
15
|
|
|
* @version 4.0 |
|
16
|
|
|
* |
|
17
|
|
|
* ------------------------------------------------------------------------ |
|
18
|
|
|
* |
|
19
|
|
|
* Venues_Admin_Page |
|
20
|
|
|
* |
|
21
|
|
|
* This contains the logic for setting up the Event Venue related admin pages. Any methods without phpdoc comments have inline docs with parent class. |
|
22
|
|
|
* |
|
23
|
|
|
* |
|
24
|
|
|
* @package Venues_Admin_Page |
|
25
|
|
|
* @subpackage caffeinated/admin/new/Venues_Admin_Page.core.php |
|
26
|
|
|
* @author Darren Ethier |
|
27
|
|
|
* |
|
28
|
|
|
* ------------------------------------------------------------------------ |
|
29
|
|
|
*/ |
|
30
|
|
|
class Venues_Admin_Page extends EE_Admin_Page_CPT { |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* _venue |
|
35
|
|
|
* This will hold the venue object for venue_details screen. |
|
36
|
|
|
* |
|
37
|
|
|
* @access protected |
|
38
|
|
|
* @var object |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $_venue; |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* This will hold the category object for category_details screen. |
|
47
|
|
|
* @var object |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $_category; |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* This property will hold the venue model instance |
|
56
|
|
|
* @var object |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $_venue_model; |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
protected function _init_page_props() { |
|
65
|
|
|
require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
66
|
|
|
$this->page_slug = EE_VENUES_PG_SLUG; |
|
67
|
|
|
$this->_admin_base_url = EE_VENUES_ADMIN_URL; |
|
68
|
|
|
$this->_admin_base_path = EE_ADMIN_PAGES . 'venues'; |
|
69
|
|
|
$this->page_label = __('Event Venues', 'event_espresso'); |
|
70
|
|
|
$this->_cpt_model_names = array( |
|
|
|
|
|
|
71
|
|
|
'create_new' => 'EEM_Venue', |
|
72
|
|
|
'edit' => 'EEM_Venue' |
|
73
|
|
|
); |
|
74
|
|
|
$this->_cpt_edit_routes = array( |
|
75
|
|
|
'espresso_venues' => 'edit' |
|
76
|
|
|
); |
|
77
|
|
|
$this->_venue_model = EEM_Venue::instance(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
protected function _ajax_hooks() { |
|
84
|
|
|
//todo: all hooks for ee_venues ajax goes in here. |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
View Code Duplication |
protected function _define_page_props() { |
|
|
|
|
|
|
93
|
|
|
$this->_admin_page_title = $this->page_label; |
|
94
|
|
|
$this->_labels = array( |
|
95
|
|
|
'buttons' => array( |
|
96
|
|
|
'add' => __('Add New Venue', 'event_espresso'), |
|
97
|
|
|
'edit' => __('Edit Venue', 'event_espresso'), |
|
98
|
|
|
'delete' => __('Delete Venue', 'event_espresso'), |
|
99
|
|
|
'add_category' => __('Add New Category', 'event_espresso'), |
|
100
|
|
|
'edit_category' => __('Edit Category', 'event_espresso'), |
|
101
|
|
|
'delete_category' => __('Delete Category', 'event_espresso') |
|
102
|
|
|
), |
|
103
|
|
|
'editor_title' => array( |
|
104
|
|
|
'espresso_venues' => __('Enter Venue name here') |
|
105
|
|
|
), |
|
106
|
|
|
'publishbox' => array( |
|
107
|
|
|
'create_new' => __('Save New Venue', 'event_espresso'), |
|
108
|
|
|
'edit' => __('Update Venue', 'event_espresso'), |
|
109
|
|
|
'add_category' => __('Save New Category', 'event_espresso'), |
|
110
|
|
|
'edit_category' => __('Update Category', 'event_espresso'), |
|
111
|
|
|
'google_map_settings' => __( 'Update Settings', 'event_espresso' ) |
|
112
|
|
|
) |
|
113
|
|
|
); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
protected function _set_page_routes() { |
|
121
|
|
|
|
|
122
|
|
|
//load formatter helper |
|
123
|
|
|
EE_Registry::instance()->load_helper( 'Formatter' ); |
|
124
|
|
|
//load field generator helper |
|
125
|
|
|
EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
126
|
|
|
|
|
127
|
|
|
//is there a vnu_id in the request? |
|
128
|
|
|
$vnu_id = ! empty( $this->_req_data['VNU_ID'] ) && ! is_array( $this->_req_data['VNU_ID'] ) ? $this->_req_data['VNU_ID'] : 0; |
|
129
|
|
|
$vnu_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $vnu_id; |
|
130
|
|
|
|
|
131
|
|
|
$this->_page_routes = array( |
|
132
|
|
|
'default' => array( |
|
133
|
|
|
'func' => '_overview_list_table', |
|
134
|
|
|
'capability' => 'ee_read_venues' |
|
135
|
|
|
), |
|
136
|
|
|
'create_new' => array( |
|
137
|
|
|
'func' => '_create_new_cpt_item', |
|
138
|
|
|
'capability' => 'ee_edit_venues' |
|
139
|
|
|
), |
|
140
|
|
|
'edit' => array( |
|
141
|
|
|
'func' => '_edit_cpt_item', |
|
142
|
|
|
'capability' => 'ee_edit_venue', |
|
143
|
|
|
'obj_id' => $vnu_id |
|
144
|
|
|
), |
|
145
|
|
|
'trash_venue' => array( |
|
146
|
|
|
'func' => '_trash_or_restore_venue', |
|
147
|
|
|
'args' => array( 'venue_status' => 'trash' ), |
|
148
|
|
|
'noheader' => TRUE, |
|
149
|
|
|
'capability' => 'ee_delete_venue', |
|
150
|
|
|
'obj_id' => $vnu_id |
|
151
|
|
|
), |
|
152
|
|
|
'trash_venues' => array( |
|
153
|
|
|
'func' => '_trash_or_restore_venues', |
|
154
|
|
|
'args' => array( 'venue_status' => 'trash' ), |
|
155
|
|
|
'noheader' => TRUE, |
|
156
|
|
|
'capability' => 'ee_delete_venues' |
|
157
|
|
|
), |
|
158
|
|
|
'restore_venue' => array( |
|
159
|
|
|
'func' => '_trash_or_restore_venue', |
|
160
|
|
|
'args' => array( 'venue_status' => 'draft' ), |
|
161
|
|
|
'noheader' => TRUE, |
|
162
|
|
|
'capability' => 'ee_delete_venue', |
|
163
|
|
|
'obj_id' => $vnu_id |
|
164
|
|
|
), |
|
165
|
|
|
'restore_venues' => array( |
|
166
|
|
|
'func' => '_trash_or_restore_venues', |
|
167
|
|
|
'args' => array( 'venue_status' => 'draft' ), |
|
168
|
|
|
'noheader' => TRUE, |
|
169
|
|
|
'capability' => 'ee_delete_venues' |
|
170
|
|
|
), |
|
171
|
|
|
'delete_venues' => array( |
|
172
|
|
|
'func' => '_delete_venues', |
|
173
|
|
|
'noheader' => TRUE, |
|
174
|
|
|
'capability' => 'ee_delete_venues' |
|
175
|
|
|
), |
|
176
|
|
|
'delete_venue' => array( |
|
177
|
|
|
'func' => '_delete_venue', |
|
178
|
|
|
'noheader' => TRUE, |
|
179
|
|
|
'capability' => 'ee_delete_venue', |
|
180
|
|
|
'obj_id' => $vnu_id |
|
181
|
|
|
), |
|
182
|
|
|
//settings related |
|
183
|
|
|
'google_map_settings' => array( |
|
184
|
|
|
'func' => '_google_map_settings', |
|
185
|
|
|
'capability' => 'manage_options' |
|
186
|
|
|
), |
|
187
|
|
|
'update_google_map_settings' => array( |
|
188
|
|
|
'func' => '_update_google_map_settings', |
|
189
|
|
|
'capability' => 'manage_options', |
|
190
|
|
|
'noheader' => TRUE |
|
191
|
|
|
), |
|
192
|
|
|
//venue category tab related |
|
193
|
|
|
'add_category' => array( |
|
194
|
|
|
'func' => '_category_details', |
|
195
|
|
|
'args' => array('add'), |
|
196
|
|
|
'capability' => 'ee_edit_venue_category' |
|
197
|
|
|
), |
|
198
|
|
|
'edit_category' => array( |
|
199
|
|
|
'func' => '_category_details', |
|
200
|
|
|
'args' => array('edit'), |
|
201
|
|
|
'capability' => 'ee_edit_venue_category' |
|
202
|
|
|
), |
|
203
|
|
|
'delete_categories' => array( |
|
204
|
|
|
'func' => '_delete_categories', |
|
205
|
|
|
'noheader' => TRUE, |
|
206
|
|
|
'capability' => 'ee_delete_venue_category' |
|
207
|
|
|
), |
|
208
|
|
|
|
|
209
|
|
|
'delete_category' => array( |
|
210
|
|
|
'func' => '_delete_categories', |
|
211
|
|
|
'noheader' => TRUE, |
|
212
|
|
|
'capability' => 'ee_delete_venue_category' |
|
213
|
|
|
), |
|
214
|
|
|
|
|
215
|
|
|
'insert_category' => array( |
|
216
|
|
|
'func' => '_insert_or_update_category', |
|
217
|
|
|
'args' => array('new_category' => TRUE), |
|
218
|
|
|
'noheader' => TRUE, |
|
219
|
|
|
'capability' => 'ee_edit_venue_category' |
|
220
|
|
|
), |
|
221
|
|
|
|
|
222
|
|
|
'update_category' => array( |
|
223
|
|
|
'func' => '_insert_or_update_category', |
|
224
|
|
|
'args' => array('new_category' => FALSE), |
|
225
|
|
|
'noheader' => TRUE, |
|
226
|
|
|
'capability' => 'ee_edit_venue_category' |
|
227
|
|
|
), |
|
228
|
|
|
'export_categories' => array( |
|
229
|
|
|
'func' => '_categories_export', |
|
230
|
|
|
'noheader' => TRUE, |
|
231
|
|
|
'capability' => 'export' |
|
232
|
|
|
), |
|
233
|
|
|
'import_categories' => array( |
|
234
|
|
|
'func' => '_import_categories', |
|
235
|
|
|
'capability' => 'import' |
|
236
|
|
|
), |
|
237
|
|
|
'category_list' => array( |
|
238
|
|
|
'func' => '_category_list_table', |
|
239
|
|
|
'capability' => 'ee_manage_venue_categories' |
|
240
|
|
|
) |
|
241
|
|
|
); |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
|
|
245
|
|
|
|
|
246
|
|
|
|
|
247
|
|
|
protected function _set_page_config() { |
|
248
|
|
|
$this->_page_config = array( |
|
249
|
|
|
'default' => array( |
|
250
|
|
|
'nav' => array( |
|
251
|
|
|
'label' => __('Overview', 'event_espresso'), |
|
252
|
|
|
'order' => 10 |
|
253
|
|
|
), |
|
254
|
|
|
'list_table' => 'Venues_Admin_List_Table', |
|
255
|
|
|
'help_tabs' => array( |
|
256
|
|
|
'venues_overview_help_tab' => array( |
|
257
|
|
|
'title' => __('Venues Overview', 'event_espresso'), |
|
258
|
|
|
'filename' => 'venues_overview' |
|
259
|
|
|
), |
|
260
|
|
|
'venues_overview_table_column_headings_help_tab' => array( |
|
261
|
|
|
'title' => __('Venues Overview Table Column Headings', 'event_espresso'), |
|
262
|
|
|
'filename' => 'venues_overview_table_column_headings' |
|
263
|
|
|
), |
|
264
|
|
|
'venues_overview_views_bulk_actions_search_help_tab' => array( |
|
265
|
|
|
'title' => __('Venues Overview Views & Bulk Actions & Search', 'event_espresso'), |
|
266
|
|
|
'filename' => 'venues_overview_views_bulk_actions_search' |
|
267
|
|
|
) |
|
268
|
|
|
), |
|
269
|
|
|
'help_tour' => array( 'Venues_Overview_Help_Tour' ), |
|
270
|
|
|
'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'), |
|
271
|
|
|
'require_nonce' => FALSE |
|
272
|
|
|
), |
|
273
|
|
|
'create_new' => array( |
|
274
|
|
|
'nav' => array( |
|
275
|
|
|
'label' => __('Add Venue', 'event_espresso'), |
|
276
|
|
|
'order' => 5, |
|
277
|
|
|
'persistent' => FALSE |
|
278
|
|
|
), |
|
279
|
|
|
'help_tabs' => array( |
|
280
|
|
|
'venues_editor_help_tab' => array( |
|
281
|
|
|
'title' => __('Venue Editor', 'event_espresso'), |
|
282
|
|
|
'filename' => 'venues_editor' |
|
283
|
|
|
), |
|
284
|
|
|
'venues_editor_title_richtexteditor_help_tab' => array( |
|
285
|
|
|
'title' => __('Venue Title & Rich Text Editor', 'event_espresso'), |
|
286
|
|
|
'filename' => 'venues_editor_title_richtexteditor' |
|
287
|
|
|
), |
|
288
|
|
|
'venues_editor_tags_categories_help_tab' => array( |
|
289
|
|
|
'title' => __('Venue Tags & Categories', 'event_espresso'), |
|
290
|
|
|
'filename' => 'venues_editor_tags_categories' |
|
291
|
|
|
), |
|
292
|
|
|
'venues_editor_physical_location_google_map_virtual_location_help_tab' => array( |
|
293
|
|
|
'title' => __('Venue Editor Physical Location & Google Map & Virtual Location', 'event_espresso'), |
|
294
|
|
|
'filename' => 'venues_editor_physical_location_google_map_virtual_location' |
|
295
|
|
|
), |
|
296
|
|
|
'venues_editor_save_new_venue_help_tab' => array( |
|
297
|
|
|
'title' => __('Save New Venue', 'event_espresso'), |
|
298
|
|
|
'filename' => 'venues_editor_save_new_venue' |
|
299
|
|
|
), |
|
300
|
|
|
'venues_editor_other_help_tab' => array( |
|
301
|
|
|
'title' => __('Venue Editor Other', 'event_espresso'), |
|
302
|
|
|
'filename' => 'venues_editor_other' |
|
303
|
|
|
) |
|
304
|
|
|
), |
|
305
|
|
|
'help_tour' => array( 'Venues_Add_Venue_Help_Tour' ), |
|
306
|
|
|
'metaboxes' => array('_venue_editor_metaboxes'), |
|
307
|
|
|
'require_nonce' => FALSE |
|
308
|
|
|
), |
|
309
|
|
|
'edit' => array( |
|
310
|
|
|
'nav' => array( |
|
311
|
|
|
'label' => __('Edit Venue', 'event_espresso'), |
|
312
|
|
|
'order' => 5, |
|
313
|
|
|
'persistent' => FALSE, |
|
314
|
|
|
'url' => isset($this->_req_data['post']) ? add_query_arg(array('post' => $this->_req_data['post'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
315
|
|
|
), |
|
316
|
|
|
'help_tabs' => array( |
|
317
|
|
|
'venues_editor_help_tab' => array( |
|
318
|
|
|
'title' => __('Venue Editor', 'event_espresso'), |
|
319
|
|
|
'filename' => 'venues_editor' |
|
320
|
|
|
), |
|
321
|
|
|
'venues_editor_title_richtexteditor_help_tab' => array( |
|
322
|
|
|
'title' => __('Venue Title & Rich Text Editor', 'event_espresso'), |
|
323
|
|
|
'filename' => 'venues_editor_title_richtexteditor' |
|
324
|
|
|
), |
|
325
|
|
|
'venues_editor_tags_categories_help_tab' => array( |
|
326
|
|
|
'title' => __('Venue Tags & Categories', 'event_espresso'), |
|
327
|
|
|
'filename' => 'venues_editor_tags_categories' |
|
328
|
|
|
), |
|
329
|
|
|
'venues_editor_physical_location_google_map_virtual_location_help_tab' => array( |
|
330
|
|
|
'title' => __('Venue Editor Physical Location & Google Map & Virtual Location', 'event_espresso'), |
|
331
|
|
|
'filename' => 'venues_editor_physical_location_google_map_virtual_location' |
|
332
|
|
|
), |
|
333
|
|
|
'venues_editor_save_new_venue_help_tab' => array( |
|
334
|
|
|
'title' => __('Save New Venue', 'event_espresso'), |
|
335
|
|
|
'filename' => 'venues_editor_save_new_venue' |
|
336
|
|
|
), |
|
337
|
|
|
'venues_editor_other_help_tab' => array( |
|
338
|
|
|
'title' => __('Venue Editor Other', 'event_espresso'), |
|
339
|
|
|
'filename' => 'venues_editor_other' |
|
340
|
|
|
) |
|
341
|
|
|
), |
|
342
|
|
|
'help_tour' => array( 'Venues_Edit_Venue_Help_Tour' ), |
|
343
|
|
|
'metaboxes' => array('_venue_editor_metaboxes'), |
|
344
|
|
|
'require_nonce' => FALSE |
|
345
|
|
|
), |
|
346
|
|
|
'google_map_settings' => array( |
|
347
|
|
|
'nav' => array( |
|
348
|
|
|
'label' => __('Google Maps'), |
|
349
|
|
|
'order' => 40 |
|
350
|
|
|
), |
|
351
|
|
|
'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
352
|
|
|
'help_tabs' => array( |
|
353
|
|
|
'general_settings_google_maps_help_tab' => array( |
|
354
|
|
|
'title' => __('Google Maps', 'event_espresso'), |
|
355
|
|
|
'filename' => 'general_settings_google_maps' |
|
356
|
|
|
) |
|
357
|
|
|
), |
|
358
|
|
|
'help_tour' => array( 'Google_Maps_Help_Tour' ), |
|
359
|
|
|
'require_nonce' => FALSE |
|
360
|
|
|
), |
|
361
|
|
|
//venue category stuff |
|
362
|
|
|
'add_category' => array( |
|
363
|
|
|
'nav' => array( |
|
364
|
|
|
'label' => __('Add Category', 'event_espresso'), |
|
365
|
|
|
'order' => 15, |
|
366
|
|
|
'persistent' => false), |
|
367
|
|
|
'metaboxes' => array('_publish_post_box'), |
|
368
|
|
|
'help_tabs' => array( |
|
369
|
|
|
'venues_add_category_help_tab' => array( |
|
370
|
|
|
'title' => __('Add New Venue Category', 'event_espresso'), |
|
371
|
|
|
'filename' => 'venues_add_category' |
|
372
|
|
|
) |
|
373
|
|
|
), |
|
374
|
|
|
'help_tour' => array( 'Venues_Add_Category_Help_Tour' ), |
|
375
|
|
|
'require_nonce' => FALSE |
|
376
|
|
|
), |
|
377
|
|
|
'edit_category' => array( |
|
378
|
|
|
'nav' => array( |
|
379
|
|
|
'label' => __('Edit Category', 'event_espresso'), |
|
380
|
|
|
'order' => 15, |
|
381
|
|
|
'persistent' => FALSE, |
|
382
|
|
|
'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
383
|
|
|
), |
|
384
|
|
|
'metaboxes' => array('_publish_post_box'), |
|
385
|
|
|
'help_tabs' => array( |
|
386
|
|
|
'venues_edit_category_help_tab' => array( |
|
387
|
|
|
'title' => __('Edit Venue Category', 'event_espresso'), |
|
388
|
|
|
'filename' => 'venues_edit_category' |
|
389
|
|
|
) |
|
390
|
|
|
), |
|
391
|
|
|
'help_tour' => array( 'Venues_Edit_Category_Help_Tour' ), |
|
392
|
|
|
'require_nonce' => FALSE |
|
393
|
|
|
), |
|
394
|
|
|
'category_list' => array( |
|
395
|
|
|
'nav' => array( |
|
396
|
|
|
'label' => __('Categories', 'event_espresso'), |
|
397
|
|
|
'order' => 20 |
|
398
|
|
|
), |
|
399
|
|
|
'list_table' => 'Venue_Categories_Admin_List_Table', |
|
400
|
|
|
'help_tabs' => array( |
|
401
|
|
|
'venues_categories_help_tab' => array( |
|
402
|
|
|
'title' => __('Venue Categories', 'event_espresso'), |
|
403
|
|
|
'filename' => 'venues_categories' |
|
404
|
|
|
), |
|
405
|
|
|
'venues_categories_table_column_headings_help_tab' => array( |
|
406
|
|
|
'title' => __('Venue Categories Table Column Headings', 'event_espresso'), |
|
407
|
|
|
'filename' => 'venues_categories_table_column_headings' |
|
408
|
|
|
), |
|
409
|
|
|
'venues_categories_views_help_tab' => array( |
|
410
|
|
|
'title' => __('Venue Categories Views', 'event_espresso'), |
|
411
|
|
|
'filename' => 'venues_categories_views' |
|
412
|
|
|
), |
|
413
|
|
|
'venues_categories_other_help_tab' => array( |
|
414
|
|
|
'title' => __('Venue Categories Other', 'event_espresso'), |
|
415
|
|
|
'filename' => 'venues_categories_other' |
|
416
|
|
|
) |
|
417
|
|
|
), |
|
418
|
|
|
'help_tour' => array( 'Venues_Categories_Help_Tour' ), |
|
419
|
|
|
'metaboxes' => $this->_default_espresso_metaboxes, |
|
420
|
|
|
'require_nonce' => FALSE |
|
421
|
|
|
) |
|
422
|
|
|
); |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
|
|
426
|
|
|
|
|
427
|
|
|
|
|
428
|
|
|
|
|
429
|
|
|
protected function _add_screen_options() { |
|
430
|
|
|
//todo |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
|
|
434
|
|
|
|
|
435
|
|
|
|
|
436
|
|
|
|
|
437
|
|
|
protected function _add_screen_options_default() { |
|
438
|
|
|
$this->_per_page_screen_option(); |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
|
|
|
|
442
|
|
|
|
|
443
|
|
View Code Duplication |
protected function _add_screen_options_category_list() { |
|
|
|
|
|
|
444
|
|
|
$page_title = $this->_admin_page_title; |
|
445
|
|
|
$this->_admin_page_title = __('Venue Categories', 'event_espresso'); |
|
446
|
|
|
$this->_per_page_screen_option(); |
|
447
|
|
|
$this->_admin_page_title = $page_title; |
|
448
|
|
|
} |
|
449
|
|
|
|
|
450
|
|
|
|
|
451
|
|
|
|
|
452
|
|
|
|
|
453
|
|
|
|
|
454
|
|
|
|
|
455
|
|
|
//none of the below group are currently used for Event Venues |
|
456
|
|
|
protected function _add_feature_pointers() {} |
|
457
|
|
|
public function admin_init() {} |
|
458
|
|
|
public function admin_notices() {} |
|
459
|
|
|
public function admin_footer_scripts() {} |
|
460
|
|
|
|
|
461
|
|
|
|
|
462
|
|
|
|
|
463
|
|
|
|
|
464
|
|
|
|
|
465
|
|
|
|
|
466
|
|
|
public function load_scripts_styles_create_new() { |
|
467
|
|
|
$this->load_scripts_styles_edit(); |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
|
|
471
|
|
|
|
|
472
|
|
|
|
|
473
|
|
|
|
|
474
|
|
|
public function load_scripts_styles() { |
|
475
|
|
|
wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
476
|
|
|
wp_enqueue_style('ee-cat-admin'); |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
|
|
|
|
480
|
|
|
|
|
481
|
|
|
public function load_scripts_styles_add_category() { |
|
482
|
|
|
$this->load_scripts_styles_edit_category(); |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
|
|
486
|
|
|
|
|
487
|
|
|
|
|
488
|
|
|
|
|
489
|
|
|
public function load_scripts_styles_edit_category() {} |
|
490
|
|
|
|
|
491
|
|
|
|
|
492
|
|
|
|
|
493
|
|
|
|
|
494
|
|
|
|
|
495
|
|
|
public function load_scripts_styles_edit() { |
|
496
|
|
|
//styles |
|
497
|
|
|
wp_enqueue_style('espresso-ui-theme'); |
|
498
|
|
|
wp_register_style( 'espresso_venues', EE_VENUES_ASSETS_URL . 'ee-venues-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
499
|
|
|
wp_enqueue_style('espresso_venues'); |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
|
|
503
|
|
|
|
|
504
|
|
|
|
|
505
|
|
|
|
|
506
|
|
|
|
|
507
|
|
|
protected function _set_list_table_views_default() { |
|
508
|
|
|
$this->_views = array( |
|
509
|
|
|
'all' => array( |
|
510
|
|
|
'slug' => 'all', |
|
511
|
|
|
'label' => __('View All Venues', 'event_espresso'), |
|
512
|
|
|
'count' => 0, |
|
513
|
|
|
'bulk_action' => array() |
|
514
|
|
|
) |
|
515
|
|
|
); |
|
516
|
|
|
|
|
517
|
|
|
if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_venues', 'espresso_venues_trash_venues' ) ) { |
|
518
|
|
|
$this->_views['all']['bulk_action'] = array( |
|
519
|
|
|
'trash_venues' => __('Move to Trash', 'event_espresso') |
|
520
|
|
|
); |
|
521
|
|
|
$this->_views['trash'] = array( |
|
522
|
|
|
'slug' => 'trash', |
|
523
|
|
|
'label' => __( 'Trash', 'event_espresso' ), |
|
524
|
|
|
'count' => 0, |
|
525
|
|
|
'bulk_action' => array( |
|
526
|
|
|
'restore_venues' => __('Restore from Trash', 'event_espresso'), |
|
527
|
|
|
'delete_venues' => __('Delete', 'event_espresso') |
|
528
|
|
|
) |
|
529
|
|
|
); |
|
530
|
|
|
} |
|
531
|
|
|
} |
|
532
|
|
|
|
|
533
|
|
|
|
|
534
|
|
|
|
|
535
|
|
|
|
|
536
|
|
|
|
|
537
|
|
View Code Duplication |
protected function _set_list_table_views_category_list() { |
|
|
|
|
|
|
538
|
|
|
$this->_views = array( |
|
539
|
|
|
'all' => array( |
|
540
|
|
|
'slug' => 'all', |
|
541
|
|
|
'label' => __('All', 'event_espresso'), |
|
542
|
|
|
'count' => 0, |
|
543
|
|
|
'bulk_action' => array( |
|
544
|
|
|
'delete_categories' => __('Delete Permanently', 'event_espresso'), |
|
545
|
|
|
// 'export_categories' => __('Export Categories', 'event_espresso'), |
|
546
|
|
|
) |
|
547
|
|
|
) |
|
548
|
|
|
); |
|
549
|
|
|
} |
|
550
|
|
|
|
|
551
|
|
|
|
|
552
|
|
|
|
|
553
|
|
|
|
|
554
|
|
|
|
|
555
|
|
|
protected function _overview_list_table() { |
|
556
|
|
|
do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
557
|
|
|
$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_venues'), __("View Venue Archive Page", "event_espresso"), 'button' ); |
|
558
|
|
|
$this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
|
559
|
|
|
$this->_search_btn_label = __('Venues', 'event_espresso'); |
|
560
|
|
|
$this->display_admin_list_table_page_with_sidebar(); |
|
561
|
|
|
} |
|
562
|
|
|
|
|
563
|
|
|
|
|
564
|
|
|
|
|
565
|
|
|
public function extra_misc_actions_publish_box() { |
|
566
|
|
|
$extra_rows = array( |
|
567
|
|
|
'vnu_capacity' => $this->_cpt_model_obj->get_pretty('VNU_capacity', 'input'), |
|
568
|
|
|
'vnu_url' => $this->_cpt_model_obj->venue_url(), |
|
|
|
|
|
|
569
|
|
|
'vnu_phone' => $this->_cpt_model_obj->phone() |
|
|
|
|
|
|
570
|
|
|
); |
|
571
|
|
|
$template = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php'; |
|
572
|
|
|
EEH_Template::display_template( $template, $extra_rows ); |
|
573
|
|
|
} |
|
574
|
|
|
|
|
575
|
|
|
|
|
576
|
|
|
|
|
577
|
|
|
/************* Google Maps *************/ |
|
578
|
|
|
|
|
579
|
|
|
|
|
580
|
|
|
protected function _google_map_settings() { |
|
581
|
|
|
|
|
582
|
|
|
|
|
583
|
|
|
$this->_template_args['values'] = $this->_yes_no_values; |
|
584
|
|
|
$default_map_settings = new stdClass(); |
|
585
|
|
|
$default_map_settings->use_google_maps = TRUE; |
|
586
|
|
|
// for event details pages (reg page) |
|
587
|
|
|
$default_map_settings->event_details_map_width = 585; // ee_map_width_single |
|
588
|
|
|
$default_map_settings->event_details_map_height = 362; // ee_map_height_single |
|
589
|
|
|
$default_map_settings->event_details_map_zoom = 14; // ee_map_zoom_single |
|
590
|
|
|
$default_map_settings->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
591
|
|
|
$default_map_settings->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
592
|
|
|
$default_map_settings->event_details_control_type = 'default'; // ee_map_type_control_single |
|
593
|
|
|
$default_map_settings->event_details_map_align = 'center'; // ee_map_align_single |
|
594
|
|
|
// for event list pages |
|
595
|
|
|
$default_map_settings->event_list_map_width = 300; // ee_map_width |
|
596
|
|
|
$default_map_settings->event_list_map_height = 185; // ee_map_height |
|
597
|
|
|
$default_map_settings->event_list_map_zoom = 12; // ee_map_zoom |
|
598
|
|
|
$default_map_settings->event_list_display_nav = FALSE; // ee_map_nav_display |
|
599
|
|
|
$default_map_settings->event_list_nav_size = TRUE; // ee_map_nav_size |
|
600
|
|
|
$default_map_settings->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
601
|
|
|
$default_map_settings->event_list_map_align = 'center'; // ee_map_align |
|
602
|
|
|
|
|
603
|
|
|
$this->_template_args['map_settings'] = |
|
604
|
|
|
isset( EE_Registry::instance()->CFG->map_settings ) && ! empty( EE_Registry::instance()->CFG->map_settings ) |
|
605
|
|
|
? (object)array_merge( (array)$default_map_settings, (array)EE_Registry::instance()->CFG->map_settings ) |
|
606
|
|
|
: $default_map_settings; |
|
607
|
|
|
|
|
608
|
|
|
$this->_set_add_edit_form_tags( 'update_google_map_settings' ); |
|
609
|
|
|
$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
610
|
|
|
$this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_VENUES_TEMPLATE_PATH . 'google_map.template.php', $this->_template_args, TRUE ); |
|
611
|
|
|
$this->display_admin_page_with_sidebar(); |
|
612
|
|
|
} |
|
613
|
|
|
|
|
614
|
|
|
protected function _update_google_map_settings() { |
|
615
|
|
|
|
|
616
|
|
|
EE_Registry::instance()->CFG->map_settings->use_google_maps = |
|
617
|
|
|
isset( $this->_req_data['use_google_maps'] ) |
|
618
|
|
|
? absint( $this->_req_data['use_google_maps'] ) |
|
619
|
|
|
: EE_Registry::instance()->CFG->map_settings->use_google_maps; |
|
620
|
|
|
|
|
621
|
|
|
EE_Registry::instance()->CFG->map_settings->event_details_map_width = |
|
622
|
|
|
isset( $this->_req_data['event_details_map_width'] ) |
|
623
|
|
|
? absint( $this->_req_data['event_details_map_width'] ) |
|
624
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_details_map_width; |
|
625
|
|
|
|
|
626
|
|
|
EE_Registry::instance()->CFG->map_settings->event_details_map_height = |
|
627
|
|
|
isset( $this->_req_data['event_details_map_height'] ) |
|
628
|
|
|
? absint( $this->_req_data['event_details_map_height'] ) |
|
629
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_details_map_height; |
|
630
|
|
|
|
|
631
|
|
|
EE_Registry::instance()->CFG->map_settings->event_details_map_zoom = |
|
632
|
|
|
isset( $this->_req_data['event_details_map_zoom'] ) |
|
633
|
|
|
? absint( $this->_req_data['event_details_map_zoom'] ) |
|
634
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_details_map_zoom; |
|
635
|
|
|
|
|
636
|
|
|
EE_Registry::instance()->CFG->map_settings->event_details_display_nav = |
|
637
|
|
|
isset( $this->_req_data['event_details_display_nav'] ) |
|
638
|
|
|
? absint( $this->_req_data['event_details_display_nav'] ) |
|
639
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_details_display_nav; |
|
640
|
|
|
|
|
641
|
|
|
EE_Registry::instance()->CFG->map_settings->event_details_nav_size = |
|
642
|
|
|
isset( $this->_req_data['event_details_nav_size'] ) |
|
643
|
|
|
? absint( $this->_req_data['event_details_nav_size'] ) |
|
644
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_details_nav_size; |
|
645
|
|
|
|
|
646
|
|
|
EE_Registry::instance()->CFG->map_settings->event_details_control_type = |
|
647
|
|
|
isset( $this->_req_data['event_details_control_type'] ) |
|
648
|
|
|
? sanitize_text_field( $this->_req_data['event_details_control_type'] ) |
|
649
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_details_control_type; |
|
650
|
|
|
|
|
651
|
|
|
EE_Registry::instance()->CFG->map_settings->event_details_map_align = |
|
652
|
|
|
isset( $this->_req_data['event_details_map_align'] ) |
|
653
|
|
|
? sanitize_text_field( $this->_req_data['event_details_map_align'] ) |
|
654
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_details_map_align; |
|
655
|
|
|
|
|
656
|
|
|
EE_Registry::instance()->CFG->map_settings->event_list_map_width = |
|
657
|
|
|
isset( $this->_req_data['event_list_map_width'] ) |
|
658
|
|
|
? absint( $this->_req_data['event_list_map_width'] ) |
|
659
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_list_map_width; |
|
660
|
|
|
|
|
661
|
|
|
EE_Registry::instance()->CFG->map_settings->event_list_map_height = |
|
662
|
|
|
isset( $this->_req_data['event_list_map_height'] ) |
|
663
|
|
|
? absint( $this->_req_data['event_list_map_height'] ) |
|
664
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_list_map_height; |
|
665
|
|
|
|
|
666
|
|
|
EE_Registry::instance()->CFG->map_settings->event_list_map_zoom = |
|
667
|
|
|
isset( $this->_req_data['event_list_map_zoom'] ) |
|
668
|
|
|
? absint( $this->_req_data['event_list_map_zoom'] ) |
|
669
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_list_map_zoom; |
|
670
|
|
|
|
|
671
|
|
|
EE_Registry::instance()->CFG->map_settings->event_list_display_nav = |
|
672
|
|
|
isset( $this->_req_data['event_list_display_nav'] ) |
|
673
|
|
|
? absint( $this->_req_data['event_list_display_nav'] ) |
|
674
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_list_display_nav; |
|
675
|
|
|
|
|
676
|
|
|
EE_Registry::instance()->CFG->map_settings->event_list_nav_size = |
|
677
|
|
|
isset( $this->_req_data['event_list_nav_size'] ) |
|
678
|
|
|
? absint( $this->_req_data['event_list_nav_size'] ) |
|
679
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_list_nav_size; |
|
680
|
|
|
|
|
681
|
|
|
EE_Registry::instance()->CFG->map_settings->event_list_control_type = |
|
682
|
|
|
isset( $this->_req_data['event_list_control_type'] ) |
|
683
|
|
|
? sanitize_text_field( $this->_req_data['event_list_control_type'] ) |
|
684
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_list_control_type; |
|
685
|
|
|
|
|
686
|
|
|
EE_Registry::instance()->CFG->map_settings->event_list_map_align = |
|
687
|
|
|
isset( $this->_req_data['event_list_map_align'] ) |
|
688
|
|
|
? sanitize_text_field( $this->_req_data['event_list_map_align'] ) |
|
689
|
|
|
: EE_Registry::instance()->CFG->map_settings->event_list_map_align; |
|
690
|
|
|
|
|
691
|
|
|
EE_Registry::instance()->CFG->map_settings = apply_filters( 'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings', EE_Registry::instance()->CFG->map_settings ); |
|
692
|
|
|
|
|
693
|
|
|
$what = 'Google Map Settings'; |
|
694
|
|
|
$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->map_settings, __FILE__, __FUNCTION__, __LINE__ ); |
|
695
|
|
|
$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'google_map_settings' ) ); |
|
|
|
|
|
|
696
|
|
|
|
|
697
|
|
|
} |
|
698
|
|
|
|
|
699
|
|
|
|
|
700
|
|
|
|
|
701
|
|
|
protected function _venue_editor_metaboxes() { |
|
702
|
|
|
$this->verify_cpt_object(); |
|
703
|
|
|
|
|
704
|
|
|
add_meta_box( 'espresso_venue_address_options', __('Physical Location', 'event_espresso'), array( $this, 'venue_address_metabox'), $this->page_slug, 'side', 'default' ); |
|
705
|
|
|
add_meta_box( 'espresso_venue_gmap_options', __('Google Map', 'event_espresso'), array( $this, 'venue_gmap_metabox'), $this->page_slug, 'side', 'default' ); |
|
706
|
|
|
add_meta_box( 'espresso_venue_virtual_loc_options', __('Virtual Location', 'event_espresso'), array( $this, 'venue_virtual_loc_metabox'), $this->page_slug, 'side', 'default' ); |
|
707
|
|
|
|
|
708
|
|
|
} |
|
709
|
|
|
|
|
710
|
|
|
|
|
711
|
|
|
|
|
712
|
|
|
public function venue_gmap_metabox() { |
|
713
|
|
|
$template_args = array( |
|
714
|
|
|
'vnu_enable_for_gmap' => EEH_Form_Fields::select_input('vnu_enable_for_gmap', $this->get_yes_no_values(), $this->_cpt_model_obj->enable_for_gmap() ), |
|
|
|
|
|
|
715
|
|
|
'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(), |
|
|
|
|
|
|
716
|
|
|
); |
|
717
|
|
|
$template = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php'; |
|
718
|
|
|
EEH_Template::display_template( $template, $template_args ); |
|
719
|
|
|
} |
|
720
|
|
|
|
|
721
|
|
|
|
|
722
|
|
|
|
|
723
|
|
|
public function venue_address_metabox() { |
|
724
|
|
|
|
|
725
|
|
|
$template_args['_venue'] =$this->_cpt_model_obj; |
|
|
|
|
|
|
726
|
|
|
|
|
727
|
|
|
$template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input( |
|
728
|
|
|
$QFI = new EE_Question_Form_Input( |
|
729
|
|
|
EE_Question::new_instance( array( 'QST_display_text' => 'State', 'QST_system' => 'state' )), |
|
730
|
|
|
EE_Answer::new_instance( array( 'ANS_value'=> $this->_cpt_model_obj->state_ID() )), |
|
|
|
|
|
|
731
|
|
|
array( |
|
732
|
|
|
'input_name' => 'sta_id', |
|
733
|
|
|
'input_id' => 'sta_id', |
|
734
|
|
|
'input_class' => '', |
|
735
|
|
|
'input_prefix' => '', |
|
736
|
|
|
'append_qstn_id' => FALSE |
|
737
|
|
|
) |
|
738
|
|
|
) |
|
739
|
|
|
); |
|
740
|
|
|
$template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input( |
|
741
|
|
|
$QFI = new EE_Question_Form_Input( |
|
742
|
|
|
EE_Question::new_instance( array( 'QST_display_text' => 'Country', 'QST_system' => 'country' )), |
|
743
|
|
|
EE_Answer::new_instance( array( 'ANS_value'=> $this->_cpt_model_obj->country_ID() )), |
|
|
|
|
|
|
744
|
|
|
array( |
|
745
|
|
|
'input_name' => 'cnt_iso', |
|
746
|
|
|
'input_id' => 'cnt_iso', |
|
747
|
|
|
'input_class' => '', |
|
748
|
|
|
'input_prefix' => '', |
|
749
|
|
|
'append_qstn_id' => FALSE |
|
750
|
|
|
) |
|
751
|
|
|
) |
|
752
|
|
|
); |
|
753
|
|
|
|
|
754
|
|
|
$template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php'; |
|
755
|
|
|
EEH_Template::display_template( $template, $template_args ); |
|
756
|
|
|
} |
|
757
|
|
|
|
|
758
|
|
|
|
|
759
|
|
|
|
|
760
|
|
|
|
|
761
|
|
|
|
|
762
|
|
|
|
|
763
|
|
|
public function venue_virtual_loc_metabox() { |
|
764
|
|
|
$template_args = array( |
|
765
|
|
|
'_venue' => $this->_cpt_model_obj |
|
766
|
|
|
); |
|
767
|
|
|
$template = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php'; |
|
768
|
|
|
EEH_Template::display_template( $template, $template_args ); |
|
769
|
|
|
} |
|
770
|
|
|
|
|
771
|
|
|
|
|
772
|
|
|
|
|
773
|
|
|
protected function _restore_cpt_item($post_id, $revision_id) { |
|
774
|
|
|
$venue_obj = $this->_venue_model->get_one_by_ID($post_id); |
|
775
|
|
|
|
|
776
|
|
|
//meta revision restore |
|
777
|
|
|
$venue_obj->restore_revision($revision_id); |
|
778
|
|
|
} |
|
779
|
|
|
|
|
780
|
|
|
|
|
781
|
|
|
|
|
782
|
|
|
|
|
783
|
|
|
|
|
784
|
|
|
|
|
785
|
|
|
/** |
|
786
|
|
|
* Handles updates for venue cpts |
|
787
|
|
|
* @param int $post_id ID of Venue CPT |
|
788
|
|
|
* @param object $post Post object (with "blessed" WP properties) |
|
789
|
|
|
* @return void |
|
790
|
|
|
*/ |
|
791
|
|
|
protected function _insert_update_cpt_item( $post_id, $post ) { |
|
792
|
|
|
|
|
793
|
|
|
if ( $post instanceof WP_Post && $post->post_type !== 'espresso_venues' ) { |
|
|
|
|
|
|
794
|
|
|
return;// get out we're not processing the saving of venues. |
|
795
|
|
|
} |
|
796
|
|
|
|
|
797
|
|
|
$wheres = array( $this->_venue_model->primary_key_name() => $post_id ); |
|
798
|
|
|
|
|
799
|
|
|
$venue_values = array( |
|
800
|
|
|
'VNU_address' => !empty( $this->_req_data['vnu_address'] ) ? $this->_req_data['vnu_address'] : NULL, |
|
801
|
|
|
'VNU_address2' => !empty( $this->_req_data['vnu_address2'] ) ? $this->_req_data['vnu_address2'] : NULL, |
|
802
|
|
|
'VNU_city' => !empty( $this->_req_data['vnu_city'] ) ? $this->_req_data['vnu_city'] : NULL, |
|
803
|
|
|
'STA_ID' => !empty( $this->_req_data['sta_id'] ) ? $this->_req_data['sta_id'] : NULL, |
|
804
|
|
|
'CNT_ISO' => !empty( $this->_req_data['cnt_iso'] ) ? $this->_req_data['cnt_iso'] : NULL, |
|
805
|
|
|
'VNU_zip' => !empty( $this->_req_data['vnu_zip'] ) ? $this->_req_data['vnu_zip'] : NULL, |
|
806
|
|
|
'VNU_phone' => !empty( $this->_req_data['vnu_phone'] ) ? $this->_req_data['vnu_phone'] : NULL, |
|
807
|
|
|
'VNU_capacity' => !empty( $this->_req_data['vnu_capacity'] ) ? str_replace( ',', '', $this->_req_data['vnu_capacity'] ) : EE_INF, |
|
808
|
|
|
'VNU_url' => !empty( $this->_req_data['vnu_url'] ) ? $this->_req_data['vnu_url'] : NULL, |
|
809
|
|
|
'VNU_virtual_phone' => !empty( $this->_req_data['vnu_virtual_phone'] ) ? $this->_req_data['vnu_virtual_phone'] : NULL, |
|
810
|
|
|
'VNU_virtual_url' => !empty( $this->_req_data['vnu_virtual_url'] ) ? $this->_req_data['vnu_virtual_url'] : NULL, |
|
811
|
|
|
'VNU_enable_for_gmap' => !empty( $this->_req_data['vnu_enable_for_gmap'] ) ? TRUE : FALSE, |
|
812
|
|
|
'VNU_google_map_link' => !empty( $this->_req_data['vnu_google_map_link'] ) ? $this->_req_data['vnu_google_map_link'] : NULL |
|
813
|
|
|
); |
|
814
|
|
|
|
|
815
|
|
|
//update venue |
|
816
|
|
|
$success = $this->_venue_model->update( $venue_values, array( $wheres ) ); |
|
817
|
|
|
|
|
818
|
|
|
//get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_model->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
819
|
|
|
$get_one_where = array( $this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
820
|
|
|
$venue = $this->_venue_model->get_one( array( $get_one_where ) ); |
|
821
|
|
|
|
|
822
|
|
|
//notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use. So this is just here for addons to more easily hook into venue saves. |
|
823
|
|
|
$venue_update_callbacks = apply_filters( 'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks', array() ); |
|
824
|
|
|
|
|
825
|
|
|
$att_success = TRUE; |
|
826
|
|
|
|
|
827
|
|
View Code Duplication |
foreach ( $venue_update_callbacks as $v_callback ) { |
|
828
|
|
|
$_succ = call_user_func_array( $v_callback, array( $venue, $this->_req_data ) ); |
|
829
|
|
|
$att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
830
|
|
|
} |
|
831
|
|
|
|
|
832
|
|
|
//any errors? |
|
833
|
|
|
if ( $success && !$att_success ) { |
|
834
|
|
|
EE_Error::add_error( __('Venue Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
835
|
|
|
} else if ( $success === FALSE ) { |
|
836
|
|
|
EE_Error::add_error( __('Venue Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
837
|
|
|
} |
|
838
|
|
|
} |
|
839
|
|
|
|
|
840
|
|
|
|
|
841
|
|
|
|
|
842
|
|
|
|
|
843
|
|
|
|
|
844
|
|
|
public function trash_cpt_item( $post_id ) { |
|
845
|
|
|
$this->_req_data['VNU_ID'] = $post_id; |
|
846
|
|
|
$this->_trash_or_restore_venue( 'trash', FALSE ); |
|
847
|
|
|
} |
|
848
|
|
|
|
|
849
|
|
|
|
|
850
|
|
|
|
|
851
|
|
|
|
|
852
|
|
|
|
|
853
|
|
|
|
|
854
|
|
|
public function restore_cpt_item( $post_id ) { |
|
855
|
|
|
$this->_req_data['VNU_ID'] = $post_id; |
|
856
|
|
|
$this->_trash_or_restore_venue( 'draft', FALSE ); |
|
857
|
|
|
} |
|
858
|
|
|
|
|
859
|
|
|
|
|
860
|
|
|
|
|
861
|
|
|
|
|
862
|
|
|
|
|
863
|
|
|
public function delete_cpt_item( $post_id ) { |
|
864
|
|
|
$this->_req_data['VNU_ID'] = $post_id; |
|
865
|
|
|
$this->_delete_venue( FALSE ); |
|
866
|
|
|
} |
|
867
|
|
|
|
|
868
|
|
|
|
|
869
|
|
|
|
|
870
|
|
|
|
|
871
|
|
|
|
|
872
|
|
|
|
|
873
|
|
|
public function get_venue_object() { |
|
874
|
|
|
return $this->_cpt_model_obj; |
|
875
|
|
|
} |
|
876
|
|
|
|
|
877
|
|
|
|
|
878
|
|
|
|
|
879
|
|
|
|
|
880
|
|
View Code Duplication |
protected function _trash_or_restore_venue( $venue_status = 'trash', $redirect_after = TRUE ) { |
|
|
|
|
|
|
881
|
|
|
$VNU_ID = isset( $this->_req_data['VNU_ID'] ) ? absint( $this->_req_data['VNU_ID'] ) : FALSE; |
|
882
|
|
|
|
|
883
|
|
|
//loop thru venues |
|
884
|
|
|
if ( $VNU_ID ) { |
|
885
|
|
|
//clean status |
|
886
|
|
|
$venue_status = sanitize_key( $venue_status ); |
|
887
|
|
|
// grab status |
|
888
|
|
|
if (!empty($venue_status)) { |
|
889
|
|
|
$success = $this->_change_venue_status($VNU_ID, $venue_status); |
|
890
|
|
|
} else { |
|
891
|
|
|
$success = FALSE; |
|
892
|
|
|
$msg = __('An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.', 'event_espresso'); |
|
893
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
894
|
|
|
} |
|
895
|
|
|
} else { |
|
896
|
|
|
$success = FALSE; |
|
897
|
|
|
$msg = __('An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.', 'event_espresso'); |
|
898
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
899
|
|
|
} |
|
900
|
|
|
$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
901
|
|
|
|
|
902
|
|
|
if ( $redirect_after ) |
|
903
|
|
|
$this->_redirect_after_action($success, 'Venue', $action, array('action' => 'default')); |
|
|
|
|
|
|
904
|
|
|
|
|
905
|
|
|
} |
|
906
|
|
|
|
|
907
|
|
|
|
|
908
|
|
|
|
|
909
|
|
|
|
|
910
|
|
|
|
|
911
|
|
View Code Duplication |
protected function _trash_or_restore_venues( $venue_status = 'trash' ) { |
|
|
|
|
|
|
912
|
|
|
// clean status |
|
913
|
|
|
$venue_status = sanitize_key($venue_status); |
|
914
|
|
|
// grab status |
|
915
|
|
|
if (!empty($venue_status)) { |
|
916
|
|
|
$success = TRUE; |
|
917
|
|
|
//determine the event id and set to array. |
|
918
|
|
|
$VNU_IDs = isset($this->_req_data['venue_id']) ? (array) $this->_req_data['venue_id'] : array(); |
|
919
|
|
|
// loop thru events |
|
920
|
|
|
foreach ($VNU_IDs as $VNU_ID) { |
|
921
|
|
|
if ($VNU_ID = absint($VNU_ID)) { |
|
922
|
|
|
$results = $this->_change_venue_status($VNU_ID, $venue_status); |
|
923
|
|
|
$success = $results !== FALSE ? $success : FALSE; |
|
924
|
|
|
} else { |
|
925
|
|
|
$msg = sprintf(__('An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.', 'event_espresso'), $VNU_ID); |
|
926
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
927
|
|
|
$success = FALSE; |
|
928
|
|
|
} |
|
929
|
|
|
} |
|
930
|
|
|
} else { |
|
931
|
|
|
$success = FALSE; |
|
932
|
|
|
$msg = __('An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.', 'event_espresso'); |
|
933
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
934
|
|
|
} |
|
935
|
|
|
// in order to force a pluralized result message we need to send back a success status greater than 1 |
|
936
|
|
|
$success = $success ? 2 : FALSE; |
|
937
|
|
|
$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
938
|
|
|
$this->_redirect_after_action($success, 'Venues', $action, array('action' => 'default')); |
|
939
|
|
|
} |
|
940
|
|
|
|
|
941
|
|
|
|
|
942
|
|
|
|
|
943
|
|
|
|
|
944
|
|
|
|
|
945
|
|
|
/** |
|
946
|
|
|
* _trash_or_restore_venues |
|
947
|
|
|
* |
|
948
|
|
|
* //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page. We should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method accepting a certain number of params. |
|
949
|
|
|
* |
|
950
|
|
|
* @access private |
|
951
|
|
|
* @param int $VNU_ID |
|
952
|
|
|
* @param string $venue_status |
|
953
|
|
|
* @return void |
|
954
|
|
|
*/ |
|
955
|
|
View Code Duplication |
private function _change_venue_status( $VNU_ID = 0, $venue_status = '' ) { |
|
|
|
|
|
|
956
|
|
|
// grab venue id |
|
957
|
|
|
if (! $VNU_ID) { |
|
958
|
|
|
$msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
|
959
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
960
|
|
|
return FALSE; |
|
961
|
|
|
} |
|
962
|
|
|
|
|
963
|
|
|
$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
|
|
|
|
|
964
|
|
|
|
|
965
|
|
|
// clean status |
|
966
|
|
|
$venue_status = sanitize_key($venue_status); |
|
967
|
|
|
// grab status |
|
968
|
|
|
if ( ! $venue_status ) { |
|
969
|
|
|
$msg = __('An error occurred. No Venue Status or an invalid Venue Status was received.', 'event_espresso'); |
|
970
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
971
|
|
|
return FALSE; |
|
972
|
|
|
} |
|
973
|
|
|
|
|
974
|
|
|
// was event trashed or restored ? |
|
975
|
|
|
switch ($venue_status) { |
|
976
|
|
|
case 'draft' : |
|
977
|
|
|
$action = 'restored from the trash'; |
|
978
|
|
|
$hook = 'AHEE_venue_restored_from_trash'; |
|
979
|
|
|
break; |
|
980
|
|
|
case 'trash' : |
|
981
|
|
|
$action = 'moved to the trash'; |
|
982
|
|
|
$hook = 'AHEE_venue_moved_to_trash'; |
|
983
|
|
|
break; |
|
984
|
|
|
default : |
|
985
|
|
|
$action = 'updated'; |
|
986
|
|
|
$hook = FALSE; |
|
987
|
|
|
} |
|
988
|
|
|
//use class to change status |
|
989
|
|
|
$this->_cpt_model_obj->set_status( $venue_status ); |
|
|
|
|
|
|
990
|
|
|
$success = $this->_cpt_model_obj->save(); |
|
991
|
|
|
|
|
992
|
|
|
if ($success === FALSE) { |
|
993
|
|
|
$msg = sprintf(__('An error occurred. The venue could not be %s.', 'event_espresso'), $action); |
|
994
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
995
|
|
|
return FALSE; |
|
996
|
|
|
} |
|
997
|
|
|
if ($hook) { |
|
|
|
|
|
|
998
|
|
|
do_action($hook); |
|
999
|
|
|
} |
|
1000
|
|
|
return TRUE; |
|
1001
|
|
|
} |
|
1002
|
|
|
|
|
1003
|
|
|
|
|
1004
|
|
|
/** |
|
1005
|
|
|
* @param bool $redirect_after |
|
1006
|
|
|
* @return void |
|
1007
|
|
|
*/ |
|
1008
|
|
|
protected function _delete_venue( $redirect_after = true ) { |
|
1009
|
|
|
//determine the venue id and set to array. |
|
1010
|
|
|
$VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : NULL; |
|
1011
|
|
|
$VNU_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $VNU_ID; |
|
1012
|
|
|
|
|
1013
|
|
|
|
|
1014
|
|
|
// loop thru venues |
|
1015
|
|
|
if ($VNU_ID) { |
|
1016
|
|
|
$success = $this->_delete_or_trash_venue( $VNU_ID ); |
|
1017
|
|
|
} else { |
|
1018
|
|
|
$success = FALSE; |
|
1019
|
|
|
$msg = __('An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.', 'event_espresso'); |
|
1020
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1021
|
|
|
} |
|
1022
|
|
|
if ( $redirect_after ) |
|
1023
|
|
|
$this->_redirect_after_action($success, 'Venue', 'deleted', array('action' => 'default')); |
|
|
|
|
|
|
1024
|
|
|
} |
|
1025
|
|
|
|
|
1026
|
|
|
|
|
1027
|
|
|
|
|
1028
|
|
|
protected function _delete_venues() { |
|
1029
|
|
|
$success = TRUE; |
|
1030
|
|
|
//determine the event id and set to array. |
|
1031
|
|
|
$VNU_IDs = isset($this->_req_data['venue_id']) ? (array) $this->_req_data['venue_id'] : array(); |
|
1032
|
|
|
// loop thru events |
|
1033
|
|
|
foreach ($VNU_IDs as $VNU_ID) { |
|
1034
|
|
|
if ($VNU_ID = absint($VNU_ID)) { |
|
1035
|
|
|
$results = $this->_delete_or_trash_venue($VNU_ID); |
|
1036
|
|
|
$success = $results !== FALSE ? $success : FALSE; |
|
1037
|
|
|
} else { |
|
1038
|
|
|
$success = FALSE; |
|
1039
|
|
|
$msg = __('An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.', 'event_espresso'); |
|
1040
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1041
|
|
|
} |
|
1042
|
|
|
} |
|
1043
|
|
|
// in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1044
|
|
|
$success = $success ? 2 : FALSE; |
|
1045
|
|
|
$this->_redirect_after_action($success, __('Venues', 'event_espresso'), __('deleted', 'event_espresso'), array('action' => 'default')); |
|
1046
|
|
|
} |
|
1047
|
|
|
|
|
1048
|
|
|
|
|
1049
|
|
|
|
|
1050
|
|
|
|
|
1051
|
|
|
//todo: put in parent |
|
1052
|
|
|
private function _delete_or_trash_venue($VNU_ID = FALSE) { |
|
1053
|
|
|
// grab event id |
|
1054
|
|
|
if (!$VNU_ID = absint($VNU_ID)) { |
|
1055
|
|
|
$msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
|
1056
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1057
|
|
|
return FALSE; |
|
1058
|
|
|
} |
|
1059
|
|
|
|
|
1060
|
|
|
|
|
1061
|
|
|
$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
1062
|
|
|
//first need to remove all term relationships |
|
1063
|
|
|
$venue->_remove_relations('Term_Taxonomy'); |
|
1064
|
|
|
$success = $venue->delete_permanently(); |
|
1065
|
|
|
// did it all go as planned ? |
|
1066
|
|
|
if ($success) { |
|
1067
|
|
|
$msg = sprintf(__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID); |
|
1068
|
|
|
EE_Error::add_success($msg); |
|
1069
|
|
|
} else { |
|
1070
|
|
|
$msg = sprintf(__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'), $VNU_ID); |
|
1071
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1072
|
|
|
return FALSE; |
|
1073
|
|
|
} |
|
1074
|
|
|
do_action( 'AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted' ); |
|
1075
|
|
|
return TRUE; |
|
1076
|
|
|
} |
|
1077
|
|
|
|
|
1078
|
|
|
|
|
1079
|
|
|
|
|
1080
|
|
|
|
|
1081
|
|
|
/***********/ |
|
1082
|
|
|
/* QUERIES */ |
|
1083
|
|
|
|
|
1084
|
|
|
|
|
1085
|
|
|
public function get_venues( $per_page = 10, $count = FALSE ) { |
|
1086
|
|
|
|
|
1087
|
|
|
$_orderby = !empty( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : ''; |
|
1088
|
|
|
|
|
1089
|
|
|
switch ( $_orderby ) { |
|
1090
|
|
|
case 'id': |
|
1091
|
|
|
$orderby = 'VNU_ID'; |
|
1092
|
|
|
break; |
|
1093
|
|
|
|
|
1094
|
|
|
case 'capacity': |
|
1095
|
|
|
$orderby = 'VNU_capacity'; |
|
1096
|
|
|
break; |
|
1097
|
|
|
|
|
1098
|
|
|
case 'city': |
|
1099
|
|
|
$orderby = 'VNU_city'; |
|
1100
|
|
|
break; |
|
1101
|
|
|
|
|
1102
|
|
|
default: |
|
1103
|
|
|
$orderby = 'VNU_name'; |
|
1104
|
|
|
} |
|
1105
|
|
|
|
|
1106
|
|
|
|
|
1107
|
|
|
$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
1108
|
|
|
|
|
1109
|
|
|
$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1110
|
|
|
$per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
|
1111
|
|
|
$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1112
|
|
|
|
|
1113
|
|
|
|
|
1114
|
|
|
$offset = ($current_page-1)*$per_page; |
|
1115
|
|
|
$limit = array($offset, $per_page); |
|
1116
|
|
|
|
|
1117
|
|
|
$category = isset( $this->_req_data['category'] ) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL; |
|
1118
|
|
|
$where = array(); |
|
1119
|
|
|
|
|
1120
|
|
|
//only set initial status if it is in the incoming request. Otherwise the "all" view display's all statuses. |
|
1121
|
|
|
if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] != 'all' ) { |
|
1122
|
|
|
$where['status'] = $this->_req_data['status']; |
|
1123
|
|
|
} |
|
1124
|
|
|
|
|
1125
|
|
|
if ( isset( $this->_req_data['venue_status'] ) ) { |
|
1126
|
|
|
$where['status'] = $this->_req_data['venue_status']; |
|
1127
|
|
|
} |
|
1128
|
|
|
|
|
1129
|
|
|
|
|
1130
|
|
|
if ( $category ) { |
|
1131
|
|
|
$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories'; |
|
1132
|
|
|
$where['Term_Taxonomy.term_id'] = $category; |
|
1133
|
|
|
} |
|
1134
|
|
|
|
|
1135
|
|
|
|
|
1136
|
|
View Code Duplication |
if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_venues', 'get_venues' ) ) { |
|
1137
|
|
|
$where['VNU_wp_user'] = get_current_user_id(); |
|
1138
|
|
|
} else { |
|
1139
|
|
|
if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' ) ) { |
|
1140
|
|
|
$where['OR'] = array( |
|
1141
|
|
|
'status*restrict_private' => array( '!=', 'private' ), |
|
1142
|
|
|
'AND' => array( |
|
1143
|
|
|
'status*inclusive' => array( '=', 'private' ), |
|
1144
|
|
|
'VNU_wp_user' => get_current_user_id() |
|
1145
|
|
|
) |
|
1146
|
|
|
); |
|
1147
|
|
|
} |
|
1148
|
|
|
} |
|
1149
|
|
|
|
|
1150
|
|
|
|
|
1151
|
|
|
|
|
1152
|
|
|
|
|
1153
|
|
|
if ( isset( $this->_req_data['s'] ) ) { |
|
1154
|
|
|
$sstr = '%' . $this->_req_data['s'] . '%'; |
|
1155
|
|
|
$where['OR'] = array( |
|
1156
|
|
|
'VNU_name' => array('LIKE',$sstr ), |
|
1157
|
|
|
'VNU_desc' => array('LIKE',$sstr ), |
|
1158
|
|
|
'VNU_short_desc' => array( 'LIKE',$sstr ), |
|
1159
|
|
|
'VNU_address' => array( 'LIKE', $sstr ), |
|
1160
|
|
|
'VNU_address2' => array( 'LIKE', $sstr ), |
|
1161
|
|
|
'VNU_city' => array( 'LIKE', $sstr ), |
|
1162
|
|
|
'VNU_zip' => array( 'LIKE', $sstr ), |
|
1163
|
|
|
'VNU_phone' => array( 'LIKE', $sstr ), |
|
1164
|
|
|
'VNU_url' => array( 'LIKE', $sstr ), |
|
1165
|
|
|
'VNU_virtual_phone' => array( 'LIKE', $sstr ), |
|
1166
|
|
|
'VNU_virtual_url' => array( 'LIKE', $sstr ), |
|
1167
|
|
|
'VNU_google_map_link' => array( 'LIKE', $sstr ), |
|
1168
|
|
|
'Event.EVT_name' => array('LIKE', $sstr ), |
|
1169
|
|
|
'Event.EVT_desc' => array('LIKE', $sstr ), |
|
1170
|
|
|
'Event.EVT_phone' => array('LIKE', $sstr ), |
|
1171
|
|
|
'Event.EVT_external_URL' => array('LIKE', $sstr ), |
|
1172
|
|
|
); |
|
1173
|
|
|
} |
|
1174
|
|
|
|
|
1175
|
|
|
|
|
1176
|
|
|
$venues = $count ? $this->_venue_model->count( array($where), 'VNU_ID' ) : $this->_venue_model->get_all( array( $where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort ) ); |
|
1177
|
|
|
|
|
1178
|
|
|
return $venues; |
|
1179
|
|
|
|
|
1180
|
|
|
} |
|
1181
|
|
|
|
|
1182
|
|
|
|
|
1183
|
|
|
|
|
1184
|
|
|
|
|
1185
|
|
|
/** Venue Category Stuff **/ |
|
1186
|
|
|
|
|
1187
|
|
|
/** |
|
1188
|
|
|
* set the _category property with the category object for the loaded page. |
|
1189
|
|
|
* |
|
1190
|
|
|
* @access private |
|
1191
|
|
|
* @return void |
|
1192
|
|
|
*/ |
|
1193
|
|
View Code Duplication |
private function _set_category_object() { |
|
|
|
|
|
|
1194
|
|
|
if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
1195
|
|
|
return; //already have the category object so get out. |
|
1196
|
|
|
|
|
1197
|
|
|
//set default category object |
|
1198
|
|
|
$this->_set_empty_category_object(); |
|
1199
|
|
|
|
|
1200
|
|
|
//only set if we've got an id |
|
1201
|
|
|
if ( !isset($this->_req_data['VEN_CAT_ID'] ) ) { |
|
1202
|
|
|
return; |
|
1203
|
|
|
} |
|
1204
|
|
|
|
|
1205
|
|
|
$category_id = absint($this->_req_data['VEN_CAT_ID']); |
|
1206
|
|
|
$term = get_term( $category_id, 'espresso_venue_categories' ); |
|
1207
|
|
|
|
|
1208
|
|
|
|
|
1209
|
|
|
if ( !empty( $term ) ) { |
|
1210
|
|
|
$this->_category->category_name = $term->name; |
|
1211
|
|
|
$this->_category->category_identifier = $term->slug; |
|
1212
|
|
|
$this->_category->category_desc = $term->description; |
|
1213
|
|
|
$this->_category->id = $term->term_id; |
|
1214
|
|
|
$this->_category->parent = $term->parent; |
|
1215
|
|
|
} |
|
1216
|
|
|
} |
|
1217
|
|
|
|
|
1218
|
|
|
|
|
1219
|
|
|
|
|
1220
|
|
|
|
|
1221
|
|
|
private function _set_empty_category_object() { |
|
1222
|
|
|
$this->_category = new stdClass(); |
|
1223
|
|
|
$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
1224
|
|
|
$this->_category->id = $this->_category->parent = 0; |
|
1225
|
|
|
} |
|
1226
|
|
|
|
|
1227
|
|
|
|
|
1228
|
|
|
|
|
1229
|
|
View Code Duplication |
protected function _category_list_table() { |
|
|
|
|
|
|
1230
|
|
|
do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1231
|
|
|
$this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
|
1232
|
|
|
$this->_search_btn_label = __('Venue Categories', 'event_espresso'); |
|
1233
|
|
|
$this->display_admin_list_table_page_with_sidebar(); |
|
1234
|
|
|
} |
|
1235
|
|
|
|
|
1236
|
|
|
|
|
1237
|
|
View Code Duplication |
protected function _category_details($view) { |
|
|
|
|
|
|
1238
|
|
|
|
|
1239
|
|
|
//load formatter helper |
|
1240
|
|
|
EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1241
|
|
|
//load field generator helper |
|
1242
|
|
|
EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
1243
|
|
|
|
|
1244
|
|
|
$route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
1245
|
|
|
$this->_set_add_edit_form_tags($route); |
|
1246
|
|
|
|
|
1247
|
|
|
$this->_set_category_object(); |
|
1248
|
|
|
$id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
1249
|
|
|
|
|
1250
|
|
|
$delete_action = 'delete_category'; |
|
1251
|
|
|
|
|
1252
|
|
|
$redirect = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'category_list' ), $this->_admin_base_url ); |
|
1253
|
|
|
|
|
1254
|
|
|
$this->_set_publish_post_box_vars( 'VEN_CAT_ID', $id, $delete_action, $redirect ); |
|
1255
|
|
|
|
|
1256
|
|
|
//take care of contents |
|
1257
|
|
|
$this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
1258
|
|
|
$this->display_admin_page_with_sidebar(); |
|
1259
|
|
|
} |
|
1260
|
|
|
|
|
1261
|
|
|
|
|
1262
|
|
|
|
|
1263
|
|
View Code Duplication |
protected function _category_details_content() { |
|
|
|
|
|
|
1264
|
|
|
$editor_args['category_desc'] = array( |
|
|
|
|
|
|
1265
|
|
|
'type' => 'wp_editor', |
|
1266
|
|
|
'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
1267
|
|
|
'class' => 'my_editor_custom', |
|
1268
|
|
|
'wpeditor_args' => array( 'media_buttons' => FALSE ) |
|
1269
|
|
|
); |
|
1270
|
|
|
$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
1271
|
|
|
|
|
1272
|
|
|
$all_terms = get_terms( array('espresso_venue_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
1273
|
|
|
|
|
1274
|
|
|
//setup category select for term parents. |
|
1275
|
|
|
$category_select_values[] = array( |
|
|
|
|
|
|
1276
|
|
|
'text' => __('No Parent', 'event_espresso'), |
|
1277
|
|
|
'id' => 0 |
|
1278
|
|
|
); |
|
1279
|
|
|
foreach ( $all_terms as $term ) { |
|
1280
|
|
|
$category_select_values[] = array( |
|
1281
|
|
|
'text' => $term->name, |
|
1282
|
|
|
'id' => $term->term_id |
|
1283
|
|
|
); |
|
1284
|
|
|
} |
|
1285
|
|
|
|
|
1286
|
|
|
$category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
1287
|
|
|
$template_args = array( |
|
1288
|
|
|
'category' => $this->_category, |
|
1289
|
|
|
'category_select' => $category_select, |
|
1290
|
|
|
'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
1291
|
|
|
'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
1292
|
|
|
'disable' => '', |
|
1293
|
|
|
'disabled_message' =>FALSE |
|
1294
|
|
|
); |
|
1295
|
|
|
$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
1296
|
|
|
return EEH_Template::display_template($template, $template_args, TRUE ); |
|
1297
|
|
|
} |
|
1298
|
|
|
|
|
1299
|
|
|
|
|
1300
|
|
View Code Duplication |
protected function _delete_categories() { |
|
|
|
|
|
|
1301
|
|
|
$cat_ids = isset( $this->_req_data['VEN_CAT_ID'] ) ? (array) $this->_req_data['VEN_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
1302
|
|
|
|
|
1303
|
|
|
foreach ( $cat_ids as $cat_id ) { |
|
1304
|
|
|
$this->_delete_category($cat_id); |
|
1305
|
|
|
} |
|
1306
|
|
|
|
|
1307
|
|
|
//doesn't matter what page we're coming from... we're going to the same place after delete. |
|
1308
|
|
|
$query_args = array( |
|
1309
|
|
|
'action' => 'category_list' |
|
1310
|
|
|
); |
|
1311
|
|
|
$this->_redirect_after_action(0,'','',$query_args); |
|
1312
|
|
|
|
|
1313
|
|
|
} |
|
1314
|
|
|
|
|
1315
|
|
|
|
|
1316
|
|
|
|
|
1317
|
|
|
|
|
1318
|
|
|
|
|
1319
|
|
|
protected function _delete_category($cat_id) { |
|
1320
|
|
|
$cat_id = absint( $cat_id ); |
|
1321
|
|
|
wp_delete_term( $cat_id, 'espresso_venue_categories' ); |
|
1322
|
|
|
} |
|
1323
|
|
|
|
|
1324
|
|
|
|
|
1325
|
|
|
|
|
1326
|
|
View Code Duplication |
protected function _insert_or_update_category($new_category) { |
|
|
|
|
|
|
1327
|
|
|
|
|
1328
|
|
|
$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
1329
|
|
|
$success = 0; //we already have a success message so lets not send another. |
|
1330
|
|
|
if ( $cat_id ) { |
|
1331
|
|
|
$query_args = array( |
|
1332
|
|
|
'action' => 'edit_category', |
|
1333
|
|
|
'VEN_CAT_ID' => $cat_id |
|
1334
|
|
|
); |
|
1335
|
|
|
} else { |
|
1336
|
|
|
$query_args = array( 'action' => 'add_category' ); |
|
1337
|
|
|
} |
|
1338
|
|
|
$this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
1339
|
|
|
|
|
1340
|
|
|
} |
|
1341
|
|
|
|
|
1342
|
|
|
|
|
1343
|
|
|
|
|
1344
|
|
|
private function _insert_category( $update = FALSE ) { |
|
1345
|
|
|
$cat_id = $update ? $this->_req_data['VEN_CAT_ID'] : ''; |
|
1346
|
|
|
$category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
1347
|
|
|
$category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
1348
|
|
|
$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
1349
|
|
|
|
|
1350
|
|
|
if ( empty( $category_name ) ) { |
|
1351
|
|
|
$msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
1352
|
|
|
EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1353
|
|
|
return false; |
|
1354
|
|
|
} |
|
1355
|
|
|
|
|
1356
|
|
|
|
|
1357
|
|
|
$term_args=array( |
|
1358
|
|
|
'name'=>$category_name, |
|
1359
|
|
|
'description'=>$category_desc, |
|
1360
|
|
|
'parent'=>$category_parent |
|
1361
|
|
|
); |
|
1362
|
|
|
|
|
1363
|
|
|
$insert_ids = $update ? wp_update_term( $cat_id, 'espresso_venue_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_venue_categories', $term_args ); |
|
1364
|
|
|
|
|
1365
|
|
View Code Duplication |
if ( !is_array( $insert_ids ) ) { |
|
1366
|
|
|
$msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
1367
|
|
|
EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1368
|
|
|
} else { |
|
1369
|
|
|
$cat_id = $insert_ids['term_id']; |
|
1370
|
|
|
$msg = sprintf ( __('The category %s was successfuly created', 'event_espresso'), $category_name ); |
|
1371
|
|
|
EE_Error::add_success( $msg ); |
|
1372
|
|
|
} |
|
1373
|
|
|
|
|
1374
|
|
|
return $cat_id; |
|
1375
|
|
|
} |
|
1376
|
|
|
|
|
1377
|
|
|
|
|
1378
|
|
|
/** |
|
1379
|
|
|
* TODO handle category exports() |
|
1380
|
|
|
* @return file export |
|
1381
|
|
|
*/ |
|
1382
|
|
View Code Duplication |
protected function _categories_export() { |
|
|
|
|
|
|
1383
|
|
|
|
|
1384
|
|
|
//todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
1385
|
|
|
$new_request_args = array( |
|
1386
|
|
|
'export' => 'report', |
|
1387
|
|
|
'action' => 'categories', |
|
1388
|
|
|
'category_ids' => $this->_req_data['VEN_CAT_ID'] |
|
1389
|
|
|
); |
|
1390
|
|
|
|
|
1391
|
|
|
$this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
1392
|
|
|
|
|
1393
|
|
|
EE_Registry::instance()->load_helper( 'File' ); |
|
1394
|
|
|
if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) { |
|
1395
|
|
|
require_once( EE_CLASSES . 'EE_Export.class.php'); |
|
1396
|
|
|
$EE_Export = EE_Export::instance( $this->_req_data ); |
|
1397
|
|
|
$EE_Export->export(); |
|
1398
|
|
|
} |
|
1399
|
|
|
|
|
1400
|
|
|
} |
|
1401
|
|
|
|
|
1402
|
|
|
|
|
1403
|
|
|
|
|
1404
|
|
|
|
|
1405
|
|
|
|
|
1406
|
|
|
protected function _import_categories() { |
|
1407
|
|
|
|
|
1408
|
|
|
require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
1409
|
|
|
EE_Import::instance()->import(); |
|
1410
|
|
|
|
|
1411
|
|
|
} |
|
1412
|
|
|
|
|
1413
|
|
|
|
|
1414
|
|
|
|
|
1415
|
|
|
|
|
1416
|
|
View Code Duplication |
public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
|
|
|
|
|
1417
|
|
|
|
|
1418
|
|
|
//testing term stuff |
|
1419
|
|
|
$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
1420
|
|
|
$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
1421
|
|
|
$limit = ($current_page-1)*$per_page; |
|
1422
|
|
|
$where = array( 'taxonomy' => 'espresso_venue_categories' ); |
|
1423
|
|
|
if ( isset( $this->_req_data['s'] ) ) { |
|
1424
|
|
|
$sstr = '%' . $this->_req_data['s'] . '%'; |
|
1425
|
|
|
$where['OR'] = array( |
|
1426
|
|
|
'Term.name' => array( 'LIKE', $sstr), |
|
1427
|
|
|
'description' => array( 'LIKE', $sstr ) |
|
1428
|
|
|
); |
|
1429
|
|
|
} |
|
1430
|
|
|
|
|
1431
|
|
|
$query_params = array( |
|
1432
|
|
|
$where, |
|
1433
|
|
|
'order_by' => array( $orderby => $order ), |
|
1434
|
|
|
'limit' => $limit . ',' . $per_page, |
|
1435
|
|
|
'force_join' => array('Term') |
|
1436
|
|
|
); |
|
1437
|
|
|
|
|
1438
|
|
|
$categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
1439
|
|
|
|
|
1440
|
|
|
return $categories; |
|
1441
|
|
|
} |
|
1442
|
|
|
|
|
1443
|
|
|
|
|
1444
|
|
|
/* end category stuff */ |
|
1445
|
|
|
/**************/ |
|
1446
|
|
|
|
|
1447
|
|
|
|
|
1448
|
|
|
|
|
1449
|
|
|
} //end Venues_Admin_Page class |
|
1450
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..