1 <?php
2 3 4 5 6 7 8 9 10
11
12 if ( ! defined( 'ABSPATH' ) ) exit;
13
14 class WC_Widget_Product_Tag_Cloud extends WC_Widget {
15
16 17 18
19 public function __construct() {
20 $this->widget_cssclass = 'woocommerce widget_product_tag_cloud';
21 $this->widget_description = __( 'Your most used product tags in cloud format.', 'woocommerce' );
22 $this->widget_id = 'woocommerce_product_tag_cloud';
23 $this->widget_name = __( 'WooCommerce Product Tags', 'woocommerce' );
24 $this->settings = array(
25 'title' => array(
26 'type' => 'text',
27 'std' => __( 'Product Tags', 'woocommerce' ),
28 'label' => __( 'Title', 'woocommerce' )
29 )
30 );
31 parent::__construct();
32 }
33
34 35 36 37 38 39 40 41 42
43 public function widget( $args, $instance ) {
44 extract( $args );
45
46 $current_taxonomy = $this->_get_current_taxonomy($instance);
47
48 if ( empty( $instance['title'] ) ) {
49 $tax = get_taxonomy( $current_taxonomy );
50 $title = apply_filters( 'widget_title', $tax->labels->name, $instance, $this->id_base );
51 } else {
52 $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
53 }
54
55 echo $before_widget;
56
57 if ( $title )
58 echo $before_title . $title . $after_title;
59
60 echo '<div class="tagcloud">';
61
62 wp_tag_cloud( apply_filters( 'woocommerce_product_tag_cloud_widget_args', array( 'taxonomy' => $current_taxonomy ) ) );
63
64 echo "</div>";
65
66 echo $after_widget;
67 }
68
69 70 71 72 73 74
75 public function _get_current_taxonomy( $instance ) {
76 return 'product_tag';
77 }
78 }
79
80 register_widget( 'WC_Widget_Product_Tag_Cloud' );