| Server IP : 172.67.71.254 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/leapdubai/public_html/wp-content/plugins/printx-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'),
'layout-2' => esc_html__('Layout 2', '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', 'tpcore' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'tpcore' ),
'label_off' => esc_html__( 'Hide', 'tpcore' ),
'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');
$this->tp_text_link_controls_style('faq_title_active', 'FAQ Title Active', '.tp-el-faq-title.tp-faq-active button', ['layout-1', 'layout-2']);
$this->tp_text_link_controls_style('faq_title', 'FAQ Title', '.tp-el-faq-title button', ['layout-1', 'layout-2']);
$this->tp_basic_style_controls('faq_content', 'FAQ Content', '.tp-el-faq-content', ['layout-1', 'layout-2']);
}
/**
* 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' ): ?>
<div class="tp-custom-accordion tp-el-section">
<div class="accordions" id="accordion-<?php echo esc_attr($this->get_id()); ?>">
<?php foreach ( $settings['accordions'] as $key => $item) :
$active = $key==0 ? 'tp-faq-active' : '';
$collapsedShow = $key==0 ? 'collapse show' : 'collapse';
$collapsed = $key==0 ? '' : 'collapsed';
?>
<div class="accordion-items">
<h2 class="accordion-header tp-el-faq-title <?php echo esc_attr($collapsed); ?>" id="heading-<?php echo esc_attr($this->get_id().$key); ?>">
<button class="accordion-buttons" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-<?php echo esc_attr($this->get_id().$key); ?>"
aria-expanded="true" aria-controls="collapse-<?php echo esc_attr($this->get_id().$key); ?>">
<?php echo esc_html($item['accordion_title']); ?>
</button>
</h2>
<div id="collapse-<?php echo esc_attr($this->get_id().$key); ?>" class="accordion-collapse <?php echo esc_attr($collapsedShow); ?>" aria-labelledby="heading-<?php echo esc_attr($this->get_id().$key); ?>"
data-bs-parent="#accordion-<?php echo esc_attr($this->get_id()); ?>">
<div class="accordion-body tp-el-faq-content">
<?php echo tp_kses($item['accordion_description']); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php else : ?>
<div class="tp-service-details-faq tp-faq-inner__customize tp-el-section">
<div class="tp-custom-accordion-2">
<div class="accordion" id="accordionExample">
<?php foreach ( $settings['accordions'] as $key => $item) :
$active = $item['tp_accordion_active_switch'] ? 'tp-faq-active' : '';
$collapsed = $item['tp_accordion_active_switch'] ? 'collapsed' : 'collapse';
$show = $item['tp_accordion_active_switch'] ? 'show' : '';
?>
<div class="accordion-items tp-el-faq-title <?php echo esc_attr($active); ?>">
<h2 class="accordion-header" id="heading-<?php echo esc_attr($key); ?>">
<button class="accordion-buttons " type="button" data-bs-toggle="collapse"
data-bs-target="#collapse-<?php echo esc_attr($key); ?>" aria-expanded="true"
aria-controls="collapse-<?php echo esc_attr($key); ?>">
<?php echo esc_html($item['accordion_title']); ?>
</button>
</h2>
<div id="collapse-<?php echo esc_attr($key); ?>"
class="accordion-collapse <?php echo esc_attr($show)." "; echo esc_attr($collapsed); ?>"
aria-labelledby="heading-<?php echo esc_attr($key); ?>" data-bs-parent="#accordionExample">
<div class="accordion-body tp-el-faq-content">
<?php echo tp_kses($item['accordion_description']); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif;
}
}
$widgets_manager->register( new TP_FAQ() );