-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Only display the modified post date if the post has been modified #46839
Conversation
Size Change: +10.1 kB (+1%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Flaky tests detected in 5de7629. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4342113468
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this one @carolinan, this is a nice change!
Code looks good to me, and it does what it says. This looks OK to merge 👍
Co-authored-by: Ari Stathopoulos <[email protected]>
This change made it impossible to use |
What?
The post date block has a setting that displays the modified date. When the setting is enabled, it displays the post date
if the post has not been modified.
This PR updates the block to only display the modified date if the setting is enabled and the post has been modified.
If the setting is enabled, but the post has not been modified, nothing is shown on the front.
It also adds a new CSS class to identify that the setting is enabled so that developers can style it differently.
Fixes #46645
Why?
Without this PR, a template that displays both the published date and the modified date could show two identical dates,
and there was no way to hide the modified date if the post was not modified.
How?
The PR compares the modified date and the post date and returns early if the time difference is a less than a minute.
Testing Instructions
Create a new post.
Add a post date block.
Wait a minute or two and add a second post date block. Enable the "Display last modified date" setting.
Save and view the front. Both blocks should show, with different dates.
Create a second new post.
Add a post date block. Enable the "Display last modified date" setting.
Save and view the front. If you were fast enough, the block should not show.
Go back to the editor, wait a minute and make a change to the post.
Save and view the front, confirm that the block shows.
Testing Instructions for Keyboard
Screenshots or screencast