Skip to content

fix(post-date): preserve classic theme markup and fix archive titles#4602

Open
rbcorrales wants to merge 2 commits intotrunkfrom
fix/post-date-markup
Open

fix(post-date): preserve classic theme markup and fix archive titles#4602
rbcorrales wants to merge 2 commits intotrunkfrom
fix/post-date-markup

Conversation

@rbcorrales
Copy link
Copy Markdown
Member

All Submissions:

Changes proposed in this Pull Request:

Follow-up to #4579. Addresses review feedback from @laurelfulford about preserving the classic theme's HTML markup for the updated date, and fixes the archive title regression.

  • Renamed hook from newspack_theme_after_posted_on to newspack_theme_posted_on (now fires inside newspack_posted_on() in the theme)
  • Changed classic theme output to bare inner elements (<span class="updated-label"> + <time class="updated">) matching the old theme markup exactly
  • Removed plugin's inline CSS for .updated-date (theme provides .updated-label styling)
  • Added in_the_loop() guard to filter_get_the_date to prevent archive titles showing relative dates (e.g. "Daily Archives: 2 days ago")
  • Added time.updated[datetime] to the relative-time JS selector so the updated date gets a hover tooltip on classic themes

Requires companion theme PR: Automattic/newspack-theme#2658. Must ship together.

Closes NPPD-1278.

How to test the changes in this Pull Request:

  1. Activate the classic Newspack theme (with the companion theme PR) and enable both "Show relative dates" and "Show last updated date" in Newspack > Settings > Advanced Settings > Post Date.
  2. Create or find a post modified well after publication (at least 24 hours). Verify the markup is all inside one .posted-on span: <time class="entry-date published"> + <span class="updated-label">Updated </span> + <time class="updated">.
  3. Hover over both dates and verify both show a tooltip with the full date.
  4. Visit a daily archive page and verify the title shows the full date, not "X days ago".
  5. Switch to the block theme. Verify the updated date still renders correctly with data-newspack-modified and wp-block-post-date__modified-date.
  6. Open a post in the block editor. Verify the "Hide/Show last updated date" toggle appears in the Summary panel.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the Post Date feature integration to better match the classic Newspack theme’s historical markup while preventing relative-date formatting from leaking into archive titles.

Changes:

  • Switch classic-theme updated-date injection to the new newspack_theme_posted_on hook and adjust classic updated-date HTML output to match legacy markup.
  • Prevent get_the_date “time ago” conversion from applying outside the loop (fixes archive title regressions).
  • Update the relative-time JS to also target time.updated[datetime] and remove the plugin’s classic updated-date inline CSS.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
includes/class-post-date.php Renames the classic-theme hook, updates classic updated-date markup, removes inline CSS, and adds an in_the_loop() guard in get_the_date filtering.
src/other-scripts/relative-time/index.js Expands the selector to include time.updated[datetime] so classic updated dates get tooltips/updates.
tests/unit-tests/class-post-date-test.php Updates the get_the_date filter test to simulate being “in the loop”.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rbcorrales rbcorrales marked this pull request as ready for review March 26, 2026 18:28
@rbcorrales rbcorrales requested a review from a team as a code owner March 26, 2026 18:28
@rbcorrales rbcorrales added the [Status] Needs Review The issue or pull request needs to be reviewed label Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants