Adds option to disable photoswiper on the media component gallery.

This commit is contained in:
mateuswetah 2021-09-06 15:32:35 -03:00
parent 92fdb57171
commit b94445a420
3 changed files with 34 additions and 4 deletions

View File

@ -745,6 +745,25 @@ function tainacan_customize_register( $wp_customize ) {
'label' => __( 'Show "Documents" section: Document and Attachments grouped in one slider.', 'tainacan-interface' ), 'label' => __( 'Show "Documents" section: Document and Attachments grouped in one slider.', 'tainacan-interface' ),
'description' => __( 'Toggle to show the document and attachments in the same list, a carousel with the current item on top.', 'tainacan-interface' ) 'description' => __( 'Toggle to show the document and attachments in the same list, a carousel with the current item on top.', 'tainacan-interface' )
) ); ) );
/**
* Disable gallery lightbox.
*/
$wp_customize->add_setting( 'tainacan_single_item_disable_gallery_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_disable_gallery_lightbox', array(
'type' => 'checkbox',
'priority' => 0, // Within the section.
'section' => 'tainacan_single_item_page_document',
'label' => __( 'Disable the gallery lightbox modal', 'tainacan-interface' ),
'description' => __( 'Toggle to not display a modal with the main slider when clicking in a gallery item of the "Documents" section.', 'tainacan-interface' )
) );
} }
/** /**
@ -1052,6 +1071,7 @@ function tainacan_customize_register( $wp_customize ) {
'description' => __( 'Toggle to not display the document and attachments description.', 'tainacan-interface' ) 'description' => __( 'Toggle to not display the document and attachments description.', 'tainacan-interface' )
) ); ) );
/** /**
* Light color palette to the media component gallery * Light color palette to the media component gallery
*/ */

View File

@ -5,6 +5,7 @@ $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);
$disable_gallery_lightbox = get_theme_mod('tainacan_single_item_disable_gallery_lightbox', false);
if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_mode', false) && tainacan_has_document() ) ) { if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_mode', false) && tainacan_has_document() ) ) {
?> ?>
@ -111,14 +112,19 @@ if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_m
'navigation' => array( 'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-thumbs', 'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-thumbs',
'prevEl' => '.swiper-navigation-prev_' . '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( 'swiper_main_options' => $is_gallery_mode ? array(
'navigation' => array( 'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-main', 'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-attachments_id-' . $post->ID . '-main',
'prevEl' => '.swiper-navigation-prev_' . '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,
) )
); );
?> ?>

View File

@ -5,6 +5,7 @@ if (version_compare(TAINACAN_VERSION, '0.18RC') >= 0) {
$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);
$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);
$class_slide_metadata = ''; $class_slide_metadata = '';
@ -34,7 +35,7 @@ if ( tainacan_has_document() && !get_theme_mod( 'tainacan_single_item_gallery_mo
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() != '' ) 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() != '' )
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>'; echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>';
if ( version_compare(TAINACAN_VERSION, '0.18RC') >= 0 ) {?> if ( version_compare(TAINACAN_VERSION, '0.18RC') >= 0 ) { ?>
<div class="document-metadata <?php echo $class_slide_metadata ?>"> <div class="document-metadata <?php echo $class_slide_metadata ?>">
<?php if ( !$hide_file_caption && $is_document_type_attachment ): ?> <?php if ( !$hide_file_caption && $is_document_type_attachment ): ?>
<span class="document-metadata__caption"> <span class="document-metadata__caption">
@ -97,8 +98,11 @@ if ( tainacan_has_document() && !get_theme_mod( 'tainacan_single_item_gallery_mo
'navigation' => array( 'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-document_id-' . $post->ID . '-main', 'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-document_id-' . $post->ID . '-main',
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-document_id-' . $post->ID . '-main', 'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-document_id-' . $post->ID . '-main',
'preloadImages' => false,
'lazy' => true
) )
) ),
'disable_lightbox' => $disable_gallery_lightbox
) )
); );