mh_affiliate_widget

The MH Corporate basic mh affiliate widget class.

Defined (1)

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

/includes/widgets/mh-affiliate.php  
  1. class mh_affiliate_widget extends WP_Widget { 
  2. function __construct() { 
  3. parent::__construct( 
  4. 'mh_affiliate', esc_html_x('MH Affiliate Widget', 'widget name', 'mh-corporate-basic'),  
  5. array( 
  6. 'classname' => 'mh_affiliate',  
  7. 'description' => esc_html__('MH Affiliate Widget to earn money by promoting WordPress themes by MH Themes.', 'mh-corporate-basic'),  
  8. 'customize_selective_refresh' => true 
  9. ); 
  10. function widget($args, $instance) { 
  11. extract($args); 
  12. $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); 
  13. $mh_username = empty($instance['mh_username']) ? 'MHthemes' : $instance['mh_username']; 
  14. $mh_ads = isset($instance['mh_ads']) ? $instance['mh_ads'] : '300x250'; 
  15.  
  16. echo $before_widget; 
  17.  
  18. if (!empty($title)) { echo $before_title . $title . $after_title; } ?> 
  19. <a href="https://creativemarket.com/MHthemes/?u=<?php echo esc_attr($mh_username); ?>" target="_blank" title="Premium WordPress Themes by MH Themes" rel="nofollow"><img src="<?php echo get_template_directory_uri() . '/images/ads/mh_corporate_' . $mh_ads . '.png' ?>" alt="MH Corporate WordPress Theme" /></a> <?php 
  20.  
  21. echo $after_widget; 
  22. function update($new_instance, $old_instance) { 
  23. $instance = $old_instance; 
  24. $instance['title'] = sanitize_text_field($new_instance['title']); 
  25. $instance['mh_username'] = sanitize_text_field($new_instance['mh_username']); 
  26. $instance['mh_ads'] = strip_tags($new_instance['mh_ads']); 
  27. return $instance; 
  28. function form($instance) { 
  29. $defaults = array('title' => 'WordPress Business Theme', 'mh_username' => '', 'mh_ads' => '300x250'); 
  30. $instance = wp_parse_args((array) $instance, $defaults); ?> 
  31.  
  32. <p> 
  33. <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'mh-corporate-basic'); ?></label> 
  34. <input class="widefat" type="text" value="<?php echo esc_attr($instance['title']); ?>" name="<?php echo $this->get_field_name('title'); ?>" id="<?php echo $this->get_field_id('title'); ?>" /> 
  35. </p> 
  36. <p> 
  37. <label for="<?php echo $this->get_field_id('mh_username'); ?>">Creative Market Username:</label> 
  38. <input class="widefat" type="text" value="<?php echo esc_attr($instance['mh_username']); ?>" name="<?php echo $this->get_field_name('mh_username'); ?>" id="<?php echo $this->get_field_id('mh_username'); ?>" /> 
  39. </p> 
  40. <p> 
  41. <label for="<?php echo $this->get_field_id('mh_ads'); ?>"><?php _e('Banner size:', 'mh-corporate-basic'); ?></label> 
  42. <select id="<?php echo $this->get_field_id('mh_ads'); ?>" name="<?php echo $this->get_field_name('mh_ads'); ?>" type="text"> 
  43. <option value="125x125" <?php if ($instance['mh_ads'] == "125x125") { echo "selected='selected'"; } ?>>125x125</option> 
  44. <option value="250x250" <?php if ($instance['mh_ads'] == "250x250") { echo "selected='selected'"; } ?>>250x250</option> 
  45. <option value="300x250" <?php if ($instance['mh_ads'] == "300x250") { echo "selected='selected'"; } ?>>300x250</option> 
  46. <option value="468x60" <?php if ($instance['mh_ads'] == "468x60") { echo "selected='selected'"; } ?>>468x60</option> 
  47. <option value="728x90" <?php if ($instance['mh_ads'] == "728x90") { echo "selected='selected'"; } ?>>728x90</option> 
  48. </select> 
  49. </p> 
  50. <p><?php echo __('With this widget you can earn money by promoting WordPress themes by MH Themes. If you do not have a Creative Market Username yet, please visit our:', 'mh-corporate-basic') . ' <a href="' . esc_url('https://www.mhthemes.com/affiliates/') . '" target="_blank">' . __('infopage for affiliates', 'mh-corporate-basic'). '</a>'; ?>.</p> <?php