Post Date: Extendable Suggested Formats#62345
Draft
TylerB24890 wants to merge 5 commits intoWordPress:trunkfrom
Draft
Post Date: Extendable Suggested Formats#62345TylerB24890 wants to merge 5 commits intoWordPress:trunkfrom
TylerB24890 wants to merge 5 commits intoWordPress:trunkfrom
Conversation
fabiankaegy
reviewed
Jun 5, 2024
| _x( 'M j', 'short date format without the year' ), | ||
| ] ), | ||
| ]; | ||
| const editorSettings = select( blockEditorStore ).getSettings(); |
Member
There was a problem hiding this comment.
@TylerB24890 can you refactor this to use useSelect instead? There are some architectural differences and the usage of select itself is discouraged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.formatOptionsproperty to the__experimentalFeaturesobject in the editor settings. TheformatOptionsvalue is then used as the suggested date formats in thecore/post-dateblock.NOTE: If
__experimentalFeaturesis 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/dateWhy?
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.formatOptionsto the Block Editor Settings, extenders can use theblock_editor_settings_allfilter to change the suggested date formats available to editors.Testing Instructions
core/post-dateblockfunctions.php(or similar) add the following:core/post-dateblock Format Options are reduced to only the two defined (plus the "Custom" option).Jan 25January 25, 2022