widget_cssclass = 'woocommerce widget_product_tag_cloud'; $this->widget_description = __( 'Your most used product tags in cloud format.', 'woocommerce' ); $this->widget_id = 'woocommerce_product_tag_cloud'; $this->widget_name = __( 'WooCommerce product tags', 'woocommerce' ); $this->settings = array( 'title' => array( 'type' => 'text', 'std' => __( 'Product tags', 'woocommerce' ), 'label' => __( 'Title', 'woocommerce' ), ), ); parent::__construct(); } /** * Output widget. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { $current_taxonomy = $this->_get_current_taxonomy( $instance ); if ( empty( $instance['title'] ) ) { $taxonomy = get_taxonomy( $current_taxonomy ); $instance['title'] = $taxonomy->labels->name; } $this->widget_start( $args, $instance ); echo '
'; wp_tag_cloud( apply_filters( 'woocommerce_product_tag_cloud_widget_args', array( 'taxonomy' => $current_taxonomy, 'topic_count_text_callback' => array( $this, '_topic_count_text' ), ) ) ); echo '
'; $this->widget_end( $args ); } /** * Return the taxonomy being displayed. * * @param object $instance * @return string */ public function _get_current_taxonomy( $instance ) { return 'product_tag'; } /** * Returns topic count text. * * @since 2.6.0 * @param int $count * @return string */ public function _topic_count_text( $count ) { /* translators: %s: product count */ return sprintf( _n( '%s product', '%s products', $count, 'woocommerce' ), number_format_i18n( $count ) ); } }