<?php
/**
 * Render homepage sections.
 */
function fuzion_blog_homepage_sections() {

	$homepage_sections = fuzion_blog_get_homepage_sections();

	$sortable_sections = get_theme_mod( 'fuzion_blog_sortable' );

	if ( empty( $sortable_sections ) ) {
		$sorted_sections = array_keys( $homepage_sections );
	} else {
		$sorted_sections = explode( ',', $sortable_sections );
	}

	foreach ( $sorted_sections as $section ) {
		if ( in_array( $section, array_keys( $homepage_sections ) ) ) {
			require get_template_directory() . '/sections/' . $section . '.php';
		}
	}

}
