mh_impact_lite_action_widget

The MH Impact lite mh impact lite action widget class.

Defined (1)

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

/includes/widgets/mh-action.php  
  1. class mh_impact_lite_action_widget extends WP_Widget { 
  2. function __construct() { 
  3. parent::__construct( 
  4. 'mh_impact_lite_action_widget', esc_html_x('MH Call to Action (Homepage)', 'widget name', 'mh-impact-lite'),  
  5. array( 
  6. 'classname' => 'mh_impact_lite_action_widget',  
  7. 'description' => esc_html__('Add a call to action button to your front page.', 'mh-impact-lite'),  
  8. 'customize_selective_refresh' => true 
  9. ); 
  10. function widget($args, $instance) { 
  11. extract($args); 
  12. $title_lead = empty($instance['title_lead']) ? '' : $instance['title_lead']; 
  13. $title_sub = empty($instance['title_sub']) ? '' : $instance['title_sub']; 
  14. $action_button = empty($instance['action_button']) ? '' : $instance['action_button']; 
  15. $action_url = empty($instance['action_url']) ? '' : $instance['action_url']; 
  16. $action_target = isset($instance['action_target']) && $instance['action_target'] ? ' target="_blank"' : ''; 
  17.  
  18. echo $before_widget; ?> 
  19. <div class="action-widget widget-wrap mh-row clearfix"> 
  20. <div class="mh-col-3-4 action-widget-content"> 
  21. <?php if ($title_lead) { ?> 
  22. <h2 class="action-widget-title"><?php echo esc_attr($title_lead); ?></h2> 
  23. <?php } ?> 
  24. <?php if ($title_sub) { ?> 
  25. <h6 class="action-widget-subtitle"><?php echo esc_attr($title_sub); ?></h6> 
  26. <?php } ?> 
  27. </div> 
  28. <?php if ($action_button) { ?> 
  29. <div class="mh-col-1-4 action-widget-button"> 
  30. <a class="button" href="<?php echo esc_url($action_url); ?>" title="<?php echo esc_attr($action_button); ?>"<?php echo $action_target; ?>><?php echo esc_attr($action_button); ?></a> 
  31. </div> 
  32. <?php } ?> 
  33. </div><?php 
  34. echo $after_widget; 
  35. function update($new_instance, $old_instance) { 
  36. $instance = $old_instance; 
  37. $instance['title_lead'] = sanitize_text_field($new_instance['title_lead']); 
  38. $instance['title_sub'] = sanitize_text_field($new_instance['title_sub']); 
  39. $instance['action_button'] = sanitize_text_field($new_instance['action_button']); 
  40. $instance['action_url'] = esc_url_raw($new_instance['action_url']); 
  41. $instance['action_target'] = isset($new_instance['action_target']) ? strip_tags($new_instance['action_target']) : ''; 
  42. return $instance; 
  43. function form($instance) { 
  44. $defaults = array('title_lead' => '', 'title_sub' => '', 'action_button' => '', 'action_url' => '', 'action_target' => ''); 
  45. $instance = wp_parse_args((array) $instance, $defaults); ?> 
  46. <p> 
  47. <label for="<?php echo $this->get_field_id('title_lead'); ?>"><?php _e('Lead Title Text:', 'mh-impact-lite'); ?></label> 
  48. <input class="widefat" type="text" value="<?php echo esc_attr($instance['title_lead']); ?>" name="<?php echo $this->get_field_name('title_lead'); ?>" id="<?php echo $this->get_field_id('title_lead'); ?>" /> 
  49. <small><?php _e('Enter your custom lead title text.', 'mh-impact-lite'); ?></small> 
  50. </p> 
  51. <p> 
  52. <label for="<?php echo $this->get_field_id('title_sub'); ?>"><?php _e('Sub-Title Text:', 'mh-impact-lite'); ?></label> 
  53. <input class="widefat" type="text" value="<?php echo esc_attr($instance['title_sub']); ?>" name="<?php echo $this->get_field_name('title_sub'); ?>" id="<?php echo $this->get_field_id('title_sub'); ?>" /> 
  54. <small><?php _e('Enter your custom sub-title text.', 'mh-impact-lite'); ?></small> 
  55. </p> 
  56. <p> 
  57. <label for="<?php echo $this->get_field_id('action_button'); ?>"><?php _e('Button Text:', 'mh-impact-lite'); ?></label> 
  58. <input class="widefat" type="text" value="<?php echo esc_attr($instance['action_button']); ?>" name="<?php echo $this->get_field_name('action_button'); ?>" id="<?php echo $this->get_field_id('action_button'); ?>" /> 
  59. <small><?php _e('Enter your custom action button text.', 'mh-impact-lite'); ?></small> 
  60. </p> 
  61. <p> 
  62. <label for="<?php echo $this->get_field_id('action_url'); ?>"><?php _e('Button URL:', 'mh-impact-lite'); ?></label> 
  63. <input class="widefat" type="text" value="<?php echo esc_url($instance['action_url']); ?>" name="<?php echo $this->get_field_name('action_url'); ?>" id="<?php echo $this->get_field_id('action_url'); ?>" /> 
  64. <small><?php _e('Enter the destination URL of the action button.', 'mh-impact-lite'); ?></small> 
  65. </p> 
  66. <p> 
  67. <input id="<?php echo $this->get_field_id('action_target'); ?>" name="<?php echo $this->get_field_name('action_target'); ?>" type="checkbox" value="1" <?php checked('1', $instance['action_target']); ?>/> 
  68. <label for="<?php echo $this->get_field_id('action_target'); ?>"><?php _e('Open link in new window / tab', 'mh-impact-lite'); ?></label> 
  69. </p><?php