WC_Widget_Product_Tag_Cloud

Tag Cloud Widget.

Defined (1)

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

/includes/widgets/class-wc-widget-product-tag-cloud.php  
  1. class WC_Widget_Product_Tag_Cloud extends WC_Widget { 
  2.  
  3. /** 
  4. * Constructor. 
  5. */ 
  6. public function __construct() { 
  7. $this->widget_cssclass = 'woocommerce widget_product_tag_cloud'; 
  8. $this->widget_description = __( 'Your most used product tags in cloud format.', 'woocommerce' ); 
  9. $this->widget_id = 'woocommerce_product_tag_cloud'; 
  10. $this->widget_name = __( 'WooCommerce product tags', 'woocommerce' ); 
  11. $this->settings = array( 
  12. 'title' => array( 
  13. 'type' => 'text',  
  14. 'std' => __( 'Product tags', 'woocommerce' ),  
  15. 'label' => __( 'Title', 'woocommerce' ),  
  16. ),  
  17. ); 
  18.  
  19. parent::__construct(); 
  20.  
  21. /** 
  22. * Output widget. 
  23. * @see WP_Widget 
  24. * @param array $args 
  25. * @param array $instance 
  26. */ 
  27. public function widget( $args, $instance ) { 
  28. $current_taxonomy = $this->_get_current_taxonomy( $instance ); 
  29.  
  30. if ( empty( $instance['title'] ) ) { 
  31. $taxonomy = get_taxonomy( $current_taxonomy ); 
  32. $instance['title'] = $taxonomy->labels->name; 
  33.  
  34. $this->widget_start( $args, $instance ); 
  35.  
  36. echo '<div class="tagcloud">'; 
  37.  
  38. wp_tag_cloud( apply_filters( 'woocommerce_product_tag_cloud_widget_args', array( 
  39. 'taxonomy' => $current_taxonomy,  
  40. 'topic_count_text_callback' => array( $this, '_topic_count_text' ),  
  41. ) ) ); 
  42.  
  43. echo '</div>'; 
  44.  
  45. $this->widget_end( $args ); 
  46.  
  47. /** 
  48. * Return the taxonomy being displayed. 
  49. * @param object $instance 
  50. * @return string 
  51. */ 
  52. public function _get_current_taxonomy( $instance ) { 
  53. return 'product_tag'; 
  54.  
  55. /** 
  56. * Returns topic count text. 
  57. * @since 2.6.0 
  58. * @param int $count 
  59. * @return string 
  60. */ 
  61. public function _topic_count_text( $count ) { 
  62. /** translators: %s: product count */ 
  63. return sprintf( _n( '%s product', '%s products', $count, 'woocommerce' ), number_format_i18n( $count ) );