Automattic\WooCommerce\Blocks\BlockTypes
ProductGalleryPager::render()
Include and render the block.
Метод класса: ProductGalleryPager{}
Хуков нет.
Возвращает
Строку
. 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.
Код ProductGalleryPager::render() ProductGalleryPager::render WC 9.6.0
protected function render( $attributes, $content, $block ) { $pager_display_mode = $block->context['pagerDisplayMode'] ?? ''; if ( 'off' === $pager_display_mode ) { return null; } $number_of_thumbnails = $block->context['thumbnailsNumberOfThumbnails'] ?? 0; $wrapper_attributes = get_block_wrapper_attributes(); $post_id = $block->context['postId'] ?? ''; $product = wc_get_product( $post_id ); if ( $product ) { $product_gallery_images_ids = ProductGalleryUtils::get_product_gallery_image_ids( $product ); $number_of_available_images = count( $product_gallery_images_ids ); $number_of_thumbnails = $number_of_thumbnails < $number_of_available_images ? $number_of_thumbnails : $number_of_available_images; if ( $number_of_thumbnails > 1 ) { $html = $this->render_pager( $product_gallery_images_ids, $pager_display_mode, $number_of_thumbnails ); return sprintf( '<div %1$s data-wc-interactive=\'%3$s\'> %2$s </div>', $wrapper_attributes, $html, wp_json_encode( array( 'namespace' => 'woocommerce/product-gallery' ), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ) ); } return ''; } }