OwlCyberSecurity - MANAGER
Edit File: gallery-filer.php
<?php use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Group_Control_Typography; use Elementor\Utils; use Elementor\Group_Control_Border; if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly class Chursy_Elementor_Gallery_Filter extends Widget_Base { public function get_name() { return 'chursy_elementor_gallery_filter'; } public function get_title() { return esc_html__( 'Gallery Filter', 'chursy' ); } public function get_icon() { return 'eicon-gallery-grid'; } public function get_categories() { return [ 'chursy' ]; } public function get_script_depends() { wp_enqueue_script( 'isotope', get_template_directory_uri().'/assets/libs/isotope/isotope.pkgd.min.js', array('jquery'), false, true ); return [ 'chursy-elementor-gallery-filter' ]; } // Add Your Controll In This Function protected function register_controls() { $this->start_controls_section( 'section_content', [ 'label' => esc_html__( 'Content', 'chursy' ), ] ); // Add Class control $this->add_control( 'always_show_overlay', [ 'label' => esc_html__( 'Always Show Overlay', 'chursy' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Show', 'chursy' ), 'label_off' => esc_html__( 'Hide', 'chursy' ), 'return_value' => 'yes', 'default' => 'no', ] ); $this->add_control( 'show_category_filter', [ 'label' => esc_html__( 'Show Category Filter', 'chursy' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Show', 'chursy' ), 'label_off' => esc_html__( 'Hide', 'chursy' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'cateAll', [ 'label' => esc_html__( 'Text All', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => esc_html__('All','chursy'), 'condition' => [ 'show_category_filter' => 'yes' ] ] ); $this->add_control( 'number_column', [ 'label' => esc_html__( 'Number Column', 'chursy' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'three_column', 'options' => [ 'no_column' => esc_html__( 'No Columns', 'chursy' ), 'three_column' => esc_html__( '3 Columns', 'chursy' ), 'four_column' => esc_html__( '4 Columns', 'chursy' ), ], ] ); $this->add_control( 'layout_mode', [ 'label' => esc_html__( 'Layout Mode', 'chursy' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'fitRows', 'options' => [ 'fitRows' => esc_html__( 'fitRows', 'chursy' ), 'masonry' => esc_html__( 'Masonry', 'chursy' ), ], ] ); $this->add_control( 'thumbnail_size', [ 'label' => esc_html__( 'Thumbnail Size', 'chursy' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'chursy_thumbnail', 'options' => [ 'chursy_thumbnail' => esc_html__( 'Chursy Thumbnail', 'chursy' ), 'large' => esc_html__( 'Large', 'chursy' ), 'full' => esc_html__( 'Full', 'chursy' ), ], ] ); $repeater = new \Elementor\Repeater(); $repeater->add_control( 'link', [ 'label' => esc_html__( 'Link', 'chursy' ), 'type' => \Elementor\Controls_Manager::URL, 'placeholder' => esc_html__( 'https://your-link.com', 'chursy' ), 'options' => [ 'url', 'is_external', 'nofollow' ], 'default' => [ 'url' => '', 'is_external' => false, 'nofollow' => false, ], 'description' => esc_html__('Redirect to the link instead of Fancybox popup','chursy'), 'dynamic' => [ 'active' => true, ], ] ); $repeater->add_control( 'video_link', [ 'label' => esc_html__( 'Embed Video Link', 'chursy' ), 'type' => \Elementor\Controls_Manager::URL, 'placeholder' => esc_html__( 'https://your-link.com', 'chursy' ), 'options' => [ 'url', 'is_external', 'nofollow' ], 'default' => [ 'url' => '', 'is_external' => false, 'nofollow' => false, ], 'dynamic' => [ 'active' => true, ], ] ); $repeater->add_control( 'icon', [ 'label' => esc_html__( 'Icon', 'chursy' ), 'type' => \Elementor\Controls_Manager::ICONS, 'default' => [ 'value' => 'ovaicon ovaicon-next-4', 'library' => 'all', ], ] ); $repeater->add_control( 'category', [ 'label' => esc_html__( 'Category', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => esc_html__( 'Church', 'chursy' ), ] ); $repeater->add_control( 'title', [ 'label' => esc_html__( 'Title', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'rows' => 3, 'default' => esc_html__( '', 'chursy' ), ] ); $repeater->add_control( 'image', [ 'label' => esc_html__( 'Image Gallery', 'chursy' ), 'type' => \Elementor\Controls_Manager::MEDIA, 'default' => [ 'url' => \Elementor\Utils::get_placeholder_image_src(), ], ] ); $repeater->add_control( 'image_popup', [ 'label' => esc_html__( 'Popup Image', 'chursy' ), 'type' => \Elementor\Controls_Manager::MEDIA, ] ); $repeater->add_control( 'is_large_column', [ 'label' => esc_html__( 'Is Large Column', 'chursy' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Show', 'chursy' ), 'label_off' => esc_html__( 'Hide', 'chursy' ), 'return_value' => 'yes', 'default' => 'no', ] ); $this->add_control( 'tab_item', [ 'label' => esc_html__( 'Items Gallery', 'chursy' ), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'default' => [ [ 'category' => esc_html__('Church', 'chursy'), ], [ 'category' => esc_html__('Donation', 'chursy'), ], [ 'category' => esc_html__('Charity', 'chursy'), ], [ 'category' => esc_html__('Education', 'chursy'), ], [ 'category' => esc_html__('Charity', 'chursy'), ], [ 'category' => esc_html__('Education', 'chursy'), ], [ 'category' => esc_html__('Charity', 'chursy'), ], [ 'category' => esc_html__('Church', 'chursy'), ], [ 'category' => esc_html__('Donation', 'chursy'), ], ], 'title_field' => '{{{ title }}}', ] ); $this->end_controls_section(); /* BEGIN WRAP CATEGORY STYLE */ $this->start_controls_section( 'wrap_category_style', [ 'label' => esc_html__( 'Wrap Category', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'show_category_filter' => 'yes' ] ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'wrap_category_border', 'label' => esc_html__( 'Border', 'chursy' ), 'selector' => '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper', ] ); $this->add_responsive_control( 'wrap_category_padding', [ 'label' => esc_html__( 'Padding', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'wrap_category_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); /* END WRAP CATEGORY STYLE */ /* BEGIN CATEGORY FILTER STYLE */ $this->start_controls_section( 'filter_style', [ 'label' => esc_html__( 'Filter', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'show_category_filter' => 'yes' ] ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'filter_typography', 'selector' => '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper li.filter-btn', ] ); $this->add_control( 'filter_color_normal', [ 'label' => esc_html__( 'Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper li.filter-btn' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'filter_color_active', [ 'label' => esc_html__( 'Color Active', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper li.filter-btn.active-category' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'border_filter', 'label' => esc_html__( 'Border', 'chursy' ), 'selector' => '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper li.filter-btn', ] ); $this->add_control( 'filter_border_color_active', [ 'label' => esc_html__( 'Border Color Active', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper li.filter-btn.active-category' => 'border-color: {{VALUE}}', ], ] ); $this->add_responsive_control( 'filter_padding', [ 'label' => esc_html__( 'Padding', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper li.filter-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'filter_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .filter-btn-wrapper li.filter-btn' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); /* END CATEGORY FILTER STYLE */ /* BEGIN IMAGE STYLE */ $this->start_controls_section( 'section_image', [ 'label' => esc_html__( 'Image', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'image_height', [ 'label' => esc_html__( 'Height', 'chursy' ), 'type' => Controls_Manager::SLIDER, 'size_units' => ['px'], 'range' => [ 'px' => [ 'min' => 300, 'max' => 500, 'step' => 10, ], ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img img' => 'height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'image_border_radius', [ 'label' => esc_html__( 'Border Radius', 'chursy' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'overlay_bgcolor', [ 'label' => esc_html__( 'Overlay Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .mask' => 'background-color: {{VALUE}}', ], ] ); $this->end_controls_section(); /* END IMAGE STYLE */ /* BEGIN ICON STYLE */ $this->start_controls_section( 'section_icon_style', [ 'label' => esc_html__( 'Icon', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'icon_size', [ 'label' => esc_html__( 'Size', 'chursy' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 40, 'step' => 1, ], ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon i' => 'font-size: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'icon_bgsize', [ 'label' => esc_html__( 'Background Size', 'chursy' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px'], 'range' => [ 'px' => [ 'min' => 48, 'max' => 130, 'step' => 1, ], ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'icon_rotate', [ 'label' => esc_html__( 'Rotate', 'chursy' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ], 'default' => [ 'unit' => 'deg', 'size' => -45, ], 'tablet_default' => [ 'unit' => 'deg', ], 'mobile_default' => [ 'unit' => 'deg', ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon i' => 'transform: rotate({{SIZE}}{{UNIT}});', ], ] ); $this->add_responsive_control( 'icon_rotate_hover', [ 'label' => esc_html__( 'Rotate Hover', 'chursy' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ], 'default' => [ 'unit' => 'deg', 'size' => -135, ], 'tablet_default' => [ 'unit' => 'deg', ], 'mobile_default' => [ 'unit' => 'deg', ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon:hover i' => 'transform: rotate({{SIZE}}{{UNIT}});', ], ] ); $this->add_control( 'bg_border_radius_icon', [ 'label' => esc_html__( 'Border Radius', 'chursy' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->start_controls_tabs( 'tabs_icons_style' ); $this->start_controls_tab( 'tab_icon_normal', [ 'label' => esc_html__( 'Normal', 'chursy' ), ] ); $this->add_control( 'color_icon', [ 'label' => esc_html__( 'Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon i' => 'color : {{VALUE}};', ], ] ); $this->add_control( 'bgcolor_icon', [ 'label' => esc_html__( 'Background Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon' => 'background-color : {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'tab_icon_hover', [ 'label' => esc_html__( 'Hover', 'chursy' ), ] ); $this->add_control( 'color_icon_hover', [ 'label' => esc_html__( 'Color Hover', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon:hover i' => 'color : {{VALUE}};', ], ] ); $this->add_control( 'bgcolor_icon_hover', [ 'label' => esc_html__( 'Background Color Hover', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .gallery-img .icon-box .icon:hover' => 'background-color : {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); /* END ICON STYLE */ /* BEGIN TITLE STYLE */ $this->start_controls_section( 'title_style', [ 'label' => esc_html__( 'Title', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'selector' => '{{WRAPPER}} .ova-gallery-filter .gallery-item .title', ] ); $this->add_control( 'title_color', [ 'label' => esc_html__( 'Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .title' => 'color: {{VALUE}}', ], ] ); $this->add_responsive_control( 'title_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .ova-gallery-filter .gallery-item .title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); } protected function slugify($text, string $divider = '-') { // replace non letter or digits by divider $text = preg_replace('~[^\pL\d]+~u', $divider, $text); // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); // trim $text = trim($text, $divider); // remove duplicate divider $text = preg_replace('~-+~', $divider, $text); // lowercase $text = strtolower($text); if (empty($text)) { return ''; } return $text; } // Render Template Here protected function render() { $settings = $this->get_settings(); $show_category_filer = $settings['show_category_filter']; $cateAll = isset($settings['cateAll']) ? $settings['cateAll'] : esc_html__('All','chursy'); $number_column = $settings['number_column']; $layout_mode = $settings['layout_mode']; $thumbnail_size = $settings['thumbnail_size']; $tabs = $settings['tab_item']; $cate_array = array(); $always_show_overlay = ''; if ( $settings['always_show_overlay'] == 'yes' ) { $always_show_overlay = 'always_show_overlay'; } ?> <?php if ( $tabs && is_array( $tabs ) ): ?> <div class="ova-gallery-filter" data-layout_mode="<?php echo esc_attr($layout_mode);?>"> <?php if( $show_category_filer == 'yes') { ?> <?php foreach ( $tabs as $key => $items ): $category = $items['category']; array_push($cate_array,$category); $cate_array = array_unique($cate_array); endforeach; ?> <ul class="filter-btn-wrapper"> <li class="filter-btn active-category" data-filter="*"> <?php echo esc_html( $cateAll ); ?> </li> <?php if ( $cate_array ) : foreach ( $cate_array as $cate) : $slug = $this->slugify($cate); ?> <?php if( $cate != '' ) { ?> <li class="filter-btn" data-slug=".<?php echo esc_attr($slug);?>"> <?php echo esc_html( $cate ); ?> </li> <?php } ?> <?php endforeach; endif; ?> </ul> <?php } ?> <div class="gallery-row <?php echo esc_attr($always_show_overlay);?>"> <div class="gallery-column <?php echo esc_attr( $number_column ) ?>"> <?php foreach ( $tabs as $key => $items ): $item_id = 'elementor-repeater-item-' . $items['_id']; if( $items['is_large_column'] == 'yes') { $is_large_column = 'is_large_column'; } else { $is_large_column = ''; } $category2 = $items['category']; $slug2 = $this->slugify($category2); $title = $items['title']; $img_id = $items['image']['id']; $img_url = $items['image']['url']; $img_popup = $items['image_popup']['url']; if ( $img_popup == '' ) { $img_popup = $img_url; } $thumbnail_url = isset(wp_get_attachment_image_src( $img_id, $thumbnail_size )[0]) ? wp_get_attachment_image_src( $img_id, $thumbnail_size )[0] : $img_url; // alt and caption image $img_alt = ( isset($items['image']['alt']) && $items['image']['alt'] != '' ) ? $items['image']['alt'] : $title; $caption = wp_get_attachment_caption( $img_id ); if ( $caption == '' ) { $caption = $img_alt; } // link and video link $video_link = $items['video_link']['url']; $link = $items['link']['url']; $target = $items['link']['is_external'] ? 'target="_blank"' : ''; ?> <div class="gallery-item <?php echo esc_attr($slug2);?> <?php echo esc_attr($item_id);?> <?php echo esc_attr($is_large_column);?>"> <?php if( $video_link ) { ?> <a class="gallery-fancybox" data-src="<?php echo esc_url( $video_link ); ?>" href="<?php echo esc_attr($video_link); ?>" data-fancybox="gallery-filter" data-caption="<?php echo esc_attr( $caption ); ?>"> <?php } elseif ( $link ) { ?> <a href="<?php echo esc_attr($link); ?>" <?php printf( $target ); ?>> <?php } else { ?> <a href="#" class="gallery-fancybox" data-src="<?php echo esc_url( $img_popup ); ?>" data-fancybox="gallery-filter" data-caption="<?php echo esc_attr( $caption ); ?>"> <?php } ?> <div class="gallery-img"> <img src="<?php echo esc_url( $thumbnail_url ) ?>" alt="<?php echo esc_attr($img_alt); ?>"> <div class="icon-box"> <?php if( !empty($items['icon']['value']) ) { ?> <div class="icon"> <?php \Elementor\Icons_Manager::render_icon( $items['icon'], [ 'aria-hidden' => 'true' ] ); ?> </div> <?php } ?> <?php if( !empty($title) ) { ?> <h3 class="title"> <?php echo esc_html( $title ); ?> </h3> <?php } ?> </div> <div class="mask"></div> </div> </a> </div> <?php endforeach; ?> </div> </div> </div> <?php endif; } } $widgets_manager->register( new Chursy_Elementor_Gallery_Filter() );