<?php
/**
 * Category tree helpers
 *
 * @package Multi
 */

if ( ! defined( 'ABSPATH' ) ) {
	die;
}
/**
 * Gets a list of subcategories for the chosen category
 *
 * @param integer $id Category id.
 */
function multimagazine_get_subcat_list( $id ) {
	$multimagazine_options = array(
		'orderby'      => 'name',
		'hierarchical' => 0,
		'child_of'     => $id,
	);
	$multimagazine_cats    = get_categories( $multimagazine_options );
	$cat_links     = array();
	foreach ( $multimagazine_cats as $cat ) {
		$cat_links[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '">' . esc_html( $cat->name ) . '</a>';
	}
	return implode( ', ', $cat_links );
}
