| @@ -14,8 +14,12 @@ | ||
| 14 | 14 | * |
| 15 | 15 | * @return bool |
| 16 | 16 | */ |
| 17 | 17 | public function is_needed() { |
| 18 | + if ( $this->context->indexable->object_type === 'unknown' ) { | |
| 19 | + return false; | |
| 20 | + } | |
| 21 | + | |
| 18 | 22 | if ( $this->context->indexable->object_type === 'system-page' && $this->context->indexable->object_sub_type === '404' ) { |
| 19 | 23 | return false; |
| 20 | 24 | } |
| 21 | 25 | |
| @@ -81,8 +85,11 @@ | ||
| 81 | 85 | $breadcrumbs[0]['text'] = $breadcrumbs_home; |
| 82 | 86 | } |
| 83 | 87 | } |
| 84 | 88 | |
| 89 | + $breadcrumbs = \array_filter( $breadcrumbs, [ $this, 'not_empty_text' ] ); | |
| 90 | + $breadcrumbs = \array_values( $breadcrumbs ); | |
| 91 | + | |
| 85 | 92 | // Create intermediate breadcrumbs. |
| 86 | 93 | foreach ( $breadcrumbs as $index => $breadcrumb ) { |
| 87 | 94 | $list_elements[] = $this->create_breadcrumb( $index, $breadcrumb ); |
| 88 | 95 | } |
| @@ -163,6 +170,17 @@ | ||
| 163 | 170 | * @return bool If the breadcrumb should not be hidden. |
| 164 | 171 | */ |
| 165 | 172 | private function not_hidden( $breadcrumb ) { |
| 166 | 173 | return empty( $breadcrumb['hide_in_schema'] ); |
| 174 | + } | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * Checks whether the breadcrumb has a not empty text. | |
| 178 | + * | |
| 179 | + * @param array $breadcrumb The breadcrumb array. | |
| 180 | + * | |
| 181 | + * @return bool If the breadcrumb has a not empty text. | |
| 182 | + */ | |
| 183 | + private function not_empty_text( $breadcrumb ) { | |
| 184 | + return ! empty( $breadcrumb['text'] ); | |
| 167 | 185 | } |
| 168 | 186 | } |