feat: persist empty-state notice dismissal via user_meta
The "No active/completed notes found" notice was already dismissible per-page-load (WP core's X button hides it), but pressing X only cleared it for the current view — it returned on the next refresh. The dismissal is now persisted to user_meta per-user-per-list-type, so once closed it stays closed across page loads until the flag is reset. MECHANICS - inc/wp-notes-display.php now checks get_user_meta(uid, 'wp_notes_dismissed_empty_<type>') before rendering and skips the notice render entirely when set. - New AJAX handler wp_ajax_wp_notes_dismiss_empty validates a nonce and the edit_posts capability, then writes the flag via update_user_meta(). type=active|completed; anything else 400s. - An inline jQuery handler in wp_notes_add_inline_scripts() listens for clicks on .wp-notes-empty .notice-dismiss (WP core's auto- injected X button) and fires the AJAX call. The visual hide is still WP core's job. - The notice element carries data-wp-notes-empty-type and a fresh per-render data-wp-notes-nonce for the round trip. RESET The flag is per-user-meta keyed wp_notes_dismissed_empty_active / wp_notes_dismissed_empty_completed. wp_delete_user removes them automatically. A UI button to reset dismissed notices is not built yet — flagged in the changelog as a future enhancement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,35 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versi
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### 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
|
||||
current view — it returned on the next refresh. The dismissal is
|
||||
now persisted to **user_meta** per-user-per-list-type, so once you
|
||||
close it, it stays closed until you reset the flag.
|
||||
|
||||
**Mechanics:**
|
||||
- `inc/wp-notes-display.php` checks
|
||||
`get_user_meta(uid, 'wp_notes_dismissed_empty_<type>')` before
|
||||
rendering and skips the notice entirely when set.
|
||||
- `wp_ajax_wp_notes_dismiss_empty` (new handler in `wp-notes.php`)
|
||||
validates a nonce + `edit_posts` capability, then writes the flag
|
||||
via `update_user_meta()`. Accepts `type` of `active` or
|
||||
`completed`; rejects anything else.
|
||||
- An inline jQuery handler in `wp_notes_add_inline_scripts()` listens
|
||||
for clicks on `.wp-notes-empty .notice-dismiss` (WP core's auto-
|
||||
injected X button), reads the data-attributes off the notice, and
|
||||
fires the AJAX call. WP core still handles the visual hide.
|
||||
- The notice element carries `data-wp-notes-empty-type` and a fresh
|
||||
per-render `data-wp-notes-nonce` for the round trip.
|
||||
|
||||
**Reset:** the flag is per-user-meta keyed
|
||||
`wp_notes_dismissed_empty_active` /
|
||||
`wp_notes_dismissed_empty_completed`. To make the notice reappear
|
||||
for a user, an admin can clear those keys (or `wp_delete_user`
|
||||
removes them automatically). A UI button to reset dismissed notices
|
||||
is not built yet — flagged as a future enhancement if needed.
|
||||
|
||||
### Fixed — Duplicate "Create a New WP Note" form at the bottom of My Notes
|
||||
A second, bare-bones *"Create a New WP Note"* form was being
|
||||
rendered at the **bottom** of the My Notes page, below the active
|
||||
|
||||
Reference in New Issue
Block a user