<?php
/**
 * Top bar template
 *
 * @package Multi
 */

?>
<?php
if ( get_theme_mod( 'multi_show_topbar', MULTIMAGAZINE_SHOW_TOPBAR ) ) :
	$top_bar_message_pos     = get_theme_mod( 'multi_top_bar_msg_pos', MULTIMAGAZINE_TOP_BAR_MSG_POS );
	$top_bar_menu_pos        = get_theme_mod( 'multi_top_bar_menu_pos', MULTIMAGAZINE_TOP_BAR_MENU_POS );
	$top_bar_social_pos      = get_theme_mod( 'multi_top_bar_social_pos', MULTIMAGAZINE_TOP_BAR_SOCIAL_POS );
	$header_layout           = get_theme_mod( 'multi_header_layout', 4 );
	$top_bar_social_settings = array(
		'tooltip'  => false,
		'wrap_nav' => true,
	);

	$topbar_classes = array( 'top-bar' );
	if ( get_theme_mod( 'multi_topbar_sticky_mobile', MULTIMAGAZINE_TOPBAR_STICKY_MOBILE ) ) {
		$topbar_classes[] = 'is-sticky-mobile';
	}
	if ( get_theme_mod( 'multi_topbar_sticky_desktop', MULTIMAGAZINE_TOPBAR_STICKY_DESKTOP ) ) {
		$topbar_classes[] = 'is-sticky-desktop';
	}
	?>
	<div class="<?php echo esc_attr( implode( ' ', $topbar_classes ) ); ?>">
	<?php
	$ad_code = get_theme_mod( 'multi_header_ad', '' );
	$show_ad = get_theme_mod( 'multi_ad_in_header', MULTIMAGAZINE_AD_IN_HEADER );
	if ( ! empty( $ad_code ) && 'topbar' === $show_ad ) {
		get_template_part( 'template-parts/advert-header' );
	}
	$classes = array( 'top-header-content' );

	if ( get_theme_mod( 'multi_fullwidth_header', MULTIMAGAZINE_FULLWIDTH_HEADER ) ) {
		$classes[] = 'full-width';
	}

	?>

	<div class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
		<div class="top-header-left">
		<?php
		if ( 'left' === $top_bar_message_pos ) {
			get_template_part( 'template-parts/top-bar-message' );
		}
		if ( 'left' === $top_bar_menu_pos ) {
			get_template_part( 'template-parts/top-bar-menu' );
		}
		if ( 'left' === $top_bar_social_pos ) {
			get_template_part( 'template-parts/social-links', null, $top_bar_social_settings );
		}
		?>
		</div>
		<div class="top-header-center">
			<?php
			if ( 'center' === $top_bar_message_pos ) {
				get_template_part( 'template-parts/top-bar-message' );
			}
			if ( 'center' === $top_bar_menu_pos ) {
				get_template_part( 'template-parts/top-bar-menu' );
			}
			if ( 'center' === $top_bar_social_pos ) {
				get_template_part( 'template-parts/social-links', null, $top_bar_social_settings );
			}
			?>
		</div>
		<div class="top-header-right">
			<?php
			if ( 'right' === $top_bar_message_pos ) {
				get_template_part( 'template-parts/top-bar-message' );
			}
			if ( 'right' === $top_bar_menu_pos ) {
				get_template_part( 'template-parts/top-bar-menu' );
			}
			if ( 'right' === $top_bar_social_pos ) {
				get_template_part( 'template-parts/social-links', null, $top_bar_social_settings );
			}
			?>
		</div>
	</div>
</div>
<?php endif; ?>
