| | |
| | | |
| | | public function __construct() |
| | | { |
| | | $this->cache = Cache::for('dashboard', WEEK_IN_SECONDS)->connect('user'); |
| | | $this->cache = Cache::for('dashboard', WEEK_IN_SECONDS)->connect('user')->user(); |
| | | if (JVB_TESTING) { |
| | | $this->cache->flush(); |
| | | } |
| | | |
| | | add_action('init', [$this, 'registerDashboard']); |
| | | |
| | | $this->user = wp_get_current_user(); |
| | |
| | | |
| | | jvb_register_do_once('buildDashboard', [$this, 'activate']); |
| | | |
| | | add_filter('the_seo_framework_sitemap_exclude_ids', [$this, 'excludeDashboard'], 10, 1); |
| | | add_filter('the_seo_framework_sitemap_exclude_ids', [$this, 'excludeDashboard'], 8, 1); |
| | | } |
| | | |
| | | public function excludeDashboard(array $ids):array { |
| | | $cached = $this->cache->remember( |
| | | public function excludeDashboard(array $IDs):array { |
| | | $this->cache->flush(); |
| | | $exclude = $this->cache->remember( |
| | | 'dashboardIDs', |
| | | function() { |
| | | return get_posts([ |
| | |
| | | 'fields' => 'ids', |
| | | ]); |
| | | }); |
| | | return array_merge($ids, $cached); |
| | | if (!empty($exclude)) { |
| | | $IDs = array_merge($IDs, $exclude); |
| | | } |
| | | |
| | | return $IDs; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | protected function renderDashboard(string $page):string |
| | | { |
| | | ob_start(); |
| | | // ob_start(); |
| | | jvbInlineStyles('nav'); |
| | | jvbInlineStyles('dash'); |
| | | jvbInlineStyles('forms'); |
| | |
| | | ); |
| | | |
| | | $this->renderFooter(); |
| | | return ob_get_clean(); |
| | | // return ob_get_clean(); |
| | | return ''; |
| | | // $integrationSlugs = array_map(function($name) { |
| | | // return sanitize_title(str_replace('_', '-', $name)); |
| | | // }, array_keys(JVB()->getAvailableServices(false))); |
| | |
| | | } |
| | | |
| | | } |
| | | return $icon; |
| | | return match($icon) { |
| | | 'favourites' => 'heart', |
| | | default => $icon |
| | | }; |
| | | }); |
| | | } |
| | | protected function getSlug(string $slug, string $page):string |
| | |
| | | |
| | | <?php |
| | | $menu = new Navigation('sidebar'); |
| | | $menuClasses = ['col', 'a-start', 'nowrap']; |
| | | $menuClasses = ['left']; |
| | | $itemClasses = ['col']; |
| | | $menu->addClass('col a-start')->hasToggle()->defaultMenuClasses($menuClasses); |
| | | $menu->addClass('sidebar left')->hasToggle()->defaultMenuClasses($menuClasses); |
| | | $menu->defaultItemClasses($itemClasses); |
| | | $pages = $this->getUserAllowedPages()?:[]; |
| | | //Dashboard |
| | |
| | | //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); |
| | |
| | | { |
| | | ?> |
| | | <div class="approvals container"> |
| | | <nav class="tabs row start" role="tablist"> |
| | | <nav class="tabs row left" role="tablist"> |
| | | <button type="button" class="tab active" data-tab="summary" role="tab" aria-selected="true"> |
| | | <?= jvbDashIcon('infinity')?>All |
| | | </button> |
| | |
| | | } |
| | | ob_start(); |
| | | ?> |
| | | <nav class="tabs row start" role="tablist"> |
| | | <nav class="tabs row left" role="tablist"> |
| | | <?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]); |
| | |
| | | $pages[] = 'Favourites'; |
| | | } |
| | | |
| | | if (!empty(Registrar::getFeatured('karma'))) { |
| | | if (!empty(Registrar::withFeature('karma'))) { |
| | | $pages[] = 'Karmic Score'; |
| | | } |
| | | |
| | |
| | | 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)); |
| | | } |
| | | } |
| | |
| | | */ |
| | | protected function getRolesWithDashboard():array |
| | | { |
| | | return Registrar::getFeatured('has_dashboard', 'user'); |
| | | return Registrar::withFeature('has_dashboard', 'user'); |
| | | } |
| | | |
| | | /** |