| | |
| | | if ($page === '' || $page === 'dash') { |
| | | return; |
| | | } |
| | | |
| | | $page = $this->getCurrentPageTitle(); |
| | | // Check if page exists in allowed pages |
| | | $allowedPages = $this->getUserAllowedPages(); |
| | | if (!array_key_exists($page, $allowedPages)) { |
| | | if (!in_array($page, $allowedPages)) { |
| | | error_log("User not allowed to access page: {$page}"); |
| | | $this->redirectToDashboard(); |
| | | return; |
| | |
| | | if ($page === 'dash') { |
| | | continue; |
| | | } |
| | | $slug = $this->getSlug($slug, $page); |
| | | $existing = get_page_by_path($slug, OBJECT, BASE.'dash'); |
| | | if ($existing) { |
| | | continue; |
| | | } |
| | | $title = $page; |
| | | |
| | | $slug = $this->getSlug($slug, $page); |
| | | |
| | | $ID = wp_insert_post(array( |
| | | 'post_title' => $title, |
| | | 'post_name' => $slug, |
| | |
| | | return; |
| | | } |
| | | |
| | | wp_enqueue_script('jvb-loading'); |
| | | wp_enqueue_script('jvb-form'); |
| | | |
| | | // Consolidate all dashboard settings |
| | | wp_localize_script('jvb-loading', 'dashboardSettings', array( |
| | | 'loadingMessages' => array( |
| | | 'default' => 'Loading...', |
| | | 'error' => 'Failed to load page' |
| | | ), |
| | | 'strings' => array( |
| | | 'deleteConfirm' => 'Are you sure you want to delete this item?', |
| | | 'bulkDeleteConfirm' => 'Are you sure you want to delete these items?', |
| | | 'deleteSuccess' => 'Item(s) deleted successfully', |
| | | 'deleteError' => 'Error deleting item(s)', |
| | | 'saveSuccess' => 'Changes saved successfully', |
| | | 'saveError' => 'Error saving changes', |
| | | 'loadError' => 'Error loading content' |
| | | ), |
| | | 'currentUser' => array( |
| | | 'id' => $this->user->ID, |
| | | 'name' => $this->user->display_name, |
| | | 'role' => array_values($this->user->roles)[0] ?? '', |
| | | 'type' => str_replace(BASE, '', array_values($this->user->roles)[0]), |
| | | 'city' => '', // Add if needed, |
| | | 'artistID' => $this->userLink, |
| | | ) |
| | | )); |
| | | |
| | | wp_enqueue_script('jvb-selector'); |
| | | wp_enqueue_script('jvb-uploader'); |
| | | wp_enqueue_script('jvb-content'); |