<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package aster_it_courses
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<div class="mag-post-single">
		<div class="mag-post-detail">
			<div class="mag-post-category">
				<?php aster_it_courses_categories_single_list(); ?>
			</div>
			<header class="entry-header">
				<?php
				if ( 'post' === get_post_type() ) :
					?>
					<div class="mag-post-meta">
						<?php
						aster_it_courses_posted_on_single();
						aster_it_courses_posted_by_single();
						aster_it_courses_posted_comments_single();
						aster_it_courses_posted_time_single();
						?>
					</div>
				<?php endif; ?>
			</header>
		</div>

		<?php
		$post_id = get_the_ID();
		$aster_it_courses_author_image = '';
		$aster_it_courses_author_name  = '';
		$aster_it_courses_paper_num    = '';
		$aster_it_courses_degree_num   = '';
		$aster_it_courses_price        = '';

		$aster_it_courses_featured_count = get_theme_mod('aster_it_courses_service_post_count');

		for ( $aster_it_courses_i = 1; $aster_it_courses_i <= $aster_it_courses_featured_count; $aster_it_courses_i++ ) {
			$aster_it_courses_theme_post_id = get_theme_mod( 'aster_it_courses_service_content_post_' . $aster_it_courses_i );
			if ( intval( $aster_it_courses_theme_post_id ) === $post_id ) {
				$aster_it_courses_author_image = get_theme_mod( 'aster_it_courses_author_image' . $aster_it_courses_i );
				$aster_it_courses_author_name  = get_theme_mod( 'aster_it_courses_author_name' . $aster_it_courses_i );
				$aster_it_courses_paper_num    = get_theme_mod( 'aster_it_courses_paper_count' . $aster_it_courses_i );
				$aster_it_courses_degree_num   = get_theme_mod( 'aster_it_courses_degree_count' . $aster_it_courses_i );
				$aster_it_courses_price        = get_theme_mod( 'aster_it_courses_regular_price' . $aster_it_courses_i );
				break;
			}
		}
		?>

		<?php aster_it_courses_post_thumbnail(); ?>

		<div class="custom-course-meta">
			<?php if ( $aster_it_courses_author_image || $aster_it_courses_author_name ) : ?>
				<div class="author-wrapper">
					<?php if ( $aster_it_courses_author_image ) : ?>
						<div class="author-image">
							<img src="<?php echo esc_url( $aster_it_courses_author_image ); ?>" alt="<?php esc_attr_e( 'author-image', 'aster-it-courses' ); ?>">
						</div>
					<?php endif; ?>
					<?php if ( $aster_it_courses_author_name ) : ?>
						<div class="author-name">
							<p><?php echo esc_html( $aster_it_courses_author_name ); ?></p>
						</div>
					<?php endif; ?>
				</div>
			<?php endif; ?>

			<div class="post-num">
				<div class="post-numbers">
					<?php if ( $aster_it_courses_paper_num ) : ?>
						<div class="paper-num">
							<span><i class="far fa-sticky-note"></i><?php echo esc_html( $aster_it_courses_paper_num ); ?></span>
						</div>
					<?php endif; ?>

					<?php if ( $aster_it_courses_degree_num ) : ?>
						<div class="degree-num">
							<span><i class="fas fa-user-graduate"></i><?php echo esc_html( $aster_it_courses_degree_num ); ?></span>
						</div>
					<?php endif; ?>
				</div>

				<?php if ( $aster_it_courses_price ) : ?>
					<div class="post-price">
						<span class="price"><?php echo esc_html( $aster_it_courses_price ); ?></span>
					</div>
				<?php endif; ?>
			</div>
		</div>

		<?php if ( ! get_theme_mod( 'aster_it_courses_single_post_hide_post_content', false ) ) : ?>
			<div class="entry-content">
				<?php
				the_content(
					sprintf(
						wp_kses(
							/* translators: %s: Name of current post. Only visible to screen readers */
							__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'aster-it-courses' ),
							array( 'span' => array( 'class' => array() ) )
						),
						wp_kses_post( get_the_title() )
					)
				);

				wp_link_pages( array(
					'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'aster-it-courses' ),
					'after'  => '</div>',
				) );
				?>
			</div>
		<?php endif; ?>

	</div>

	<footer class="entry-footer">
		<?php aster_it_courses_entry_footer(); ?>
	</footer>
</article>
