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:
+12
-4
@@ -177,16 +177,24 @@ function wp_notes_admin_menu() {
|
||||
3
|
||||
);
|
||||
|
||||
// "My Notes" — the main landing submenu (same slug as the parent
|
||||
// menu, so clicking either WP Notes or My Notes lands on the same
|
||||
// central dashboard: create form + active list + completed list).
|
||||
// "My Notes" — the main landing submenu. Same slug as the parent
|
||||
// menu so clicking either WP Notes or My Notes lands on the same
|
||||
// central dashboard (the parent's wp_notes_page_callback already
|
||||
// renders form + active list + completed list).
|
||||
//
|
||||
// CRITICAL: callback must be empty here. WordPress registers BOTH
|
||||
// the parent's and the submenu's callbacks against the same page
|
||||
// hook when slugs match, and runs them in order — passing
|
||||
// wp_notes_create_page as the callback caused a duplicate
|
||||
// "Create a New WP Note" form to render BELOW the main page
|
||||
// content. Empty callback means only the parent's renderer fires.
|
||||
add_submenu_page(
|
||||
'wp-notes', // Parent slug
|
||||
'My Notes', // Page title (browser tab)
|
||||
'My Notes', // Menu label (sidebar)
|
||||
'manage_options', // Capability
|
||||
'wp-notes', // Menu slug (matches parent → same page)
|
||||
'wp_notes_create_page' // Renderer
|
||||
'' // Empty callback — see comment above
|
||||
);
|
||||
|
||||
// Settings submenu
|
||||
|
||||
Reference in New Issue
Block a user