File: /mnt/data/dreamstour-wp/wp-content/plugins/dreamstour-widgets/widgets/class-our-clients-says.php
<?php
namespace Dreamstourelementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Repeater;
if ( ! defined( 'ABSPATH' ) ) exit;
class DTS_our_clients_says extends Widget_Base {
public function get_name() {
return 'dreamstour_elementor_our_clients_says';
}
public function get_title() {
return __( 'Dreams Tour - Our Clients Says', 'dreamstour_elementor' );
}
public function get_icon() {
return 'eicon-testimonial-carousel';
}
public function get_categories() {
return [ 'dreamstourelemetortheme' ];
}
protected function register_controls() {
$this->start_controls_section('content_section', [ 'label' => __( 'Content', 'dreamstour_elementor' ) ]);
$this->add_control('left_image', [
'label' => __( 'Left Image', 'dreamstour_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [ 'url' => '' ],
]);
$this->add_control('badge_text', [
'label' => __( 'Badge Text', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Testimonials', 'dreamstour_elementor' ),
]);
$this->add_control('heading_text', [
'label' => __( 'Heading', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'What Our Clients Says', 'dreamstour_elementor' ),
]);
$this->add_control('rating_value', [
'label' => __( 'Rating Value', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => '5.0',
]);
$this->add_control('review_paragraph', [
'label' => __( 'Review Text', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXTAREA,
'default' => __( 'I had an I recently booked a flight through, and I couldn’t be happier with the experience.After finally selecting a flight, I was hit with unexpected fees during checkout that weren’t clearly stated upfront.', 'dreamstour_elementor' ),
]);
$this->add_control('author_avatar', [
'label' => __( 'Author Avatar', 'dreamstour_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [ 'url' => '' ],
]);
$this->add_control('author_name', [
'label' => __( 'Author Name', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Rachel Mariscal', 'dreamstour_elementor' ),
]);
$this->add_control('author_country', [
'label' => __( 'Author Country', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'United States', 'dreamstour_elementor' ),
]);
$this->add_control('clients_title', [
'label' => __( 'Clients Title', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( '40+ Clients Around the Globe', 'dreamstour_elementor' ),
]);
$this->add_control('top_bg_image', [
'label' => __( 'Top Background Image', 'dreamstour_elementor' ),
'type' => Controls_Manager::MEDIA,
'description' => __( 'Background image for the section top (::before).', 'dreamstour_elementor' ),
'default' => [ 'url' => '' ],
]);
$logos = new Repeater();
$logos->add_control('logo', [
'label' => __( 'Client Logo', 'dreamstour_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [ 'url' => '' ],
]);
$this->add_control('client_logos', [
'label' => __( 'Client Logos', 'dreamstour_elementor' ),
'type' => Controls_Manager::REPEATER,
'fields' => $logos->get_controls(),
'title_field' => 'Logo',
'default' => [ [], [], [], [], [], [] ],
]);
$this->end_controls_section();
}
protected function render() {
$s = $this->get_settings();
$left_img = ! empty($s['left_image']['url']) ? $s['left_image']['url'] : get_template_directory_uri() . '/assets/images/placeholder.webp';
$avatar = ! empty($s['author_avatar']['url']) ? $s['author_avatar']['url'] : get_template_directory_uri() . '/assets/images/user-placeholder.webp';
$top_bg = ! empty($s['top_bg_image']['url']) ? $s['top_bg_image']['url'] : '';
$section_id = 'ocs-' . $this->get_id();
$rating_val = isset($s['rating_value']) ? floatval($s['rating_value']) : 0.0;
$filled = (int) round( max(0, min(5, $rating_val)) );
?>
<section id="<?php echo esc_attr($section_id); ?>" class="section testi-sec-six pb-0" style="position:relative;">
<?php if ( $top_bg ) : ?>
<style>
#<?php echo esc_attr($section_id); ?>.testi-sec-six::before{
background-image: url(<?php echo esc_url($top_bg); ?>);
}
</style>
<?php endif; ?>
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<div>
<img src="<?php echo esc_url($left_img); ?>" alt="Img">
</div>
</div>
<div class="col-lg-6">
<div class="testi-info-six">
<div class="section-header-six mt-mobile-4 mb-4">
<span class="badge badge-soft-primary rounded-pill mb-1"><?php echo esc_html($s['badge_text']); ?></span>
<h2><?php echo esc_html($s['heading_text']); ?></h2>
</div>
<div>
<div class="d-flex align-items-center fs-12 mb-4">
<?php for ( $i = 1; $i <= 5; $i++ ) : ?>
<i class="ti ti-star-filled <?php echo $i <= $filled ? 'text-primary' : 'text-gray-4'; ?><?php echo $i === 5 ? ' me-1' : ''; ?>"></i>
<?php endfor; ?>
<p class="fs-14 text-gray-9"><?php echo esc_html( number_format($rating_val, 1) ); ?></p>
</div>
<p class="mb-4 testi-para"><?php echo esc_html($s['review_paragraph']); ?></p>
<div class="bg-white rounded-pill p-3 d-inline-flex align-items-center">
<a href="javascript:void(0);" class="avatar avtar-lg me-2">
<img src="<?php echo esc_url($avatar); ?>" class="rounded-circle" alt="Img">
</a>
<div>
<h6><a href="javascript:void(0);" class="text-capitalize"><?php echo esc_html($s['author_name']); ?></a></h6>
<span class="d-block"><?php echo esc_html($s['author_country']); ?></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="client-logos-sec">
<div class="container">
<div>
<h6 class="text-white mb-3"><?php echo esc_html($s['clients_title']); ?></h6>
</div>
<div class="owl-carousel client-slider">
<?php if ( ! empty($s['client_logos']) ) : foreach($s['client_logos'] as $item) :
$logo = ! empty($item['logo']['url']) ? $item['logo']['url'] : get_template_directory_uri() . '/assets/images/placeholder.webp';
?>
<div class="client-img">
<img src="<?php echo esc_url($logo); ?>" class="img-white" alt="img">
</div>
<?php endforeach; endif; ?>
</div>
</div>
</div>
</section>
<?php
}
}