fix: hide unused wp_note CPT from admin UI to stop "Add New Note" misroute

The plugin registered a wp_note CPT with show_ui=true and show_in_menu=
'wp-notes', which caused WordPress to auto-inject "All Notes" and
"Add New" submenus under the WP Notes admin menu. The "Add New"
submenu routed to post-new.php?post_type=wp_note — the standard WP
post editor — but the live plugin stores notes in wp_options
(get_option('wp_notes')), not as CPT posts. Anyone clicking that
submenu ended up writing to the wrong storage and their note never
appeared in the WP Notes list.

Fix: show_ui and show_in_menu set to false on the wp_note CPT, and
show_ui / show_admin_column / show_in_rest set to false on the
wp_note_category taxonomy. The CPT/taxonomy remain registered so the
wp_notes_migrate_to_cpt() helper can still call wp_insert_post() —
just no admin UI side-effects until the migration is completed and
the live storage swaps over.

Also adds CHANGELOG.md in Keep-a-Changelog format with the
[Unreleased] entry for this fix and a 3.0.2 baseline note for the
"trimmed from v1.1.5 feature-creep" lineage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 07:26:04 +01:00
parent 433de27d9b
commit 05d8ad52ad
2 changed files with 81 additions and 6 deletions
+15 -6
View File
@@ -1513,14 +1513,20 @@ function wp_notes_register_cpt() {
$args = array(
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_in_menu' => 'wp-notes',
// show_ui=false: the live UI stores notes in wp_options, not as
// CPT posts. show_ui=true caused WordPress to auto-inject "All
// Notes" and "Add New" submenus that pointed at post-new.php and
// routed users into the standard post editor — which writes to
// the wrong storage. The CPT remains registered so the
// wp_notes_migrate_to_cpt() helper can still use wp_insert_post.
'show_ui' => false,
'show_in_menu' => false,
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array('title', 'editor', 'author', 'custom-fields'),
'has_archive' => false,
'menu_position' => null,
'show_in_rest' => true,
'show_in_rest' => false,
);
register_post_type('wp_note', $args);
@@ -1543,10 +1549,13 @@ function wp_notes_register_cpt() {
register_taxonomy('wp_note_category', 'wp_note', array(
'hierarchical' => true,
'labels' => $tax_labels,
'show_ui' => true,
'show_admin_column' => true,
// Hidden alongside the parent CPT — live UI doesn't surface
// categories yet, and showing the taxonomy in admin with the
// parent hidden would just dead-link.
'show_ui' => false,
'show_admin_column' => false,
'query_var' => true,
'show_in_rest' => true,
'show_in_rest' => false,
));
}
add_action('init', 'wp_notes_register_cpt');