HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/dreamstour-wp/wp-content/plugins/dreamstour-widgets/widgets/class-testimonials-grid.php
<?php
namespace Dreamstourelementor\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Repeater;

if ( ! defined( 'ABSPATH' ) ) exit;

class DTS_testimonials_grid extends Widget_Base {

    public function get_name() { return 'dreamstour_elementor_testimonials_grid'; }
    public function get_title() { return \__( 'Dreams Tour - Testimonials Grid', 'dreamstour_elementor' ); }
    public function get_icon() { return 'eicon-testimonial-carousel'; }
    public function get_categories() { return [ 'dreamstourelemetortheme' ]; }

    protected function register_controls() {
        $this->start_controls_section('header', [ 'label' => \__( 'Header', 'dreamstour_elementor' ) ]);
        $this->add_control('title', [ 'label' => \__( 'Title', 'dreamstour_elementor' ), 'type' => Controls_Manager::TEXT, 'default' => \__( 'What’s Our <span class="text-primary  text-decoration-underline">User</span> Says', 'dreamstour_elementor' ), 'label_block' => true ]);
        $this->add_control('subtitle', [ 'label' => \__( 'Subtitle', 'dreamstour_elementor' ), 'type' => Controls_Manager::TEXTAREA, 'default' => \__( 'DreamsTour, a tour operator specializing in dream destinations, offers a variety of benefits for travelers.', 'dreamstour_elementor' ) ]);
        $this->end_controls_section();

        $this->start_controls_section('layout', [ 'label' => \__( 'Layout', 'dreamstour_elementor' ) ]);
        $this->add_control('columns_desktop', [
            'label' => \__( 'Columns (Desktop ≥1200px)', 'dreamstour_elementor' ),
            'type' => Controls_Manager::SELECT,
            'default' => '3',
            'options' => [ '1' => '1', '2' => '2', '3' => '3', '4' => '4' ],
        ]);
        $this->add_control('columns_tablet', [
            'label' => \__( 'Columns (Tablet ≥768px)', 'dreamstour_elementor' ),
            'type' => Controls_Manager::SELECT,
            'default' => '2',
            'options' => [ '1' => '1', '2' => '2', '3' => '3' ],
        ]);
        $this->add_control('columns_mobile', [
            'label' => \__( 'Columns (Mobile <768px)', 'dreamstour_elementor' ),
            'type' => Controls_Manager::SELECT,
            'default' => '1',
            'options' => [ '1' => '1', '2' => '2' ],
        ]);
        $this->end_controls_section();

        $this->start_controls_section('items', [ 'label' => \__( 'Testimonials', 'dreamstour_elementor' ) ]);
        $rep = new Repeater();
        $rep->add_control('heading', [ 'label' => \__( 'Heading', 'dreamstour_elementor' ), 'type' => Controls_Manager::TEXT, 'default' => 'Great Hospitalization' ]);
        $rep->add_control('text', [ 'label' => \__( 'Text', 'dreamstour_elementor' ), 'type' => Controls_Manager::TEXTAREA, 'default' => 'Dream Tours made our Ark trip a dream come true! The staff was incredibly attentive, and every detail was perfectly managed. We couldn’t have asked for a better experience!' ]);
        $rep->add_control('avatar', [ 'label' => \__( 'Avatar', 'dreamstour_elementor' ), 'type' => Controls_Manager::MEDIA ]);
        $rep->add_control('name', [ 'label' => \__( 'Name', 'dreamstour_elementor' ), 'type' => Controls_Manager::TEXT, 'default' => 'Andrew Fetcher' ]);
        $rep->add_control('location', [ 'label' => \__( 'Location', 'dreamstour_elementor' ), 'type' => Controls_Manager::TEXT, 'default' => 'Newyork, United States' ]);
        $rep->add_control('rating', [ 'label' => \__( 'Rating', 'dreamstour_elementor' ), 'type' => Controls_Manager::TEXT, 'default' => '5.0' ]);
        $this->add_control('testimonials', [ 'label' => \__( 'Items', 'dreamstour_elementor' ), 'type' => Controls_Manager::REPEATER, 'fields' => $rep->get_controls(), 'default' => [ [ 'name' => 'Andrew Fetcher' ], [ 'name' => 'Bryan Bradfield' ], [ 'name' => 'Prajakta Sasane' ] ], 'title_field' => '{{{ name }}}' ]);
        $this->end_controls_section();
    }

    private function map_cols( $count, $breakpoint = 'lg' ) {
        // Maps column count to Bootstrap like grid width
        $map = [ '1' => 12, '2' => 6, '3' => 4, '4' => 3 ];
        $count = isset($map[$count]) ? $count : 12;
        return 'col-' . $breakpoint . '-' . $count;
    }

    protected function render() {
        $s = $this->get_settings_for_display();
        $lg = isset($s['columns_desktop']) ? $s['columns_desktop'] : '3';
        $md = isset($s['columns_tablet']) ? $s['columns_tablet'] : '2';
        $sm = isset($s['columns_mobile']) ? $s['columns_mobile'] : '1';

        $col_lg = $this->map_cols($lg, 'lg');
        $col_md = $this->map_cols($md, 'md');
        $col_sm = $this->map_cols($sm, 'sm');

        ?>
        <div class="container">
        <div class="row justify-content-center">
            <div class="col-xl-6 col-lg-10 text-center wow fadeInUp" data-wow-delay="0.2s">
                <div class="section-header text-center">
                    <h2 class="mb-2"><?php echo wp_kses_post( $s['title'] ); ?></h2>
                    <p class="sub-title"><?php echo esc_html( $s['subtitle'] ); ?></p>
                </div>
            </div>
        </div>
        </div>
<div class="container">
        <div class="row row-gap-4">
            <?php if ( ! empty( $s['testimonials'] ) ) : foreach ( $s['testimonials'] as $t ) : ?>
            <div class="<?php echo esc_attr( trim( $col_lg . ' ' . $col_md ) ); ?> d-flex">
                <div class="card border-white mb-0 wow fadeInUp flex-fill" data-wow-delay="0.2s">
                    <div class="card-body">
                        <h6 class="mb-3"><?php echo esc_html( $t['heading'] ); ?></h6>
                        <p class="mb-4"><?php echo esc_html( $t['text'] ); ?></p>
                        <div class="border-top pt-4 d-flex align-items-center justify-content-between">
                            <div class="d-flex align-items-center">
                                <a href="javascript:void(0);" class="avatar avatar-md  flex-shrink-0">
                                    <img src="<?php echo esc_url( isset( $t['avatar']['url'] ) ? $t['avatar']['url'] : '' ); ?>" class="rounded-circle" alt="img">
                                </a>
                                <div class="ms-2">
                                    <h6 class="fs-16 fw-medium"><a href="javascript:void(0);"><?php echo esc_html( $t['name'] ); ?></a></h6>
                                    <p><?php echo esc_html( $t['location'] ); ?></p>
                                </div>
                            </div>
                            <span class="badge badge-warning badge-xs text-gray-9 fs-13 fw-medium me-2"><?php echo esc_html( $t['rating'] ); ?></span>
                        </div>
                    </div>
                </div>
            </div>
            <?php endforeach; endif; ?>
        </div>
        </div>
        <?php
    }

    protected function content_template() {}
}