Post Date: Extendable Suggested Formats #62345
Draft
+26
−19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
This PR adds a
date.formatOptions
property to the__experimentalFeatures
object in the editor settings. TheformatOptions
value is then used as the suggested date formats in thecore/post-date
block.NOTE: If
__experimentalFeatures
is not the correct key this kind of setting should live under please let me know. This might be better off living in the date settings from@wordpress/date
Why?
Related Issue: #55638
This PR makes the hard-coded suggested date formats extendable so extenders can choose which date formats are allowed for selecting. If a unique date format is required, extenders can add it to this setting and have it selectable instead of requiring editors to use the Custom Format option every time.
How?
By applying the
date.formatOptions
to the Block Editor Settings, extenders can use theblock_editor_settings_all
filter to change the suggested date formats available to editors.Testing Instructions
core/post-date
blockfunctions.php
(or similar) add the following:core/post-date
block Format Options are reduced to only the two defined (plus the "Custom" option).Jan 25
January 25, 2022