<?php
/** Header fancy box gallery */

if ( ! function_exists( 'elinalite_headerg1' ) ) {

function elinalite_headerg1 () {

	$img1 = get_theme_mod( 'fancyboxg1', get_template_directory_uri() . '/images/gallery/gal1.jpg' );
	$img2 = get_theme_mod( 'fancyboxg2', get_template_directory_uri() . '/images/gallery/gal2.jpg' );
	$img3 = get_theme_mod( 'fancyboxg3', get_template_directory_uri() . '/images/gallery/gal3.jpg' );
	$img4 = get_theme_mod( 'fancyboxg4', get_template_directory_uri() . '/images/gallery/gal4.jpg' );

	if ( $img1 || $img2 || $img3 || $img4 ) {
		echo '<div class="row">';

		foreach ( [$img1, $img2, $img3, $img4] as $img ) {
			if ( ! empty( $img ) ) {
				echo '
				<div class="col-12">
					<div class="owl-hover">
						<a class="info" data-fancybox="gallery1" href="' . esc_url( $img ) . '">
							<img src="' . esc_url( $img ) . '" alt="image">
							<div class="box-content">
								<i class="fas fa-images"></i>
							</div>
						</a>
					</div>
				</div>';
			}
		}

		echo '</div>';
	}
}
add_action( 'firstgal', 'elinalite_headerg1' );
}


/* ================= SECOND ================= */

if ( ! function_exists( 'elinalite_headerg2' ) ) {

function elinalite_headerg2 () {

	$imgs = [
		get_theme_mod( 'fancyboxg5', get_template_directory_uri() . '/images/gallery/gal5.jpg' ),
		get_theme_mod( 'fancyboxg6', get_template_directory_uri() . '/images/gallery/gal6.jpg' ),
		get_theme_mod( 'fancyboxg7', get_template_directory_uri() . '/images/gallery/gal7.jpg' ),
		get_theme_mod( 'fancyboxg8', get_template_directory_uri() . '/images/gallery/gal8.jpg' ),
	];

	if ( array_filter( $imgs ) ) {
		echo '<div class="row">';

		foreach ( $imgs as $img ) {
			if ( ! empty( $img ) ) {
				echo '
				<div class="col-12">
					<div class="owl-hover">
						<a class="info" data-fancybox="gallery1" href="' . esc_url( $img ) . '">
							<img src="' . esc_url( $img ) . '" alt="image">
							<div class="box-content">
								<i class="fas fa-images"></i>
							</div>
						</a>
					</div>
				</div>';
			}
		}

		echo '</div>';
	}
}
add_action( 'secndgal', 'elinalite_headerg2' );
}


/* ================= THIRD ================= */

if ( ! function_exists( 'elinalite_headerg3' ) ) {

function elinalite_headerg3 () {

	$imgs = [
		get_theme_mod( 'fancyboxg9', get_template_directory_uri() . '/images/gallery/gal9.jpg' ),
		get_theme_mod( 'fancyboxg10', get_template_directory_uri() . '/images/gallery/gal10.jpg' ),
		get_theme_mod( 'fancyboxg11', get_template_directory_uri() . '/images/gallery/gal11.jpg' ),
		get_theme_mod( 'fancyboxg12', get_template_directory_uri() . '/images/gallery/gal12.jpg' ),
	];

	if ( array_filter( $imgs ) ) {
		echo '<div class="row">';

		foreach ( $imgs as $img ) {
			if ( ! empty( $img ) ) {
				echo '
				<div class="col-12">
					<div class="owl-hover">
						<a class="info" data-fancybox="gallery1" href="' . esc_url( $img ) . '">
							<img src="' . esc_url( $img ) . '" alt="image">
							<div class="box-content">
								<i class="fas fa-images"></i>
							</div>
						</a>
					</div>
				</div>';
			}
		}

		echo '</div>';
	}
}
add_action( 'thirdgal', 'elinalite_headerg3' );
}


/* ================= FOURTH (FIXED BUG) ================= */

if ( ! function_exists( 'elinalite_headerg4' ) ) {

function elinalite_headerg4 () {

	$imgs = [
		get_theme_mod( 'fancyboxg13', get_template_directory_uri() . '/images/gallery/gal13.jpg' ),
		get_theme_mod( 'fancyboxg14', get_template_directory_uri() . '/images/gallery/gal14.jpg' ),
		get_theme_mod( 'fancyboxg15', get_template_directory_uri() . '/images/gallery/gal15.jpg' ),
		get_theme_mod( 'fancyboxg16', get_template_directory_uri() . '/images/gallery/gal16.jpg' ),
	];

	if ( array_filter( $imgs ) ) {
		echo '<div class="row">';

		foreach ( $imgs as $img ) {
			if ( ! empty( $img ) ) {
				echo '
				<div class="col-12">
					<div class="owl-hover">
						<a class="info" data-fancybox="gallery1" href="' . esc_url( $img ) . '">
							<img src="' . esc_url( $img ) . '" alt="image">
							<div class="box-content">
								<i class="fas fa-images"></i>
							</div>
						</a>
					</div>
				</div>';
			}
		}

		echo '</div>';
	}
}
add_action( 'fourtgal', 'elinalite_headerg4' );
}


/* ================= FIFTH ================= */

