| 1 |
<?php |
| 2 |
// Hooks. |
| 3 |
add_action('bbpc-resolved-topics', 'forumax_solve_topic_callback', 10, 2); |
| 4 |
|
| 5 |
// functions |
| 6 |
function forumax_solve_topic_callback($content = '', $topic_id = 0) |
| 7 |
{ |
| 8 |
|
| 9 |
if (forumax_get_opt('is_solved_topics', true)) { |
| 10 |
|
| 11 |
if (empty($topic_id)) { |
| 12 |
$topic_id = bbp_get_topic_id($topic_id); |
| 13 |
} |
| 14 |
|
| 15 |
$open = ''; |
| 16 |
$close = ''; |
| 17 |
$resolved = ''; |
| 18 |
$has_best_answer = ''; |
| 19 |
|
| 20 |
$obj = features\forumax_solve_topic(); |
| 21 |
|
| 22 |
if ($obj->is_solved($topic_id) || $obj->has_best_answer($topic_id)) { |
| 23 |
$open = '<div class="solved-topic-bar">'; |
| 24 |
$close = '</div>'; |
| 25 |
} |
| 26 |
|
| 27 |
if ($obj->is_solved($topic_id)) { |
| 28 |
$resolved = '<span class="accepted-ans-mark badge"><i class="icon_check_alt"></i> ' . esc_html__('Resolved', 'forumax') . '</span>'; |
| 29 |
} |
| 30 |
|
| 31 |
$content = $content . $open . $resolved . $has_best_answer . $close; |
| 32 |
|
| 33 |
$allowed_html = [ |
| 34 |
'div' => ['class' => []], |
| 35 |
'span' => ['class' => []], |
| 36 |
'i' => ['class' => []], |
| 37 |
]; |
| 38 |
|
| 39 |
echo wp_kses($content, $allowed_html); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
// Forumax Social Share Hook - Triggered manually in content-single-topic-lead.php |
| 44 |
// add_action( 'bbp_theme_after_topic_content', 'forumax_topic_social_share' ); |
| 45 |
|
| 46 |
function forumax_topic_social_share() |
| 47 |
{ |
| 48 |
if ( ! forumax_get_opt( 'is_social_links', true ) ) { |
| 49 |
return ''; |
| 50 |
} |
| 51 |
|
| 52 |
$is_copy_link = forumax_get_opt('is_copy_link'); |
| 53 |
$copy_link_text_success = forumax_get_opt('copy_link_text_success', esc_html__('Copied!', 'forumax')); |
| 54 |
$copy_link_label = forumax_get_opt('copy_link_label', esc_html__('Or copy link', 'forumax')); |
| 55 |
|
| 56 |
if (is_user_logged_in()): |
| 57 |
?> |
| 58 |
<a href="#" class="forumax-share-btn modal-toggle" data-id="forumax_share_modal"> |
| 59 |
<i class="social_share_square"></i> |
| 60 |
<?php echo esc_html(forumax_get_opt('share_btn_label', esc_html__('Share this Topic', 'forumax'))) ?> |
| 61 |
</a> |
| 62 |
|
| 63 |
<div class="forumax-modal" id='forumax_share_modal'> |
| 64 |
<div class="forumax-modal-overlay modal-toggle"></div> |
| 65 |
<div class="forumax-modal-dialog" role="document"> |
| 66 |
<div class="forumax-modal-content"> |
| 67 |
<a class="close forumax-close"> |
| 68 |
<i class="icon_close"></i> |
| 69 |
</a> |
| 70 |
<div class="forumax-share-wrap"> |
| 71 |
<h2> <?php the_title(); ?> </h2> |
| 72 |
<div class="social-links"> |
| 73 |
<a href="mailto:?subject=<?php echo rawurlencode(bbp_get_topic_title(bbp_get_topic_id())); ?>&body=<?php echo rawurlencode(bbp_get_topic_permalink(bbp_get_topic_id())); ?>" |
| 74 |
target="_blank"> |
| 75 |
<i class="icon_mail"></i> |
| 76 |
</a> |
| 77 |
<a |
| 78 |
href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode(bbp_get_topic_permalink(bbp_get_topic_id())); ?>"> |
| 79 |
<i class="social_facebook_circle"></i> |
| 80 |
</a> |
| 81 |
<a |
| 82 |
href="https://www.linkedin.com/sharing/share-offsite/?url=<?php echo urlencode(bbp_get_topic_permalink(bbp_get_topic_id())); ?>"> |
| 83 |
<i class="social_linkedin_square"></i> |
| 84 |
</a> |
| 85 |
<a |
| 86 |
href="https://x.com/intent/tweet?url=<?php echo urlencode(bbp_get_topic_permalink(bbp_get_topic_id())); ?>&text=<?php echo urlencode(bbp_get_topic_title(bbp_get_topic_id())); ?>"> |
| 87 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865z"/></svg> |
| 88 |
</a> |
| 89 |
</div> |
| 90 |
|
| 91 |
<?php |
| 92 |
if ($is_copy_link): |
| 93 |
?> |
| 94 |
<p> <?php echo esc_html($copy_link_label); ?> </p> |
| 95 |
<div class="copy-url-wrap"> |
| 96 |
<input readonly type="text" |
| 97 |
value="<?php echo esc_url(bbp_get_topic_permalink(bbp_get_topic_id())); ?>" |
| 98 |
class="word-wrap"> |
| 99 |
<div class="share-this-doc" title="<?php esc_attr_e('Copy Link', 'forumax'); ?>"> |
| 100 |
<img src="<?php echo FORUMAX_FRONT_ASS . 'img/clone.svg'; ?>" |
| 101 |
alt="<?php esc_attr_e('Clipboard Icon', 'forumax'); ?>"> |
| 102 |
</div> |
| 103 |
<div class="forumax-link-copied-wrap"> |
| 104 |
<i class="icon_check_alt2"></i> |
| 105 |
<?php echo esc_attr($copy_link_text_success) ?> |
| 106 |
<i class="icon_close close-notice"></i> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
<?php |
| 110 |
endif; |
| 111 |
?> |
| 112 |
|
| 113 |
</div> |
| 114 |
</div> |
| 115 |
</div> |
| 116 |
</div> |
| 117 |
<?php endif; |
| 118 |
} |
| 119 |
|