Version 2.5 - Deprecates ekkolighbox an slick carousel. Uses new Tainacan function to render item gallery.

This commit is contained in:
mateuswetah 2022-03-18 16:56:32 -03:00
parent 2269ac5976
commit d17758e420
5 changed files with 254 additions and 252 deletions

View File

@ -287,6 +287,63 @@ if ( !function_exists('tainacan_interface_customize_register_tainacan_single_ite
), ),
) ); ) );
} }
if ( function_exists('tainacan_the_item_gallery') ) {
/**
* Adds options to hide attachments file names on the lightbox.
*/
$wp_customize->add_setting( 'tainacan_single_item_hide_files_name_lightbox', array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => false,
'transport' => 'refresh',
'sanitize_callback' => 'tainacan_callback_sanitize_checkbox'
) );
$wp_customize->add_control( 'tainacan_single_item_hide_files_name_lightbox', array(
'type' => 'checkbox',
'priority' => 4, // Within the section.
'section' => 'tainacan_single_item_page_document',
'label' => __( 'Hide the attachments label (in the lightbox)', 'tainacan-interface' ),
'description' => __( 'Toggle to not display the document and attachments name in the lightbox.', 'tainacan-interface' )
) );
/**
* Adds options to hide attachments file caption on the lightbox.
*/
$wp_customize->add_setting( 'tainacan_single_item_hide_files_caption_lightbox', array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => false,
'transport' => 'refresh',
'sanitize_callback' => 'tainacan_callback_sanitize_checkbox'
) );
$wp_customize->add_control( 'tainacan_single_item_hide_files_caption_lightbox', array(
'type' => 'checkbox',
'priority' => 4, // Within the section.
'section' => 'tainacan_single_item_page_document',
'label' => __( 'Hide the attachments caption (in the lightbox)', 'tainacan-interface' ),
'description' => __( 'Toggle to not display the document and attachments caption in the lightbox.', 'tainacan-interface' )
) );
/**
* Adds options to hide attachments file description on the lightbox.
*/
$wp_customize->add_setting( 'tainacan_single_item_hide_files_description_lightbox', array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => false,
'transport' => 'refresh',
'sanitize_callback' => 'tainacan_callback_sanitize_checkbox'
) );
$wp_customize->add_control( 'tainacan_single_item_hide_files_description_lightbox', array(
'type' => 'checkbox',
'priority' => 4, // Within the section.
'section' => 'tainacan_single_item_page_document',
'label' => __( 'Hide the attachments description (in the lightbox)', 'tainacan-interface' ),
'description' => __( 'Toggle to not display the document and attachments description in the lightbox.', 'tainacan-interface' )
) );
}
} }
} }
add_action( 'customize_register', 'tainacan_interface_customize_register_tainacan_single_item_page_document', 11 ); add_action( 'customize_register', 'tainacan_interface_customize_register_tainacan_single_item_page_document', 11 );
@ -408,7 +465,7 @@ if ( !function_exists('tainacan_gallery_light_color_scheme') ) {
$has_light_dark_color_scheme = get_theme_mod( 'tainacan_single_item_gallery_color_scheme', 'dark' ) == 'light'; $has_light_dark_color_scheme = get_theme_mod( 'tainacan_single_item_gallery_color_scheme', 'dark' ) == 'light';
if (!$has_light_dark_color_scheme) if (!$has_light_dark_color_scheme || function_exists('tainacan_the_item_gallery'))
return; return;
$css = ' $css = '

View File

@ -1,7 +1,13 @@
<?php <?php
if ( function_exists('tainacan_get_the_media_component') ) { //if (version_compare(TAINACAN_VERSION, '0.18RC') >= 0) { if ( function_exists('tainacan_the_item_gallery') ) { //if (version_compare(TAINACAN_VERSION, '0.19RC') >= 0) {
get_template_part( 'template-parts/single-items-attachments_new' ); get_template_part( 'template-parts/single-items-attachments_new' );
} else { } else if ( function_exists('tainacan_get_the_media_component') ) { //if (version_compare(TAINACAN_VERSION, '0.18RC') >= 0) {
get_template_part( 'template-parts/single-items-attachments_old' ); get_template_part( 'template-parts/single-items-attachments_old' );
} else {
?>
<div style="text-aling: center; max-width: 600px; margin: 2em auto; width: 100%; font-style: italic;">
<p><?php __('It seems that you are using a legacy vesion of the Tainacan plugin. Please update in order to use the latest features for displaying item media.', 'tainacan-interface') ?></p>
</div>
<?php
} }
?> ?>

