start_controls_section( 'section_gallery', [ 'label' => esc_html__( 'Gallery Images', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'gallery_images', [ 'label' => esc_html__( 'Add Images', 'easy-elements' ), 'type' => Controls_Manager::GALLERY, 'default' => [], ] ); $this->add_responsive_control( 'columns', [ 'label' => esc_html__( 'Columns', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => '4', 'options' => [ '1' => esc_html__( '1 Column', 'easy-elements' ), '2' => esc_html__( '2 Columns', 'easy-elements' ), '3' => esc_html__( '3 Columns', 'easy-elements' ), '4' => esc_html__( '4 Columns', 'easy-elements' ), '5' => esc_html__( '5 Columns', 'easy-elements' ), ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-grid' => 'grid-template-columns: repeat({{VALUE}}, 1fr);', ], ] ); $this->add_group_control( Group_Control_Image_Size::get_type(), [ 'name' => 'thumbnail', 'default' => 'large', 'separator' => 'none', ] ); $this->add_control( 'show_caption', [ 'label' => esc_html__( 'Show Caption', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Show', 'easy-elements' ), 'label_off' => esc_html__( 'Hide', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'caption_source', [ 'label' => esc_html__( 'Caption Source', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'media', 'options' => [ 'media' => esc_html__( 'Media Library Caption', 'easy-elements' ), 'title' => esc_html__( 'Image Title', 'easy-elements' ), 'none' => esc_html__( 'None', 'easy-elements' ), ], 'condition' => [ 'show_caption' => 'yes', ], ] ); $this->add_control( 'show_description', [ 'label' => esc_html__( 'Show Description', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Show', 'easy-elements' ), 'label_off' => esc_html__( 'Hide', 'easy-elements' ), 'default' => '', 'description' => esc_html__( 'Pulls from each image\'s Description field in the Media Library. Hidden automatically when empty.', 'easy-elements' ), 'separator' => 'before', ] ); $this->add_control( 'enable_popup', [ 'label' => esc_html__( 'Enable Lightbox', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'order_by', [ 'label' => esc_html__( 'Order By', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'menu_order', 'options' => [ 'menu_order' => esc_html__( 'Default', 'easy-elements' ), 'title' => esc_html__( 'Title', 'easy-elements' ), 'id' => esc_html__( 'ID', 'easy-elements' ), 'date' => esc_html__( 'Date', 'easy-elements' ), 'rand' => esc_html__( 'Random', 'easy-elements' ), ], ] ); $this->add_control( 'hover_style', [ 'label' => esc_html__( 'On Hover', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'default', 'options' => [ 'default' => esc_html__( 'Default', 'easy-elements' ), 'icon' => esc_html__( 'Icon', 'easy-elements' ), 'text' => esc_html__( 'Text', 'easy-elements' ), ], ] ); $this->add_control( 'hover_text', [ 'label' => esc_html__( 'Hover Text', 'easy-elements' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => esc_html__( 'View', 'easy-elements' ), 'placeholder' => esc_html__( 'Enter hover text', 'easy-elements' ), 'condition' => [ 'hover_style' => 'text', ], ] ); $this->add_control( 'hover_icon', [ 'label' => esc_html__( 'Hover Icon', 'easy-elements' ), 'type' => \Elementor\Controls_Manager::ICONS, 'default' => [ 'value' => 'fas fa-plus', 'library' => 'fa-solid', ], 'condition' => [ 'hover_style' => 'icon', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_item_style', [ 'label' => esc_html__('Items', 'easy-elements'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'image_gap', [ 'label' => esc_html__( 'Gap', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 100 ], ], 'default' => [ 'size' => 10 ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-grid' => 'gap: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_image_style', [ 'label' => esc_html__('Images', 'easy-elements'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'image_height', [ 'label' => esc_html__( 'Height', 'easy-elements' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'range' => [ 'px' => [ 'min' => 50, 'max' => 1000, 'step' => 1 ], '%' => [ 'min' => 10, 'max' => 100, 'step' => 1 ], ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-item img' => 'height: {{SIZE}}{{UNIT}}; object-fit: cover; width: 100%;', ], ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'image_border', 'label' => esc_html__( 'Border', 'easy-elements' ), 'selector' => '{{WRAPPER}} .eel-gallery-item img', ] ); $this->add_responsive_control( 'image_border_radius', [ 'label' => esc_html__( 'Border Radius', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-item img, {{WRAPPER}} .eel-gallery-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_caption_style', [ 'label' => esc_html__('Caption', 'easy-elements'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 'conditions' => [ 'relation' => 'or', 'terms' => [ [ 'name' => 'show_caption', 'operator' => '==', 'value' => 'yes', ], [ 'name' => 'show_description', 'operator' => '==', 'value' => 'yes', ], ], ], ] ); $this->add_control( 'container_heading', [ 'label' => esc_html__('Container', 'easy-elements'), 'type' => Controls_Manager::HEADING, ] ); $this->add_responsive_control( 'caption_padding', [ 'label' => esc_html__('Padding', 'easy-elements'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-caption' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'caption_border_radius', [ 'label' => esc_html__('Border Radius', 'easy-elements'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-caption' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'caption_width', [ 'label' => esc_html__('Width', 'easy-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'range' => [ 'px' => [ 'min' => 50, 'max' => 1000, 'step' => 1 ], '%' => [ 'min' => 10, 'max' => 100, 'step' => 1 ], ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-caption' => 'width: {{SIZE}}{{UNIT}}; margin: 0 auto; left: 0; right: 0;', ], ] ); $this->add_responsive_control( 'caption_move_up', [ 'label' => esc_html__('Move Up', 'easy-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 500, 'step' => 1 ], '%' => [ 'min' => 0, 'max' => 100, 'step' => 1 ], ], 'description' => esc_html__('Lift the caption block upward over the image.', 'easy-elements'), 'selectors' => [ '{{WRAPPER}} .eel-gallery-caption' => 'transform: translateY(-{{SIZE}}{{UNIT}});', ], ] ); $this->add_responsive_control( 'caption_align', [ 'label' => esc_html__('Alignment', 'easy-elements'), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__('Left', 'easy-elements'), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__('Center', 'easy-elements'), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__('Right', 'easy-elements'), 'icon' => 'eicon-text-align-right', ], ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-caption' => 'text-align: {{VALUE}};', ], ] ); $this->add_control( 'caption_heading', [ 'label' => esc_html__('Caption', 'easy-elements'), 'type' => Controls_Manager::HEADING, 'separator' => 'before', 'condition' => [ 'show_caption' => 'yes', ], ] ); // Caption Color $this->add_control( 'caption_color', [ 'label' => esc_html__('Color', 'easy-elements'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-gallery-caption' => 'color: {{VALUE}};', ], 'condition' => [ 'show_caption' => 'yes', ], ] ); // Caption Background Color $this->add_control( 'caption_bg_color', [ 'label' => esc_html__('Background Color', 'easy-elements'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-gallery-caption' => 'background-color: {{VALUE}};', ], 'condition' => [ 'show_caption' => 'yes', ], ] ); // Caption Typography $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'caption_typography', 'label' => esc_html__('Typography', 'easy-elements'), 'selector' => '{{WRAPPER}} .eel-gallery-caption', 'condition' => [ 'show_caption' => 'yes', ], ] ); $this->add_control( 'description_heading', [ 'label' => esc_html__('Description', 'easy-elements'), 'type' => Controls_Manager::HEADING, 'separator' => 'before', 'condition' => [ 'show_description' => 'yes', ], ] ); $this->add_control( 'description_color', [ 'label' => esc_html__('Color', 'easy-elements'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-gallery-description' => 'color: {{VALUE}};', ], 'condition' => [ 'show_description' => 'yes', ], ] ); $this->add_group_control( \Elementor\Group_Control_Background::get_type(), [ 'name' => 'description_background', 'label' => esc_html__('Background', 'easy-elements'), 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .eel-gallery-description', 'condition' => [ 'show_description' => 'yes', ], ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'description_typography', 'label' => esc_html__('Typography', 'easy-elements'), 'selector' => '{{WRAPPER}} .eel-gallery-description', 'condition' => [ 'show_description' => 'yes', ], ] ); $this->add_responsive_control( 'description_margin', [ 'label' => esc_html__('Margin', 'easy-elements'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-gallery-description' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'condition' => [ 'show_description' => 'yes', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_hover_overlay_style', [ 'label' => esc_html__('Hover Overlay', 'easy-elements'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 'condition' => [ 'hover_style!' => 'default', ], ] ); $this->add_control( 'hover_overlay_color', [ 'label' => esc_html__( 'Hover Overlay Color', 'easy-elements' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'rgba(0,0,0,0.6)', 'selectors' => [ '{{WRAPPER}} .eel-hover-content' => 'background-color: {{VALUE}};', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_hover_icon_style', [ 'label' => esc_html__('Hover Icon', 'easy-elements'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 'condition' => [ 'hover_style' => 'icon', ], ] ); $this->add_responsive_control( 'hover_icon_size', [ 'label' => esc_html__( 'Icon Size', 'easy-elements' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 10, 'max' => 100 ], ], 'default' => [ 'size' => 16 ], 'selectors' => [ '{{WRAPPER}} .eel-hover-icon i' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .eel-hover-icon svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'hover_icon_color', [ 'label' => esc_html__( 'Icon Color', 'easy-elements' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .eel-hover-icon i, {{WRAPPER}} .eel-hover-icon svg, {{WRAPPER}} .eel-hover-icon svg path' => 'color: {{VALUE}}; fill: {{VALUE}};', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_hover_text_style', [ 'label' => esc_html__('Hover Text', 'easy-elements'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 'condition' => [ 'hover_style' => 'text', ], ] ); // Color $this->add_control( 'hover_text_color', [ 'label' => esc_html__('Color', 'easy-elements'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-hover-text span' => 'color: {{VALUE}};', ], ] ); // Typography $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'hover_text_color_typography', 'label' => esc_html__('Typography', 'easy-elements'), 'selector' => '{{WRAPPER}} .eel-hover-text span', ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $images = $settings['gallery_images']; if ( empty( $images ) ) { echo '
' . esc_html__( 'Please select images to display the gallery.', 'easy-elements' ) . '
'; return; } // Order images $order_by = $settings['order_by']; if ( $order_by === 'rand' ) { shuffle( $images ); } elseif ( $order_by !== 'menu_order' ) { usort( $images, function( $a, $b ) use ( $order_by ) { $a_post = get_post( $a['id'] ); $b_post = get_post( $b['id'] ); if ( ! $a_post || ! $b_post ) return 0; return strcmp( strtolower( $a_post->$order_by ), strtolower( $b_post->$order_by ) ); }); } $popup_enabled = isset( $settings['enable_popup'] ) && $settings['enable_popup'] === 'yes'; $popup_class = $popup_enabled ? 'eel-popup-enabled' : ''; echo '