1 <?php
 2 /**
 3  * Tag Cloud Widget
 4  *
 5  * @author      WooThemes
 6  * @category    Widgets
 7  * @package     WooCommerce/Widgets
 8  * @version     2.1.0
 9  * @extends     WC_Widget
10  */
11 
12 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13 
14 class WC_Widget_Product_Tag_Cloud extends WC_Widget {
15 
16     /**
17      * Constructor
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      * widget function.
36      *
37      * @see WP_Widget
38      * @access public
39      * @param array $args
40      * @param array $instance
41      * @return void
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      * Return the taxonomy being displayed
71      *
72      * @param  object $instance
73      * @return string
74      */
75     public function _get_current_taxonomy( $instance ) {
76         return 'product_tag';
77     }
78 }
79 
80 register_widget( 'WC_Widget_Product_Tag_Cloud' );
WooCommerce API documentation generated by ApiGen 2.8.0