File: /home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/gallery.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Lesya Gallery Widget.
*
* @since 1.0
*/
class Lesya_Gallery_Widget extends Widget_Base {
public function get_name() {
return 'lesya-gallery';
}
public function get_title() {
return esc_html__( 'Gallery', '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(
'content_tab',
[
'label' => esc_html__( 'Content', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'lesya-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'lesya-plugin' ),
'default' => esc_html__( 'Title', 'lesya-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'bg_text',
[
'label' => esc_html__( 'Background Title', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter title', 'lesya-plugin' ),
'default' => esc_html__( 'Title', 'lesya-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_tab',
[
'label' => esc_html__( 'Gallery', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'image', [
'label' => esc_html__( 'Image', 'lesya-plugin' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$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__( 'Enter name', 'lesya-plugin' ),
]
);
$repeater->add_control(
'type_show',
[
'label' => esc_html__( 'Select Layout', 'lesya-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 1,
'options' => [
1 => __( 'Default', 'lesya-plugin' ),
2 => __( 'Vertical', 'lesya-plugin' ),
3 => __( 'Big', '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(
'content_styling',
[
'label' => esc_html__( 'Content Styling', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .section-title h2' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .section-title h2',
]
);
$this->add_control(
'bgtext_color',
[
'label' => esc_html__( 'BG Text Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .section-title .bg-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'bgtext_typography',
'label' => esc_html__( 'BG Text Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .section-title .bg-text',
]
);
$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( 'title', 'basic' );
$this->add_inline_editing_attributes( 'subtitle', 'basic' );
$this->add_inline_editing_attributes( 'bg_text', 'none' );
?>
<!-- Gallery Section Start -->
<section class="gallery-section bg-green text-white text-center pt-140 rpt-90 pb-120 rpb-70">
<?php if ( $settings['bg_text'] || $settings['title'] ) : ?>
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-8 col-lg-9 col-md-10">
<div class="section-title mb-65">
<?php if ( $settings['bg_text'] ) : ?>
<span class="bg-text">
<span <?php echo $this->get_render_attribute_string( 'bg_text' ); ?>><?php echo wp_kses_post( $settings['bg_text'] ); ?></span>
</span>
<?php endif; ?>
<?php if ( $settings['title'] ) : ?>
<h2>
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>><?php echo wp_kses_post( $settings['title'] ); ?></span>
</h2>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $settings['items'] ) : ?>
<div class="container-fluid">
<div class="custom-gallery-wrap">
<?php foreach ( $settings['items'] as $index => $item ) :
$item_title = $this->get_repeater_setting_key( 'title', 'items', $index );
$this->add_inline_editing_attributes( $item_title, 'basic' );
?>
<div class="custom-gallery-item wow fadeInUp delay-0-2s <?php if ( $item['type_show'] == 2 ) : ?> vertical-item<?php endif; ?><?php if ( $item['type_show'] == 3 ) : ?> big-item<?php endif; ?>">
<?php if ( $item['image'] ) : $image = wp_get_attachment_image_url( $item['image']['id'], 'lesya_900x900' ); ?>
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $item['name'] ); ?>" />
<?php endif; ?>
<div class="gallery-overlay">
<a href="<?php echo esc_url( $image ); ?>"><i class="fas fa-share"></i></a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</section>
<!-- Gallery Section End -->
<?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_Gallery_Widget() );