mh_impact_lite_pages_widget

The MH Impact lite mh impact lite pages widget class.

Defined (1)

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

/includes/widgets/mh-pages.php  
  1. class mh_impact_lite_pages_widget extends WP_Widget { 
  2. function __construct() { 
  3. parent::__construct( 
  4. 'mh_impact_lite_pages_widget', esc_html_x('MH Custom Pages (Homepage)', 'widget name', 'mh-impact-lite'),  
  5. array( 
  6. 'classname' => 'mh_impact_lite_pages_widget',  
  7. 'description' => esc_html__('Display 3 columns of linked pages on your front page.', 'mh-impact-lite'),  
  8. 'customize_selective_refresh' => true 
  9. ); 
  10. function widget($args, $instance) { 
  11. extract($args); 
  12. $pages = empty($instance['pages']) ? '' : $instance['pages']; 
  13.  
  14. echo $before_widget; ?> 
  15. <div class="mh-pages-widget widget-wrap mh-row clearfix"><?php 
  16. $include_ids = explode(', ', $pages); 
  17. $args = array('post_type' => 'page', 'post__in' => $include_ids, 'orderby' => 'post__in'); 
  18. $widget_loop = new WP_Query($args); 
  19. while ($widget_loop->have_posts()) : $widget_loop->the_post(); ?> 
  20. <div class="pages-widget-item mh-col-1-3"> 
  21. <div class="pages-widget-thumb"> 
  22. <a href="<?php the_permalink(); ?>"><?php if (has_post_thumbnail()) { the_post_thumbnail('pages-widget'); } else { echo '<img src="' . get_template_directory_uri() . '/images/placeholder-pages-widget.jpg' . '" alt="No Picture" />'; } ?></a> 
  23. </div> 
  24. <h3 class="pages-widget-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> 
  25. <div class="pages-widget-excerpt"><?php the_excerpt(); ?></div> 
  26. </div><?php 
  27. endwhile; 
  28. wp_reset_postdata(); ?> 
  29. </div> <?php 
  30. echo $after_widget; 
  31. function update($new_instance, $old_instance) { 
  32. $instance = $old_instance; 
  33. $instance['pages'] = strip_tags($new_instance['pages']); 
  34. return $instance; 
  35. function form($instance) { 
  36. $defaults = array('pages' => ''); 
  37. $instance = wp_parse_args((array) $instance, $defaults); ?> 
  38. <p> 
  39. <label for="<?php echo $this->get_field_id('pages'); ?>"><?php _e('Filter Pages by ID (comma separated):', 'mh-impact-lite'); ?></label> 
  40. <input class="widefat" type="text" value="<?php echo esc_attr($instance['pages']); ?>" name="<?php echo $this->get_field_name('pages'); ?>" id="<?php echo $this->get_field_id('pages'); ?>" /> 
  41. </p> 
  42. <p> 
  43. <strong><?php _e('Info:', 'mh-impact-lite'); ?></strong> <?php _e('This is the lite version of this widget with basic features. If you need more professional features and options, you can upgrade to the premium version of this theme.', 'mh-impact-lite'); ?> 
  44. </p><?php