YITH_Woocompare_Widget

YITH WooCommerce Ajax Navigation Widget.

Defined (1)

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

/widgets/class.yith-woocompare-widget.php  
  1. class YITH_Woocompare_Widget extends WP_Widget { 
  2.  
  3. function __construct() { 
  4. $widget_ops = array ( 
  5. 'classname' => 'yith-woocompare-widget',  
  6. 'description' => __( 'The widget shows the list of products added in the comparison table.', 'yith-woocommerce-compare' 
  7. ); 
  8.  
  9. parent::__construct( 'yith-woocompare-widget', __( 'YITH WooCommerce Compare Widget', 'yith-woocommerce-compare' ), $widget_ops ); 
  10.  
  11.  
  12. function widget( $args, $instance ) { 
  13. global $yith_woocompare; 
  14.  
  15. /** 
  16. * WPML Support 
  17. */ 
  18. $lang = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : false; 
  19.  
  20. extract( $args ); 
  21.  
  22. do_action ( 'wpml_register_single_string', 'Widget', 'widget_yit_compare_title_text', $instance['title'] ); 
  23. $localized_widget_title = apply_filters ( 'wpml_translate_single_string', $instance['title'], 'Widget', 'widget_yit_compare_title_text' ); 
  24.  
  25. echo $before_widget . $before_title . $localized_widget_title . $after_title; ?> 
  26.  
  27. <ul class="products-list" data-lang="<?php echo $lang ?>"> 
  28. <?php echo $yith_woocompare->obj->list_products_html(); ?> 
  29. </ul> 
  30.  
  31. <a href="<?php echo $yith_woocompare->obj->remove_product_url('all') ?>" data-product_id="all" class="clear-all" rel="nofollow"><?php _e( 'Clear all', 'yith-woocommerce-compare' ) ?></a> 
  32. <a href="<?php echo add_query_arg( array( 'iframe' => 'true' ), $yith_woocompare->obj->view_table_url() ) ?>" class="compare added button" rel="nofollow"><?php _e( 'Compare', 'yith-woocommerce-compare' ) ?></a> 
  33.  
  34. <?php echo $after_widget; 
  35.  
  36.  
  37. function form( $instance ) { 
  38. global $woocommerce; 
  39.  
  40. $defaults = array( 
  41. 'title' => '',  
  42. ); 
  43.  
  44. $instance = wp_parse_args( (array) $instance, $defaults ); ?> 
  45.  
  46. <p> 
  47. <label> 
  48. <?php _e( 'Title', 'yith-woocommerce-compare' ) ?>:<br /> 
  49. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" /> 
  50. </label> 
  51. </p> 
  52. <?php 
  53.  
  54. function update( $new_instance, $old_instance ) { 
  55. $instance = $old_instance; 
  56.  
  57. $instance['title'] = strip_tags( $new_instance['title'] ); 
  58.  
  59. return $instance; 
  60.