105 lines
3.1 KiB
PHP
105 lines
3.1 KiB
PHP
<?php
|
|
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
|
|
|
class Elementor_Custom_Gallery extends \Elementor\Widget_Base {
|
|
|
|
public function get_name() {
|
|
return 'custom gallery';
|
|
}
|
|
|
|
public function get_title() {
|
|
return esc_html__( 'custom gallery', 'elementor-addon' );
|
|
}
|
|
|
|
public function get_icon() {
|
|
return 'eicon-code';
|
|
}
|
|
|
|
public function get_categories() {
|
|
return [ 'basic' ];
|
|
}
|
|
|
|
public function get_keywords() {
|
|
return [ 'gallery', 'images' ];
|
|
}
|
|
|
|
/**
|
|
* Register image gallery widget controls.
|
|
*
|
|
* Adds different input fields to allow the user to change and customize the widget settings.
|
|
*
|
|
* @since 3.1.0
|
|
* @access protected
|
|
*/
|
|
protected function register_controls() {
|
|
$this->start_controls_section(
|
|
'section_gallery',
|
|
[
|
|
'label' => esc_html__( 'Image Gallery', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'wp_gallery',
|
|
[
|
|
'label' => esc_html__( 'Add Images', 'elementor' ),
|
|
'type' => \Elementor\Controls_Manager::GALLERY,
|
|
'show_label' => false,
|
|
'dynamic' => [
|
|
'active' => true,
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
}
|
|
|
|
protected function render() {
|
|
$settings = $this->get_settings_for_display();
|
|
$gallery = $settings['wp_gallery'];
|
|
|
|
echo "<div class='custom-gallery'>";
|
|
echo "<div class='top'>";
|
|
echo "<div class='left'>";
|
|
if ( $gallery[0]['url'] ) {
|
|
echo "<a href='{$gallery[0]['url']}' data-elementor-open-lightbox='yes' data-elementor-lightbox-slideshow='111111'>";
|
|
echo "<img src='{$gallery[0]['url']}' alt='{$gallery[0]['title']}'>";
|
|
echo "</a>";
|
|
}
|
|
echo "</div>";
|
|
echo "<div class='right'>";
|
|
if ( $gallery[1]['url'] ) {
|
|
echo "<a href='{$gallery[1]['url']}' data-elementor-open-lightbox='yes' data-elementor-lightbox-slideshow='111111'>";
|
|
echo "<img src='{$gallery[1]['url']}' alt='{$gallery[1]['title']}'>";
|
|
echo "</a>";
|
|
|
|
}
|
|
if ( $gallery[2]['url'] ) {
|
|
echo "<a href='{$gallery[2]['url']}' data-elementor-open-lightbox='yes' data-elementor-lightbox-slideshow='111111'>";
|
|
echo "<img src='{$gallery[2]['url']}' alt='{$gallery[2]['title']}'>";
|
|
echo "</a>";
|
|
}
|
|
echo "</div>";
|
|
echo "</div>";
|
|
|
|
if ( count ( $gallery ) > 3 ) {
|
|
echo "<div class='bottom'>";
|
|
for ( $i = 3; $i < count( $gallery ); $i++ ) {
|
|
if ( $gallery[$i]['url'] and $i < 9 ) {
|
|
echo "<a href='{$gallery[$i]['url']}' data-elementor-open-lightbox='yes' data-elementor-lightbox-slideshow='111111'>";
|
|
echo "<img src='{$gallery[$i]['url']}' alt='{$gallery[$i]['title']}'>";
|
|
echo "</a>";
|
|
}
|
|
}
|
|
echo "</div>";
|
|
for ( $i = 9; $i < count( $gallery ); $i++ ) {
|
|
if ( $gallery[$i]['url'] ) {
|
|
echo "<a href='{$gallery[$i]['url']}' data-elementor-open-lightbox='yes' data-elementor-lightbox-slideshow='111111' class='hidden'>";
|
|
echo "<img src='{$gallery[$i]['url']}' alt='{$gallery[$i]['title']}'>";
|
|
echo "</a>";
|
|
}
|
|
}
|
|
}
|
|
echo "</div>";
|
|
}
|
|
} |