From 3801cc283bf9fad147910cc5ca1e1d5686f64be1 Mon Sep 17 00:00:00 2001 From: David Keane Date: Mon, 25 May 2026 07:59:01 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20remove=20Tools=20=E2=86=92=20My=20N?= =?UTF-8?q?otes=20shortcut,=20redirect=20legacy=20URL=20to=20main=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Tools → My Notes" admin menu shortcut routed to a separate bare-bones create form at ?page=wp-notes-create with no notes list, no styling, no parity with the main My Notes page. It was a third route to "create a note" duplicating the two that already work better: the proper WP Notes → My Notes sidebar entry, and the admin- bar "New Note" quick-jump that lands on the same page's form. CHANGES - Removed the wp_notes_add_tools_menu() registration (add_management_page + its admin_menu hook). - Deleted the wp_notes_create_page() function in full — the bare-bones renderer, no longer referenced anywhere. - Added wp_notes_redirect_legacy_create_page() on admin_init: anyone hitting the legacy ?page=wp-notes-create URL (stale bookmark, old email link, etc.) is wp_safe_redirect()-ed to ?page=wp-notes. No 404 / no "insufficient permissions" page for old links. Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 26 +++++++++++++++++++++++++ wp-notes.php | 54 +++++++++++++++++----------------------------------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d2142..e5ad6ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,32 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versi ## [Unreleased] +### Removed — Tools → My Notes shortcut (with backward-compatible redirect) +The "Tools → My Notes" admin menu shortcut has been removed. It +routed to a separate bare-bones form at `?page=wp-notes-create` +rendered by `wp_notes_create_page()` — a stripped-down create form +with no notes list, no styling, and no parity with the main page. + +The shortcut was a third route to "create a note" duplicating the +two that already exist and work better: + +1. **WP Notes → My Notes** in the admin sidebar (the proper page — + styled form + active/completed lists + edit + restore). +2. **Admin bar → WP Notes → New Note** quick-access (jumps to the + form on the main page via `#new-note` anchor). + +**Backward-compat redirect:** anyone hitting the legacy +`?page=wp-notes-create` URL (stale bookmark, old email link, etc.) +is now `wp_safe_redirect()`-ed to `?page=wp-notes` via an +`admin_init` hook. No 404 / no "you do not have sufficient +permissions" page. + +**Code removed:** +- `wp_notes_add_tools_menu()` registration (the `add_management_page` + call and its `add_action('admin_menu', ...)` hook). +- `wp_notes_create_page()` function body in full — the bare-bones + form renderer, no longer referenced anywhere. + ### Added — Persistent dismissal of the empty-state notice (user_meta) The "No active/completed notes found" notice was already dismissible per-page-load, but pressing X only hid it for the diff --git a/wp-notes.php b/wp-notes.php index 68a3736..d20ff1c 100644 --- a/wp-notes.php +++ b/wp-notes.php @@ -498,18 +498,24 @@ function wp_notes_import_data() { } add_action('admin_menu', 'wp_notes_admin_menu'); -// Tools → My Notes — quick-access shortcut for users who think of -// notes as a "tool" rather than navigating WP Notes from the top menu. -function wp_notes_add_tools_menu() { - add_management_page( - 'My Notes', // Page title (browser tab) - 'My Notes', // Menu label (Tools submenu) - 'manage_options', // Capability - 'wp-notes-create', // Menu slug - 'wp_notes_create_page' // Renderer (same page as wp-notes) - ); +// The Tools → My Notes shortcut used to live here and routed to a +// separate bare-bones form at ?page=wp-notes-create. It was removed +// as a duplicate — the My Notes page (and the admin-bar "New Note" +// shortcut that jumps to its #new-note anchor) covers the same need +// with the proper UI. Any stale bookmark to the old URL is caught +// by wp_notes_redirect_legacy_create_page() below. + +// Redirect anyone hitting the legacy ?page=wp-notes-create URL to +// the My Notes page, so existing bookmarks don't 404 / show "you do +// not have sufficient permissions" after the Tools shortcut removal. +add_action('admin_init', 'wp_notes_redirect_legacy_create_page'); +function wp_notes_redirect_legacy_create_page() { + if (!is_admin()) { return; } + if (!isset($_GET['page'])) { return; } + if (sanitize_key(wp_unslash($_GET['page'])) !== 'wp-notes-create') { return; } + wp_safe_redirect(admin_url('admin.php?page=wp-notes')); + exit; } -add_action('admin_menu', 'wp_notes_add_tools_menu'); // Enqueue Scripts @@ -603,32 +609,6 @@ function wp_notes_emoji_picker_init() { -
-

Create a New WP Note

-
-
-
-
-
-
-
-
-
- -
-
-