98 lines
5.2 KiB
PHP
98 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* آیتم هر سوال در لیست — طرح hesabix2
|
|
*
|
|
* @package Hesabix2
|
|
* @subpackage AnsPress
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
if ( ! ap_user_can_view_post( get_the_ID() ) ) {
|
|
return;
|
|
}
|
|
|
|
$question_id = get_the_ID();
|
|
$views_count = ap_get_post_field( 'views', $question_id );
|
|
$views_count = is_numeric( $views_count ) ? (int) $views_count : 0;
|
|
$is_solved = ap_have_answer_selected( $question_id );
|
|
$is_private = is_private_post( $question_id );
|
|
$question_tags = get_the_terms( $question_id, 'question_tag' );
|
|
$content = get_the_content();
|
|
$excerpt = wp_trim_words( wp_strip_all_tags( $content ), 50, '...' );
|
|
?>
|
|
|
|
<article id="question-<?php the_ID(); ?>" <?php post_class( 'ap-question-item hesabix2-ap-item ap-card-qa bg-white rounded-2xl shadow-sm border border-slate-100 overflow-hidden group relative ' . ( $is_solved ? 'ap-card-qa--solved' : '' ) ); ?> itemtype="https://schema.org/Question" itemscope>
|
|
<div class="p-4 sm:p-5">
|
|
<div class="flex flex-col sm:flex-row gap-4">
|
|
<div class="flex-1 min-w-0 <?php echo $is_private ? 'sm:ps-14' : ''; ?>">
|
|
<div class="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3 mb-3">
|
|
<h3 class="text-lg font-semibold text-slate-800 group-hover:text-brand-600 transition-colors" itemprop="name">
|
|
<a class="ap-questions-hyperlink no-underline hover:underline" itemprop="url" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo esc_attr( get_the_title() ); ?>">
|
|
<?php echo esc_html( get_the_title() ); ?>
|
|
</a>
|
|
</h3>
|
|
<?php if ( $is_solved ) : ?>
|
|
<span class="inline-flex items-center gap-1.5 px-3 py-1 bg-success-500/15 text-success-700 text-sm font-medium rounded-full flex-shrink-0 border border-success-400/40">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
|
|
<span><?php esc_html_e( 'حل شده', 'anspress-question-answer' ); ?></span>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<p class="text-slate-600 mb-4 line-clamp-3 leading-relaxed"><?php echo esc_html( $excerpt ); ?></p>
|
|
|
|
<div class="flex flex-col sm:flex-row sm:items-center gap-4">
|
|
<?php if ( ! empty( $question_tags ) && ! is_wp_error( $question_tags ) ) : ?>
|
|
<div class="flex flex-wrap gap-2" itemprop="keywords">
|
|
<?php foreach ( $question_tags as $tag ) : ?>
|
|
<a href="<?php echo esc_url( get_term_link( $tag ) ); ?>" class="ap-tag inline-flex px-3 py-1 bg-light-100 text-brand-600 rounded-full text-sm font-medium hover:bg-brand-500/10 transition-colors">
|
|
<?php echo esc_html( $tag->name ); ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="flex flex-wrap items-center gap-4 text-sm text-slate-500">
|
|
<span class="flex items-center gap-1" itemprop="author" itemscope itemtype="http://schema.org/Person">
|
|
<?php ap_user_display_name( array( 'html' => true, 'echo' => true ) ); ?>
|
|
</span>
|
|
<time class="flex items-center gap-1" datetime="<?php echo esc_attr( ap_get_time( $question_id, 'c' ) ); ?>" itemprop="dateCreated">
|
|
<?php echo esc_html( ap_human_time( ap_get_time( $question_id, 'U' ) ) ); ?>
|
|
</time>
|
|
<?php if ( $views_count > 0 ) : ?>
|
|
<span class="flex items-center gap-1"><?php echo esc_html( number_format_i18n( $views_count ) ); ?> <?php esc_html_e( 'بازدید', 'anspress-question-answer' ); ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- باکس آمار -->
|
|
<div class="hesabix2-ap-item-stats flex sm:flex-col gap-4 sm:w-24 flex-shrink-0">
|
|
<?php if ( ! ap_opt( 'disable_voting_on_question' ) ) : ?>
|
|
<div class="flex items-center gap-2 sm:flex-col sm:gap-1">
|
|
<span class="text-xl font-bold tabular-nums <?php echo ap_votes_net() > 0 ? 'text-success-500' : ( ap_votes_net() < 0 ? 'text-red-500' : 'text-slate-600' ); ?>">
|
|
<span itemprop="upvoteCount"><?php echo esc_html( ap_votes_net() ); ?></span>
|
|
</span>
|
|
<span class="text-xs text-slate-500"><?php esc_html_e( 'رای', 'anspress-question-answer' ); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="flex items-center gap-2 sm:flex-col sm:gap-1">
|
|
<span class="text-xl font-bold tabular-nums <?php echo ap_answers_count() > 0 ? 'text-brand-600' : 'text-slate-600'; ?>">
|
|
<span itemprop="answerCount"><?php echo esc_html( ap_answers_count() ); ?></span>
|
|
</span>
|
|
<span class="text-xs text-slate-500"><?php esc_html_e( 'پاسخ', 'anspress-question-answer' ); ?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ( $is_private ) : ?>
|
|
<div class="absolute top-0 bottom-0 end-0 w-10 bg-accent-500 flex flex-col items-center justify-center py-4" dir="ltr">
|
|
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path></svg>
|
|
<span class="text-white text-[10px] font-semibold writing-mode-vertical rotate-180 mt-2"><?php esc_html_e( 'خصوصی', 'anspress-question-answer' ); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</article>
|