function register_widgets() { foreach ($this->widget_groups as $key => $widget_group_settings) { if (!WPHF::element('id', $widget_group_settings)) { $widget_group_settings['id'] = WPHF::dash($key); } $this->widget_groups[$key] = new MY_Theme_Widget_Group($widget_group_settings); } $widgets = WPHF::directory_map(self::$widgets_path, FALSE, array('php')); // non-recursive foreach ($widgets as $key => $widget_file) { $widget_path = WPHF::d_path(array(self::$widgets_path, $widget_file)); // class.name-sub-sub.php -> MY_Name_Sub_Sub_Widget $widget_class = WPHF::underscore(preg_replace('/^(?:(?:class|abstract|functions)[-_.])?/i', 'MY_', basename($widget_file, '.php')), FALSE, FALSE, TRUE); // lower, path, camel $widgets[$key] = $widget_class; require $widget_path; } foreach ($widgets as $widget_class) { // do not instantiate 'abstract' classes if (preg_match('/_Base$/', $widget_class) == 0) { register_widget($widget_class); } } }