esc_html__( 'Display two columns of categories', 'simple-days' ), ) // Args ); } /** * Set default settings of the widget */ private function default_settings() { $defaults = array( 'title_left' => esc_html__( 'Category', 'simple-days' ), 'category_left' => 0, 'title_right' => esc_html__( 'Category', 'simple-days' ), 'category_right' => 0, 'number_post' => 4, 'date' => true, 'image_size' => 'thumbnail', 'heading_image_size' => 'medium', 'random' => false, 'sticky_posts' => true, 'include_page' => false, 'to_main_content' => false, ); return $defaults; } public function widget( $args, $instance ) { $settings = wp_parse_args( $instance, $this->default_settings() ); $orderby = 'date'; if($settings['random'])$orderby = 'rand'; $post_type = array('post'); if($settings['include_page']) $post_type = array('post','page'); include_once SIMPLE_DAYS_THEME_DIR . 'template-parts/custom_hp/hp-category_heading.php'; include_once SIMPLE_DAYS_THEME_DIR . 'template-parts/custom_hp/hp-category_from_2nd.php'; $angle = array('left','right'); $grid_margin = array('left' => 'ch_sep','right' => ''); echo $args['before_widget']; echo '
'; foreach ($angle as $angle_value) { $latest_posts = new WP_Query( array( 'post_type' => $post_type, 'cat' => $settings['category_'.$angle_value], 'posts_per_page' => $settings['number_post'], 'post_status' => 'publish', 'ignore_sticky_posts' => $settings['sticky_posts'], 'orderby' => $orderby, ) ); if ( $latest_posts->have_posts() ) : $i=0; echo '
'; if ( ! empty($settings['title_'.$angle_value]) ) { echo $args['before_title']. $settings['title_'.$angle_value] . $args['after_title']; } echo '
'; while ( $latest_posts->have_posts() ) : $latest_posts->the_post(); global $post; if($i === 0){ simple_days_custom_hp_category_heading($post,$settings); }else{ simple_days_custom_hp_category_from_2nd($post,$settings); } ++$i; endwhile; echo '
'; endif; } echo '
'; echo $args['after_widget']; } public function form( $instance ) { // Get Widget Settings. $settings = wp_parse_args( $instance, $this->default_settings() ); ?>

esc_html__( 'All Categories', 'simple-days' ), 'show_count' => true, 'hide_empty' => false, 'selected' => $settings['category_left'], 'name' => $this->get_field_name( 'category_left' ), 'id' => $this->get_field_id( 'category_left' ), 'depth' => 1, 'hierarchical' => true, ); wp_dropdown_categories( $args ); ?>

esc_html__( 'All Categories', 'simple-days' ), 'show_count' => true, 'hide_empty' => false, 'selected' => $settings['category_right'], 'name' => $this->get_field_name( 'category_right' ), 'id' => $this->get_field_id( 'category_right' ), 'depth' => 1, 'hierarchical' => true, ); wp_dropdown_categories( $args ); ?>

class="checkbox" id="get_field_id('date'); ?>" name="get_field_name('date'); ?>" />



class="checkbox" id="get_field_id('random'); ?>" name="get_field_name('random'); ?>" />

class="checkbox" id="get_field_id('sticky_posts'); ?>" name="get_field_name('sticky_posts'); ?>" />

class="checkbox" id="get_field_id( 'include_page' ) ); ?>" name="get_field_name( 'include_page' ) ); ?>" />

class="checkbox" id="get_field_id( 'to_main_content' ) ); ?>" name="get_field_name( 'to_main_content' ) ); ?>" />