| | |
| | | <?php |
| | | |
| | | use JVBase\managers\CacheManager; |
| | | use JVBase\utility\Features; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | */ |
| | | function jvbGetCrumbs():array |
| | | { |
| | | $cache = CacheManager::for('breadcrumbs', MONTH_IN_SECONDS); |
| | | $cache = CacheManager::for('breadcrumbs', MONTH_IN_SECONDS)->connectTo('all'); |
| | | $key = get_queried_object_id(); |
| | | $crumbs = $cache->get($key); |
| | | $crumbs = false; |
| | |
| | | |
| | | //taxonomies extra |
| | | if (is_tax()) { |
| | | switch ($obj->taxonomy) { |
| | | case BASE.'type': |
| | | $type = 'artist'; |
| | | break; |
| | | default: |
| | | $type = jvbNoBase($obj->taxonomy); |
| | | break; |
| | | } |
| | | $directory = jvbDirectories($type); |
| | | $crumbs[] = [ |
| | | 'name' => $directory['title'], |
| | | 'url' => $directory['url'] |
| | | ]; |
| | | $tax = jvbNoBase($obj->taxonomy); |
| | | $config = Features::getConfig($tax, 'term'); |
| | | if (count($config['for_content']) === 1) { |
| | | $contentConfig = JVB_CONTENT[$config['for_content'][0]]; |
| | | $crumbs[] = [ |
| | | 'name' => $contentConfig['breadcrumb']??$contentConfig['plural'], |
| | | 'url' => get_post_type_archive_link(jvbCheckBase($config['for_content'][0])), |
| | | ]; |
| | | $crumbs[] = [ |
| | | 'name' => 'By '.$config['singular'], |
| | | 'url' => false, |
| | | ]; |
| | | } |
| | | if (Features::forTaxonomy($tax)->has('directory')){ |
| | | $directory = jvbDirectories($tax); |
| | | $crumbs[] = [ |
| | | 'name' => $directory['title'], |
| | | 'url' => $directory['url'] |
| | | ]; |
| | | } |
| | | |
| | | $crumbs = array_merge($crumbs, jvbGetBreadcrumbTermHierarchy($obj)); |
| | | |
| | | } |