Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::render() public WC 1.0
Render the Product Categories List block.
{} It's a method of the class: ProductCategories{}
No Hooks.
Return
String. Rendered block type output.
Usage
$ProductCategories = new ProductCategories(); $ProductCategories->render( $attributes, $content );
- $attributes(array)
- Block attributes.
Default: empty array - $content(string)
- Block content.
Default: empty string
Code of ProductCategories::render() ProductCategories::render WC 5.0.0
public function render( $attributes = array(), $content = '' ) {
$uid = uniqid( 'product-categories-' );
$categories = $this->get_categories( $attributes );
if ( empty( $categories ) ) {
return '';
}
if ( ! empty( $content ) ) {
// Deal with legacy attributes (before this was an SSR block) that differ from defaults.
if ( strstr( $content, 'data-has-count="false"' ) ) {
$attributes['hasCount'] = false;
}
if ( strstr( $content, 'data-is-dropdown="true"' ) ) {
$attributes['isDropdown'] = true;
}
if ( strstr( $content, 'data-is-hierarchical="false"' ) ) {
$attributes['isHierarchical'] = false;
}
if ( strstr( $content, 'data-has-empty="true"' ) ) {
$attributes['hasEmpty'] = true;
}
}
$classes = $this->get_container_classes( $attributes );
$output = '<div class="' . esc_attr( $classes ) . '">';
$output .= ! empty( $attributes['isDropdown'] ) ? $this->renderDropdown( $categories, $attributes, $uid ) : $this->renderList( $categories, $attributes, $uid );
$output .= '</div>';
return $output;
}