/** * Return the url to the last reply in a forum * * @since bbPress (r2683) * * @param int $forum_id Optional. Forum id * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_forum_last_reply_id() To get the forum's last reply id * @uses bbp_get_reply_url() To get the reply url * @uses bbp_get_forum_last_topic_permalink() To get the forum's last * topic's permalink * @uses apply_filters() Calls 'bbp_get_forum_last_reply_url' with the * reply url and forum id * @return string Paginated URL to latest reply */ function bbp_get_forum_last_reply_url($forum_id = 0) { $forum_id = bbp_get_forum_id($forum_id); // If forum has replies, get the last reply and use its url $reply_id = bbp_get_forum_last_reply_id($forum_id); if (!empty($reply_id)) { $reply_url = bbp_get_reply_url($reply_id); // No replies, so look for topics and use last permalink } else { $reply_url = bbp_get_forum_last_topic_permalink($forum_id); // No topics either, so set $reply_url as empty string if (empty($reply_url)) { $reply_url = ''; } } // Filter and return return apply_filters('bbp_get_forum_last_reply_url', $reply_url, $forum_id); }
/** * @covers ::bbp_forum_last_topic_permalink * @covers ::bbp_get_forum_last_topic_permalink */ public function test_bbp_get_forum_last_topic_permalink() { if (is_multisite()) { $this->markTestSkipped('Skipping URL tests in multisite for now.'); } $c = $this->factory->forum->create(array('forum_meta' => array('forum_type' => 'category', 'status' => 'open'))); $f = $this->factory->forum->create(array('post_parent' => $c, 'forum_meta' => array('forum_id' => $c, 'forum_type' => 'forum', 'status' => 'open'))); $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f))); // Get the forums last topic permalink. $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink($f); $this->assertSame(bbp_get_topic_permalink($t), $forum_last_topic_permalink); // Get the categories last topic permalink. $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink($c); $this->assertSame(bbp_get_topic_permalink($t), $forum_last_topic_permalink); }
<li class="bbp-forum-topic-count col-lg-1"> <div class="topic-reply-counts">Ämnen: <?php bbp_forum_topic_count(); ?> </div> <div class="topic-reply-counts">Inlägg: <?php bbp_show_lead_topic() ? bbp_forum_reply_count() : bbp_forum_post_count(); ?> </div> </li> <li class="bbp-forum-freshness col-lg-3"> <div class="last-posted-topic-title"> <a href="<?php echo bbp_get_forum_last_topic_permalink(); ?> "><?php echo bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id()); ?> </a> </div> <div class="last-posted-topic-user">av <span class="bbp-author-avatar"><?php echo get_avatar(bbp_get_forum_last_reply_author_id(), '14'); ?> </span> <?php echo bbp_get_user_profile_link(bbp_get_forum_last_reply_author_id()); ?> </div>
function st_get_last_poster_block($subforum_id = "") { if (!empty($subforum_id)) { // Main forum display with sub forums $st_forum_topic_count_two = bbp_get_forum_topic_count($subforum_id); if ($st_forum_topic_count_two == 0) { $output = "<div class='last-posted-topic-title no-topics'>"; $output .= "No Topics"; } else { $output = "<div class='last-posted-topic-title'>"; // Get and crop title lenth if needed $st_topic_last_reply_title = bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id($subforum_id)); $st_topic_last_reply_title_print = strlen($st_topic_last_reply_title) > 50 ? substr($st_topic_last_reply_title, 0, 53) . '…' : $st_topic_last_reply_title; $output .= "<a href='" . bbp_get_forum_last_topic_permalink($subforum_id) . "'>" . $st_topic_last_reply_title_print . "</a>"; $output .= "</div>"; $output .= "<div class='last-posted-topic-time'>"; $output .= bbp_get_forum_last_active_time($subforum_id); } $output .= "</div>"; } else { // forum category display (no sub forums list) $st_forum_topic_count = bbp_get_forum_topic_count(); if ($st_forum_topic_count == 0) { $output = "<div class='last-posted-topic-title no-topics'>"; $output .= "No Topics"; } else { $output = "<div class='last-posted-topic-title'>"; // Get and crop title lenth if needed $st_topic_last_reply_title = bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id($subforum_id)); $st_topic_last_reply_title_print = strlen($st_topic_last_reply_title) > 50 ? substr($st_topic_last_reply_title, 0, 53) . '…' : $st_topic_last_reply_title; $output .= "<a href='" . bbp_get_forum_last_topic_permalink() . "'>" . $st_topic_last_reply_title_print . "</a>"; $output .= "</div>"; $output .= "<div class='last-posted-topic-time'>"; $output .= bbp_get_forum_last_active_time(); } $output .= "</div>"; } return $output; }
function custom_freshness_link($forum_id = 0) { global $rpg_settingsf; $forum_id = bbp_get_forum_id($forum_id); $active_id = bbp_get_forum_last_active_id($forum_id); $link_url = $title = ''; $forum_title = bbp_get_forum_title($forum_id); if (empty($active_id)) { $active_id = bbp_get_forum_last_reply_id($forum_id); } if (empty($active_id)) { $active_id = bbp_get_forum_last_topic_id($forum_id); } if (bbp_is_topic($active_id)) { $link_url = bbp_get_forum_last_topic_permalink($forum_id); //$link_id added to get post_id and type to allow for later check $link_id = bbp_get_forum_last_topic_id($forum_id); $check = "topic"; $title = bbp_get_forum_last_topic_title($forum_id); $forum_id_last_active = bbp_get_topic_forum_id($active_id); } elseif (bbp_is_reply($active_id)) { $link_url = bbp_get_forum_last_reply_url($forum_id); //$link-id added to get post-id and type to allow for later check $link_id = bbp_get_forum_last_reply_id($forum_id); $check = "reply"; $title = bbp_get_forum_last_reply_title($forum_id); $forum_id_last_active = bbp_get_reply_forum_id($active_id); } $time_since = bbp_get_forum_last_active_time($forum_id); if (!empty($time_since) && !empty($link_url)) { //ADDITIONAL CODE to original bbp_get_forum_freshness_link function //test if user can see this post, and post link if they can $user_id = wp_get_current_user()->ID; //get the forum id for the post - that's the forum ID against which we check to see if it is in a group - no idea what forum group the stuff above produces, suspect post id of when last changed. $forum_id_check = private_groups_get_forum_id_from_post_id($link_id, $check); //now we can check if the user can view this, and if it's not private if (private_groups_can_user_view_post($user_id, $forum_id_check) && !bbp_is_forum_private($forum_id_last_active)) { $anchor = '<a href="' . esc_url($link_url) . '" title="' . esc_attr($title) . '">' . esc_html($time_since) . '</a>'; } elseif (private_groups_can_user_view_post($user_id, $forum_id_check) && bbp_is_forum_private($forum_id_last_active) && current_user_can('read_private_forums')) { $anchor = '<a href="' . esc_url($link_url) . '" title="' . esc_attr($title) . '">' . esc_html($time_since) . '</a>'; } else { //set up which link to send them to if (!is_user_logged_in()) { if ($rpg_settingsf['redirect_page2']) { $link = $rpg_settingsf['redirect_page2']; } else { $link = "/wp-login"; } } else { if ($rpg_settingsf['redirect_page1']) { $link = $rpg_settingsf['redirect_page1']; } else { $link = '/404'; } } //now see if there is a freshness message if ($rpg_settingsf['set_freshness_message']) { $title = $rpg_settingsf['freshness_message']; //and set up anchor $anchor = '<a href="' . esc_url($link) . '">' . $title . '</a>'; } else { $anchor = '<a href="' . esc_url($link) . '">' . esc_html($time_since) . '</a>'; } } } else { $anchor = esc_html__('No Topics', 'bbpress'); } return $anchor; }
public function epicwebs_get_last_poster_block($subforum_id = "") { if (!empty($subforum_id)) { // Main forum display with sub forums $output = "<div class='last-posted-topic-title'>"; $output .= "<a href='" . bbp_get_forum_last_topic_permalink($subforum_id) . "'>" . bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id($subforum_id)) . "</a>"; $output .= "</div>"; $output .= "<div class='last-posted-topic-user'>av "; $author_id = bbp_get_forum_last_reply_author_id($subforum_id); $output .= "<span class=\"bbp-author-avatar\">" . get_avatar($author_id, '14') . " </span>"; $output .= bbp_get_user_profile_link($author_id); $output .= "</div>"; $output .= "<div class='last-posted-topic-time'>"; $output .= bbp_get_forum_last_active_time($subforum_id); $output .= "</div>"; } else { // forum category display (no sub forums list) $output = "<div class='last-posted-topic-title'>"; $output .= "<a href='" . bbp_get_forum_last_topic_permalink() . "'>" . bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id()) . "</a>"; $output .= "</div>"; $output .= "<div class='last-posted-topic-user'>av "; $output .= "<span class=\"bbp-author-avatar\">" . get_avatar(bbp_get_forum_last_reply_author_id(), '14') . " </span>"; $output .= bbp_get_user_profile_link(bbp_get_forum_last_reply_author_id()); $output .= "</div>"; $output .= "<div class='last-posted-topic-time'>"; $output .= bbp_get_forum_last_active_time(); $output .= "</div>"; } return $output; }
function firmasite_social_bbp_get_forum_freshness_link($forum_id = 0) { $forum_id = bbp_get_forum_id($forum_id); $active_id = bbp_get_forum_last_active_id($forum_id); if (empty($active_id)) { $active_id = bbp_get_forum_last_reply_id($forum_id); } if (empty($active_id)) { $active_id = bbp_get_forum_last_topic_id($forum_id); } if (bbp_is_topic($active_id)) { $link_url = bbp_get_forum_last_topic_permalink($forum_id); $title = bbp_get_forum_last_topic_title($forum_id); } elseif (bbp_is_reply($active_id)) { $link_url = bbp_get_forum_last_reply_url($forum_id); $title = bbp_get_forum_last_reply_title($forum_id); } $time_since = bbp_get_forum_last_active_time($forum_id); if (!empty($time_since) && !empty($link_url)) { $anchor = '<a href="' . $link_url . '" data-toggle="popover" data-rel="popover" data-placement="left" data-trigger="hover" data-html="true" data-original-title="' . __('Freshness', 'firmasite') . '" data-content="' . esc_attr($time_since) . '"><i class="icon-time"></i></a> ' . __('Freshness', 'firmasite') . ':'; } else { $anchor = __('No Topics', 'firmasite'); } return apply_filters('bbp_get_forum_freshness_link', $anchor, $forum_id); }