_directory === $directory) { // add year to the list (do not closes li, because // we may have nested elements) $this->_year = $file; $lnk = get_year_link($file); $this->_htmllist[$this->_year] = "
  • 20$file"; return 1; } elseif (is_dir($f)) { $this->_months[] = $file; return 0; } } } function _exitingDir($directory = null, $file=null) { $y = $this->_year; if ($mos =& $this->_months) { sort($mos); $list = ''; $linearlist = array(); foreach($mos as $mth) { $lnk = get_month_link($y, $mth); $the_month = theme_date_format( mktime(0, 0, 0, $mth, 1, 0 ), '%B'); $list = "
  • ". $the_month .'
  • ' . $list; $linearlist["$the_month 20{$this->_year}"] = $lnk; } $list = ''; } $mos = array(); // we close year's li $this->_list[$y] = $linearlist; $this->_htmllist[$y] .= $list . ''; } function getList() { krsort($this->_list); return $this->_list; } function getHtmlList() { krsort($this->_htmllist); return implode($this->_htmllist); } } function plugin_archives_head() { global $PLUGIN_ARCHIVES_MONTHLIST; $PLUGIN_ARCHIVES_MONTHLIST = new plugin_archives_monthlist; echo "\n\n"; foreach($PLUGIN_ARCHIVES_MONTHLIST->getList() as $y => $months) { foreach ($months as $ttl => $link) echo "\n"; } echo "\n\n"; } add_filter('wp_head', 'plugin_archives_head'); function plugin_archives_widget() { lang_load('plugin:archives'); global $lang, $PLUGIN_ARCHIVES_MONTHLIST; return array( 'subject' => $lang['plugin']['archives']['subject'], 'content' => ($list = $PLUGIN_ARCHIVES_MONTHLIST->getHtmlList()) ? '' : "

    {$lang['plugin']['archives']['no_posts']}

    " ); } register_widget('archives', 'Archives', 'plugin_archives_widget'); ?>