Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::renderListItems()
Render a list of terms.
Метод класса: ProductCategories{}
Хуков нет.
Возвращает
Строку
. Rendered output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->renderListItems( $categories, $attributes, $uid, $depth );
- $categories(массив) (обязательный)
- List of terms.
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array - $uid(int) (обязательный)
- Unique ID for the rendered block, used for HTML IDs.
- $depth(int)
- Current depth.
Код ProductCategories::renderListItems() ProductCategories::renderListItems WC 8.7.0
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 ); }