diff --git a/tainacan-blocksy/inc/options/posts/tainacan-item-single.php b/tainacan-blocksy/inc/options/posts/tainacan-item-single.php index d583c43..6ff0d31 100644 --- a/tainacan-blocksy/inc/options/posts/tainacan-item-single.php +++ b/tainacan-blocksy/inc/options/posts/tainacan-item-single.php @@ -29,4 +29,11 @@ $options = [ blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/metadata-list.php', [ 'prefix' => $post_type->name . '_single', ], false) -]; \ No newline at end of file +]; + +if ( function_exists('tainacan_the_related_items_carousel') ) { + $options[] = blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/items-related-to-this.php', [ + 'prefix' => $post_type->name . '_single', + 'enabled' => 'no' + ], false); +} \ No newline at end of file diff --git a/tainacan-blocksy/inc/options/single-elements/attachments-size.php b/tainacan-blocksy/inc/options/single-elements/attachments-size.php index 9d7c0c6..f7cb831 100644 --- a/tainacan-blocksy/inc/options/single-elements/attachments-size.php +++ b/tainacan-blocksy/inc/options/single-elements/attachments-size.php @@ -16,7 +16,7 @@ $options = [ 'units' => blocksy_units_config([ [ 'unit' => 'px', - 'min' => 80, + 'min' => 42, 'max' => 200, ] ]), diff --git a/tainacan-blocksy/inc/options/single-elements/items-related-to-this.php b/tainacan-blocksy/inc/options/single-elements/items-related-to-this.php new file mode 100644 index 0000000..ba4bb82 --- /dev/null +++ b/tainacan-blocksy/inc/options/single-elements/items-related-to-this.php @@ -0,0 +1,34 @@ + [ + 'label' => __( 'Display "Items related to this"', 'tainacan-blocksy' ), + 'type' => 'ct-panel', + 'switch' => true, + 'value' => $enabled, + 'sync' => blocksy_sync_whole_page([ + 'prefix' => $prefix, + ]), + 'inner-options' => [ + $prefix . 'items_related_to_this_max_items_per_screen' => [ + 'label' => __( 'Max amount of items per slide', 'blocksy' ), + 'type' => 'ct-number', + 'design' => 'inline', + 'value' => 6, + 'min' => 1, + 'max' => 10, + 'sync' => '' + ], + ] + ] +]; \ No newline at end of file diff --git a/tainacan-blocksy/inc/options/single-elements/section-labels.php b/tainacan-blocksy/inc/options/single-elements/section-labels.php index 6402b8b..79b95b8 100644 --- a/tainacan-blocksy/inc/options/single-elements/section-labels.php +++ b/tainacan-blocksy/inc/options/single-elements/section-labels.php @@ -115,7 +115,25 @@ $options = [ 'sync' => blocksy_sync_single_post_container([ 'prefix' => $prefix ]) - ] + ], + blocksy_rand_md5() => [ + 'type' => 'ct-condition', + 'condition' => [ + $prefix . 'display_items_related_to_this' => 'yes', + ], + 'options' => [ + $prefix . 'section_items_related_to_this_label' => [ + 'label' => __( 'Label for the "Items related to this" section', 'tainacan-blocksy' ), + 'desc' => __( 'Leave it blank for not displaying any label.', 'tainacan-blocksy' ), + 'type' => 'text', + 'design' => 'block', + 'value' => __( 'Items related to this', 'tainacan-blocksy' ), + 'sync' => blocksy_sync_single_post_container([ + 'prefix' => $prefix + ]) + ], + ] + ], ], ], ]; diff --git a/tainacan-blocksy/tainacan/item-single-page.php b/tainacan-blocksy/tainacan/item-single-page.php index 620cebd..a977d91 100644 --- a/tainacan-blocksy/tainacan/item-single-page.php +++ b/tainacan-blocksy/tainacan/item-single-page.php @@ -11,6 +11,7 @@ $prefix = blocksy_manager()->screen->get_prefix(); $page_structure_type = get_theme_mod( $prefix . '_page_structure_type', 'type-dam'); $template_columns_style = ''; +$display_items_related_to_this = get_theme_mod( $prefix . '_display_items_related_to_this', 'no' ) === 'yes'; if ($page_structure_type == 'type-gm' || $page_structure_type == 'type-mg') { $column_documents_attachments_width = 60; @@ -85,6 +86,11 @@ add_action( 'blocksy:single:top', function() use ( $page_structure_type, $prefix tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-metadata' ); do_action( 'tainacan-blocksy-single-item-after-metadata' ); + + if ($display_items_related_to_this) { + tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-items-related-to-this' ); + do_action( 'tainacan-blocksy-single-item-after-items-related-to-this' ); + } ?> diff --git a/tainacan-blocksy/template-parts/tainacan-item-single-items-related-to-this.php b/tainacan-blocksy/template-parts/tainacan-item-single-items-related-to-this.php new file mode 100644 index 0000000..da867b6 --- /dev/null +++ b/tainacan-blocksy/template-parts/tainacan-item-single-items-related-to-this.php @@ -0,0 +1,30 @@ +screen->get_prefix(); + + $section_label = get_theme_mod($prefix . '_section_items_related_to_this_label', __( 'Items related to this', 'tainacan-blocksy' )); + $max_items_per_screen = get_theme_mod($prefix . '_items_related_to_this_max_items_per_screen', 6); + + if ( function_exists('tainacan_the_related_items_carousel') && (get_theme_mod( $prefix . '_display_items_related_to_this', 'no' ) === 'yes') && tainacan_has_related_items() ) : ?> + + + \ No newline at end of file