Jake Vanderwerf
6 hours ago 88d9e0e2b7997eb0c96dc737082c91b4e3f7ca6e
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
@@ -395,7 +393,6 @@
      $this->renderHeader();
      // Pass to page handler
      $constantSlug = $this->getConstantSlug($page);
        echo apply_filters(
         'jvbDashboardPage',
         $this->renderPage($page),
@@ -641,7 +638,10 @@
            }
         }
         return $icon;
         return match($icon) {
            'favourites'   => 'heart',
            default => $icon
         };
      });
   }
   protected function getSlug(string $slug, string $page):string
@@ -744,7 +744,7 @@
         //content types
      $all = array_merge(
         Registrar::getRegistered('post'),
         Registrar::getFeatured('is_content', 'term')
         Registrar::withFeature('is_content', 'term')
      );
      $availableContent = array_filter($pages, function($page, $key) use($all) {
         return !is_numeric($key) && in_array($key, $all) && JVB()->roles()->checkRole($this->user, $key);
@@ -930,28 +930,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);
@@ -1091,7 +1069,7 @@
        <?php
        $i=1;
        $content = Registrar::getRegistered('post');
        $contentTax = Registrar::getFeatured('is_content', 'term');
        $contentTax = Registrar::withFeature('is_content', 'term');
        $taxonomies = Registrar::getRegistered('term');
        foreach($contentTax as $index => $tax) {
            unset($taxonomies[$index]);
@@ -1284,7 +1262,7 @@
            $pages[] = 'Favourites';
         }
         if (!empty(Registrar::getFeatured('karma'))) {
         if (!empty(Registrar::withFeature('karma'))) {
            $pages[] = 'Karmic Score';
         }
@@ -1451,7 +1429,7 @@
                     foreach ($roles as $role) {
                        $contents = Registrar::getInstance($role)?->getCreatable();
                        if (!empty($contents)) {
                           $hasKarma = Registrar::getFeatured('karma');
                           $hasKarma = Registrar::withFeature('karma');
                           $remove = empty(array_intersect($contents, $hasKarma));
                        }
                     }
@@ -1512,7 +1490,7 @@
    */
   protected function getRolesWithDashboard():array
   {
      return Registrar::getFeatured('has_dashboard', 'user');
      return Registrar::withFeature('has_dashboard', 'user');
   }
   /**