Skip to content

feat: fallback to post type slug for parent page - #37

Merged
ictbeheer merged 1 commit into
mainfrom
feat/parent-page-slug
May 1, 2026
Merged

feat: fallback to post type slug for parent page#37
ictbeheer merged 1 commit into
mainfrom
feat/parent-page-slug

Conversation

@ictbeheer

@ictbeheer ictbeheer commented Apr 28, 2026

Copy link
Copy Markdown
Member

See also Brave Hooks

Copilot AI review requested due to automatic review settings April 28, 2026 13:15
@ictbeheer
ictbeheer requested a review from a team as a code owner April 28, 2026 13:15
@github-actions

github-actions Bot commented Apr 28, 2026

Copy link
Copy Markdown

Coverage report for commit: ef81625
File: coverage.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ███████████████████████ │ 100.0%
  10% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  20% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  30% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  80% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  90% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
 100% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: - | Methods: -
FilesLinesMethodsBranches
src/Components
   Accordion.php--100.00%
   BackButton.php--100.00%
   Breadcrumb.php--100.00%
   Dialog.php--100.00%
   FeedbackForm.php--100.00%
   ImgFocalPoint.php--100.00%
   Nav.php--100.00%
   PatternContent.php--100.00%
   ReadSpeaker.php--100.00%
   SocialIcon.php--100.00%
   Tooltip.php--100.00%
src/Components/Breadcrumb
   Crumb.php--100.00%
src
   ComponentsServiceProvider.php--100.00%
src/Hooks
   PatternContent.php--100.00%
   ReadSpeaker.php--100.00%

🤖 comment via lucassabreu/comment-coverage-clover

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a fallback mechanism in the breadcrumb parent-page resolution logic so that when an explicit parent-page support slug is not configured, the code attempts to derive the parent page from the post type’s rewrite slug.

Changes:

  • Update breadcrumb parent page slug detection to fall back to the post type rewrite slug when parent-page slug is missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$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.
@ictbeheer
ictbeheer merged commit df97646 into main May 1, 2026
9 checks passed
@ictbeheer
ictbeheer deleted the feat/parent-page-slug branch May 1, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants