[wp-hackers] plugin framework class (was ]RE: [wp-hackers] [help] sink plugin hooks for $this)

Per Soderlind per at soderlind.no
Sat Jan 14 21:32:55 GMT 2006


> Owen Winkler wrote:
> While I'm thinking about it, would it be useful to produce a 
> plugin framework class, if not for the core then for general use?
> Something like (LIKE this, NOT this):
> 
> class pluginFramework {
> 	function pluginFramework() {
> 	// Do generic init stuff here?
> 	}
> 	function register_sinks() {
> 		$sinks = array_filter(get_class_methods($this), 
> array(&$this, 'filterSinks'));
> 		foreach($sinks as $sink) {
> 			add_filter($sink, array(&$this, '__'.$sink))
> 		}
> 	}
> 	function filterSinks($name) {
> 		return(substr($name, 0, 2) == '__');
> 	}
> 	function debug() {
> 	// Generic plugin debug stuff here...
> 	}
> }
> 
> And then you could do simple stuff like:
> 
> class myPlugin extends pluginFramework {
> 	funciton myPlugin() {
> 		$this->register_sinks();
> 	}
> 	function __admin_head() {
> 	// Output stuff in the admin head
> 	}
> 	function __admin_footer() {
> 		$this->debug($_GLOBALS);
> 	}
> }
> $myplugin = new myPlugin();
> 
> Such a framework could include functions to do more 
> complicated things like mess with TinyMCE, handle Ajax 
> requests ($this->handle_ajax('function_name'); //!!), or 
> respond differently when the plugin file is requested 
> directly, and would save me from having to package those 
> generic functions into every plugin I produce.


I agree, this is a nice idea. Anyone else been working on this?

../Per
 



More information about the wp-hackers mailing list