post_type !== Core::POST) {
return;
}
$id = (int) $post->ID;
$plate_id = (int) get_post_meta($id, '_jio_forum_plate_id', true);
$type = (string) get_post_meta($id, '_jio_forum_type', true);
$user_id = get_current_user_id();
$can_view = Access::can_view($user_id, $id);
echo '';
echo '
';
\Jio\WidgetSystem\WidgetAreas::render('forum_post_top_fluid');
do_action('bbs_posts_page_content_top');
if ($can_view) echo self::cover($post);
echo self::breadcrumbs($post);
echo '
';
echo '' . self::title($post) . self::meta($post) . '
';
echo self::content($post, $can_view);
echo self::footer($post);
echo '';
if ($can_view) {
self::comments($id);
}
do_action('bbs_posts_page_content_bottom');
\Jio\WidgetSystem\WidgetAreas::render('forum_post_bottom_fluid');
echo '
';
if (jio_is_show_sidebar()) {
echo '';
}
echo '
';
}
private static function breadcrumbs(\WP_Post $post): string {
$plate_id = (int) get_post_meta($post->ID, '_jio_forum_plate_id', true);
$icon = ' ';
$html = '
';
}
private static function cover(\WP_Post $post): string {
if (!has_post_thumbnail($post)) return '';
return '' . get_the_post_thumbnail($post, 'large', ['class' => 'fit-cover']) . '
';
}
private static function title(\WP_Post $post): string {
return Cards::title($post, 'article-title', '', true);
}
private static function meta(\WP_Post $post): string {
$author = (int) $post->post_author;
$name = function_exists('jio_get_user_name') ? jio_get_user_name(['id' => $author, 'class' => '', 'name_class' => 'focus-color']) : esc_html((string) get_the_author_meta('display_name', $author));
$left = '' . $name
. '' . esc_html(Cards::ago($post->post_date)) . '
';
$right = ''
. '- ' . esc_html(jio_cut_count((int) get_post_meta($post->ID, '_jio_forum_views', true))) . '
'
. ''
. '
';
return '' . $left . $right . '
';
}
private static function content(\WP_Post $post, bool $can_view): string {
$id = (int) $post->ID;
if (!$can_view) {
return '' . self::locked($post) . '
';
}
$html = '' . apply_filters('the_content', $post->post_content) . '
';
$type = (string) get_post_meta($id, '_jio_forum_type', true);
if ($type === 'vote') {
$html .= self::vote($post);
}
return $html;
}
private static function locked(\WP_Post $post): string {
$id = (int) $post->ID;
$plate_id = (int) get_post_meta($id, '_jio_forum_plate_id', true);
$user_id = get_current_user_id();
$html = jio_get_null('抱歉!您暂无查看此内容的权限', 10, 'null-post.svg');
if ($user_id <= 0) {
return $html . '登录后查看
';
}
$plate_rule = (string) get_post_meta($plate_id, '_jio_forum_view_limit', true);
$post_rule = (string) get_post_meta($id, '_jio_forum_view_limit', true);
$action = '';
if (in_array($plate_rule, ['points', 'pay'], true) && !Commerce::has_plate_entitlement($user_id, $plate_id)) {
$action = '';
} elseif (($plate_rule === 'follow' || $post_rule === 'follow') && !Access::follows($user_id, $plate_id)) {
$action = Cards::follow_button($plate_id, 'but jb-blue padding-lg');
} elseif (in_array($post_rule, ['points', 'pay'], true)) {
$action = '';
}
return $html . ($action !== '' ? '' . $action . '
' : '');
}
private static function vote(\WP_Post $post): string {
$id = (int) $post->ID;
$options = (array) get_post_meta($id, '_jio_forum_vote_options', true);
if (!$options) return '';
$counts = (array) get_post_meta($id, '_jio_forum_vote_counts', true);
$total = (int) get_post_meta($id, '_jio_forum_vote_total', true);
$vote_type = (string) get_post_meta($id, '_jio_forum_vote_type', true);
$deadline = (int) get_post_meta($id, '_jio_forum_vote_deadline', true);
$expired = $deadline > 0 && current_time('timestamp') > $deadline;
$display = (string) jio_get_setting('jio_forum_vote_number_type', 'percentage');
$voted = get_current_user_id() > 0 && get_user_meta(get_current_user_id(), '_jio_forum_vote_' . $id, true) !== '';
$html = '';
}
private static function footer(\WP_Post $post): string {
$id = (int) $post->ID;
$user_id = get_current_user_id();
$plate_id = (int) get_post_meta($id, '_jio_forum_plate_id', true);
$html = '';
$html .= '';
if (jio_get_setting('jio_forum_score_enabled', true)) {
$score = (int) get_post_meta($id, '_jio_forum_score', true);
$html .= '';
$html .= '';
}
$html .= '
';
if (function_exists('jio_get_post_share_btn')) $html .= jio_get_post_share_btn($post, 'item', true, false);
$html .= '
';
$html .= '
';
if (Access::can_manage_post($user_id, $id)) {
$html .= '
编辑';
$html .= '
';
}
$html .= '
';
$html .= '';
if (get_post_meta($id, '_jio_forum_type', true) === 'question' && get_post_meta($id, '_jio_forum_adopted_comment', true)) {
$html .= '已采纳回复
';
}
return $html;
}
private static function comments(int $post_id): void {
echo '';
View::replies($post_id);
echo '
';
}
}