How It Works
This section explains the technical behavior behind ID Admin Notices — how notices are classified, how visibility is enforced, how dismissals are tracked, and how data is stored.
Notice Classification
WordPress admin notices use CSS classes to indicate severity. The plugin reads these classes and splits notices into two groups:
- Operational notices —
.notice-error,.notice-warning,.notice-success. These are never touched by the plugin. No dismiss buttons are added, no visibility restrictions applied. - Informational notices —
.notice-info, generic.notice(no severity class), and.update-nag. These are only shown to designated users.
CSS Injection for Non-Designated Users
For non-designated administrators, the plugin injects a <style> block during the admin_head action:
.notice:not(.notice-error):not(.notice-warning):not(.notice-success),
.update-nag { display: none !important; }
Because this CSS loads before the page body renders, there is no flash of content — informational notices are never visible to non-designated users.
JavaScript for Designated Users
For designated users, the plugin loads a JavaScript file that processes each notice:
- Selects all
.noticeand.update-nagelements. - Skips any notice with
.notice-error,.notice-warning, or.notice-success. - For remaining notices, generates a hash from the notice text.
- If the hash matches a previously dismissed notice, hides it immediately.
- For
.update-nagelements, leaves them visible without a dismiss button. - For info and generic nag notices, adds a persistent dismiss button (or replaces an existing WordPress dismiss button to make it persistent).
Hash-Based Tracking
Each notice is identified by a djb2 hash of its trimmed text content, prefixed with idan_. This means:
- If a notice has the exact same text across different admin pages, dismissing it on one page hides it on all pages.
- If a notice changes its text (e.g., a version number updates), it’s treated as a new notice.
- The hash is deterministic — the same text always produces the same hash.
Data Storage
The plugin uses two WordPress options:
idan_settings— Stores the visibility mode (all_adminsorspecific_users) and the array of designated user IDs.idan_dismissed_notices— An associative array keyed by notice hash. Each entry contains a text preview (first 150 characters) and the dismiss date.
Auto-Pruning
Each time the dismissed notices list is read, entries older than 90 days are automatically removed. This prevents the option from growing indefinitely as plugins come and go.
Uninstalling
When the plugin is deleted (not just deactivated), both the idan_settings and idan_dismissed_notices options are removed from the database. Deactivating the plugin preserves all data.
