WC_Product_Cat_List_Walker::start_el
Start the element output.
Method of the class: WC_Product_Cat_List_Walker{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$WC_Product_Cat_List_Walker = new WC_Product_Cat_List_Walker(); $WC_Product_Cat_List_Walker->start_el( $output, $cat, $depth, $args, $current_object_id );
- $output(string) (required) (passed by reference — &)
- Passed by reference. Used to append additional content.
- $cat(object) (required)
- Category.
- $depth(int)
- Depth of category in reference to parents.
- $args(array)
- Arguments.
Default: array() - $current_object_id(int)
- Current object ID.
Notes
- See: Walker::start_el()
Changelog
| Since 2.1.0 | Introduced. |
WC_Product_Cat_List_Walker::start_el() WC Product Cat List Walker::start el code WC 10.3.5
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>';
}
}