[wp-hackers] Question about the architecture of the admin widgets.php

Andrew Ozz admin at laptoptips.ca
Tue Jan 5 04:11:35 UTC 2010

Don't forget that JS is not like PHP, it's very easy to redeclare and 
overload. The "standard" hack for this is to do something like:

wpWidgets.save1 = wpWidgets.save;
wpWidgets.save = function(){
   check the widget;
   do what you need;

We could design some kind of JS hooks for core, probably based on custom 
events in jQuery (since they are so easy). Something like:

jQuery('body').trigger('eventName', [arg1, arg2]);

and plugins can do:

jQuery('body').bind('eventName', function(event, arg1, arg2){ ... });

But since everything can be redeclared easily, not sure if they are 
needed that much.

More information about the wp-hackers mailing list