View File

@ -1,13 +1,18 @@
<?php <?php
$attachments = tainacan_get_the_attachments(); $attachments = tainacan_get_the_attachments();
$is_gallery_mode = get_theme_mod( 'tainacan_single_item_gallery_mode', false ); $is_gallery_mode = get_theme_mod( 'tainacan_single_item_gallery_mode', false );
$hide_file_name = get_theme_mod('tainacan_single_item_hide_files_name_main', true); $hide_file_name = get_theme_mod('tainacan_single_item_hide_files_name_main', true);
$hide_file_caption = get_theme_mod('tainacan_single_item_hide_files_caption_main', true); $hide_file_caption = get_theme_mod('tainacan_single_item_hide_files_caption_main', true);
$hide_file_description = get_theme_mod('tainacan_single_item_hide_files_description_main', true); $hide_file_description = get_theme_mod('tainacan_single_item_hide_files_description_main', true);
$hide_thumbnail_info = get_theme_mod('tainacan_single_item_hide_files_name', false);
$disable_gallery_lightbox = get_theme_mod('tainacan_single_item_disable_gallery_lightbox', false); $disable_gallery_lightbox = get_theme_mod('tainacan_single_item_disable_gallery_lightbox', false);
$hide_download_button = get_theme_mod( 'tainacan_single_item_hide_download_document', false );
$hide_file_name_lightbox = get_theme_mod('tainacan_single_item_hide_files_name_lightbox', false);
$hide_file_caption_lightbox = get_theme_mod('tainacan_single_item_hide_files_caption_lightbox', false);
$hide_file_description_lightbox = get_theme_mod('tainacan_single_item_hide_files_description_lightbox', false);
$has_light_dark_color_scheme = get_theme_mod( 'tainacan_single_item_gallery_color_scheme', 'dark' ) == 'light';
if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_mode', false) && tainacan_has_document() ) ) { if ( !empty( $attachments ) || ( $is_gallery_mode && tainacan_has_document() ) ) {
?> ?>
<div class="mt-3 tainacan-single-post"> <div class="mt-3 tainacan-single-post">
@ -21,116 +26,32 @@ if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_m
<?php echo esc_html( get_theme_mod('tainacan_single_item_documents_section_label', __( 'Documents', 'tainacan-interface' )) ); ?> <?php echo esc_html( get_theme_mod('tainacan_single_item_documents_section_label', __( 'Documents', 'tainacan-interface' )) ); ?>
</h2> </h2>
<?php endif; ?> <?php endif; ?>
<section <section
style="<?php echo (!$is_gallery_mode ? 'min-height: 10vh;' : '') ?>" style="<?php echo (!$is_gallery_mode ? 'min-height: 10vh;' : '') ?>"
class="tainacan-content single-item-collection margin-two-column"> class="tainacan-content single-item-collection margin-two-column">
<?php <?php
tainacan_the_item_gallery([
$media_items_thumbs = array(); 'blockId' => 'tainacan-item-attachments_id-' . $post->ID,
$media_items_main = array(); 'layoutElements' => array( 'main' => $is_gallery_mode, 'thumbnails' => true ),
'mediaSources' => array( 'document' => $is_gallery_mode, 'attachments' => true, 'metadata' => false),
if ($is_gallery_mode) { 'hideFileNameMain' => $hide_file_name,
'hideFileCaptionMain' => $hide_file_caption,
$class_slide_metadata = ''; 'hideFileDescriptionMain' => $hide_file_description,
if ($hide_file_name) 'hideFileNameThumbnails' => $hide_thumbnail_info,
$class_slide_metadata .= ' hide-name'; 'hideFileCaptionThumbnails' => true,
if ($hide_file_description) 'hideFileDescriptionThumbnails' => true,
$class_slide_metadata .= ' hide-description'; 'showDownloadButtonMain' => !$hide_download_button,
if ($hide_file_caption) 'showArrowsAsSVG' => false,
$class_slide_metadata .= ' hide-caption'; 'hideFileNameLightbox' => $hide_file_name_lightbox,
'hideFileCaptionLightbox' => $hide_file_caption_lightbox,
if ( tainacan_has_document() ) { 'hideFileDescriptionLightbox' => $hide_file_description_lightbox,
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment'; 'openLightboxOnClick' => $is_gallery_mode ? !$disable_gallery_lightbox : true,
$media_items_main[] = 'lightboxHasLightBackground' => $has_light_dark_color_scheme
tainacan_get_the_media_component_slide(array( ]);
'after_slide_metadata' => (( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && tainacan_the_item_document_download_link() != '' ) ?
('<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>')
: ''),
'media_content' => tainacan_get_the_document(),
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => $class_slide_metadata
));
}
foreach ( $attachments as $attachment ) {
$media_items_main[] =
tainacan_get_the_media_component_slide(array(
'after_slide_metadata' => (( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && tainacan_the_item_attachment_download_link($attachment->ID) != '' ) ?
'<span class="tainacan-item-file-download">' . tainacan_the_item_attachment_download_link($attachment->ID) . '</span>'
: ''),
'media_content' => tainacan_get_attachment_as_html($attachment->ID, 0),
'media_content_full' => wp_attachment_is('image', $attachment->ID) ? wp_get_attachment_image( $attachment->ID, 'full', false) : ('<div class="attachment-without-image tainacan-embed-container"><iframe id="tainacan-attachment-iframe" src="' . tainacan_get_attachment_html_url($attachment->ID) . '"></iframe></div>'),
'media_title' => $attachment->post_title,
'media_description' => $attachment->post_content,
'media_caption' => $attachment->post_excerpt,
'media_type' => $attachment->post_mime_type,
'class_slide_metadata' => $class_slide_metadata
));
}
}
if (
(tainacan_has_document() && $attachments && sizeof($attachments) > 0 ) ||
(!tainacan_has_document() && $attachments && sizeof($attachments) > 1 )
) {
if ( tainacan_has_document() ) {
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$media_items_thumbs[] =
tainacan_get_the_media_component_slide(array(
'media_content' => get_the_post_thumbnail(null, 'tainacan-medium'),
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => 'hide-caption hide-description ' . ( get_theme_mod('tainacan_single_item_hide_files_name', false) ? 'hide-name' : '' )
));
}
foreach ( $attachments as $attachment ) {
$media_items_thumbs[] =
tainacan_get_the_media_component_slide(array(
'media_content' => wp_get_attachment_image( $attachment->ID, 'tainacan-medium', false ),
'media_content_full' => wp_attachment_is('image', $attachment->ID) ? wp_get_attachment_image( $attachment->ID, 'full', false) : ('<div class="attachment-without-image tainacan-embed-container"><iframe id="tainacan-attachment-iframe" src="' . tainacan_get_attachment_html_url($attachment->ID) . '"></iframe></div>'),
'media_title' => $attachment->post_title,
'media_description' => $attachment->post_content,
'media_caption' => $attachment->post_excerpt,
'media_type' => $attachment->post_mime_type,
'class_slide_metadata' => 'hide-caption hide-description ' . ( get_theme_mod('tainacan_single_item_hide_files_name', false) ? 'hide-name' : '' )
));
}
}
tainacan_the_media_component(
'tainacan-item-attachments_id-' . $post->ID,
$media_items_thumbs,
$is_gallery_mode ? $media_items_main : null,
array(
'class_main_div' => '',
'class_thumbs_div' => '',
'swiper_thumbs_options' => $is_gallery_mode ? '' : array(
'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-thumbs',
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-attachments_id-' . $post->ID . '-thumbs',
'preloadImages' => false,
'lazy' => true
)
),
'swiper_main_options' => $is_gallery_mode ? array(
'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-main',
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-attachments_id-' . $post->ID . '-main',
'preloadImages' => false,
'lazy' => true
)
) : '',
'disable_lightbox' => $is_gallery_mode ? $disable_gallery_lightbox : false,
)
);
?> ?>
</section> </section>
</div> </div>
<div class="my-5 border-bottom border-silver"></div> <div class="my-5 border-bottom border-silver"></div>

