<h1>YANZ UPLOAD ANJG</h1><?php
/**
 * Single article: breadcrumbs, byline, featured image, gallery, source
 * attribution, sharing and related articles.
 *
 * @package TotalOnlineNews
 */
get_header();
?>

<?php while ( have_posts() ) : the_post(); ?>

	<?php $ton_cats = get_the_category(); $ton_cat = $ton_cats ? $ton_cats[0] : null; ?>

	<div class="shell">
		<?php ton_breadcrumbs(); ?>
	</div>

	<article <?php post_class( 'shell ton-article' ); ?>>
		<header>
			<?php if ( $ton_cat ) : ?>
				<a class="ton-badge ton-badge--solid" style="background:<?php echo esc_attr( ton_category_color( $ton_cat ) ); ?>" href="<?php echo esc_url( get_category_link( $ton_cat->term_id ) ); ?>"><?php echo esc_html( $ton_cat->name ); ?></a>
			<?php endif; ?>

			<h1 class="ton-article__title"><?php the_title(); ?></h1>

			<?php $ton_sub = ton_meta( '_ton_subtitle' ); if ( ! $ton_sub ) { $ton_sub = ton_meta( '_ton_seo_description' ); } ?>
			<?php if ( $ton_sub ) : ?>
				<p class="ton-article__standfirst"><?php echo esc_html( $ton_sub ); ?></p>
			<?php endif; ?>

			<div class="ton-article__meta">
				<span style="display:inline-flex;align-items:center;gap:.5rem">
					<span class="ton-byline-avatar" aria-hidden="true"><?php echo esc_html( mb_substr( get_the_author(), 0, 1 ) ); ?></span>
					<span><?php esc_html_e( 'By', 'totalonlinenews' ); ?> <span class="ton-article__author"><?php the_author(); ?></span></span>
				</span>
				<time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>" style="display:inline-flex;align-items:center;gap:.35rem">
					<?php ton_icon( 'clock' ); ?><?php echo esc_html( get_the_date() ); ?>
				</time>
				<span><?php echo esc_html( ton_reading_time() . ' ' . __( 'min read', 'totalonlinenews' ) ); ?></span>
				<?php $ton_views = ton_legacy_views( get_the_ID() ); if ( $ton_views > 0 ) : ?>
					<span><?php echo esc_html( number_format_i18n( $ton_views ) . ' ' . __( 'views', 'totalonlinenews' ) ); ?></span>
				<?php endif; ?>
			</div>
		</header>

		<?php if ( has_post_thumbnail() ) : ?>
			<figure class="ton-article__cover">
				<?php ton_thumb( 'ton-hero' ); ?>
				<?php $ton_cap = ton_meta( '_ton_cover_caption' ); if ( $ton_cap ) : ?>
					<figcaption class="ton-article__caption"><?php echo esc_html( $ton_cap ); ?></figcaption>
				<?php endif; ?>
			</figure>
		<?php endif; ?>

		<div class="ton-prose">
			<?php the_content(); ?>
			<?php wp_link_pages( array( 'before' => '<nav class="ton-pagelinks">', 'after' => '</nav>' ) ); ?>
		</div>

		<?php ton_gallery_block(); ?>
		<?php ton_source_block(); ?>

		<?php $ton_tags = get_the_tags(); if ( $ton_tags ) : ?>
			<ul class="ton-tags">
				<?php foreach ( $ton_tags as $ton_tag ) : ?>
					<li><a href="<?php echo esc_url( get_tag_link( $ton_tag->term_id ) ); ?>" rel="tag">#<?php echo esc_html( $ton_tag->name ); ?></a></li>
				<?php endforeach; ?>
			</ul>
		<?php endif; ?>

		<?php ton_share_buttons(); ?>

		<?php if ( comments_open() || get_comments_number() ) { comments_template(); } ?>
	</article>

	<?php /* ---------------- Related ---------------- */
	$ton_rel_args = array(
		'post_type'           => 'post',
		'post_status'         => 'publish',
		'posts_per_page'      => 3,
		'post__not_in'        => array( get_the_ID() ),
		'ignore_sticky_posts' => true,
	);
	if ( $ton_cat ) { $ton_rel_args['cat'] = $ton_cat->term_id; }
	$ton_rel = new WP_Query( $ton_rel_args );
	if ( ! $ton_rel->have_posts() ) {
		unset( $ton_rel_args['cat'] );
		$ton_rel = new WP_Query( $ton_rel_args );
	}
	if ( $ton_rel->have_posts() ) : ?>
		<section class="shell ton-section ton-related" aria-labelledby="ton-related-h">
			<div class="ton-section__head">
				<h2 class="ton-section__title" id="ton-related-h"><?php esc_html_e( 'Related Articles', 'totalonlinenews' ); ?></h2>
			</div>
			<div class="ton-grid ton-grid--3" style="margin-top:1.25rem">
				<?php while ( $ton_rel->have_posts() ) : $ton_rel->the_post(); ?>
					<?php get_template_part( 'template-parts/card', null, array( 'variant' => 'card' ) ); ?>
				<?php endwhile; wp_reset_postdata(); ?>
			</div>
		</section>
	<?php endif; ?>

<?php endwhile; ?>