| @@ -1,10 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. | |
| 3 | - | |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | - exit; | |
| 6 | -} | |
| 7 | 2 | if ( is_front_page() ) { |
| 8 | 3 | return; |
| 9 | 4 | } |
| 10 | 5 | $breadcrumbs_layout = isset( $breadcrumbs_layout ) ? $breadcrumbs_layout : 'layout-1'; |
| @@ -49,33 +44,16 @@ | ||
| 49 | 44 | unset($breadcrumbs[0]); |
| 50 | 45 | } |
| 51 | 46 | |
| 52 | 47 | $breadcrumbs = apply_filters( 'betterdocs_breadcrumb_before_archives', $breadcrumbs ); |
| 53 | - | |
| 54 | - // Detect the current archive taxonomy via the queried object (reliable in Elementor theme builder context) | |
| 55 | - $_queried_obj = get_queried_object(); | |
| 56 | - $_is_doc_tag = $_queried_obj instanceof \WP_Term && $_queried_obj->taxonomy === 'doc_tag'; | |
| 57 | - | |
| 58 | - if ( $taxanomy == 'doc_category' ) { | |
| 48 | + if ( $taxanomy == 'doc_category' || is_tax( 'doc_tag' ) ) { | |
| 59 | 49 | if ( $enable_breadcrumb_category ) { |
| 60 | 50 | $query_obj = get_queried_object(); |
| 61 | 51 | $term_id = $query_obj->term_id; |
| 62 | 52 | |
| 63 | 53 | $term_parents = betterdocs()->query->get_term_parents( $term_id ); |
| 64 | - if ( ! is_wp_error( $term_parents ) && is_array( $term_parents ) ) { | |
| 65 | - $breadcrumbs = apply_filters( 'betterdocs_breadcrumb_after_archives', array_merge( $breadcrumbs, $term_parents ) ); | |
| 66 | - } | |
| 54 | + $breadcrumbs = apply_filters( 'betterdocs_breadcrumb_after_archives', array_merge( $breadcrumbs, $term_parents ) ); | |
| 67 | 55 | } |
| 68 | - } elseif ( $_is_doc_tag ) { | |
| 69 | - // Always append the current tag name: Home > Docs > Tag Title | |
| 70 | - $tag_crumb = [ | |
| 71 | - [ | |
| 72 | - 'li_classes' => [ 'item-current', 'item-tag-' . esc_attr( $_queried_obj->term_id ), 'current' ], | |
| 73 | - 'url' => '', | |
| 74 | - 'text' => $_queried_obj->name, | |
| 75 | - ], | |
| 76 | - ]; | |
| 77 | - $breadcrumbs = apply_filters( 'betterdocs_breadcrumb_after_archives', array_merge( $breadcrumbs, $tag_crumb ) ); | |
| 78 | 56 | } elseif ( is_single() ) { |
| 79 | 57 | global $wp_query, $post; |
| 80 | 58 | |
| 81 | 59 | if ( $enable_breadcrumb_category ) { |
| @@ -94,11 +72,9 @@ | ||
| 94 | 72 | $breadcrumbs = apply_filters( 'betterdocs_breadcrumb_before_single_category', $breadcrumbs ); |
| 95 | 73 | |
| 96 | 74 | if ( $cat_terms ) { |
| 97 | 75 | $term_parents = betterdocs()->query->get_term_parents( $cat_terms[0]->term_id ); |
| 98 | - if ( ! is_wp_error( $term_parents ) && is_array( $term_parents ) ) { | |
| 99 | - $breadcrumbs = array_merge( $breadcrumbs, $term_parents ); | |
| 100 | - } | |
| 76 | + $breadcrumbs = array_merge( $breadcrumbs, $term_parents ); | |
| 101 | 77 | } |
| 102 | 78 | } |
| 103 | 79 | |
| 104 | 80 | // Check if the post is in a category |
| @@ -103,9 +79,9 @@ | ||
| 103 | 79 | |
| 104 | 80 | // Check if the post is in a category |
| 105 | 81 | if ( $enable_breadcrumb_title ) { |
| 106 | 82 | $breadcrumbs[] = [ |
| 107 | - 'li_classes' => [ 'item-current', 'item-' . ( $post->ID != null ? $post->ID : '' ), 'current' ], | |
| 83 | + 'li_classes' => [ 'item-current', 'item-' . $post->ID, 'current' ], | |
| 108 | 84 | 'url' => '', |
| 109 | 85 | 'text' => betterdocs()->template_helper->kses( get_the_title() ) |
| 110 | 86 | ]; |
| 111 | 87 | } |
| @@ -160,9 +136,9 @@ | ||
| 160 | 136 | ?> |
| 161 | 137 | </li> |
| 162 | 138 | <?php |
| 163 | 139 | if ( next( $breadcrumbs ) ) : |
| 164 | - if ( $breadcrumbs_layout == 'layout-2' || $breadcrumbs_layout == 'layout-3' ) { | |
| 140 | + if ( $breadcrumbs_layout == 'layout-2' ) { | |
| 165 | 141 | $view_object->get( 'template-parts/breadcrumb-delimiter-2' ); |
| 166 | 142 | } else { |
| 167 | 143 | $view_object->get( 'template-parts/breadcrumb-delimiter-1' ); |
| 168 | 144 | } |