| | |
| | | <?php |
| | | namespace JVBase\managers; |
| | | |
| | | use JVBase\forms\TaxonomySelector; |
| | | use JetBrains\PhpStorm\NoReturn;use JVBase\forms\TaxonomySelector; |
| | | use JVBase\base\Site; |
| | | use JVBase\meta\Form; |
| | | use JVBase\registrar\Registrar; |
| | |
| | | /** |
| | | * Redirect all non-admin users from wp-admin to custom dashboard |
| | | */ |
| | | public function redirectFromAdmin() |
| | | public function redirectFromAdmin():void |
| | | { |
| | | // Skip if already processing a redirect |
| | | if (defined('DOING_AJAX') && DOING_AJAX) { |
| | |
| | | } |
| | | } |
| | | |
| | | protected function redirectToLogin():void |
| | | #[NoReturn]protected function redirectToLogin():void |
| | | { |
| | | wp_redirect(wp_login_url(get_home_url(null, '/dash'))); |
| | | exit; |
| | | } |
| | | |
| | | protected function redirectToDashboard():void |
| | | #[NoReturn]protected function redirectToDashboard():void |
| | | { |
| | | wp_redirect(get_home_url(null, '/dash')); |
| | | exit; |
| | |
| | | if (!is_404() && !is_user_logged_in()) { |
| | | error_log('Redirecting to login - user not logged in'); |
| | | $this->redirectToLogin(); |
| | | return; |
| | | } |
| | | |
| | | // If logged in but doesn't have dashboard access, redirect to home |
| | |
| | | if (is_404() && (str_starts_with($wp->request, 'dash/') || $wp->request === 'dash')) { |
| | | error_log('404 on dashboard URL, redirecting to dashboard home'); |
| | | $this->redirectToDashboard(); |
| | | return; |
| | | } |
| | | |
| | | // For valid dashboard pages, check access permissions |
| | |
| | | $this->renderHeader(); |
| | | // Pass to page handler |
| | | $constantSlug = $this->getConstantSlug($page); |
| | | |
| | | echo apply_filters( |
| | | 'jvbDashboardPage', |
| | | $this->renderPage($page), |
| | |
| | | jvbRenderSections($this->userLink, 'post', $type); |
| | | } |
| | | |
| | | protected function renderSettings():void |
| | | { |
| | | wp_enqueue_script('jvb-form'); |
| | | wp_enqueue_script( |
| | | 'jvb-bio-manager', |
| | | JVB_URL.'assets/js/min/bioManager.min.js', |
| | | array('jvb-client-queue', 'sortablejs', 'quill-js', 'jvb-taxonomy-selector'), |
| | | '1.0.0', |
| | | true |
| | | ); |
| | | wp_localize_script('jvb-bio-manager', 'bioSettings', [ |
| | | 'type' => 'user_settings', |
| | | ]); |
| | | $content = apply_filters('jvbDashboardSettings', ''); |
| | | if ($content !== '') { |
| | | echo $content; |
| | | } else { |
| | | jvbRenderSections($this->user->ID, 'user', jvbUserRole()); |
| | | } |
| | | |
| | | } |
| | | |
| | | protected function getIntegrationsMenu():string |
| | | { |
| | | $integrations = JVB()->getAvailableServices(false); |