Automattic\WooCommerce\Blocks\BlockTypes
ProductImageGallery::render()
Include and render the block.
Метод класса: ProductImageGallery{}
Хуков нет.
Возвращает
Строку
. Rendered block type output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render( $attributes, $content, $block );
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array - $content(строка) (обязательный)
- Block content.
По умолчанию: empty string - $block(WP_Block) (обязательный)
- Block instance.
Код ProductImageGallery::render() ProductImageGallery::render WC 7.7.2
protected function render( $attributes, $content, $block ) { $post_id = $block->context['postId']; global $product; $product = wc_get_product( $post_id ); if ( class_exists( 'WC_Frontend_Scripts' ) ) { $frontend_scripts = new \WC_Frontend_Scripts(); $frontend_scripts::load_scripts(); } $classname = $attributes['className'] ?? ''; 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(); return sprintf( '<div class="wp-block-woocommerce-product-image-gallery %1$s">%2$s %3$s</div>', esc_attr( $classname ), $sale_badge_html, $product_image_gallery_html ); }