Habari\Posts::descend PHP Метод

descend() публичный статический Метод

Returns a descending post
public static descend ( Post $post, array $userparams = null ) : Post
$post Post The Post from which to start
$userparams array The params by which to work out what is the next descending post
Результат Post The descending post
    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;
    }