<?php
// Display on selected pages only
$ishide = magboost_area_ishide( 'topbar' );
if ( $ishide ) { return; }

// Get Content
global $hoot_data;
hoot_set_data( 'topbar_left', is_active_sidebar( 'hoot-topbar-left' ) );
hoot_set_data( 'topbar_right', is_active_sidebar( 'hoot-topbar-right' ) );

// Template modification Hook
do_action( 'magboost_before_topbar' );

// Display Topbar
$hoot_topbar_left = hoot_data()->topbar_left;
$hoot_topbar_right = hoot_data()->topbar_right;
$hoot_topbar_align = hoot_get_mod( 'topbar_align' );

if ( !empty( $hoot_topbar_left ) || !empty( $hoot_topbar_right ) ) :

	$topbar_grid = ( hoot_get_mod( 'topbar_grid' ) == 'stretch' ) ? 'hgrid-stretch' : 'hgrid';

	?>
	<div <?php hoot_attr( 'topbar', '', 'inline-nav js-search hgrid-stretch' ); ?>>
		<div class="<?php echo $topbar_grid; ?>">
			<div class="hgrid-span-12">

				<div class="topbar-inner hootflex <?php if ( $hoot_topbar_align === 'center' ) echo 'hootflex-center'; ?>">
					<?php
					if ( $hoot_topbar_left ):
						$topbarid = $hoot_topbar_align === 'leftright' ? 'left' : 'center';

						// Template modification Hook
						do_action( 'magboost_sidebar_start', 'topbar-left', $topbarid );
						?>

						<div id="topbar-left" class="topbar-part topbar-<?php echo $topbarid; ?>">
							<?php dynamic_sidebar( 'hoot-topbar-left' ); ?>
						</div>

						<?php
						// Template modification Hook
						do_action( 'magboost_sidebar_end', 'topbar-left', $topbarid );

					endif;
					
					if ( $hoot_topbar_right ):
						$topbarid = $hoot_topbar_align === 'leftright' ? 'right' : 'center';

						// Template modification Hook
						do_action( 'magboost_sidebar_start', 'topbar-right', $topbarid );
						?>

						<div id="topbar-right" class="topbar-part topbar-<?php echo $topbarid; ?>">
							<?php dynamic_sidebar( 'hoot-topbar-right' ); ?>
						</div>

						<?php
						// Template modification Hook
						do_action( 'magboost_sidebar_end', 'topbar-right', $topbarid );

					endif;
					?>
				</div>

			</div>
		</div>
	</div>
	<?php

endif;

// Template modification Hook
do_action( 'magboost_after_topbar' );