| 1 |
<?php |
| 2 |
namespace admin\Blocks\Render; |
| 3 |
|
| 4 |
use WP_Query; |
| 5 |
|
| 6 |
class Forum_Tab { |
| 7 |
/** |
| 8 |
* Render the Forum Tab block. |
| 9 |
* |
| 10 |
* Displays forums and topics in tabbed layout with full |
| 11 |
* customization for layout, visibility, colors, typography, |
| 12 |
* spacing, and responsive behavior. |
| 13 |
* |
| 14 |
* @param array $attributes Block attributes. |
| 15 |
* @param string $content Block content. |
| 16 |
* |
| 17 |
* @return string Rendered block HTML. |
| 18 |
*/ |
| 19 |
public function render_forum_tab( $attributes, $content ) { |
| 20 |
|
| 21 |
$settings = $attributes; |
| 22 |
$forum_tab_title = ! empty( $attributes['forum_tab_title'] ) ? $attributes['forum_tab_title'] : __( 'Show Forums', 'bbp-core' ); |
| 23 |
$topics_tab_title = ! empty( $attributes['topics_tab_title'] ) ? $attributes['topics_tab_title'] : __( 'Show Topics', 'bbp-core' ); |
| 24 |
$ppp = ! empty( $attributes['ppp'] ) ? absint( $attributes['ppp'] ) : 9; |
| 25 |
$ppp2 = ! empty( $attributes['ppp2'] ) ? absint( $attributes['ppp2'] ) : 6; |
| 26 |
$order = ! empty( $attributes['order'] ) ? $attributes['order'] : 'ASC'; |
| 27 |
$order2 = ! empty( $attributes['order2'] ) ? $attributes['order2'] : 'ASC'; |
| 28 |
$orderby = ! empty( $attributes['orderby'] ) ? $attributes['orderby'] : 'date'; |
| 29 |
$orderby2 = ! empty( $attributes['orderby2'] ) ? $attributes['orderby2'] : 'date'; |
| 30 |
$default_tab = ! empty( $attributes['default_active_tab'] ) ? $attributes['default_active_tab'] : 'forum'; |
| 31 |
$columns = ! empty( $attributes['columns'] ) ? absint( $attributes['columns'] ) : 3; |
| 32 |
$forum_image_size = ! empty( $attributes['forum_image_size'] ) ? $attributes['forum_image_size'] : 'thumbnail'; |
| 33 |
$no_posts_message = ! empty( $attributes['no_posts_message'] ) ? $attributes['no_posts_message'] : __( 'No posts found.', 'bbp-core' ); |
| 34 |
$forum_filter_ids = ! empty( $attributes['forum_filter_ids'] ) ? $attributes['forum_filter_ids'] : ''; |
| 35 |
|
| 36 |
// Visibility toggles. |
| 37 |
$show_forum_image = isset( $attributes['show_forum_image'] ) ? $attributes['show_forum_image'] : true; |
| 38 |
$show_forum_post_count = isset( $attributes['show_forum_post_count'] ) ? $attributes['show_forum_post_count'] : true; |
| 39 |
$show_forum_reply_count = isset( $attributes['show_forum_reply_count'] ) ? $attributes['show_forum_reply_count'] : true; |
| 40 |
$show_forum_excerpt = isset( $attributes['show_forum_excerpt'] ) ? $attributes['show_forum_excerpt'] : false; |
| 41 |
$show_topic_avatar = isset( $attributes['show_topic_avatar'] ) ? $attributes['show_topic_avatar'] : true; |
| 42 |
$show_topic_post_info = isset( $attributes['show_topic_post_info'] ) ? $attributes['show_topic_post_info'] : true; |
| 43 |
$show_topic_tags = isset( $attributes['show_topic_tags'] ) ? $attributes['show_topic_tags'] : true; |
| 44 |
$show_topic_post_reach = isset( $attributes['show_topic_post_reach'] ) ? $attributes['show_topic_post_reach'] : true; |
| 45 |
$enable_card_hover = isset( $attributes['enable_card_hover'] ) ? $attributes['enable_card_hover'] : true; |
| 46 |
|
| 47 |
// Enforce free defaults when Pro is not active. |
| 48 |
$is_pro_active = function_exists( 'forumax_is_premium' ) && forumax_is_premium(); |
| 49 |
if ( ! $is_pro_active ) { |
| 50 |
$default_tab = 'forum'; |
| 51 |
$columns = 3; |
| 52 |
$show_forum_image = true; |
| 53 |
$show_forum_post_count = true; |
| 54 |
$show_forum_reply_count = true; |
| 55 |
$show_forum_excerpt = false; |
| 56 |
$show_topic_avatar = true; |
| 57 |
$show_topic_post_info = true; |
| 58 |
$show_topic_tags = true; |
| 59 |
$show_topic_post_reach = true; |
| 60 |
$enable_card_hover = true; |
| 61 |
$mobile_columns = 1; |
| 62 |
$hide_forum_image_mobile = false; |
| 63 |
$hide_topic_reach_mobile = true; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
$this_get_id = 'bbpcft-' . uniqid(); |
| 68 |
|
| 69 |
|
| 70 |
$forum_args = array( |
| 71 |
'post_type' => 'forum', |
| 72 |
'posts_per_page' => $ppp, |
| 73 |
'order' => $order, |
| 74 |
'orderby' => $orderby, |
| 75 |
); |
| 76 |
|
| 77 |
// Filter by specific forum IDs. |
| 78 |
if ( ! empty( $forum_filter_ids ) ) { |
| 79 |
$ids = array_map( 'absint', array_filter( explode( ',', $forum_filter_ids ) ) ); |
| 80 |
if ( ! empty( $ids ) ) { |
| 81 |
$forum_args['post__in'] = $ids; |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
$forums = new \WP_Query( $forum_args ); |
| 86 |
|
| 87 |
|
| 88 |
$topic_args = array( |
| 89 |
'post_type' => 'topic', |
| 90 |
'posts_per_page' => $ppp2, |
| 91 |
'order' => $order2, |
| 92 |
'orderby' => $orderby2, |
| 93 |
); |
| 94 |
|
| 95 |
// If filtering by forum IDs, only show topics from those forums. |
| 96 |
if ( ! empty( $forum_filter_ids ) ) { |
| 97 |
$ids = array_map( 'absint', array_filter( explode( ',', $forum_filter_ids ) ) ); |
| 98 |
if ( ! empty( $ids ) ) { |
| 99 |
$topic_args['post_parent__in'] = $ids; |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
$topics = new \WP_Query( $topic_args ); |
| 104 |
|
| 105 |
|
| 106 |
if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) { |
| 107 |
wp_register_style( 'bbpc-el-widgets', FORUMAX_STYLES . 'frontend/el-widgets.css', array(), FORUMAX_VERSION ); |
| 108 |
} |
| 109 |
if ( ! wp_style_is( 'elegant-icon', 'registered' ) ) { |
| 110 |
wp_register_style( 'elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css' ); |
| 111 |
} |
| 112 |
if ( ! wp_script_is( 'bbpc_js', 'registered' ) ) { |
| 113 |
wp_register_script( 'bbpc_js', FORUMAX_FRONT_ASS . 'js/forumTab.js', array( 'jquery' ), FORUMAX_VERSION, true ); |
| 114 |
} |
| 115 |
|
| 116 |
wp_enqueue_style( 'bbpc-el-widgets' ); |
| 117 |
wp_enqueue_style( 'elegant-icon' ); |
| 118 |
wp_enqueue_script( 'bbpc_js' ); |
| 119 |
|
| 120 |
|
| 121 |
$forum_active = ( 'forum' === $default_tab ) ? ' active' : ''; |
| 122 |
$topic_active = ( 'topic' === $default_tab ) ? ' active' : ''; |
| 123 |
$forum_show = ( 'forum' === $default_tab ) ? ' show active' : ''; |
| 124 |
$topic_show = ( 'topic' === $default_tab ) ? ' show active' : ''; |
| 125 |
|
| 126 |
|
| 127 |
$hover_class = $enable_card_hover ? '' : ' bbpc-ft-no-hover'; |
| 128 |
|
| 129 |
|
| 130 |
$arrow_svg = '<div class="arrow-cont"> |
| 131 |
<svg width="13px" height="13px" class="first" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> |
| 132 |
<path d="M0 0h48v48H0z" fill="none"></path> |
| 133 |
<polygon points="24,29.171 9.414,14.585 6.586,17.413 24,34.827 41.414,17.413 38.586,14.585"></polygon> |
| 134 |
</svg> |
| 135 |
<svg width="13px" height="13px" class="second" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> |
| 136 |
<path d="M0 0h48v48H0z" fill="none"></path> |
| 137 |
<polygon points="24,29.171 9.414,14.585 6.586,17.413 24,34.827 41.414,17.413 38.586,14.585"></polygon> |
| 138 |
</svg> |
| 139 |
</div>'; |
| 140 |
|
| 141 |
ob_start(); |
| 142 |
?> |
| 143 |
<section class="community-area<?php echo esc_attr( $hover_class ); ?>" id="forumTab-<?php echo esc_attr( $this_get_id ); ?>"> |
| 144 |
<ul class="nav nav-tabs tab-buttons" role="tablist"> |
| 145 |
<li class="nav-item" role="presentation"> |
| 146 |
<button class="nav-links<?php echo esc_attr( $forum_active ); ?> tab-button tab" |
| 147 |
onclick="forumTab(event, 'forumTab-<?php echo esc_attr( $this_get_id ); ?>', 'forum-<?php echo esc_attr( $this_get_id ); ?>')"> |
| 148 |
<?php echo esc_html( $forum_tab_title ); ?> |
| 149 |
</button> |
| 150 |
</li> |
| 151 |
<li class="nav-item" role="presentation"> |
| 152 |
<button class="nav-links<?php echo esc_attr( $topic_active ); ?> tab-button tab" |
| 153 |
onclick="forumTab(event, 'forumTab-<?php echo esc_attr( $this_get_id ); ?>', 'topics-<?php echo esc_attr( $this_get_id ); ?>')"> |
| 154 |
<?php echo esc_html( $topics_tab_title ); ?> |
| 155 |
</button> |
| 156 |
</li> |
| 157 |
</ul> |
| 158 |
|
| 159 |
<?php // Forum Tab Content ?> |
| 160 |
<div id="forum-<?php echo esc_attr( $this_get_id ); ?>" class="tab-content<?php echo esc_attr( $forum_show ); ?>"> |
| 161 |
<?php if ( $forums->have_posts() ) : ?> |
| 162 |
<div class="gy-4 bbpc-community-topic-widget-main-wrapper"> |
| 163 |
<?php |
| 164 |
while ( $forums->have_posts() ) : |
| 165 |
$forums->the_post(); |
| 166 |
$item_id = get_the_ID(); |
| 167 |
?> |
| 168 |
<div class="bbpc-community-topic-widget-wrapper"> |
| 169 |
<div class="community-topic-widget-box"> |
| 170 |
<?php if ( $show_forum_image ) : ?> |
| 171 |
<?php the_post_thumbnail( $forum_image_size ); ?> |
| 172 |
<?php endif; ?> |
| 173 |
<div class="box-content"> |
| 174 |
<h5> |
| 175 |
<a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a> |
| 176 |
</h5> |
| 177 |
<?php if ( $show_forum_excerpt ) : ?> |
| 178 |
<p class="bbpc-ft-excerpt"><?php echo esc_html( wp_trim_words( get_the_excerpt(), 15, '...' ) ); ?></p> |
| 179 |
<?php endif; ?> |
| 180 |
<?php if ( $show_forum_post_count || $show_forum_reply_count ) : ?> |
| 181 |
<div class="bbpc-ft-meta"> |
| 182 |
<?php if ( $show_forum_post_count ) : ?> |
| 183 |
<span><?php bbp_forum_topic_count( $item_id ); ?> <?php esc_html_e( 'Posts', 'bbp-core' ); ?></span> |
| 184 |
<?php endif; ?> |
| 185 |
<?php if ( $show_forum_post_count && $show_forum_reply_count ) : ?> |
| 186 |
<span class="vr-line">|</span> |
| 187 |
<?php endif; ?> |
| 188 |
<?php if ( $show_forum_reply_count ) : ?> |
| 189 |
<span><?php bbp_forum_reply_count( $item_id ); ?> <?php esc_html_e( 'Replies', 'bbp-core' ); ?></span> |
| 190 |
<?php endif; ?> |
| 191 |
</div> |
| 192 |
<?php endif; ?> |
| 193 |
</div> |
| 194 |
</div> |
| 195 |
</div> |
| 196 |
<?php endwhile; ?> |
| 197 |
</div> |
| 198 |
<?php else : ?> |
| 199 |
<div class="alert alert-warning"><?php echo esc_html( $no_posts_message ); ?></div> |
| 200 |
<?php endif; ?> |
| 201 |
<?php wp_reset_postdata(); ?> |
| 202 |
|
| 203 |
<?php if ( isset( $settings['is_forum_tab_btn'] ) && $settings['is_forum_tab_btn'] ) : ?> |
| 204 |
<?php $forum_btn_url = ! empty( $settings['more_url'] ) ? $settings['more_url'] : get_post_type_archive_link( 'forum' ); ?> |
| 205 |
<div class="frmx-text-center bbpc-show-more-btn-wrapper"> |
| 206 |
<a href="<?php echo esc_url( $forum_btn_url ); ?>" |
| 207 |
class="dbl-arrow-upper show-more-btn show-more-round frmx-mt-70"> |
| 208 |
<?php echo wp_kses_post( $arrow_svg ); ?> |
| 209 |
<?php echo esc_html( $settings['more_txt'] ?? '' ); ?> |
| 210 |
</a> |
| 211 |
</div> |
| 212 |
<?php endif; ?> |
| 213 |
</div> |
| 214 |
|
| 215 |
<?php // Topics Tab Content ?> |
| 216 |
<div id="topics-<?php echo esc_attr( $this_get_id ); ?>" class="tab-content<?php echo esc_attr( $topic_show ); ?>"> |
| 217 |
<?php if ( $topics->have_posts() ) : ?> |
| 218 |
<?php |
| 219 |
$i = 0; |
| 220 |
while ( $topics->have_posts() ) : |
| 221 |
$topics->the_post(); |
| 222 |
$topic_id = $topics->posts[ $i ]->ID; |
| 223 |
$vote_count = get_post_meta( $topic_id, 'bbpv-votes', true ); |
| 224 |
$forum_id = bbp_get_topic_forum_id(); |
| 225 |
?> |
| 226 |
<div class="single-forum-post-widget"> |
| 227 |
<div class="post-content"> |
| 228 |
<div class="post-title"> |
| 229 |
<h6> |
| 230 |
<a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a> |
| 231 |
</h6> |
| 232 |
</div> |
| 233 |
<?php if ( $show_topic_post_info ) : ?> |
| 234 |
<div class="post-info"> |
| 235 |
<?php if ( $show_topic_avatar ) : ?> |
| 236 |
<div class="author"> |
| 237 |
<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/user-circle-alt.svg' ); ?>" alt="<?php esc_attr_e( 'User', 'bbp-core' ); ?>"> |
| 238 |
<?php |
| 239 |
echo wp_kses_post( bbp_get_topic_author_link( |
| 240 |
array( |
| 241 |
'post_id' => $topic_id, |
| 242 |
'type' => 'name', |
| 243 |
) |
| 244 |
) ); |
| 245 |
?> |
| 246 |
</div> |
| 247 |
<?php endif; ?> |
| 248 |
<div class="post-time"> |
| 249 |
<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/time-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Time', 'bbp-core' ); ?>"> |
| 250 |
<?php bbp_forum_last_active_time( get_the_ID() ); ?> |
| 251 |
</div> |
| 252 |
<div class="post-category"> |
| 253 |
<a href="<?php echo esc_url( get_the_permalink( $forum_id ) ); ?>"> |
| 254 |
<?php echo get_the_post_thumbnail( $forum_id ); ?> |
| 255 |
<?php echo esc_html( get_the_title( $forum_id ) ); ?> |
| 256 |
</a> |
| 257 |
</div> |
| 258 |
</div> |
| 259 |
<?php endif; ?> |
| 260 |
<?php if ( $show_topic_tags ) : ?> |
| 261 |
<?php |
| 262 |
bbp_topic_tag_list( |
| 263 |
'', |
| 264 |
array( |
| 265 |
'before' => '<div class="post-tags">', |
| 266 |
'after' => '</div>', |
| 267 |
'sep' => '', |
| 268 |
) |
| 269 |
); |
| 270 |
?> |
| 271 |
<?php endif; ?> |
| 272 |
</div> |
| 273 |
<?php if ( $show_topic_post_reach ) : ?> |
| 274 |
<div class="post-reach"> |
| 275 |
<div class="post-view"> |
| 276 |
<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/eye-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Views', 'bbp-core' ); ?>"> |
| 277 |
<?php |
| 278 |
if ( function_exists( 'forumax_topic_view_count' ) ) { |
| 279 |
forumax_topic_view_count( $topic_id ); |
| 280 |
} |
| 281 |
esc_html_e( ' Views', 'bbp-core' ); |
| 282 |
?> |
| 283 |
</div> |
| 284 |
<div class="post-like"> |
| 285 |
<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/thumbs-up-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Likes', 'bbp-core' ); ?>"> |
| 286 |
<?php echo esc_html( $vote_count ? $vote_count : '0' ); ?> |
| 287 |
<?php esc_html_e( ' Likes', 'bbp-core' ); ?> |
| 288 |
</div> |
| 289 |
<div class="post-comment"> |
| 290 |
<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/chatbubbles-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Replies', 'bbp-core' ); ?>"> |
| 291 |
<?php bbp_topic_reply_count( $topic_id ); ?> |
| 292 |
<?php esc_html_e( ' Replies', 'bbp-core' ); ?> |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
<?php endif; ?> |
| 296 |
</div> |
| 297 |
<?php |
| 298 |
$i++; |
| 299 |
endwhile; |
| 300 |
unset( $i ); |
| 301 |
else : |
| 302 |
?> |
| 303 |
<div class="alert alert-warning"><?php echo esc_html( $no_posts_message ); ?></div> |
| 304 |
<?php endif; ?> |
| 305 |
<?php wp_reset_postdata(); ?> |
| 306 |
|
| 307 |
<?php if ( isset( $settings['is_topic_tab_btn'] ) && $settings['is_topic_tab_btn'] ) : ?> |
| 308 |
<?php $topic_btn_url = ! empty( $settings['more_url2'] ) ? $settings['more_url2'] : get_post_type_archive_link( 'topic' ); ?> |
| 309 |
<div class="frmx-text-center bbpc-show-more-btn-wrapper"> |
| 310 |
<a href="<?php echo esc_url( $topic_btn_url ); ?>" |
| 311 |
class="dbl-arrow-upper show-more-btn show-more-round frmx-mt-70"> |
| 312 |
<?php echo wp_kses_post( $arrow_svg ); ?> |
| 313 |
<?php echo esc_html( $settings['more_txt2'] ?? '' ); ?> |
| 314 |
</a> |
| 315 |
</div> |
| 316 |
<?php endif; ?> |
| 317 |
</div> |
| 318 |
</section> |
| 319 |
|
| 320 |
<?php |
| 321 |
// Dynamic inline styles |
| 322 |
$sanitize_css_color = function ( $color ) { |
| 323 |
$color = trim( (string) $color ); |
| 324 |
if ( empty( $color ) ) { |
| 325 |
return ''; |
| 326 |
} |
| 327 |
if ( preg_match( '/^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$/', $color ) ) { |
| 328 |
return $color; |
| 329 |
} |
| 330 |
if ( preg_match( '/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/', $color ) ) { |
| 331 |
return $color; |
| 332 |
} |
| 333 |
return ''; |
| 334 |
}; |
| 335 |
|
| 336 |
$uid = esc_attr( $this_get_id ); |
| 337 |
|
| 338 |
// Color attributes. |
| 339 |
$forum_tab_title_color = isset( $attributes['forum_tab_title_color'] ) ? $sanitize_css_color( $attributes['forum_tab_title_color'] ) : ''; |
| 340 |
$topics_tab_title_color = isset( $attributes['topics_tab_title_color'] ) ? $sanitize_css_color( $attributes['topics_tab_title_color'] ) : ''; |
| 341 |
$tab_active_color = isset( $attributes['tab_active_color'] ) ? $sanitize_css_color( $attributes['tab_active_color'] ) : ''; |
| 342 |
$forum_content_color = isset( $attributes['forum_tab_content_color'] ) ? $sanitize_css_color( $attributes['forum_tab_content_color'] ) : ''; |
| 343 |
$topics_content_color = isset( $attributes['topics_tab_content_color'] ) ? $sanitize_css_color( $attributes['topics_tab_content_color'] ) : ''; |
| 344 |
$title_hover_color = isset( $attributes['title_hover_color'] ) ? $sanitize_css_color( $attributes['title_hover_color'] ) : ''; |
| 345 |
$card_bg_color = isset( $attributes['card_bg_color'] ) ? $sanitize_css_color( $attributes['card_bg_color'] ) : ''; |
| 346 |
$btn_color = isset( $attributes['btn_color'] ) ? $sanitize_css_color( $attributes['btn_color'] ) : ''; |
| 347 |
$btn_bg_color = isset( $attributes['btn_bg_color'] ) ? $sanitize_css_color( $attributes['btn_bg_color'] ) : ''; |
| 348 |
|
| 349 |
// Numeric attributes. |
| 350 |
$tab_font_size = ! empty( $attributes['tab_font_size'] ) ? absint( $attributes['tab_font_size'] ) : 0; |
| 351 |
$card_title_font_size = ! empty( $attributes['card_title_font_size'] ) ? absint( $attributes['card_title_font_size'] ) : 0; |
| 352 |
$meta_font_size = ! empty( $attributes['meta_font_size'] ) ? absint( $attributes['meta_font_size'] ) : 0; |
| 353 |
$tab_padding = ! empty( $attributes['tab_padding'] ) ? absint( $attributes['tab_padding'] ) : 0; |
| 354 |
$card_gap = ! empty( $attributes['card_gap'] ) ? absint( $attributes['card_gap'] ) : 0; |
| 355 |
$section_padding = ! empty( $attributes['section_padding'] ) ? absint( $attributes['section_padding'] ) : 0; |
| 356 |
$card_border_radius = ! empty( $attributes['card_border_radius'] ) ? absint( $attributes['card_border_radius'] ) : 0; |
| 357 |
$btn_border_radius = ! empty( $attributes['btn_border_radius'] ) ? absint( $attributes['btn_border_radius'] ) : 0; |
| 358 |
$mobile_columns = ! empty( $attributes['mobile_columns'] ) ? absint( $attributes['mobile_columns'] ) : 1; |
| 359 |
|
| 360 |
// Responsive. |
| 361 |
$hide_forum_image_mobile = isset( $attributes['hide_forum_image_mobile'] ) ? $attributes['hide_forum_image_mobile'] : false; |
| 362 |
$hide_topic_reach_mobile = isset( $attributes['hide_topic_reach_mobile'] ) ? $attributes['hide_topic_reach_mobile'] : true; |
| 363 |
|
| 364 |
// Re-enforce responsive defaults for free users (these variables are re-assigned above from attributes). |
| 365 |
if ( ! $is_pro_active ) { |
| 366 |
$mobile_columns = 1; |
| 367 |
$hide_forum_image_mobile = false; |
| 368 |
$hide_topic_reach_mobile = true; |
| 369 |
} |
| 370 |
?> |
| 371 |
<style> |
| 372 |
/* Layout: columns */ |
| 373 |
#forumTab-<?php echo $uid; ?> .bbpc-community-topic-widget-main-wrapper { |
| 374 |
grid-template-columns: repeat(<?php echo esc_attr( $columns ); ?>, 1fr) !important; |
| 375 |
} |
| 376 |
|
| 377 |
<?php if ( $forum_tab_title_color ) : ?> |
| 378 |
#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item:first-child button { |
| 379 |
color: <?php echo esc_attr( $forum_tab_title_color ); ?> !important; |
| 380 |
} |
| 381 |
<?php endif; ?> |
| 382 |
|
| 383 |
<?php if ( $topics_tab_title_color ) : ?> |
| 384 |
#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item:nth-child(2) button { |
| 385 |
color: <?php echo esc_attr( $topics_tab_title_color ); ?> !important; |
| 386 |
} |
| 387 |
<?php endif; ?> |
| 388 |
|
| 389 |
<?php if ( $tab_active_color ) : ?> |
| 390 |
#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item button.active { |
| 391 |
border-bottom-color: <?php echo esc_attr( $tab_active_color ); ?> !important; |
| 392 |
color: <?php echo esc_attr( $tab_active_color ); ?> !important; |
| 393 |
} |
| 394 |
<?php endif; ?> |
| 395 |
|
| 396 |
<?php if ( $forum_content_color ) : ?> |
| 397 |
#forum-<?php echo $uid; ?> .community-topic-widget-box .box-content, |
| 398 |
#forum-<?php echo $uid; ?> .community-topic-widget-box .box-content a, |
| 399 |
#forum-<?php echo $uid; ?> .community-topic-widget-box .box-content span { |
| 400 |
color: <?php echo esc_attr( $forum_content_color ); ?> !important; |
| 401 |
} |
| 402 |
<?php endif; ?> |
| 403 |
|
| 404 |
<?php if ( $topics_content_color ) : ?> |
| 405 |
#topics-<?php echo $uid; ?> .single-forum-post-widget .post-content, |
| 406 |
#topics-<?php echo $uid; ?> .single-forum-post-widget .post-content a { |
| 407 |
color: <?php echo esc_attr( $topics_content_color ); ?> !important; |
| 408 |
} |
| 409 |
<?php endif; ?> |
| 410 |
|
| 411 |
<?php if ( $title_hover_color ) : ?> |
| 412 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box h5:hover a, |
| 413 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box h5 a:hover, |
| 414 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6:hover a, |
| 415 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6 a:hover, |
| 416 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget:hover .post-title h6 a { |
| 417 |
color: <?php echo esc_attr( $title_hover_color ); ?> !important; |
| 418 |
} |
| 419 |
<?php endif; ?> |
| 420 |
|
| 421 |
<?php if ( $card_bg_color ) : ?> |
| 422 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box, |
| 423 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget { |
| 424 |
background-color: <?php echo esc_attr( $card_bg_color ); ?> !important; |
| 425 |
} |
| 426 |
<?php endif; ?> |
| 427 |
|
| 428 |
<?php if ( $btn_color || $btn_bg_color ) : ?> |
| 429 |
#forumTab-<?php echo $uid; ?> .show-more-btn { |
| 430 |
<?php if ( $btn_color ) : ?> |
| 431 |
color: <?php echo esc_attr( $btn_color ); ?> !important; |
| 432 |
<?php endif; ?> |
| 433 |
<?php if ( $btn_bg_color ) : ?> |
| 434 |
background-color: <?php echo esc_attr( $btn_bg_color ); ?> !important; |
| 435 |
<?php endif; ?> |
| 436 |
} |
| 437 |
<?php endif; ?> |
| 438 |
|
| 439 |
<?php if ( $tab_font_size ) : ?> |
| 440 |
#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item button { |
| 441 |
font-size: <?php echo esc_attr( $tab_font_size ); ?>px !important; |
| 442 |
} |
| 443 |
<?php endif; ?> |
| 444 |
|
| 445 |
<?php if ( $card_title_font_size ) : ?> |
| 446 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box h5, |
| 447 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6, |
| 448 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6 a { |
| 449 |
font-size: <?php echo esc_attr( $card_title_font_size ); ?>px !important; |
| 450 |
} |
| 451 |
<?php endif; ?> |
| 452 |
|
| 453 |
<?php if ( $meta_font_size ) : ?> |
| 454 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box span, |
| 455 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-info > div { |
| 456 |
font-size: <?php echo esc_attr( $meta_font_size ); ?>px !important; |
| 457 |
} |
| 458 |
<?php endif; ?> |
| 459 |
|
| 460 |
<?php if ( $tab_padding ) : ?> |
| 461 |
#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item button { |
| 462 |
padding: <?php echo esc_attr( $tab_padding ); ?>px 0 !important; |
| 463 |
} |
| 464 |
<?php endif; ?> |
| 465 |
|
| 466 |
<?php if ( $card_gap ) : ?> |
| 467 |
#forumTab-<?php echo $uid; ?> .bbpc-community-topic-widget-main-wrapper { |
| 468 |
grid-gap: <?php echo esc_attr( $card_gap ); ?>px !important; |
| 469 |
} |
| 470 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget { |
| 471 |
margin-top: <?php echo esc_attr( $card_gap ); ?>px !important; |
| 472 |
} |
| 473 |
<?php endif; ?> |
| 474 |
|
| 475 |
<?php if ( $section_padding ) : ?> |
| 476 |
#forumTab-<?php echo $uid; ?> .tab-content { |
| 477 |
padding-top: <?php echo esc_attr( $section_padding ); ?>px !important; |
| 478 |
} |
| 479 |
<?php endif; ?> |
| 480 |
|
| 481 |
<?php if ( $card_border_radius ) : ?> |
| 482 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box, |
| 483 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget { |
| 484 |
border-radius: <?php echo esc_attr( $card_border_radius ); ?>px !important; |
| 485 |
} |
| 486 |
<?php endif; ?> |
| 487 |
|
| 488 |
<?php if ( $btn_border_radius ) : ?> |
| 489 |
#forumTab-<?php echo $uid; ?> .show-more-btn { |
| 490 |
border-radius: <?php echo esc_attr( $btn_border_radius ); ?>px !important; |
| 491 |
} |
| 492 |
<?php endif; ?> |
| 493 |
|
| 494 |
/* Disable hover animation */ |
| 495 |
<?php if ( ! $enable_card_hover ) : ?> |
| 496 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box:hover, |
| 497 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget:hover { |
| 498 |
transform: none !important; |
| 499 |
box-shadow: 0 1.6px 3.5px 0 rgba(51,77,114,.15), 0 0.5px 1px 0 rgba(51,77,114,.1) !important; |
| 500 |
} |
| 501 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget:hover .post-title h6 a { |
| 502 |
color: inherit !important; |
| 503 |
} |
| 504 |
<?php endif; ?> |
| 505 |
|
| 506 |
/* Responsive */ |
| 507 |
@media (max-width: 768px) { |
| 508 |
#forumTab-<?php echo $uid; ?> .bbpc-community-topic-widget-main-wrapper { |
| 509 |
grid-template-columns: repeat(<?php echo esc_attr( $mobile_columns ); ?>, 1fr) !important; |
| 510 |
} |
| 511 |
<?php if ( $hide_forum_image_mobile ) : ?> |
| 512 |
#forumTab-<?php echo $uid; ?> .community-topic-widget-box img { |
| 513 |
display: none !important; |
| 514 |
} |
| 515 |
<?php endif; ?> |
| 516 |
<?php if ( $hide_topic_reach_mobile ) : ?> |
| 517 |
#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-reach { |
| 518 |
display: none !important; |
| 519 |
} |
| 520 |
<?php endif; ?> |
| 521 |
} |
| 522 |
</style> |
| 523 |
<?php |
| 524 |
return ob_get_clean(); |
| 525 |
} |
| 526 |
} |