<?php
/**
 * The template for displaying all pages
 *
 * @package SEO Specialist
 */

get_header();
?>

<div class="container">
	<?php
	$seo_specialist_page_layout = get_theme_mod( 'seo_specialist_page_layout', 'layout-1' );

	if ( $seo_specialist_page_layout == 'layout-1' ) {
		?>
	<div class="site-wrapper">
		<main id="primary" class="site-main lay-width">
			<?php
			while ( have_posts() ) :
				the_post();

				get_template_part( 'revolution/template-parts/content', 'page' );

				if ( comments_open() || get_comments_number() ) :
					comments_template();
				endif;

			endwhile; // End of the loop.
			?>
		</main>
		<?php if ( is_active_sidebar( 'sidebar-1' )) { ?>
		<aside id="secondary" class="widget-area sidebar-width">
			<?php dynamic_sidebar( 'sidebar-1' ); ?>
		</aside>
		<?php } else { ?>
			<aside id="secondary" class="widget-area sidebar-width">
				<div class="default-sidebar">
					<aside id="search-3" class="widget widget_search">
						<h2 class="widget-title"><?php esc_html_e('Search Anything', 'seo-specialist'); ?></h2>
						<?php get_search_form(); ?>
					</aside>
					<aside id="recent-posts-2" class="widget widget_recent_entries">
						<h2 class="widget-title"><?php esc_html_e('Latest Posts', 'seo-specialist'); ?></h2>
						<ul>
							<?php
							$seo_specialist_recent_posts = wp_get_recent_posts(array('numberposts' => 5));
							foreach ($seo_specialist_recent_posts as $seo_specialist_post) {
								echo '<li><a href="' . esc_url(get_permalink($seo_specialist_post['ID'])) . '">' . esc_html($seo_specialist_post['post_title']) . '</a></li>';
							}
							?>
						</ul>
					</aside>
					<aside id="recent-comments-2" class="widget widget_recent_comments">
						<h2 class="widget-title"><?php esc_html_e('Latest Comments', 'seo-specialist'); ?></h2>
						<ul id="recentcomments">
							<?php
								$seo_specialist_comments = get_comments(array(
									'number' => 5,
									'status' => 'approve',
								));
								foreach ($seo_specialist_comments as $seo_specialist_comment) {
									echo '<li class="recentcomments">' . esc_html($seo_specialist_comment->comment_author) . ': <a href="' . esc_url(get_comment_link($seo_specialist_comment->comment_ID)) . '">' . esc_html(get_the_title($seo_specialist_comment->comment_post_ID)) . '</a></li>';
								}
							?>
						</ul>
					</aside>
					<aside id="categories-2" class="widget widget_categories">
						<h2 class="widget-title"><?php esc_html_e('Explore Categories', 'seo-specialist'); ?></h2>
						<ul>
							<?php
								wp_list_categories(array(
									'title_li' => '',
								));
							?>
						</ul>
					</aside>
					<aside id="archives-2" class="widget widget_archive">
						<h2 class="widget-title"><?php esc_html_e('Blog Archives', 'seo-specialist'); ?></h2>
						<ul>
							<?php
								wp_get_archives(array(
									'type' => 'postbypost',
									'format' => 'html',
								));
							?>
						</ul>
				</aside>
					<aside id="pages-2" class="widget widget_pages">
						<h2 class="widget-title"><?php esc_html_e('Explore Our Pages', 'seo-specialist'); ?></h2>
						<ul>
							<?php
								wp_list_pages(array(
									'title_li' => '',
								));
							?>
						</ul>
					</aside>
				<aside id="calendar-2" class="widget widget_calendar">
						<h2 class="widget-title"><?php esc_html_e('Calender', 'seo-specialist'); ?></h2>
						<?php get_calendar(); ?>
				</aside>
			   </div>
			</aside>
	<?php } ?>
	</div>
	<?php
	} elseif ( $seo_specialist_page_layout == 'layout-2' ) {
		?>
	<div class="site-wrapper">
		<?php if ( is_active_sidebar( 'sidebar-1' )) { ?>
		<aside id="secondary" class="widget-area sidebar-width">
			<?php dynamic_sidebar( 'sidebar-1' ); ?>
		</aside>
		<?php } else { ?>
			<aside id="secondary" class="widget-area sidebar-width">
				<div class="default-sidebar">
					<aside id="search-3" class="widget widget_search">
						<h2 class="widget-title"><?php esc_html_e('Search Anything', 'seo-specialist'); ?></h2>
						<?php get_search_form(); ?>
					</aside>
					<aside id="recent-posts-2" class="widget widget_recent_entries">
						<h2 class="widget-title"><?php esc_html_e('Latest Posts', 'seo-specialist'); ?></h2>
						<ul>
							<?php
							$seo_specialist_recent_posts = wp_get_recent_posts(array('numberposts' => 5));
							foreach ($seo_specialist_recent_posts as $seo_specialist_post) {
								echo '<li><a href="' . esc_url(get_permalink($seo_specialist_post['ID'])) . '">' . esc_html($seo_specialist_post['post_title']) . '</a></li>';
							}
							?>
						</ul>
					</aside>
					<aside id="recent-comments-2" class="widget widget_recent_comments">
						<h2 class="widget-title"><?php esc_html_e('Latest Comments', 'seo-specialist'); ?></h2>
						<ul id="recentcomments">
							<?php
								$seo_specialist_comments = get_comments(array(
									'number' => 5,
									'status' => 'approve',
								));
								foreach ($seo_specialist_comments as $seo_specialist_comment) {
									echo '<li class="recentcomments">' . esc_html($seo_specialist_comment->comment_author) . ': <a href="' . esc_url(get_comment_link($seo_specialist_comment->comment_ID)) . '">' . esc_html(get_the_title($seo_specialist_comment->comment_post_ID)) . '</a></li>';
								}
							?>
						</ul>
					</aside>
					<aside id="categories-2" class="widget widget_categories">
						<h2 class="widget-title"><?php esc_html_e('Explore Categories', 'seo-specialist'); ?></h2>
						<ul>
							<?php
								wp_list_categories(array(
									'title_li' => '',
								));
							?>
						</ul>
					</aside>
					<aside id="archives-2" class="widget widget_archive">
						<h2 class="widget-title"><?php esc_html_e('Blog Archives', 'seo-specialist'); ?></h2>
						<ul>
							<?php
								wp_get_archives(array(
									'type' => 'postbypost',
									'format' => 'html',
								));
							?>
						</ul>
				</aside>
					<aside id="pages-2" class="widget widget_pages">
						<h2 class="widget-title"><?php esc_html_e('Explore Our Pages', 'seo-specialist'); ?></h2>
						<ul>
							<?php
								wp_list_pages(array(
									'title_li' => '',
								));
							?>
						</ul>
					</aside>
				<aside id="calendar-2" class="widget widget_calendar">
						<h2 class="widget-title"><?php esc_html_e('Calender', 'seo-specialist'); ?></h2>
						<?php get_calendar(); ?>
				</aside>
			   </div>
			</aside>
	<?php } ?>
		<main id="primary" class="site-main lay-width">
			<?php
			while ( have_posts() ) :
				the_post();

				get_template_part( 'revolution/template-parts/content', 'page' );

				if ( comments_open() || get_comments_number() ) :
					comments_template();
				endif;

			endwhile; // End of the loop.
			?>
		</main>
	</div>
	<?php 
	} elseif ( $seo_specialist_page_layout == 'layout-3' ) { // No-sidebar layout ?>
		<div class="site-wrapper full-width">
			<main id="primary" class="site-main lay-width">
				<?php
				while ( have_posts() ) :
					the_post();

					get_template_part( 'revolution/template-parts/content', 'page' );

					if ( comments_open() || get_comments_number() ) :
						comments_template();
					endif;

				endwhile; // End of the loop.
				?>
			</main>
		</div>
	<?php } ?>
</div>

<?php
get_footer();
				