Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::renderDropdownOptions
Render dropdown options list.
Метод класса: ProductCategories{}
Хуков нет.
Возвращает
Строку. Rendered output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->renderDropdownOptions( $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::renderDropdownOptions() ProductCategories::renderDropdownOptions WC 10.9.1
protected function renderDropdownOptions( $categories, $attributes, $uid, $depth = 0 ) {
$output = '';
foreach ( $categories as $category ) {
$output .= '
<option value="' . esc_attr( get_term_link( $category->term_id, 'product_cat' ) ) . '">
' . str_repeat( '−', $depth ) . '
' . esc_html( $category->name ) . '
' . $this->getCount( $category, $attributes ) . '
</option>
' . ( ! empty( $category->children ) ? $this->renderDropdownOptions( $category->children, $attributes, $uid, $depth + 1 ) : '' ) . '
';
}
return $output;
}