WC_Product_Cat_List_Walker::start_el( string $output, object $cat, int $depth, array $args = array(), integer $current_object_id )

Start the element output.


Description Description

See also See also


Top ↑

Parameters Parameters

$output

(Required) Passed by reference. Used to append additional content.

$cat

(Required) Category.

$depth

(Required) Depth of category in reference to parents.

$args

(Optional) Arguments.

Default value: array()

$current_object_id

(Required) Current object ID.


Top ↑

Source Source

File: includes/walkers/class-wc-product-cat-list-walker.php

	public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
		$cat_id = intval( $cat->term_id );

		$output .= '<li class="cat-item cat-item-' . $cat_id;

		if ( $args['current_category'] === $cat_id ) {
			$output .= ' current-cat';
		}

		if ( $args['has_children'] && $args['hierarchical'] && ( empty( $args['max_depth'] ) || $args['max_depth'] > $depth + 1 ) ) {
			$output .= ' cat-parent';
		}

		if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat_id, $args['current_category_ancestors'], true ) ) {
			$output .= ' current-cat-parent';
		}

		$output .= '"><a href="' . get_term_link( $cat_id, $this->tree_type ) . '">' . apply_filters( 'list_product_cats', $cat->name, $cat ) . '</a>';

		if ( $args['show_count'] ) {
			$output .= ' <span class="count">(' . $cat->count . ')</span>';
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.