id = $id; $this->$post_type = $post_type; $this->format = $format; $this->post_information(); $this->post_image(); $this->set_content(); } public function __toString() { return $this->output; } public function set_content() { $post = get_queried_object(); if( $post->post_title) $pre_title = $post->post_title; elseif($post->name) $pre_title = $post->name; $output = ''; $output .= ''; $output .= $pre_title; $output .= ''; $output .= '

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

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

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

'; } $this->output = $output; } private function post_information() { $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 post_image() { $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]; } 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 = ''; $author .= ''; $author .= get_the_author_meta('display_name', $aid); $author .= ''; $author .= ''; return '' . $date . ' - ' . $author . ''; } }