rendered paste body<?php
class Blitzkreig
{
function excerpt(){
echo $this->get_excerpt();
}
function get_excerpt($max_length){
global $post;
if (!$max_length) {
$max_length = 100;
}
// If they've manually put in an excerpt, let it go!
if ($post->post_excerpt) return $post->post_excerpt;
// Check to see if it's a password protected post
if ($post->post_password) {
if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) {
if(is_feed()) {
return __('This is a protected post');
} else {
return get_the_password_form();
}
}
}
if( strpos($post->post_content, '<!--more-->') ) { // There's a more link
$temp_ex = explode('<!--more-->', $post->post_content, 2);
$excerpt = $temp_ex[0];
} else {
$temp_ex = explode(' ', $post->post_content); // Split up the spaces
$length = count($temp_ex) < $max_length ? count($temp_ex) : $max_length;
for ($i=0; $i<$length; $i++) $excerpt .= $temp_ex[$i] . ' ';
}
$excerpt = $excerpt . '...';
$excerpt = balanceTags($excerpt);
$excerpt = apply_filters('the_excerpt', $excerpt);
return $excerpt;
}
function time_since(){
$older_date = abs(strtotime(get_the_time() . " GMT"));
$newer_date = false;
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);
$newer_date = ($newer_date == false) ? (time()+(60*60*get_settings("gmt_offset"))) : $newer_date;
$since = $newer_date - $older_date;
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
if (($count = floor($since / $seconds)) != 0) {
break;
}
}
$output = ($count == 1) ? '1 '.$name : "$count {$name}s";
if ($i + 1 < $j) {
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
$output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
}
}
echo $output;
}
}
$blitz = new Blitzkreig();