View File

@ -1,119 +1,141 @@
<?php <?php
if (function_exists('tainacan_get_the_attachments')) {
$attachments = tainacan_get_the_attachments(); $attachments = tainacan_get_the_attachments();
} else { $is_gallery_mode = get_theme_mod( 'tainacan_single_item_gallery_mode', false );
// compatibility with pre 0.11 tainacan plugin $hide_file_name = get_theme_mod('tainacan_single_item_hide_files_name_main', true);
$attachments = array_values( $hide_file_caption = get_theme_mod('tainacan_single_item_hide_files_caption_main', true);
get_children( $hide_file_description = get_theme_mod('tainacan_single_item_hide_files_description_main', true);
array( $disable_gallery_lightbox = get_theme_mod('tainacan_single_item_disable_gallery_lightbox', false);
'post_parent' => $post->ID, $hide_thumbnail_info = get_theme_mod('tainacan_single_item_hide_files_name', false);
'post_type' => 'attachment',
'post_mime_type' => 'image', if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_mode', false) && tainacan_has_document() ) ) {
'order' => 'ASC',
'numberposts' => -1,
)
)
);
}
?> ?>
<?php if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_mode', false) && tainacan_has_document() )) : ?>
<div class="mt-3 tainacan-single-post"> <div class="mt-3 tainacan-single-post">
<?php if ( !get_theme_mod( 'tainacan_single_item_gallery_mode', false ) && get_theme_mod('tainacan_single_item_attachments_section_label', __( 'Attachments', 'tainacan-interface' )) != '') : ?> <?php if ( !$is_gallery_mode && get_theme_mod('tainacan_single_item_attachments_section_label', __( 'Attachments', 'tainacan-interface' )) != '') : ?>
<h2 class="title-content-items" id="single-item-attachments-label"> <h2 class="title-content-items" id="single-item-attachments-label">
<?php echo esc_html( get_theme_mod('tainacan_single_item_attachments_section_label', __( 'Attachments', 'tainacan-interface' )) ); ?> <?php echo esc_html( get_theme_mod('tainacan_single_item_attachments_section_label', __( 'Attachments', 'tainacan-interface' )) ); ?>
</h2> </h2>
<?php endif; ?> <?php endif; ?>
<?php if ( get_theme_mod( 'tainacan_single_item_gallery_mode', false ) && get_theme_mod('tainacan_single_item_documents_section_label', __( 'Documents', 'tainacan-interface' )) != '') : ?> <?php if ( $is_gallery_mode && get_theme_mod('tainacan_single_item_documents_section_label', __( 'Documents', 'tainacan-interface' )) != '') : ?>
<h2 class="title-content-items" id="single-item-documents-label"> <h2 class="title-content-items" id="single-item-documents-label">
<?php echo esc_html( get_theme_mod('tainacan_single_item_documents_section_label', __( 'Documents', 'tainacan-interface' )) ); ?> <?php echo esc_html( get_theme_mod('tainacan_single_item_documents_section_label', __( 'Documents', 'tainacan-interface' )) ); ?>
</h2> </h2>
<?php endif; ?> <?php endif; ?>
<section class="tainacan-content single-item-collection margin-two-column">
<?php if (get_theme_mod( 'tainacan_single_item_gallery_mode', false )): ?> <section
<div class="single-item-collection--gallery"> style="<?php echo (!$is_gallery_mode ? 'min-height: 10vh;' : '') ?>"
<?php if ( tainacan_has_document() ) : ?> class="tainacan-content single-item-collection margin-two-column">
<section class="tainacan-content single-item-collection margin-two-column">
<div class="single-item-collection--document">
<?php <?php
tainacan_the_document();
if ( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) { $media_items_thumbs = array();
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>'; $media_items_main = array();
if ($is_gallery_mode) {
$class_slide_metadata = '';
if ($hide_file_name)
$class_slide_metadata .= ' hide-name';
if ($hide_file_description)
$class_slide_metadata .= ' hide-description';
if ($hide_file_caption)
$class_slide_metadata .= ' hide-caption';
if ( tainacan_has_document() ) {
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$media_items_main[] =
tainacan_get_the_media_component_slide(array(
'after_slide_metadata' => (( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && tainacan_the_item_document_download_link() != '' ) ?
('<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>')
: ''),
'media_content' => tainacan_get_the_document(),
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => $class_slide_metadata
));
} }
foreach ( $attachments as $attachment ) {
$media_items_main[] =
tainacan_get_the_media_component_slide(array(
'after_slide_metadata' => (( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && tainacan_the_item_attachment_download_link($attachment->ID) != '' ) ?
'<span class="tainacan-item-file-download">' . tainacan_the_item_attachment_download_link($attachment->ID) . '</span>'
: ''),
'media_content' => tainacan_get_attachment_as_html($attachment->ID, 0),
'media_content_full' => wp_attachment_is('image', $attachment->ID) ? wp_get_attachment_image( $attachment->ID, 'full', false) : ('<div class="attachment-without-image tainacan-embed-container"><iframe id="tainacan-attachment-iframe" src="' . tainacan_get_attachment_html_url($attachment->ID) . '"></iframe></div>'),
'media_title' => $attachment->post_title,
'media_description' => $attachment->post_content,
'media_caption' => $attachment->post_excerpt,
'media_type' => $attachment->post_mime_type,
'class_slide_metadata' => $class_slide_metadata
));
}
}
if (
(tainacan_has_document() && $attachments && sizeof($attachments) > 0 ) ||
(!tainacan_has_document() && $attachments && sizeof($attachments) > 1 )
) {
if ( tainacan_has_document() ) {
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$media_items_thumbs[] =
tainacan_get_the_media_component_slide(array(
'media_content' => get_the_post_thumbnail(null, 'tainacan-medium'),
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => 'hide-caption hide-description ' . ( $hide_thumbnail_info ? 'hide-name' : '' )
));
}
foreach ( $attachments as $attachment ) {
$media_items_thumbs[] =
tainacan_get_the_media_component_slide(array(
'media_content' => wp_get_attachment_image( $attachment->ID, 'tainacan-medium', false ),
'media_content_full' => wp_attachment_is('image', $attachment->ID) ? wp_get_attachment_image( $attachment->ID, 'full', false) : ('<div class="attachment-without-image tainacan-embed-container"><iframe id="tainacan-attachment-iframe" src="' . tainacan_get_attachment_html_url($attachment->ID) . '"></iframe></div>'),
'media_title' => $attachment->post_title,
'media_description' => $attachment->post_content,
'media_caption' => $attachment->post_excerpt,
'media_type' => $attachment->post_mime_type,
'class_slide_metadata' => 'hide-caption hide-description ' . ( $hide_thumbnail_info ? 'hide-name' : '' )
));
}
}
tainacan_the_media_component(
'tainacan-item-attachments_id-' . $post->ID,
$media_items_thumbs,
$is_gallery_mode ? $media_items_main : null,
array(
'class_main_div' => '',
'class_thumbs_div' => '',
'swiper_thumbs_options' => $is_gallery_mode ? '' : array(
'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-thumbs',
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-attachments_id-' . $post->ID . '-thumbs',
'preloadImages' => false,
'lazy' => true
)
),
'swiper_main_options' => $is_gallery_mode ? array(
'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-main',
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-attachments_id-' . $post->ID . '-main',
'preloadImages' => false,
'lazy' => true
)
) : '',
'disable_lightbox' => $is_gallery_mode ? $disable_gallery_lightbox : false,
)
);
?> ?>
</div>
</section>
<?php endif; ?>
<?php foreach ( $attachments as $attachment ) { ?>
<section class="tainacan-content single-item-collection margin-two-column">
<div class="single-item-collection--document">
<?php
if ( function_exists('tainacan_get_single_attachment_as_html') ) {
tainacan_get_single_attachment_as_html($attachment->ID);
}
if ( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && function_exists('tainacan_the_item_attachment_download_link') && tainacan_the_item_attachment_download_link($attachment->ID) != '' ) {
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_attachment_download_link($attachment->ID) . '</span>';
}
?>
</div>
</section>
<?php } ?>
</div>
<?php if ( (tainacan_has_document() && $attachments && sizeof($attachments) > 0 ) || (!tainacan_has_document() && $attachments && sizeof($attachments) > 1 ) ) : ?>
<div class="single-item-collection--gallery-items">
<?php if ( tainacan_has_document() ) : ?>
<div class="single-item-collection--attachments-file">
<?php
the_post_thumbnail('tainacan-medium-full', array('class' => 'item-card--thumbnail mt-2'));
echo '<br>';
?>
<span class="single-item-file-name <?php if (get_theme_mod('tainacan_single_item_hide_files_name', false)) echo 'sr-only' ?>"><?php echo __( 'Document', 'tainacan-interface' ); ?></span>
</div>
<?php endif; ?>
<?php foreach ( $attachments as $attachment ) { ?>
<div class="single-item-collection--attachments-file">
<div class="<?php if (!wp_get_attachment_image( $attachment->ID, 'tainacan-medium')) echo'attachment-without-image'; ?>">
<?php
echo wp_get_attachment_image( $attachment->ID, 'tainacan-medium', true );
echo '<br>';
?>
<span class="single-item-file-name <?php if (get_theme_mod('tainacan_single_item_hide_files_name', false)) echo 'sr-only' ?>"><?php echo get_the_title( $attachment->ID ); ?></span>
</div>
</div>
<?php } ?>
</div>
<?php endif; ?>
<?php else : ?>
<div class="single-item-collection--attachments">
<?php foreach ( $attachments as $attachment ) { ?>
<?php
if ( function_exists('tainacan_get_attachment_html_url') ) {
$href = tainacan_get_attachment_html_url($attachment->ID);
} else {
$href = wp_get_attachment_url($attachment->ID, 'large');
}
?>
<div class="single-item-collection--attachments-file">
<a
class="<?php if (!wp_get_attachment_image( $attachment->ID, 'tainacan-medium')) echo'attachment-without-image'; ?>"
href="<?php echo $href; ?>"
data-toggle="lightbox"
data-gallery="example-gallery">
<?php
echo wp_get_attachment_image( $attachment->ID, 'tainacan-medium', true );
echo '<br>';
?>
<span class="single-item-file-name <?php if (get_theme_mod('tainacan_single_item_hide_files_name', false)) echo 'sr-only' ?>"><?php echo get_the_title( $attachment->ID ); ?></span>
</a>
</div>
<?php }
?>
</div>
<?php endif; ?>
</section> </section>
</div> </div>
<div class="my-5 border-bottom border-silver"></div> <div class="my-5 border-bottom border-silver"></div>
<?php
<?php endif; ?> }

