| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Single Topic Lead Content Part |
| 5 |
* |
| 6 |
* @package bbPress |
| 7 |
* @subpackage Theme |
| 8 |
*/ |
| 9 |
|
| 10 |
// Exit if accessed directly. |
| 11 |
defined( 'ABSPATH' ) || exit; |
| 12 |
|
| 13 |
do_action( 'bbp_template_before_lead_topic' ); |
| 14 |
|
| 15 |
$topic_tag_list = bbp_get_topic_tag_list( |
| 16 |
get_the_ID(), |
| 17 |
array( |
| 18 |
'before' => '', |
| 19 |
'after' => '', |
| 20 |
'sep' => ', ', |
| 21 |
'none' => '', |
| 22 |
) |
| 23 |
); |
| 24 |
$has_topic_tags = ! empty( $topic_tag_list ); |
| 25 |
$action_btns_class = $has_topic_tags ? 'has-topic-tags' : 'no-topic-tags'; |
| 26 |
?> |
| 27 |
<div class="main-post"> |
| 28 |
<div class="topic-content-wrapper"> |
| 29 |
|
| 30 |
<div class="forum-post-top"> |
| 31 |
<div class="bbp-author-wrap"> |
| 32 |
<div class="author-avatar bbp-author-link"> |
| 33 |
<?php |
| 34 |
echo bbp_get_topic_author_link( |
| 35 |
array( |
| 36 |
'post_id' => get_the_ID(), |
| 37 |
'size' => 40, |
| 38 |
'type' => 'avatar', |
| 39 |
) |
| 40 |
); |
| 41 |
?> |
| 42 |
</div> |
| 43 |
|
| 44 |
<div class="forum-post-author"> |
| 45 |
<div class="topic-author author-flex author-gap"> |
| 46 |
<?php |
| 47 |
echo bbp_get_topic_author_link( |
| 48 |
array( |
| 49 |
'post_id' => get_the_ID(), |
| 50 |
'type' => 'name', |
| 51 |
) |
| 52 |
); |
| 53 |
?> |
| 54 |
<div class="author-badge badge <?php echo esc_attr( sanitize_title( forumax_get_bbp_user_role() ) ); ?>"> |
| 55 |
<?php forumax_bbp_user_role_icon(); ?> |
| 56 |
<span><?php echo esc_html( forumax_get_bbp_user_role() ); ?></span> |
| 57 |
</div> |
| 58 |
</div> |
| 59 |
|
| 60 |
<div class="forum-author-meta meta"> |
| 61 |
<span title="<?php bbp_topic_post_date( get_the_ID() ); ?>"> |
| 62 |
<?php bbp_topic_post_date( get_the_ID(), true ); ?> |
| 63 |
</span> |
| 64 |
<span class="dot"></span> |
| 65 |
<?php $lead_reply_count = bbp_get_topic_reply_count( bbp_get_topic_id() ); ?> |
| 66 |
<a href="#topic-<?php bbp_topic_id(); ?>-replies" class="replies-count"> |
| 67 |
<?php |
| 68 |
printf( |
| 69 |
/* translators: %s: number of replies */ |
| 70 |
esc_html( _n( '%s Reply', '%s Replies', $lead_reply_count, 'forumax' ) ), |
| 71 |
esc_html( number_format_i18n( $lead_reply_count ) ) |
| 72 |
); |
| 73 |
?> |
| 74 |
</a> |
| 75 |
</div> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
|
| 79 |
<div class="action-button-container"> |
| 80 |
<?php |
| 81 |
if ( is_user_logged_in() ) : |
| 82 |
bbp_topic_subscription_link( |
| 83 |
array( |
| 84 |
'before' => '', |
| 85 |
'after' => '', |
| 86 |
'unsubscribe' => esc_html__( 'Subscribed', 'forumax' ), |
| 87 |
) |
| 88 |
); |
| 89 |
else : |
| 90 |
if ( get_option( '_bbp_enable_subscriptions' ) == 1 && forumax_get_opt( 'is_topic_subscription' ) == 1 ) : |
| 91 |
?> |
| 92 |
<button class="button subscription-login-btn frmx-subscribe-trigger-btn"> |
| 93 |
<?php esc_html_e( 'Log in to subscribe', 'forumax' ); ?> |
| 94 |
</button> |
| 95 |
<div class="subscription-login-modal frmx-topic-sub-modal"> |
| 96 |
<div class="subscription-login-modal-inner"> |
| 97 |
<button class="subscription-login-modal-close" aria-label="<?php esc_attr_e( 'Close', 'forumax' ); ?>">×</button> |
| 98 |
<h3 class="frmx-inline-login-title"><?php echo esc_html( forumax_get_opt( 'subscription_modal_title', __( 'Login to the community', 'forumax' ) ) ); ?></h3> |
| 99 |
<p class="frmx-inline-login-subtitle"><?php echo esc_html( forumax_get_opt( 'subscription_modal_subtitle', __( 'You must be logged in to subscribe to this topic.', 'forumax' ) ) ); ?></p> |
| 100 |
<div class="frmx-subscription-login-form"> |
| 101 |
<button type="button" class="button fill-brand frmx-scroll-to-login"> |
| 102 |
<?php esc_html_e( 'Go to login form', 'forumax' ); ?> |
| 103 |
</button> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
</div> |
| 107 |
<?php |
| 108 |
endif; |
| 109 |
endif; |
| 110 |
?> |
| 111 |
|
| 112 |
<?php |
| 113 |
/** |
| 114 |
* Topic admin links dropdown (⋯ three-dot menu). |
| 115 |
* Placed next to Subscribe for quick access. |
| 116 |
*/ |
| 117 |
if ( is_user_logged_in() && function_exists( 'forumax_get_topic_admin_links' ) ) { |
| 118 |
echo forumax_get_topic_admin_links(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 119 |
} |
| 120 |
?> |
| 121 |
</div> |
| 122 |
</div> |
| 123 |
|
| 124 |
<div class="q-title"> |
| 125 |
<?php |
| 126 |
$topic_prefix = forumax_get_opt( 'topic_title_prefix', 'Q:' ); |
| 127 |
if ( ! empty( $topic_prefix ) ) : |
| 128 |
?> |
| 129 |
<span class="question-icon" title="Question"> |
| 130 |
<?php echo esc_html( $topic_prefix ); ?> |
| 131 |
</span> |
| 132 |
<?php endif; ?> |
| 133 |
<h1> |
| 134 |
<?php do_action( 'bbp_theme_before_topic_title' ); ?> |
| 135 |
<?php |
| 136 |
the_title(); |
| 137 |
do_action( 'bbpc-resolved-topics' ); |
| 138 |
?> |
| 139 |
</h1> |
| 140 |
</div> |
| 141 |
|
| 142 |
<div class="forum-post-content"> |
| 143 |
<?php do_action('bbp_theme_after_topic_author_details'); ?> |
| 144 |
<div class="topic-content-layout"> |
| 145 |
<?php |
| 146 |
$topic_post = get_post(); |
| 147 |
$forum_id = $topic_post ? bbp_get_topic_forum_id( $topic_post->ID ) : 0; |
| 148 |
$forum_vote = $forum_id ? get_post_meta( $forum_id, 'bbp_voting_forum_enable_topics', true ) : ''; |
| 149 |
|
| 150 |
// Note: despite the option id name, this switcher is used as an enable flag in the voting frontend. |
| 151 |
$topic_voting_enabled = ! empty( forumax_get_opt( 'is_voting_disabled_topics', 0 ) ); |
| 152 |
$voting_feature_on = (bool) forumax_get_opt( 'is_votes', true ); |
| 153 |
|
| 154 |
$show_vote_column = $voting_feature_on |
| 155 |
&& (bool) has_action( 'bbp_voting_cpt' ) |
| 156 |
&& ( ( ! empty( $forum_vote ) && $forum_vote !== 'false' ) || ( empty( $forum_vote ) && $topic_voting_enabled ) ); |
| 157 |
?> |
| 158 |
<?php if ( $show_vote_column ) : ?> |
| 159 |
<div class="topic-vote-column"> |
| 160 |
<?php |
| 161 |
/** |
| 162 |
* Render only the voting UI in the left column. |
| 163 |
*/ |
| 164 |
do_action( 'bbp_voting_cpt', $topic_post ); |
| 165 |
?> |
| 166 |
</div> |
| 167 |
<?php endif; ?> |
| 168 |
|
| 169 |
<div class="topic-content-body"> |
| 170 |
<div class="content editor-content"> |
| 171 |
<?php do_action('bbp_theme_before_topic_content'); ?> |
| 172 |
<?php bbp_topic_content(); ?> |
| 173 |
</div> |
| 174 |
|
| 175 |
<div class="action-button-container action-btns <?php echo esc_attr( $action_btns_class ); ?>"> |
| 176 |
<?php |
| 177 |
if ( has_action( 'bbp_theme_after_topic_content', 'bbp_voting_buttons' ) ) { |
| 178 |
remove_action( 'bbp_theme_after_topic_content', 'bbp_voting_buttons' ); |
| 179 |
} |
| 180 |
?> |
| 181 |
<?php do_action('bbp_theme_after_topic_content'); ?> |
| 182 |
<?php if ( $has_topic_tags ) : ?> |
| 183 |
<div class="taxonomy forum-post-tags"> |
| 184 |
<?php |
| 185 |
echo wp_kses_post( |
| 186 |
'<span class="tags-label">' . esc_html__( 'Tags:', 'forumax' ) . '</span> <span class="tags">' . $topic_tag_list . '</span>' |
| 187 |
); |
| 188 |
?> |
| 189 |
</div> |
| 190 |
<?php endif; ?> |
| 191 |
|
| 192 |
<div class="frmx-action-btns-right"> |
| 193 |
<?php |
| 194 |
bbp_topic_favorite_link( |
| 195 |
array( |
| 196 |
'before' => '', |
| 197 |
) |
| 198 |
); |
| 199 |
?> |
| 200 |
<?php |
| 201 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 202 |
echo forumax_topic_social_share(); |
| 203 |
?> |
| 204 |
</div> |
| 205 |
</div> |
| 206 |
</div> |
| 207 |
</div> |
| 208 |
</div> |
| 209 |
|
| 210 |
</div> |
| 211 |
</div> |
| 212 |
|
| 213 |
<?php |
| 214 |
do_action( 'bbp_template_after_lead_topic' ); |
| 215 |
|