81 lines
5.3 KiB
PHP
81 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* کارت پست وبلاگ
|
|
*
|
|
* @package Hesabix2
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
$categories = get_the_category();
|
|
$reading_time = hesabix2_post_reading_time(get_the_ID());
|
|
$post_views = hesabix2_post_views_label(get_the_ID());
|
|
?>
|
|
<article id="post-<?php the_ID(); ?>" <?php post_class('blog-card group relative'); ?>>
|
|
<div class="blog-card-glow absolute inset-0 rounded-3xl blur opacity-20 group-hover:opacity-30 transition-opacity duration-300" aria-hidden="true"></div>
|
|
<div class="blog-card-inner relative bg-white rounded-3xl overflow-hidden shadow-lg hover:shadow-xl transition-all duration-300 flex flex-col h-full">
|
|
<div class="relative overflow-hidden shrink-0">
|
|
<?php if (has_post_thumbnail()) : ?>
|
|
<a href="<?php the_permalink(); ?>" class="block" tabindex="-1" aria-hidden="true">
|
|
<?php the_post_thumbnail('medium_large', array(
|
|
'class' => 'blog-card-img w-full aspect-[16/10] object-cover group-hover:scale-105 transition-transform duration-500',
|
|
'alt' => esc_attr(get_the_title()),
|
|
'loading' => 'lazy',
|
|
)); ?>
|
|
</a>
|
|
<?php else : ?>
|
|
<a href="<?php the_permalink(); ?>" class="block w-full aspect-[16/10] bg-gradient-to-br from-slate-100 to-slate-200 flex items-center justify-center" tabindex="-1" aria-hidden="true">
|
|
<svg class="w-16 h-16 text-slate-300" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
|
|
</svg>
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($categories)) : ?>
|
|
<div class="absolute top-4 right-4 flex flex-wrap gap-2">
|
|
<?php foreach (array_slice($categories, 0, 2) as $category) : ?>
|
|
<a href="<?php echo esc_url(get_category_link($category->term_id)); ?>"
|
|
class="blog-card-cat px-3 py-1 bg-brand-600 text-white text-xs font-medium rounded-full shadow hover:bg-brand-700 transition-colors">
|
|
<?php echo esc_html($category->name); ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="p-5 lg:p-6 flex flex-col flex-1 min-h-0">
|
|
<div class="blog-card-meta flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-slate-500 mb-3">
|
|
<span class="flex items-center gap-1.5">
|
|
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>
|
|
<time datetime="<?php echo esc_attr(get_the_date('c')); ?>"><?php echo esc_html(get_the_date('Y/n/d')); ?></time>
|
|
</span>
|
|
<?php if ($reading_time) : ?>
|
|
<span class="blog-card-meta__dot" aria-hidden="true">·</span>
|
|
<span><?php echo esc_html($reading_time); ?></span>
|
|
<?php endif; ?>
|
|
<span class="blog-card-meta__dot" aria-hidden="true">·</span>
|
|
<span class="flex items-center gap-1.5">
|
|
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path></svg>
|
|
<?php echo esc_html($post_views); ?> <?php esc_html_e('بازدید', 'hesabix2'); ?>
|
|
</span>
|
|
</div>
|
|
<h2 class="blog-card-title text-lg font-bold text-slate-900 mb-2 line-clamp-2 group-hover:text-brand-600 transition-colors">
|
|
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
|
</h2>
|
|
<p class="blog-card-excerpt text-slate-600 text-sm leading-relaxed line-clamp-3 mb-4 flex-1">
|
|
<?php
|
|
$excerpt = get_the_excerpt();
|
|
echo esc_html($excerpt ? wp_trim_words($excerpt, 22) : wp_trim_words(get_the_content(), 22));
|
|
?>
|
|
</p>
|
|
<a href="<?php the_permalink(); ?>" class="blog-card-more inline-flex items-center gap-2 text-brand-600 hover:text-brand-700 font-medium text-sm transition-colors group/link mt-auto">
|
|
<span><?php esc_html_e('ادامه مطلب', 'hesabix2'); ?></span>
|
|
<svg class="w-4 h-4 group-hover/link:-translate-x-0.5 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</article>
|