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() { -