<?php
namespace BdevsElement\Widget;
use \Elementor\Group_Control_Background;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Image_Size;
Use \Elementor\Core\Schemes\Typography;
use \Elementor\Repeater;
use \Elementor\Utils;
defined('ABSPATH') || die();
class FAQ extends BDevs_El_Widget
{
/**
* Get widget name.
*
* Retrieve Bdevs Element widget name.
*
* @return string Widget name.
* @since 1.0.0
* @access public
*
*/
public function get_name()
{
return 'faq';
}
/**
* Get widget title.
*
* @return string Widget title.
* @since 1.0.0
* @access public
*
*/
public function get_title()
{
return __('FAQ', 'bdevselement');
}
public function get_custom_help_url()
{
return 'http://elementor.bdevs.net//widgets/contact-7-form/';
}
/**
* Get widget icon.
*
* @return string Widget icon.
* @since 1.0.0
* @access public
*
*/
public function get_icon()
{
return 'eicon-edit';
}
public function get_keywords()
{
return ['services', 'tab'];
}
protected function register_content_controls()
{
$this->start_controls_section(
'_section_design_title',
[
'label' => __('Design Style', 'bdevselement'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'design_style',
[
'label' => __('Design Style', 'bdevselement'),
'type' => Controls_Manager::SELECT,
'options' => [
'style_1' => __('Style 1', 'bdevselement'),
'style_2' => __('Style 2', 'bdevselement'),
],
'default' => 'style_1',
'frontend_available' => true,
'style_transfer' => true,
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_title',
[
'label' => __('Title ', 'bdevselement'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'sub_title',
[
'label' => __('Sub Title', 'bdevselement'),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => 'Heading Sub Title',
'placeholder' => __('Heading Sub Text', 'bdevselement'),
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'title',
[
'label' => __('Title', 'bdevselement'),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'default' => 'Heading Title',
'placeholder' => __('Heading Text', 'bdevselement'),
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'description',
[
'label' => __('Description', 'bdevselement'),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => __('Heading Description Text', 'bdevselement'),
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'title_tag',
[
'label' => __('Title HTML Tag', 'bdevselement'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'h1' => [
'title' => __('H1', 'bdevselement'),
'icon' => 'eicon-editor-h1'
],
'h2' => [
'title' => __('H2', 'bdevselement'),
'icon' => 'eicon-editor-h2'
],
'h3' => [
'title' => __('H3', 'bdevselement'),
'icon' => 'eicon-editor-h3'
],
'h4' => [
'title' => __('H4', 'bdevselement'),
'icon' => 'eicon-editor-h4'
],
'h5' => [
'title' => __('H5', 'bdevselement'),
'icon' => 'eicon-editor-h5'
],
'h6' => [
'title' => __('H6', 'bdevselement'),
'icon' => 'eicon-editor-h6'
]
],
'default' => 'h2',
'toggle' => false,
]
);
$this->add_responsive_control(
'align',
[
'label' => __('Alignment', 'bdevselement'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', 'bdevselement'),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => __('Center', 'bdevselement'),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => __('Right', 'bdevselement'),
'icon' => 'fa fa-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}}' => 'text-align: {{VALUE}};'
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_image',
[
'label' => __('Image', 'bdevselement'),
'tab' => Controls_Manager::TAB_CONTENT,
'condition' => [
'design_style' => ['style_1'],
],
]
);
$this->add_control(
'tab_big_image',
[
'label' => __('BG Image', 'bdevselement'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'dynamic' => [
'active' => true,
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_slides',
[
'label' => __('Faq List', 'bdevselement'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new Repeater();
$repeater->add_control(
'tab_title',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __('Tab Title', 'bdevselement'),
'default' => __('Tab Title', 'bdevselement'),
'placeholder' => __('Type title here', 'bdevselement'),
'dynamic' => [
'active' => true,
]
]
);
$repeater->add_control(
'tab_content_info',
[
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
'show_label' => false,
'default' => __('Content Here', 'bdevselement'),
'placeholder' => __('Type subtitle here', 'bdevselement'),
'dynamic' => [
'active' => true,
]
]
);
// REPEATER
$this->add_control(
'slides',
[
'show_label' => false,
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '<# print(tab_title || "Carousel Item"); #>',
'default' => [
[
'image' => [
'url' => Utils::get_placeholder_image_src(),
],
],
[
'image' => [
'url' => Utils::get_placeholder_image_src(),
],
],
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_button',
[
'label' => __('Button', 'bdevselement'),
'tab' => Controls_Manager::TAB_CONTENT,
'condition' => [
'design_style' => ['style_2'],
],
]
);
$this->add_control(
'button_text',
[
'label' => __('Text', 'bdevselement'),
'type' => Controls_Manager::TEXT,
'default' => __('Button Text', 'bdevselement'),
'placeholder' => __('Type button text here', 'bdevselement'),
'label_block' => true,
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'button_link',
[
'label' => __('Link', 'bdevselement'),
'type' => Controls_Manager::URL,
'placeholder' => __('http://elementor.bdevs.net/', 'bdevselement'),
'dynamic' => [
'active' => true,
]
]
);
if (bdevs_element_is_elementor_version('<', '2.6.0')) {
$this->add_control(
'button_icon',
[
'label' => __('Icon', 'bdevselement'),
'label_block' => true,
'type' => Controls_Manager::ICON,
'options' => bdevs_element_get_bdevs_element_icons(),
'default' => 'fa fa-angle-right',
]
);
$condition = ['button_icon!' => ''];
} else {
$this->add_control(
'button_selected_icon',
[
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'button_icon',
'label_block' => true,
]
);
$condition = ['button_selected_icon[value]!' => ''];
}
$this->add_control(
'button_icon_position',
[
'label' => __('Icon Position', 'bdevselement'),
'type' => Controls_Manager::CHOOSE,
'label_block' => false,
'options' => [
'before' => [
'title' => __('Before', 'bdevselement'),
'icon' => 'eicon-h-align-left',
],
'after' => [
'title' => __('After', 'bdevselement'),
'icon' => 'eicon-h-align-right',
],
],
'default' => 'after',
'toggle' => false,
'condition' => $condition,
'style_transfer' => true,
]
);
$this->add_control(
'button_icon_spacing',
[
'label' => __('Icon Spacing', 'bdevselement'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 10
],
'condition' => $condition,
'selectors' => [
'{{WRAPPER}} .btn--icon-before .btn-icon' => 'margin-right: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .btn--icon-after .btn-icon' => 'margin-left: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
}
// register_style_controls
protected function register_style_controls(){
$this->start_controls_section(
'_section_style_content',
[
'label' => __( 'Title / Content', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'content_padding',
[
'label' => __( 'Content Padding', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .bdevs-el-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'content_background',
'selector' => '{{WRAPPER}} .bdevs-el-content',
'exclude' => [
'image'
]
]
);
// Title
$this->add_control(
'_heading_title',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Title', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'title_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .bdevs-el-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'title_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-el-title' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title',
'selector' => '{{WRAPPER}} .bdevs-el-title',
'scheme' => Typography::TYPOGRAPHY_2,
]
);
// Subtitle
$this->add_control(
'_heading_subtitle',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Subtitle', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'subtitle_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .bdevs-el-subtitle' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'subtitle_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-el-subtitle' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'subtitle',
'selector' => '{{WRAPPER}} .bdevs-el-subtitle',
'scheme' => Typography::TYPOGRAPHY_3,
]
);
// description
$this->add_control(
'_content_description',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Description', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'description_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .bdevs-el-content p' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'description_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-el-content p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'description',
'selector' => '{{WRAPPER}} .bdevs-el-content p',
'scheme' => Typography::TYPOGRAPHY_4,
]
);
$this->end_controls_section();
// services item
$this->start_controls_section(
'_box_section_style_content',
[
'label' => __( 'Box Title / Content', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'_box_content_padding',
[
'label' => __( 'Content Padding', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .bdevs-box-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'box_content_background',
'selector' => '{{WRAPPER}} .bdevs-box-content',
'exclude' => [
'image'
]
]
);
// Box Title
$this->add_control(
'_box_heading_title',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Title', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'_box_title_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .bdevs-box-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'_box_title_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-box-title' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'boxtitle',
'selector' => '{{WRAPPER}} .bdevs-box-title',
'scheme' => Typography::TYPOGRAPHY_2,
]
);
// description
$this->add_control(
'_box_content_description',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Description', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'_box_description_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .bdevs-box-content p' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'_box_description_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-box-content p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'boxdescription',
'selector' => '{{WRAPPER}} .bdevs-box-content p',
'scheme' => Typography::TYPOGRAPHY_4,
]
);
$this->end_controls_section();
// Button 1 style
$this->start_controls_section(
'_section_style_button',
[
'label' => __( 'Button', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'button_padding',
[
'label' => __( 'Padding', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .bdevs-el-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'selector' => '{{WRAPPER}} .bdevs-el-btn',
'scheme' => Typography::TYPOGRAPHY_4,
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'button_border',
'selector' => '{{WRAPPER}} .bdevs-el-btn',
]
);
$this->add_control(
'button_border_radius',
[
'label' => __( 'Border Radius', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .bdevs-el-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'button_box_shadow',
'selector' => '{{WRAPPER}} .bdevs-el-btn',
]
);
$this->add_control(
'hr',
[
'type' => Controls_Manager::DIVIDER,
'style' => 'thick',
]
);
$this->start_controls_tabs( '_tabs_button' );
$this->start_controls_tab(
'_tab_button_normal',
[
'label' => __( 'Normal', 'bdevselement' ),
]
);
$this->add_control(
'button_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .bdevs-el-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'button_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-el-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'_tab_button_hover',
[
'label' => __( 'Hover', 'bdevselement' ),
]
);
$this->add_control(
'button_hover_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-el-btn:hover, {{WRAPPER}} .bdevs-el-btn:focus' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'button_hover_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-el-btn:hover, {{WRAPPER}} .bdevs-el-btn:focus' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'button_hover_border_color',
[
'label' => __( 'Border Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'button_border_border!' => '',
],
'selectors' => [
'{{WRAPPER}} .bdevs-el-btn:hover, {{WRAPPER}} .bdevs-el-btn:focus' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function render()
{
$settings = $this->get_settings_for_display();
$this->add_render_attribute('title', 'class', 'big_title text-white mb-0');
$title = bdevs_element_kses_basic($settings['title']);
// img
if (!empty($settings['tab_big_image']['id'])) {
$tab_big_image = wp_get_attachment_image_url(!empty($settings['tab_big_image']['id']), !empty($settings['tab_big_image_size']));
if (!$tab_big_image) {
$tab_big_image = $settings['tab_big_image']['url'];
}
}
// img small
if (!empty($settings['tab_small_image']['id'])) {
$tab_small_image = wp_get_attachment_image_url(!empty($settings['tab_small_image']['id']), !empty($settings['tab_big_image_size']));
if (!$tab_small_image) {
$tab_small_image = $settings['tab_small_image']['url'];
}
}
if (empty($settings['slides'])) {
return;
}
?>
<?php if ($settings['design_style'] === 'style_2'):
$this->add_render_attribute('button', 'class', 'z-btn z-btn-border wow fadeInLeft2 bdevs-el-btn');
$this->add_render_attribute('button', 'data-wow-delay', '.6s');
?>
<section class="faq-area">
<div class="faq-wrapper">
<div class="accordion" id="accordionExample">
<?php foreach ($settings['slides'] as $id => $slide) :
// active class
$collapsed_tab = ($id == 0) ? '' : 'collapsed';
$area_expanded = ($id == 0) ? 'true' : 'false';
$active_show_tab = ($id == 0) ? 'show' : '';
?>
<div class="accordion-item">
<h2 class="accordion-header" id="headingSix_<?php echo esc_attr($id); ?>">
<button class="accordion-button collapsed <?php echo esc_attr($collapsed_tab); ?>"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapseSix_<?php echo esc_attr($id); ?>"
aria-expanded="<?php echo esc_attr($area_expanded); ?>"
aria-controls="collapseSix_<?php echo esc_attr($id); ?>">
<?php echo bdevs_element_kses_basic($slide['tab_title']); ?>
</button>
</h2>
<div id="collapseSix_<?php echo esc_attr($id); ?>"
class="accordion-collapse collapse <?php echo esc_attr($active_show_tab); ?>"
aria-labelledby="headingSix_<?php echo esc_attr($id); ?>"
data-bs-parent="#accordionExample">
<div class="accordion-body">
<?php echo bdevs_element_kses_basic($slide['tab_content_info']); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<?php else: ?>
<div class="services-faq-wrap sd-faq">
<div class="faq-wrapper">
<div class="accordion" id="accordionExample">
<?php foreach ($settings['slides'] as $id => $slide) :
// active class
$collapsed_tab = ($id == 0) ? '' : 'collapsed';
$area_expanded = ($id == 0) ? 'true' : 'false';
$active_show_tab = ($id == 0) ? 'show' : '';
?>
<div class="accordion-item">
<h2 class="accordion-header" id="headingOne_<?php echo esc_attr($id); ?>">
<button class="accordion-button collapsed <?php echo esc_attr($collapsed_tab); ?>"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapseOne_<?php echo esc_attr($id); ?>"
aria-expanded="<?php echo esc_attr($area_expanded); ?>"
aria-controls="collapseOne_<?php echo esc_attr($id); ?>">
<?php echo bdevs_element_kses_basic($slide['tab_title']); ?>
</button>
</h2>
<div id="collapseOne_<?php echo esc_attr($id); ?>"
class="accordion-collapse collapse <?php echo esc_attr($active_show_tab); ?>"
aria-labelledby="headingOne_<?php echo esc_attr($id); ?>"
data-bs-parent="#accordionExample">
<div class="accordion-body">
<?php echo bdevs_element_kses_basic($slide['tab_content_info']); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php
}
}