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); } } }
function nav_add_section_description($output) { $pages = explode('<li', $output); $web_root = trailingslashit(get_bloginfo('url')); foreach ($pages as &$page) { $matches = array(); preg_match('/href="([^"]+)"/i', $page, $matches); // match base-theme's format // _log($matches); if ($url = WPHF::element(1, $matches) and $url === FALSE) { continue; } $cat_slug = WPHF::underscore(str_replace($web_root, '', $url), TRUE, TRUE); // do i, is path if ($cat_id = $this->{"cat_id_{$cat_slug}"} and $cat_id !== FALSE) { $category = get_category($cat_id); $page = preg_replace('/title\\="[^"]*"/i', 'title="' . esc_attr($category->description) . '"', $page); } } $output = implode('<li', $pages); return $output; }