| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace UiCoreElements; |
| 3 | 4 | |
| 4 | 5 | use Elementor\Controls_Manager; |
| 5 | 6 | use Elementor\Group_Control_Background; |
| @@ -53,9 +54,9 @@ | ||
| 53 | 54 | 'carousel', |
| 54 | 55 | 'animation', // hover animations |
| 55 | 56 | 'entrance', // entrance basic style |
| 56 | 57 | ]; |
| 57 | - if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){ | |
| 58 | + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) { | |
| 58 | 59 | $styles['e-animations'] = [ // entrance animations |
| 59 | 60 | 'external' => true, |
| 60 | 61 | ]; |
| 61 | 62 | } |
| @@ -64,12 +65,13 @@ | ||
| 64 | 65 | public function get_scripts() |
| 65 | 66 | { |
| 66 | 67 | return $this->TRAIT_get_carousel_scripts(); |
| 67 | 68 | } |
| 68 | - // TODO: remove or set as false, after 3.30, when the full deprecation of widget innet wrapper is ready | |
| 69 | - public function has_widget_inner_wrapper(): bool { | |
| 70 | - return true; | |
| 71 | - } | |
| 69 | + public function has_widget_inner_wrapper(): bool | |
| 70 | + { | |
| 71 | + // TODO: remove after Optmized Markup experiment is merged to the core | |
| 72 | + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup'); | |
| 73 | + } | |
| 72 | 74 | protected function register_controls() |
| 73 | 75 | { |
| 74 | 76 | $this->TRAIT_register_gallery_repeater_controls('Content'); |
| 75 | 77 | $this->TRAIT_register_additional_controls(true); |
| @@ -80,16 +82,16 @@ | ||
| 80 | 82 | 'label' => esc_html__('Carousel Settings', 'uicore-elements'), |
| 81 | 83 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 82 | 84 | ] |
| 83 | 85 | ); |
| 84 | - $this->TRAIT_register_carousel_additional_controls(); | |
| 85 | - $this->add_control( | |
| 86 | - 'divider', | |
| 87 | - [ | |
| 88 | - 'type' => Controls_Manager::DIVIDER, | |
| 89 | - ] | |
| 90 | - ); | |
| 91 | - $this->TRAIT_register_carousel_settings_controls(); | |
| 86 | + $this->TRAIT_register_carousel_additional_controls(); | |
| 87 | + $this->add_control( | |
| 88 | + 'divider', | |
| 89 | + [ | |
| 90 | + 'type' => Controls_Manager::DIVIDER, | |
| 91 | + ] | |
| 92 | + ); | |
| 93 | + $this->TRAIT_register_carousel_settings_controls(); | |
| 92 | 94 | |
| 93 | 95 | $this->end_controls_section(); |
| 94 | 96 | |
| 95 | 97 | $this->TRAIT_register_navigation_controls(); |
| @@ -101,9 +103,9 @@ | ||
| 101 | 103 | 'tab' => Controls_Manager::TAB_STYLE, |
| 102 | 104 | ] |
| 103 | 105 | ); |
| 104 | 106 | |
| 105 | - $this->TRAIT_register_all_item_style_controls(); | |
| 107 | + $this->TRAIT_register_all_item_style_controls(); | |
| 106 | 108 | |
| 107 | 109 | $this->end_controls_section(); |
| 108 | 110 | |
| 109 | 111 | $this->TRAIT_register_filters_style_controls(); |
| @@ -121,9 +123,9 @@ | ||
| 121 | 123 | [ |
| 122 | 124 | 'default' => 'none' |
| 123 | 125 | ] |
| 124 | 126 | ); |
| 125 | - $this->update_control( | |
| 127 | + $this->update_responsive_control( | |
| 126 | 128 | 'item_padding', |
| 127 | 129 | [ |
| 128 | 130 | 'default' => [ |
| 129 | 131 | 'top' => 10, |
| @@ -131,10 +133,10 @@ | ||
| 131 | 133 | 'bottom' => 10, |
| 132 | 134 | 'left' => 10, |
| 133 | 135 | ], |
| 134 | 136 | 'selectors' => [ |
| 135 | - '{{WRAPPER}} .ui-e-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 136 | - ], | |
| 137 | + '{{WRAPPER}} .ui-e-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 138 | + ], | |
| 137 | 139 | ] |
| 138 | 140 | ); |
| 139 | 141 | $this->update_control( |
| 140 | 142 | 'item_border_radius', |
| @@ -148,13 +150,69 @@ | ||
| 148 | 150 | ] |
| 149 | 151 | ] |
| 150 | 152 | ); |
| 151 | 153 | $this->update_control( |
| 152 | - 'match_height', [ | |
| 154 | + 'match_height', | |
| 155 | + [ | |
| 153 | 156 | 'render_type' => 'template', |
| 154 | 157 | ] |
| 155 | 158 | ); |
| 156 | 159 | |
| 160 | + $image_conditions = [ | |
| 161 | + 'relation' => 'or', | |
| 162 | + 'terms' => [ | |
| 163 | + [ | |
| 164 | + 'relation' => 'and', | |
| 165 | + 'terms' => [ | |
| 166 | + [ | |
| 167 | + 'name' => 'layout', | |
| 168 | + 'operator' => '==', | |
| 169 | + 'value' => '', | |
| 170 | + ], | |
| 171 | + [ | |
| 172 | + 'name' => 'vertical', | |
| 173 | + 'operator' => '!=', | |
| 174 | + 'value' => 'true', | |
| 175 | + ], | |
| 176 | + ] | |
| 177 | + ], | |
| 178 | + [ | |
| 179 | + 'relation' => 'and', | |
| 180 | + 'terms' => [ | |
| 181 | + [ | |
| 182 | + 'name' => 'layout', | |
| 183 | + 'operator' => '==', | |
| 184 | + 'value' => 'ui-e-overlay', | |
| 185 | + ], | |
| 186 | + [ | |
| 187 | + 'name' => 'match_height', | |
| 188 | + 'operator' => '==', | |
| 189 | + 'value' => 'yes', | |
| 190 | + ], | |
| 191 | + [ | |
| 192 | + 'name' => 'vertical', | |
| 193 | + 'operator' => '!=', | |
| 194 | + 'value' => 'true', | |
| 195 | + ], | |
| 196 | + ], | |
| 197 | + ] | |
| 198 | + ], | |
| 199 | + ]; | |
| 200 | + | |
| 201 | + $this->update_control( | |
| 202 | + 'style_image_section', | |
| 203 | + [ | |
| 204 | + 'conditions' => $image_conditions | |
| 205 | + ] | |
| 206 | + ); | |
| 207 | + $this->update_responsive_control( | |
| 208 | + 'image_height', | |
| 209 | + [ | |
| 210 | + 'conditions' => $image_conditions | |
| 211 | + ] | |
| 212 | + ); | |
| 213 | + | |
| 214 | + | |
| 157 | 215 | // Remove some useless component controls or group controls that can't be properly updated |
| 158 | 216 | $this->remove_control('item_background_background'); |
| 159 | 217 | $this->remove_control('item_hover_background_background'); |
| 160 | 218 | $this->remove_control('item_background_color'); |
| @@ -166,26 +224,29 @@ | ||
| 166 | 224 | 'of' => 'animation_style', |
| 167 | 225 | 'at' => 'after', |
| 168 | 226 | ]); |
| 169 | 227 | |
| 170 | - $this->add_control( | |
| 171 | - 'main_image', | |
| 172 | - [ | |
| 173 | - 'label' => __('Main image', 'uicore-elements'), | |
| 174 | - 'type' => Controls_Manager::SELECT, | |
| 175 | - 'default' => '', | |
| 176 | - 'options' => [ | |
| 177 | - '' => esc_html__('Default', 'uicore-elements'), | |
| 178 | - 'ui-e-main-image-scale' => esc_html__('Scale', 'uicore-elements'), | |
| 179 | - 'ui-e-main-image-show' => esc_html__('Show Info', 'uicore-elements'), | |
| 180 | - 'ui-e-main-image-show_scale' => esc_html__('Show Info & Scale', 'uicore-elements'), | |
| 181 | - ], | |
| 182 | - 'description' => __('Works best with centered slides.', 'uicore-elements'), | |
| 183 | - 'prefix_class' => '', | |
| 184 | - 'render_type' => 'template', | |
| 185 | - 'frontend_available' => true, | |
| 228 | + $this->add_control( | |
| 229 | + 'main_image', | |
| 230 | + [ | |
| 231 | + 'label' => __('Main image', 'uicore-elements'), | |
| 232 | + 'type' => Controls_Manager::SELECT, | |
| 233 | + 'default' => '', | |
| 234 | + 'options' => [ | |
| 235 | + '' => esc_html__('Default', 'uicore-elements'), | |
| 236 | + 'ui-e-main-image-scale' => esc_html__('Scale', 'uicore-elements'), | |
| 237 | + 'ui-e-main-image-show' => esc_html__('Show Info', 'uicore-elements'), | |
| 238 | + 'ui-e-main-image-show_scale' => esc_html__('Show Info & Scale', 'uicore-elements'), | |
| 239 | + ], | |
| 240 | + 'description' => __('Works best with centered slides.', 'uicore-elements'), | |
| 241 | + 'prefix_class' => '', | |
| 242 | + 'render_type' => 'template', | |
| 243 | + 'frontend_available' => true, | |
| 244 | + 'condition' => [ | |
| 245 | + 'animation_style!' => 'marquee', | |
| 186 | 246 | ] |
| 187 | - ); | |
| 247 | + ] | |
| 248 | + ); | |
| 188 | 249 | |
| 189 | 250 | $this->end_injection(); |
| 190 | 251 | |
| 191 | 252 | $this->start_injection([ |
| @@ -192,29 +253,29 @@ | ||
| 192 | 253 | 'of' => 'item_border_border', |
| 193 | 254 | 'at' => 'before', |
| 194 | 255 | ]); |
| 195 | 256 | |
| 196 | - // normal background controls | |
| 197 | - $this->add_group_control( | |
| 198 | - Group_Control_Background::get_type(), | |
| 199 | - [ | |
| 200 | - 'name' => 'item_gallery_background', | |
| 201 | - 'selector' => '{{WRAPPER}} .ui-e-item', | |
| 202 | - 'condition' => [ | |
| 203 | - 'layout' => '', | |
| 204 | - ] | |
| 257 | + // normal background controls | |
| 258 | + $this->add_group_control( | |
| 259 | + Group_Control_Background::get_type(), | |
| 260 | + [ | |
| 261 | + 'name' => 'item_gallery_background', | |
| 262 | + 'selector' => '{{WRAPPER}} .ui-e-item', | |
| 263 | + 'condition' => [ | |
| 264 | + 'layout' => '', | |
| 205 | 265 | ] |
| 206 | - ); | |
| 207 | - $this->add_group_control( | |
| 208 | - Group_Control_Background::get_type(), | |
| 209 | - [ | |
| 210 | - 'name' => 'item_content_background', | |
| 211 | - 'selector' => '{{WRAPPER}} .ui-e-content', | |
| 212 | - 'condition' => [ | |
| 213 | - 'layout' => 'ui-e-overlay', | |
| 214 | - ] | |
| 266 | + ] | |
| 267 | + ); | |
| 268 | + $this->add_group_control( | |
| 269 | + Group_Control_Background::get_type(), | |
| 270 | + [ | |
| 271 | + 'name' => 'item_content_background', | |
| 272 | + 'selector' => '{{WRAPPER}} .ui-e-content', | |
| 273 | + 'condition' => [ | |
| 274 | + 'layout' => 'ui-e-overlay', | |
| 215 | 275 | ] |
| 216 | - ); | |
| 276 | + ] | |
| 277 | + ); | |
| 217 | 278 | |
| 218 | 279 | $this->end_injection(); |
| 219 | 280 | |
| 220 | 281 | $this->start_injection([ |
| @@ -221,29 +282,29 @@ | ||
| 221 | 282 | 'of' => 'item_hover_border_color', |
| 222 | 283 | 'at' => 'before', |
| 223 | 284 | ]); |
| 224 | 285 | |
| 225 | - // hover background controls | |
| 226 | - $this->add_group_control( | |
| 227 | - Group_Control_Background::get_type(), | |
| 228 | - [ | |
| 229 | - 'name' => 'item_gallery_hover_background', | |
| 230 | - 'selector' => '{{WRAPPER}} .ui-e-item:hover', | |
| 231 | - 'condition' => [ | |
| 232 | - 'layout' => '', | |
| 233 | - ] | |
| 286 | + // hover background controls | |
| 287 | + $this->add_group_control( | |
| 288 | + Group_Control_Background::get_type(), | |
| 289 | + [ | |
| 290 | + 'name' => 'item_gallery_hover_background', | |
| 291 | + 'selector' => '{{WRAPPER}} .ui-e-item:hover', | |
| 292 | + 'condition' => [ | |
| 293 | + 'layout' => '', | |
| 234 | 294 | ] |
| 235 | - ); | |
| 236 | - $this->add_group_control( | |
| 237 | - Group_Control_Background::get_type(), | |
| 238 | - [ | |
| 239 | - 'name' => 'item_content_hover_background', | |
| 240 | - 'selector' => '{{WRAPPER}} .ui-e-item:hover .ui-e-content', | |
| 241 | - 'condition' => [ | |
| 242 | - 'layout' => 'ui-e-overlay', | |
| 243 | - ] | |
| 295 | + ] | |
| 296 | + ); | |
| 297 | + $this->add_group_control( | |
| 298 | + Group_Control_Background::get_type(), | |
| 299 | + [ | |
| 300 | + 'name' => 'item_content_hover_background', | |
| 301 | + 'selector' => '{{WRAPPER}} .ui-e-item:hover .ui-e-content', | |
| 302 | + 'condition' => [ | |
| 303 | + 'layout' => 'ui-e-overlay', | |
| 244 | 304 | ] |
| 245 | - ); | |
| 305 | + ] | |
| 306 | + ); | |
| 246 | 307 | |
| 247 | 308 | $this->end_injection(); |
| 248 | 309 | } |
| 249 | 310 | |
| @@ -249,16 +310,17 @@ | ||
| 249 | 310 | |
| 250 | 311 | public function render() |
| 251 | 312 | { |
| 252 | 313 | $settings = $this->get_settings_for_display(); |
| 253 | - ?> | |
| 254 | - <div class="ui-e-carousel swiper"> | |
| 255 | - <div class='swiper-wrapper'> | |
| 256 | - <?php $this->TRAIT_render_gallery($settings, true); ?> | |
| 257 | - </div> | |
| 314 | + $total_slides = count($settings['gallery_items']); | |
| 315 | + $this->TRAIT_render_center_loop_warning($total_slides); | |
| 316 | +?> | |
| 317 | + <div class="ui-e-carousel swiper"> | |
| 318 | + <div class='swiper-wrapper'> | |
| 319 | + <?php $this->TRAIT_render_gallery($settings, true); ?> | |
| 258 | 320 | </div> |
| 259 | - <?php $this->TRAIT_render_carousel_navigations(); ?> | |
| 260 | - <?php | |
| 321 | + </div> | |
| 322 | + <?php $this->TRAIT_render_carousel_navigations($total_slides); ?> | |
| 323 | +<?php | |
| 261 | 324 | } |
| 262 | - | |
| 263 | 325 | } |
| 264 | -\Elementor\Plugin::instance()->widgets_manager->register(new GalleryCarousel()); | |
| 326 | +\Elementor\Plugin::instance()->widgets_manager->register(new GalleryCarousel()); | |