Example #1
0
function compact_archive($style = 'initial', $before = '<li>', $after = '</li>')
{
    $result = false;
    // if the Plugin Output Cache is installed we can cheat...
    if (defined('POC_CACHE')) {
        $key = 'c_a' . $style . $before . $after;
        $cache = new POC_Cache();
        $cache->timer_start();
        $result = $cache->fetch($key);
        if ($result) {
            $cache_time = sprintf('<!-- Compact Archive took %.3f milliseconds from the cache -->', 1000 * $cache->timer_stop());
        }
    }
    // ... otherwise we do it the hard way
    if (false === $result) {
        $result = utf8_encode(get_compact_archive($style, $before, $after));
        if (defined('POC_CACHE')) {
            $cache->store($key, $result);
        }
    }
    echo $result;
    if (defined('POC_CACHE')) {
        echo $cache_time;
    }
}
Example #2
0
function compact_archives_shortcode($atts)
{
    extract(shortcode_atts(array('style' => 'initial', 'before' => '<li>', 'after' => '</li>'), $atts));
    if ($before == "<li>") {
        $wrap = "<ul>";
    }
    if ($after == "</li>") {
        $wrap_end = "</ul>";
    }
    $string = $wrap . get_compact_archive($style, $before, $after) . $wrap_end;
    return $string;
}