Repository navigation
Pre-publish panel: Add filters for the suggested post format and the open state of the suggestions - #86691
Pre-publish panel: Add filters for the suggested post format and the open state of the suggestions#86691pfefferle wants to merge 6 commits into
Conversation
…open state of the suggestions
🤖 PR meta 🤖👋 Welcome👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @pfefferle! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. 🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
…ions on sites without terms
What?
Closes #86688
Adds two filters to the pre-publish panel:
editor.PrePublishPanel.suggestedPostFormatfilters the post format that "Suggestion: Use a post format" offers.editor.PrePublishPanel.showSuggestionfilters whether a suggestion shows. For'tags'it defaults to whether the site has tags, for'category'to whether the site has categories other than the default one.editor.PrePublishPanel.suggestionInitialOpenfilters whether a suggestion starts open. The second argument names the suggestion:'post-format','tags','category'or'external-media'.Why?
Plugins that care about post formats or tags cannot change these suggestions today.
getSuggestedPostFormat()only looks at posts with one or two blocks, the tags suggestion only shows when the site already has tags, and the post format, tags and category suggestions always start closed.For example, the ActivityPub plugin shares posts on the Fediverse based on their post format, so it suggests formats for more cases, such as "status" for a short text post or "gallery" for several image blocks. It currently has to show its own panel next to core's "Suggestion: Use a post format", and it opens the tags suggestion by finding the panel in the DOM and clicking it (Automattic/wordpress-activitypub#4040). With these filters it could reuse the core panels.
How?
MaybePostFormatPanelruns the result ofgetSuggestedPostFormat()through the new filter, with the post ID as the second argument. The existing checks stay: the theme has to support the format, and the post must not have it already. The selector itself is unchanged.MaybeTagsPanelandMaybeCategoryPanelpass their "site has terms" check througheditor.PrePublishPanel.showSuggestion. The post type still has to support the taxonomy, and the post must not have terms of it yet.initialOpenvalue througheditor.PrePublishPanel.suggestionInitialOpen.'external-media'defaults totrue, the others tofalse, so nothing changes without a filter.docs/reference-guides/filters/editor-filters.md.Testing Instructions
add_theme_support( 'post-formats', array( 'gallery', 'status' ) )).Unit tests:
npm run test:unit:vitest -- packages/editor/src/components/post-publish-panelTesting Instructions for Keyboard
No UI change without a filter. With the open filter, the panels are the same
PanelBodytoggles as before and can be opened and closed with the keyboard.Screenshots or screencast
No visual change without a filter.
Use of AI Tools