js
7 months ago
class-thumbnail-gallery-template.php
7 months ago
gallery-thumbnail.php
7 months ago
gallery-thumbnail.php
68 lines
| 1 | <?php |
| 2 | /** |
| 3 | * FooGallery single thumbnail gallery template |
| 4 | */ |
| 5 | global $current_foogallery; |
| 6 | |
| 7 | $lightbox = foogallery_gallery_template_setting_lightbox(); |
| 8 | $position = foogallery_gallery_template_setting( 'position', 'fg-center' ); |
| 9 | $link_custom_url = foogallery_gallery_template_setting( 'link_custom_url' ); |
| 10 | $show_as_stack = foogallery_gallery_template_setting( 'show_as_stack' ); |
| 11 | |
| 12 | $featured_attachment = $current_foogallery->featured_attachment(); |
| 13 | $featured_attachment->featured = true; |
| 14 | |
| 15 | $args = foogallery_gallery_template_arguments(); |
| 16 | $args['override_caption_title'] = foogallery_format_caption_text( foogallery_gallery_template_setting( 'caption_title', '' ) ); |
| 17 | $args['override_caption_desc'] = foogallery_format_caption_text( foogallery_gallery_template_setting( 'caption_description', '' ) ); |
| 18 | |
| 19 | if ( 'on' === $link_custom_url && '' !== $lightbox && ! empty( $featured_attachment->custom_url ) ) { |
| 20 | $featured_attachment->type = 'iframe'; |
| 21 | } |
| 22 | |
| 23 | $foogallery_single_thumbnail_classes = foogallery_build_class_attribute_safe( $current_foogallery, 'foogallery-single-thumbnail', 'foogallery-lightbox-' . $lightbox, $position, $show_as_stack ); |
| 24 | $foogallery_single_thumbnail_attributes = foogallery_build_container_attributes_safe( $current_foogallery, array( 'class' => $foogallery_single_thumbnail_classes ) ); |
| 25 | |
| 26 | // Get 2 arrays of attachments for this gallery. |
| 27 | // 1 will not be hidden (if show_as_stack is enabled) |
| 28 | // and the other will be the default hidden ones, so that they show up in the lightbox. |
| 29 | $attachments_not_hidden = array(); |
| 30 | $attachments_hidden = array(); |
| 31 | $always_hide = false; |
| 32 | |
| 33 | foreach ( foogallery_current_gallery_attachments_for_rendering() as $attachment ) { |
| 34 | // We can skip the featured attachment. |
| 35 | if ( $attachment->url === $featured_attachment->url ) { |
| 36 | continue; |
| 37 | } |
| 38 | |
| 39 | if ( !$always_hide && 'fg-stacked' === $show_as_stack ) { |
| 40 | $attachments_not_hidden[] = $attachment; |
| 41 | } else { |
| 42 | $attachments_hidden[] = $attachment; |
| 43 | } |
| 44 | |
| 45 | // If only want to not hide 2 attachments, then set always_hide to true. |
| 46 | if ( count( $attachments_not_hidden ) >= 2 ) { |
| 47 | $always_hide = true; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | |
| 52 | ?> |
| 53 | <div <?php echo $foogallery_single_thumbnail_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> |
| 54 | <?php echo foogallery_attachment_html( $featured_attachment, $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 55 | <?php |
| 56 | foreach ( $attachments_not_hidden as $attachment ) { |
| 57 | echo foogallery_attachment_html( $attachment ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 58 | } |
| 59 | ?> |
| 60 | <div class="fg-st-hidden"> |
| 61 | <?php |
| 62 | foreach ( $attachments_hidden as $attachment ) { |
| 63 | echo foogallery_attachment_html( $attachment ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 64 | } |
| 65 | ?> |
| 66 | </div> |
| 67 | </div> |
| 68 |