diff --git a/tainacan-blocksy/inc/enqueues.php b/tainacan-blocksy/inc/enqueues.php index ecef6b1..ae3a63f 100644 --- a/tainacan-blocksy/inc/enqueues.php +++ b/tainacan-blocksy/inc/enqueues.php @@ -19,8 +19,7 @@ function tainacan_blocksy_enqueue_scripts() { // This should only happen if we have Tainacan plugin installed if ( defined ('TAINACAN_VERSION') ) { - // $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers(); - // $post_type = get_post_type(); + wp_enqueue_script( 'tainacan-blocksy-scripts', TAINACAN_BLOCKSY_PLUGIN_URL_PATH . '/js/scripts.js', array(), TAINACAN_BLOCKSY_VERSION, true ); } } 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 index ba4bb82..d759840 100644 --- a/tainacan-blocksy/inc/options/single-elements/items-related-to-this.php +++ b/tainacan-blocksy/inc/options/single-elements/items-related-to-this.php @@ -20,15 +20,64 @@ $options = [ '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' => '' + $prefix . 'items_related_to_this_layout' => [ + 'label' => false, + 'type' => 'ct-image-picker', + 'value' => 'carousel', + 'design' => 'block', + 'setting' => [ 'transport' => 'postMessage' ], + 'choices' => [ + 'carousel' => [ + 'src' => tainacan_blocksy_image_picker_url( 'items-carousel.svg' ), + 'title' => __( 'Carousel', 'tainacan-blocksy' ), + ], + 'grid' => [ + 'src' => tainacan_blocksy_image_picker_url( 'items-grid.svg' ), + 'title' => __( 'Grid', 'tainacan-blocksy' ), + ], + 'list' => [ + 'src' => tainacan_blocksy_image_picker_url( 'items-list.svg' ), + 'title' => __( 'List', 'tainacan-blocksy' ), + ], + ], + 'sync' => blocksy_sync_single_post_container([ + 'prefix' => $prefix + ]) ], + blocksy_rand_md5() => [ + 'type' => 'ct-condition', + 'condition' => [ + $prefix . 'items_related_to_this_layout' => 'carousel' + ], + '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' => '' + ] + ] + ], + blocksy_rand_md5() => [ + 'type' => 'ct-condition', + 'condition' => [ + $prefix . 'items_related_to_this_layout' => 'grid | list' + ], + 'options' => [ + $prefix . 'items_related_to_this_max_column_count' => [ + 'label' => __( 'Max amount of items columns', 'blocksy' ), + 'type' => 'ct-number', + 'design' => 'inline', + 'value' => 4, + 'min' => 1, + 'max' => 8, + 'sync' => '' + ] + ] + ] ] ] ]; \ No newline at end of file diff --git a/tainacan-blocksy/js/scripts.js b/tainacan-blocksy/js/scripts.js index eff3f6e..74212e8 100644 --- a/tainacan-blocksy/js/scripts.js +++ b/tainacan-blocksy/js/scripts.js @@ -1,6 +1,12 @@ // Scripts that run on document load need to be manually refreshed when inside the customizer -if (window.ctEvents && window.ctEvents.default) { - window.ctEvents.default.on('blocksy:frontend:init', () => { +if (window.ctEvents) { + + if ( window.ctEvents.default ) + window.ctEvents.default.on('blocksy:frontend:init', onBlocksyFrontendInit); + else + window.ctEvents.on('blocksy:frontend:init', onBlocksyFrontendInit); + + function onBlocksyFrontendInit() { /* Handles updating Media Items component */ if (tainacan_plugin?.classes?.TainacanMediaGallery && tainacan_plugin?.tainacan_media_components) { @@ -18,5 +24,9 @@ if (window.ctEvents && window.ctEvents.default) { /* Handles updating Items carousel */ document.dispatchEvent(new Event('TainacanReloadCarouselItemsListBlock')); - }); + + /* Handles Dynamic Items lists */ + document.dispatchEvent(new Event('TainacanReloadDynamicItemsBlock')); + + } } \ No newline at end of file diff --git a/tainacan-blocksy/static/images/items-carousel.svg b/tainacan-blocksy/static/images/items-carousel.svg new file mode 100644 index 0000000..0300b5d --- /dev/null +++ b/tainacan-blocksy/static/images/items-carousel.svg @@ -0,0 +1,122 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tainacan-blocksy/static/images/items-grid.svg b/tainacan-blocksy/static/images/items-grid.svg new file mode 100644 index 0000000..6811dfe --- /dev/null +++ b/tainacan-blocksy/static/images/items-grid.svg @@ -0,0 +1,122 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tainacan-blocksy/static/images/items-list.svg b/tainacan-blocksy/static/images/items-list.svg new file mode 100644 index 0000000..5981532 --- /dev/null +++ b/tainacan-blocksy/static/images/items-list.svg @@ -0,0 +1,196 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 index da867b6..5249e24 100644 --- 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 @@ -1,8 +1,10 @@ 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); + $section_label = get_theme_mod( $prefix . '_section_items_related_to_this_label', __( 'Items related to this', 'tainacan-blocksy' ) ); + $items_related_to_this_layout = get_theme_mod( $prefix . '_items_related_to_this_layout', 'carousel' ); + $max_columns_count = get_theme_mod( $prefix . '_items_related_to_this_max_columns_count', 4 ); + $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() ) : ?> @@ -16,9 +18,11 @@