diff --git a/functions.php b/functions.php index 3f0c470..df0e2bd 100644 --- a/functions.php +++ b/functions.php @@ -192,6 +192,24 @@ function blocksy_tainacan_custom_post_types_supported_list( $potential_post_type } add_filter( 'blocksy:custom_post_types:supported_list', 'blocksy_tainacan_custom_post_types_supported_list', 10 ); +/** + * Renders the item single page with a custom template that will use most of Blocksy features + */ +function filter_the_content_in_the_main_loop( $content ) { + + if ( defined ('TAINACAN_VERSION') ) { + $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers(); + $post_type = get_post_type(); + + // Check if we're inside the main loop in a single Post. + if (in_array($post_type, $collections_post_types) && is_singular() && in_the_loop() && is_main_query() ) { + return get_template_part( 'tainacan/item-single-page' ); + } + } + + return $content; +} +add_filter( 'the_content', 'filter_the_content_in_the_main_loop'); /** * Enqueues js scripts related to swiper, only if in TainacanSingleItem pages diff --git a/inc/options/single-elements/hide-download-button.php b/inc/options/single-elements/hide-download-button.php index 38c7400..b7d8453 100644 --- a/inc/options/single-elements/hide-download-button.php +++ b/inc/options/single-elements/hide-download-button.php @@ -12,7 +12,7 @@ if (! isset($enabled)) { $options = [ $prefix . 'hide_download_button' => [ - 'label' => __( ' Document download button', 'blocksy-tainacan' ), + 'label' => __( 'Hide document download button', 'blocksy-tainacan' ), 'type' => 'ct-switch', 'value' => $enabled, 'setting' => [ 'transport' => 'postMessage' ], diff --git a/js/attachments-carousel.js b/js/attachments-carousel.js index 7dce8ba..53b97b9 100644 --- a/js/attachments-carousel.js +++ b/js/attachments-carousel.js @@ -1,6 +1,33 @@ const attachmentsThumbsSwiper = new Swiper('.swiper-container-thumbs', { - spaceBetween: 10, + spaceBetween: 15, slidesPerView: 7, + // Responsive breakpoints + breakpoints: { + // when window width is >= 320px + 320: { + slidesPerView: 1 + }, + // when window width is >= 480px + 480: { + slidesPerView: 2 + }, + // when window width is >= 640px + 768: { + slidesPerView: 3 + }, + // when window width is >= 640px + 960: { + slidesPerView: 4 + }, + // when window width is >= 640px + 1024: { + slidesPerView: 5 + }, + // when window width is >= 640px + 1280: { + slidesPerView: 6 + } + }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', diff --git a/tainacan/item-single-page.php b/tainacan/item-single-page.php new file mode 100644 index 0000000..f75c76d --- /dev/null +++ b/tainacan/item-single-page.php @@ -0,0 +1,52 @@ +'; + +switch (get_theme_mod( 'tainacan_single_item_layout_sections_order', 'document-attachments-metadata')) { + case 'document-attachments-metadata': + get_template_part( 'template-parts/single-items-document' ); + do_action( 'blocksy-tainacan-single-item-after-document' ); + + get_template_part( 'template-parts/single-items-attachments' ); + do_action( 'blocksy-tainacan-single-item-after-attachments' ); + + get_template_part( 'template-parts/single-items-metadata' ); + do_action( 'blocksy-tainacan-single-item-after-metadata' ); + break; + + case 'metadata-document-attachments': + get_template_part( 'template-parts/single-items-metadata' ); + do_action( 'blocksy-tainacan-single-item-after-metadata' ); + + get_template_part( 'template-parts/single-items-document' ); + do_action( 'blocksy-tainacan-single-item-after-document' ); + + get_template_part( 'template-parts/single-items-attachments' ); + do_action( 'blocksy-tainacan-single-item-after-attachments' ); + break; + + case 'document-metadata-attachments': + get_template_part( 'template-parts/single-items-document' ); + do_action( 'blocksy-tainacan-single-item-after-document' ); + + get_template_part( 'template-parts/single-items-metadata' ); + do_action( 'blocksy-tainacan-single-item-after-metadata' ); + + get_template_part( 'template-parts/single-items-attachments' ); + do_action( 'blocksy-tainacan-single-item-after-attachments' ); + break; + +} +echo ''; + +do_action( 'blocksy-tainacan-single-item-bottom' ); ?> diff --git a/tainacan/single-items.php b/tainacan/single-items.php deleted file mode 100644 index 99873b6..0000000 --- a/tainacan/single-items.php +++ /dev/null @@ -1,398 +0,0 @@ - blocksy_default_akg( - 'page_structure_type', - blocksy_get_post_options(), - 'default' - ) - ], - '' - ); - } - ); - } - - if (have_posts()) { - the_post(); - } - - /** - * Note to code reviewers: This line doesn't need to be escaped. - * Function blocksy_output_hero_section() used here escapes the value properly. - */ - echo blocksy_output_hero_section('type-2'); - - $container_class = 'ct-container'; - - if (blocksy_get_page_structure() === 'narrow') { - $container_class = 'ct-container-narrow'; - } - - $content_area_class = 'content-area'; - - $post_content = get_the_content(); - $content_style = blocksy_get_content_style(); - - if ( - ( - strpos($post_content, 'alignwide') !== false - || - strpos($post_content, 'alignfull') !== false - ) - && - blocksy_sidebar_position() === 'none' - && - blocksy_get_content_style() !== 'boxed' - ) { - $content_area_class .= ' content-area-wide'; - } - - ?> - -