| | |
| | | 'name' => $contentRegistrar->getConfig('breadcrumbs')['title']??$contentRegistrar->getPlural(), |
| | | 'url' => get_post_type_archive_link(jvbCheckBase($content)), |
| | | ]; |
| | | $crumbs[] = [ |
| | | 'name' => 'By ' . $registrar->getSingular(), |
| | | 'url' => false, |
| | | ]; |
| | | // $crumbs[] = [ |
| | | // 'name' => 'By ' . $registrar->getSingular(), |
| | | // 'url' => false, |
| | | // ]; |
| | | } |
| | | } |
| | | |
| | |
| | | // Add directory if exists |
| | | $content = jvbNoBase($post->post_type); |
| | | $registrar = Registrar::getInstance($content); |
| | | $crumbConfig = false; |
| | | if ($registrar){ |
| | | $crumbConfig = $registrar->getConfig('breadcrumbs'); |
| | | } |
| | | |
| | | if($registrar && $registrar->hasFeature('show_directory')) { |
| | | $directory = JVB()->directories()?->directories($content)??[]; |
| | | if (!empty($directory)) { |
| | |
| | | } elseif (is_post_type_archive() && $registrar && $registrar->hasFeature('show_directory')) { |
| | | |
| | | $crumbs[] = [ |
| | | 'name' => $registrar->getConfig('breadcrumb')['title'] ?? $registrar->getPlural(), |
| | | 'name' => $registrar->getConfig('breadcrumbs')['title'] ?? $registrar->getPlural(), |
| | | 'url' => get_post_type_archive_link($type) |
| | | ]; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public function addTaxToCrumbs(array $crumbs, string $taxonomy):array |
| | | public function addTaxToCrumbs(array $crumbs, string|array $taxonomy):array |
| | | { |
| | | $ID = get_the_ID(); |
| | | $taxonomy = jvbCheckBase($taxonomy); |
| | | $terms = get_the_terms($ID, $taxonomy); |
| | | if ($terms && !is_wp_error($terms)) { |
| | | $term = $terms[0]; |
| | | $ancestors = get_ancestors($term->term_id, $taxonomy, 'taxonomy'); |
| | | $ancestors = array_reverse($ancestors); |
| | | foreach ($ancestors as $ancestor) { |
| | | $aTerm = get_term($ancestor, $taxonomy); |
| | | if ($aTerm && !is_wp_error($aTerm)) { |
| | | $crumbs[] = [ |
| | | 'name' => $aTerm->name, |
| | | 'url' => get_term_link($ancestor, $taxonomy) |
| | | ]; |
| | | $taxonomies = is_string($taxonomy) ? [$taxonomy] : $taxonomy; |
| | | foreach ($taxonomies as $tax) { |
| | | $taxonomy = jvbCheckBase($tax); |
| | | $terms = get_the_terms($ID, $taxonomy); |
| | | if ($terms && !is_wp_error($terms)) { |
| | | $term = $terms[0]; |
| | | $ancestors = get_ancestors($term->term_id, $taxonomy, 'taxonomy'); |
| | | $ancestors = array_reverse($ancestors); |
| | | foreach ($ancestors as $ancestor) { |
| | | $aTerm = get_term($ancestor, $taxonomy); |
| | | if ($aTerm && !is_wp_error($aTerm)) { |
| | | $crumbs[] = [ |
| | | 'name' => $aTerm->name, |
| | | 'url' => get_term_link($ancestor, $taxonomy) |
| | | ]; |
| | | } |
| | | } |
| | | $crumbs[] = [ |
| | | 'name' => html_entity_decode($term->name), |
| | | 'url' => get_term_link($term, $taxonomy) |
| | | ]; |
| | | } |
| | | $crumbs[] = [ |
| | | 'name' => html_entity_decode($term->name), |
| | | 'url' => get_term_link($term, $taxonomy) |
| | | ]; |
| | | } |
| | | |
| | | return $crumbs; |
| | | } |
| | | } |