evolve_Tabs_Widget

The evolve evolve Tabs Widget class.

Defined (1)

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

/library/functions/tabs-widget.php  
  1. class evolve_Tabs_Widget extends WP_Widget { 
  2.  
  3. function __construct() { 
  4. parent::__construct( 
  5. 'evolve_tabs-widget', __('evolve: Tabs', 'evolve'), // Name 
  6. array('classname' => 'evolve_tabs', 'description' => __('Popular posts, recent post and comments.', 'evolve'), ) // Args 
  7. ); 
  8.  
  9. function widget($args, $instance) { 
  10. global $data, $post; 
  11.  
  12. extract($args); 
  13.  
  14. $posts = $instance['posts']; 
  15. $comments = $instance['comments']; 
  16. $tags_count = $instance['tags']; 
  17. $show_popular_posts = isset($instance['show_popular_posts']) ? 'true' : 'false'; 
  18. $show_recent_posts = isset($instance['show_recent_posts']) ? 'true' : 'false'; 
  19. $show_comments = isset($instance['show_comments']) ? 'true' : 'false'; 
  20. $show_tags = isset($instance['show_tags']) ? 'true' : 'false'; 
  21. $orderby = $instance['orderby']; 
  22.  
  23. if (!$orderby) { 
  24. $orderby = 'Highest Comments'; 
  25.  
  26. echo $before_widget; 
  27. ?> 
  28. <div class="tab-holder"> 
  29. <div class="tabs-wrapper"> 
  30. <ul id="tabs" class="tabset tabs"> 
  31. <?php if ($show_popular_posts == 'true'): ?> 
  32. <li><a href="#tab-popular"><?php _e('Popular', 'evolve'); ?></a></li> 
  33. <?php 
  34. endif; 
  35. if ($show_recent_posts == 'true'): 
  36. ?> 
  37. <li><a href="#tab-recent"><?php _e('Recent', 'evolve'); ?></a></li> 
  38. <?php 
  39. endif; 
  40. if ($show_comments == 'true'): 
  41. ?> 
  42. <li><a href="#tab-comments"><?php _e('Comments', 'evolve'); ?></a></li> 
  43. <?php endif; ?> 
  44. </ul> 
  45. <div class="tab-box tabs-container"> 
  46. <?php if ($show_popular_posts == 'true'): ?> 
  47. <div id="tab-popular" class="tab tab_content" style="display: none;"> 
  48. <?php 
  49. if ($orderby == 'Highest Comments') { 
  50. $order_string = '&orderby=comment_count'; 
  51. } else { 
  52. $order_string = '&meta_key=evolve_post_views_count&orderby=meta_value_num'; 
  53. $popular_posts = new WP_Query('showposts=' . $posts . $order_string . '&order=DESC'); 
  54. if ($popular_posts->have_posts()): 
  55. ?> 
  56. <ul class="news-list"> 
  57. <?php while ($popular_posts->have_posts()): $popular_posts->the_post(); ?> 
  58. <li> 
  59. <?php if (has_post_thumbnail()): ?> 
  60. <div class="image"> 
  61. <a href="<?php the_permalink(); ?>"> 
  62. <?php the_post_thumbnail('tabs-img'); ?> 
  63. </a> 
  64. </div> 
  65. <?php endif; ?> 
  66. <div class="post-holder"> 
  67. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
  68.  
  69. <div class="meta"> 
  70. <?php the_time(get_option('date_format')); ?> 
  71. </div> 
  72. </div> 
  73. </li> 
  74. <?php endwhile; ?> 
  75. </ul> 
  76. <?php endif; ?> 
  77. </div> 
  78. <?php 
  79. endif; 
  80. if ($show_recent_posts == 'true'): 
  81. ?> 
  82. <div id="tab-recent" class="tab tab_content" style="display: none;"> 
  83. <?php 
  84. $recent_posts = new WP_Query('showposts=' . $tags_count); 
  85. if ($recent_posts->have_posts()): 
  86. ?> 
  87. <ul class="news-list"> 
  88. <?php while ($recent_posts->have_posts()): $recent_posts->the_post(); ?> 
  89. <li> 
  90. <?php if (has_post_thumbnail()): ?> 
  91. <div class="image"> 
  92. <a href="<?php the_permalink(); ?>"> 
  93. <?php the_post_thumbnail('tabs-img'); ?> 
  94. </a> 
  95. </div> 
  96. <?php endif; ?> 
  97. <div class="post-holder"> 
  98. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
  99.  
  100. <div class="meta"> 
  101. <?php the_time(get_option('date_format')); ?> 
  102. </div> 
  103. </div> 
  104. </li> 
  105. <?php endwhile; ?> 
  106. </ul> 
  107. <?php endif; ?> 
  108. </div> 
  109. <?php 
  110. endif; 
  111. if ($show_comments == 'true'): 
  112. ?> 
  113. <div id="tab-comments" class="tab tab_content" style="display: none;"> 
  114. <ul class="news-list"> 
  115. <?php 
  116. $number = $instance['comments']; 
  117. global $wpdb; 
  118. $recent_comments = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved, comment_type, comment_author_url, SUBSTRING(comment_content, 1, 110) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT $number"; 
  119. $the_comments = $wpdb->get_results($recent_comments); 
  120. foreach ($the_comments as $comment) { 
  121. ?> 
  122. <li> 
  123. <div class="image"> 
  124. <?php echo get_avatar($comment, '50'); ?> 
  125. </div> 
  126. <div class="post-holder"> 
  127. <a class="comment-text-side" href="<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment->comment_ID; ?>" title="<?php echo strip_tags($comment->comment_author); ?> on <?php echo $comment->post_title; ?>"><?php echo strip_tags($comment->comment_author); ?><?php _e(' says', 'evolve'); ?></a> 
  128.  
  129. <div class="meta"> 
  130. <?php echo evolve_truncate(strip_tags($comment->com_excerpt), 70); ?> 
  131. </div> 
  132. </div> 
  133. </li> 
  134. <?php } ?> 
  135. </ul> 
  136. </div> 
  137. <?php endif; ?> 
  138. </div> 
  139. </div> 
  140. </div> 
  141. <?php 
  142. echo $after_widget; 
  143.  
  144. function update($new_instance, $old_instance) { 
  145. $instance = $old_instance; 
  146.  
  147. $instance['posts'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['posts']))); 
  148. $instance['comments'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['comments']))); 
  149. $instance['tags'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['tags']))); 
  150. $instance['show_popular_posts'] = $new_instance['show_popular_posts']; 
  151. $instance['show_recent_posts'] = $new_instance['show_recent_posts']; 
  152. $instance['show_comments'] = $new_instance['show_comments']; 
  153. $instance['show_tags'] = $new_instance['show_tags']; 
  154. $instance['orderby'] = $new_instance['orderby']; 
  155.  
  156. return $instance; 
  157.  
  158. function form($instance) { 
  159. $defaults = array( 
  160. 'posts' => 3,  
  161. 'comments' => '3',  
  162. 'tags' => 3,  
  163. 'show_popular_posts' => 'on',  
  164. 'show_recent_posts' => 'on',  
  165. 'show_comments' => 'on',  
  166. 'show_tags' => 'on',  
  167. 'orderby' => 'Highest Comments' 
  168. ); 
  169. $instance = wp_parse_args((array) $instance, $defaults); 
  170. ?> 
  171. <p> 
  172. <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e('Popular Posts Order By', 'evolve'); ?>:</label> 
  173. <select id="<?php echo $this->get_field_id('orderby'); ?>" name="<?php echo $this->get_field_name('orderby'); ?>" class="widefat" style="width:100%;"> 
  174. <option <?php 
  175. if ('Highest Comments' == $instance['orderby']) { 
  176. echo 'selected="selected"'; 
  177. ?>><?php _e('Highest Comments', 'evolve'); ?></option> 
  178. <option <?php 
  179. if ('Highest Views' == $instance['orderby']) { 
  180. echo 'selected="selected"'; 
  181. ?>><?php _e('Highest Views', 'evolve'); ?></option> 
  182. </select> 
  183. </p> 
  184. <p> 
  185. <label for="<?php echo $this->get_field_id('posts'); ?>"><?php _e('Number of popular posts', 'evolve'); ?>:</label> 
  186. <input class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('posts'); ?>" name="<?php echo $this->get_field_name('posts'); ?>" value="<?php echo $instance['posts']; ?>"/> 
  187. </p> 
  188. <p> 
  189. <label for="<?php echo $this->get_field_id('tags'); ?>"><?php _e('Number of recent posts', 'evolve'); ?>:</label> 
  190. <input class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('tags'); ?>" name="<?php echo $this->get_field_name('tags'); ?>" value="<?php echo $instance['tags']; ?>"/> 
  191. </p> 
  192. <p> 
  193. <label for="<?php echo $this->get_field_id('comments'); ?>"><?php _e('Number of comments', 'evolve'); ?>:</label> 
  194. <input class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('comments'); ?>" name="<?php echo $this->get_field_name('comments'); ?>" value="<?php echo $instance['comments']; ?>"/> 
  195. </p> 
  196. <p> 
  197. <input class="checkbox" type="checkbox" <?php checked($instance['show_popular_posts'], 'on'); ?> id="<?php echo $this->get_field_id('show_popular_posts'); ?>" name="<?php echo $this->get_field_name('show_popular_posts'); ?>"/> 
  198. <label for="<?php echo $this->get_field_id('show_popular_posts'); ?>"><?php _e('Show popular posts', 'evolve'); ?></label> 
  199. </p> 
  200. <p> 
  201. <input class="checkbox" type="checkbox" <?php checked($instance['show_recent_posts'], 'on'); ?> id="<?php echo $this->get_field_id('show_recent_posts'); ?>" name="<?php echo $this->get_field_name('show_recent_posts'); ?>"/> 
  202. <label for="<?php echo $this->get_field_id('show_recent_posts'); ?>"><?php _e('Show recent posts', 'evolve'); ?></label> 
  203. </p> 
  204. <p> 
  205. <input class="checkbox" type="checkbox" <?php checked($instance['show_comments'], 'on'); ?> id="<?php echo $this->get_field_id('show_comments'); ?>" name="<?php echo $this->get_field_name('show_comments'); ?>"/> 
  206. <label for="<?php echo $this->get_field_id('show_comments'); ?>"><?php _e('Show comments', 'evolve'); ?></label> 
  207. </p> 
  208. <?php 
  209.