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'; - } - - ?> - -
> -
> - -
- - screen->get_prefix(); - - $has_share_box = get_theme_mod( - $prefix . '_has_share_box', - $prefix === 'single_blog_post' ? 'yes' : 'no' - ) === 'yes'; - - if (blocksy_is_page()) { - $has_share_box = false; - } - - $has_author_box = get_theme_mod( - $prefix . '_has_author_box', - 'no' - ) === 'yes'; - - $has_post_tags = get_theme_mod('has_post_tags', 'yes') === 'yes'; - $has_post_nav = get_theme_mod( - $prefix . '_has_post_nav', - $prefix === 'single_blog_post' ? 'yes' : 'no' - ) === 'yes'; - - if (blocksy_is_page()) { - $has_author_box = false; - $has_post_nav = false; - } - - if ( - blocksy_default_akg( - 'disable_posts_navigation', $post_options, 'no' - ) === 'yes' - ) { - $has_post_nav = false; - } - - if ( - blocksy_default_akg( - 'disable_author_box', $post_options, 'no' - ) === 'yes' - ) { - $has_author_box = false; - } - - if ( - blocksy_default_akg( - 'disable_post_tags', $post_options, 'no' - ) === 'yes' - ) { - $has_post_tags = false; - } - - if ( - blocksy_default_akg( - 'disable_share_box', $post_options, 'no' - ) === 'yes' - ) { - $has_share_box = false; - } - - $featured_image_location = 'none'; - - $page_title_source = blocksy_get_page_title_source(); - $featured_image_source = blocksy_get_featured_image_source(); - - if ($page_title_source) { - $actual_type = blocksy_akg_or_customizer( - 'hero_section', - blocksy_get_page_title_source(), - 'type-1' - ); - - if ($actual_type !== 'type-2') { - $featured_image_location = get_theme_mod( - $prefix . '_featured_image_location', - 'above' - ); - } else { - $featured_image_location = 'below'; - } - } else { - $featured_image_location = 'above'; - } - - $share_box_type = get_theme_mod($prefix . '_share_box_type', 'type-1'); - - $share_box1_location = get_theme_mod($prefix . '_share_box1_location', [ - 'top' => false, - 'bottom' => true, - ]); - - $share_box2_location = get_theme_mod($prefix . '_share_box2_location', 'right'); - - $content_editor = blocksy_get_entry_content_editor(); - - $content_class = 'entry-content'; - - if ( - strpos($content_editor, 'classic') === false - && - strpos($content_editor, 'default') === false - ) { - $content_class = 'ct-builder-content'; - } - - ob_start(); - - ?> - -
- > - - - - - $share_box_type === 'type-1' ? [ - 'data-location' => 'top' - ] : [ - 'data-location' => $share_box2_location, - ], - 'type' => $share_box_type - ]); - ?> - - -
- '; - - 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 '
'; - ?> - - - -
- - "%s"', 'blocksy' ), - get_the_title() - ) - ); - } - - wp_link_pages( - [ - 'before' => '', - ] - ); - ?> - - - 'entry-tags'], - blocksy_get_categories_list('', false) - ); - } - ?> - - - - ['data-location' => 'bottom'], - 'type' => 'type-1' - ]); - ?> - - - - - - - - - - -
- - - -