From 4089ba01e0881c89a72332e13bc3a80b6bddec2a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 29 Jun 2026 22:15:55 +0000
Subject: [PATCH] =DashboardManager overhaul. A bit easier to modify the output of pages. Still have to get the account pages to work as expected, as well as verify the integrations and others are working - but registrar/content pages work as expected. Also fixed up the table generation in CRUD.js and CRUDSkeleton.php
---
inc/managers/DashboardManager.php | 41 +++++++++++------------------------------
1 files changed, 11 insertions(+), 30 deletions(-)
diff --git a/inc/managers/DashboardManager.php b/inc/managers/DashboardManager.php
index bb671e8..e8fb17c 100644
--- a/inc/managers/DashboardManager.php
+++ b/inc/managers/DashboardManager.php
@@ -1,7 +1,7 @@
<?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;
@@ -111,7 +111,7 @@
/**
* 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) {
@@ -133,13 +133,13 @@
}
}
- 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;
@@ -191,7 +191,6 @@
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
@@ -206,7 +205,6 @@
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
@@ -220,7 +218,7 @@
$page = $this->getCurrentPageTitle();
// Check if page exists in allowed pages
$allowedPages = $this->getUserAllowedPages();
-
+ error_log('Allowed pages: '.print_r($allowedPages, true));
if (!in_array($page, $allowedPages)) {
error_log("User not allowed to access page: {$page}");
$this->redirectToDashboard();
@@ -395,7 +393,6 @@
$this->renderHeader();
// Pass to page handler
$constantSlug = $this->getConstantSlug($page);
-
echo apply_filters(
'jvbDashboardPage',
$this->renderPage($page),
@@ -868,6 +865,7 @@
public function renderIndex(string $content, string $page):string
{
+ jvbDump($page);
if ($page !== '' && $page !== 'dash') {
return $content;
}
@@ -933,28 +931,6 @@
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);
@@ -1228,6 +1204,7 @@
echo jvbNewModal(
'edit-modal '.$type,
+ 'edit-modal',
'Edit '.ucfirst($type),
jvbRenderForm('admin', $fields)
);
@@ -1346,12 +1323,14 @@
}
if (!$user || !$this->userHasDashboardAccess($user)) {
+ error_log('No Dashboard Access');
return [];
}
$pages = $this->cache->get($userID);
+ $pages = false;
if ($pages === false || JVB_TESTING) {
if (user_can($userID, 'manage_options')) {
// Admin gets all pages as flat array
@@ -1364,6 +1343,7 @@
$pages = $this->getAllDashboardPages();
$canSkip = user_can($userID, 'skip_moderation');
+ jvbDump($pages, 'All Pages');
foreach($pages as $key => $slug) {
//Default to Remove pages
$remove = true;
@@ -1459,6 +1439,7 @@
}
}
break;
+ case 'Account':
case 'dash':
case 'Referrals':
case 'favourites':
--
Gitblit v1.10.0