[wp-hackers] Widget definitions inside classes

Sean Hickey seanhickey at gmail.com
Sun Aug 27 06:22:52 GMT 2006


> Thanks for that, though, as I mentioned before, static methods are no use in this case because I'd
> like access to $this.  Guess it's not possible - will probably encapsulate it as Alex suggested with
> a wrapper function.  This would be a nice addition to the Widgets plugin, though...

Then I guess I'm just confused.  The following code works fine for me.

class MyPlugin {
	function MyPlugin() {
		register_sidebar_widget('My Plugin', array(&$this, 'show'));
	}
	function show() {
		// Do something here
	}
}

- Sean
-- 
http://www.headzoo.com
http://www.480x.com


More information about the wp-hackers mailing list