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

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

Returns an ascending post
public static ascend ( 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 ascending post
Результат Post The ascending post
    public static function ascend($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 ASC');
            if ($userparams == null) {
                $userparams = array();
            }
            $params = array_merge($defaultparams, $userparams);
            $params = Plugins::filter('ascend_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)) {
                $ascend = $posts[$target];
                return $ascend;
            }
        }
        return false;
    }