View File

@ -4,18 +4,17 @@ if (version_compare(TAINACAN_VERSION, '0.18RC') >= 0) {
$hide_file_name = get_theme_mod('tainacan_single_item_hide_files_name_main', true); $hide_file_name = get_theme_mod('tainacan_single_item_hide_files_name_main', true);
$hide_file_caption = get_theme_mod('tainacan_single_item_hide_files_caption_main', true); $hide_file_caption = get_theme_mod('tainacan_single_item_hide_files_caption_main', true);
$hide_file_description = get_theme_mod('tainacan_single_item_hide_files_description_main', true); $hide_file_description = get_theme_mod('tainacan_single_item_hide_files_description_main', true);
$hide_thumbnail_info = get_theme_mod('tainacan_single_item_hide_files_name', false);
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment'; $is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$disable_gallery_lightbox = get_theme_mod('tainacan_single_item_disable_gallery_lightbox', false); $disable_gallery_lightbox = get_theme_mod('tainacan_single_item_disable_gallery_lightbox', false);
$hide_download_button = get_theme_mod( 'tainacan_single_item_hide_download_document', false );
$has_light_dark_color_scheme = get_theme_mod( 'tainacan_single_item_gallery_color_scheme', 'dark' ) == 'light';
$class_slide_metadata = ''; if ( function_exists('tainacan_the_item_gallery') ) {
$hide_file_name_lightbox = get_theme_mod('tainacan_single_item_hide_files_name_lightbox', false);
if ($hide_file_name) $hide_file_caption_lightbox = get_theme_mod('tainacan_single_item_hide_files_caption_lightbox', false);
$class_slide_metadata .= ' hide-name'; $hide_file_description_lightbox = get_theme_mod('tainacan_single_item_hide_files_description_lightbox', false);
if ($hide_file_description) }
$class_slide_metadata .= ' hide-description';
if ($hide_file_caption)
$class_slide_metadata .= ' hide-caption';
global $post; global $post;
} }
@ -28,37 +27,28 @@ if ( tainacan_has_document() && !get_theme_mod( 'tainacan_single_item_gallery_mo
<?php endif; ?> <?php endif; ?>
<section class="tainacan-content single-item-collection margin-two-column"> <section class="tainacan-content single-item-collection margin-two-column">
<div class="single-item-collection--document"> <div class="single-item-collection--document">
<?php if ( !function_exists('tainacan_get_the_media_component') ) { <?php if ( function_exists('tainacan_the_item_gallery') ) {
tainacan_the_document(); tainacan_the_item_gallery([
'blockId' => 'tainacan-item-document_id-' . $post->ID,
'layoutElements' => array( 'main' => true, 'thumbnails' => false ),
'mediaSources' => array( 'document' => true, 'attachments' => false, 'metadata' => false),
'hideFileNameMain' => $hide_file_name,
'hideFileCaptionMain' => $hide_file_caption,
'hideFileDescriptionMain' => $hide_file_description,
'hideFileNameThumbnails' => $hide_thumbnail_info,
'hideFileCaptionThumbnails' => true,
'hideFileDescriptionThumbnails' => true,
'showDownloadButtonMain' => !$hide_download_button,
'showArrowsAsSVG' => false,
'hideFileNameLightbox' => $hide_file_name_lightbox,
'hideFileCaptionLightbox' => $hide_file_caption_lightbox,
'hideFileDescriptionLightbox' => $hide_file_description_lightbox,
'openLightboxOnClick' => !$disable_gallery_lightbox,
'lightboxHasLightBackground' => $has_light_dark_color_scheme
]);
if ( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) } else if (function_exists('tainacan_get_the_media_component')) {
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>';
if ( version_compare(TAINACAN_VERSION, '0.18RC') >= 0 ) { ?>
<div class="document-metadata <?php echo $class_slide_metadata ?>">
<?php if ( !$hide_file_caption && $is_document_type_attachment ): ?>
<span class="document-metadata__caption">
<?php echo wp_get_attachment_caption(tainacan_get_the_document_raw()); ?>
<br>
</span>
<?php endif; ?>
<?php if ( !$hide_file_name && $is_document_type_attachment ): ?>
<span class="document-metadata__name">
<?php echo get_the_title(tainacan_get_the_document_raw()); ?>
</span>
<?php endif; ?>
<br>
<?php if ( !$hide_file_description && $is_document_type_attachment ): ?>
<span class="document-metadata__description">
<?php echo get_the_content(tainacan_get_the_document_raw()); ?>
</span>
<?php endif; ?>
</div>
<?php
}
} else {
$media_items_main = array(); $media_items_main = array();
$class_slide_metadata = ''; $class_slide_metadata = '';
@ -73,7 +63,7 @@ if ( tainacan_has_document() && !get_theme_mod( 'tainacan_single_item_gallery_mo
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment'; $is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$media_items_main[] = $media_items_main[] =
tainacan_get_the_media_component_slide(array( tainacan_get_the_media_component_slide(array(
'after_slide_metadata' => (( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && tainacan_the_item_document_download_link() != '' ) ? 'after_slide_metadata' => (( !$hide_download_button && tainacan_the_item_document_download_link() != '' ) ?
('<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>') ('<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>')
: ''), : ''),
'media_content' => tainacan_get_the_document(), 'media_content' => tainacan_get_the_document(),
@ -106,6 +96,12 @@ if ( tainacan_has_document() && !get_theme_mod( 'tainacan_single_item_gallery_mo
) )
); );
} else {
?>
<div style="text-aling: center; max-width: 600px; margin: 2em auto; width: 100%; font-style: italic;">
<p><?php __('It seems that you are using a legacy vesion of the Tainacan plugin. Please update in order to use the latest features for displaying item media.', 'tainacan-interface') ?></p>
</div>
<?php
}?> }?>
</div> </div>
</section> </section>