mh_affiliate_widget

The MH Corporate lite 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 mh_affiliate_widget() { 
  3. $widget_ops = array('classname' => 'mh_affiliate', 'description' => __('MH Affiliate Widget to earn money by promoting WordPress themes by MH Themes.', 'mhc')); 
  4. $this->WP_Widget('mh_affiliate', __('MH Affiliate Widget', 'mhc'), $widget_ops); 
  5. function widget($args, $instance) { 
  6. extract($args); 
  7. $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); 
  8. $mh_username = empty($instance['mh_username']) ? 'MHthemes' : $instance['mh_username']; 
  9. $mh_ads = isset($instance['mh_ads']) ? $instance['mh_ads'] : '300x250'; 
  10.  
  11. echo $before_widget; 
  12.  
  13. if (!empty($title)) { echo $before_title . $title . $after_title; } ?> 
  14. <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 
  15.  
  16. echo $after_widget; 
  17. function update($new_instance, $old_instance) { 
  18. $instance = $old_instance; 
  19. $instance['title'] = strip_tags($new_instance['title']); 
  20. $instance['mh_username'] = strip_tags($new_instance['mh_username']); 
  21. $instance['mh_ads'] = strip_tags($new_instance['mh_ads']); 
  22. return $instance; 
  23. function form($instance) { 
  24. $defaults = array('title' => 'WordPress Business Theme', 'mh_username' => '', 'mh_ads' => '300x250'); 
  25. $instance = wp_parse_args((array) $instance, $defaults); ?> 
  26.  
  27. <p> 
  28. <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'mhc'); ?></label> 
  29. <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'); ?>" /> 
  30. </p> 
  31. <p> 
  32. <label for="<?php echo $this->get_field_id('mh_username'); ?>">Creative Market Username:</label> 
  33. <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'); ?>" /> 
  34. </p> 
  35. <p> 
  36. <label for="<?php echo $this->get_field_id('mh_ads'); ?>"><?php _e('Banner size:', 'mhc'); ?></label> 
  37. <select id="<?php echo $this->get_field_id('mh_ads'); ?>" name="<?php echo $this->get_field_name('mh_ads'); ?>" type="text"> 
  38. <option value="125x125" <?php if ($instance['mh_ads'] == "125x125") { echo "selected='selected'"; } ?>>125x125</option> 
  39. <option value="250x250" <?php if ($instance['mh_ads'] == "250x250") { echo "selected='selected'"; } ?>>250x250</option> 
  40. <option value="300x250" <?php if ($instance['mh_ads'] == "300x250") { echo "selected='selected'"; } ?>>300x250</option> 
  41. <option value="468x60" <?php if ($instance['mh_ads'] == "468x60") { echo "selected='selected'"; } ?>>468x60</option> 
  42. <option value="728x90" <?php if ($instance['mh_ads'] == "728x90") { echo "selected='selected'"; } ?>>728x90</option> 
  43. </select> 
  44. </p> 
  45. <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:', 'mhc') . ' <a href="http://www.mhthemes.com/affiliates/" target="_blank">' . __('infopage for affiliates', 'mhc'). '</a>'; ?>.</p> <?php