prefix = Easy_get_prefix(); /* Set the widget textdomain. */ $this->textdomain = Easy_get_textdomain(); /* Set up the widget options. */ $widget_options = array( 'classname' => 'categories', 'description' => esc_html__( 'An advanced widget that gives you total control over the output of your category links.', $this->textdomain ) ); /* Set up the widget control options. */ $control_options = array( 'width' => 800, 'height' => 350, 'id_base' => "{$this->prefix}-categories" ); /* Create the widget. */ $this->WP_Widget( "{$this->prefix}-categories", esc_attr__( 'Categories', $this->textdomain ), $widget_options, $control_options ); } /** * Outputs the widget based on the arguments input through the widget controls. * @since 0.6.0 */ function widget( $args, $instance ) { extract( $args ); /* Set up the arguments for wp_list_categories(). */ $args = array( 'taxonomy' => $instance['taxonomy'], 'style' => $instance['style'], 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'include' => !empty( $instance['include'] ) ? join( ', ', $instance['include'] ) : '', 'exclude' => !empty( $instance['exclude'] ) ? join( ', ', $instance['exclude'] ) : '', 'exclude_tree' => $instance['exclude_tree'], 'depth' => intval( $instance['depth'] ), 'number' => intval( $instance['number'] ), 'child_of' => intval( $instance['child_of'] ), 'current_category' => intval( $instance['current_category'] ), 'feed' => $instance['feed'], 'feed_type' => $instance['feed_type'], 'feed_image' => esc_url( $instance['feed_image'] ), 'search' => $instance['search'], 'hierarchical' => !empty( $instance['hierarchical'] ) ? true : false, 'use_desc_for_title' => !empty( $instance['use_desc_for_title'] ) ? true : false, 'show_last_update' => !empty( $instance['show_last_update'] ) ? true : false, 'show_count' => !empty( $instance['show_count'] ) ? true : false, 'hide_empty' => !empty( $instance['hide_empty'] ) ? true : false, 'title_li' => false, 'echo' => false ); /* Output the theme's 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 categories list. */ $categories = str_replace( array( "\r", "\n", "\t" ), '', wp_list_categories( $args ) ); /* If 'list' is the user-selected style, wrap the categories in an unordered list. */ if ( 'list' == $args['style'] ) $categories = ''; /* Output the categories list. */ echo $categories; /* Close the theme's widget wrapper. */ echo $after_widget; } /** * Updates the widget control options for the particular instance of the widget. * @since 0.6.0 */ 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'] && '' !== $old_instance['taxonomy'] ) { $instance['include'] = array(); $instance['exclude'] = array(); } $instance['title'] = strip_tags( $new_instance['title'] ); $instance['taxonomy'] = $new_instance['taxonomy']; $instance['exclude_tree'] = strip_tags( $new_instance['exclude_tree'] ); $instance['depth'] = strip_tags( $new_instance['depth'] ); $instance['number'] = strip_tags( $new_instance['number'] ); $instance['child_of'] = strip_tags( $new_instance['child_of'] ); $instance['current_category'] = strip_tags( $new_instance['current_category'] ); $instance['feed'] = strip_tags( $new_instance['feed'] ); $instance['feed_image'] = strip_tags( $new_instance['feed_image'] ); $instance['search'] = strip_tags( $new_instance['search'] ); $instance['hierarchical'] = ( isset( $new_instance['hierarchical'] ) ? 1 : 0 ); $instance['use_desc_for_title'] = ( isset( $new_instance['use_desc_for_title'] ) ? 1 : 0 ); $instance['show_last_update'] = ( isset( $new_instance['show_last_update'] ) ? 1 : 0 ); $instance['show_count'] = ( isset( $new_instance['show_count'] ) ? 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.0 */ function form( $instance ) { /* Set up the default form values. */ $defaults = array( 'title' => esc_attr__( 'Categories', $this->textdomain ), 'taxonomy' => 'category', 'style' => 'list', 'include' => array(), 'exclude' => array(), 'exclude_tree' => '', 'child_of' => '', 'current_category' => '', 'search' => '', 'hierarchical' => true, 'hide_empty' => true, 'order' => 'ASC', 'orderby' => 'name', 'depth' => 0, 'number' => '', 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'use_desc_for_title' => false, 'show_last_update' => false, 'show_count' => false, ); /* Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args( (array) $instance, $defaults ); /*