𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/builxejc/public_html/wp-content/plugins/kinsley-plugin/elementor/widgets//blog-grid.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Kinsley Blog Grid Widget.
*
* @since 1.0
*/
class Kinsley_Blog_Grid_Widget extends Widget_Base {
public function get_name() {
return 'kinsley-blog-grid';
}
public function get_title() {
return esc_html__( 'Blog (Grid)', 'kinsley-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'kinsley-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'heading_tab',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'heading',
[
'label' => esc_html__( 'Heading', 'kinsley-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'kinsley-plugin' ),
'label_off' => __( 'Hide', 'kinsley-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Title', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'title_tag',
[
'label' => esc_html__( 'Title Tag', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'h2',
'options' => [
'h1' => __( 'H1', 'kinsley-plugin' ),
'h2' => __( 'H2', 'kinsley-plugin' ),
'h3' => __( 'H3', 'kinsley-plugin' ),
'h4' => __( 'H4', 'kinsley-plugin' ),
'div' => __( 'DIV', 'kinsley-plugin' ),
],
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'title_align',
[
'label' => esc_html__( 'Title Align', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => __( 'Default', 'kinsley-plugin' ),
'left' => __( 'Left', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'description',
[
'label' => esc_html__( 'Description', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter description', 'kinsley-plugin' ),
'default' => esc_html__( 'Description', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'more',
[
'label' => esc_html__( 'Button (label)', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Button', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'link',
[
'label' => esc_html__( 'Button (link)', 'kinsley-plugin' ),
'type' => Controls_Manager::URL,
'show_external' => true,
'condition' => [
'heading' => 'yes'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_tab',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'source',
[
'label' => esc_html__( 'Source', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'all',
'options' => [
'all' => __( 'All', 'kinsley-plugin' ),
'categories' => __( 'Categories', 'kinsley-plugin' ),
'tags' => __( 'Tags', 'kinsley-plugin' ),
'custom' => __( 'Custom', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'source_categories',
[
'label' => esc_html__( 'Source', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT2,
'label_block' => true,
'multiple' => true,
'options' => $this->get_blog_categories(),
'condition' => [
'source' => 'categories'
],
]
);
$this->add_control(
'source_tags',
[
'label' => esc_html__( 'Tags', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT2,
'label_block' => true,
'multiple' => true,
'options' => $this->get_blog_tags(),
'condition' => [
'source' => 'tags'
],
]
);
$this->add_control(
'source_custom',
[
'label' => esc_html__( 'Custom Menu Items', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT2,
'label_block' => true,
'multiple' => true,
'options' => $this->get_blog_items_custom(),
'condition' => [
'source' => 'custom'
],
]
);
$this->add_control(
'limit',
[
'label' => esc_html__( 'Number of Items', 'kinsley-plugin' ),
'type' => Controls_Manager::NUMBER,
'placeholder' => 6,
'default' => 6,
]
);
$this->add_control(
'sort',
[
'label' => esc_html__( 'Sorting By', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'date',
'options' => [
'date' => __( 'Date', 'kinsley-plugin' ),
'title' => __( 'Title', 'kinsley-plugin' ),
'rand' => __( 'Random', 'kinsley-plugin' ),
'menu_order' => __( 'Order', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'order',
[
'label' => esc_html__( 'Order', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'desc',
'options' => [
'asc' => __( 'ASC', 'kinsley-plugin' ),
'desc' => __( 'DESC', 'kinsley-plugin' ),
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'pagination_tab',
[
'label' => esc_html__( 'Pagination', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'pagination',
[
'label' => esc_html__( 'Pagination Type', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'pages',
'options' => [
'pages' => __( 'Pages', 'kinsley-plugin' ),
'button' => __( 'Button', 'kinsley-plugin' ),
'no' => __( 'No', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'more_text',
[
'label' => esc_html__( 'More Text', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter text', 'kinsley-plugin' ),
'condition' => [
'pagination' => 'button'
],
]
);
$this->add_control(
'more_btn_txt',
[
'label' => esc_html__( 'Button (title)', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter button', 'kinsley-plugin' ),
'default' => esc_html__( 'All Posts', 'kinsley-plugin' ),
'condition' => [
'pagination' => 'button'
],
]
);
$this->add_control(
'more_btn_link',
[
'label' => esc_html__( 'Button (link)', 'kinsley-plugin' ),
'type' => Controls_Manager::URL,
'show_external' => true,
'condition' => [
'pagination' => 'button'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'settings_tab',
[
'label' => esc_html__( 'Settings', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'bg_position',
[
'label' => esc_html__( 'BG Transition Position', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => [
'top' => __( 'Top', 'kinsley-plugin' ),
'bottom' => __( 'Bottom', 'kinsley-plugin' ),
'middle' => __( 'Middle', 'kinsley-plugin' ),
'none' => __( 'None', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'container_type',
[
'label' => esc_html__( 'Container', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'basic',
'options' => [
'basic' => __( 'Basic', 'kinsley-plugin' ),
'full' => __( 'Full', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'layout',
[
'label' => esc_html__( 'Layout', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'column-3',
'options' => [
'column-1' => __( '1 Columns', 'kinsley-plugin' ),
'column-2' => __( '2 Columns', 'kinsley-plugin' ),
'column-3' => __( '3 Columns', 'kinsley-plugin' ),
],
]
);
$this->add_control('attr_featured_image', array(
'type' => Controls_Manager::SELECT,
'label' => __('Featured Image', 'kinsley-plugin'),
'description' => __('Whether to display featured image of the post type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_categories', array(
'type' => Controls_Manager::SELECT,
'label' => __('Categories', 'kinsley-plugin'),
'description' => __('Whether to display categories of the post type.', 'kinsley-plugin'),
'default' => 'false',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_details', array(
'type' => Controls_Manager::SELECT,
'label' => __('Details', 'kinsley-plugin'),
'description' => __('Whether to display details of the post type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_details_author', array(
'type' => Controls_Manager::SELECT,
'label' => __(' - author', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_details_date', array(
'type' => Controls_Manager::SELECT,
'label' => __(' - date', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_title', array(
'type' => Controls_Manager::SELECT,
'label' => __('Title', 'kinsley-plugin'),
'description' => __('Whether to display title of the post type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_excerpt', array(
'type' => Controls_Manager::SELECT,
'label' => __('Excerpt', 'kinsley-plugin'),
'description' => __('Whether to display excerpt (short description) of the post type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_view_button', array(
'type' => Controls_Manager::SELECT,
'label' => __('Read More Button', 'kinsley-plugin'),
'description' => __('Whether to display "Read more" button with the link to post type.', 'kinsley-plugin'),
'default' => 'false',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->end_controls_section();
$this->start_controls_section(
'title_styling',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-title--h' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-title--h',
]
);
$this->add_control(
'description_color',
[
'label' => esc_html__( 'Description Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'description_typography',
'label' => esc_html__( 'Description Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-text',
]
);
$this->add_control(
'button_color',
[
'label' => esc_html__( 'Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'button_bgcolor',
[
'label' => esc_html__( 'Button BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'label' => esc_html__( 'Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-btn',
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_styling',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_bg_color',
[
'label' => esc_html__( 'Item BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-blog-card' => 'background-color: {{VALUE}}; box-shadow: none;',
],
]
);
$this->add_control(
'item_details_bgcolor',
[
'label' => esc_html__( 'Details BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-blog-card .knsl-description-frame .knsl-room-features, {{WRAPPER}} .knsl-blog-card .knsl-description-frame .knsl-room-features' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'item_details_color',
[
'label' => esc_html__( 'Details Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-blog-card .knsl-description-frame .knsl-room-features .knsl-feature' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_details_typography',
'label' => esc_html__( 'Details Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-blog-card .knsl-description-frame .knsl-room-features .knsl-feature',
]
);
$this->add_control(
'item_title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-blog-card .knsl-description-frame h4' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_title_typography',
'label' => esc_html__( 'Title Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-blog-card .knsl-description-frame h4',
]
);
$this->add_control(
'item_desc_color',
[
'label' => esc_html__( 'Description Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-blog-card .knsl-description-frame .knsl-text-light' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_desc_typography',
'label' => esc_html__( 'Description Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-blog-card .knsl-description-frame .knsl-text-light',
]
);
$this->end_controls_section();
$this->start_controls_section(
'pagination_styling',
[
'label' => esc_html__( 'Pagination', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'pagination_color',
[
'label' => esc_html__( 'Pagination Links Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-pagination a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'pagination_typography',
'label' => esc_html__( 'Pagination Links Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-pagination',
]
);
$this->add_control(
'more_button_color',
[
'label' => esc_html__( 'More Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-el-more .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'more_button_bgcolor',
[
'label' => esc_html__( 'More Button BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-el-more .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'more_button_bdcolor',
[
'label' => esc_html__( 'More Button Border Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-el-more .knsl-btn' => 'box-shadow: 0 0 0 1px {{VALUE}} !important;',
],
]
);
$this->add_control(
'button_color_hover',
[
'label' => esc_html__( 'More Button Color (Hover)', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-el-more .knsl-btn:hover' => 'color: {{VALUE}} !important;',
],
]
);
$this->add_control(
'button_bgcolor_hover',
[
'label' => esc_html__( 'More Button BG Color (Hover)', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-el-more .knsl-btn:hover' => 'background-color: {{VALUE}} !important;',
],
]
);
$this->add_control(
'button_bdcolor_hover',
[
'label' => esc_html__( 'More Button Border Color (Hover)', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-el-more .knsl-btn:hover' => 'box-shadow: 0 0 0 1px {{VALUE}} !important;',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'more_button_typography',
'label' => esc_html__( 'More Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-el-more .knsl-btn',
]
);
$this->end_controls_section();
}
/**
* Render Categories List.
*
* @since 1.0
*/
protected function get_blog_categories() {
$categories = [];
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'taxonomy' => 'category',
'pad_counts' => false
);
$blog_categories = get_categories( $args );
foreach ( $blog_categories as $category ) {
$categories[$category->term_id] = $category->name;
}
return $categories;
}
protected function get_blog_tags() {
$tags = [];
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'taxonomy' => 'post_tag',
'pad_counts' => false
);
$blog_tags = get_categories( $args );
foreach ( $blog_tags as $tag ) {
$tags[$tag->term_id] = $tag->name;
}
return $tags;
}
protected function get_blog_items_custom() {
$items = [];
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1
);
$menu_items = new \WP_Query( $args );
while ( $menu_items->have_posts() ) : $menu_items->the_post();
$items[get_the_ID()] = get_the_title();
endwhile; wp_reset_postdata();
return $items;
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes( 'title', 'basic' );
$this->add_inline_editing_attributes( 'description', 'basic' );
$this->add_inline_editing_attributes( 'more', 'basic' );
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$page_id = get_the_ID();
$ids = '';
$cat_ids = '';
if ( $settings['source'] == 'categories' ) {
$ids = $settings['source_categories'];
$cat_ids = $ids;
} elseif ( $settings['source'] == 'tags' ) {
$ids = $settings['source_tags'];
} elseif ( $settings['source'] == 'custom' ) {
$ids = $settings['source_custom'];
} else {
}
$cat_args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'taxonomy' => 'category',
'pad_counts' => false,
'include' => $cat_ids
);
$bp_categories = get_categories( $cat_args );
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => $settings['sort'],
'order' => $settings['order'],
'posts_per_page' => $settings['limit'],
'paged' => $paged
);
if( $settings['source'] == 'categories' ) {
$tax_array = array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => $ids
)
);
$args += array('tax_query' => $tax_array);
}
if ( $settings['source'] == 'tags' ) {
$tax_array = array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => $ids
)
);
$args += array('tax_query' => $tax_array);
}
if ( $settings['source'] == 'custom' ) {
$args += array( 'post__in' => $ids );
}
if ( $settings['layout'] == 'column-1' ) {
$item_classes = 'col-lg-12';
} elseif ( $settings['layout'] == 'column-2' ) {
$item_classes = 'col-md-6 col-lg-6';
} else {
$item_classes = 'col-md-6 col-lg-4';
}
$attr_classes = '';
if ( $settings['attr_featured_image'] == 'false' ) {
$attr_classes .= ' attr-featured-false';
}
if ( $settings['attr_categories'] == 'false' ) {
$attr_classes .= ' attr-categories-false';
}
if ( $settings['attr_details'] == 'false' ) {
$attr_classes .= ' attr-details-false';
}
if ( $settings['attr_details_author'] == 'false' ) {
$attr_classes .= ' attr-details-author-false';
}
if ( $settings['attr_details_date'] == 'false' ) {
$attr_classes .= ' attr-details-date-false';
}
if ( $settings['attr_title'] == 'false' ) {
$attr_classes .= ' attr-title-false';
}
if ( $settings['attr_excerpt'] == 'false' ) {
$attr_classes .= ' attr-desc-false';
}
if ( $settings['attr_view_button'] == 'false' ) {
$attr_classes .= ' attr-readmore-false';
}
$q = new \WP_Query( $args );
?>
<!-- blog -->
<section class="knsl-transition-<?php echo esc_attr( $settings['bg_position'] ); ?> knsl-p-0-80">
<?php kinsley_deco_svg( 'right' ); ?>
<?php if ( $settings['container_type'] == 'basic' ) : ?><div class="container"><?php endif; ?>
<div class="row <?php echo esc_attr( $attr_classes ); ?>">
<?php if ( $settings['title'] || $settings['more'] || $settings['description'] ) : ?>
<div class="col-lg-12">
<div class="knsl-center knsl-title-frame knsl-scroll-animation knsl-mb-100<?php if ( $settings['title_align'] == 'left' ) : ?> knsl-title-left<?php endif; ?>">
<?php if ( $settings['title'] ) : ?>
<<?php echo esc_attr( $settings['title_tag'] ); ?> class="knsl-title--h knsl-mb-20">
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php endif; ?>
<?php if ( $settings['description'] ) : ?>
<p class="knsl-text knsl-mb-30">
<span <?php echo $this->get_render_attribute_string( 'description' ); ?>>
<?php echo wp_kses_post( $settings['description'] ); ?>
</span>
</p>
<?php endif; ?>
<?php if ( $settings['more'] ) : ?>
<a <?php if ( $settings['link'] ) : if ( $settings['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $settings['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $settings['link']['url'] ); ?>"<?php endif; ?> class="knsl-btn knsl-btn-md">
<span <?php echo $this->get_render_attribute_string( 'more' ); ?>>
<?php echo wp_kses_post( $settings['more'] ); ?>
</span>
</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ( $q->have_posts() ) : ?>
<?php $i=0; while ( $q->have_posts() ) : $q->the_post(); $i++; ?>
<div class="<?php echo esc_attr( $item_classes ); ?><?php if ( $settings['container_type'] == 'full' ) : ?> knsl-icon-frame-hide<?php endif; ?>">
<?php
set_query_var( 'layout', $settings['layout'] );
set_query_var( 'index', $i );
get_template_part( 'template-parts/content', 'grid' ); ?>
</div>
<?php endwhile; ?>
<?php if ( $settings['pagination'] == 'pages' ) : ?>
<!-- pagination -->
<div class="knsl-pagination">
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $q->max_num_pages,
'prev_text' => esc_html__( 'Prev', 'kinsley-plugin' ),
'next_text' => esc_html__( 'Next', 'kinsley-plugin' ),
) );
?>
</div>
<!-- pagination end -->
<?php endif; ?>
<?php if ( $settings['pagination'] == 'button' ) : ?>
<!-- read more -->
<div class="knsl-read-more">
<?php if ( $settings['more_text'] ) : ?>
<div class="knsl-text">
<span <?php echo $this->get_render_attribute_string( 'more_text' ); ?>>
<?php echo wp_kses_post( $settings['more_text'] ); ?>
</span>
</div>
<?php endif; ?>
<a <?php if ( $settings['more_btn_link'] ) : ?><?php if ( $settings['more_btn_link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $settings['more_btn_link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $settings['more_btn_link']['url'] ); ?>"<?php endif; ?> class="knsl-btn">
<span <?php echo $this->get_render_attribute_string( 'more_btn_txt' ); ?>>
<?php echo wp_kses_post( $settings['more_btn_txt'] ); ?>
</span>
</a>
</div>
<!-- read more end -->
<?php endif; ?>
<?php else :
get_template_part( 'template-parts/content', 'none' );
endif; wp_reset_postdata(); ?>
</div>
<?php if ( $settings['container_type'] == 'basic' ) : ?></div><?php endif; ?>
</section>
<!-- blog end -->
<?php
}
}
Plugin::instance()->widgets_manager->register( new Kinsley_Blog_Grid_Widget() );