';
foreach ($boxes as $box) {
echo sprintf('
', $box->ID) . $box->get_content() . '
';
}
echo '
';
}
/**
* Get an array of Box objects. These are the boxes that will be loaded for the current request.
*
* @return Box[]
*/
public function get_matched_boxes()
{
static $boxes;
if (is_null($boxes)) {
if (count($this->box_ids_to_load) === 0) {
$boxes = array();
return $boxes;
}
// query Box posts
$posts = get_posts(
array(
'post_type' => 'boxzilla-box',
'post_status' => 'publish',
'post__in' => $this->box_ids_to_load,
'numberposts' => -1
)
);
// create `Box` instances out of \WP_Post instances
$boxes = array();
foreach ($posts as $key => $post) {
$box = new Box($post);
// skip boxes without any content
if ($box->get_content() === '') {
continue;
}
$boxes[ $key ] = $box;
}
}
return $boxes;
}
}