array( 'data' => array( 'spaceBetween' => 10, 'slidesPerView' => 1, 'breakpoints' => array( '1000' => array( 'slidesPerView' => 2, ), ), ), ), ); return $data; } /** * Override Gutenberg code to render post featured image. * Return placeholder when there is no featured image. */ public function render_callback( $attributes, $content, $block ) { $post_id = $block->context['postId']; if ( ! isset( $post_id ) ) { return ''; } global $product; $previous_product = $product; $product = wc_get_product( $post_id ); if ( ! $product instanceof \WC_Product ) { $product = $previous_product; return ''; } if ( class_exists( 'WC_Frontend_Scripts' ) ) { $frontend_scripts = new \WC_Frontend_Scripts(); $frontend_scripts::load_scripts(); } ob_start(); woocommerce_show_product_sale_flash(); $sale_badge_html = ob_get_clean(); ob_start(); woocommerce_show_product_images(); $product_image_gallery_html = ob_get_clean(); $can_editable = ! empty( $attributes['className'] ) && false !== strpos( $attributes['className'], 'brandy-product-image-gallery' ); $navigation = ' '; $product = $previous_product; $classname = $attributes['className'] ?? ''; $content = sprintf( '', esc_attr( $classname ), $sale_badge_html, $product_image_gallery_html, $can_editable ? $navigation : '' ); if ( ! $can_editable ) { return $content; } $content = str_replace( array( 'woocommerce-product-gallery__wrapper', 'woocommerce-product-gallery__image' ), array( 'woocommerce-product-gallery__wrapper swiper-wrapper', 'woocommerce-product-gallery__image swiper-slide' ), $content ); return $content; } public function enqueue_scripts() { wp_enqueue_script( 'brandy/woocommerce-product-image-gallery', BRANDY_TEMPLATE_URL . '/inc/Blocks/Assets/product-image-gallery.js', array( 'jquery' ), BRANDY_SCRIPT_VERSION, true ); } }