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: +3.32 kB (+0.04%) Total Size: 8.86 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. adds one note to every selected block in
|
…st fallback Register a boolean `wp_navigation_auto_add_pages` meta on Navigation Menus. While it is on, publishing a top-level page appends a link to the menu, the way classic menus do; existing items are never touched. The default menu a site creates for itself is now built from link blocks, one per published page, nested like the Page List block rendered them, with the setting on. The setting is a switch in the Navigation block's Settings tab and on the extensible site editor's navigation menu screen. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
The server appends a link to every menu with "Auto add pages" on, but the editor keeps its copy of the menu until a reload. Invalidate the loaded `wp_navigation` records when the page publish is received, the way saving a template invalidates the site record, so a Navigation block on the screen refetches and shows the new link. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
…ve button The navigation menu screen already saves the menu's items through the global Save button, so the setting becomes a pending edit to the same record instead of saving on its own. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
The setting is saved on its own in both the block inspector and the extensible site editor's navigation screen, so it never appears as a pending change in a save flow. Only the setting is sent; the menu's items are left to the editor's own save. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
… root reset When the root blocks are reset, the reducer preserves each controlled block's sub-tree but wrapped it in a new tree entry, so every nested controller saw a changed block list and reported it as an edit it did not make. Publishing a page refetches the template and resets the root blocks, and the Navigation block inside the header template part could report its stale children before it had applied the menu content refetched from the server, hiding the appended link until a reload. Reuse the previous entry when the preserved sub-tree is unchanged, and cover the "Show template" case in the auto-add e2e spec. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
…ve flow The setting is an edit to the menu record, so it now goes through `editEntityRecord` and is saved with the editor's other changes, like any other menu edit. The self-saving handler, its saving state and error notice are removed from both the block control and the extensible site editor toggle. The extensible site editor screen uses a Stack with a gap to space the toggle from the menu editor instead of a one-off margin rule. The two e2e tests that asserted the setting saved on its own now assert that the Save or Review changes button appears and that saving stores the setting. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
The "Auto add pages" hook skipped child pages, as classic menus do. It now adds a child page under the link to its parent when the menu has one: a Navigation Link for the parent becomes a Navigation Submenu with the same attributes, and an existing submenu gets the child appended. A menu with no link to the parent is left alone, so no orphan links are added. The page-link check is split out so the same match rule (page ID with the post-type kind or page type) finds the parent block. The toggle descriptions and the meta description no longer say "top-level". PHPUnit covers the link-to-submenu conversion, appending to an existing submenu, a grandchild, and a parent that is only linked by URL. The e2e spec publishes a child page and checks that the navigation block shows the parent as a submenu holding the child without a reload. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
0bb40a2 to
b3a1096
Compare
Creating a published page from the Navigation block's link UI fires the auto-add hook before the editor has saved its own link. The hook appends a link on the server, and the editor's pending block edit shadows that copy and overwrites it on save, so the menu ends up with a single link. Add an e2e test that documents this flow and asserts the saved menu links to the new page exactly once. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
…ent user A scheduled page publishes from cron with no user, so kses filters the menu content on save. Cover that path alongside the existing author test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
With no current user, kses filters the menu content on save and entity-encodes string attributes such as labels. The no-user test now covers an existing link next to the auto-added one, and the test helper slashes fixture content the way wp_insert_post expects. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
…hanged The no-user test compared an existing label against the entity-encoded form kses produces, which pins kses behavior the feature does not own. Compare the existing link block before and after the save instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
Open this PR in WordPress Playground. The latest successful plugin build I found is for |
Add the "Auto add new pages" setting without deciding what the default menu should be. The menu a site creates for itself is a Page List block again, as on trunk. The fallback filter, the page tree builders only it used and their tests are removed, and the default menu tests are back to trunk's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It goes in among the menu's page links in page order, so the file comment and the changelog now only say it is added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Conflicts were the changelogs and the controlled block reset in the block editor reducer. Trunk now leaves a controlled block's own tree entry without inner blocks on reset, and replaced that entry with a new object even when it already had none, which broke the stable reference for a nested controller. It is now replaced only when it has inner blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trunk now requires new files in the e2e tests to be TypeScript (#84829). Menus with the setting 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>
# Conflicts: # packages/block-editor/CHANGELOG.md # packages/block-library/CHANGELOG.md # packages/block-library/src/private-apis.js # packages/core-data/CHANGELOG.md
…mpat folder WordPress 7.2 has branched, so new features now target 7.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The WordPress 7.3 compat folder is analyzed at PHPStan's strict level. Give the block arrays value types, read nested block fields only when they are arrays, and state the void returns. A link whose page ID isn't numeric is skipped, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… site editor screens In the site editor's navigation sidebar, the setting is now the screen's footer, which sticks to the bottom of the sidebar. In the extensible site editor, it sits at the bottom of the menu screen and stays there while the list scrolls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # packages/block-editor/CHANGELOG.md # packages/block-library/CHANGELOG.md # packages/block-library/src/navigation/edit/menu-inspector-controls.tsx
# Conflicts: # packages/core-data/CHANGELOG.md
# Conflicts: # packages/block-library/CHANGELOG.md
…eside scoped Page Lists - core-data: when a refetch brings content that changed on the server and the record has no unsaved changes, drop the blocks kept as a transient edit since its last save. A menu edited and saved earlier in the session now shows the link a page publish added, and its next save keeps it. - Save the menu with kses off and filter only the new link's label when the publisher can't post unfiltered HTML, so a page publish no longer strips the menu's existing markup or encodes its URLs. - Skip a menu only when one of its Page Lists shows the new page. A Page List limited to one parent page no longer stops other pages from being added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- core-data: drop a refetched record's transient blocks only when they still serialize to the saved content, so typing that continued in the same attribute after a save isn't lost. - Lift only the `content_save_pre` kses filter, at its own priority, for the menu save, instead of removing and re-adding every kses filter, so a site's other kses settings stay as they were. - Read a Page List's `parentPageID` as the block validates it, and count a page as listed only when its parent pages up to the Page List's are published, as the Page List renders them. - Correct the docblock on nesting: with submenus set to open on click, the parent's item opens the submenu, as in a Page List. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- core-data: don't drop a refetched record's transient blocks when a save changed its stored content while the request was out, since the response is then older than what was saved. - Lift every kses filter on the post fields for the menu save, at their own priorities, so the menu's title isn't filtered again either. - Sort titles by the new link ignoring accents as well as case, closer to the database collation the Page List sorts by. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Render the switch only when the menu's REST meta lists the setting, so a WordPress release without the server side doesn't show a switch that resets after saving. - Keep the site editor's menu screen in place while the menu is fetched again after a page publish, instead of swapping it for a spinner, which dropped focus. - Describe the setting as "Adds pages to this navigation when they are published.", the wording the Page List PR uses: the old copy said existing pages are never added, but a draft is added when it publishes. - Cover `getEntityRecord.shouldInvalidate` for menus with unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Leave the site editor's menu screen without its footer when the menu has no "Auto add new pages" setting, instead of an empty bordered bar, as the extensible site editor already does. - Read the transient blocks through `select?.` like the saved content, in the resolver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #85156
What?
Adds an "Auto add new pages" setting to Navigation Menus.
_wp_auto_add_pages_to_menu()for classic menus, which only adds top-level pages.wp_navigationrecords in core-data, so a Navigation block on screen picks up the added link without a reload, also when the menu was edited and saved earlier in the session.The Page List block is untouched, and the default menu a site creates for itself is still a Page List block, as on trunk. Whether that default should change is left for later.
Why?
The Page List block is a live mirror of the page tree, which makes a menu built on it impossible to edit without first detaching it into links, and once detached it no longer picks up new pages. Classic menus solved the same problem fifteen years ago with an append-only "Automatically add new top-level pages" option that coexists with manual editing. This brings that model to block menus.
How?
lib/compat/wordpress-7.3/navigation-auto-add-pages.phpregisters a booleanwp_navigation_auto_add_pagespost meta onwp_navigation(and addscustom-fieldssupport so the RESTmetafield is exposed), and hookstransition_post_statusto add links.core/post-dataURL binding the Page List "Detach" conversion adds, so permalink changes follow the page. Links to pages that are later unpublished or deleted are already hidden byblock_core_shared_navigation_item_should_render().packages/block-library/src/navigation/edit/auto-add-pages-control.tsxandroutes/navigation-edit/auto-add-pages-toggle.tsxread the setting from the editedwp_navigationrecord and change it witheditEntityRecord, so the menu shows up as a changed entity in the save panel and saves with everything else. The route gains a dependency on@wordpress/uifor the switch.getEntityRecord.shouldInvalidatein@wordpress/core-datanow invalidateswp_navigationrecords when a page save carryingstatus: publishis received, following the existing precedent that invalidates the site record when a template is saved. The site editor's menu screen keeps showing the menu while it is fetched again, instead of a spinner, so focus stays put.getEntityRecordresolver now drops a record's transient edits when a refetch brings content that changed on the server, the record has no unsaved changes, and its blocks still serialize to the saved content, so the editor parses the new content. A refetch that brings the same content, of a record with unsaved changes, of blocks holding typing that wasn't saved yet (typing that continues in the same attribute after a save changes only the blocks), or one that started before a save landed, keeps them.Known limitations
unfiltered_htmlsaving a link URL with&, for example), the editor can't tell its blocks match the saved menu, so it keeps showing them after a page publish, and the next save of the menu drops the added link, as before this PR's refetch handling.gutenberg-real-time-collaborationexperiment on, eachwp_navigationpost is a synced CRDT document. The append runs server-side throughwp_update_post, outside that document, so a collaboration client already holding the menu does not learn about the link and its next save of the menu writes its own copy back over it. Routing the append through the sync layer is a separate change.Side effects
wp_navigationgainscustom-fieldssupport so the setting's meta is exposed through REST. The Real-Time Collaboration experiment decides which post types sync by that same support, so with the experiment on, Navigation Menus become collaborative entities and the CRDT document is persisted into the menu's post meta on save. On trunk they are excluded. This is noted here so it is a deliberate change: the menu is edited through the Navigation block inside another post's editor rather than as the current post, and that path has not been exercised with collaboration yet.custom-fieldssupport also registers thefootnotesmeta onwp_navigation(register_block_core_footnotes_post_meta()registers it for every post type that supportseditor,custom-fieldsandrevisions). Menus then expose an emptymeta.footnotesin REST and keep it in their revisions.unfiltered_html; only the new link's label is filtered for that user. PHPUnit tests cover both, with an existing item whose label and URL kses would change.Testing Instructions
gutenberg-extensible-site-editorexperiment on, open Appearance > Navigation, open a menu. Flip the switch below the menu's links: the "Review 1 change…" button appears, and saving from it stores the setting.Automated coverage:
phpunit/navigation-auto-add-pages-test.php,test/e2e/specs/editor/blocks/navigation-auto-add-pages.spec.ts(including the "Show template" case with the menu in the header template part) andtest/e2e/specs/site-editor/navigation-auto-add-pages.spec.ts, plus a block editor reducer unit test for the reset behavior and core-data resolver unit tests for the refetch.🤖 Generated with Claude Code
https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL