<?php
/**
 * Setting-based classes added to body element
 *
 * @package Multi
 */

?>
<?php
/**
 * Applies appropriate classes to body element
 *
 * @param array $classes Initial classes passed from WP.
 */
function multimagazine_body_classes( $classes ) {

	$body_classes   = array();
	$layout         = get_theme_mod( 'multi_layout_type', MULTIMAGAZINE_LAYOUT_TYPE );
	$body_classes[] = $layout;
	$body_classes[] = 'theme-multi';

	$last_widget_sticky = get_theme_mod( 'multi_last_widget_sticky', MULTIMAGAZINE_LAST_WIDGET_STICKY ) ? true : false;
	if ( $last_widget_sticky ) {
		$body_classes[] = 'last-widget-sticky';
	}

	$body_classes[] = get_theme_mod( 'multi_show_menus', MULTIMAGAZINE_SHOW_MENUS );

	/* transparent header for a post */
	if ( is_single() || is_page() ) {
		$transparent_header = get_post_meta( get_the_id(), 'multi_header_style', true );
		if ( ! empty( $transparent_header ) ) {
			$body_classes[] = 'transparent-header';
		}
	}

	/* image hover effect */
	$img_hover = get_theme_mod( 'multi_image_hover', MULTIMAGAZINE_IMAGE_HOVER );
	if ( 'none' !== $img_hover ) {
		$body_classes[] = $img_hover;
	}

	/* lightbox multimagazine_setup */
	$lightbox_style = get_theme_mod( 'multi_lightbox_style', 'all-controls' );
	if ( 'minimal' === $lightbox_style ) {
		$body_classes[] = 'lightbox-minimal';
	}

	/* form message styles */
	$multimagazine_msg_style = get_theme_mod( 'multi_msg_style', 'minimal' );
	$body_classes[]  = 'msg-' . str_replace( ' ', '-', $multimagazine_msg_style );

	/* if no preloader */
	if ( get_theme_mod( 'multi_preloader', MULTIMAGAZINE_PRELOADER ) ) {
		$body_classes[] = 'has-preloader';

		if ( get_theme_mod( 'multi_preloader_loading_only', MULTIMAGAZINE_PRELOADER_LOADING_ONLY ) ) {
			$body_classes[] = 'preloader-loading-only';
		}
	} else {
		$body_classes[] = 'no-preloader';
	}

	return array_merge( $classes, $body_classes );
}

add_filter( 'body_class', 'multimagazine_body_classes' );
