888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

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.

Fun Without Cliches
Fun cliches?
12 comments
page 861
Wordpress Chat
Wp chat themes?
3 comments
page 1308
Post Image The Easy Peasy Way
Wp custom field arrau thumbnails?
26 comments
page 1065
Dont Mess With My Toot Toot
Custom content types wordpress?
15 comments
page 599
Post Image The Easy Peasy Way
Wp change post image size?
26 comments
page 1065
Using Your Own Url Shortener
Use your domain as a url shortner?
4 comments
page 1190
Dont Mess With My Toot Toot
Dont mess with my toot toot?
15 comments
page 599
Six Million Ways To Die Choose One
Simply ways to die?
14 comments
page 1128
3 Ways To Speed Up Your Blog Without A Cache Plugin
Speed up disqus?
one comment
page 1321
Updating Code Snippets Here
Fun with plugins?
no comment
page 1338
Easy Peasy Images Suggestion Roundup
Display attached images within loop?
21 comments
page 1073
Html 5 Gallery
Wordpress and html5?
6 comments
page 1305
Post Image The Easy Peasy Way
Wp get attachment?
26 comments
page 1065
Post Image The Easy Peasy Way
Post image gallery wp?
26 comments
page 1065
Why I Ditched Disqus
Better than disqus?
5 comments
page 1175
Updating Code Snippets Here
Andy dp?
no comment
page 1338
Using Wordpress As A Php Framework
Wordpress php framework?
2 comments
page 335
Post Image The Easy Peasy Way
Get images attached to a post all images?
26 comments
page 1065
Why I Ditched Disqus
Disqus vs wordpress comments?
5 comments
page 1175
Poll Daddy Reviewed
Wordpress pie chart poll?
2 comments
page 42
Html 5 Gallery
Html 5 wordpress theme gallery?
6 comments
page 1305
Html 5 Gallery
Html 5 photo album?
6 comments
page 1305
Dont Mess With My Toot Toot
Dont mess with my toot toot?
15 comments
page 599
Why You Should Try Netbeans
Function of netbeans?
6 comments
page 973
Quick N Dirty Admin Login Screen
Css login screen?
no comment
page 128
Why I Ditched Disqus
Disqus wordpress static page?
5 comments
page 1175
Fun With Sidebar Tabs Styling
Sidebar vertical tab wordpress?
2 comments
page 336
Quick N Dirty Admin Login Screen
Login page css html?
no comment
page 128
Using Your Own Url Shortener
Url for your category in wordpress?
4 comments
page 1190
3 Ways To Speed Up Your Blog Without A Cache Plugin
Speed up web with html5 cache?
one comment
page 1321
My Experience Of Flexx
Why flexx is used?
4 comments
page 1026
Wpunlimited The Ultimate Wordpress Theme
Wordpress premium theme html 5?
3 comments
page 1141
Post Image The Easy Peasy Way
Image post?
26 comments
page 1065
  1 query every 3722 seconds, 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)