<?php

/**  
 * The template used for displaying page content in page.php  
 *  
 * @package Chic Lifestyle  */

?>

<div class="page-title">
  <h1 class="my-32"><?php the_title(); ?></h1>
</div>

<div class="single-post">

  <?php
    $post_options = get_theme_mod('chic_lifestyle_post_details', array('date', 'categories', 'tags'));
    $featured_image_position = get_theme_mod('chic_lifestyle_featured_image_position', 'center');
    if ( $featured_image_position === 'left' ) {
      $featured_image_position_class = 'justify-content-start';
    } elseif ( $featured_image_position === 'right' ) {
      $featured_image_position_class = 'justify-content-end';
    } else {
      $featured_image_position_class = 'justify-content-center';
    }
  ?>
  <?php if (! empty($post_options)) : ?>

    <div class="info fs-85 text-info">
      <ul class="list-inline d-flex gap-16 m-0">
        <?php foreach ($post_options as $key => $value) : ?>

          <?php if ($value == 'author') { ?>
            <li>
              <a class="text-primary url fn n" href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>">
                <?php $avatar = get_avatar(
                  get_the_author_meta('ID'),
                  20,
                  '',
                  '',
                  array('class' => 'rounded-circle h-20 w-20')
                ); ?>
                <?php if ($avatar) : ?>
                  <div class="author-image float-start me-2">
                    <?php echo $avatar; ?>
                  </div>
                <?php endif; ?>
                <?php echo esc_html(get_the_author()); ?>
              </a>
            </li>
          <?php } ?>

          <?php if ($value == 'date') { ?>
            <?php $archive_year  = get_the_time('Y');
            $archive_month = get_the_time('m');
            $archive_day = get_the_time('d'); ?>
            <li><i class="fa fa-clock-o"></i> <a href="<?php echo esc_url(get_day_link($archive_year, $archive_month, $archive_day)); ?>"><?php echo get_the_date(); ?></a></li>
          <?php } ?>

          <?php if ($value == 'categories') { ?>
            <?php $categories = get_the_category();
            if (! empty($categories)) :
              foreach ($categories as $cat) { ?>
                <li><a href="<?php echo esc_url(get_category_link($cat->term_id)); ?>"><?php echo esc_html($cat->name); ?></a></li>
            <?php }
            endif; ?>
          <?php } ?>

          <?php if ($value == 'tags') { ?>
            <?php $tags = get_the_tags();
            if (! empty($tags)) :
              foreach ($tags as $tag) { ?>
                <li><a href="<?php echo esc_url(get_category_link($tag->term_id)); ?>"><?php echo esc_html($tag->name); ?></a></li>
            <?php }
            endif; ?>
          <?php } ?>


          <?php if ($value == 'number_of_comments') { ?>
            <li><i class="fa fa-comments-o"></i> <?php comments_popup_link(__('zero comment', 'chic-lifestyle'), __('one comment', 'chic-lifestyle'), __('% comments', 'chic-lifestyle')); ?></li>
          <?php } ?>

        <?php endforeach; ?>

      </ul>
    </div>

  <?php endif; ?>


  <div class="post-content">
    <figure class="py-16 mb-16 d-flex <?php echo esc_attr( $featured_image_position_class ); ?>" id="featured-image">
      <?php if (has_post_thumbnail() && ! post_password_required()) : ?>
          <?php the_post_thumbnail('full', ['class' => "featured-image rounded-0 object-fit-cover object-position-center"]); ?>
      <?php endif; ?>
    </figure>
    <article>
      <?php the_content(); ?>
      <?php wp_link_pages(array('before' => '<div class="page-links"><span class="page-links-title">' . __('Pages:', 'chic-lifestyle') . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>')); ?>
    </article> <!-- /.end of article -->
  </div>


</div>


<div class="entry-meta">
  <?php edit_post_link(__('Edit', 'chic-lifestyle'), '<span class="edit-link">', '</span>'); ?>
</div><!-- .entry-meta -->