mh_magazine_lite_tabbed

The MH Magazine lite mh magazine lite tabbed class.

Defined (1)

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

/includes/widgets/mh-tabbed.php  
  1. class mh_magazine_lite_tabbed extends WP_Widget { 
  2. function __construct() { 
  3. parent::__construct( 
  4. 'mh_magazine_lite_tabbed', esc_html_x('MH Tabbed [lite]', 'widget name', 'mh-magazine-lite'),  
  5. array( 
  6. 'classname' => 'mh_magazine_lite_tabbed',  
  7. 'description' => esc_html__('MH Tabbed widget showing your latest posts, tags and comments.', 'mh-magazine-lite') 
  8. ); 
  9. function widget($args, $instance) { 
  10. $defaults = array('title' => ''); 
  11. $instance = wp_parse_args($instance, $defaults); 
  12. echo $args['before_widget']; 
  13. if (!empty($instance['title'])) { 
  14. echo $args['before_title'] . esc_html(apply_filters('widget_title', $instance['title'])) . $args['after_title']; 
  15. } ?> 
  16. <div class="mh-tabbed-widget"> 
  17. <div class="mh-tab-buttons clearfix"> 
  18. <a class="mh-tab-button" href="#tab-<?php echo esc_attr($args['widget_id']); ?>-1"> 
  19. <span><i class="fa fa-newspaper-o"></i></span> 
  20. </a> 
  21. <a class="mh-tab-button" href="#tab-<?php echo esc_attr($args['widget_id']); ?>-2"> 
  22. <span><i class="fa fa-tags"></i></span> 
  23. </a> 
  24. <a class="mh-tab-button" href="#tab-<?php echo esc_attr($args['widget_id']); ?>-3"> 
  25. <span><i class="fa fa-comments-o"></i></span> 
  26. </a> 
  27. </div> 
  28. <div id="tab-<?php echo esc_attr($args['widget_id']); ?>-1" class="mh-tab-content mh-tab-posts"><?php 
  29. $latest_posts = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 10, 'ignore_sticky_posts' => 1)); 
  30. if ($latest_posts->have_posts()) { 
  31. echo '<ul class="mh-tab-content-posts">' . "\n"; 
  32. while ($latest_posts->have_posts()) : $latest_posts->the_post(); ?> 
  33. <li class="post-<?php the_ID(); ?> mh-tab-post-item"> 
  34. <a href="<?php the_permalink(); ?>"> 
  35. <?php the_title(); ?> 
  36. </a> 
  37. </li><?php 
  38. endwhile; 
  39. echo '</ul>' . "\n"; 
  40. wp_reset_postdata(); ?> 
  41. </div> 
  42. <div id="tab-<?php echo esc_attr($args['widget_id']); ?>-2" class="mh-tab-content mh-tab-cloud"> 
  43. <div class="tagcloud mh-tab-content-cloud"> 
  44. <?php wp_tag_cloud(array('number' => 25, 'smallest' => 12, 'largest' => 12, 'unit' => 'px')); ?> 
  45. </div> 
  46. </div> 
  47. <div id="tab-<?php echo esc_attr($args['widget_id']); ?>-3" class="mh-tab-content mh-tab-comments"><?php 
  48. $comments_query = new WP_Comment_Query; 
  49. $comments = $comments_query->query(array('number' => 3, 'status' => 'approve')); 
  50. if ($comments) { 
  51. echo '<ul class="mh-tab-content-comments">'; 
  52. foreach ($comments as $comment) { ?> 
  53. <li class="mh-tab-comment-item"> 
  54. <span class="mh-tab-comment-avatar"> 
  55. <?php echo get_avatar($comment->comment_author_email, 24); ?> 
  56. </span> 
  57. <span class="mh-tab-comment-author"> 
  58. <?php echo esc_attr($comment->comment_author) . ': '; ?> 
  59. </span> 
  60. <a href="<?php echo esc_url(get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID); ?>"> 
  61. <span class="mh-tab-comment-excerpt"> 
  62. <?php comment_excerpt($comment->comment_ID); ?> 
  63. </span> 
  64. </a> 
  65. </li><?php 
  66. echo '</ul>'; 
  67. } else { 
  68. esc_html_e('No comments found', 'mh-magazine-lite'); 
  69. } ?> 
  70. </div> 
  71. </div><?php 
  72. echo $args['after_widget']; 
  73. function update($new_instance, $old_instance) { 
  74. $instance = array(); 
  75. if (!empty($new_instance['title'])) { 
  76. $instance['title'] = sanitize_text_field($new_instance['title']); 
  77. return $instance; 
  78. function form($instance) { 
  79. $defaults = array('title' => ''); 
  80. $instance = wp_parse_args($instance, $defaults); ?> 
  81. <p> 
  82. <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:', 'mh-magazine-lite'); ?></label> 
  83. <input class="widefat" type="text" value="<?php echo esc_attr($instance['title']); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" id="<?php echo esc_attr($this->get_field_id('title')); ?>" /> 
  84. </p> 
  85. <p> 
  86. <strong><?php esc_html_e('Info:', 'mh-magazine-lite'); ?></strong> <?php esc_html_e('This is the lite version of this widget with basic features. More features and options are available in the premium version of MH Magazine.', 'mh-magazine-lite'); ?> 
  87. </p><?php