Automattic\WooCommerce\Blocks\BlockTypes
CatalogSorting::render
Render the block.
Method of the class: CatalogSorting{}
No Hooks.
Returns
String. | void Rendered block output.
Usage
// protected - for code of main (parent) or child class $result = $this->render( $attributes, $content, $block );
- $attributes(array) (required)
- Block attributes.
- $content(string) (required)
- Block content.
- $block(WP_Block) (required)
- Block instance.
CatalogSorting::render() CatalogSorting::render code WC 10.6.2
protected function render( $attributes, $content, $block ) {
ob_start();
woocommerce_catalog_ordering( $attributes );
$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
);
}