start_controls_section( 'content_section', [ 'label' => esc_html__('Gallery Content', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'gallery_source', [ 'label' => esc_html__('Image Source', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'manual', 'options' => [ 'manual' => esc_html__('Manual Upload', 'advanced-widget-kit-for-elementor'), 'media_library' => esc_html__('WordPress Media Library', 'advanced-widget-kit-for-elementor'), 'acf_gallery' => esc_html__('ACF Gallery Field', 'advanced-widget-kit-for-elementor'), 'custom_post' => esc_html__('Custom Post Type', 'advanced-widget-kit-for-elementor'), ], ] ); // Manual Upload $this->add_control( 'gallery_images', [ 'label' => esc_html__('Gallery Images', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::GALLERY, 'default' => [], 'condition' => [ 'gallery_source' => 'manual', ], ] ); // Media Library $this->add_control( 'media_library_ids', [ 'label' => esc_html__('Media IDs', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => esc_html__('Enter comma-separated media IDs', 'advanced-widget-kit-for-elementor'), 'condition' => [ 'gallery_source' => 'media_library', ], ] ); // ACF Gallery Field $this->add_control( 'acf_field_name', [ 'label' => esc_html__('ACF Field Name', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => 'gallery_images', 'condition' => [ 'gallery_source' => 'acf_gallery', ], ] ); // Custom Post Type $this->add_control( 'post_type', [ 'label' => esc_html__('Post Type', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $this->get_post_types(), 'condition' => [ 'gallery_source' => 'custom_post', ], ] ); $this->add_control( 'posts_per_page', [ 'label' => esc_html__('Posts Per Page', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => 12, 'min' => 1, 'max' => 100, 'condition' => [ 'gallery_source' => 'custom_post', ], ] ); $this->end_controls_section(); // Layout Section $this->start_controls_section( 'layout_section', [ 'label' => esc_html__('Layout Settings', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'gallery_layout', [ 'label' => esc_html__('Gallery Layout', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'grid', 'options' => [ 'grid' => esc_html__('Grid', 'advanced-widget-kit-for-elementor'), 'masonry' => esc_html__('Masonry', 'advanced-widget-kit-for-elementor'), 'justified' => esc_html__('Justified', 'advanced-widget-kit-for-elementor'), ], 'frontend_available' => true, ] ); $this->add_responsive_control( 'columns', [ 'label' => esc_html__('Columns', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '3', 'tablet_default' => '2', 'mobile_default' => '1', 'options' => [ '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', ], 'selectors' => [ '{{WRAPPER}} .awke-gallery-grid' => 'grid-template-columns: repeat({{VALUE}}, 1fr);', ], 'condition' => [ 'gallery_layout' => 'grid', ], ] ); $this->add_control( 'image_ratio', [ 'label' => esc_html__('Image Ratio', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'original', 'options' => [ 'original' => esc_html__('Original', 'advanced-widget-kit-for-elementor'), 'square' => esc_html__('Square (1:1)', 'advanced-widget-kit-for-elementor'), 'landscape' => esc_html__('Landscape (4:3)', 'advanced-widget-kit-for-elementor'), 'portrait' => esc_html__('Portrait (3:4)', 'advanced-widget-kit-for-elementor'), ], 'condition' => [ 'gallery_layout' => 'grid', ], ] ); $this->add_responsive_control( 'gallery_gap', [ 'label' => esc_html__('Gap Between Images', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px', 'em'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, 'step' => 1, ], ], 'default' => [ 'unit' => 'px', 'size' => 10, ], 'selectors' => [ '{{WRAPPER}} .awke-gallery-grid' => 'gap: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .awke-gallery-masonry' => 'gap: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Filter Section $this->start_controls_section( 'filter_section', [ 'label' => esc_html__('Filter Settings', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_filters', [ 'label' => esc_html__('Show Filters', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'no', 'frontend_available' => true, ] ); $this->add_control( 'filter_all_text', [ 'label' => esc_html__('All Filter Text', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => esc_html__('All', 'advanced-widget-kit-for-elementor'), 'condition' => [ 'show_filters' => 'yes', ], ] ); $this->add_control( 'filter_taxonomy', [ 'label' => esc_html__('Filter By Taxonomy', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $this->get_taxonomies(), 'condition' => [ 'show_filters' => 'yes', ], ] ); $this->end_controls_section(); // Lightbox Section $this->start_controls_section( 'lightbox_section', [ 'label' => esc_html__('Lightbox Settings', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'enable_lightbox', [ 'label' => esc_html__('Enable Lightbox', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', 'frontend_available' => true, ] ); $this->add_control( 'lightbox_effect', [ 'label' => esc_html__('Lightbox Effect', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'zoom', 'options' => [ 'zoom' => esc_html__('Zoom', 'advanced-widget-kit-for-elementor'), 'fade' => esc_html__('Fade', 'advanced-widget-kit-for-elementor'), 'slide' => esc_html__('Slide', 'advanced-widget-kit-for-elementor'), ], 'condition' => [ 'enable_lightbox' => 'yes', ], 'frontend_available' => true, ] ); $this->add_control( 'show_captions', [ 'label' => esc_html__('Show Captions', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', 'condition' => [ 'enable_lightbox' => 'yes', ], 'frontend_available' => true, ] ); $this->add_control( 'show_thumbnails', [ 'label' => esc_html__('Show Thumbnails', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', 'condition' => [ 'enable_lightbox' => 'yes', ], 'frontend_available' => true, ] ); $this->end_controls_section(); // Hover Effects Section $this->start_controls_section( 'hover_section', [ 'label' => esc_html__('Hover Effects', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'hover_effect', [ 'label' => esc_html__('Hover Effect', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'overlay', 'options' => [ 'none' => esc_html__('None', 'advanced-widget-kit-for-elementor'), 'overlay' => esc_html__('Overlay', 'advanced-widget-kit-for-elementor'), 'zoom' => esc_html__('Zoom', 'advanced-widget-kit-for-elementor'), 'grayscale' => esc_html__('Grayscale', 'advanced-widget-kit-for-elementor'), 'blur' => esc_html__('Blur', 'advanced-widget-kit-for-elementor'), 'icon' => esc_html__('Icon Button', 'advanced-widget-kit-for-elementor'), ], 'frontend_available' => true, ] ); $this->add_control( 'overlay_color', [ 'label' => esc_html__('Overlay Color', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'rgba(0, 0, 0, 0.7)', 'condition' => [ 'hover_effect' => 'overlay', ], 'selectors' => [ '{{WRAPPER}} .awke-gallery-item:hover .awke-gallery-overlay' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'hover_icon', [ 'label' => esc_html__('Hover Icon', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::ICONS, 'default' => [ 'value' => 'fas fa-search-plus', 'library' => 'fa-solid', ], 'condition' => [ 'hover_effect' => 'icon', ], ] ); $this->end_controls_section(); // Load More Section $this->start_controls_section( 'load_more_section', [ 'label' => esc_html__('Load More Settings', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'enable_load_more', [ 'label' => esc_html__('Enable Load More', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'no', 'frontend_available' => true, ] ); $this->add_control( 'load_more_text', [ 'label' => esc_html__('Load More Text', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => esc_html__('Load More', 'advanced-widget-kit-for-elementor'), 'condition' => [ 'enable_load_more' => 'yes', ], ] ); $this->add_control( 'images_per_load', [ 'label' => esc_html__('Images Per Load', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => 6, 'min' => 1, 'max' => 50, 'condition' => [ 'enable_load_more' => 'yes', ], 'frontend_available' => true, ] ); $this->end_controls_section(); // Animation Section $this->start_controls_section( 'animation_section', [ 'label' => esc_html__('Animation Settings', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'enable_animations', [ 'label' => esc_html__('Enable Animations', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', 'frontend_available' => true, ] ); $this->add_control( 'animation_type', [ 'label' => esc_html__('Animation Type', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'fadeIn', 'options' => [ 'fadeIn' => esc_html__('Fade In', 'advanced-widget-kit-for-elementor'), 'slideUp' => esc_html__('Slide Up', 'advanced-widget-kit-for-elementor'), 'slideDown' => esc_html__('Slide Down', 'advanced-widget-kit-for-elementor'), 'slideLeft' => esc_html__('Slide Left', 'advanced-widget-kit-for-elementor'), 'slideRight' => esc_html__('Slide Right', 'advanced-widget-kit-for-elementor'), 'zoomIn' => esc_html__('Zoom In', 'advanced-widget-kit-for-elementor'), ], 'condition' => [ 'enable_animations' => 'yes', ], 'frontend_available' => true, ] ); $this->add_control( 'animation_delay', [ 'label' => esc_html__('Animation Delay (ms)', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => 100, 'min' => 0, 'max' => 1000, 'condition' => [ 'enable_animations' => 'yes', ], 'frontend_available' => true, ] ); $this->end_controls_section(); // Style Section $this->start_controls_section( 'style_section', [ 'label' => esc_html__('Style', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'image_border_radius', [ 'label' => esc_html__('Border Radius', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .awke-gallery-item img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'image_box_shadow', 'label' => esc_html__('Box Shadow', 'advanced-widget-kit-for-elementor'), 'selector' => '{{WRAPPER}} .awke-gallery-item', ] ); $this->end_controls_section(); // Filter Style Section $this->start_controls_section( 'filter_style_section', [ 'label' => esc_html__('Filter Style', 'advanced-widget-kit-for-elementor'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 'condition' => [ 'show_filters' => 'yes', ], ] ); $this->add_control( 'filter_alignment', [ 'label' => esc_html__('Filter Alignment', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__('Left', 'advanced-widget-kit-for-elementor'), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__('Center', 'advanced-widget-kit-for-elementor'), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__('Right', 'advanced-widget-kit-for-elementor'), 'icon' => 'eicon-text-align-right', ], ], 'default' => 'center', 'selectors' => [ '{{WRAPPER}} .awke-gallery-filters' => 'text-align: {{VALUE}};', ], ] ); $this->add_control( 'filter_button_color', [ 'label' => esc_html__('Filter Button Color', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .awke-filter-btn' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'filter_button_bg_color', [ 'label' => esc_html__('Filter Button Background', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .awke-filter-btn' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'filter_button_active_color', [ 'label' => esc_html__('Active Filter Color', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .awke-filter-btn.active' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'filter_button_active_bg_color', [ 'label' => esc_html__('Active Filter Background', 'advanced-widget-kit-for-elementor'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .awke-filter-btn.active' => 'background-color: {{VALUE}};', ], ] ); $this->end_controls_section(); } /** * Get available post types. */ private function get_post_types() { $post_types = get_post_types(['public' => true], 'objects'); $options = []; foreach ($post_types as $post_type) { $options[$post_type->name] = $post_type->label; } return $options; } /** * Get available taxonomies. */ private function get_taxonomies() { $taxonomies = get_taxonomies(['public' => true], 'objects'); $options = []; foreach ($taxonomies as $taxonomy) { $options[$taxonomy->name] = $taxonomy->label; } return $options; } /** * Render widget output on the frontend. */ protected function render() { $settings = $this->get_settings_for_display(); // Check if we have any images to display $has_images = false; if (isset($settings['gallery_source'])) { switch ($settings['gallery_source']) { case 'manual': $has_images = !empty($settings['gallery_images']); break; case 'media_library': $has_images = !empty($settings['media_library_ids']); break; case 'acf_gallery': $has_images = !empty($settings['acf_field_name']); break; case 'custom_post': $has_images = !empty($settings['post_type']); break; } } if (!$has_images) { return; } // Store settings in transient for AJAX requests $widget_id = $this->get_id(); set_transient('awke_gallery_settings_' . $widget_id, $settings, HOUR_IN_SECONDS); $this->add_render_attribute('gallery-wrapper', [ 'class' => 'awke-advanced-image-gallery', 'data-settings' => wp_json_encode($this->get_gallery_settings($settings)), 'data-widget-id' => $widget_id, ]); ?>