Skip to content

Pre-publish panel: Add filters for the suggested post format and the open state of the suggestions - #86691

Open
pfefferle wants to merge 6 commits into
WordPress:trunkfrom
pfefferle:add/pre-publish-suggestion-filters
Open

pfefferle wants to merge 6 commits into
WordPress:trunkfrom
pfefferle:add/pre-publish-suggestion-filters

Conversation

@pfefferle

@pfefferle pfefferle commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

What?

Closes #86688

Adds two filters to the pre-publish panel:

  • editor.PrePublishPanel.suggestedPostFormat filters the post format that "Suggestion: Use a post format" offers.
  • editor.PrePublishPanel.showSuggestion filters 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.suggestionInitialOpen filters 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?

  • MaybePostFormatPanel runs the result of getSuggestedPostFormat() 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.
  • MaybeTagsPanel and MaybeCategoryPanel pass their "site has terms" check through editor.PrePublishPanel.showSuggestion. The post type still has to support the taxonomy, and the post must not have terms of it yet.
  • All four suggestion panels pass their default initialOpen value through editor.PrePublishPanel.suggestionInitialOpen. 'external-media' defaults to true, the others to false, so nothing changes without a filter.
  • Both filters are documented in docs/reference-guides/filters/editor-filters.md.

Testing Instructions

  1. Enable a theme that supports post formats (or add add_theme_support( 'post-formats', array( 'gallery', 'status' ) )).
  2. Add this in the browser console of the post editor:
    wp.hooks.addFilter( 'editor.PrePublishPanel.suggestedPostFormat', 'test', () => 'gallery' );
    wp.hooks.addFilter( 'editor.PrePublishPanel.suggestionInitialOpen', 'test', () => true );
    wp.hooks.addFilter( 'editor.PrePublishPanel.showSuggestion', 'test', () => true );
  3. Write a post with two paragraphs and click "Publish".
  4. "Suggestion: Use a post format" suggests the Gallery format, and all suggestions are open. On a site without tags, "Suggestion: Add tag" shows too.
  5. Without the filters, nothing changes compared to trunk.

Unit tests: npm run test:unit:vitest -- packages/editor/src/components/post-publish-panel

Testing Instructions for Keyboard

No UI change without a filter. With the open filter, the panels are the same PanelBody toggles as before and can be opened and closed with the keyboard.

Screenshots or screencast

No visual change without a filter.

Use of AI Tools

@github-actions github-actions Bot added the [Package] Editor /packages/editor label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

👋 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.

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: pfefferle <pfefferle@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Editor /packages/editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow plugins to change the pre-publish post format and tags suggestions

1 participant