'', 'order' => 'DESC', 'orderby' => 'date', 'select' => 'all', 'show' => 6, 'cats' => array(), 'thumbnails' => true, ); /* Widget setup */ function __construct() { /* Widget settings. */ $widget_ops = array( 'description' => _x( 'Blog categories', 'widget', 'the7mk2' ) ); /* Create the widget. */ parent::__construct( 'presscore-blog-categories', DT_WIDGET_PREFIX . _x( 'Blog categories', 'widget', 'the7mk2' ), $widget_ops ); } /* Display the widget */ function widget( $args, $instance ) { extract( $args ); $instance = wp_parse_args( (array) $instance, self::$widget_defaults ); /* Our variables from the widget settings. */ $title = apply_filters( 'widget_title', $instance['title'] ); $cats_args = array( 'show_count' => true, 'hierarchical' => false, 'title_li' => '', 'echo' => false, 'walker' => new Dt_Inc_Classes_WidgetsCategory_Walker() ); switch ( $instance['select'] ) { case 'except' : $cats_args['exclude'] = implode( ',', $instance['cats'] ); break; case 'only' : $cats_args['include'] = implode( ',', $instance['cats'] ); } $cats = wp_list_categories( $cats_args ); echo $before_widget ; // title if ( $title ) echo $before_title . $title . $after_title; echo ''; echo $after_widget; } /* Update the widget settings */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['select'] = in_array( $new_instance['select'], array('all', 'only', 'except') ) ? $new_instance['select'] : 'all'; $instance['cats'] = (array) $new_instance['cats']; if ( empty($instance['cats']) ) { $instance['select'] = 'all'; } return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { /* Set up some default widget settings. */ $instance = wp_parse_args( (array) $instance, self::$widget_defaults ); $title = strip_tags( $instance['title'] ); $terms = get_terms( 'category', array( 'hide_empty' => 1, 'hierarchical' => false ) ); ?>


term_id, $instance['cats']) ); ?> />