<?php
/**
 * The template for displaying the footer
 *
 * Contains the closing of the #content div and all content after.
 *
 * @link https://developer.WordPress.org/themes/basics/template-files/#template-partials
 *
 * @package blogging_hub
 */

?>
	</div>

	<footer id="colophon" class="site-footer">
		<div id="footer-widgets" class="container">
			<div class="row">

				<!-- Footer Column 1 - Sidebar 1 -->
				<div class="col-md-3">
					<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
						<?php dynamic_sidebar( 'sidebar-2' ); ?>
					<?php else : ?>
						<section class="widget">
						<h2 class="widget-title"><?php esc_html_e( 'About Us', 'blogging-hub' ); ?></h2>
							<p><?php _e( 'This is default About Us text. Customize this in your widgets area. We are a passionate team dedicated to delivering quality services and exceptional support to our customers every step of the way. With years of experience and a commitment to innovation, we strive to meet the unique needs of every client.', 'blogging-hub' ); ?></p>
						</section>
					<?php endif; ?>
				</div>

				<!-- Footer Column 2 - Sidebar 2 -->
				<div class="col-md-3">
					<?php if ( is_active_sidebar( 'sidebar-3' ) ) : ?>
						<?php dynamic_sidebar( 'sidebar-3' ); ?>
					<?php else : ?>
						<section class="widget">
						<h2 class="widget-title"><?php esc_html_e( 'Recent Posts', 'blogging-hub' ); ?></h2>
							<ul>
								<?php
								$blogging_hub_recent_posts = wp_get_recent_posts( array(
									'numberposts' => 3,
									'post_status' => 'publish',
								) );
								foreach ( $blogging_hub_recent_posts as $blogging_hub_post ) : ?>
									<li>
										<a href="<?php echo esc_url( get_permalink( $blogging_hub_post['ID'] ) ); ?>">
											<?php echo esc_html( $blogging_hub_post['post_title'] ); ?>
										</a>
									</li>
								<?php endforeach; ?>
							</ul>
						</section>
					<?php endif; ?>
				</div>

				<!-- Footer Column 3 - Sidebar 3 -->
				<div class="col-md-3">
					<?php if ( is_active_sidebar( 'sidebar-4' ) ) : ?>
						<?php dynamic_sidebar( 'sidebar-4' ); ?>
					<?php else : ?>
						<section class="widget">
						<h2 class="widget-title"><?php esc_html_e( 'Pages', 'blogging-hub' ); ?></h2>
							<ul>
								<?php
							$blogging_hub_pages = get_pages( array(
								'sort_column' => 'post_date',
								'sort_order'  => 'DESC',
								'number'      => 3, // change number of pages here
							) );

							foreach ( $blogging_hub_pages as $blogging_hub_page ) : ?>
								<li>
									<a href="<?php echo esc_url( get_permalink( $blogging_hub_page->ID ) ); ?>">
										<?php echo esc_html( $blogging_hub_page->post_title ); ?>
										</a>
									</li>
								<?php endforeach; ?>
							</ul>
						</section>
					<?php endif; ?>
				</div>

				<!-- Footer Column 4 - Sidebar 4 -->
				<div class="col-md-3">
					<?php if ( is_active_sidebar( 'sidebar-5' ) ) : ?>
						<?php dynamic_sidebar( 'sidebar-5' ); ?>
					<?php else : ?>
						<section class="widget">
						<h2 class="widget-title"><?php esc_html_e( 'Contact Info', 'blogging-hub' ); ?></h2>
							<ul>
							<li><?php esc_html_e( 'Email: info@example.com', 'blogging-hub' ); ?></li>
							<li><?php esc_html_e( 'Phone: +91-123-456-7890', 'blogging-hub' ); ?></li>
							<li><?php esc_html_e( 'Address: 1234 Elm St, Springfield, IL, USA', 'blogging-hub' ); ?></li>
							</ul>
						</section>
					<?php endif; ?>
				</div>

			</div>
		</div>

		<div class="site-info">
			<div class="container">
				<?php
					if ( ! get_theme_mod('blogging_hub_copyright_option') ) {

						$blogging_hub_theme_name  = wp_get_theme()->get('Name');
						$blogging_hub_theme_uri   = wp_get_theme()->get('ThemeURI');
						$blogging_hub_author_name = wp_get_theme()->get('Author');
						$blogging_hub_author_uri  = wp_get_theme()->get('AuthorURI');
						?>

						<a target="_blank" href="<?php echo esc_url( $blogging_hub_theme_uri ); ?>">
							<?php echo esc_html( $blogging_hub_theme_name ); ?>
						</a>

						<?php echo esc_html(' By '); ?>

						<a target="_blank" href="<?php echo esc_url( $blogging_hub_author_uri ); ?>">
							<?php echo esc_html( $blogging_hub_author_name ); ?>
						</a>

					<?php
					} else {
						echo esc_html( get_theme_mod('blogging_hub_copyright_option') );
					}
				?>
			</div>
		</div>
	</footer>

	<a href="#page" class="to-top"></a>
	
</div>

<?php wp_footer(); ?>

</body>
</html>
