Plugin reviews
WordPress plugins are a fun thing to maintain as a hobby, and one of the most enjoyable aspects is when you receive those great five star reviews 😀 To encourage this, I decided to use some code created a while back by Rhys Wynne. The idea is that we should prompt users to review the plugin, but we don’t want to pester them with messages about it. So Rhys’s code only asks the user after one week, and provides a link to opt out if they desire.
I’ve improved on this implementation a little, by making it only prompt once per network. On a multisite network, Rhys’s original code was prompting me to provide a review for every site, which was a tad irritating. With my version, only one administrator is asked to review and only once for their entire network of sites. The latest version also only displays the notice on the plugins page rather than the entire network, as some users had mentioned that the notice was distracting.
I also wrapped it up into a class, so that you can simply drop it into your projects, and added a prettier looking button and improved some of the text.
You can read about the original code by Rhys on his blog.
Implementation
Simply copy the following class into your plugin and instantiate it via the code shown below the class.
After you have included the class, instantiate it with arguments corresponding to your own plugin.
<?php new DotOrg_Plugin_Review( array( 'slug' => 'your-plugin-slug', // The plugin slug 'name' => 'Your plugins name', // The plugin name 'time_limit' => WEEK_IN_SECONDS, // The time limit at which notice is shown ) ); ?>
Samuel Aguilera says:
Looks like plugin_file arg is not used in any place, and the line that refers to it in the constructor throws an undefined index notice.
August 25, 2015 at 10:32 pm # //
Ryan says:
Thanks for noticing. That was used in an earlier version. I wasn’t aware that there were any references to it still left. I’ve removed it from the code now. Thanks for finding it 🙂
August 26, 2015 at 5:02 am # //