Repository navigation
Conversation
…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
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
🤖 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. As a site builder, I want to insert a core navigation overlay pattern with CTA and see it on the frontend in
|
…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
0b0f875 to
97440ea
Compare
…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
97440ea to
cca490b
Compare
…f links The setting belongs to the menu's content, not to the block, so it follows the List View of the menu's links in every place that list is shown: the block inspector's List View tab, the site editor's navigation sidebar, and the extensible site editor's navigation menu screen. It leaves the block's Settings tab, and the control guards itself with the user's permission to update the menu. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
cca490b to
95ca50a
Compare
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>
Trunk now requires new files in the e2e tests to be TypeScript (#84829). Pages are created through the REST API, since `createPage()` is typed with only the page's ID and status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
…-delete # Conflicts: # lib/load.php
…lder 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>
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, read the URL binding's source with `_wp_array_get()`, and state the void returns. 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 #85573. Part of #85148.
Branched off #84508. This branch sits on top of
try/auto-add-pages, so the diff shows that PR's commits until it merges; only the last two commits belong here. Review the auto-add PR first, since it introduces the server-side menu write this one builds on.What?
When a post or term is permanently deleted, every Navigation Link block bound to it is removed from every Navigation Menu. A bound Navigation Submenu keeps its label and inner blocks and loses only its link attributes.
Why?
Classic menus drop their items on
delete_postanddelete_term(_wp_delete_post_menu_item()and_wp_delete_tax_menu_item()). Block menus never did, so a deleted page's link block stayed in everywp_navigationpost forever: hidden on the front end, flagged as invalid in the editor, never removed.How?
New
lib/compat/wordpress-7.3/navigation-remove-deleted-links.php, hooked ondelete_postanddelete_term.urlcarries acore/post-databinding (post) or acore/term-databinding (term) and itsidis the deleted object. That is what the link UI writes for a link picked from the site's content. A link with a typed-in URL and no binding is left alone, even when it carries the ID.wp_navigationpost is checked, any status, at any depth. A cheap string check for the ID runs beforeparse_blocks, and a menu is only saved when something changed.id,url,kind,typeand theurlbinding, so the menu structure stays in place. It renders as an anchor withouthref.innerContent, so a wrapper with its own HTML keeps that HTML.unfiltered_html. Since WordPress 7.2 kses parses block JSON and re-encodes it, so the menu structure and the remaining links survive; string attributes may come back entity-encoded (&as&in a label). A PHPUnit test covers the no-user save.Testing Instructions
PHPUnit:
npm run test:unit:php:base -- --filter Gutenberg_Navigation_Remove_Deleted_Links_Test. E2E:npm run test:e2e -- test/e2e/specs/editor/blocks/navigation-deleted-links.spec.ts.Known limitation
An editor that already has the menu loaded with unsaved edits overwrites the server change on save. Same as the "Auto add new pages" setting in #84508.
🤖 Generated with Claude Code
https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL