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"]; ... }