Example #1
0
/**
 * Returns link to the most recent activity inside a topic, complete
 * with link attributes and content.
 *
 * @since 2.0.0 bbPress (r2625)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic_last_reply_url() To get the topic last reply url
 * @uses bbp_get_topic_last_reply_title() To get the reply title
 * @uses bbp_get_topic_last_active_time() To get the topic freshness
 * @uses apply_filters() Calls 'bbp_get_topic_freshness_link' with the
 *                        link and topic id
 * @return string Topic freshness link
 */
function bbp_get_topic_freshness_link($topic_id = 0)
{
    $topic_id = bbp_get_topic_id($topic_id);
    $link_url = bbp_get_topic_last_reply_url($topic_id);
    $title = bbp_get_topic_last_reply_title($topic_id);
    $time_since = bbp_get_topic_last_active_time($topic_id);
    if (!empty($time_since)) {
        $anchor = '<a href="' . esc_url($link_url) . '" title="' . esc_attr($title) . '">' . esc_html($time_since) . '</a>';
    } else {
        $anchor = esc_html__('No Replies', 'bbpress');
    }
    return apply_filters('bbp_get_topic_freshness_link', $anchor, $topic_id, $time_since, $link_url, $title);
}
Example #2
0
    function build_html()
    {
        // Store everything in an output buffer
        ob_start();
        ?>
	
		<div class="widget showcase-widget">
			<header class="widget-header">
				<h3 class="widget-title">Recent Discussion</h3>
			</header>
			<ul class="recent-discussion-list">		
	
			<?php 
        // Iterate topics
        while (bp_activities()) {
            bp_the_activity();
            // Get the activity user
            $user = new Apoc_User(bp_get_activity_user_id(), 'directory', 40);
            // Get the activity type
            $type = bp_get_activity_type();
            // Format activity based on context
            switch ($type) {
                case 'bbp_topic_create':
                    $topic_id = bp_get_activity_item_id();
                    $link = '<a href="' . bbp_get_topic_permalink($topic_id) . '" title="Read topic" target="_blank">' . bbp_get_topic_title($topic_id) . '</a>';
                    $verb = 'created topic';
                    break;
                case 'bbp_reply_create':
                    $reply_id = bp_get_activity_secondary_item_id();
                    $link = '<a href="' . bbp_get_topic_last_reply_url($reply_id) . '" title="Read reply" target="_blank">' . bbp_get_topic_title($reply_id) . '</a>';
                    $verb = 'replied to';
                    break;
                case 'new_blog_comment':
                    $comment_id = bp_get_activity_secondary_item_id();
                    $comment = get_comment($comment_id);
                    $link = '<a href="' . get_comment_link($comment_id) . '" title="Read reply" target="_blank">' . get_the_title($comment->comment_post_ID) . '</a>';
                    $verb = 'commented on';
                    break;
            }
            // Get the activity time
            $time = bp_core_time_since(bp_get_activity_date_recorded());
            // Output the HTML
            ?>
				<li class="recent-discussion double-border">			
					<?php 
            echo $user->avatar;
            ?>
					<div class="recent-discussion-content">
						<span class="recent-discussion-title"><?php 
            echo $user->link . ' ' . $verb . ' ' . $link;
            ?>
</span>
						<span class="recent-discussion-time"><?php 
            echo $time;
            ?>
					</div>
				</li>
			
			<?php 
        }
        ?>
			</ul>
		</div><?php 
        // Get the contents of the buffer
        $html = ob_get_contents();
        ob_end_clean();
        // Return the html to the class
        return $html;
    }
Example #3
0
 /**
  * @covers ::bbp_topic_last_reply_url
  * @covers ::bbp_get_topic_last_reply_url
  */
 public function test_bbp_get_topic_last_reply_url()
 {
     if (is_multisite()) {
         $this->markTestSkipped('Skipping URL tests in multiste for now.');
     }
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $topic_last_reply_url = bbp_get_topic_last_reply_url($t);
     $this->assertSame(get_permalink($t), $topic_last_reply_url);
     $r = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     $topic_last_reply_url = bbp_get_topic_last_reply_url($t);
     $this->assertSame(bbp_get_reply_url($r), $topic_last_reply_url);
 }
Example #4
0
 /**
  * Format the display of each notification
  */
 function format_notification($not)
 {
     // Get the action
     $action = $not->component_action;
     // Maybe override the action description
     switch ($action) {
         // Activities
         case 'new_at_mention':
             $grammar = $not->count > 1 ? ' times.' : ' time.';
             $link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
             $desc = '<a href="' . $link . '">You were mentioned in discussion ' . $not->count . $grammar . '</a>';
             break;
         case 'bbp_new_reply':
             $grammar = $not->count > 1 ? ' new replies.' : ' new reply.';
             $link = bbp_get_topic_last_reply_url($not->item_id);
             $desc = '<a href="' . $link . '">Your topic "' . bbp_get_topic_title($not->item_id) . '" has ' . $not->count . $grammar . '</a>';
             break;
             // Default
         // Default
         default:
             break;
     }
     // Return the description
     return $desc;
 }
Example #5
0
function firmasite_social_bbp_get_topic_freshness_link($topic_id = 0)
{
    $topic_id = bbp_get_topic_id($topic_id);
    $link_url = bbp_get_topic_last_reply_url($topic_id);
    $title = bbp_get_topic_last_reply_title($topic_id);
    $time_since = bbp_get_topic_last_active_time($topic_id);
    if (!empty($time_since)) {
        $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>';
    } else {
        $anchor = __('No Replies', 'firmasite');
    }
    return apply_filters('bbp_get_topic_freshness_link', $anchor, $topic_id);
}