Automattic\WooCommerce\Blocks\BlockTypes

ProductDetails::render()protectedWC 1.0

Render the block.

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

Хуков нет.

Возвращает

Строку. Rendered block output.

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

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

Код ProductDetails::render() WC 9.8.5

protected function render( $attributes, $content, $block ) {
	$hide_tab_title = isset( $attributes['hideTabTitle'] ) ? $attributes['hideTabTitle'] : false;

	if ( $hide_tab_title ) {
		add_filter( 'woocommerce_product_description_heading', '__return_empty_string' );
		add_filter( 'woocommerce_product_additional_information_heading', '__return_empty_string' );
		add_filter( 'woocommerce_reviews_title', '__return_empty_string' );
	}

	$tabs = $this->render_tabs();

	if ( $hide_tab_title ) {
		remove_filter( 'woocommerce_product_description_heading', '__return_empty_string' );
		remove_filter( 'woocommerce_product_additional_information_heading', '__return_empty_string' );
		remove_filter( 'woocommerce_reviews_title', '__return_empty_string' );

		// Remove the first `h2` of every `.wc-tab`. This is required for the Reviews tabs when there are no reviews and for plugin tabs.
		$tabs_html = new WP_HTML_Tag_Processor( $tabs );
		while ( $tabs_html->next_tag( array( 'class_name' => 'wc-tab' ) ) ) {
			if ( $tabs_html->next_tag( 'h2' ) ) {
				$tabs_html->set_attribute( 'hidden', 'true' );
			}
		}
		$tabs = $tabs_html->get_updated_html();
	}

	$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );

	return sprintf(
		'<div class="wp-block-woocommerce-product-details %1$s">
			<div style="%2$s">
				%3$s
			</div>
		</div>',
		esc_attr( $classes_and_styles['classes'] ),
		esc_attr( $classes_and_styles['styles'] ),
		$tabs
	);
}