WordPress-Coding-Standards
WordPress-Coding-Standards copied to clipboard
Add check for WP_UNINSTALL_PLUGIN
Hello,
I'd like to suggest the following:
How about adding a notice if ! defined( 'WP_UNINSTALL_PLUGIN' ) is not present in uninstall.php files?
But what if the uninstall.php is not present in the plugin? I saw plugins that have no uninstall methods, simply because they aren't changing anything in the database, so nothing needs to be cleaned up.
I'd be fine with it in general, but it may be that uninstall.php actually just requires some other files, and it's those files which have the definition check in it (though that would be somewhat daft).
If there's no uninstall.php, then the sniff just continues.
@GaryJones agreed this could happen, agreed it would be somehow unorthodox. Maybe a warning would suffice instead of a downright error? Could be only in Wordpress-Extra coding standard ; we see many of these warnings popping up in the core and widely-used and accepted plugins, whereas failing to check for 'WP_UNINSTALL_PLUGIN gets a plugin softly rejected.
And yes, @dingo-d, this check would happen only in uninstall.php at the root of the plugin folder (as per the Plugin Development Guidelines as it's how it should be done when uninstalling with included file(s), if I'm not mistaken).