refactor: remove Tools → My Notes shortcut, redirect legacy URL to main page
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 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,32 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versi
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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)
|
### Added — Persistent dismissal of the empty-state notice (user_meta)
|
||||||
The "No active/completed notes found" notice was already
|
The "No active/completed notes found" notice was already
|
||||||
dismissible per-page-load, but pressing X only hid it for the
|
dismissible per-page-load, but pressing X only hid it for the
|
||||||
|
|||||||
+17
-37
@@ -498,18 +498,24 @@ function wp_notes_import_data() {
|
|||||||
}
|
}
|
||||||
add_action('admin_menu', 'wp_notes_admin_menu');
|
add_action('admin_menu', 'wp_notes_admin_menu');
|
||||||
|
|
||||||
// Tools → My Notes — quick-access shortcut for users who think of
|
// The Tools → My Notes shortcut used to live here and routed to a
|
||||||
// notes as a "tool" rather than navigating WP Notes from the top menu.
|
// separate bare-bones form at ?page=wp-notes-create. It was removed
|
||||||
function wp_notes_add_tools_menu() {
|
// as a duplicate — the My Notes page (and the admin-bar "New Note"
|
||||||
add_management_page(
|
// shortcut that jumps to its #new-note anchor) covers the same need
|
||||||
'My Notes', // Page title (browser tab)
|
// with the proper UI. Any stale bookmark to the old URL is caught
|
||||||
'My Notes', // Menu label (Tools submenu)
|
// by wp_notes_redirect_legacy_create_page() below.
|
||||||
'manage_options', // Capability
|
|
||||||
'wp-notes-create', // Menu slug
|
// Redirect anyone hitting the legacy ?page=wp-notes-create URL to
|
||||||
'wp_notes_create_page' // Renderer (same page as wp-notes)
|
// 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
|
// Enqueue Scripts
|
||||||
@@ -603,32 +609,6 @@ function wp_notes_emoji_picker_init() {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback function for the "My Notes" page (registered from both the
|
|
||||||
// WP Notes submenu and Tools → My Notes; both route here).
|
|
||||||
function wp_notes_create_page() {
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h1>Create a New WP Note</h1>
|
|
||||||
<form method="post">
|
|
||||||
<label for="wp_notes_text">Note:</label><br>
|
|
||||||
<textarea name="wp_notes_text" id="wp_notes_text" required></textarea><br>
|
|
||||||
<label for="wp_notes_color">Color:</label><br>
|
|
||||||
<input type="color" name="wp_notes_color" id="wp_notes_color" value="#000000"><br>
|
|
||||||
<label for="wp_notes_size">Size:</label><br>
|
|
||||||
<input type="number" name="wp_notes_size" id="wp_notes_size" min="8" max="72" value="16"><br>
|
|
||||||
<label for="wp_notes_font">Font:</label><br>
|
|
||||||
<select name="wp_notes_font" id="wp_notes_font">
|
|
||||||
<option value="Arial">Arial</option>
|
|
||||||
<option value="Helvetica">Helvetica</option>
|
|
||||||
<option value="Times New Roman">Times New Roman</option>
|
|
||||||
<option value="Verdana">Verdana</option>
|
|
||||||
</select><br>
|
|
||||||
<input type="submit" value="Add Note" class="button button-primary">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
// JavaScript for saving edited notes
|
// JavaScript for saving edited notes
|
||||||
add_action('admin_footer', 'wp_notes_add_inline_scripts');
|
add_action('admin_footer', 'wp_notes_add_inline_scripts');
|
||||||
function wp_notes_add_inline_scripts() {
|
function wp_notes_add_inline_scripts() {
|
||||||
|
|||||||
Reference in New Issue
Block a user