Repository navigation
Conversation
🤖 PR meta 🤖🎉 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 📦 Bundle sizeSize Change: +746 B (+0.01%) Total Size: 8.73 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. should give the image its context menu while selected @WebKit @Firefox in
|
c69f8b8 to
39587eb
Compare
bc0ec2e to
ade55fe
Compare
39587eb to
7b923be
Compare
ade55fe to
21159ab
Compare
…t is published The pre-publish panel of a page lists every Navigation Menu with a checkbox. The menus that "Auto add pages" would add the page to start checked, a menu that already links to the page is checked and locked, and any other menu can be checked. A change is sent with the page as a write-only `navigation_menus` REST field, which the status transition uses instead of the setting for that page only: an unchecked menu keeps its setting and still gets the next page. The hook now builds on gutenberg_navigation_add_post_link( $menu_id, $post ), a public function that adds a link to a post to one menu, nested under the link to its parent when there is one and appended otherwise, so a plugin can add a link to one of its pages to a menu it knows the ID of. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
Each menu row links to the menu's screen in the site editor with a "View" link that opens in a new tab, so the author can look at the menu without leaving the publish flow. The link replaces the "Edit" one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
7b923be to
ce97ed6
Compare
21159ab to
7b7ffa1
Compare
The selector built a new object and rows array on every call, which trips the `useSelect` consistency check and failed the pre-publish panel's unit test. It now returns the records array and primitives, and the rows derive from them in a memo. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
…avigation-choose-menus-on-publish
…avigation-choose-menus-on-publish
…avigation-choose-menus-on-publish # Conflicts: # lib/compat/wordpress-7.2/navigation-auto-add-pages.php # packages/editor/src/components/post-publish-panel/maybe-navigation-menus-panel.tsx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1u1vfDfpUYw8PAkEUWnB7
…avigation-choose-menus-on-publish # Conflicts: # lib/compat/wordpress-7.2/navigation-auto-add-pages.php
…avigation-choose-menus-on-publish
The site editor's Duplicate action copied only the title and content, so the copy of a menu with the setting on had it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1u1vfDfpUYw8PAkEUWnB7
…avigation-choose-menus-on-publish
…avigation-choose-menus-on-publish # Conflicts: # test/e2e/specs/editor/blocks/navigation-auto-add-pages-publish-panel.spec.ts
Trunk now requires new files in the e2e tests to be TypeScript (#84829). Menus with "Auto add new pages" on are created through the REST API, since `createNavigationMenu()` takes only a title and content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…avigation-choose-menus-on-publish # Conflicts: # lib/load.php # packages/editor/CHANGELOG.md
… compat folder WordPress 7.2 has branched, so new features now target 7.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…avigation-choose-menus-on-publish # Conflicts: # lib/compat/wordpress-7.3/navigation-auto-add-pages.php # packages/editor/CHANGELOG.md
The WordPress 7.3 compat folder is analyzed at PHPStan's strict level. Read the request's menu IDs with `wp_parse_id_list()`, read the page ID only when it is numeric, type the stored choices, and state the void returns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…avigation-choose-menus-on-publish
What?
The pre-publish panel of a page lists every Navigation Menu with a checkbox, so the author chooses the menus the page is added to when it is published. The menus that "Auto add new pages" would add the page to start checked, a menu that already links to the page is checked and locked, and any other menu can be checked. Each menu links to its editor.
It also adds
gutenberg_navigation_add_post_link( $menu_id, $post ), the public function that adds a link to a post to one menu, which the "Auto add new pages" hook now builds on and which a plugin can call.Stacked on #85762, which is stacked on #85589 and #84508. The diff against that branch is only this change.
Why?
Part of #85156. With "Auto add new pages" on, the setting decides for every page. In #16635, @joanrho asked for a way to keep a page out of a menu at publish time (a legal page that belongs in the footer, not the header) and to add a page to a menu that does not add pages. Doing both from the publish panel saves a trip to the site editor afterwards.
The public function answers a second question: a plugin that wants a link to one of its pages in a menu, the way WooCommerce wants the Shop page in the header. Block Hooks already let a plugin hook its own block type into
core/navigation, including intowp_navigationposts, and that is the right tool for a block like the Mini Cart. A plain link is acore/navigation-link, a block type every plugin shares, so thehooked_block_core/navigation-linkfilter cannot tell one plugin's link from another's. With this function a plugin adds its link to a menu it knows the ID of, in one call, without parsing the menu.How?
Server
gutenberg_navigation_add_post_link( $menu_id, $post )innavigation-auto-add-pages.php: parses the menu, returnsfalsewhen it already links to the post, nests the link under the link to the post's parent when the menu has one and appends it otherwise, and saves. Returns aWP_Errorfor an unknown menu or post. The link block carries the post's type, so it works for any post type.gutenberg_navigation_auto_add_page_on_publish()calls it. Its rule that a child page is skipped by a menu without its parent is unchanged.navigation-choose-menus-on-publish.phpregistersnavigation_menuson pages, a write-only REST field (a list of menu IDs).rest_pre_insert_pagekeeps the value for the request, and the status transition uses it in place of the setting: the page is added to exactly those menus the current user can edit, appended when the menu has no link to the parent. No menu's setting changes. A value sent with a request that does not publish is dropped onrest_after_insert_page.Editor
MaybeNavigationMenusPanelrenders oneCheckboxControlper menu, with "Under " as its description when the link would be nested, and an "Edit" link to the menu. The section is hidden for other post types and when the site has no menu.editPost( { navigation_menus: [ ...checked ids ] } ), so the choice travels with the publish request. Without a change nothing is sent and the server behaves as before.For plugins
To find the menus that take new pages, query
wp_navigationposts with thewp_navigation_auto_add_pagesmeta set.Testing Instructions
Automated
The spec from #85762 is folded into the new one, since the panel it tested is now the checkbox list.
Notes
gutenberg_and would becomewp_navigation_add_post_link()in Core.🤖 Generated with Claude Code
https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL