Persistent Dismissible Notices self-updates
Makes all admin notices dismissible and persists their dismissal across sessions for notices with IDs.
by Robert DeVore · github.com/robertdevore/persistent-dismissible-notices · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/robertdevore/persistent-dismissible-notices/archive/refs/heads/main.zipShips its own WordPress updater (Plugin Update Checker), so new versions show up under Dashboard → Updates.
Readme
Persistent Dismissible Notices
Persistent Dismissible Notices is a free WordPress® plugin that enhances the handling of admin notices by making them dismissible and ensuring their dismissal persists across sessions.
If you've ever been frustrated by repeatedly dismissing the same notices, this plugin is for you. It stores the dismissal state for logged-in users, improving the user experience and decluttering your admin dashboard.
Features
- Automatically adds a "dismiss" button to all admin notices.
- Persists dismissal across sessions for notices with IDs.
- Automatically assigns unique IDs to notices without predefined
idattributes. - Works seamlessly with custom admin notices.
- Stores dismissed notices as user metadata for scalability and performance.
Why It's Useful
Admin notices are essential for communicating important information, but they can clutter the WordPress® dashboard when they lack a dismissal option or reappear on every page load.
Persistent Dismissible Notices solves this problem by ensuring:
- Cleaner dashboards: Dismissed notices stay dismissed, even after logging out and back in.
- User-friendly experience: No more redundant clicks to hide the same messages.
- Custom notice support: Works with notices from third-party plugins and themes.
Installation
- Download the plugin zip file or clone the repository.
- Upload the plugin to your WordPress® site:
- Go to
Plugins > Add New > Upload Plugin. - Select the zip file and click "Install Now."
- Go to
- Activate the plugin.
Alternatively, place the plugin folder in the wp-content/plugins directory and activate it via the WordPress® admin dashboard.
How to Use
- Default Behavior: The plugin automatically makes all admin notices dismissible, even those without an
idattribute. No configuration is required. - Persistent Dismissal:
- If a notice has an
idattribute, dismissing it will persist the dismissal across sessions. - For notices without an
id, the plugin generates a uniqueidbased on the notice content, ensuring dismissal persistence.
- If a notice has an
- Custom Notices: To ensure persistence, add a unique
idattribute to your custom admin notices.
Example:
// Notice with ID
add_action('admin_notices', function() {
echo '<div id="my-custom-notice" class="notice notice-info">This is a custom notice.</div>';
});
// Notice without ID
add_action('admin_notices', function() {
echo '<div class="notice notice-warning">This is a notice without an ID.</div>';
});
How It Works
- JavaScript: Assigns a unique
idto notices without one by hashing their content, adds a dismiss button to all admin notices, and handles dismissal via AJAX. - AJAX: Sends the dismissed notice ID (predefined or generated) to the server to store it in the current user's metadata.
- PHP: Filters out dismissed notices before they are rendered, ensuring they don't reappear once dismissed.
Development
Requirements
- WordPress® 5.0+
- PHP 7.4+
File Structure
persistent-dismissible-notices.php: Main plugin file.assets/js/dismissible-notices.js: Handles JavaScript for making notices dismissible.
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch (ex: feature/your-feature).
- Commit your changes and submit a pull request.
Support
If you encounter any issues or have questions, please open a GitHub issue 🙏
License
This plugin is licensed under the GPLv2 or later.
You are free to use, modify, and distribute it under the same terms.
Acknowledgments
- Special thanks to Robert DeVore for the initial creation and maintenance of this plugin.
- Maintained by WebDevStudios.
Read the full README on GitHub →
Releases
| Tag | Published |
|---|---|
| 1.0.0 | Dec 7, 2024 |
These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.
