Skip to content

Commit fe4cb84

Browse files
committed
refactor(wordpress-seo): drop obsolete fixHomeBreadcrumbs
fixHomeBreadcrumbs only ran when Yoast's get_page_type() returned 'Home_Page' for a PFCPT page. That held in Yoast ~17 (when the logic was first written, late 2021), but Yoast has since moved is_static_posts_page() onto the $wp_query->is_posts_page flag -- which Handler always sets -- and checks it before the Home_Page branch. PFCPT pages now resolve to Static_Posts_Page, so the method is unreachable on every supported Yoast. Verified against Yoast 25.9 and 27.7, with and without Polylang and with breadcrumbs-home set: all resolve to Static_Posts_Page.
1 parent 4bc5222 commit fe4cb84

1 file changed

Lines changed: 0 additions & 48 deletions

File tree

src/Integration/WordPressSeo/Breadcrumbs.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Yoast\WP\SEO\Context\Meta_Tags_Context;
99
use Yoast\WP\SEO\Main;
1010
use Yoast\WP\SEO\Models\Indexable;
11-
use Yoast\WP\SEO\Repositories\Indexable_Repository;
1211
use Yoast\WP\SEO\Surfaces\Values\Meta;
1312

1413
/**
@@ -26,7 +25,6 @@ public function __construct(
2625

2726
public function registerHooks(): void
2827
{
29-
add_filter('wpseo_breadcrumb_indexables', [$this, 'fixHomeBreadcrumbs'], 10, 2);
3028
add_filter('wpseo_breadcrumb_indexables', [$this, 'fixTaxonomyBreadcrumbs'], 10, 2);
3129
add_filter('wpseo_breadcrumb_indexables', [$this, 'fixPostBreadcrumbs'], 10, 2);
3230
}
@@ -125,52 +123,6 @@ public function fixTaxonomyBreadcrumbs(array $indexables, Meta_Tags_Context $con
125123
return $indexables;
126124
}
127125

128-
/**
129-
* Fix Yoast breadcrumbs on home.
130-
*
131-
* @param Indexable[] $indexables
132-
* @return Indexable[]
133-
*/
134-
public function fixHomeBreadcrumbs(array $indexables, Meta_Tags_Context $context): array
135-
{
136-
if (!$this->api->isQueryPageForCustomPostType()) {
137-
return $indexables;
138-
}
139-
140-
$yoast = $this->getYoast();
141-
142-
if ($yoast->helpers->current_page->get_page_type() !== 'Home_Page') {
143-
return $indexables;
144-
}
145-
146-
/** @var Indexable_Repository $indexableRepository */
147-
$indexableRepository = $yoast->classes->get(Indexable_Repository::class);
148-
$staticAncestors = [];
149-
150-
$breadcrumbsHome = $yoast->helpers->options->get('breadcrumbs-home');
151-
152-
if ($breadcrumbsHome !== '') {
153-
$frontPageId = $yoast->helpers->current_page->get_front_page_id();
154-
155-
$staticAncestor = $frontPageId === 0
156-
? $indexableRepository->find_for_home_page()
157-
: $indexableRepository->find_by_id_and_type($frontPageId, 'post');
158-
159-
if (
160-
$staticAncestor instanceof Indexable
161-
&& ($frontPageId === 0 || $staticAncestor->post_status !== 'unindexed')
162-
) {
163-
$staticAncestors[] = $staticAncestor;
164-
}
165-
}
166-
167-
if (!empty($staticAncestors)) {
168-
array_unshift($indexables, ...$staticAncestors);
169-
}
170-
171-
return $indexables;
172-
}
173-
174126
private function getYoast(): Main
175127
{
176128
/** @var Main */

0 commit comments

Comments
 (0)