| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/cwd/wp-content/plugins/portx-core/include/elementor/ |
Upload File : |
<?php
namespace TPCore\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Tp Core
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class TP_FAQ extends Widget_Base {
use \TPCore\Widgets\TPCoreElementFunctions;
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'tp-faq';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'FAQ', 'tpcore' );
}
/**
* Retrieve the widget icon.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'tp-icon';
}
/**
* Retrieve the list of categories the widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* Note that currently Elementor supports only one category.
* When multiple categories passed, Elementor uses the first one.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget categories.
*/
public function get_categories() {
return [ 'tpcore' ];
}
/**
* Retrieve the list of scripts the widget depended on.
*
* Used to set scripts dependencies required to run the widget.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget scripts dependencies.
*/
public function get_script_depends() {
return [ 'tpcore' ];
}
/**
* Register the widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
*
* @access protected
*/
protected function register_controls(){
$this->register_controls_section();
$this->style_tab_content();
}
protected function register_controls_section() {
// layout Panel
$this->start_controls_section(
'tp_layout',
[
'label' => esc_html__('Design Layout', 'tpcore'),
]
);
$this->add_control(
'tp_design_style',
[
'label' => esc_html__('Select Layout', 'tpcore'),
'type' => Controls_Manager::SELECT,
'options' => [
'layout-1' => esc_html__('Layout 1', 'tpcore'),
],
'default' => 'layout-1',
]
);
$this->end_controls_section();
$this->start_controls_section(
'_accordion',
[
'label' => esc_html__( 'Accordion', 'tpcore' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'tp_accordion_active_switch',
[
'label' => esc_html__( 'Show', 'tp-core' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'tp-core' ),
'label_off' => esc_html__( 'Hide', 'tp-core' ),
'return_value' => 'yes',
'default' => '0',
]
);
$repeater->add_control(
'accordion_title', [
'label' => esc_html__( 'Accordion Item', 'tpcore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__( 'This is accordion item title' , 'tpcore' ),
'label_block' => true,
]
);
$repeater->add_control(
'accordion_description',
[
'label' => esc_html__('Description', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => \Elementor\Controls_Manager::TEXTAREA,
'default' => 'Facilis fugiat hic ipsam iusto laudantium libero maiores minima molestiae mollitia repellat rerum sunt ullam voluptates? Perferendis, suscipit.',
'label_block' => true,
]
);
$this->add_control(
'accordions',
[
'label' => esc_html__( 'Repeater Accordion', 'tpcore' ),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'accordion_title' => esc_html__( 'This is accordion item title #1', 'tpcore' ),
],
[
'accordion_title' => esc_html__( 'This is accordion item title #2', 'tpcore' ),
],
[
'accordion_title' => esc_html__( 'This is accordion item title #3', 'tpcore' ),
],
[
'accordion_title' => esc_html__( 'This is accordion item title #4', 'tpcore' ),
],
],
'title_field' => '{{{ accordion_title }}}',
]
);
$this->end_controls_section();
}
protected function style_tab_content(){
$this->tp_section_style_controls('faq_section', 'Section - Style', '.tp-el-section');
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
*
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
?>
<?php if ( $settings['tp_design_style'] == 'layout-2' ): ?>
<?php else : ?>
<div class="tp-faq-area mb-40">
<div class="container">
<div class="row">
<div class="tp-custom-accordion">
<div class="accordion" id="accordionExample-<?php echo esc_attr($this->get_id()); ?>">
<?php foreach ( $settings['accordions'] as $index => $item) :
$collapsed = ($index == '0' ) ? '' : 'collapsed';
$aria_expanded = ($index == '0' ) ? "true" : "false";
$show = $item['tp_accordion_active_switch'] ? "show" : "";
$active = $item['tp_accordion_active_switch'] ? "tp-faq-active" : "";
?>
<div class="accordion-items <?php echo esc_attr($active); ?>">
<h2 class="accordion-header" id="headingOne-<?php echo esc_attr($index); ?>">
<button class="accordion-buttons <?php echo esc_attr($collapsed); ?>" type="button" data-bs-toggle="collapse"
data-bs-target="#collapseOne-<?php echo esc_attr($index); ?>" aria-expanded="<?php echo esc_attr($aria_expanded); ?>" aria-controls="collapseOne-<?php echo esc_attr($index); ?>">
<?php echo esc_html($item['accordion_title']); ?>
</button>
</h2>
<div id="collapseOne-<?php echo esc_attr($index); ?>" class="accordion-collapse collapse <?php echo esc_attr($show); ?>" aria-labelledby="headingOne-<?php echo esc_attr($index); ?>"
data-bs-parent="#accordionExample-<?php echo esc_attr($this->get_id()); ?>">
<div class="accordion-body">
<?php echo tp_kses($item['accordion_description']); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
<?php endif;
}
}
$widgets_manager->register( new TP_FAQ() );