function _get_assets($type) { if (!empty($this->stores[$type])) { return; } $extensions = $this->_get_extensions($type); $store =& $this->stores[$type]; $path = WPHF::d_path(array($this->handle, $this->dirs[$type])); $url = WPHF::path(array($this->url, $this->dirs[$type])); $store = WPHF::directory_map($path, FALSE, $extensions); $store = WPHF::md_array_flatten($store, TRUE); asort($store); foreach ($store as &$file) { $path = pathinfo($file); $file = array('file' => $path['filename'], 'url' => WPHF::path(array($url, $file)), 'deps' => array(), 'ver' => MY_TVERSION); } if ($method = '_filter_' . $type and method_exists($this, $method)) { $this->{$method}(); } else { foreach ($store as $key => $file) { if (strncmp($file['file'], '_', 1) == 0) { $store[] = $store[$key]; unset($store[$key]); } } } }
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); } } }