Ferodynamics Network

popular: profile privacy, mobile privacy

January 15, 2008

Uninstall Banner

This going to be my last post on the issue uninstallers for WordPress plugins. This is an explanation of the code I have submitted to the WordPress trac, and a plugin to give you an idea of what it does differently to the previous two versions I produced.

I think it is important to note that although I have submitted this code for inclusion in the core, that doesn’t mean it will be included exactly as I submitted it, or even that it will be included at all, but I am hopeful.

In the first version a separate file was required, but it was fairly evident that this wasn’t going to be the best solution. The second version changed this, allowing the plugin author to register a callback function, and added functions to help ringfence the uninstall content from the live plugin content.

In the final version not even this is necessary.

The most important function in version three is register_plugin_assets(). This function, used in an activation function allows the plugin author to register the options they intend to add to WordPress, the database tables they intend to add, and to register a callback function within the plugin itself.

[php]
register_plugin_assets( $plugin_file , $callback , $options = array() , $tables = array() );

Registering the tables and options lets WordPress take care of uninstalling those, meaning that the plugin author doesn’t need to write any code at all to handle uninstallation unless it requires more complex changes or file deletions. In many cases $callback can be set to NULL.

If a callback function is registered, before the tables and options are removed, the plugin will be loaded to allow the callback function to be used. There is no longer a need to ringfence that code; however, it will mean that plugin authors need to be careful about what their plugin does that isn’t triggered by a hook.

On the surface the process works the same. When a plugin is deactivated, and there is something to uninstall, the uninstall option will be presented beneath the plugin entry. Although, the discussion on the trac is that it may be in a table column of its own I have left it as per previous versions as that is what I actually submitted and because of the limitations of doing it as a plugin.

You can download Fun with Uninstallation 0.3 here.

The plugin is as close to the code I submitted. As it was written for the version of WordPress currently in development I haven’t done much testing on it outside of that. The version I tested the plugin on was 2.3.2.

Post Image The Easy Peasy Way
26 comments
page 1065
Quick N Dirty Admin Login Screen
no comment
page 128
Wordpress Chat
one comment
page 1308
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Silence Is Golden
3 comments
page 213
Questions About Habari For Wordpress Users
6 comments
page 424
Theming Habari Vs Wordpress
13 comments
page 440
My Experience Of Flexx
4 comments
page 1026
Plugin Update Fun With Photo Data 2
one comment
page 815
Post Image The Easy Peasy Way
26 comments
page 1065
Categories Vs Tags Either Neither Or Both
12 comments
page 7
Gaining Benefits From Plugins
8 comments
page 1167
Fun With Theme Widgets
24 comments
page 867
Beware Wp Cache
8 comments
page 1310
Six Million Ways To Die Choose One
14 comments
page 1128
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Wordpress Chat
one comment
page 1308
Post Image The Easy Peasy Way
26 comments
page 1065
Wordpress Chat
one comment
page 1308
Beware Wp Cache
8 comments
page 1310
Wp Polls Reviewed
one comment
page 58
Fun With Photo Data
12 comments
page 330
Html 5 Gallery
6 comments
page 1305
Fun With Sidebar Tabs Styling
2 comments
page 336
Using Your Own Url Shortener
4 comments
page 1190
Html 5 Gallery
6 comments
page 1305
My Experience Of Flexx
4 comments
page 1026
Fun With Sidebar Tabs
193 comments
page 57
Html 5 Gallery
6 comments
page 1305
Fun With Plugins
27 comments
page 14
Wordpress 25 Exif Fields
12 comments
page 230
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
  updated 1 seconds ago
Tuesday, 9pm
wesley

Well, some people might still want to use it for backwards compatability with older wp versions. Never mind though, as I see the source code in the trac. Thanks

Tuesday, 5pm
Andrew Rickmann

Wesley,

The downloads have been removed because they are not relevent any more. The patch I submitted has been completely changed. Uninstallation for plugins will be available as part of the delete process in WP 2.7 a version of the plugin generator that supports it will be released soon.

I also found some people were misunderstanding the point of the plugins. It was to illustrate an idea but had no practical value outside that. Some people thought it would clean out their plugin settings for plugins they didn’t want any more.

Tuesday, 9am
wesley

None of your downloads work (v1, 2, 3)