𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/builxejc/public_html/wp-content/plugins/kinsley-plugin/elementor/widgets//faq.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Kinsley FAQ Widget.
*
* @since 1.0
*/
class Kinsley_Faq_Widget extends Widget_Base {
public function get_name() {
return 'kinsley-faq';
}
public function get_title() {
return esc_html__( 'FAQ (Style-2)', '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(
'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' ),
],
]
);
$this->add_control(
'source_categories',
[
'label' => esc_html__( 'Categories', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT2,
'label_block' => true,
'multiple' => true,
'options' => $this->get_faq_categories(),
'condition' => [
'source' => 'categories'
],
]
);
$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(
'items_styling',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-faq .card .card-header .knsl-faq-title' => '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-faq .card .card-header .knsl-faq-title',
]
);
$this->add_control(
'item_desc_color',
[
'label' => esc_html__( 'Description Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-faq .card .knsl-card-body' => '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-faq .card .knsl-card-body',
]
);
$this->add_control(
'item_badge_color',
[
'label' => esc_html__( 'Badge Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-faq .card .card-header .knsl-faq-title .badge' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
/**
* Render Categories List.
*
* @since 1.0
*/
protected function get_faq_categories() {
$categories = [];
$args = array(
'type' => 'faq',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'taxonomy' => 'faq_categories',
'pad_counts' => false
);
$faq_categories = get_categories( $args );
foreach ( $faq_categories as $category ) {
$categories[$category->term_id] = $category->name;
}
return $categories;
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$page_id = get_the_ID();
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$cat_ids = '';
if ( $settings['source'] == 'categories' ) {
$cat_ids = $settings['source_categories'];
} else {
$cat_ids = '';
}
$cat_args = array(
'type' => 'faq',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'taxonomy' => 'faq_categories',
'pad_counts' => false,
'include' => $cat_ids
);
$fq_categories = get_categories( $cat_args );
?>
<!-- faq -->
<?php if ( $fq_categories ) : ?>
<div id="accordion">
<?php $i = 0; foreach ( $fq_categories as $category ) : $i++; ?>
<div class="knsl-faq knsl-faq-two knsl-mb-60" id="faq-<?php echo esc_attr( $category->term_id ); ?>">
<?php
$args = array(
'post_type' => 'faq',
'post_status' => 'publish',
'orderby' => $settings['sort'],
'order' => $settings['order'],
'posts_per_page' => $settings['limit'],
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'faq_categories',
'field' => 'id',
'terms' => $category->term_id
)
)
);
$q = new \WP_Query( $args );
if ( $q->have_posts() ) : $i = 0;
while ( $q->have_posts() ) : $q->the_post(); $i++;
set_query_var( 'index', $i );
get_template_part( 'template-parts/content', 'faq' );
endwhile;
else : get_template_part( 'template-parts/content', 'none' );
endif; wp_reset_postdata();
?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<!-- faq end -->
<?php
}
}
Plugin::instance()->widgets_manager->register( new Kinsley_Faq_Widget() );