Skip to content

Fix breadcrumb date archive links, comma category names, and author warning - #111

Merged
iamprazol merged 1 commit into
developfrom
fix/breadcrumbs-date-comma-author-bugs
Sep 30, 2026
Merged

iamprazol merged 1 commit into
developfrom
fix/breadcrumbs-date-comma-author-bugs

Conversation

@deepench

Copy link
Copy Markdown
Contributor

Fixes #93

Changes proposed in this Pull Request:

Three bugs in flash_breadcrumbs() (inc/extras.php), all verified live, not just from source:

  1. Date archive month link pointed at /YYYY/00/, a dead URL that still returns 200. get_month_link() takes a numeric month, but the code passed get_the_time('M') (the month name, e.g. "Sep") instead of get_the_time('m'). Also added the missing space between the day suffix and month name ("15thMar" -> "15th Mar"), and stopped passing date-format codes ('Y', 'M', 'm', 'jS') through __() - they're PHP date() format characters, not translatable text.

  2. A category name containing a comma (a perfectly normal name, e.g. "Food, Drink") broke the breadcrumb markup. The code built one comma-joined string via get_category_parents(..., ',') then split it back apart with explode(',', ...), so the comma in the name itself got mistaken for the separator - opening an in one

  3. and closing it in the next, invalid HTML. Rebuilt from actual term objects via get_ancestors()/get_term(), which can't confuse a name for a separator.

  4. A non-existent author archive URL (which WordPress core still answers with HTTP 200) logged "PHP Warning: Attempt to read property 'display_name' on false" on every anonymous visit, since get_userdata() was used with no existence check. Added the missing check.

Verified all three live: reproduced the broken /2026/00/ link and "15thMar"-style concatenation on a day archive, reproduced the exact broken markup on a post in a category named "Food, Drink", and reproduced the exact PHP warning on /author// - then confirmed all three are gone after the fix, with no regression on ordinary categories/archives/authors.

How to test the changes in this Pull Request:

  1. Publish a post today, then visit its day archive (/YYYY/MM/DD/) - the month breadcrumb link should point at /YYYY/MM/, not /YYYY/00/, and the day item should read like "28th Sep" with a space.
  2. Create a category with a comma in its name (e.g. "Food, Drink"), assign a post to it, and check the breadcrumb - it should be one well-formed item with the full name.
  3. Visit /author/some-nonexistent-username/ and confirm no "display_name on false/bool" warning appears in the PHP error log.

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (modification of the currently available functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Other information:

  • Have you added an explanation of what your changes do and why you would like us to include them?
  • Have you successfully ran tests with your changes locally?
  • Have you updated the documentation accordingly?

Changelog entry

Fix - Breadcrumb date archive links, category names containing a comma, and a PHP warning on non-existent author URLs.

…s, PHP warning on bad author URLs

All three confirmed live, not just from source:

1. Date archive month link pointed at /YYYY/00/, a dead URL that still
   200s. get_month_link() takes a numeric month, but the code passed
   get_the_time('M') (the month name, e.g. "Sep") instead of get_the_time('m').
   Also added the missing space between the day suffix and month name
   ("15thMar" -> "15th Mar"), and stopped passing date-format codes ('Y',
   'M', 'm', 'jS') through __() - they're PHP date() format characters,
   not translatable text, and only ever collided with the month-link bug
   because nobody noticed the untranslated fallback still worked.

2. A category name containing a comma (a perfectly normal name, e.g.
   "Food, Drink") broke the breadcrumb markup. The code built one
   comma-joined string via get_category_parents(..., ',') then split it
   back apart with explode(',', ...), so the comma in the name itself got
   mistaken for the separator - opening an <a> in one <li> and closing it
   in the next. Rebuilt from actual term objects via
   get_ancestors()/get_term(), which can't confuse a name for a separator.

3. A non-existent author archive URL (which WordPress core still answers
   with HTTP 200) logged "PHP Warning: Attempt to read property
   'display_name' on false" on every anonymous visit, since get_userdata()
   was used unchecked. Added the missing existence check.

Same code, same bugs, in both Free and Pro's inc/extras.php.
@github-actions

Copy link
Copy Markdown

QA suite — refused, no regression spec

This PR changes product source but adds no spec, so the suite was
refused before booting WordPress — running it just to report the same
thing at the end costs runner minutes for nothing. Run
/claudegrill:verify-fix locally and let write-spec add the guard
to this branch, then push again.

Source files changed with no matching spec
inc/extras.php

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Only a minor issue-reference documentation nit remains; no code-blocking issues were identified.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Fixes breadcrumb date links, comma-containing category names, and warnings for nonexistent author archives.

Changes:

  • Corrects month archive URLs and date formatting.
  • Builds category breadcrumbs from term objects.
  • Guards missing author data.
File Summary
inc/​extras.php Updates breadcrumb generation and author handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread inc/extras.php
Comment on lines +221 to +223
// Get parent categories and the category itself, top-most ancestor first.
$cat_ancestors = array_reverse( get_ancestors( $last_category->term_id, 'category' ) );
$cat_ancestors[] = $last_category->term_id;

@subin-shk subin-shk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM 👍🏼

@iamprazol
iamprazol merged commit dfce29b into develop Sep 30, 2026
3 of 5 checks passed
@iamprazol
iamprazol deleted the fix/breadcrumbs-date-comma-author-bugs branch September 30, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants