From b94445a42063873370bd1314a00a1e690fc29a08 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Mon, 6 Sep 2021 15:32:35 -0300 Subject: [PATCH] Adds option to disable photoswiper on the media component gallery. --- src/functions/customizer.php | 20 +++++++++++++++++++ .../single-items-attachments_new.php | 10 ++++++++-- src/template-parts/single-items-document.php | 8 ++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/functions/customizer.php b/src/functions/customizer.php index dd417b8..7fea3ab 100644 --- a/src/functions/customizer.php +++ b/src/functions/customizer.php @@ -745,6 +745,25 @@ function tainacan_customize_register( $wp_customize ) { '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' ) ) ); + + /** + * 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' ) ) ); + /** * Light color palette to the media component gallery */ diff --git a/src/template-parts/single-items-attachments_new.php b/src/template-parts/single-items-attachments_new.php index 1f40cfb..98c86d8 100644 --- a/src/template-parts/single-items-attachments_new.php +++ b/src/template-parts/single-items-attachments_new.php @@ -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_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); +$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() ) ) { ?> @@ -111,14 +112,19 @@ if ( !empty( $attachments ) || ( get_theme_mod( 'tainacan_single_item_gallery_m '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, ) ); ?> diff --git a/src/template-parts/single-items-document.php b/src/template-parts/single-items-document.php index 8e24b33..6d4433f 100644 --- a/src/template-parts/single-items-document.php +++ b/src/template-parts/single-items-document.php @@ -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_description = get_theme_mod('tainacan_single_item_hide_files_description_main', true); $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 = ''; @@ -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() != '' ) echo '' . tainacan_the_item_document_download_link() . ''; - if ( version_compare(TAINACAN_VERSION, '0.18RC') >= 0 ) {?> + if ( version_compare(TAINACAN_VERSION, '0.18RC') >= 0 ) { ?>