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:
2026-05-25 07:59:01 +01:00
parent 35920fea07
commit 3801cc283b
2 changed files with 43 additions and 37 deletions
+17 -37
View File
@@ -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() {
<?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
add_action('admin_footer', 'wp_notes_add_inline_scripts');
function wp_notes_add_inline_scripts() {