Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/Breadcrumb/Crumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private function getParentPagesIds(int $postId): array

$postType = get_post_type($postId);
$supports = get_all_post_type_supports($postType);
$parentPageSlug = $supports['parent-page'][0]['slug'] ?? null;
$parentPageSlug = $supports['parent-page'][0]['slug'] ?? get_post_type_object($postType)->rewrite['slug'] ?? null;

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_post_type_object($postType)->rewrite['slug'] can throw if get_post_type_object() returns null or if rewrite is false/non-array (common for post types registered with rewrite => false). Consider storing the object in a variable and only reading rewrite['slug'] when it’s an array, otherwise fall back to null (or a safe default).

Suggested change
$parentPageSlug = $supports['parent-page'][0]['slug'] ?? get_post_type_object($postType)->rewrite['slug'] ?? null;
$postTypeObject = get_post_type_object($postType);
$rewriteSlug = is_object($postTypeObject) && is_array($postTypeObject->rewrite)
? ($postTypeObject->rewrite['slug'] ?? null)
: null;
$parentPageSlug = $supports['parent-page'][0]['slug'] ?? $rewriteSlug;

Copilot uses AI. Check for mistakes.
$parent = $parentPageSlug ? get_page_by_path($parentPageSlug) : null;

if (! $parent) {
Expand Down
Loading