prefix = Easy_get_prefix(); /* Set the widget textdomain. */ $this->textdomain = Easy_get_textdomain(); /* Set up the widget options. */ $widget_options = array( 'classname' => 'tags', 'description' => esc_html__( 'An advanced widget that gives you total control over the output of your tags.', $this->textdomain ) ); /* Set up the widget control options. */ $control_options = array( 'width' => 800, 'height' => 350, 'id_base' => "{$this->prefix}-tags" ); /* Create the widget. */ $this->WP_Widget( "{$this->prefix}-tags", esc_attr__( 'Tags', $this->textdomain ), $widget_options, $control_options ); } /** * Outputs the widget based on the arguments input through the widget controls. * @since 0.6 */ function widget( $args, $instance ) { extract( $args ); /* Set up the arguments for wp_tag_cloud(). */ $args = array( 'taxonomy' => $instance['taxonomy'], 'largest' => !empty( $instance['largest'] ) ? absint( $instance['largest'] ) : 22, 'smallest' => !empty( $instance['smallest'] ) ? absint( $instance['smallest'] ) : 8, 'number' => intval( $instance['number'] ), 'child_of' => intval( $instance['child_of'] ), 'parent' => !empty( $instance['parent'] ) ? intval( $instance['parent'] ) : '', 'separator' => !empty( $instance['separator'] ) ? $instance['separator'] : "\n", 'pad_counts' => !empty( $instance['pad_counts'] ) ? true : false, 'hide_empty' => !empty( $instance['hide_empty'] ) ? true : false, 'unit' => $instance['unit'], 'format' => $instance['format'], 'include' => !empty( $instance['include'] ) ? join( ', ', $instance['include'] ) : '', 'exclude' => !empty( $instance['exclude'] ) ? join( ', ', $instance['exclude'] ) : '', 'order' => $instance['order'], 'orderby' => $instance['orderby'], 'link' => $instance['link'], 'search' => $instance['search'], 'name__like' => $instance['name__like'], 'echo' => false ); /* Output the theme's $before_widget wrapper. */ echo $before_widget; /* If a title was input by the user, display it. */ if ( !empty( $instance['title'] ) ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; /* Get the tag cloud. */ $tags = str_replace( array( "\r", "\n", "\t" ), ' ', wp_tag_cloud( $args ) ); /* If $format should be flat, wrap it in the

element. */ if ( 'flat' == $instance['format'] ) $tags = '

' . $tags . '

'; /* Output the tag cloud. */ echo $tags; /* Close the theme's widget wrapper. */ echo $after_widget; } /** * Updates the widget control options for the particular instance of the widget. * @since 0.6 */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Set the instance to the new instance. */ $instance = $new_instance; /* If new taxonomy is chosen, reset includes and excludes. */ if ( $instance['taxonomy'] !== $old_instance['taxonomy'] ) { $instance['include'] = array(); $instance['exclude'] = array(); } $instance['title'] = strip_tags( $new_instance['title'] ); $instance['smallest'] = strip_tags( $new_instance['smallest'] ); $instance['largest'] = strip_tags( $new_instance['largest'] ); $instance['number'] = strip_tags( $new_instance['number'] ); $instance['separator'] = strip_tags( $new_instance['separator'] ); $instance['name__like'] = strip_tags( $new_instance['name__like'] ); $instance['search'] = strip_tags( $new_instance['search'] ); $instance['child_of'] = strip_tags( $new_instance['child_of'] ); $instance['parent'] = strip_tags( $new_instance['parent'] ); $instance['unit'] = $new_instance['unit']; $instance['format'] = $new_instance['format']; $instance['orderby'] = $new_instance['orderby']; $instance['order'] = $new_instance['order']; $instance['taxonomy'] = $new_instance['taxonomy']; $instance['link'] = $new_instance['link']; $instance['pad_counts'] = ( isset( $new_instance['pad_counts'] ) ? 1 : 0 ); $instance['hide_empty'] = ( isset( $new_instance['hide_empty'] ) ? 1 : 0 ); return $instance; } /** * Displays the widget control options in the Widgets admin screen. * @since 0.6 */ function form( $instance ) { /* Set up the default form values. */ $defaults = array( 'title' => esc_attr__( 'Tags', $this->textdomain ), 'order' => 'ASC', 'orderby' => 'name', 'format' => 'flat', 'include' => array(), 'exclude' => array(), 'unit' => 'pt', 'smallest' => 8, 'largest' => 22, 'link' => 'view', 'number' => 45, 'separator' => '', 'child_of' => '', 'parent' => '', 'taxonomy' => 'post_tag', 'hide_empty' => 1, 'pad_counts' => false, 'search' => '', 'name__like' => '' ); /* Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args( (array) $instance, $defaults ); /*