function widget($args, $instance) { // outputs the content of the widget extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if (empty($title)) { $title = __('Posts Statistics', POSTSTATS_TEXTDOMAIN); } echo $before_title . $title . $after_title; PostStats::diplay_stats(); echo $after_widget; }
function format_time($time) { if ($time == 0) { $time = 1; } // Evite le temps de lecture nul $periods = array('years' => 86400 * 365, 'months' => 86400 * 31, 'days' => 86400, 'hours' => 3600, 'minutes' => 60, 'secondes' => 1); $reading = array(); foreach ($periods as $period => $duration) { if ($time >= $duration) { $nb = floor($time / $duration); $time -= $nb * $duration; $reading[] = $nb . ' ' . PostStats::periodl10n($period, $nb); } } return implode(', ', $reading); }