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);
         }
     }
 }
예제 #2
0
 /**
  * @see     class Walker_Page, function start_el
  */
 function nav_link_post_to_page($output, $count = FALSE, $smarttip = FALSE)
 {
     if ($this->is_single) {
         $pages = explode('<li', $output);
         $web_root = trailingslashit(get_bloginfo('url'));
         $current_category = WPHF::element($this->wp_query->query['category_name'], $this->categories);
         // key is slug
         if (!$current_category) {
             return $output;
         }
         foreach ($pages as &$page) {
             preg_match('/href="[-a-z:_\\/]+\\/([-a-z]+)"/i', $page, $matches);
             // get the last part
             // match wp format
             if (count($matches) < 2) {
                 continue;
             }
             $section_category = WPHF::element($matches[1], $this->categories);
             if ($section_category and $section_category->slug == $current_category->slug) {
                 $page = str_replace('class="', 'class="current_page_parent ', $page);
             } else {
                 $custom_routing = WPHF::element('children', WPHF::element($matches[1], $this->routing));
                 if ($custom_routing and in_array($current_category->slug, $custom_routing)) {
                     $page = str_replace('class="', 'class="current_page_ancestor ', $page);
                 }
             }
         }
         $output = implode('<li', $pages);
     }
     return $output;
 }