esc_html__( 'Display one columns of categories', 'simple-days' ), ) // Args ); } /** * Set default settings of the widget */ private function default_settings() { $defaults = array( 'title' => esc_html__( 'Category', 'simple-days' ), 'category' => 0, 'number_post' => 5, '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'); $latest_posts = new WP_Query( array( 'post_type' => $post_type, 'cat' => $settings['category'], 'posts_per_page' => $settings['number_post'], 'post_status' => 'publish', 'ignore_sticky_posts' => $settings['sticky_posts'], 'orderby' => $orderby, ) ); if ( $latest_posts->have_posts() ) : echo $args['before_widget']; echo '
'; 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'; $i=0; if ( ! empty($settings['title']) ) { $args['before_title'] = str_replace( 'widget_title','widget_title w100',$args['before_title']); echo $args['before_title']. $settings['title'] . $args['after_title']; } echo '
'; echo '
'; while ( $latest_posts->have_posts() ) : $latest_posts->the_post(); global $post; if($i === 0){ simple_days_custom_hp_category_heading($post,$settings); }elseif($i === 1){ echo '
'; simple_days_custom_hp_category_from_2nd($post,$settings); }else{ simple_days_custom_hp_category_from_2nd($post,$settings); } ++$i; endwhile; if($i >= 2){ echo '
'; }elseif($i === 1){ 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'], 'name' => $this->get_field_name( 'category' ), 'id' => $this->get_field_id( 'category' ), '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' ) ); ?>" />