'blogmagazine_featured_slider', 'description' => esc_html__( 'Displays posts from selected categories in the slider with the featured section.', 'blogmagazine' ) ); parent::__construct( 'blogmagazine_featured_slider', esc_html__( 'DG: Featured Slider', 'blogmagazine' ), $widget_ops ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ public function widget_fields( $instance = array() ) { $fields = array( 'dg_widget_tab' => array( 'dg_widget_field_name' => 'dg_widget_tab', 'dg_widget_field_title' => esc_html__( 'General', 'blogmagazine' ), 'dg_widget_field_default' => 'general', 'dg_widget_field_type' => 'tabgroup', 'dg_widget_field_options' => array( 'general'=>array( 'dg_widget_field_title'=>esc_html__('General', 'blogmagazine'), 'dg_widget_field_options'=> array( 'title' => array( 'dg_widget_field_name' => 'title', 'dg_widget_field_title' => esc_html__( 'Block title', 'blogmagazine' ), 'dg_widget_field_description' => esc_html__( 'Enter your block title. (Optional - Leave blank to hide the title.)', 'blogmagazine' ), 'dg_widget_field_type' => 'text' ), 'title_target' => array( 'dg_widget_field_name' => 'title_target', 'dg_widget_field_wraper' => 'title-target', 'dg_widget_field_title' => esc_html__( 'Link Target', 'blogmagazine' ), 'dg_widget_field_default' => '_self', 'dg_widget_field_type' => 'select', 'dg_widget_field_options' => dglib_link_target(), 'dg_widget_field_relation' => array( 'exist' => array( 'show_fields' => array( 'title-link', ), ), 'empty' => array( 'hide_fields' => array( 'title-link', ), ), ), ), 'title_link' => array( 'dg_widget_field_name' => 'title_link', 'dg_widget_field_wraper' => 'title-link', 'dg_widget_field_title' => esc_html__( 'Title link', 'blogmagazine' ), 'dg_widget_field_default' => '', 'dg_widget_field_type' => 'text', ), 'slider_term_ids' => array( 'dg_widget_field_name' => 'slider_term_ids', 'dg_widget_field_title' => esc_html__( 'Slider Categories', 'blogmagazine' ), 'dg_widget_taxonomy_type' => 'category', 'dg_widget_field_type' => 'multitermlist', ), 'featured_term_ids' => array( 'dg_widget_field_name' => 'featured_term_ids', 'dg_widget_field_title' => esc_html__( 'Featured Post Categories', 'blogmagazine' ), 'dg_widget_taxonomy_type' => 'category', 'dg_widget_field_type' => 'multitermlist', ) ) ) ) ) ); $widget_fields_key = 'fields_'.$this->id_base; $widgets_fields = apply_filters( $widget_fields_key, $fields ); return $widgets_fields; } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ){ extract( $args ); $title = isset( $instance['title'] ) ? esc_attr($instance['title']) : ''; $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $title_link = isset( $instance['title_link'] ) ? esc_url($instance['title_link']) : ''; $title_target = isset( $instance['title_target'] ) ? esc_attr($instance['title_target']) : ''; $slider_term_ids = empty( $instance['slider_term_ids'] ) ? '' : $instance['slider_term_ids']; $featured_term_ids = empty( $instance['featured_term_ids'] ) ? '' : $instance['featured_term_ids']; echo $before_widget; ?>