Pastoid

dynamic calls in plugin

The page you are looking at now is at this URL: http://pastoid.com/brl

This paste was last updated on July 23, 2009 at 8:47 am.

Pasted Coderaw

class ga_dashboard extends Plugin
{
 
	private $class_name = '';
	private $config = array();
	private $reports = array();
	private $funcs = array();
 
	public function action_init()
	{
		$this->class_name = strtolower( get_class( $this ) );
		$this->validate_reports( $this->load_available_reports() );
 
		// Add our template files for valid reports and register our functions
		foreach ( $this->reports as $rpt => $data ) {
			$this->add_template( $data['slug'], $data['template'] );
			// This is janky.  dynamic_dash_filter() is too.
			$this->funcs[$data['module']] = "$rpt";
			Plugins::register( array( $this, 'dynamic_dash_filter' ), 'filter', 'dash_module_' . $data['slug'] );
		}
	}
 
	public function dynamic_dash_filter( $module, $module_id, $theme )
	{
		// Pull a little magic sauce out of the params
		$searchVal = (string)$module['name'];
		// $rpt is set to the key of our reports array...
		$rpt = $this->funcs["$searchVal"];
	...
	} 
 
 

Toggle wordwrap

Referring DomainHits
Unknown Referer 127
pastoid.com 3
Is this paste spam?
<Hide