<?php 
add_shortcode('year', 'year_shortcode');
function year_shortcode(){
	return date('Y');
}

add_shortcode('social_link', 'social_link');
function social_link(){
	$social_media = get_field('social_media', 'option');

	ob_start();
	if($social_media): ?>

	<ul class="list-social">
		<?php foreach ($social_media as $social) {?>
			<li class="<?php echo $social['social'] ?>"><a href="<?php echo $social['url']; ?>"><?php echo $social['font_awesome_icon']; ?></a></li>
		<?php } ?>
	</ul>
<?php 
	endif;

	$output = ob_get_contents();
	ob_end_clean();

	return $output;
}

add_shortcode( 'office_info', function(){
	$offices = get_field( 'office', 'option' );

	ob_start(); ?>
	<div class="wrap-office-info">
		<?php $hotline = get_field( 'header_phone', 'option' );
		if( $hotline ): ?>
		<div class="hot-line"><?php _e( 'Hotline: ', 'tbang_text' ) ?> <span><?php echo $hotline; ?></span></div>
		<?php endif; ?>

		<?php if($offices): ?>
		<ul class="list-office">
			<?php foreach( $offices as $office ) {?>
				<li class="office-item">
					<h3 class="title"><?php echo $office['title'] ?></h3>
					<h4 class="address"><?php echo $office['address'] ?></h4>
					<h5 class="phone"><?php echo $office['phone'] ?></h5>
				</li>
			<?php } ?>
		</ul>
		<?php endif; ?>
	</div>
<?php 	
	$output = ob_get_contents();
	ob_end_clean();

	return $output;
} );
