evolved_recent_posts_widget

The Evolved evolved recent posts widget class.

Defined (1)

The class is defined in the following location(s).

/admin/widgets/recent-posts-widget.php  
  1. class evolved_recent_posts_widget extends WP_Widget { 
  2.  
  3. /** 
  4. * Widget setup. 
  5. */ 
  6. function evolved_recent_posts_widget() { 
  7. /** Widget settings. */ 
  8. $widget_ops = array( 'classname' => 'evolved_tabbed_widget', 'description' => __('Displays a list of recent posts, reviews and videos in a tabbed widget', 'evolved') ); 
  9.  
  10. /** Widget control settings. */ 
  11. $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'evolved_tabbed_widget' ); 
  12.  
  13. /** Create the widget. */ 
  14. $this->WP_Widget( 'evolved_tabbed_widget', __('Evolved: Recent news, reviews & videos', 'evolved'), $widget_ops, $control_ops ); 
  15.  
  16. /** 
  17. * How to display the widget on the screen. 
  18. */ 
  19. function widget( $args, $instance ) { 
  20. extract( $args ); 
  21.  
  22. /** Our variables from the widget settings. */ 
  23. $number = $instance['number']; 
  24.  
  25. ?> 
  26. <div class="widget reviews_widget"> 
  27. <div class="tabs-wrapper"> 
  28.  
  29. <ul class="tabs-nav tabs"> 
  30. <li><a href="#"><?php _e('Reviews', 'evolved'); ?></a></li> 
  31. <li><a href="#"><?php _e('News', 'evolved'); ?></a></li> 
  32. <li><a href="#"><?php _e('Videos', 'evolved'); ?></a></li> 
  33. </ul> 
  34.  
  35. <ul id="tabs-1" class="reviews pane"> 
  36.  
  37. <?php 
  38.  
  39. /** Get all reviews **/ 
  40.  
  41. $query = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'evolved_game_reviews'); 
  42. $post = new WP_Query($query); 
  43. if ($post->have_posts()) : 
  44.  
  45.  
  46. ?> 
  47. <?php while ($post->have_posts()) : $post->the_post(); ?> 
  48.  
  49. <li> 
  50. <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> 
  51. <div class="entry-thumb"> 
  52. <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> 
  53. <?php the_post_thumbnail(); ?> 
  54. </a> 
  55. </div> 
  56. <?php endif; ?> 
  57.  
  58. <div class="entry-wrapper"> 
  59. <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> 
  60. <div class="entry-meta"> 
  61. <?php the_time('F j, Y') ?> | 
  62. <?php comments_popup_link(__('No comments', 'evolved'), __('1 comment', 'evolved'), __('Comments: %', 'evolved')); ?> 
  63. </div> 
  64.  
  65. <?php if(get_post_meta(get_the_ID(), "Evolved_score", true)) : ?> 
  66. <div class="rating-bar"> 
  67. <?php echo evolved_rating(get_post_meta(get_the_ID(), "Evolved_score", true)); ?> 
  68. </div> 
  69. <?php endif; ?> 
  70. </div> 
  71. </li> 
  72.  
  73. <?php endwhile; ?> 
  74.  
  75. <?php wp_reset_query(); ?> 
  76. <?php endif; ?> 
  77.  
  78. </ul> 
  79.  
  80. <ul id="tabs-2" class="news pane"> 
  81.  
  82. <?php 
  83.  
  84. $recent_posts = new WP_Query(array('showposts' => $number, 'post_status' => 'publish')); 
  85.  
  86. ?> 
  87.  
  88. <?php while($recent_posts->have_posts()): $recent_posts->the_post(); ?> 
  89.  
  90. <li> 
  91. <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> 
  92. <div class="entry-thumb"> 
  93. <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> 
  94. <?php the_post_thumbnail(); ?> 
  95. </a> 
  96. </div> 
  97. <?php endif; ?> 
  98. <div class="entry-wrapper"> 
  99. <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> 
  100. <div class="entry-meta"> 
  101. <?php the_time('F j, Y') ?> | 
  102. <?php comments_popup_link(__('No comments', 'evolved'), __('1 comment', 'evolved'), __('Comments: %', 'evolved')); ?> 
  103. </div> 
  104. </div> 
  105. </li> 
  106.  
  107. <?php endwhile; ?> 
  108. </ul> 
  109. <?php wp_reset_query(); ?> 
  110.  
  111. <ul id="tabs-3" class="video pane"> 
  112. <?php 
  113.  
  114. /** Get all reviews **/ 
  115.  
  116. $query = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'evolved_video'); 
  117. $loop = new WP_Query($query); 
  118. if ($loop->have_posts()) : 
  119.  
  120. ?> 
  121. <?php while ($loop->have_posts()) : $loop->the_post(); ?> 
  122.  
  123. <li> 
  124. <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> 
  125. <div class="entry-thumb"> 
  126. <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> 
  127. <?php the_post_thumbnail(); ?> 
  128. </a> 
  129. </div> 
  130. <?php endif; ?> 
  131.  
  132. <div class="entry-wrapper"> 
  133. <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> 
  134. <div class="entry-meta"> 
  135. <?php the_time('F j, Y') ?> | 
  136. <?php comments_popup_link(__('No comments', 'evolved'), __('1 comment', 'evolved'), __('Comments: %', 'evolved')); ?> 
  137. </div> 
  138. </div> 
  139. </li> 
  140.  
  141. <?php endwhile; ?> 
  142.  
  143. <?php wp_reset_query(); ?> 
  144. <?php endif; ?>  
  145. </ul> 
  146. </div> 
  147. <?php 
  148.  
  149. /** After widget (defined by themes). */ 
  150. echo $after_widget; 
  151.  
  152. /** 
  153. * Update the widget settings. 
  154. */ 
  155. function update( $new_instance, $old_instance ) { 
  156. $instance = $old_instance; 
  157.  
  158. /** Strip tags for title and name to remove HTML (important for text inputs). */ 
  159. $instance['number'] = strip_tags( $new_instance['number'] ); 
  160.  
  161. return $instance; 
  162.  
  163.  
  164. function form( $instance ) { 
  165.  
  166. /** Set up some default widget settings. */ 
  167. $defaults = array('number' => 3); 
  168. $instance = wp_parse_args( (array) $instance, $defaults ); ?> 
  169.  
  170. <!-- Number of posts --> 
  171. <p> 
  172. <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e('Number of posts to show', 'evolved') ?>:</label> 
  173. <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>" size="3" /> 
  174. </p> 
  175.  
  176.  
  177. <?php