wc_walk_category_dropdown_tree()WC 1.0

Custom walker for Product Categories.

Previously used by wc_product_dropdown_categories, but wp_dropdown_categories has been fixed in core.

No Hooks.

Return

Mixed.

Usage

wc_walk_category_dropdown_tree( ...$args );
...$args(mixed) (required)
Variable number of parameters to be passed to the walker.

wc_walk_category_dropdown_tree() code WC 8.7.0

function wc_walk_category_dropdown_tree( ...$args ) {
	if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) {
		include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php';
	}

	// The user's options are the third parameter.
	if ( empty( $args[2]['walker'] ) || ! is_a( $args[2]['walker'], 'Walker' ) ) {
		$walker = new WC_Product_Cat_Dropdown_Walker();
	} else {
		$walker = $args[2]['walker'];
	}

	return $walker->walk( ...$args );
}