theme-elements
1 year ago
accordion.php
1 year ago
audio.php
4 years ago
before-after.php
3 years ago
button.php
1 year ago
carousel-navigation.php
4 years ago
circle-chart.php
1 year ago
contact-box.php
4 years ago
contact-form.php
1 year ago
custom-list.php
1 year ago
divider.php
4 years ago
gallery.php
1 year ago
gmap.php
4 years ago
heading-modern.php
1 year ago
icon.php
1 year ago
image.php
1 year ago
mailchimp.php
1 year ago
modern-button.php
1 year ago
products-grid.php
1 year ago
quote.php
1 year ago
recent-comments.php
1 year ago
recent-posts-grid-carousel.php
1 year ago
recent-posts-land-style.php
1 year ago
recent-posts-masonry.php
1 year ago
recent-posts-tiles-carousel.php
1 year ago
recent-posts-tiles.php
1 year ago
recent-posts-timeline.php
1 year ago
recent-products.php
1 year ago
responsive-table.php
1 year ago
search.php
4 years ago
staff.php
1 year ago
svg.php
1 year ago
tabs.php
1 year ago
testimonial.php
1 year ago
text.php
1 year ago
touch-slider.php
1 year ago
video.php
4 years ago
gallery.php
553 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Widget_Base; |
| 5 | use Elementor\Controls_Manager; |
| 6 | use Elementor\Core\Kits\Documents\Tabs\Global_Colors; |
| 7 | use Elementor\Group_Control_Border; |
| 8 | |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; // Exit if accessed directly. |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Elementor 'gallery' widget. |
| 16 | * |
| 17 | * Elementor widget that displays an 'gallery' with lightbox. |
| 18 | * |
| 19 | * @since 1.0.0 |
| 20 | */ |
| 21 | class Gallery extends Widget_Base { |
| 22 | |
| 23 | /** |
| 24 | * Get widget name. |
| 25 | * |
| 26 | * Retrieve 'gallery' widget name. |
| 27 | * |
| 28 | * @since 1.0.0 |
| 29 | * @access public |
| 30 | * |
| 31 | * @return string Widget name. |
| 32 | */ |
| 33 | public function get_name() { |
| 34 | return 'aux-gallery'; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get widget title. |
| 39 | * |
| 40 | * Retrieve 'gallery' widget title. |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | * @access public |
| 44 | * |
| 45 | * @return string Widget title. |
| 46 | */ |
| 47 | public function get_title() { |
| 48 | return __( 'Modern Gallery', 'auxin-elements' ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Get widget icon. |
| 53 | * |
| 54 | * Retrieve 'gallery' widget icon. |
| 55 | * |
| 56 | * @since 1.0.0 |
| 57 | * @access public |
| 58 | * |
| 59 | * @return string Widget icon. |
| 60 | */ |
| 61 | public function get_icon() { |
| 62 | return 'eicon-gallery-grid auxin-badge'; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get widget categories. |
| 67 | * |
| 68 | * Retrieve 'gallery' widget icon. |
| 69 | * |
| 70 | * @since 1.0.0 |
| 71 | * @access public |
| 72 | * |
| 73 | * @return string Widget icon. |
| 74 | */ |
| 75 | public function get_categories() { |
| 76 | return array( 'auxin-core' ); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Register 'gallery' widget controls. |
| 81 | * |
| 82 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 83 | * |
| 84 | * @since 1.0.0 |
| 85 | * @access protected |
| 86 | */ |
| 87 | protected function register_controls() { |
| 88 | |
| 89 | $this->start_controls_section( |
| 90 | 'section_gallery', |
| 91 | array( |
| 92 | 'label' => __( 'Gallery Images', 'auxin-elements' ), |
| 93 | ) |
| 94 | ); |
| 95 | |
| 96 | $this->add_control( |
| 97 | 'wp_gallery', |
| 98 | array( |
| 99 | 'label' => __( 'Add Images', 'auxin-elements' ), |
| 100 | 'type' => Controls_Manager::GALLERY, |
| 101 | 'show_label' => false, |
| 102 | 'dynamic' => array( |
| 103 | 'active' => true, |
| 104 | ) |
| 105 | ) |
| 106 | ); |
| 107 | |
| 108 | $this->add_control( |
| 109 | 'layout', |
| 110 | array( |
| 111 | 'label' => __( 'Gallery layout', 'auxin-elements' ), |
| 112 | 'type' => Controls_Manager::SELECT, |
| 113 | 'default' => 'grid', |
| 114 | 'options' => array( |
| 115 | 'grid' => __( 'Grid', 'auxin-elements' ), |
| 116 | 'masonry' => __( 'Masonry', 'auxin-elements' ), |
| 117 | 'tiles' => __( 'Tiles', 'auxin-elements' ), |
| 118 | ), |
| 119 | ) |
| 120 | ); |
| 121 | |
| 122 | $this->add_control( |
| 123 | 'tile_style_pattern', |
| 124 | array( |
| 125 | 'label' => __( 'Tile styles', 'auxin-elements' ), |
| 126 | 'type' => Controls_Manager::SELECT, |
| 127 | 'default' => 'default', |
| 128 | 'options' => array( |
| 129 | 'default' => __( 'Default', 'auxin-elements' ), |
| 130 | 'pattern-1' => __( 'Pattern 1', 'auxin-elements' ), |
| 131 | 'pattern-2' => __( 'Pattern 2', 'auxin-elements' ), |
| 132 | 'pattern-3' => __( 'Pattern 3', 'auxin-elements' ), |
| 133 | 'pattern-4' => __( 'Pattern 4', 'auxin-elements' ), |
| 134 | 'pattern-5' => __( 'Pattern 5', 'auxin-elements' ), |
| 135 | 'pattern-6' => __( 'Pattern 6', 'auxin-elements' ), |
| 136 | 'pattern-7' => __( 'Pattern 7', 'auxin-elements' ) |
| 137 | ), |
| 138 | 'condition' => array( |
| 139 | 'layout' => 'tiles', |
| 140 | ), |
| 141 | ) |
| 142 | ); |
| 143 | |
| 144 | $gallery_columns = range( 1, 6 ); |
| 145 | $gallery_columns = array_combine( $gallery_columns, $gallery_columns ); |
| 146 | |
| 147 | $this->add_responsive_control( |
| 148 | 'columns', |
| 149 | array( |
| 150 | 'label' => __( 'Columns', 'auxin-elements' ), |
| 151 | 'type' => Controls_Manager::SELECT, |
| 152 | 'default' => '4', |
| 153 | 'tablet_default' => '2', |
| 154 | 'mobile_default' => '1', |
| 155 | 'options' => $gallery_columns, |
| 156 | 'condition' => array( |
| 157 | 'layout' => array('masonry','grid') |
| 158 | ) |
| 159 | ) |
| 160 | ); |
| 161 | |
| 162 | $this->add_control( |
| 163 | 'space', |
| 164 | array( |
| 165 | 'label' => __( 'Image spacing', 'auxin-elements' ), |
| 166 | 'type' => Controls_Manager::SLIDER, |
| 167 | 'default' => array( |
| 168 | 'size' => 10, |
| 169 | ), |
| 170 | 'range' => array( |
| 171 | 'px' => array( |
| 172 | 'min' => 0, |
| 173 | 'max' => 40, |
| 174 | 'step' => 1, |
| 175 | ) |
| 176 | ), |
| 177 | 'condition' => array( |
| 178 | 'layout' => array('masonry','grid', 'tiles') |
| 179 | ) |
| 180 | ) |
| 181 | ); |
| 182 | |
| 183 | $this->add_responsive_control( |
| 184 | 'image_aspect_ratio', |
| 185 | array( |
| 186 | 'label' => __( 'Image aspect ratio', 'auxin-elements' ), |
| 187 | 'type' => Controls_Manager::SLIDER, |
| 188 | 'default' => array( |
| 189 | 'size' => 0.75, |
| 190 | ), |
| 191 | 'range' => array( |
| 192 | 'px' => array( |
| 193 | 'min' => 0.1, |
| 194 | 'max' => 2, |
| 195 | 'step' => 0.01, |
| 196 | ) |
| 197 | ), |
| 198 | 'selectors' => array( |
| 199 | '{{WRAPPER}} .aux-layout-masonry .aux-frame-ratio' => 'padding-bottom:calc( {{SIZE}} * 100% )' |
| 200 | ), |
| 201 | 'condition' => array( |
| 202 | 'layout' => 'grid' |
| 203 | ) |
| 204 | ) |
| 205 | ); |
| 206 | |
| 207 | $this->add_control( |
| 208 | 'link', |
| 209 | array( |
| 210 | 'label' => __( 'Link to', 'auxin-elements' ), |
| 211 | 'type' => Controls_Manager::SELECT, |
| 212 | 'default' => 'lightbox', |
| 213 | 'options' => array( |
| 214 | 'file' => __( 'Media File', 'auxin-elements' ), |
| 215 | 'attachment' => __( 'Attachment Page', 'auxin-elements' ), |
| 216 | 'lightbox' => __( 'Lightbox', 'auxin-elements' ), |
| 217 | 'none' => __( 'None', 'auxin-elements' ) |
| 218 | ), |
| 219 | ) |
| 220 | ); |
| 221 | |
| 222 | $this->add_control( |
| 223 | 'pagination', |
| 224 | array( |
| 225 | 'label' => __( 'Pagination', 'auxin-elements' ), |
| 226 | 'type' => Controls_Manager::SWITCHER, |
| 227 | 'label_off' => __( 'On', 'auxin-elements' ), |
| 228 | 'label_on' => __( 'Off', 'auxin-elements' ), |
| 229 | 'default' => 'no' |
| 230 | ) |
| 231 | ); |
| 232 | |
| 233 | $this->add_control( |
| 234 | 'lazyload', |
| 235 | array( |
| 236 | 'label' => __( 'Enable lazyload', 'auxin-elements' ), |
| 237 | 'type' => Controls_Manager::SWITCHER, |
| 238 | 'label_off' => __( 'On', 'auxin-elements' ), |
| 239 | 'label_on' => __( 'Off', 'auxin-elements' ), |
| 240 | 'default' => 'no', |
| 241 | 'condition' => array( |
| 242 | 'pagination' => 'yes' |
| 243 | ) |
| 244 | ) |
| 245 | ); |
| 246 | |
| 247 | $this->add_control( |
| 248 | 'perpage', |
| 249 | array( |
| 250 | 'label' => __( 'Images per page', 'auxin-elements' ), |
| 251 | 'type' => Controls_Manager::SLIDER, |
| 252 | 'range' => array( |
| 253 | 'px' => array( |
| 254 | 'max' => 100, |
| 255 | ) |
| 256 | ), |
| 257 | 'default' => array( |
| 258 | 'size' => 24, |
| 259 | ), |
| 260 | 'condition' => array( |
| 261 | 'pagination' => 'yes' |
| 262 | ) |
| 263 | ) |
| 264 | ); |
| 265 | |
| 266 | $this->add_control( |
| 267 | 'wp_order', |
| 268 | array( |
| 269 | 'label' => __( 'Order by query', 'auxin-elements' ), |
| 270 | 'type' => Controls_Manager::SWITCHER, |
| 271 | 'label_off' => __( 'On', 'auxin-elements' ), |
| 272 | 'label_on' => __( 'Off', 'auxin-elements' ), |
| 273 | 'default' => 'no' |
| 274 | ) |
| 275 | ); |
| 276 | |
| 277 | $this->add_control( |
| 278 | 'order', |
| 279 | array( |
| 280 | 'label' => __( 'Order', 'auxin-elements' ), |
| 281 | 'type' => Controls_Manager::SELECT, |
| 282 | 'default' => 'ASC', |
| 283 | 'options' => array( |
| 284 | 'ASC' => __( 'ASC', 'auxin-elements' ), |
| 285 | 'DESC' => __( 'DESC', 'auxin-elements' ) |
| 286 | ), |
| 287 | 'condition' => array( |
| 288 | 'wp_order' => 'yes', |
| 289 | ) |
| 290 | ) |
| 291 | ); |
| 292 | |
| 293 | $this->add_control( |
| 294 | 'orderby', |
| 295 | array( |
| 296 | 'label' => __( 'Order images by', 'auxin-elements' ), |
| 297 | 'type' => Controls_Manager::SELECT, |
| 298 | 'default' => 'menu_order ID', |
| 299 | 'options' => array( |
| 300 | 'menu_order ID' => __( 'Menu Order', 'auxin-elements' ), |
| 301 | 'date' => __( 'date', 'auxin-elements' ), |
| 302 | 'ID' => __( 'ID', 'auxin-elements' ), |
| 303 | 'none' => __( 'None', 'auxin-elements' ) |
| 304 | ), |
| 305 | 'condition' => array( |
| 306 | 'wp_order' => 'yes', |
| 307 | ) |
| 308 | ) |
| 309 | ); |
| 310 | |
| 311 | $this->end_controls_section(); |
| 312 | |
| 313 | /*$this->start_controls_section( |
| 314 | 'section_caption', |
| 315 | array( |
| 316 | 'label' => __( 'Caption', 'auxin-elements' ), |
| 317 | 'tab' => Controls_Manager::TAB_STYLE, |
| 318 | ) |
| 319 | ); |
| 320 | |
| 321 | $this->add_control( |
| 322 | 'caption_display', |
| 323 | array( |
| 324 | 'label' => __( 'Display', 'auxin-elements' ), |
| 325 | 'type' => Controls_Manager::SELECT, |
| 326 | 'default' => '', |
| 327 | 'options' => array( |
| 328 | 'yes' => __( 'Show', 'auxin-elements' ), |
| 329 | 'no' => __( 'Hide', 'auxin-elements' ), |
| 330 | ), |
| 331 | 'selectors' => array( |
| 332 | '{{WRAPPER}} .gallery-item .gallery-caption' => 'display: {{VALUE}};', |
| 333 | ) |
| 334 | ) |
| 335 | ); |
| 336 | |
| 337 | $this->add_control( |
| 338 | 'caption_align', |
| 339 | array( |
| 340 | 'label' => __( 'Alignment', 'auxin-elements' ), |
| 341 | 'type' => Controls_Manager::CHOOSE, |
| 342 | 'options' => array( |
| 343 | 'left' => array( |
| 344 | 'title' => __( 'Left', 'auxin-elements' ), |
| 345 | 'icon' => 'eicon-text-align-left', |
| 346 | ), |
| 347 | 'center' => array( |
| 348 | 'title' => __( 'Center', 'auxin-elements' ), |
| 349 | 'icon' => 'eicon-text-align-center', |
| 350 | ), |
| 351 | 'right' => array( |
| 352 | 'title' => __( 'Right', 'auxin-elements' ), |
| 353 | 'icon' => 'eicon-text-align-right', |
| 354 | ), |
| 355 | 'justify' => array( |
| 356 | 'title' => __( 'Justified', 'auxin-elements' ), |
| 357 | 'icon' => 'fa fa-align-justify', |
| 358 | ), |
| 359 | ), |
| 360 | 'default' => 'center', |
| 361 | 'selectors' => array( |
| 362 | '{{WRAPPER}} .gallery-item .gallery-caption' => 'text-align: {{VALUE}};', |
| 363 | ), |
| 364 | 'condition' => array( |
| 365 | 'caption_display' => 'yes' |
| 366 | ), |
| 367 | ) |
| 368 | ); |
| 369 | |
| 370 | $this->add_control( |
| 371 | 'caption_color', |
| 372 | array( |
| 373 | 'label' => __( 'Text Color', 'auxin-elements' ), |
| 374 | 'type' => Controls_Manager::COLOR, |
| 375 | 'default' => '', |
| 376 | 'selectors' => array( |
| 377 | '{{WRAPPER}} .gallery-item .gallery-caption' => 'color: {{VALUE}};', |
| 378 | ), |
| 379 | 'condition' => array( |
| 380 | 'caption_display' => 'yes' |
| 381 | ), |
| 382 | ) |
| 383 | ); |
| 384 | |
| 385 | $this->add_group_control( |
| 386 | Group_Control_Typography::get_type(), |
| 387 | array( |
| 388 | 'name' => 'typography', |
| 389 | 'global' => [ |
| 390 | 'default' => Global_Typography::TYPOGRAPHY_TEXT, |
| 391 | ], |
| 392 | 'selector' => '{{WRAPPER}} .gallery-item .gallery-caption', |
| 393 | 'condition' => array( |
| 394 | 'caption_display' => 'yes' |
| 395 | ), |
| 396 | ) |
| 397 | ); |
| 398 | |
| 399 | $this->end_controls_section();*/ |
| 400 | |
| 401 | $this->start_controls_section( |
| 402 | 'section_image_hover', |
| 403 | array( |
| 404 | 'label' => __( 'Image Hover', 'auxin-elements' ), |
| 405 | 'tab' => Controls_Manager::TAB_STYLE |
| 406 | ) |
| 407 | ); |
| 408 | |
| 409 | $this->add_control( |
| 410 | 'image_hover_overlay_color', |
| 411 | array( |
| 412 | 'label' => __( 'Image hover overlay color', 'auxin-elements' ), |
| 413 | 'type' => Controls_Manager::COLOR, |
| 414 | 'global' => [ |
| 415 | 'default' => Global_Colors::COLOR_ACCENT, |
| 416 | ], |
| 417 | 'default' => 'rgba(0, 0, 0, 0.7)', |
| 418 | 'selectors' => array( |
| 419 | '{{WRAPPER}} .aux-gallery-container .aux-frame-darken::after' => 'background-color: {{VALUE}}' |
| 420 | ) |
| 421 | ) |
| 422 | ); |
| 423 | |
| 424 | $this->add_control( |
| 425 | 'image_hover_transition_duration', |
| 426 | array( |
| 427 | 'label' => __( 'Image hover transition duration (milliseconds)', 'auxin-elements' ), |
| 428 | 'type' => Controls_Manager::SLIDER, |
| 429 | 'default' => array( |
| 430 | 'size' => 1000, |
| 431 | ), |
| 432 | 'range' => array( |
| 433 | 'px' => array( |
| 434 | 'min' => 0, |
| 435 | 'max' => 5000, |
| 436 | 'step' => 10 |
| 437 | ) |
| 438 | ), |
| 439 | 'selectors' => array( |
| 440 | '{{WRAPPER}} .aux-gallery-container .aux-frame-darken::after, {{WRAPPER}} .aux-gallery-container .aux-frame-mask-plain' => 'transition-duration:{{SIZE}}ms;' |
| 441 | ) |
| 442 | ) |
| 443 | ); |
| 444 | |
| 445 | $this->add_control( |
| 446 | 'image_hover_zoom', |
| 447 | array( |
| 448 | 'label' => __( 'Image hover zoom', 'auxin-elements' ), |
| 449 | 'type' => Controls_Manager::SLIDER, |
| 450 | 'default' => array( |
| 451 | 'size' => 120, |
| 452 | ), |
| 453 | 'range' => array( |
| 454 | 'px' => array( |
| 455 | 'min' => 0, |
| 456 | 'max' => 250, |
| 457 | 'step' => 1 |
| 458 | ) |
| 459 | ), |
| 460 | 'selectors' => array( |
| 461 | '{{WRAPPER}} .aux-gallery-container .aux-hover-active:hover .aux-frame-mask-plain' => |
| 462 | '-webkit-transform: perspective(1000) translateZ(-{{SIZE}}px); transform: perspective(1000) translateZ(-{{SIZE}}px);' |
| 463 | ) |
| 464 | ) |
| 465 | ); |
| 466 | |
| 467 | $this->end_controls_section(); |
| 468 | |
| 469 | |
| 470 | $this->start_controls_section( |
| 471 | 'section_image_border', |
| 472 | array( |
| 473 | 'label' => __( 'Image Border', 'auxin-elements' ), |
| 474 | 'tab' => Controls_Manager::TAB_STYLE |
| 475 | ) |
| 476 | ); |
| 477 | |
| 478 | $this->add_group_control( |
| 479 | Group_Control_Border::get_type(), |
| 480 | array( |
| 481 | 'name' => 'image_border', |
| 482 | 'selector' => '{{WRAPPER}} .aux-gallery-container .gallery-item .aux-frame-ratio-inner', |
| 483 | 'separator' => 'before' |
| 484 | ) |
| 485 | ); |
| 486 | |
| 487 | $this->add_control( |
| 488 | 'image_border_radius', |
| 489 | array( |
| 490 | 'label' => __( 'Border Radius', 'auxin-elements' ), |
| 491 | 'type' => Controls_Manager::DIMENSIONS, |
| 492 | 'size_units' => array( 'px', '%' ), |
| 493 | 'selectors' => array( |
| 494 | '{{WRAPPER}} .aux-gallery-container .gallery-item .aux-frame-ratio-inner' => 'overflow:hidden;', |
| 495 | '{{WRAPPER}} .aux-gallery-container .gallery-item .aux-frame-ratio-inner, {{WRAPPER}} .aux-gallery-container .aux-frame-ratio-inner:after' => 'border-radius:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 496 | ) |
| 497 | ) |
| 498 | ); |
| 499 | |
| 500 | $this->end_controls_section(); |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * Render image box widget output on the frontend. |
| 505 | * |
| 506 | * Written in PHP and used to generate the final HTML. |
| 507 | * |
| 508 | * @since 1.0.0 |
| 509 | * @access protected |
| 510 | */ |
| 511 | protected function render() { |
| 512 | global $post; |
| 513 | $settings = $this->get_settings_for_display(); |
| 514 | |
| 515 | if ( ! $settings['wp_gallery'] ) { |
| 516 | return; |
| 517 | } |
| 518 | |
| 519 | $ids = wp_list_pluck( $settings['wp_gallery'], 'id' ); |
| 520 | $perpage = !empty( $settings['perpage']['size'] ) ? $settings['perpage']['size'] : 24; |
| 521 | |
| 522 | $tablet_columns = !empty( $settings['columns_tablet'] ) ? $settings['columns_tablet'] : 2; |
| 523 | $mobile_columns = !empty( $settings['columns_mobile'] ) ? $settings['columns_mobile'] : 1; |
| 524 | |
| 525 | // Gallery attributes |
| 526 | $args = array( |
| 527 | //'default_image_size' => 'medium', |
| 528 | 'include' => $ids, |
| 529 | 'order' => $settings['order'], |
| 530 | 'orderby' => $settings['orderby'], |
| 531 | 'columns' => $settings['columns'], |
| 532 | 'tablet_cnum' => $tablet_columns, |
| 533 | 'phone_cnum' => $mobile_columns, |
| 534 | 'space' => $settings['space']['size'], |
| 535 | 'image_aspect_ratio' => !empty( $settings['image_aspect_ratio']['size'] ) ? $settings['image_aspect_ratio']['size'] : 0.75, |
| 536 | 'layout' => $settings['layout'], |
| 537 | 'tile_style_pattern' => $settings['tile_style_pattern'], |
| 538 | 'link' => $settings['link'], |
| 539 | 'perpage' => $perpage, |
| 540 | 'pagination' => $settings['pagination'], |
| 541 | 'lazyload' => $settings['lazyload'], |
| 542 | 'wp_order' => $settings['wp_order'] |
| 543 | // 'caption_display' => $settings['caption_display'], |
| 544 | // 'caption_align' => $settings['caption_align'], |
| 545 | // 'caption_color' => $settings['caption_color'] |
| 546 | ); |
| 547 | |
| 548 | // render the markup using element base fallback |
| 549 | echo auxin_widget_gallery_callback( $args ); |
| 550 | } |
| 551 | |
| 552 | } |
| 553 |