start_controls_section( 'post_option', [ 'label' => __( 'Post Option', '99fy' ), ] ); $this->add_control( 'post_column', [ 'label' => __( 'Column', '99fy' ), 'type' => Controls_Manager::SELECT, 'default' => '3', 'options' => [ '1' => __( 'One', '99fy' ), '2' => __( 'Two', '99fy' ), '3' => __( 'Three', '99fy' ), '4' => __( 'Four', '99fy' ), ], ] ); $this->add_control( 'post_categories', [ 'label' => esc_html__( 'Categories', '99fy' ), 'type' => Controls_Manager::SELECT2, 'label_block' => true, 'multiple' => true, 'options' => nnfy_get_taxonomies(), ] ); $this->add_control( 'post_limit', [ 'label' => __('Limit', '99fy'), 'type' => Controls_Manager::NUMBER, 'default' => 5, 'separator'=>'before', ] ); $this->add_control( 'custom_order', [ 'label' => esc_html__( 'Custom order', '99fy' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'no', ] ); $this->add_control( 'postorder', [ 'label' => esc_html__( 'Order', '99fy' ), 'type' => Controls_Manager::SELECT, 'default' => 'DESC', 'options' => [ 'DESC' => esc_html__('Descending','99fy'), 'ASC' => esc_html__('Ascending','99fy'), ], 'condition' => [ 'custom_order!' => 'yes', ] ] ); $this->add_control( 'orderby', [ 'label' => esc_html__( 'Orderby', '99fy' ), 'type' => Controls_Manager::SELECT, 'default' => 'none', 'options' => [ 'none' => esc_html__('None','99fy'), 'ID' => esc_html__('ID','99fy'), 'date' => esc_html__('Date','99fy'), 'name' => esc_html__('Name','99fy'), 'title' => esc_html__('Title','99fy'), 'comment_count' => esc_html__('Comment count','99fy'), 'rand' => esc_html__('Random','99fy'), ], 'condition' => [ 'custom_order' => 'yes', ] ] ); $this->add_control( 'show_date', [ 'label' => esc_html__( 'Date', '99fy' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_author', [ 'label' => esc_html__( 'Author', '99fy' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_title', [ 'label' => esc_html__( 'Title', '99fy' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'title_length', [ 'label' => __( 'Title Length', '99fy' ), 'type' => Controls_Manager::NUMBER, 'step' => 1, 'default' => 5, 'condition'=>[ 'show_title'=>'yes', ] ] ); $this->add_control( 'show_content', [ 'label' => esc_html__( 'Content', '99fy' ), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'content_length', [ 'label' => __( 'Content Length', '99fy' ), 'type' => Controls_Manager::NUMBER, 'step' => 1, 'default' => 20, 'condition'=>[ 'show_content'=>'yes', ] ] ); $this->end_controls_section(); // Style tab section $this->start_controls_section( 'blog_style_section', [ 'label' => esc_html__( 'Style', '99fy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'heading_image_style', [ 'label' => __( 'Thumbnails', '99fy' ), 'type' => Controls_Manager::HEADING, 'separator' => 'after', ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'blog_thumbnail_border', 'label' => __( 'Border', '99fy' ), 'selector' => '{{WRAPPER}} .blog-img', ] ); $this->add_responsive_control( 'blog_thumbnail_margin', [ 'label' => __( 'Margin', '99fy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .blog-img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'blog_thumbnail_padding', [ 'label' => __( 'Padding', '99fy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .blog-img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'heading_title_style', [ 'label' => __( 'Title', '99fy' ), 'type' => Controls_Manager::HEADING, 'separator' => 'after', ] ); $this->add_control( 'title_color', [ 'label' => __( 'Title Color', '99fy' ), 'type' => Controls_Manager::COLOR, 'default'=>'#444444', 'selectors' => [ '{{WRAPPER}} .blog-info a' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'title_hover_color', [ 'label' => __( 'Title Hover Color', '99fy' ), 'type' => Controls_Manager::COLOR, 'default'=>'#444444', 'selectors' => [ '{{WRAPPER}} .blog-info a:hover' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'label' => __( 'Title Typography', '99fy' ), 'selector' => '{{WRAPPER}} .blog-info > h4', ] ); $this->add_responsive_control( 'blog_title_margin', [ 'label' => __( 'Margin', '99fy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .blog-info > h4' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'heading_content_style', [ 'label' => __( 'Content', '99fy' ), 'type' => Controls_Manager::HEADING, 'separator' => 'after', ] ); $this->add_control( 'content_color', [ 'label' => __( 'Content Color', '99fy' ), 'type' => Controls_Manager::COLOR, 'default'=>'#878787', 'selectors' => [ '{{WRAPPER}} .blog-info > p' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'content_typography', 'label' => __( 'Content Typography', '99fy' ), 'selector' => '{{WRAPPER}} .blog-info > p', ] ); $this->add_responsive_control( 'blog_content_margin', [ 'label' => __( 'Margin', '99fy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .blog-info > p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'heading_blog_meta_style', [ 'label' => __( 'Meta', '99fy' ), 'type' => Controls_Manager::HEADING, 'separator' => 'after', ] ); $this->add_control( 'blog_meta_link_color', [ 'label' => __( 'Post Meta Info Link Color', '99fy' ), 'type' => Controls_Manager::COLOR, 'default'=>'#444444', 'selectors' => [ '{{WRAPPER}} .blog-info h6 a' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'blog_meta_label_color', [ 'label' => __( 'Post Meta Info Label Color', '99fy' ), 'type' => Controls_Manager::COLOR, 'default'=>'#878787', 'selectors' => [ '{{WRAPPER}} .blog-info h6' => 'color: {{VALUE}}', '{{WRAPPER}} .blog-info span' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'meta_typography', 'label' => __( 'Meta Typography', '99fy' ), 'selector' => '{{WRAPPER}} .blog-info > h6,{{WRAPPER}} .blog-info span', ] ); $this->add_responsive_control( 'blog_meta_margin', [ 'label' => __( 'Margin', '99fy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .blog-info h6' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style tab end } protected function render( $instance = [] ) { $settings = $this->get_settings_for_display(); $custom_order_ck = ! empty( $settings['custom_order'] ) ? $settings['custom_order'] : ''; $orderby = ! empty( $settings['orderby'] ) ? $settings['orderby'] : 'date'; $postorder = ! empty( $settings['postorder'] ) ? $settings['postorder'] : 'DESC'; // Query $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => ! empty( $settings['post_limit'] ) ? absint( $settings['post_limit'] ) : 3, 'order' => sanitize_text_field( $postorder ) ); // Custom Order if ( 'yes' === $custom_order_ck ) { $args['orderby'] = sanitize_text_field( $orderby ); } // Categories $get_categories = ! empty( $settings['post_categories'] ) ? $settings['post_categories'] : array(); if ( ! empty( $get_categories ) ) { if ( is_array( $get_categories ) && count( $get_categories ) > 0 ) { $field_name = is_numeric( $get_categories[0] ) ? 'term_id' : 'slug'; $args['tax_query'] = array( array( 'taxonomy' => 'category', 'terms' => array_map( 'sanitize_text_field', $get_categories ), 'field' => $field_name, 'include_children' => false ) ); } } $post_query = new \WP_Query( $args ); $this->add_render_attribute( 'post_area_attr', 'class', 'sc_blog' ); ?>