WC_Compare_Widget

WooCommerce Compare Widget.

Defined (1)

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

/widgets/compare_widget.php  
  1. class WC_Compare_Widget extends WP_Widget 
  2.  
  3. function __construct() { 
  4. $widget_ops = array( 
  5. 'classname' => 'woo_compare_widget',  
  6. 'customize_selective_refresh' => true,  
  7. ); 
  8. parent::__construct('woo_compare_widget', __('WOO Compare Products', 'woocommerce-compare-products' ), $widget_ops); 
  9.  
  10. function widget($args, $instance) { 
  11. extract($args, EXTR_SKIP); 
  12. $total_compare_product = 0; 
  13. $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 
  14.  
  15. echo $before_widget; 
  16.  
  17. if ( $title != '') 
  18. echo $before_title . $title . ' <span class="total_compare_product_container">(<span id="total_compare_product">'.$total_compare_product.'</span>)</span>' . $after_title; 
  19. else 
  20. echo $before_title . __( 'Compare Products', 'woocommerce-compare-products' ).' <span class="total_compare_product_container">(<span id="total_compare_product">'.$total_compare_product.'</span>)</span>' . $after_title; 
  21.  
  22.  
  23. echo '<div class="woo_compare_widget_container"></div><div class="woo_compare_widget_loader" style="display:none; text-align:center"><img src="'.WOOCP_IMAGES_URL.'/ajax-loader.gif" border=0 /></div>'; 
  24.  
  25. echo $after_widget; 
  26.  
  27.  
  28. function update($new_instance, $old_instance) { 
  29. $instance = $old_instance; 
  30. $instance['title'] = strip_tags($new_instance['title']); 
  31. return $instance; 
  32.  
  33.  
  34. function form($instance) { 
  35. $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); 
  36. $title = strip_tags($instance['title']); 
  37. ?> 
  38.  
  39. <p> 
  40. <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title', 'woocommerce-compare-products' ); ?> : 
  41. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /> 
  42. </label> 
  43. </p> 
  44. <?php