id_base); echo $before_widget; echo $before_title; echo $title; echo $after_title; echo ""; echo $after_widget; } function update($new_instance, $old_instance) { $instance = array(); $instance['widget_title'] = $_POST['widget_title']; $instance['post_count'] = $_POST['post_count']; if ($_POST['show_thumb'] == 'on') { $instance['show_thumb'] = 'checked'; } if ($_POST['show_date'] == 'on') { $instance['show_date'] = 'checked'; } switch ($_POST['thumb_size']) { case 'thumbnail': $instance['thumb_selected'] = 'checked'; break; case 'medium': $instance['medium_selected'] = 'checked'; break; case 'large': $instance['large_selected'] = 'checked'; break; case 'full': $instance['full_selected'] = 'checked'; break; } $instance['thumb_size'] = $_POST['thumb_size']; $instance['post_excerpt'] = $_POST['post_excerpt']; if ($_POST['show_excerpt'] == 'on') { $instance['show_excerpt'] = 'checked'; } if (!empty($_POST['read_more'])) { $instance['read_more'] = $_POST['read_more']; } return $instance; } function form($instance) { echo " "; echo "
"; echo " "; echo "
"; echo " "; echo "
"; echo ""; echo "
"; echo "
"; echo "
"; echo ""; echo "
"; echo ""; echo "
"; echo ""; echo "
"; echo ""; echo "
"; echo '
'; echo " "; echo "
"; echo " "; echo "
"; echo " "; echo "
"; return $instance; } public function display_information_from_plugin($number_of_posts, $show_thumb, $thumb_size, $display_date, $post_excerpt, $show_excerpt, $read_more) { $tax_query_array = ''; if (!empty($content)) { $tax_query_array = array( array( 'taxonomy' => 'last-posts-tax', 'field' => 'slug', 'terms' => $content ) ); } $args = array( 'post_type' => 'last-posts', 'showposts' => $number_of_posts, 'tax_query' => $tax_query_array, 'orderby' => 'title', 'order' => "$order" ); $get_all_posts = get_posts($args); foreach ($get_all_posts as $get_post) { echo '
  • '; echo "
    " . $get_post->post_title . "
    "; if ($show_thumb) { echo "
    "; $this->display_posts_thumbnails($get_post->ID, $thumb_size); echo '
    '; } if ($display_date) { echo $get_post->post_date; } if ($show_excerpt) { echo $this->excerpt_length($get_post->post_content, $post_excerpt) . " " . $read_more . ""; } else { echo "
    " . $get_post->post_content . "
    "; } echo '
  • '; } } public function display_information_from_posts($number_of_posts, $show_thumb, $thumb_size, $display_date, $post_excerpt, $show_excerpt) { $tax_query_array = ''; if (!empty($content)) { $tax_query_array = array( array( 'taxonomy' => 'last-posts-tax', 'field' => 'slug', 'terms' => $content ) ); } $args = array( 'post_type' => '', 'showposts' => $number_of_posts, 'tax_query' => $tax_query_array, 'orderby' => 'title', 'order' => "$order" ); $get_all_posts = get_posts($args); foreach ($get_all_posts as $get_post) { echo '
  • '; echo "" . $get_post->post_title . ""; echo '
  • '; if ($show_thumb) { $this->display_posts_thumbnails($get_post->ID, $thumb_size); } if ($display_date) { echo $get_post->post_date; } if ($show_excerpt) { echo $this->excerpt_length($get_post->post_content, $post_excerpt); } else { echo $get_post->post_content; } } } public function display_posts_thumbnails($post_id, $thumb_size) { switch ($thumb_size) { case 'medium': $thumb_size = array(80, 80); break; case 'large': $thumb_size = array(120, 120); break; case 'full': $thumb_size = 'full'; break; default: $thumb_size = array(60, 60); break; } echo get_the_post_thumbnail($post_id, $thumb_size); } public function display_posts_date() { echo the_date(); } function excerpt_length($post_content, $post_excerpt_length) { $excerpted_sentence = implode(' ', array_slice(explode(' ', $post_content), 0, $post_excerpt_length)); return $excerpted_sentence; } public function enqueue_widget_style_css() { wp_enqueue_style('widget-styles.css', plugins_url('/styles/widget-styles.css', __FILE__)); wp_enqueue_style('widget-styles.css'); } } new Last_Posts_Widget(); ?>