if ( ! function_exists( 'elinalite_headerg5' ) ) {

function elinalite_headerg5 () {

	$imgs = [
		get_theme_mod( 'fancyboxg17', get_template_directory_uri() . '/images/gallery/gal17.jpg' ),
		get_theme_mod( 'fancyboxg18', get_template_directory_uri() . '/images/gallery/gal18.jpg' ),
		get_theme_mod( 'fancyboxg19', get_template_directory_uri() . '/images/gallery/gal19.jpg' ),
		get_theme_mod( 'fancyboxg20', get_template_directory_uri() . '/images/gallery/gal20.jpg' ),
	];

	if ( array_filter( $imgs ) ) {
		echo '<div class="row">';

		foreach ( $imgs as $img ) {
			if ( ! empty( $img ) ) {
				echo '
				<div class="col-12">
					<div class="owl-hover">
						<a class="info" data-fancybox="gallery1" href="' . esc_url( $img ) . '">
							<img src="' . esc_url( $img ) . '" alt="image">
							<div class="box-content">
								<i class="fas fa-images"></i>
							</div>
						</a>
					</div>
				</div>';
			}
		}

		echo '</div>';
	}
}
add_action( 'fifthgal', 'elinalite_headerg5' );
}


/* ================= SOCIAL (clean) ================= */

function elinalite_social_cb() {

	$facebook  = get_theme_mod( 'elinalite_facebook', 'https://www.facebook.com/pixelonetry' );
	$twitter   = get_theme_mod( 'elinalite_twitter', 'https://twitter.com' );
	$pinterest = get_theme_mod( 'elinalite_pinterest', 'https://www.pinterest.com/pixelonetry' );
	$linkedin  = get_theme_mod( 'elinalite_linkedin' );
	$instagram = get_theme_mod( 'elinalite_instagram' );
	$youtube   = get_theme_mod( 'elinalite_youtube' );
	$tiktok    = get_theme_mod( 'elinalite_tiktok' );

	if ( $facebook || $twitter || $pinterest || $linkedin || $instagram || $youtube || $tiktok ) {
		echo '<div class="icons">';

		if ( $facebook )  echo '<a href="' . esc_url( $facebook ) . '" target="_blank"><i class="lni lni-facebook"></i></a>';
		if ( $twitter )   echo '<a href="' . esc_url( $twitter ) . '" target="_blank"><i class="lni lni-twitter"></i></a>';
		if ( $pinterest ) echo '<a href="' . esc_url( $pinterest ) . '" target="_blank"><i class="lni lni-pinterest"></i></a>';
		if ( $linkedin )  echo '<a href="' . esc_url( $linkedin ) . '" target="_blank"><i class="lni lni-linkedin"></i></a>';
		if ( $instagram ) echo '<a href="' . esc_url( $instagram ) . '" target="_blank"><i class="lni lni-instagram"></i></a>';
		if ( $youtube )   echo '<a href="' . esc_url( $youtube ) . '" target="_blank"><i class="lni lni-youtube"></i></a>';
		if ( $tiktok )    echo '<a href="' . esc_url( $tiktok ) . '" target="_blank"><i class="lni lni-tiktok"></i></a>';

		echo '</div>';
	}
}
add_action( 'elinalite_social', 'elinalite_social_cb' );


function elinalite_social__header() {

	$facebook  = get_theme_mod( 'elinalite_facebook', 'https://www.facebook.com/pixelonetry' );
	$twitter   = get_theme_mod( 'elinalite_twitter', 'https://www.twitter.com' );
	$pinterest = get_theme_mod( 'elinalite_pinterest', 'https://www.pinterest.com/pixelonetry' );
	$linkedin  = get_theme_mod( 'elinalite_linkedin' );
	$instagram = get_theme_mod( 'elinalite_instagram' );
	$youtube   = get_theme_mod( 'elinalite_youtube' );
	$tiktok    = get_theme_mod( 'elinalite_tiktok' );

	if ( $facebook || $twitter || $pinterest || $linkedin || $instagram || $youtube || $tiktok ) {
		echo '<div class="social-icon ini-social-hover">';

		if ( $facebook )  echo '<a href="' . esc_url( $facebook ) . '" target="_blank"><i class="lni lni-facebook"></i></a>';
		if ( $twitter )   echo '<a href="' . esc_url( $twitter ) . '" target="_blank"><i class="lni lni-twitter"></i></a>';
		if ( $pinterest ) echo '<a href="' . esc_url( $pinterest ) . '" target="_blank"><i class="lni lni-pinterest"></i></a>';
		if ( $linkedin )  echo '<a href="' . esc_url( $linkedin ) . '" target="_blank"><i class="lni lni-linkedin"></i></a>';
		if ( $instagram ) echo '<a href="' . esc_url( $instagram ) . '" target="_blank"><i class="lni lni-instagram"></i></a>';
		if ( $youtube )   echo '<a href="' . esc_url( $youtube ) . '" target="_blank"><i class="lni lni-youtube"></i></a>';
		if ( $tiktok )    echo '<a href="' . esc_url( $tiktok ) . '" target="_blank"><i class="lni lni-tiktok"></i></a>';

		echo '</div>';
	}
}
add_action( 'elinalite_social_top', 'elinalite_social__header' );