Skip to content

Navigation: Remove links to a permanently deleted post or term from Navigation Menus #85573

Open

Description

@jeryj

Part of #85148.

What problem does this address?

When a post or term is permanently deleted, the Navigation Link or Submenu block pointing at it stays in every wp_navigation post that links to it. The front end hides it and the editor flags it as invalid, but nothing removes it.

Classic menus handle this: _wp_delete_post_menu_item() and _wp_delete_tax_menu_item() delete the matching menu items on delete_post and delete_term. Trash and unpublish are read-time only in Core, and block menus already cover those at render time.

What is your proposed solution?

Match Core on permanent deletion, for bound links only:

  • On delete_post and delete_term, remove every Navigation Link block whose URL is bound to the deleted post or term (a core/post-data or core/term-data binding on url, which the link UI adds when a link is picked from the site's content) from every Navigation Menu, at any depth.
  • A link with a typed-in URL and no binding is left alone, even when it carries the ID.
  • A matching Navigation Submenu keeps its label and inner blocks and loses only its link attributes, so the menu structure stays in place.
  • Only rewrite a menu whose content changed.
  • Trash and unpublish stay as they are.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Block] Navigation[Status] In Progress[Type] Enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions