fix: stop the duplicate "Create a New WP Note" form rendering at the bottom of My Notes

WordPress registers BOTH the parent menu's callback AND a submenu's
callback against the same page hook when they share a menu_slug, and
runs both in registration order. The My Notes submenu was passing
wp_notes_create_page as its callback (a separate bare-form renderer
used by the Tools-menu shortcut), so its output was being appended
below the main page content — appearing as a duplicate "Create a
New WP Note" form at the bottom of the My Notes page.

The submenu now passes an empty string as the callback — the
standard WP pattern when a submenu just relabels the parent (same
slug, same target page). Only the parent's wp_notes_page_callback
renders now.

The wp_notes_create_page function is unchanged and still serves
the Tools → My Notes shortcut at ?page=wp-notes-create.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 07:54:54 +01:00
parent 71df974a93
commit c773a21c25
2 changed files with 34 additions and 4 deletions
+22
View File
@@ -7,6 +7,28 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versi
## [Unreleased]
### Fixed — Duplicate "Create a New WP Note" form at the bottom of My Notes
A second, bare-bones *"Create a New WP Note"* form was being
rendered at the **bottom** of the My Notes page, below the active
and completed lists. The form at the **top** (the proper `Add New
Note` postbox with color/size/font/emoji controls) is the intended
one — the bottom one was a duplicate, redundant from a UX standpoint.
**Root cause:** WordPress registers BOTH the parent menu's callback
AND a submenu's callback against the same page hook when the two
share a `menu_slug`. When `?page=wp-notes` is requested, both fire
in registration order. The submenu was passing `wp_notes_create_page`
as its callback (a separate bare-form renderer used by the
Tools-menu shortcut), so its output was getting appended below the
main page.
**Fix:** the My Notes submenu now passes an **empty string** as the
callback — the standard WP pattern when a submenu just relabels the
parent (same slug, same target page). Only the parent's
`wp_notes_page_callback` renders now. The `wp_notes_create_page`
function is unchanged and still serves the Tools → My Notes
shortcut at `?page=wp-notes-create`.
### Fixed — Empty-state notice ("No notes found") now dismissible
The "No active notes found" / "No completed notes found" inline
notice on the My Notes page rendered with `class="notice notice-info"`