HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1014-azure #14~24.04.1-Ubuntu SMP Fri Oct 3 20:52:11 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/dreamsrent-wp/wp-content/plugins/dreamsrent-widgets/widgets/class-faq.php
<?php
namespace Dreamsrentelementor\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use \Elementor\Utils;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Elementor Hello World
 *
 * Elementor widget for hello world.
 *
 * @since 1.0.0
 */
class DSR_faq extends Widget_Base {

	/**
	 * Retrieve the widget name.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'dreamsrent_elementor_faq';
	}

	/**
	 * Retrieve the widget title.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return __( 'DR FAQ', 'dreamsrent_elementor' );
	}

	/**
	 * Retrieve the widget icon.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'eicon-posts-ticker';
	}

	/**
	 * 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 [ 'dreamsrentelemetortheme' ];
	}

	/**
	 * 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 [ 'dreamsrentelementor-elementor' ];
	}

	/**
	 * 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->start_controls_section(
			'section_content',
			[
				'label' => __( 'Content', 'dreamsrent_elementor' ),
			]
		);

			$this->add_control(
				'faq',
				[
					'label' => __( 'FAQ Items', 'dreamsrent_elementor' ),
					'type' => Controls_Manager::REPEATER,
					'default' => [
						[
							'name' => __( 'What is about rental car deals?', 'dreamsrent_elementor' ),
							'desc' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.', 'dreamsrent_elementor' ),
 							'class' => '',
						],
						[
							'name' => __( 'In which areas do you operate?', 'dreamsrent_elementor' ),
							'desc' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.', 'dreamsrent_elementor' ),
 							'class' => '',
						],
					],
					'fields' => [
						[
							'name' => 'name',
							'label' => __( 'Name', 'dreamsrent_elementor' ),
							'type' => Controls_Manager::TEXT,
							'default' => __( 'Tony Chester' , 'dreamsrent_elementor' ),
							'dynamic' => [
								'active' => true,
							],
							'label_block' => true,
						],
						 
						[
							'name' => 'desc',
							'label' => __( 'Content', 'dreamsrent_elementor' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => __( 'Desciption', 'dreamsrent_elementor' ),
							'show_label' => false,
						],
						[
							'name' => 'class',
							'label' => __( 'Class', 'dreamsrent_elementor' ),
							'type' => Controls_Manager::TEXT,
							'dynamic' => [
								'active' => true,
							],
							'label_block' => true,
						],
					],
					'title_field' => '{{{ name }}}',
				]
			);
 

		 

		 
			$this->add_control(
				'class',
				[
					'label' => __( 'Class', 'dreamsrent_elementor' ),
					'type' => Controls_Manager::TEXT,
				]
			);



		$this->end_controls_section();

		// Style tab: Question
		$this->start_controls_section(
			'faq_question_style',
			[
				'label' => __( 'Question', 'dreamsrent_elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'faq_question_color',
			[
				'label'     => __( 'Question Color', 'dreamsrent_elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .faq-card .faq-title a' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name'     => 'faq_question_typography',
				'label'    => __( 'Question Typography', 'dreamsrent_elementor' ),
				'selector' => '{{WRAPPER}} .faq-card .faq-title a',
			]
		);

		$this->end_controls_section();

		// Style tab: Answer
		$this->start_controls_section(
			'faq_answer_style',
			[
				'label' => __( 'Answer', 'dreamsrent_elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'faq_answer_color',
			[
				'label'     => __( 'Answer Color', 'dreamsrent_elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .faq-card .card-collapse p' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name'     => 'faq_answer_typography',
				'label'    => __( 'Answer Typography', 'dreamsrent_elementor' ),
				'selector' => '{{WRAPPER}} .faq-card .card-collapse p',
			]
		);

		$this->end_controls_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();

		?>
<div class="faq-info">
	<!-- Carousel Item -->
<?php foreach ( $settings['faq'] as $index => $item ) : 
	   $tab_count = $index + 1;
	   $faq_id    = 'faq_' . intval( $tab_count );
	 ?>

	<div class="faq-card bg-white" data-aos="fade-down">
						<h4 class="faq-title">
							<a class="collapseds  <?php if($tab_count=='1') { ?>    <?php } else { ?> collapsed <?php } ?> " data-bs-toggle="collapse" href="#<?php echo esc_attr( $faq_id ); ?>" <?php if($tab_count=='1') { ?> aria-expanded="true"<?php } else { ?> aria-expanded="false" <?php } ?>><?php echo esc_html( $item['name'] ); ?></a>
						</h4>
						<div id="<?php echo esc_attr( $faq_id ); ?>" class="card-collapse  <?php if($tab_count=='1') { ?>  collapsed show <?php } else { ?>collapse<?php } ?>">
							<p><?php echo esc_html( $item['desc'] ); ?></p>
						</div>
					</div>	

 
<?php   endforeach; ?>
<!-- /Carousel Item  -->
</div>
		<?php 

		 
	}

	/**
	 * Render the widget output in the editor.
	 *
	 * Written as a Backbone JavaScript template and used to generate the live preview.
	 *
	 * @since 1.0.0
	 *
	 * @access protected
	 */
	protected function content_template() {
		?>
	 
		<?php
	}
	
}