WC_Product_Cat_Dropdown_Walker::start_el()publicWC 2.1.0

Starts the list before the elements are added.

Метод класса: WC_Product_Cat_Dropdown_Walker{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$WC_Product_Cat_Dropdown_Walker = new WC_Product_Cat_Dropdown_Walker();
$WC_Product_Cat_Dropdown_Walker->start_el( $output, $cat, $depth, $args, $current_object_id );
$output(строка) (обязательный) (передается по ссылке — &)
Passed by reference. Used to append additional content.
$cat(объект) (обязательный)
Category.
$depth(int)
Depth of category in reference to parents.
$args(массив)
Arguments.
По умолчанию: array()
$current_object_id(int)
Current object ID.

Заметки

Список изменений

С версии 2.1.0 Введена.

Код WC_Product_Cat_Dropdown_Walker::start_el() WC 8.7.0

public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {

	if ( ! empty( $args['hierarchical'] ) ) {
		$pad = str_repeat( ' ', $depth * 3 );
	} else {
		$pad = '';
	}

	$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
	$value    = ( isset( $args['value'] ) && 'id' === $args['value'] ) ? $cat->term_id : $cat->slug;
	$output  .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $value ) . '"';

	if ( $value === $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'], true ) ) ) {
		$output .= ' selected="selected"';
	}

	$output .= '>';
	$output .= esc_html( $pad . $cat_name );

	if ( ! empty( $args['show_count'] ) ) {
		$output .= '&nbsp;(' . absint( $cat->count ) . ')';
	}

	$output .= "</option>\n";
}