theme-elements
6 months ago
accordion.php
6 months ago
audio.php
6 months ago
before-after.php
6 months ago
button.php
6 months ago
carousel-navigation.php
6 months ago
circle-chart.php
6 months ago
contact-box.php
6 months ago
contact-form.php
6 months ago
custom-list.php
6 months ago
divider.php
6 months ago
gallery.php
6 months ago
gmap.php
6 months ago
heading-modern.php
6 months ago
icon.php
6 months ago
image.php
6 months ago
mailchimp.php
6 months ago
modern-button.php
6 months ago
products-grid.php
6 months ago
quote.php
6 months ago
recent-comments.php
6 months ago
recent-posts-grid-carousel.php
6 months ago
recent-posts-land-style.php
6 months ago
recent-posts-masonry.php
6 months ago
recent-posts-tiles-carousel.php
6 months ago
recent-posts-tiles.php
6 months ago
recent-posts-timeline.php
6 months ago
recent-products.php
6 months ago
responsive-table.php
6 months ago
search.php
6 months ago
staff.php
6 months ago
svg.php
6 months ago
tabs.php
6 months ago
testimonial.php
6 months ago
text.php
6 months ago
touch-slider.php
6 months ago
video.php
6 months ago
touch-slider.php
491 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Widget_Base; |
| 6 | use Elementor\Controls_Manager; |
| 7 | use Elementor\Group_Control_Typography; |
| 8 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 9 | |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; // Exit if accessed directly. |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Elementor 'TouchSlider' widget. |
| 17 | * |
| 18 | * Elementor widget that displays an 'TouchSlider' with lightbox. |
| 19 | * |
| 20 | * @since 1.0.0 |
| 21 | */ |
| 22 | class TouchSlider extends Widget_Base { |
| 23 | |
| 24 | /** |
| 25 | * Get widget name. |
| 26 | * |
| 27 | * Retrieve 'TouchSlider' widget name. |
| 28 | * |
| 29 | * @since 1.0.0 |
| 30 | * @access public |
| 31 | * |
| 32 | * @return string Widget name. |
| 33 | */ |
| 34 | public function get_name() { |
| 35 | return 'aux_touch_slider'; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Get widget title. |
| 40 | * |
| 41 | * Retrieve 'TouchSlider' widget title. |
| 42 | * |
| 43 | * @since 1.0.0 |
| 44 | * @access public |
| 45 | * |
| 46 | * @return string Widget title. |
| 47 | */ |
| 48 | public function get_title() { |
| 49 | return __( 'Simple Image Slider', 'auxin-elements' ); |
| 50 | } |
| 51 | |
| 52 | public function has_widget_inner_wrapper(): bool { |
| 53 | return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * Get widget icon. |
| 59 | * |
| 60 | * Retrieve 'TouchSlider' widget icon. |
| 61 | * |
| 62 | * @since 1.0.0 |
| 63 | * @access public |
| 64 | * |
| 65 | * @return string Widget icon. |
| 66 | */ |
| 67 | public function get_icon() { |
| 68 | return 'eicon-slider-device auxin-badge'; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Get widget categories. |
| 73 | * |
| 74 | * Retrieve 'TouchSlider' widget icon. |
| 75 | * |
| 76 | * @since 1.0.0 |
| 77 | * @access public |
| 78 | * |
| 79 | * @return string Widget icon. |
| 80 | */ |
| 81 | public function get_categories() { |
| 82 | return array( 'auxin-core' ); |
| 83 | } |
| 84 | |
| 85 | |
| 86 | /** |
| 87 | * Register 'TouchSlider' widget controls. |
| 88 | * |
| 89 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 90 | * |
| 91 | * @since 1.0.0 |
| 92 | * @access protected |
| 93 | */ |
| 94 | protected function register_controls() { |
| 95 | |
| 96 | /*-----------------------------------------------------------------------------------*/ |
| 97 | /* images_section |
| 98 | /*-----------------------------------------------------------------------------------*/ |
| 99 | |
| 100 | $this->start_controls_section( |
| 101 | 'images_section', |
| 102 | array( |
| 103 | 'label' => __('Images', 'auxin-elements' ) |
| 104 | ) |
| 105 | ); |
| 106 | |
| 107 | $this->add_control( |
| 108 | 'images', |
| 109 | array( |
| 110 | 'label' => __( 'Add Images', 'auxin-elements' ), |
| 111 | 'type' => Controls_Manager::GALLERY, |
| 112 | 'show_label' => false, |
| 113 | ) |
| 114 | ); |
| 115 | |
| 116 | $this->end_controls_section(); |
| 117 | |
| 118 | /*-----------------------------------------------------------------------------------*/ |
| 119 | /* display_section |
| 120 | /*-----------------------------------------------------------------------------------*/ |
| 121 | |
| 122 | $this->start_controls_section( |
| 123 | 'display_section', |
| 124 | array( |
| 125 | 'label' => __('Display', 'auxin-elements' ) |
| 126 | ) |
| 127 | ); |
| 128 | |
| 129 | $this->add_control( |
| 130 | 'arrows', |
| 131 | array( |
| 132 | 'label' => __('Arrow navigation','auxin-elements' ), |
| 133 | 'type' => Controls_Manager::SWITCHER, |
| 134 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 135 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 136 | 'return_value' => 'yes', |
| 137 | 'default' => 'yes' |
| 138 | ) |
| 139 | ); |
| 140 | |
| 141 | |
| 142 | $this->add_control( |
| 143 | 'loop', |
| 144 | array( |
| 145 | 'label' => __('Loop navigation','auxin-elements' ), |
| 146 | 'type' => Controls_Manager::SWITCHER, |
| 147 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 148 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 149 | 'return_value' => 'yes', |
| 150 | 'default' => 'yes' |
| 151 | ) |
| 152 | ); |
| 153 | |
| 154 | $this->add_control( |
| 155 | 'slideshow', |
| 156 | array( |
| 157 | 'label' => __('Slideshow','auxin-elements' ), |
| 158 | 'type' => Controls_Manager::SWITCHER, |
| 159 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 160 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 161 | 'return_value' => 'yes', |
| 162 | 'default' => 'no' |
| 163 | ) |
| 164 | ); |
| 165 | |
| 166 | $this->add_control( |
| 167 | 'slideshow_delay', |
| 168 | array( |
| 169 | 'label' => __( 'Autoplay delay', 'auxin-elements' ), |
| 170 | 'description' => __('Specifies the delay between auto-forwarding in seconds.', 'auxin-elements' ), |
| 171 | 'type' => Controls_Manager::NUMBER, |
| 172 | 'default' => '2', |
| 173 | 'condition' => array( |
| 174 | 'slideshow' => 'yes', |
| 175 | ) |
| 176 | ) |
| 177 | ); |
| 178 | |
| 179 | $this->add_control( |
| 180 | 'add_title', |
| 181 | array( |
| 182 | 'label' => __('Display image title','auxin-elements' ), |
| 183 | 'type' => Controls_Manager::SWITCHER, |
| 184 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 185 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 186 | 'return_value' => 'yes', |
| 187 | 'default' => 'yes' |
| 188 | ) |
| 189 | ); |
| 190 | |
| 191 | $this->add_control( |
| 192 | 'add_caption', |
| 193 | array( |
| 194 | 'label' => __('Display image caption','auxin-elements' ), |
| 195 | 'type' => Controls_Manager::SWITCHER, |
| 196 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 197 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 198 | 'return_value' => 'yes', |
| 199 | 'default' => 'yes' |
| 200 | ) |
| 201 | ); |
| 202 | |
| 203 | $this->end_controls_section(); |
| 204 | |
| 205 | /*-----------------------------------------------------------------------------------*/ |
| 206 | /* slides_section |
| 207 | /*-----------------------------------------------------------------------------------*/ |
| 208 | |
| 209 | $this->start_controls_section( |
| 210 | 'slides_section', |
| 211 | array( |
| 212 | 'label' => __('Slides', 'auxin-elements' ), |
| 213 | 'tab' => Controls_Manager::TAB_STYLE |
| 214 | ) |
| 215 | ); |
| 216 | |
| 217 | $this->add_control( |
| 218 | 'width', |
| 219 | array( |
| 220 | 'label' => __('Slider image width','auxin-elements' ), |
| 221 | 'type' => Controls_Manager::SLIDER, |
| 222 | 'size_units' => array('px'), |
| 223 | 'range' => array( |
| 224 | 'px' => array( |
| 225 | 'min' => 1, |
| 226 | 'max' => 2000, |
| 227 | 'step' => 1 |
| 228 | ) |
| 229 | ), |
| 230 | 'default' => array( |
| 231 | 'unit' => 'px', |
| 232 | 'size' => 960 |
| 233 | ) |
| 234 | ) |
| 235 | ); |
| 236 | |
| 237 | $this->add_control( |
| 238 | 'height', |
| 239 | array( |
| 240 | 'label' => __('Slider image height','auxin-elements' ), |
| 241 | 'type' => Controls_Manager::SLIDER, |
| 242 | 'size_units' => array('px'), |
| 243 | 'range' => array( |
| 244 | 'px' => array( |
| 245 | 'min' => 1, |
| 246 | 'max' => 2000, |
| 247 | 'step' => 1 |
| 248 | ) |
| 249 | ), |
| 250 | 'default' => array( |
| 251 | 'unit' => 'px', |
| 252 | 'size' => 560 |
| 253 | ) |
| 254 | ) |
| 255 | ); |
| 256 | |
| 257 | $this->add_control( |
| 258 | 'space', |
| 259 | array( |
| 260 | 'label' => __('Space between slides','auxin-elements' ), |
| 261 | 'type' => Controls_Manager::SLIDER, |
| 262 | 'size_units' => array('px'), |
| 263 | 'range' => array( |
| 264 | 'px' => array( |
| 265 | 'min' => 1, |
| 266 | 'max' => 200, |
| 267 | 'step' => 1 |
| 268 | ) |
| 269 | ), |
| 270 | 'default' => array( |
| 271 | 'unit' => 'px', |
| 272 | 'size' => 0 |
| 273 | ) |
| 274 | ) |
| 275 | ); |
| 276 | |
| 277 | $this->end_controls_section(); |
| 278 | |
| 279 | /*-----------------------------------------------------------------------------------*/ |
| 280 | /* info_section |
| 281 | /*-----------------------------------------------------------------------------------*/ |
| 282 | |
| 283 | $this->start_controls_section( |
| 284 | 'info_section', |
| 285 | array( |
| 286 | 'label' => __('Info Container', 'auxin-elements' ), |
| 287 | 'tab' => Controls_Manager::TAB_STYLE, |
| 288 | 'conditions' => array( |
| 289 | 'relation' => 'or', |
| 290 | 'terms' => array( |
| 291 | array( |
| 292 | 'name' => 'add_title', |
| 293 | 'operator' => '===', |
| 294 | 'value' => 'yes', |
| 295 | ), array( |
| 296 | 'name' => 'add_caption', |
| 297 | 'operator' => '===', |
| 298 | 'value' => 'yes', |
| 299 | ), |
| 300 | ), |
| 301 | ), |
| 302 | ) |
| 303 | ); |
| 304 | |
| 305 | $this->add_control( |
| 306 | 'info_color', |
| 307 | array( |
| 308 | 'label' => __( 'Background Color', 'auxin-elements' ), |
| 309 | 'type' => Controls_Manager::COLOR, |
| 310 | 'selectors' => array( |
| 311 | '{{WRAPPER}} .aux-info-container' => 'background: {{VALUE}};', |
| 312 | ) |
| 313 | ) |
| 314 | ); |
| 315 | |
| 316 | $this->add_responsive_control( |
| 317 | 'info_padding', |
| 318 | array( |
| 319 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 320 | 'type' => Controls_Manager::DIMENSIONS, |
| 321 | 'size_units' => array( 'px', '%' ), |
| 322 | 'selectors' => array( |
| 323 | '{{WRAPPER}} .aux-info-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 324 | ) |
| 325 | ) |
| 326 | ); |
| 327 | |
| 328 | $this->end_controls_section(); |
| 329 | |
| 330 | /*-----------------------------------------------------------------------------------*/ |
| 331 | /* title_section |
| 332 | /*-----------------------------------------------------------------------------------*/ |
| 333 | |
| 334 | $this->start_controls_section( |
| 335 | 'title_section', |
| 336 | array( |
| 337 | 'label' => __('Title', 'auxin-elements' ), |
| 338 | 'tab' => Controls_Manager::TAB_STYLE, |
| 339 | 'condition' => array( |
| 340 | 'add_title' => 'yes', |
| 341 | ) |
| 342 | ) |
| 343 | ); |
| 344 | |
| 345 | $this->add_control( |
| 346 | 'title_color', |
| 347 | array( |
| 348 | 'label' => __( 'Color', 'auxin-elements' ), |
| 349 | 'type' => Controls_Manager::COLOR, |
| 350 | 'selectors' => array( |
| 351 | '{{WRAPPER}} .aux-slide-title h3' => 'color: {{VALUE}};', |
| 352 | ), |
| 353 | 'condition' => array( |
| 354 | 'add_title' => 'yes', |
| 355 | ) |
| 356 | ) |
| 357 | ); |
| 358 | |
| 359 | $this->add_group_control( |
| 360 | Group_Control_Typography::get_type(), |
| 361 | array( |
| 362 | 'name' => 'title_typography', |
| 363 | 'global' => [ |
| 364 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 365 | ], |
| 366 | 'selector' => '{{WRAPPER}} .aux-slide-title h3', |
| 367 | 'condition' => array( |
| 368 | 'add_title' => 'yes', |
| 369 | ) |
| 370 | ) |
| 371 | ); |
| 372 | |
| 373 | $this->add_responsive_control( |
| 374 | 'title_padding', |
| 375 | array( |
| 376 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 377 | 'type' => Controls_Manager::DIMENSIONS, |
| 378 | 'size_units' => array( 'px', '%' ), |
| 379 | 'selectors' => array( |
| 380 | '{{WRAPPER}} .aux-slide-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 381 | ), |
| 382 | 'condition' => array( |
| 383 | 'add_title' => 'yes', |
| 384 | ) |
| 385 | ) |
| 386 | ); |
| 387 | |
| 388 | $this->end_controls_section(); |
| 389 | |
| 390 | /*-----------------------------------------------------------------------------------*/ |
| 391 | /* caption_section |
| 392 | /*-----------------------------------------------------------------------------------*/ |
| 393 | |
| 394 | $this->start_controls_section( |
| 395 | 'caption_section', |
| 396 | array( |
| 397 | 'label' => __('Caption', 'auxin-elements' ), |
| 398 | 'tab' => Controls_Manager::TAB_STYLE, |
| 399 | 'condition' => array( |
| 400 | 'add_caption' => 'yes', |
| 401 | ) |
| 402 | ) |
| 403 | ); |
| 404 | |
| 405 | $this->add_control( |
| 406 | 'caption_color', |
| 407 | array( |
| 408 | 'label' => __( 'Color', 'auxin-elements' ), |
| 409 | 'type' => Controls_Manager::COLOR, |
| 410 | 'selectors' => array( |
| 411 | '{{WRAPPER}} .aux-slide-info' => 'color: {{VALUE}};', |
| 412 | ), |
| 413 | 'condition' => array( |
| 414 | 'add_caption' => 'yes', |
| 415 | ) |
| 416 | ) |
| 417 | ); |
| 418 | |
| 419 | $this->add_group_control( |
| 420 | Group_Control_Typography::get_type(), |
| 421 | array( |
| 422 | 'name' => 'caption_typography', |
| 423 | 'global' => [ |
| 424 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 425 | ], |
| 426 | 'selector' => '{{WRAPPER}} .aux-slide-info', |
| 427 | 'condition' => array( |
| 428 | 'add_caption' => 'yes', |
| 429 | ) |
| 430 | ) |
| 431 | ); |
| 432 | |
| 433 | $this->add_responsive_control( |
| 434 | 'caption_padding', |
| 435 | array( |
| 436 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 437 | 'type' => Controls_Manager::DIMENSIONS, |
| 438 | 'size_units' => array( 'px', '%' ), |
| 439 | 'selectors' => array( |
| 440 | '{{WRAPPER}} .aux-slide-info' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 441 | ), |
| 442 | 'condition' => array( |
| 443 | 'add_caption' => 'yes', |
| 444 | ) |
| 445 | ) |
| 446 | ); |
| 447 | |
| 448 | $this->end_controls_section(); |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Render image box widget output on the frontend. |
| 453 | * |
| 454 | * Written in PHP and used to generate the final HTML. |
| 455 | * |
| 456 | * @since 1.0.0 |
| 457 | * @access protected |
| 458 | */ |
| 459 | protected function render() { |
| 460 | |
| 461 | $settings = $this->get_settings_for_display(); |
| 462 | |
| 463 | if ( ! $settings['images'] ) { |
| 464 | return; |
| 465 | } |
| 466 | |
| 467 | $ids = wp_list_pluck( $settings['images'], 'id' ); |
| 468 | $args = array( |
| 469 | // images_section |
| 470 | 'images' => $ids, |
| 471 | |
| 472 | // display_section |
| 473 | 'arrows' => $settings['arrows'], |
| 474 | 'loop' => $settings['loop'], |
| 475 | 'slideshow' => $settings['slideshow'], |
| 476 | 'slideshow_delay' => $settings['slideshow_delay'], |
| 477 | 'add_title' => $settings['add_title'], |
| 478 | 'add_caption' => $settings['add_caption'], |
| 479 | |
| 480 | // slides_section |
| 481 | 'width' => $settings['width']['size'], |
| 482 | 'height' => $settings['height']['size'], |
| 483 | 'space' => $settings['space']['size'], |
| 484 | ); |
| 485 | |
| 486 | // get the shortcode base blog page |
| 487 | echo auxin_touch_slider_callback( $args ); |
| 488 | } |
| 489 | |
| 490 | } |
| 491 |