public static function descend($post, $userparams = null)
{
$posts = null;
if ($userparams instanceof Posts) {
$posts = $userparams;
} else {
$defaultparams = array('where' => "pubdate <= '{$post->pubdate->sql}'", 'content_type' => $post->content_type, 'status' => $post->status, 'limit' => 2, 'orderby' => 'pubdate DESC');
if ($userparams == null) {
$userparams = array();
}
$params = array_merge($defaultparams, $userparams);
$params = Plugins::filter('descend_filters', $params, $post);
$posts = Posts::get($params);
}
if ($posts) {
// find $post and return the next one.
$index = $posts->search_id($post);
$target = $index + 1;
if (array_key_exists($target, $posts)) {
$descend = $posts[$target];
return $descend;
}
}
return false;
}