GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/faq.php
<?php
namespace Elementor;

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

/**
 * Lesya Team Widget.
 *
 * @since 1.0
 */

class Lesya_Faq_Widget extends Widget_Base {

	public function get_name() {
		return 'lesya-faq';
	}

	public function get_title() {
		return esc_html__( 'FAQ', 'lesya-plugin' );
	}

	public function get_icon() {
		return 'eicon-parallax';
	}

	public function get_categories() {
		return [ 'lesya-category' ];
	}

	/**
	 * Register widget controls.
	 *
	 * @since 1.0
	 */
	protected function register_controls() {

		$this->start_controls_section(
			'items_tab',
			[
				'label' => esc_html__( 'Items', 'lesya-plugin' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);

		$repeater = new \Elementor\Repeater();

		$repeater->add_control(
			'name', [
				'label'       => esc_html__( 'Name', 'lesya-plugin' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'Enter Name', 'lesya-plugin' ),
				'default' => esc_html__( 'Name', 'lesya-plugin' ),
			]
		);

		$repeater->add_control(
			'text', [
				'label'       => esc_html__( 'Description', 'lesya-plugin' ),
				'type'        => Controls_Manager::WYSIWYG,
				'placeholder' => esc_html__( 'Enter description', 'lesya-plugin' ),
				'default' => esc_html__( 'Description', 'lesya-plugin' ),
			]
		);

		$this->add_control(
			'items',
			[
				'label' => esc_html__( 'Items', 'lesya-plugin' ),
				'type' => Controls_Manager::REPEATER,
				'prevent_empty' => false,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ name }}}',
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'items_styling',
			[
				'label'     => esc_html__( 'Items Styling', 'lesya-plugin' ),
				'tab'       => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'item_bg_color',
			[
				'label'     => esc_html__( 'BG Color', 'lesya-plugin' ),
				'type'      => Controls_Manager::COLOR,
				'default'	=> '',
				'selectors' => [
					'{{WRAPPER}} .faq-accordion .card' => 'background-color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'item_title_color',
			[
				'label'     => esc_html__( 'Title Color', 'lesya-plugin' ),
				'type'      => Controls_Manager::COLOR,
				'default'	=> '',
				'selectors' => [
					'{{WRAPPER}} .faq-accordion .card-header' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name'     => 'item_title_typography',
				'label'     => esc_html__( 'Title Typography', 'lesya-plugin' ),
				'selector' => '{{WRAPPER}} .faq-accordion .card-header',
			]
		);

		$this->add_control(
			'item_text_color',
			[
				'label'     => esc_html__( 'Text Color', 'lesya-plugin' ),
				'type'      => Controls_Manager::COLOR,
				'default'	=> '',
				'selectors' => [
					'{{WRAPPER}} .faq-accordion .card-body' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name'     => 'item_text_typography',
				'label'     => esc_html__( 'Text Typography', 'lesya-plugin' ),
				'selector' => '{{WRAPPER}} .faq-accordion .card-body',
			]
		);

		$this->end_controls_section();
	}

	private function uniqId(){
		return uniqid( 'prefix-' );
	}

	/**
	 * Render widget output on the frontend.
	 *
	 * @since 1.0
	 */
	protected function render() {
		$settings = $this->get_settings_for_display();
		$uniqID = $this->uniqId();
		?>

    <?php if ( $settings['items'] ) : ?>
    <div class="faq-accordion">
        <?php $i=1; foreach ( $settings['items'] as $index => $item ) : $i++;
          $item_name = $this->get_repeater_setting_key( 'name', 'items', $index );
          $this->add_inline_editing_attributes( $item_name, 'basic' );

          $item_text = $this->get_repeater_setting_key( 'text', 'items', $index );
          $this->add_inline_editing_attributes( $item_text, 'advanced' );

					$name_id = 'item-' . $i;
        ?>
        <div class="card" id="faq-accordion-<?php echo esc_attr( $uniqID ); ?>-<?php echo esc_attr( $name_id ); ?>">
            <?php if ( $item['name'] ) : ?>
            <a class="collapsed card-header" id="heading-<?php echo esc_attr( $uniqID ); ?>-<?php echo esc_attr( $name_id ); ?>" href="#" data-toggle="collapse" data-target="#collapse-<?php echo esc_attr( $uniqID ); ?>-<?php echo esc_attr( $name_id ); ?>" aria-expanded="false" aria-controls="collapse-<?php echo esc_attr( $uniqID ); ?>-<?php echo esc_attr( $name_id ); ?>">
              <span <?php echo $this->get_render_attribute_string( $item_name ); ?>>
                <?php echo wp_kses_post( $item['name'] ); ?>
                <i class="fas fa-chevron-down"></i>
              </span>
            </a>
            <?php endif; ?>
            <?php if ( $item['text'] ) : ?>
            <div id="collapse-<?php echo esc_attr( $uniqID ); ?>-<?php echo esc_attr( $name_id ); ?>" class="collapse" data-parent="#faq-accordion-<?php echo esc_attr( $uniqID ); ?>-<?php echo esc_attr( $name_id ); ?>">
                <div class="card-body">
                    <div <?php echo $this->get_render_attribute_string( $item_text ); ?>>
                      <?php echo wp_kses_post( $item['text'] ); ?>
                    </div>
                </div>
            </div>
            <?php endif; ?>
        </div>
        <?php endforeach; ?>
    </div>
    <?php endif; ?>

		<?php
	}

	/**
	 * Render 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 }*/
}

Plugin::instance()->widgets_manager->register_widget_type( new Lesya_Faq_Widget() );