id = $id;
$this->post_type = $post_type;
$this->format = $format;
$this->postInformation();
$this->postImage();
$this->setContent();
}
public function __toString() {
return $this->output;
}
public function setContent() {
$label = get_post_type_object($this->post_type)->labels->singular_name;
$post = get_queried_object();
if( $post->post_title)
$pre_title = $post->post_title;
elseif($post->name)
$pre_title = $post->name;
$output = '';
$output .= '
';
$output .= '
';
$output .= 'Featured '.ucfirst($label);
$output .= '';
$output .= '
';
$output .= '
';
$output .= $this->getMeta();
$output .= '
';
if($this->format == 'use-excerpt' && $this->excerpt ){
$output .= '';
}
// $output .= '
Read More ';
$output .= '
';
$this->output = $output;
}
private function postInformation() {
$id = $this->id;
$post = get_post($id);
$this->title = get_the_title($id);
$this->terms = get_the_term_list( $id, 'category', null, ', ' );
$this->date = get_the_date($this->date_format, $id );
$this->url = get_permalink($id);
$this->excerpt = get_the_excerpt($id);
$this->author = $post->post_author;
}
private function postVideo() {
if( benjamin_has_post_video() )
$this->video = benjamin_get_the_post_video_url();
}
private function postImage() {
$sizes = get_intermediate_image_sizes();
$thumb_id = get_post_thumbnail_id($this->id);
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
// we cannot use the default image because it interfeers with our user settings
if( strpos(reset($thumb_url_array), 'wp-includes/images/media/default.png') )
return false;
$this->image = $thumb_url_array[0];
}
public function getMeta(){
$id = $this->ID;
$aid = $this->author;
$m = get_the_time('m');
$d = get_the_date('F j');
$y = get_the_time('Y');
$month_url = get_month_link($y, $m);
$year_url = get_year_link($y);
$date = '';
$date .= '