𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/builxejc/public_html/wp-content/plugins/kinsley-plugin/elementor/widgets//photo-gallery.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Kinsley Photo Gallery Widget.
*
* @since 1.0
*/
class Kinsley_Photo_Gallery_Widget extends Widget_Base {
public function get_name() {
return 'kinsley-photo-gallery';
}
public function get_title() {
return esc_html__( 'Photo Gallery', 'kinsley-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'kinsley-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'heading_tab',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'heading',
[
'label' => esc_html__( 'Heading', 'kinsley-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'kinsley-plugin' ),
'label_off' => __( 'Hide', 'kinsley-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Title', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'title_tag',
[
'label' => esc_html__( 'Title Tag', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'h2',
'options' => [
'h1' => __( 'H1', 'kinsley-plugin' ),
'h2' => __( 'H2', 'kinsley-plugin' ),
'h3' => __( 'H3', 'kinsley-plugin' ),
'h4' => __( 'H4', 'kinsley-plugin' ),
'div' => __( 'DIV', 'kinsley-plugin' ),
],
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'description',
[
'label' => esc_html__( 'Description', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter description', 'kinsley-plugin' ),
'default' => esc_html__( 'Description', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'more',
[
'label' => esc_html__( 'Button (label)', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Button', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'link',
[
'label' => esc_html__( 'Button (link)', 'kinsley-plugin' ),
'type' => Controls_Manager::URL,
'show_external' => true,
'condition' => [
'heading' => 'yes'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_tab',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'source',
[
'label' => esc_html__( 'Parse from', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'custom',
'options' => [
'mphb_room_type' => __( 'Accommodation Types', 'kinsley-plugin' ),
'custom' => __( 'Custom', 'kinsley-plugin' ),
],
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'image', [
'label' => esc_html__( 'Image', 'kinsley-plugin' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$repeater->add_control(
'title', [
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Enter title', 'kinsley-plugin' ),
]
);
$this->add_control(
'items',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'type' => Controls_Manager::REPEATER,
'prevent_empty' => false,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ title }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'slider_settings_tab',
[
'label' => esc_html__( 'Slider Settings', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'slider_nav',
[
'label' => esc_html__( 'Slider Navigation', 'kinsley-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'kinsley-plugin' ),
'label_off' => __( 'Hide', 'kinsley-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'thumbs_nav',
[
'label' => esc_html__( 'Thumbnails Navigation', 'kinsley-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'kinsley-plugin' ),
'label_off' => __( 'Hide', 'kinsley-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->end_controls_section();
$this->start_controls_section(
'title_styling',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-title--h' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-title--h',
]
);
$this->add_control(
'description_color',
[
'label' => esc_html__( 'Description Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'description_typography',
'label' => esc_html__( 'Description Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-text',
]
);
$this->add_control(
'button_color',
[
'label' => esc_html__( 'Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'button_bgcolor',
[
'label' => esc_html__( 'Button BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'label' => esc_html__( 'Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-btn',
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_styling',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_bgcolor',
[
'label' => esc_html__( 'Background Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-room-detail-slider-frame' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes( 'more', 'none' );
$this->add_inline_editing_attributes( 'title', 'basic' );
$this->add_inline_editing_attributes( 'description', 'basic' );
$theme_lightbox = get_field( 'portfolio_lightbox_disable', 'option' );
?>
<div class="knsl-room-detail-slider-frame knsl-mb-60">
<?php if ( $settings['heading'] == 'yes' && ( $settings['title'] || $settings['more'] || $settings['description'] ) ) : ?>
<div class="container">
<div class="row align-items-center">
<div class="col-lg-12">
<div class="knsl-center knsl-title-frame knsl-scroll-animation knsl-mb-100">
<?php if ( $settings['title'] ) : ?>
<<?php echo esc_attr( $settings['title_tag'] ); ?> class="knsl-title--h knsl-mb-20">
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php endif; ?>
<?php if ( $settings['description'] ) : ?>
<div class="knsl-text knsl-mb-30">
<p>
<span <?php echo $this->get_render_attribute_string( 'description' ); ?>>
<?php echo wp_kses_post( $settings['description'] ); ?>
</span>
</p>
</div>
<?php endif; ?>
<?php if ( $settings['more'] ) : ?>
<a <?php if ( $settings['link'] ) : if ( $settings['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $settings['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $settings['link']['url'] ); ?>"<?php endif; ?> class="knsl-btn knsl-btn-md">
<span <?php echo $this->get_render_attribute_string( 'more' ); ?>>
<?php echo wp_kses_post( $settings['more'] ); ?>
</span>
</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $settings['source'] == 'mphb_room_type' ) : ?>
<?php
if ( class_exists( 'HotelBookingPlugin' ) && !( is_admin() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) ) :
$roomType = MPHB()->getCurrentRoomType();
if ( is_object( $roomType ) ) :
$galleryIds = $roomType->getGalleryIds();
?>
<?php if ( $galleryIds ) : ?>
<div class="swiper-container knsl-rd-slider-2 knsl-mb-10">
<div class="swiper-wrapper">
<?php foreach ( $galleryIds as $index => $value ) : ?>
<div class="swiper-slide">
<?php if ( $value ) : $image = wp_get_attachment_image_url( $value, 'kinsley_1920xAuto' ); $image_alt = get_post_meta( $value, '_wp_attachment_image_alt', true); ?>
<a<?php if ( ! $theme_lightbox ) : ?> data-magnific-gallery<?php endif; ?> data-elementor-lightbox-slideshow="photo-gallery" data-elementor-lightbox-title="" href="<?php echo esc_url( $image ); ?>" class="knsl-room-detail-photo-lg" data-swiper-parallax="-80" data-swiper-parallax-scale="1.2" data-swiper-parallax-duration="400">
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $image_alt ); ?>" />
<span class="knsl-zoom"><i class="fas fa-search-plus"></i></span>
</a>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php if ( $settings['slider_nav'] == 'yes' ) : ?>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<?php endif; ?>
</div>
<div class="swiper-container knsl-rd-slider-1">
<div class="swiper-wrapper">
<?php foreach ( $galleryIds as $index => $value ) : ?>
<div class="swiper-slide">
<div class="knsl-room-detail-photo-sm">
<?php if ( $value ) : $image = wp_get_attachment_image_url( $value, 'kinsley_950xAuto' ); $image_alt = get_post_meta( $value, '_wp_attachment_image_alt', true); ?>
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $image_alt ); ?>" />
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php if ( $settings['thumbs_nav'] == 'yes' ) : ?>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<?php endif; ?>
</div>
<?php endif; endif; endif; ?>
<?php else : ?>
<?php if ( $settings['items'] ) : ?>
<div class="swiper-container knsl-rd-slider-2 knsl-mb-10">
<div class="swiper-wrapper">
<?php foreach ( $settings['items'] as $index => $item ) : ?>
<div class="swiper-slide">
<?php if ( $item['image'] ) : $image = wp_get_attachment_image_url( $item['image']['id'], 'kinsley_1920xAuto' ); ?>
<a<?php if ( ! $theme_lightbox ) : ?> data-magnific-gallery<?php endif; ?> data-elementor-lightbox-slideshow="photo-gallery" data-elementor-lightbox-title="<?php echo esc_attr( $item['title'] ); ?>" href="<?php echo esc_url( $image ); ?>" class="knsl-room-detail-photo-lg" data-swiper-parallax="-80" data-swiper-parallax-scale="1.2" data-swiper-parallax-duration="400">
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $item['title'] ); ?>" />
<span class="knsl-zoom"><i class="fas fa-search-plus"></i></span>
</a>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php if ( $settings['slider_nav'] == 'yes' ) : ?>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<?php endif; ?>
</div>
<div class="swiper-container knsl-rd-slider-1">
<div class="swiper-wrapper">
<?php foreach ( $settings['items'] as $index => $item ) : ?>
<div class="swiper-slide">
<div class="knsl-room-detail-photo-sm">
<?php if ( $item['image'] ) : $image = wp_get_attachment_image_url( $item['image']['id'], 'kinsley_950xAuto' ); ?>
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $item['title'] ); ?>" />
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php if ( $settings['thumbs_nav'] == 'yes' ) : ?>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php
}
}
Plugin::instance()->widgets_manager->register( new Kinsley_Photo_Gallery_Widget() );