PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/generators/schema/breadcrumb.php +18 -0 18.428.5 View file →
@@ -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 }