WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

Add check for WP_UNINSTALL_PLUGIN

Open froger-me opened this issue 7 years ago • 3 comments

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?

froger-me avatar Apr 22 '18 23:04 froger-me

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.

dingo-d avatar Apr 23 '18 09:04 dingo-d

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 avatar Apr 23 '18 10:04 GaryJones

@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).

froger-me avatar Apr 23 '18 10:04 froger-me