ux: make the "No notes found" empty-state notice dismissible

The inline notice on the My Notes page rendered with class="notice
notice-info" but no is-dismissible modifier, so WordPress's core
common.js never attached an X close button. Users had no way to
clear the empty-state message for the current view.

Audited every notice the plugin emits while I was in there — the
migration notice and the settings_errors() calls were already
correctly dismissible AND only fired in their intended state. The
empty-state notice was the only laggard. All four notice paths now
share the same contract: dismissible by the user, AND only rendered
when the underlying state warrants it.

Dismissal is per-page-load (WP core's default behavior — clicking X
hides the element for the current view only). Cross-page-load
persistence would need user_meta or a transient and isn't built
yet; flagged in the changelog for a future enhancement.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 07:51:39 +01:00
parent 3f881b01ca
commit 71df974a93
2 changed files with 26 additions and 1 deletions
+6 -1
View File
@@ -22,7 +22,12 @@ function wp_notes_display_notes($type = 'active') {
$section_title = ($type === 'active') ? 'Active Notes' : 'Completed Notes';
if (empty($notes)) {
echo '<div class="wp-notes-empty notice notice-info">';
/* is-dismissible adds an X button via WP core's common.js so
users can clear the empty-state message for the current view.
Dismissal is per-page-load (the message reappears on next
refresh if the list is still empty) — persistence across
reloads would need user_meta tracking and isn't built yet. */
echo '<div class="wp-notes-empty notice notice-info is-dismissible">';
echo '<p>' . esc_html__('No ' . ($type === 'active' ? 'active' : 'completed') . ' notes found.', 'a-wp-notes') . '</p>';
echo '</div>';
return;