protected static function init($posts, $post_class)
{
$returned_posts = array();
if (is_null($posts)) {
$posts = array();
}
foreach ($posts as $post_object) {
$post_type = get_post_type($post_object);
$post_class_use = PostGetter::get_post_class($post_type, $post_class);
// Don't create yet another object if $post_object is already of the right type
if (is_a($post_object, $post_class_use)) {
$post = $post_object;
} else {
$post = new $post_class_use($post_object);
}
if (isset($post->ID)) {
$returned_posts[] = $post;
}
}
return self::maybe_set_preview($returned_posts);
}