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

	$homepage_sections = minimalistic_blog_get_homepage_sections();

	$sortable_sections = get_theme_mod( 'minimalistic_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';
		}
	}

}
