A Demo Plugin to display how you might trigger a delayed admin notice.
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
admin
assets
.gitignore
LICENSE
README.md
plugin.php

README.md

Delayed Admin Notice Demo Plugin

A Demo Plugin to display how you might trigger a delayed admin notice.


This plugin demo's a simple way to create delayed admin notices in WordPress. This example specifically does the following: 1. Creates an option with the timestamp of the day/time the plugin was activated plus 30 days 2. When today's timestamp equals or is greater than the activation timestamp, a admin notice will appear only for Admins, and only on the plugins.php page.

The whole function was inspired by Julien Liabeuf's "WP-Review-Me" library which is a far more robust way of doing something similar.

Admin Notice Screenshot

Why It's Great

The last thing you want to do is annoy someone who is using your plugin. If you ask for a donation or review in a way that is bothersome most likely you'll get neither, unless it's a BAD review.

With that in mind, this notice does several things that have the end-user in mind.

  • Easily Configurable
  • Only appears on the Plugin page
  • Only appears to Admins, or Super Admins (on Multisite Networks)
  • Is permanently dismissable

How to Use it

  • STEP ONE
    Add the "admin/notice.php" file into your plugin folder
  • STEP TWO
    Add the code from plugin.php into the root file of your plugin. NOTE the register_activation_hook will only work in the root file of your plugin.
  • STEP THREE
    Do a search/replace for "your_prefix_" and change that to whatever you like
  • STEP FOUR
    Do a search/replace for "your-plugin-textdomain" and change that to whatever you like
  • STEP FIVE
    Customize the strings in notice.php for the following
    • $plugin_name = Your plugins name
    • $donate_url = The url you want to direct your users to in order to donate
    • $review_url = The url you want to direct your users to in order to leave a review

ALL DONE!