<?php
/**
 * The template for displaying the footer
 *
 * @package Zentorone
 */

?>

	<footer id="colophon" class="site-footer bg-light pt-4">
		<?php do_action( 'zentorone_before_footer' ); ?>
		<div class="container">
			<div class="row">
				<?php for ( $i = 1; $i <= 4; $i++ ) : ?>
					<?php if ( is_active_sidebar( 'footer-' . $i ) ) : ?>
						<div class="col-lg-3 col-md-6 mb-4 mb-lg-0">
							<?php dynamic_sidebar( 'footer-' . $i ); ?>
						</div>
					<?php endif; ?>
				<?php endfor; ?>
			</div>

			<?php
			// Tüm sosyal medya linklerini tek seferde al (tekrar eden sorguları önler)
			$socials = array( 'facebook', 'twitter', 'instagram', 'youtube', 'linkedin' );
			$social_urls = array();
			$has_social  = false;

			foreach ( $socials as $social ) {
				$url = zentorone_get_option( 'zentorone_social_' . $social );
				if ( $url ) {
					$social_urls[ $social ] = $url;
					$has_social = true;
				}
			}

			if ( $has_social ) :
			?>
				<div class="footer-social text-center">
					<?php foreach ( $social_urls as $social => $url ) :
						$icon = ( 'twitter' === $social ) ? 'twitter-x' : $social;
					?>
						<a href="<?php echo esc_url( $url ); ?>" class="text-secondary mx-2 fs-4" target="_blank" rel="noopener noreferrer">
							<i class="bi bi-<?php echo esc_attr( $icon ); ?>"></i>
							<span class="screen-reader-text"><?php echo esc_html( ucfirst( $social ) ); ?></span>
						</a>
					<?php endforeach; ?>
				</div>
			<?php endif; ?>

			<div class="site-info text-center<?php echo $has_social ? ' mt-4 border-top pt-4' : ''; ?>">
				<span class="copyright">
					<?php echo wp_kses_post( zentorone_get_option( 'zentorone_footer_copyright', sprintf( __( '&copy; %d %s. All Rights Reserved.', 'zentorone' ), date_i18n( 'Y' ), get_bloginfo( 'name' ) ) ) ); ?>
				</span>
				<span class="sep"> | </span>
				<?php
				$theme = wp_get_theme();
				/* translators: 1: Theme name, 2: Theme author. */
				printf(
					esc_html__( 'Theme: %1$s by %2$s.', 'zentorone' ),
					'<a href="' . esc_url( $theme->get( 'ThemeURI' ) ) . '">' . esc_html( $theme->get( 'Name' ) ) . '</a>',
					'<a href="' . esc_url( $theme->get( 'AuthorURI' ) ) . '">' . esc_html( $theme->get( 'Author' ) ) . '</a>'
				);
				?>
				<?php do_action( 'zentorone_footer_info' ); ?>
			</div><!-- .site-info -->
		</div>
		<?php do_action( 'zentorone_after_footer' ); ?>
	</footer><!-- #colophon -->
</div><!-- #page -->

<a href="#" class="scroll-to-top" aria-label="<?php esc_attr_e( 'Scroll to top', 'zentorone' ); ?>">
	<i class="bi bi-arrow-up"></i>
</a>

<?php wp_footer(); ?>

</body>
</html>