Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::renderListItems()
Render a list of terms.
Method of the class: ProductCategories{}
No Hooks.
Return
String
. Rendered output.
Usage
// protected - for code of main (parent) or child class $result = $this->renderListItems( $categories, $attributes, $uid, $depth );
- $categories(array) (required)
- List of terms.
- $attributes(array) (required)
- Block attributes.
Default: empty array - $uid(int) (required)
- Unique ID for the rendered block, used for HTML IDs.
- $depth(int)
- Current depth.
ProductCategories::renderListItems() ProductCategories::renderListItems code WC 9.4.2
protected function renderListItems( $categories, $attributes, $uid, $depth = 0 ) { $output = ''; $link_color_class_and_style = StyleAttributesUtils::get_link_color_class_and_style( $attributes ); $link_color_style = isset( $link_color_class_and_style['style'] ) ? $link_color_class_and_style['style'] : ''; foreach ( $categories as $category ) { $output .= ' <li class="wc-block-product-categories-list-item"> <a style="' . esc_attr( $link_color_style ) . '" href="' . esc_attr( get_term_link( $category->term_id, 'product_cat' ) ) . '">' . $this->get_image_html( $category, $attributes ) . '<span class="wc-block-product-categories-list-item__name">' . esc_html( $category->name ) . '</span>' . '</a>' . $this->getCount( $category, $attributes ) . ( ! empty( $category->children ) ? $this->renderList( $category->children, $attributes, $uid, $depth + 1 ) : '' ) . ' </li> '; } return preg_replace( '/\r|\n/', '', $output ); }