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