Automattic\WooCommerce\Blocks\BlockTypes

FeaturedItem::render()protectedWC 1.0

Render the featured item block.

Метод класса: FeaturedItem{}

Хуков нет.

Возвращает

Строку. Rendered block type output.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render( $attributes, $content, $block );
$attributes(массив) (обязательный)
Block attributes.
$content(строка) (обязательный)
Block content.
$block(WP_Block) (обязательный)
Block instance.

Код FeaturedItem::render() WC 8.7.0

protected function render( $attributes, $content, $block ) {
	$item = $this->get_item( $attributes );
	if ( ! $item ) {
		return '';
	}

	$attributes = wp_parse_args( $attributes, $this->defaults );

	$attributes['height'] = $attributes['height'] ?? wc_get_theme_support( 'featured_block::default_height', 500 );

	$image_url = esc_url( $this->get_image_url( $attributes, $item ) );

	$styles  = $this->get_styles( $attributes );
	$classes = $this->get_classes( $attributes );

	$output  = sprintf( '<div class="%1$s wp-block-woocommerce-%2$s" style="%3$s">', esc_attr( trim( $classes ) ), $this->block_name, esc_attr( $styles ) );
	$output .= sprintf( '<div class="wc-block-%s__wrapper">', $this->block_name );
	$output .= $this->render_overlay( $attributes );

	if ( ! $attributes['isRepeated'] && ! $attributes['hasParallax'] ) {
		$output .= $this->render_image( $attributes, $item, $image_url );
	} else {
		$output .= $this->render_bg_image( $attributes, $image_url );
	}

	$output .= $this->render_attributes( $item, $attributes );
	$output .= sprintf( '<div class="wc-block-%s__link">%s</div>', $this->block_name, $content );
	$output .= '</div>';
	$output .= '</div>';

	return $output;
}