File: /var/www/html/wp-content/plugins/ethnic-single-post-layout/template.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
get_header();
?>
<div id="main" class="site-main page__top-shadow visible ethnic-single-post-page" role="main" aria-label="Main">
<div id="main-content" class="main-content">
<?php
if ( have_posts() ) :
the_post();
$post_id = get_the_ID();
$title = get_the_title();
$excerpt = ethnic_single_post_layout_excerpt_text( $post_id );
$content_payload = ethnic_single_post_layout_prepare_content_markup( $post_id );
$content_html = isset( $content_payload['html'] ) ? (string) $content_payload['html'] : '';
$content_outline = isset( $content_payload['outline'] ) && is_array( $content_payload['outline'] ) ? $content_payload['outline'] : array();
$author_id = (int) get_post_field( 'post_author', $post_id );
$author_name = get_the_author_meta( 'display_name', $author_id );
$author_url = get_author_posts_url( $author_id );
$publish_date = get_the_date( 'F d, Y', $post_id );
$reading_minutes = ethnic_single_post_layout_reading_minutes( $post_id );
$category_terms = ethnic_single_post_layout_normalize_terms( get_the_terms( $post_id, 'category' ) );
$tag_terms = ethnic_single_post_layout_normalize_terms( get_the_terms( $post_id, 'post_tag' ) );
$featured_image_id = get_post_thumbnail_id( $post_id );
$featured_image = $featured_image_id
? wp_get_attachment_image(
$featured_image_id,
'full',
false,
array(
'class' => 'ethnic-single-post__featured-image',
'loading' => 'eager',
'fetchpriority' => 'high',
)
)
: '';
$related_posts = ethnic_single_post_layout_related_posts( $post_id );
$share_links = ethnic_single_post_layout_share_links( $post_id );
$back_link = home_url( '/news/' );
$primary_category = ! empty( $category_terms ) ? $category_terms[0] : null;
$primary_category_url = $primary_category ? ethnic_single_post_layout_term_url( $primary_category ) : '';
$sidebar_term = ethnic_single_post_layout_sidebar_term( $post_id, array_merge( $category_terms, $tag_terms ) );
$sidebar_posts = $sidebar_term ? ethnic_single_post_layout_term_posts( $sidebar_term, $post_id ) : array();
$placeholder_logo = ethnic_single_post_layout_placeholder_logo_payload();
?>
<div class="ethnic-single-post">
<section class="ethnic-single-post__hero">
<div class="ethnic-shell ethnic-shell--article">
<a class="ethnic-single-post__back-link" href="<?php echo esc_url( $back_link ); ?>">Back to insights</a>
<div class="ethnic-single-post__hero-copy">
<div class="ethnic-single-post__eyebrow">
<?php if ( $primary_category && $primary_category_url ) : ?>
<a class="ethnic-single-post__eyebrow-link" href="<?php echo esc_url( $primary_category_url ); ?>">
<?php echo esc_html( $primary_category->name ); ?>
</a>
<?php endif; ?>
<span class="ethnic-single-post__eyebrow-meta"><?php echo esc_html( $publish_date ); ?></span>
<span class="ethnic-single-post__eyebrow-separator" aria-hidden="true"></span>
<span class="ethnic-single-post__eyebrow-meta"><?php echo esc_html( sprintf( _n( '%d min read', '%d mins read', $reading_minutes, 'thegem' ), $reading_minutes ) ); ?></span>
</div>
<h1 class="ethnic-single-post__title"><?php echo esc_html( $title ); ?></h1>
<?php if ( $excerpt ) : ?>
<p class="ethnic-single-post__excerpt"><?php echo esc_html( $excerpt ); ?></p>
<?php endif; ?>
<div class="ethnic-single-post__hero-footer">
<div class="ethnic-single-post__byline">
<span class="ethnic-single-post__byline-item">
by
<a class="ethnic-single-post__byline-link" href="<?php echo esc_url( $author_url ); ?>">
<?php echo esc_html( $author_name ); ?>
</a>
</span>
<span class="ethnic-single-post__byline-separator" aria-hidden="true"></span>
<span class="ethnic-single-post__byline-item"><?php echo esc_html( sprintf( _n( '%d minute read', '%d minutes read', $reading_minutes, 'thegem' ), $reading_minutes ) ); ?></span>
</div>
</div>
</div>
</div>
<?php if ( $featured_image ) : ?>
<div class="ethnic-shell ethnic-shell--wide">
<div class="ethnic-single-post__hero-media">
<div class="ethnic-single-post__hero-media-frame">
<?php echo $featured_image; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
</div>
<?php endif; ?>
</section>
<section class="ethnic-single-post__main">
<div class="ethnic-shell ethnic-shell--article<?php echo ! empty( $content_outline ) ? ' ethnic-shell--article-with-toc' : ''; ?>">
<div class="ethnic-single-post__main-grid<?php echo ! empty( $content_outline ) ? ' ethnic-single-post__main-grid--has-toc' : ''; ?>">
<aside class="ethnic-single-post__sidebar" aria-label="Article sidebar">
<div class="ethnic-single-post__sidebar-block">
<div class="ethnic-single-post__fact-list">
<div class="ethnic-single-post__fact">
<span class="ethnic-single-post__fact-label">Published</span>
<div class="ethnic-single-post__fact-value"><?php echo esc_html( $publish_date ); ?></div>
</div>
<?php if ( $sidebar_term && ! empty( $sidebar_posts ) ) : ?>
<div class="ethnic-single-post__fact">
<div class="ethnic-single-post__fact-value">
<div class="ethnic-single-post__category-posts" aria-label="<?php echo esc_attr( sprintf( '%s articles', $sidebar_term->name ) ); ?>">
<?php foreach ( $sidebar_posts as $category_post ) : ?>
<?php
$category_post_id = $category_post instanceof WP_Post ? (int) $category_post->ID : 0;
if ( ! $category_post_id ) {
continue;
}
?>
<a class="ethnic-single-post__category-post-link" href="<?php echo esc_url( get_permalink( $category_post_id ) ); ?>">
<span class="ethnic-single-post__category-post-thumb">
<?php if ( has_post_thumbnail( $category_post_id ) ) : ?>
<?php
echo get_the_post_thumbnail(
$category_post_id,
'thumbnail',
array(
'class' => 'ethnic-single-post__category-post-image',
'loading' => 'lazy',
)
); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<?php else : ?>
<?php if ( ! empty( $placeholder_logo['url'] ) ) : ?>
<img
class="ethnic-single-post__category-post-placeholder-logo"
src="<?php echo esc_url( $placeholder_logo['url'] ); ?>"
<?php echo ! empty( $placeholder_logo['srcset'] ) ? 'srcset="' . esc_attr( $placeholder_logo['srcset'] ) . '"' : ''; ?>
alt="Ethnic Infotech"
loading="lazy"
decoding="async"
>
<?php endif; ?>
<?php endif; ?>
</span>
<span class="ethnic-single-post__category-post-copy">
<span class="ethnic-single-post__category-post-title"><?php echo esc_html( get_the_title( $category_post_id ) ); ?></span>
<span class="ethnic-single-post__category-post-date"><?php echo esc_html( get_the_date( 'd M Y', $category_post_id ) ); ?></span>
</span>
</a>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php if ( ! empty( $share_links ) ) : ?>
<div class="ethnic-single-post__sidebar-block">
<span class="ethnic-single-post__sidebar-heading">Share</span>
<div class="ethnic-single-post__share-list">
<?php foreach ( $share_links as $share_link ) : ?>
<a class="ethnic-single-post__share-link" href="<?php echo esc_url( $share_link['url'] ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php echo esc_attr( $share_link['label'] ); ?>" title="<?php echo esc_attr( $share_link['label'] ); ?>">
<?php if ( ! empty( $share_link['icon'] ) ) : ?>
<span class="ethnic-single-post__share-icon" aria-hidden="true">
<?php echo ethnic_single_post_layout_share_icon_svg( $share_link['icon'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</span>
<?php endif; ?>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</aside>
<article class="ethnic-single-post__article" aria-label="Article content">
<div class="ethnic-single-post__article-card">
<div class="ethnic-single-post__content">
<?php echo $content_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php if ( ! empty( $category_terms ) || ! empty( $tag_terms ) ) : ?>
<div class="ethnic-single-post__article-footer">
<?php if ( ! empty( $category_terms ) ) : ?>
<div class="ethnic-single-post__meta-group">
<span class="ethnic-single-post__section-kicker">Filed under</span>
<div class="ethnic-single-post__meta-pills">
<?php foreach ( $category_terms as $category_term ) : ?>
<?php $category_url = ethnic_single_post_layout_term_url( $category_term ); ?>
<?php if ( $category_url ) : ?>
<a class="ethnic-single-post__pill" href="<?php echo esc_url( $category_url ); ?>">
<?php echo esc_html( $category_term->name ); ?>
</a>
<?php else : ?>
<span class="ethnic-single-post__pill"><?php echo esc_html( $category_term->name ); ?></span>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if ( ! empty( $tag_terms ) ) : ?>
<div class="ethnic-single-post__meta-group">
<span class="ethnic-single-post__section-kicker">Tagged with</span>
<div class="ethnic-single-post__meta-pills">
<?php foreach ( $tag_terms as $tag_term ) : ?>
<?php $tag_url = ethnic_single_post_layout_term_url( $tag_term ); ?>
<?php if ( $tag_url ) : ?>
<a class="ethnic-single-post__tag" href="<?php echo esc_url( $tag_url ); ?>">
<?php echo esc_html( $tag_term->name ); ?>
</a>
<?php else : ?>
<span class="ethnic-single-post__tag"><?php echo esc_html( $tag_term->name ); ?></span>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="ethnic-single-post__cta">
<div class="ethnic-single-post__cta-copy">
<span class="ethnic-single-post__cta-kicker">Need a strong digital partner?</span>
<h2 class="ethnic-single-post__cta-title">Planning your next product, platform, or growth move?</h2>
<p class="ethnic-single-post__cta-text">Ethnic Infotech helps teams shape scalable software, sharper customer experiences, and content systems that support real business growth.</p>
</div>
<div class="ethnic-single-post__cta-actions">
<a class="ethnic-single-post__button ethnic-single-post__button--primary" href="<?php echo esc_url( home_url( '/contact-us/' ) ); ?>">Talk to our team</a>
<a class="ethnic-single-post__button ethnic-single-post__button--secondary" href="<?php echo esc_url( $back_link ); ?>">Browse more articles</a>
</div>
</div>
<?php if ( comments_open( $post_id ) || get_comments_number( $post_id ) ) : ?>
<section class="ethnic-single-post__comments" aria-label="Article comments">
<?php comments_template(); ?>
</section>
<?php endif; ?>
</article>
<?php if ( ! empty( $content_outline ) ) : ?>
<aside class="ethnic-single-post__toc-sidebar" aria-label="Article contents sidebar">
<div class="ethnic-single-post__sidebar-block ethnic-single-post__sidebar-block--toc">
<details class="ethnic-single-post__toc-dropdown" open>
<summary class="ethnic-single-post__toc-summary">
<span class="ethnic-single-post__sidebar-heading">On this page</span>
<span class="ethnic-single-post__toc-summary-icon" aria-hidden="true"></span>
</summary>
<nav class="ethnic-single-post__toc" aria-label="Article contents">
<ul class="ethnic-single-post__toc-list">
<?php foreach ( $content_outline as $outline_item ) : ?>
<li class="ethnic-single-post__toc-item">
<a class="ethnic-single-post__toc-link" data-level="<?php echo esc_attr( (string) $outline_item['level'] ); ?>" href="#<?php echo esc_attr( $outline_item['id'] ); ?>">
<span><?php echo esc_html( $outline_item['text'] ); ?></span>
</a>
</li>
<?php endforeach; ?>
</ul>
</nav>
</details>
</div>
</aside>
<?php endif; ?>
</div>
</div>
</section>
<?php if ( $related_posts->have_posts() ) : ?>
<section class="ethnic-single-post__related">
<div class="ethnic-shell ethnic-shell--article">
<div class="ethnic-single-post__related-head">
<span class="ethnic-single-post__section-kicker">More insights</span>
<h2 class="ethnic-single-post__related-title">Keep reading</h2>
</div>
<div class="ethnic-single-post__related-grid">
<?php
while ( $related_posts->have_posts() ) :
$related_posts->the_post();
$related_id = get_the_ID();
$related_category = ethnic_single_post_layout_normalize_terms( get_the_terms( $related_id, 'category' ) );
$related_term = ! empty( $related_category ) ? $related_category[0] : null;
$related_excerpt = ethnic_single_post_layout_excerpt_text( $related_id );
$related_term_name = $related_term ? $related_term->name : '';
?>
<article class="ethnic-single-post__related-card">
<a class="ethnic-single-post__related-image" href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( 'large' ); ?>
<?php else : ?>
<span class="ethnic-single-post__related-placeholder" aria-hidden="true"></span>
<?php endif; ?>
</a>
<div class="ethnic-single-post__related-body">
<div class="ethnic-single-post__related-meta">
<?php if ( $related_term_name ) : ?>
<span><?php echo esc_html( $related_term_name ); ?></span>
<?php endif; ?>
<span><?php echo esc_html( get_the_date( 'd M Y', $related_id ) ); ?></span>
</div>
<h3 class="ethnic-single-post__related-heading">
<a class="ethnic-single-post__related-link" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>
<?php if ( $related_excerpt ) : ?>
<p class="ethnic-single-post__related-excerpt"><?php echo esc_html( wp_trim_words( $related_excerpt, 18, '...' ) ); ?></p>
<?php endif; ?>
</div>
</article>
<?php endwhile; ?>
</div>
</div>
</section>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php
get_footer();