<?php
/**
* Elementor Single Widget
* @package Prinox Tools
* @since 1.0.0
*/
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
class Prinox_Faq extends Widget_Base {
/**
* Get widget name.
*
* Retrieve Elementor widget name.
*
* @since 1.0.0
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'prionx-faq-id';
}
/**
* Get widget title.
*
* Retrieve Elementor widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return esc_html__( 'Prinox FAQ', 'prinox-tools' );
}
/**
* Get widget icon.
*
* Retrieve Elementor widget icon.
*
* @since 1.0.0
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'mg-custom-icon';
}
/**
* Get widget categories.
*
* Retrieve the list of categories the Elementor widget belongs to.
*
* @since 1.0.0
* @access public
*
* @return array Widget categories.
*/
public function get_categories() {
return [ 'prinox_widgets' ];
}
protected function register_controls() {
$this->start_controls_section(
'prinox_faq_option',
[
'label' => esc_html__( 'FAQ Option', 'prinox-tools' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'shape1', [
'label' => esc_html__( 'Shape 1', 'prinox-tools' ),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
]
);
$this->add_control(
'shape2', [
'label' => esc_html__( 'Shape 2', 'prinox-tools' ),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
]
);
$this->add_control(
'sub_title', [
'label' => esc_html__( 'Sub Title', 'prinox-tools' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'title-bg',
'label' => esc_html__( 'Background', 'prinox-tools' ),
'types' => [ 'classic' ],
'exclude' => [ 'color' ],
'selector' => '{{WRAPPER}} .sec-title h2 span:before',
]
);
$this->add_control(
'title', [
'label' => esc_html__( 'Title', 'prinox-tools' ),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
]
);
$this->add_control(
'description', [
'label' => esc_html__( 'Description', 'prinox-tools' ),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
]
);
$repeater = new Repeater();
$repeater->add_control(
'active',
[
'label' => esc_html__( 'Active', 'prinox-tools' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'prinox-tools' ),
'label_off' => esc_html__( 'Hide', 'prinox-tools' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$repeater->add_control(
'title', [
'label' => esc_html__( 'Title', 'prinox-tools' ),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
]
);
$repeater->add_control(
'description', [
'label' => esc_html__( 'Description', 'prinox-tools' ),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
]
);
$this->add_control(
'accordions',
[
'label' => esc_html__( 'Add New Accordions Item', 'prinox-tools' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ title }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'faq_sec_title_style',
[
'label' => __( 'FAQ Section Title', 'prinox-tools' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'subtitle_color',
[
'label' => esc_html__( 'Sub Title Color', 'prinox-tools' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .sec-title .title' => 'color: {{VALUE}} ',
],
]
);
$this->add_control(
'subtitle_bg_color',
[
'label' => esc_html__( 'Sub Title BG Color', 'prinox-tools' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .sec-title .title:before' => 'background-color: {{VALUE}} ',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'subtitle_typography',
'label' => esc_html__( 'Sub Title Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .sec-title .title',
]
);
$this->add_control(
'title_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Title', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'prinox-tools' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .sec-title h2' => 'color: {{VALUE}} ',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .sec-title h2',
]
);
$this->add_control(
'content_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Content', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'content_color',
[
'label' => esc_html__( 'Content Color', 'prinox-tools' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .sec-title .text' => 'color: {{VALUE}} ',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'content_typography',
'label' => esc_html__( 'Content Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .sec-title .text',
]
);
$this->end_controls_section();
$this->start_controls_section(
'faq_style',
[
'label' => __( 'FAQ', 'prinox-tools' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'f_title_color',
[
'label' => esc_html__( 'Title Color', 'prinox-tools' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .accordion-box .block .acc-btn' => 'color: {{VALUE}} ',
'{{WRAPPER}} .accordion-box .block .icon-outer .icon' => 'color: {{VALUE}} ',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'f_title_typography',
'label' => esc_html__( 'Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .accordion-box .block .acc-btn',
]
);
$this->add_control(
'f_content_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Content', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'f_content_color',
[
'label' => esc_html__( 'Content Color', 'prinox-tools' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .acc-content .content .text' => 'color: {{VALUE}} ',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'f_content_typography',
'label' => esc_html__( 'Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .acc-content .content .text',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
?>
<!-- Faq Section -->
<section class="faq-section">
<div class="color-one"></div>
<div class="color-two"></div>
<div class="color-three"></div>
<div class="color-four"></div>
<?php if(!empty($settings['shape1']['url'])):?>
<div class="vector-layer-one" style="background-image: url(<?php echo esc_url($settings['shape1']['url']);?>)"></div>
<?php endif;?>
<?php if(!empty($settings['shape2']['url'])):?>
<div class="vector-layer-two" style="background-image: url(<?php echo esc_url($settings['shape2']['url']);?>)"></div>
<?php endif;?>
<div class="auto-container">
<!-- Sec Title -->
<div class="sec-title centered">
<?php if(!empty($settings['sub_title'])):?>
<div class="title"><?php echo wp_kses( $settings['sub_title'], true );?></div>
<?php endif;?>
<?php if(!empty($settings['title'])):?>
<h2><?php echo wp_kses( $settings['title'], true );?></h2>
<?php endif;?>
<?php if(!empty($settings['description'])):?>
<div class="text"><?php echo wp_kses( $settings['description'], true );?></div>
<?php endif;?>
</div>
<div class="inner-container">
<!-- Accordion Box / Style Two -->
<ul class="accordion-box style-two">
<?php foreach($settings['accordions'] as $item):?>
<!-- Block -->
<li class="accordion block">
<div class="acc-btn <?php if($item['active'] == 'yes'){ echo esc_attr('active');}?>"><div class="icon-outer"><span class="icon icon-plus fa fa-plus"></span> <span class="icon icon-minus fa fa-minus"></span></div><?php echo wp_kses( $item['title'], true )?></div>
<div class="acc-content <?php if($item['active'] == 'yes'){ echo esc_attr('current');}?> ">
<div class="content">
<div class="text"><?php echo wp_kses( $item['description'], true )?></div>
</div>
</div>
</li>
<?php endforeach;?>
</ul>
</div>
</div>
</section>
<!-- End Faq Section -->
<?php
}
}
Plugin::instance()->widgets_manager->register( new Prinox_Faq() );