__( "A cloud of your most used tags.") ); parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops); } /** * @param array $args * @param array $instance */ public function widget( $args, $instance ) { $current_taxonomy = $this->_get_current_taxonomy($instance); if ( !empty($instance['title']) ) { $title = $instance['title']; } else { if ( 'post_tag' == $current_taxonomy ) { $title = __('Tags'); } else { $tax = get_taxonomy($current_taxonomy); $title = $tax->labels->name; } } /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } echo '
'; /** * Filter the taxonomy used in the Tag Cloud widget. * * @since 2.8.0 * @since 3.0.0 Added taxonomy drop-down. * * @see wp_tag_cloud() * * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'. */ wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( 'taxonomy' => $current_taxonomy ) ) ); echo "
\n"; echo $args['after_widget']; } /** * @param array $new_instance * @param array $old_instance * @return array */ public function update( $new_instance, $old_instance ) { $instance = array(); $instance['title'] = sanitize_text_field( stripslashes( $new_instance['title'] ) ); $instance['taxonomy'] = stripslashes($new_instance['taxonomy']); return $instance; } /** * @param array $instance */ public function form( $instance ) { $current_taxonomy = $this->_get_current_taxonomy($instance); $title = isset( $instance['title'] ) ? $instance['title'] : ''; ?>