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

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

Callback function to publish scheduled posts, executed on cron
public static publish_scheduled_posts ( )
    public static function publish_scheduled_posts()
    {
        $select = array();
        // Default fields to select, everything by default
        foreach (Post::default_fields() as $field => $value) {
            $select[$field] = "{posts}.{$field} AS {$field}";
        }
        $select = implode(',', $select);
        $posts = DB::get_results('SELECT ' . $select . ' FROM {posts} WHERE {posts}.status = ? AND {posts}.pubdate <= ? ORDER BY {posts}.pubdate DESC', array(Post::status('scheduled'), DateTime::create()), 'Post');
        /** @var Post $post */
        foreach ($posts as $post) {
            $post->publish();
        }
    }