Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wp_get_archives for years <1000 #5330

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

faisal-alvi
Copy link

Trac ticket: https://core.trac.wordpress.org/ticket/59381

This PR adds leading zeros when year has less than 4 digits.

Steps to Test

  1. With a block theme active, add an Archive block to a page template.
  2. Set permalinks to use "Month" based URL structure.
  3. Create or modify a post and set the post date to a year earlier than 1000, for example 420.
  4. Save and view/preview the post on the frontend.
  5. The Archive block's representation of the year should include leading zeros.
  6. The /420 archive listing page should work and does not show to a 404.
@faisal-alvi
Copy link
Author

This is ready for Code Review.

@ironprogrammer
Copy link

Thanks for the patch, @faisal-alvi!

I wonder what consensus is on the frontend's display of years < 1000, versus how the slugs are formatted. For instance comparing:

  1. September 26, 520
  2. September 26, 0520

I prefer the first, without the leading zero. That's the English standard (e.g. Wikipedia's date guidelines), but I'm unsure for other languages/cultures. Rather than make a suggestion to change this at this time, I feel that additional contributor input would be valuable.

As for slugs, they're currently forced into YYYY format, so the update to the underlying anchor links in the archive list function how I'd expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants