diff --git a/includes/assets/js/kb-splide-init.min.js b/includes/assets/js/kb-splide-init.min.js index f7f3ee09e..a940b8737 100644 --- a/includes/assets/js/kb-splide-init.min.js +++ b/includes/assets/js/kb-splide-init.min.js @@ -1 +1 @@ -(function(){"use strict";var a={initAll(){const a=document.querySelectorAll(".wp-block-kadence-advancedgallery .kt-blocks-carousel-init");this.bootstrapSliders(a);const b=document.querySelectorAll(".wp-block-kadence-testimonials .kt-blocks-carousel-init");this.bootstrapSliders(b);const c=document.querySelectorAll(".kb-blocks-bg-slider > .kt-blocks-carousel-init");this.bootstrapSliders(c)},bootstrapSliders(a){if(a&&0!==a.length)for(let c=0;c=e?0:Math.floor(e/2),arrows:!!(1{const d=parseInt(a[c]);return Number.isNaN(d)||c.includes("sliderGap")?"true"===a[c]||"false"===a[c]?{...b,[c]:JSON.parse(a[c])}:{...b,[c]:a[c]}:{...b,[c]:d}},{})},createSplideElements(a){const b=a.children.length;for(const b of a.children)b.classList.add("splide__slide"),b.classList.contains("last")&&b.classList.remove("last");const c=document.createElement("div");c.classList.add("splide__track");const d=document.createElement("div");return d.classList.add("splide__list"),d.innerHTML=a.innerHTML,c.innerHTML=d.outerHTML,a.innerHTML=c.outerHTML,a.classList.add("splide"),b},getSplideOptions(a){const b=1===a.sliderScroll&&1,c={trimSpace:!0,drag:!0,perPage:a.columnsXxl||1,type:a.sliderFade?"fade":"loop",easing:a.sliderAnimSpeed&&1e3 .kt-blocks-carousel-init");this.bootstrapSliders(c)},bootstrapSliders(a){if(a&&0!==a.length)for(let c=0;c=e?0:Math.floor(e/2),arrows:!!(1{const d=parseInt(a[c]);return Number.isNaN(d)||c.includes("sliderGap")?"true"===a[c]||"false"===a[c]?{...b,[c]:JSON.parse(a[c])}:{...b,[c]:a[c]}:{...b,[c]:d}},{})},createSplideElements(a){const b=a.children.length;for(const b of a.children)b.classList.add("splide__slide"),b.classList.contains("last")&&b.classList.remove("last");const c=document.createElement("div");c.classList.add("splide__track");const d=document.createElement("div");return d.classList.add("splide__list"),d.innerHTML=a.innerHTML,c.innerHTML=d.outerHTML,a.innerHTML=c.outerHTML,a.classList.add("splide"),b},getSplideOptions(a){const b=1===a.sliderScroll&&1,c={trimSpace:!0,drag:!0,perPage:a.columnsXxl||1,type:a.sliderFade?"fade":"loop",easing:a.sliderAnimSpeed&&1e3 __('Display this image in a lightbox', 'kadence-blocks'), ) ); + wp_localize_script( + 'kadence-blocks-splide-init', + 'kb_splide', + array( + 'i18n' => array( + 'prev' => __( 'Previous slide', 'kadence-blocks' ), + 'next' => __( 'Next slide', 'kadence-blocks' ), + 'first' => __( 'Go to first slide', 'kadence-blocks' ), + 'last' => __( 'Go to last slide', 'kadence-blocks' ), + 'slideX' => __( 'Go to slide %s', 'kadence-blocks' ), + 'pageX' => __( 'Go to page %s', 'kadence-blocks' ), + 'play' => __( 'Start autoplay', 'kadence-blocks' ), + 'pause' => __( 'Pause autoplay', 'kadence-blocks' ), + 'carousel' => __( 'carousel', 'kadence-blocks' ), + 'slide' => __( 'slide', 'kadence-blocks' ), + 'select' => __( 'Select a slide to show', 'kadence-blocks' ), + 'slideLabel' => __( '%s of %s', 'kadence-blocks' ), + ), + ) + ); } } diff --git a/includes/blocks/class-kadence-blocks-row-layout-block.php b/includes/blocks/class-kadence-blocks-row-layout-block.php index bb1a68e7a..87d5fc44e 100644 --- a/includes/blocks/class-kadence-blocks-row-layout-block.php +++ b/includes/blocks/class-kadence-blocks-row-layout-block.php @@ -1711,6 +1711,26 @@ public function register_scripts() { wp_register_script( 'kad-splide', KADENCE_BLOCKS_URL . 'includes/assets/js/splide.min.js', array(), KADENCE_BLOCKS_VERSION, true ); wp_register_script( 'kadence-blocks-splide-init', KADENCE_BLOCKS_URL . 'includes/assets/js/kb-splide-init.min.js', array( 'kad-splide' ), KADENCE_BLOCKS_VERSION, true ); wp_register_script( 'kadence-blocks-video-bg', KADENCE_BLOCKS_URL . 'includes/assets/js/kb-init-html-bg-video.min.js', array(), KADENCE_BLOCKS_VERSION, true ); + wp_localize_script( + 'kadence-blocks-splide-init', + 'kb_splide', + array( + 'i18n' => array( + 'prev' => __( 'Previous slide', 'kadence-blocks' ), + 'next' => __( 'Next slide', 'kadence-blocks' ), + 'first' => __( 'Go to first slide', 'kadence-blocks' ), + 'last' => __( 'Go to last slide', 'kadence-blocks' ), + 'slideX' => __( 'Go to slide %s', 'kadence-blocks' ), + 'pageX' => __( 'Go to page %s', 'kadence-blocks' ), + 'play' => __( 'Start autoplay', 'kadence-blocks' ), + 'pause' => __( 'Pause autoplay', 'kadence-blocks' ), + 'carousel' => __( 'carousel', 'kadence-blocks' ), + 'slide' => __( 'slide', 'kadence-blocks' ), + 'select' => __( 'Select a slide to show', 'kadence-blocks' ), + 'slideLabel' => __( '%s of %s', 'kadence-blocks' ), + ), + ) + ); } } diff --git a/includes/blocks/class-kadence-blocks-testimonials-block.php b/includes/blocks/class-kadence-blocks-testimonials-block.php index 970ef920d..851ba1305 100644 --- a/includes/blocks/class-kadence-blocks-testimonials-block.php +++ b/includes/blocks/class-kadence-blocks-testimonials-block.php @@ -910,6 +910,26 @@ public function register_scripts() { wp_register_style( 'kadence-blocks-splide', KADENCE_BLOCKS_URL . 'includes/assets/css/kb-blocks-splide.min.css', array( 'kadence-kb-splide' ), KADENCE_BLOCKS_VERSION ); wp_register_script( 'kad-splide', KADENCE_BLOCKS_URL . 'includes/assets/js/splide.min.js', array(), KADENCE_BLOCKS_VERSION, true ); wp_register_script( 'kadence-blocks-splide-init', KADENCE_BLOCKS_URL . 'includes/assets/js/kb-splide-init.min.js', array( 'kad-splide' ), KADENCE_BLOCKS_VERSION, true ); + wp_localize_script( + 'kadence-blocks-splide-init', + 'kb_splide', + array( + 'i18n' => array( + 'prev' => __( 'Previous slide', 'kadence-blocks' ), + 'next' => __( 'Next slide', 'kadence-blocks' ), + 'first' => __( 'Go to first slide', 'kadence-blocks' ), + 'last' => __( 'Go to last slide', 'kadence-blocks' ), + 'slideX' => __( 'Go to slide %s', 'kadence-blocks' ), + 'pageX' => __( 'Go to page %s', 'kadence-blocks' ), + 'play' => __( 'Start autoplay', 'kadence-blocks' ), + 'pause' => __( 'Pause autoplay', 'kadence-blocks' ), + 'carousel' => __( 'carousel', 'kadence-blocks' ), + 'slide' => __( 'slide', 'kadence-blocks' ), + 'select' => __( 'Select a slide to show', 'kadence-blocks' ), + 'slideLabel' => __( '%s of %s', 'kadence-blocks' ), + ), + ) + ); } } diff --git a/src/assets/js/kb-splide-init.js b/src/assets/js/kb-splide-init.js index 0a675526b..235c34a3e 100644 --- a/src/assets/js/kb-splide-init.js +++ b/src/assets/js/kb-splide-init.js @@ -280,6 +280,20 @@ prev: 'splide__arrow--prev slick-prev', next: 'splide__arrow--next slick-next', }, + i18n: { + prev: kb_splide?.i18n?.prev, + next: kb_splide?.i18n?.next, + first: kb_splide?.i18n?.first, + last: kb_splide?.i18n?.last, + slideX: kb_splide?.i18n?.slideX, + pageX: kb_splide?.i18n?.pageX, + play: kb_splide?.i18n?.play, + pause: kb_splide?.i18n?.pause, + carousel: kb_splide?.i18n?.carousel, + slide: kb_splide?.i18n?.slide, + select: kb_splide?.i18n?.select, + slideLabel: kb_splide?.i18n?.slideLabel, + }, }; if (splideOpts.perPage === 1 || scrollIsOne) {