widget_cssclass = 'bloglex-categories-widget'; $this->widget_description = __('Displays post categories with image in grid', 'bloglex'); $this->widget_id = 'bloglex_categories'; $this->widget_name = __('Bloglex: Categories', 'bloglex'); $this->settings = $this->get_widget_settings(); parent::__construct(); } protected function get_widget_settings() { $post_categories = array(); $categories = get_categories(array( 'orderby' => 'name', 'order' => 'ASC', )); if (!empty($categories)) { foreach ($categories as $cat) { $post_categories[$cat->term_id] = $cat->name; } } return array( 'title' => array( 'type' => 'text', 'label' => __('Title', 'bloglex'), ), 'font_size' => array( 'type' => 'select', 'label' => __('Entry title font size', 'bloglex'), 'options' => array( 'entry-title-xsmall' => __('Extra Small', 'bloglex'), 'entry-title-small' => __('Small', 'bloglex'), 'entry-title-medium' => __('Medium', 'bloglex'), 'entry-title-big' => __('Big', 'bloglex'), ), 'std' => 'entry-title-small', ), 'font_style' => array( 'type' => 'select', 'label' => __('Entry title font style', 'bloglex'), 'options' => array( 'entry-title-normal' => __('Normal', 'bloglex'), 'entry-title-italic' => __('Italic', 'bloglex'), ), 'std' => 'entry-title-normal', ), 'categories' => array( 'type' => 'multi-checkbox', 'label' => __('Select Categories', 'bloglex'), 'desc' => sprintf( __('To be displayed, a category must have a "Thumbnail" image. %s', 'bloglex'), '' . __('Click here', 'bloglex') . ' ' . __('to add one.', 'bloglex') ), 'options' => $post_categories, ), 'no_of_column' => array( 'type' => 'number', 'step' => 1, 'min' => 1, 'max' => 4, 'std' => 1, 'label' => __('Number of Column', 'bloglex'), ), 'display_style' => array( 'type' => 'select', 'label' => __('Display Style', 'bloglex'), 'options' => array( 'categories-layout-1' => __('Style 1', 'bloglex'), 'categories-layout-2' => __('Style 2', 'bloglex'), 'categories-layout-3' => __('Style 3', 'bloglex'), ), 'std' => 'categories-layout-1', ), 'show_post_count' => array( 'type' => 'checkbox', 'label' => __('Show Post Count', 'bloglex'), 'std' => false, ), 'image_size' => array( 'type' => 'select', 'label' => __('Image size', 'bloglex'), 'options' => array( 'entry-image-large' => __('Large', 'bloglex'), 'entry-image-big' => __('Big', 'bloglex'), 'entry-image-medium' => __('Medium', 'bloglex'), 'entry-image-small' => __('Small', 'bloglex'), ), 'std' => 'entry-image-medium', ), 'image_hover_effects' => array( 'type' => 'select', 'label' => __('Image hover effects', 'bloglex'), 'options' => array( 'hover-effect-shine' => __('Shine', 'bloglex'), 'hover-effect-slide' => __('Slide', 'bloglex'), 'hover-effect-zoom' => __('Zoom', 'bloglex'), ), 'std' => 'hover-effect-shine', ), ); } public function widget($args, $instance) { ob_start(); if (!empty($instance['categories'])) { echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . esc_html($instance['title']) . $args['after_title']; } $font_size = !empty($instance['font_size']) ? $instance['font_size'] : $this->settings['font_size']['std']; $font_style = !empty($instance['font_style']) ? $instance['font_style'] : $this->settings['font_style']['std']; $column = isset($instance['no_of_column']) ? $instance['no_of_column'] : $this->settings['no_of_column']['std']; $show_post_count = isset($instance['show_post_count']) ? $instance['show_post_count'] : $this->settings['show_post_count']['std']; $display_style = isset($instance['display_style']) ? $instance['display_style'] : $this->settings['display_style']['std']; $col_class = $this->get_column_class($column); $img_size = 'medium_large'; $wrapper_class = $display_style; if ($show_post_count) { $wrapper_class .= ' bloglex-cat-post-count-active'; } $style_attr = ' style="background-color:value;"'; ?>
count; $color = get_term_meta($cat_info->term_id, 'category_color', true); $build_style_attr = $color ? str_replace('value', $color, $style_attr) : ''; ?>