Automattic\WooCommerce\Blocks\BlockTypes

CatalogSorting::render()protectedWC 1.0

Render the block.

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

Хуков нет.

Возвращает

Строку. | void Rendered block output.

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

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

Код CatalogSorting::render() WC 9.6.1

protected function render( $attributes, $content, $block ) {
	ob_start();
	woocommerce_catalog_ordering();
	$catalog_sorting = ob_get_clean();

	if ( ! $catalog_sorting ) {
		return;
	}

	$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'extra_classes' ) );
	$wrapper_attributes = get_block_wrapper_attributes(
		array(
			'class' => implode(
				' ',
				array_filter(
					[
						'woocommerce wc-block-catalog-sorting',
						esc_attr( $classes_and_styles['classes'] ),
					]
				)
			),
			'style' => esc_attr( $styles_and_classes['styles'] ?? '' ),
		)
	);

	return sprintf(
		'<div %1$s>%2$s</div>',
		$wrapper_attributes,
		$catalog_sorting
	);
}