Changeset 3423134
- Timestamp:
- 12/18/2025 05:06:57 PM (4 months ago)
- Location:
- rainbow-slider/trunk
- Files:
-
- 3 edited
-
rainbow-slider.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
widgets/rainbow-slider-widget.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rainbow-slider/trunk/rainbow-slider.php
r3422472 r3423134 4 4 * Plugin URI: https://wordpress.org/plugins/rainbow-slider/ 5 5 * Description: Convert Elementor Sections, Containers, and Grids into a responsive Slider effortlessly. 6 * Version: 1.0. 26 * Version: 1.0.3 7 7 * Requires at least: 5.8 8 8 * Requires PHP: 7.2 … … 19 19 if ( ! defined( 'ABSPATH' ) ) exit; 20 20 21 use Elementor\Plugin; 22 use Elementor\Core\Files\CSS\Post as Post_CSS; 23 21 24 /*------------------------------------------------- 22 25 1. Register CPT (rainbow_slider) … … 32 35 'edit_item' => 'Edit Slider', 33 36 ], 34 'public' => true, 35 'show_in_rest' => true, 36 'menu_icon' => 'dashicons-images-alt2', 37 'supports' => [ 'title', 'editor' ], 38 ] ); 37 'public' => true, 38 'show_ui' => true, 39 'show_in_menu' => true, 40 'rewrite' => [ 'slug' => 'rainbow_slider', 'with_front' => false ], 41 'has_archive' => false, 42 'exclude_from_search' => true, 43 'menu_icon' => 'dashicons-art', 44 'supports' => [ 'title', 'editor' ], 45 ]); 39 46 }); 40 47 41 48 /*------------------------------------------------- 42 2. Admin Column: Shortcode 43 --------------------------------------------------*/ 44 add_filter( 'manage_rainbow_slider_posts_columns', function( $columns ) { 45 $date = $columns['date']; 46 unset( $columns['date'] ); 47 $columns['shortcode'] = 'Shortcode'; 48 $columns['date'] = $date; 49 return $columns; 50 }); 51 52 add_action( 'manage_rainbow_slider_posts_custom_column', function( $column, $post_id ) { 53 if ( 'shortcode' === $column ) { 54 echo '<input type="text" 55 value="[rainbow_slider id=\'' . esc_attr( $post_id ) . '\']" 56 readonly 57 style="width:100%;max-width:260px;padding:6px;background:#f0f0f1;border:1px solid #ddd;" 58 onclick="this.select()">'; 59 } 60 }, 10, 2 ); 61 62 /*------------------------------------------------- 63 3. Elementor Support for CPT 49 2. Elementor Support 64 50 --------------------------------------------------*/ 65 51 add_action( 'init', function () { … … 73 59 74 60 /*------------------------------------------------- 75 4. Enqueue Swiper & Assets61 3. Assets Enqueue 76 62 --------------------------------------------------*/ 77 add_action( 'wp_enqueue_scripts', function () { 78 79 // Swiper CSS (Local) 80 wp_enqueue_style( 81 'swiper', 82 plugin_dir_url( __FILE__ ) . 'assets/swiper/swiper-bundle.min.css', 83 [], 84 '11.0.0' 85 ); 86 87 // Custom CSS 63 function rainbow_slider_assets() { 64 wp_enqueue_style( 'swiper', plugin_dir_url( __FILE__ ) . 'assets/swiper/swiper-bundle.min.css', [], '11.0.0' ); 65 88 66 wp_add_inline_style( 'swiper', " 89 67 .rainbow-slider{width:100%;position:relative;overflow:hidden;opacity:0;transition:opacity .3s ease;min-height:50px} 90 68 .rainbow-slider.rainbow-loaded{opacity:1} 91 .rainbow-slider .swiper-wrapper{transition-property:transform,height;box-sizing:border-box} 92 .rainbow-slider .swiper-slide{height:auto;width:100%;position:relative;display:block} 93 .rainbow-slider .swiper-slide>.elementor-section, 94 .rainbow-slider .swiper-slide>.elementor-top-section, 95 .rainbow-slider .swiper-slide>.e-con, 96 .rainbow-slider .swiper-slide>.e-parent, 97 .rainbow-slider .swiper-slide>.e-container, 98 .rainbow-slider .swiper-slide>.e-grid{width:100%!important;height:100%} 99 " ); 69 .rainbow-slider .swiper-wrapper{display:flex;} /* Crucial Fix */ 70 .rainbow-slider .swiper-slide{height:auto;width:100%;flex-shrink:0;position:relative;display:block} 71 72 .rainbow-slider .swiper-slide > .elementor-section, 73 .rainbow-slider .swiper-slide > .e-con, 74 .rainbow-slider .swiper-slide > .e-container { width: 100% !important; height: 100%; } 75 "); 100 76 101 // Swiper JS (Local) 102 wp_enqueue_script( 103 'swiper', 104 plugin_dir_url( __FILE__ ) . 'assets/swiper/swiper-bundle.min.js', 105 [ 'jquery' ], 106 '11.0.0', 107 true 108 ); 77 wp_enqueue_script( 'swiper', plugin_dir_url( __FILE__ ) . 'assets/swiper/swiper-bundle.min.js', [ 'jquery' ], '11.0.0', true ); 109 78 110 // Initialization JS79 // JS Handler 111 80 $js_code = <<<'JS' 112 (function($){ 113 var initRainbowSlider = function() { 114 $('.rainbow-slider').each(function(){ 115 var slider = this; 116 if(slider.classList.contains('rainbow-loaded')) return; 81 window.initRainbowSlider = function( $scope ) { 82 var $slider = $scope.find('.rainbow-slider'); 83 if ( ! $slider.length ) return; 84 85 // Prevent double init 86 if ( $slider.hasClass('swiper-initialized') ) return; 117 87 118 var elementorInner = slider.querySelector('.elementor'); 119 if(!elementorInner){ 120 slider.classList.add('rainbow-loaded'); 121 return; 122 } 88 var elementorInner = $slider[0].querySelector('.elementor'); 89 if(!elementorInner) { $slider.addClass('rainbow-loaded'); return; } 123 90 124 var originalClasses = elementorInner.className.split(' '); 125 originalClasses.forEach(function(cls){ 126 if(cls !== 'elementor'){ 127 slider.classList.add(cls); 128 } 129 }); 91 // Copy classes 92 var originalClasses = elementorInner.className.split(' '); 93 originalClasses.forEach(function(cls){ if(cls !== 'elementor') $slider.addClass(cls); }); 130 94 131 var sections = elementorInner.querySelectorAll( 132 ':scope > .elementor-section,' + 133 ':scope > .elementor-top-section,' + 134 ':scope > .e-con,' + 135 ':scope > .e-parent,' + 136 ':scope > .e-container' 137 ); 138 if(!sections.length) return; 95 // Structure 96 var sections = elementorInner.querySelectorAll(':scope > .elementor-section, :scope > .elementor-top-section, :scope > .e-con, :scope > .e-parent, :scope > .e-container'); 97 if(!sections.length) return; 139 98 140 var wrapper = document.createElement('div');141 wrapper.className = 'swiper-wrapper';99 var wrapper = document.createElement('div'); 100 wrapper.className = 'swiper-wrapper'; 142 101 143 sections.forEach(function(section){144 var slide = document.createElement('div');145 slide.className = 'swiper-slide';146 slide.appendChild(section);147 wrapper.appendChild(slide);148 });102 sections.forEach(function(section){ 103 var slide = document.createElement('div'); 104 slide.className = 'swiper-slide'; 105 slide.appendChild(section); 106 wrapper.appendChild(slide); 107 }); 149 108 150 slider.innerHTML = '';151 slider.classList.add('elementor');152 slider.appendChild(wrapper);109 $slider.html('').addClass('elementor').append(wrapper); 110 $slider.append('<div class="swiper-pagination"></div><div class="swiper-button-next"></div><div class="swiper-button-prev"></div>'); 111 $slider.addClass('rainbow-loaded'); 153 112 154 $(slider).append( 155 '<div class="swiper-pagination"></div>' + 156 '<div class="swiper-button-next"></div>' + 157 '<div class="swiper-button-prev"></div>' 158 ); 159 160 slider.classList.add('rainbow-loaded'); 161 162 new Swiper(slider,{ 163 slidesPerView:1, 164 loop:true, 165 autoHeight:true, 166 observer:true, 167 observeParents:true, 168 effect:'slide', 169 pagination:{el:slider.querySelector('.swiper-pagination'),clickable:true}, 170 navigation:{ 171 nextEl:slider.querySelector('.swiper-button-next'), 172 prevEl:slider.querySelector('.swiper-button-prev') 173 }, 174 autoplay:{ 175 delay:5000, 176 disableOnInteraction:false, 177 pauseOnMouseEnter:true 178 } 179 }); 180 181 if(window.elementorFrontend){ 182 try{ elementorFrontend.init(); }catch(e){} 183 } 113 // Init Swiper 114 new Swiper($slider[0], { 115 slidesPerView: 1, 116 loop: true, 117 autoHeight: true, 118 observer: true, 119 observeParents: true, 120 pagination: { el: $slider.find('.swiper-pagination')[0], clickable: true }, 121 navigation: { nextEl: $slider.find('.swiper-button-next')[0], prevEl: $slider.find('.swiper-button-prev')[0] }, 122 autoplay: { delay: 5000, pauseOnMouseEnter: true } 184 123 }); 185 124 }; 186 125 187 $(document).ready(initRainbowSlider); 188 189 $(window).on('elementor/frontend/init',function(){ 190 elementorFrontend.hooks.addAction('frontend/element_ready/widget',function($scope){ 191 if($scope.find('.rainbow-slider').length){ 192 setTimeout(initRainbowSlider,100); 193 } 126 jQuery(window).on('elementor/frontend/init', function () { 127 elementorFrontend.hooks.addAction('frontend/element_ready/rainbow_slider_widget.default', function ($scope) { 128 window.initRainbowSlider($scope); 194 129 }); 195 130 }); 196 })(jQuery);197 131 JS; 132 wp_add_inline_script( 'swiper', $js_code ); 133 } 134 add_action( 'wp_enqueue_scripts', 'rainbow_slider_assets' ); 135 add_action( 'elementor/editor/before_enqueue_scripts', 'rainbow_slider_assets' ); 198 136 199 wp_add_inline_script( 'swiper', $js_code );200 });201 137 202 138 /*------------------------------------------------- 203 5. Shortcode139 4. RENDER FUNCTION (The CSS Fix) 204 140 --------------------------------------------------*/ 205 function rainbow_slider_shortcode( $atts ) { 206 $atts = shortcode_atts([ 'id' => 0 ], $atts ); 207 $post_id = intval( $atts['id'] ); 208 141 function get_rainbow_slider_view( $post_id ) { 142 $post_id = intval( $post_id ); 209 143 if ( ! $post_id || ! class_exists( '\\Elementor\\Plugin' ) ) return ''; 210 144 211 $content = \Elementor\Plugin::instance() 212 ->frontend 213 ->get_builder_content_for_display( $post_id ); 145 // ১. Contenct Genarate 146 $content = Plugin::instance()->frontend->get_builder_content_for_display( $post_id ); 214 147 215 return '<div class="swiper rainbow-slider" id="rainbow-slider-' . esc_attr( $post_id ) . '">' . 216 $content . 217 '</div>'; 148 // ২. Css Load on Editor Mode- when select drowpdown item it css same ot css from template 149 if ( Plugin::instance()->editor->is_edit_mode() ) { 150 $css_file = new Post_CSS( $post_id ); 151 $css_data = $css_file->get_content(); 152 153 if ( ! empty( $css_data ) ) { 154 // Printing universal style tags so browsers don't miss them 155 echo '<style id="rainbow-slider-css-' . $post_id . '">' . $css_data . '</style>'; 156 } else { 157 // If the CSS file is missing, try regenerating it once. 158 $css_file->enqueue(); 159 } 160 } 161 162 $unique_id = 'rainbow-slider-' . $post_id . '-' . rand(1000,9999); 163 164 $html = '<div class="swiper rainbow-slider" id="' . esc_attr( $unique_id ) . '">' . $content . '</div>'; 165 166 // ৩. Re-initialize JS when dropdown changes in editor 167 if ( Plugin::instance()->editor->is_edit_mode() ) { 168 $html .= "<script> 169 jQuery(document).ready(function($){ 170 var scope = $('#" . esc_attr( $unique_id ) . "').closest('.elementor-widget'); 171 if(window.initRainbowSlider) { 172 window.initRainbowSlider(scope); 173 } 174 }); 175 </script>"; 176 } 177 178 return $html; 218 179 } 219 add_shortcode( 'rainbow_slider', 'rainbow_slider_shortcode' );220 180 221 181 /*------------------------------------------------- 222 6. ELEMENTOR WIDGET INTEGRATION182 5. Widget Registration 223 183 --------------------------------------------------*/ 224 225 // 6.1 Register Category "Rainbow Addons"226 184 add_action( 'elementor/elements/categories_registered', function( $elements_manager ) { 227 $elements_manager->add_category( 228 'rainbow_addons', 229 [ 230 'title' => esc_html__( 'Rainbow Addons', 'rainbow-slider' ), 231 'icon' => 'fa fa-plug', 232 ] 233 ); 185 $elements_manager->add_category( 'rainbow_addons', [ 'title' => 'Rainbow Addons', 'icon' => 'fa fa-plug' ] ); 234 186 } ); 235 187 236 // 6.2 Load and Register Widget from External File237 188 add_action( 'elementor/widgets/register', function( $widgets_manager ) { 238 239 // Check for Widget Base Class 240 if ( ! class_exists( '\Elementor\Widget_Base' ) ) { 241 return; 242 } 243 244 // Include the separate widget file 245 // Make sure the folder name is 'widgets' and file is 'rainbow-slider-widget.php' 189 if ( ! class_exists( '\Elementor\Widget_Base' ) ) return; 246 190 require_once( __DIR__ . '/widgets/rainbow-slider-widget.php' ); 247 248 // Register the class (defined in the included file)249 191 $widgets_manager->register( new \Widget_Rainbow_Slider() ); 250 251 192 } ); -
rainbow-slider/trunk/readme.txt
r3422497 r3423134 4 4 Requires at least: 5.8 5 5 Tested up to: 6.9 6 Stable tag: 1.0. 26 Stable tag: 1.0.3 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later … … 13 13 == Description == 14 14 15 ⭐Rainbow Slider is a Good Slider for Your Wordpress Website use Any Theme : 16 Rainbow Slider is a lightweight and reliable slider plugin that works smoothly with Elementor on any WordPress theme. It allows you to create beautiful, responsive sliders using Elementor sections and containers without affecting your existing design. The plugin supports modern layouts including flexbox and grid, while offering features like autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls to ensure a fast and engaging slider experience on all devices. 15 ⭐<em>Rainbow Slider is a Good Slider for Your Wordpress Website use Any Theme :</em> 16 Rainbow Slider is a lightweight and reliable slider plugin that works smoothly with Elementor on any WordPress theme. <b>It doesn't matter if your website has a theme or not, it will work as long as it is beautiful. 17 If your website doesn't have elements. Then it will work very well. That is, it will work on any theme.</b> It allows you to create beautiful, responsive sliders using Elementor sections and containers without affecting your existing design. The plugin supports modern layouts including flexbox and grid, while offering features like autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls to ensure a fast and engaging slider experience on all devices. 17 18 18 19 19 👉 Rainbow Slider is Carousel :20 👉<em>Rainbow Slider is Carousel :</em> 20 21 Rainbow Slider is a lightweight carousel slider plugin built for Elementor. It lets you transform Elementor sections and containers into smooth, responsive carousel sliders without altering your original designs. The plugin supports Elementor sections, flexbox containers, and grid layouts while preserving full design integrity. With features like autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider delivers a fast, modern, and reliable carousel experience for Elementor-powered websites. 21 22 22 23 23 👉 Rainbow Slider is Elementor Slider :24 👉<em>Rainbow Slider is Elementor Slider :</em> 24 25 Rainbow Slider is a lightweight and flexible slider plugin designed exclusively for Elementor. It allows you to convert Elementor sections and containers into smooth, responsive sliders without modifying your original designs. The plugin fully supports Elementor sections, flexbox containers, and grid layouts while preserving complete design integrity. With features such as autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider delivers a fast, modern, and reliable slider experience for Elementor-powered websites. 25 26 26 27 27 👉 Rainbow Slider is Swiper Slider :28 👉<em>Rainbow Slider is Swiper Slider :</em> 28 29 Rainbow Slider is a lightweight Swiper-based slider plugin built for Elementor. It allows you to transform Elementor sections and containers into smooth, responsive Swiper sliders without changing your original designs. The plugin supports Elementor sections, flexbox containers, and grid layouts while keeping full design integrity. With features like autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider delivers a fast, modern, and reliable Swiper slider experience for Elementor-powered websites. 29 30 30 31 31 👉 Rainbow Slider is Image Slider :32 👉<em>Rainbow Slider is Image Slider :</em> 32 33 Rainbow Slider is a lightweight image slider plugin designed for Elementor. It allows you to create smooth, responsive image sliders using Elementor sections and containers without changing your original designs. The plugin supports modern layouts including flexbox and grid while maintaining full design integrity. With features such as autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider delivers a fast, modern, and reliable image slider experience for any Elementor-powered website. 33 34 34 35 35 👉 Rainbow Slider is Image Carousel :36 👉<em>Rainbow Slider is Image Carousel :</em> 36 37 Rainbow Slider is a lightweight image carousel plugin built for Elementor. It lets you turn Elementor sections and containers into smooth, responsive image carousels without changing your original designs. The plugin supports Elementor sections, flexbox containers, and grid layouts while preserving full design integrity. With features like autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider delivers a fast, modern, and reliable image carousel experience for Elementor-powered websites. 37 38 38 39 39 👉 Rainbow Slider is Gallery Carousel :40 👉<em>Rainbow Slider is Gallery Carousel :</em> 40 41 Rainbow Slider is a lightweight gallery carousel plugin designed for Elementor. It allows you to transform Elementor sections and containers into smooth, responsive gallery carousels without affecting your original designs. The plugin supports Elementor sections, flexbox containers, and grid layouts while maintaining full design integrity. With features such as autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider provides a fast, modern, and reliable gallery carousel experience for Elementor-powered websites. 41 42 42 43 43 👉 Rainbow Slider is Gallery Slider :44 👉<em>Rainbow Slider is Gallery Slider :</em> 44 45 Rainbow Slider is a lightweight gallery slider plugin built for Elementor. It enables you to convert Elementor sections and containers into smooth, responsive gallery sliders without changing your original designs. The plugin supports Elementor sections, flexbox containers, and grid layouts while preserving full design integrity. With features like autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider delivers a fast, modern, and reliable gallery slider experience for Elementor-powered websites. 45 46 46 👉 Rainbow Slider is Video Slider :47 👉<em>Rainbow Slider is Video Slider :</em> 47 48 Rainbow Slider is a lightweight and flexible video slider plugin built for Elementor. It allows you to create smooth, responsive video sliders using Elementor sections and containers without affecting your original designs. The plugin supports YouTube, Vimeo, and external video sources, as well as self-hosted videos, while maintaining full design integrity. With features like autoplay, infinite loop, navigation arrows, pagination, and touch-friendly controls, Rainbow Slider delivers a fast, modern, and reliable video slider experience for Elementor-powered websites. 48 49 -
rainbow-slider/trunk/widgets/rainbow-slider-widget.php
r3422472 r3423134 17 17 18 18 public function get_categories() { 19 // Must match the category registered in the main file20 19 return [ 'rainbow_addons' ]; 21 20 } … … 23 22 protected function register_controls() { 24 23 25 // Get all posts from 'rainbow_slider' CPT26 24 $args = [ 27 25 'post_type' => 'rainbow_slider', … … 66 64 67 65 if ( ! empty( $slider_id ) && $slider_id != '0' ) { 68 // Echo the shortcode based on the selected ID 69 echo do_shortcode( '[rainbow_slider id="' . esc_attr( $slider_id ) . '"]' ); 66 67 // Check if the helper function exists before calling it 68 if ( function_exists( 'get_rainbow_slider_view' ) ) { 69 echo get_rainbow_slider_view( $slider_id ); 70 } 71 70 72 } else { 71 73 if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
Note: See TracChangeset
for help on using the changeset viewer.