Changeset 3423195
- Timestamp:
- 12/18/2025 07:10:59 PM (4 months ago)
- Location:
- rainbow-slider/trunk
- Files:
-
- 2 edited
-
rainbow-slider.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
rainbow-slider/trunk/rainbow-slider.php
r3423134 r3423195 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. 36 * Version: 1.0.4 7 7 * Requires at least: 5.8 8 8 * Requires PHP: 7.2 … … 58 58 }); 59 59 60 /*------------------------------------------------- 61 3. Assets Enqueue 60 61 /*------------------------------------------------- 62 3. TEMPLATE METABOX 63 --------------------------------------------------*/ 64 add_action( 'add_meta_boxes', function () { 65 66 add_meta_box( 67 'rainbow_slider_template', 68 __( 'Template', 'rainbow-slider' ), 69 'rainbow_slider_template_box', 70 'rainbow_slider', 71 'side', 72 'default' 73 ); 74 75 }); 76 77 function rainbow_slider_template_box( $post ) { 78 79 wp_nonce_field( 'rainbow_slider_template', 'rainbow_slider_template_nonce' ); 80 81 $current = get_post_meta( $post->ID, '_wp_page_template', true ); 82 if ( ! $current ) { 83 $current = 'default'; 84 } 85 86 // Theme + Elementor templates (NO duplicate) 87 $templates = wp_get_theme()->get_page_templates(); 88 89 echo '<select name="rainbow_slider_template" style="width:100%">'; 90 echo '<option value="default">Default</option>'; 91 92 foreach ( $templates as $file => $name ) { 93 echo '<option value="' . esc_attr( $file ) . '"' . 94 selected( $current, $file, false ) . '>' . 95 esc_html( $name ) . 96 '</option>'; 97 } 98 99 echo '</select>'; 100 } 101 102 103 104 /*------------------------------------------------- 105 4. SAVE TEMPLATE 106 --------------------------------------------------*/ 107 add_action( 'save_post_rainbow_slider', function ( $post_id ) { 108 109 if ( ! isset( $_POST['rainbow_slider_template_nonce'] ) ) return; 110 if ( ! wp_verify_nonce( $_POST['rainbow_slider_template_nonce'], 'rainbow_slider_template' ) ) return; 111 112 if ( isset( $_POST['rainbow_slider_template'] ) ) { 113 update_post_meta( 114 $post_id, 115 '_wp_page_template', 116 sanitize_text_field( $_POST['rainbow_slider_template'] ) 117 ); 118 } 119 }); 120 121 122 123 /*------------------------------------------------- 124 5. APPLY TEMPLATE ON FRONTEND 125 --------------------------------------------------*/ 126 add_filter( 'template_include', function ( $template ) { 127 128 if ( is_singular( 'rainbow_slider' ) ) { 129 130 $tpl = get_post_meta( get_queried_object_id(), '_wp_page_template', true ); 131 132 if ( $tpl === 'elementor_canvas' ) { 133 return ELEMENTOR_PATH . 'modules/page-templates/templates/canvas.php'; 134 } 135 136 if ( $tpl === 'elementor_header_footer' ) { 137 return ELEMENTOR_PATH . 'modules/page-templates/templates/header-footer.php'; 138 } 139 140 if ( $tpl && $tpl !== 'default' ) { 141 $located = locate_template( $tpl ); 142 if ( $located ) return $located; 143 } 144 } 145 146 return $template; 147 }); 148 149 /*------------------------------------------------- 150 6. Assets Enqueue 62 151 --------------------------------------------------*/ 63 152 function rainbow_slider_assets() { … … 137 226 138 227 /*------------------------------------------------- 139 4. RENDER FUNCTION (The CSS Fix)228 7. RENDER FUNCTION (The CSS Fix) 140 229 --------------------------------------------------*/ 141 230 function get_rainbow_slider_view( $post_id ) { … … 180 269 181 270 /*------------------------------------------------- 182 5. Widget Registration271 8. Widget Registration 183 272 --------------------------------------------------*/ 184 273 add_action( 'elementor/elements/categories_registered', function( $elements_manager ) { -
rainbow-slider/trunk/readme.txt
r3423134 r3423195 4 4 Requires at least: 5.8 5 5 Tested up to: 6.9 6 Stable tag: 1.0. 36 Stable tag: 1.0.4 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later
Note: See TracChangeset
for help on using the changeset viewer.