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 ', 'benjamin') . ucfirst($label); $output .= ''; $output .= '

'; $output .= '' . $this->title . ''; $output .= '

'; $output .= '
'; $output .= $this->getMeta(); $output .= '
'; if ($this->format == 'use-excerpt' && $this->excerpt) { $output .= '

'; $output .= $this->excerpt; $output .= '

'; } $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 = esc_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 .= '' . $d . ', '; $date .= '' . $y . ''; $author = ''; if (function_exists('coauthors_posts_links')) { $author .= coauthors_posts_links(null, null, null, null, false); } else { $author .= ''; $author .= get_the_author_meta('display_name', $aid); $author .= ''; } $author .= ''; $cats = ''; // benjamin_get_cpt_custom_tax_terms($this->id); if ($categories_list = benjamin_get_the_category_list($this->id)) { $cats = '' . __('Posted in ', 'benjamin') . $categories_list . ''; } return '' . $date . ' - ' . $author . '
' . $cats; } }