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