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-gallery.php
<?php
namespace Dreamstourelementor\Widgets;

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

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

class DTS_gallery extends Widget_Base {

	public function get_name() {
		return 'dreamstour_elementor_gallery';
	}

	public function get_title() {
		return __( 'Dreams Tour Gallery', 'dreamstour_elementor' );
	}

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

	public function get_categories() {
		return [ 'dreamstourelemetortheme' ];
	}

	public function get_script_depends() {
		return [ 'dreamstourelementor-elementor' ];
	}

	protected function register_controls() {
		$this->start_controls_section(
			'section_content',
			[
				'label' => __( 'Content', 'dreamstour_elementor' ),
			]
		);

		$this->add_control(
			'columns',
			[
				'label' => __( 'Columns (Desktop)', 'dreamstour_elementor' ),
				'type' => Controls_Manager::SELECT,
				'default' => '4',
				'options' => [
					'2' => '2',
					'3' => '3',
					'4' => '4',
					'6' => '6',
				],
			]
		);

		$this->add_control(
			'items',
			[
				'label' => __( 'Gallery Items', 'dreamstour_elementor' ),
				'type' => Controls_Manager::REPEATER,
				'default' => [
					[
						'title' => __( 'Demo 01', 'dreamstour_elementor' ),
						'image' => [ 'url' => Utils::get_placeholder_image_src() ],
					],
					[
						'title' => __( 'Demo 02', 'dreamstour_elementor' ),
						'image' => [ 'url' => Utils::get_placeholder_image_src() ],
					],
				],
				'fields' => [
					[
						'name' => 'title',
						'label' => __( 'Title', 'dreamstour_elementor' ),
						'type' => Controls_Manager::TEXT,
						'default' => __( 'Demo 01', 'dreamstour_elementor' ),
						'label_block' => true,
					],
					[
						'name' => 'image',
						'label' => __( 'Image', 'dreamstour_elementor' ),
						'type' => Controls_Manager::MEDIA,
						'default' => [ 'url' => Utils::get_placeholder_image_src() ],
						'label_block' => true,
					],
				],
				'title_field' => '{{{ title }}}',
			]
		);

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

		$this->end_controls_section();
	}

	protected function render() {
		$settings = $this->get_settings();
		$columns = isset( $settings['columns'] ) ? intval( $settings['columns'] ) : 4;
		$col_class = 'col-lg-' . ( $columns ? intval(12 / max(1, min(6, $columns))) : 3 );

?>
<div class="container">
<div class="row row-gap-4 <?php echo esc_attr( $settings['class'] ); ?>">
<?php if ( ! empty( $settings['items'] ) ) : foreach ( $settings['items'] as $item ) :
	$image_url = isset( $item['image']['url'] ) ? $item['image']['url'] : '';
	$title = isset( $item['title'] ) ? $item['title'] : '';
?>
	<div class="<?php echo esc_attr( $col_class ); ?>">
		<div class="gallery-card">
			<div class="gallery-body">
				<div class="img-wrap">
					<img src="<?php echo esc_url( $image_url ); ?>" alt="img">
					<div class="img-overlay-1">
						<a class="gallery-img" data-fancybox="gallery-img" href="<?php echo esc_url( $image_url ); ?>" title="<?php echo esc_attr( $title ); ?>"><span class="gallery-eye-icon rounded-circle bg-primary d-flex align-items-center justify-content-center"><i class="ti ti-eye text-white"></i></span></a>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php endforeach; endif; ?>
</div>
</div>
<?php
	}

	protected function content_template() {
		?>
		<div class="row row-gap-4">
			<# if ( settings.items ) { #>
				<# _.each( settings.items, function( item ){ #>
					<div class="col-lg-3">
						<div class="gallery-card">
							<div class="gallery-body">
								<div class="img-wrap">
									<img src="{{ item.image.url }}" alt="img">
									<div class="img-overlay-1">
										<a class="gallery-img" data-fancybox="gallery-img" href="{{ item.image.url }}" title="{{ item.title }}"><span class="gallery-eye-icon rounded-circle bg-primary d-flex align-items-center justify-content-center"><i class="ti ti-eye text-white"></i></span></a>
									</div>
								</div>
							</div>
						</div>
					</div>
				<# }); #>
			<# } #>
		</div>
		<?php
	}
}