Example #1
0
 /**
  * @group canonical
  * @covers ::bbp_insert_forum
  */
 public function test_bbp_insert_forum()
 {
     $f = $this->factory->forum->create(array('post_title' => 'Forum 1', 'post_content' => 'Content of Forum 1'));
     $now = time();
     $post_date = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the forum.
     $forum = bbp_get_forum($f);
     // Forum post.
     $this->assertSame('Forum 1', bbp_get_forum_title($f));
     $this->assertSame('Content of Forum 1', bbp_get_forum_content($f));
     $this->assertSame('open', bbp_get_forum_status($f));
     $this->assertSame('forum', bbp_get_forum_type($f));
     $this->assertTrue(bbp_is_forum_public($f));
     $this->assertSame(0, bbp_get_forum_parent_id($f));
     $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?forum=' . $forum->post_name, $forum->guid);
     // Forum meta.
     $this->assertSame(0, bbp_get_forum_subforum_count($f, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, true, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($f, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, true, true));
     $this->assertSame($t, bbp_get_forum_last_topic_id($f));
     $this->assertSame($r, bbp_get_forum_last_reply_id($f));
     $this->assertSame($r, bbp_get_forum_last_active_id($f));
     $this->assertSame('4 days, 4 hours ago', bbp_get_forum_last_active_time($f));
 }
Example #2
0
 /**
  * @covers ::bbp_update_forum_last_topic_id
  */
 public function test_bbp_update_forum_last_topic_id()
 {
     $f1 = $this->factory->forum->create();
     $f2 = $this->factory->forum->create(array('post_parent' => $f1));
     $t1 = $this->factory->topic->create(array('post_parent' => $f1, 'topic_meta' => array('forum_id' => $f1)));
     $id = bbp_update_forum_last_topic_id($f1, $t1);
     $this->assertSame($t1, $id);
     $id = bbp_get_forum_last_topic_id($f1);
     $this->assertSame($t1, $id);
     $t2 = $this->factory->topic->create(array('post_parent' => $f2, 'topic_meta' => array('forum_id' => $f2)));
     bbp_update_forum_last_topic_id($f2);
     $id = bbp_get_forum_last_topic_id($f2);
     $this->assertSame($t2, $id);
     bbp_update_forum_last_topic_id($f1);
     $id = bbp_get_forum_last_topic_id($f1);
     $this->assertSame($t2, $id);
 }
/**
 * this function changes the bbp freshness data (time since) into a last post date for forums
 * @return string Formatted date-time
 */
function change_freshness_forum()
{
    // Verify forum and get last active meta
    $forum_id = bbp_get_forum_id($forum_id);
    $last_active = get_post_meta($forum_id, '_bbp_last_active_time', true);
    if (empty($last_active)) {
        $reply_id = bbp_get_forum_last_reply_id($forum_id);
        if (!empty($reply_id)) {
            $last_active = get_post_field('post_date', $reply_id);
        } else {
            $topic_id = bbp_get_forum_last_topic_id($forum_id);
            if (!empty($topic_id)) {
                $last_active = bbp_get_topic_last_active_time($topic_id);
            }
        }
    }
    $last_active = bbp_convert_date($last_active);
    $date_format = get_option('date_format');
    $time_format = get_option('time_format');
    $date = date_i18n("{$date_format}", $last_active);
    $time = date_i18n("{$time_format}", $last_active);
    $active_time = sprintf(_x('%1$s, %2$s', 'date at time', 'bbp-last-post'), $date, $time);
    return $active_time;
}
 /**
  * @covers ::bbp_forum_last_topic_id
  * @covers ::bbp_get_forum_last_topic_id
  * @covers ::bbp_forum_last_reply_id
  * @covers ::bbp_get_forum_last_reply_id
  * @covers ::bbp_topic_last_reply_id
  * @covers ::bbp_get_topic_last_reply_id
  */
 public function test_bbp_get_forum_and_topic_last_topic_id_and_last_reply_id()
 {
     $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')));
     // Get the forums last topic id _bbp_last_topic_id.
     $this->assertSame(0, bbp_get_forum_last_topic_id($f));
     // Get the category last topic id _bbp_last_topic_id.
     $this->assertSame(0, bbp_get_forum_last_topic_id($c));
     // Get the forums last reply id _bbp_last_reply_id.
     $this->assertSame(0, bbp_get_forum_last_reply_id($f));
     // Get the category last reply id _bbp_last_reply_id.
     $this->assertSame(0, bbp_get_forum_last_reply_id($c));
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     // Get the forums last topic id _bbp_last_topic_id.
     $this->assertSame($t, bbp_get_forum_last_topic_id($f));
     // Get the category last topic id _bbp_last_topic_id.
     $this->assertSame($t, bbp_get_forum_last_topic_id($c));
     // Create another reply.
     $r = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the forums last reply id _bbp_last_reply_id.
     $this->assertSame($r, bbp_get_forum_last_reply_id($f));
     // Get the category last reply id _bbp_last_reply_id.
     $this->assertSame($r, bbp_get_forum_last_reply_id($c));
     // Get the topics last reply id _bbp_last_reply_id.
     $this->assertSame($r, bbp_get_topic_last_reply_id($t));
 }
    bbp_forum_topic_count();
    ?>
			</div>

			<div class="forum-freshness">
				<?php 
    echo apoc_get_avatar(array('user_id' => bbp_get_forum_last_reply_author_id(), 'link' => true, 'size' => 50));
    ?>
				<div class="freshest-meta">
					<a class="freshest-title" href="<?php 
    echo $link;
    ?>
" title=""><?php 
    bbp_forum_last_topic_title();
    ?>
</a>
					<span class="freshest-author">By <?php 
    bbp_author_link(array('post_id' => bbp_get_forum_last_topic_id(), 'type' => 'name'));
    ?>
</span>
					<span class="freshest-time"><?php 
    bbp_topic_last_active_time(bbp_get_forum_last_topic_id());
    ?>
</span>
				</div>
			</div>
			
		</li>
	</ol>
<?php 
}
Example #6
0
 /**
  * @covers ::bbp_move_topic_handler
  */
 public function test_bbp_move_topic_handler()
 {
     $old_current_user = 0;
     $this->old_current_user = get_current_user_id();
     $this->set_current_user($this->factory->user->create(array('role' => 'administrator')));
     $this->keymaster_id = get_current_user_id();
     bbp_set_user_role($this->keymaster_id, bbp_get_keymaster_role());
     $old_forum_id = $this->factory->forum->create();
     $topic_id = $this->factory->topic->create(array('post_parent' => $old_forum_id, 'topic_meta' => array('forum_id' => $old_forum_id)));
     $reply_id = $this->factory->reply->create(array('post_parent' => $topic_id, 'reply_meta' => array('forum_id' => $old_forum_id, 'topic_id' => $topic_id)));
     // Topic post parent
     $topic_parent = wp_get_post_parent_id($topic_id);
     $this->assertSame($old_forum_id, $topic_parent);
     // Forum meta
     $this->assertSame(1, bbp_get_forum_topic_count($old_forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($old_forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($old_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($old_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($old_forum_id));
     // Topic meta
     $this->assertSame($old_forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     // Reply Meta
     $this->assertSame($old_forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
     // Create a new forum
     $new_forum_id = $this->factory->forum->create();
     // Move the topic into the new forum
     bbp_move_topic_handler($topic_id, $old_forum_id, $new_forum_id);
     // Topic post parent
     $topic_parent = wp_get_post_parent_id($topic_id);
     $this->assertSame($new_forum_id, $topic_parent);
     // Forum meta
     $this->assertSame(1, bbp_get_forum_topic_count($new_forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($new_forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($new_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($new_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($new_forum_id));
     // Topic meta
     $this->assertSame($new_forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     // Reply Meta
     $this->assertSame($new_forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
     // Retore the user
     $this->set_current_user($this->old_current_user);
 }
Example #7
0
/**
 * Return the forums last reply id
 *
 * @since bbPress (r2464)
 *
 * @param int $forum_id Optional. Forum id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses get_post_meta() To get the forum's last reply id
 * @uses bbp_get_forum_last_topic_id() To get the forum's last topic id
 * @uses apply_filters() Calls 'bbp_get_forum_last_reply_id' with
 *                        the last reply id and forum id
 * @return int Forum's last reply id
 */
function bbp_get_forum_last_reply_id($forum_id = 0)
{
    $forum_id = bbp_get_forum_id($forum_id);
    $reply_id = get_post_meta($forum_id, '_bbp_last_reply_id', true);
    if (empty($reply_id)) {
        $reply_id = bbp_get_forum_last_topic_id($forum_id);
    }
    return (int) apply_filters('bbp_get_forum_last_reply_id', (int) $reply_id, $forum_id);
}
Example #8
0
/**
 * Return the author ID of the last topic of a forum
 *
 * @since 2.0.0 bbPress (r2625)
 *
 * @param int $forum_id Optional. Forum id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum_last_topic_id() To get the forum's last topic id
 * @uses bbp_get_topic_author_id() To get the topic's author id
 * @uses apply_filters() Calls 'bbp_get_forum_last_topic_author' with the author
 *                        id and forum id
 * @return int Forum's last topic's author id
 */
function bbp_get_forum_last_topic_author_id($forum_id = 0)
{
    $forum_id = bbp_get_forum_id($forum_id);
    $topic_id = bbp_get_forum_last_topic_id($forum_id);
    $author_id = bbp_get_topic_author_id($topic_id);
    return (int) apply_filters('bbp_get_forum_last_topic_author_id', (int) $author_id, $forum_id, $topic_id);
}
Example #9
0
 /**
  * @covers ::bbp_unspam_topic
  */
 public function test_bbp_unspam_topic()
 {
     $f = $this->factory->forum->create();
     $now = time();
     $post_date_topic = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $post_date_reply = date('Y-m-d H:i:s', $now - 60 * 60 * 80);
     $topic_time = '4 days, 4 hours ago';
     $reply_time = '3 days, 8 hours ago';
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date_topic, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create_many(2, array('post_parent' => $t, 'post_date' => $post_date_reply, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     bbp_spam_topic($t);
     bbp_unspam_topic($t);
     $topic_status = get_post_status($t);
     $this->assertSame(bbp_get_public_status_id(), $topic_status);
     $this->assertEquals('', get_post_meta($t, '_bbp_pre_spammed_replies', true));
     $this->assertEquals(array(), get_post_meta($t, '_bbp_pre_spammed_replies', false));
     $this->assertEquals('', get_post_meta($t, '_bbp_spam_meta_status', true));
     $this->assertEquals(array(), get_post_meta($t, '_bbp_spam_meta_status', false));
     $count = bbp_get_forum_topic_count($f, false, true);
     $this->assertSame(1, $count);
     $count = bbp_get_forum_topic_count_hidden($f, true);
     $this->assertSame(0, $count);
     $count = bbp_get_forum_reply_count($f, false, true);
     $this->assertSame(2, $count);
     $last_topic_id = bbp_get_forum_last_topic_id($f);
     $this->assertSame($t, $last_topic_id);
     $last_reply_id = bbp_get_forum_last_reply_id($f);
     $this->assertSame($r[1], $last_reply_id);
     $last_active_id = bbp_get_forum_last_active_id($f);
     $this->assertSame($r[1], $last_active_id);
     $last_active_time = bbp_get_forum_last_active_time($f);
     $this->assertSame($reply_time, $last_active_time);
     $count = bbp_get_topic_reply_count($t, true, true);
     $this->assertSame(2, $count);
     $count = bbp_get_topic_reply_count_hidden($t, true, true);
     $this->assertSame(0, $count);
     $last_reply_id = bbp_get_topic_last_reply_id($t);
     $this->assertSame($r[1], $last_reply_id);
     $last_active_id = bbp_get_topic_last_active_id($t);
     $this->assertSame($r[1], $last_active_id);
     $last_active_time = bbp_get_topic_last_active_time($t);
     $this->assertSame($reply_time, $last_active_time);
 }
Example #10
0
 /**
  * @group canonical
  * @covers ::bbp_create_initial_content
  */
 public function test_bbp_create_initial_content()
 {
     $category_id = $this->factory->forum->create(array('forum_meta' => array('_bbp_forum_type' => 'category', '_bbp_status' => 'open')));
     bbp_create_initial_content(array('forum_parent' => $category_id));
     $forum_id = bbp_forum_query_subforum_ids($category_id);
     $forum_id = (int) $forum_id[0];
     $topic_id = bbp_get_forum_last_topic_id($forum_id);
     $reply_id = bbp_get_forum_last_reply_id($forum_id);
     // Forum post
     $this->assertSame('General', bbp_get_forum_title($forum_id));
     $this->assertSame('General chit-chat', bbp_get_forum_content($forum_id));
     $this->assertSame('open', bbp_get_forum_status($forum_id));
     $this->assertTrue(bbp_is_forum_public($forum_id));
     $this->assertSame($category_id, bbp_get_forum_parent_id($forum_id));
     // Topic post
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame('Hello World!', bbp_get_topic_title($topic_id));
     remove_all_filters('bbp_get_topic_content');
     $topic_content = "I am the first topic in your new forums.";
     $this->assertSame($topic_content, bbp_get_topic_content($topic_id));
     $this->assertSame('publish', bbp_get_topic_status($topic_id));
     $this->assertTrue(bbp_is_topic_published($topic_id));
     // Reply post
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_reply_title($reply_id));
     $this->assertSame($reply_id, bbp_get_reply_title_fallback($reply_id));
     remove_all_filters('bbp_get_reply_content');
     $reply_content = "Oh, and this is what a reply looks like.";
     $this->assertSame($reply_content, bbp_get_reply_content($reply_id));
     $this->assertSame('publish', bbp_get_reply_status($reply_id));
     $this->assertTrue(bbp_is_reply_published($reply_id));
     // Category meta
     $this->assertSame(1, bbp_get_forum_subforum_count($category_id, true));
     $this->assertSame(0, bbp_get_forum_topic_count($category_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($category_id, true));
     $this->assertSame(0, bbp_get_forum_reply_count($category_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($category_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($category_id, true, true));
     $this->assertSame(0, bbp_get_forum_post_count($category_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($category_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($category_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($category_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($category_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($category_id));
     // Forum meta
     $this->assertSame(0, bbp_get_forum_subforum_count($forum_id, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($forum_id, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($forum_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($forum_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($forum_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($forum_id));
     // Topic meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($topic_id));
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame(0, bbp_get_topic_reply_count_hidden($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_topic_last_active_time($topic_id));
     // Reply Meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($reply_id));
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
 }
Example #11
0
function ipt_kb_bbp_forum_freshness_in_list($forum_id = 0)
{
    $og_forum_last_topic_id = bbp_get_forum_last_topic_id($forum_id);
    $og_last_topic_id = bbp_get_topic_last_active_id($og_forum_last_topic_id);
    $author_link = bbp_get_author_link(array('post_id' => $og_last_topic_id, 'type' => 'name'));
    $freshness = bbp_get_author_link(array('post_id' => $og_last_topic_id, 'size' => 32, 'type' => 'avatar'));
    if (!empty($freshness)) {
        ?>
<span class="pull-left thumbnail">
        <?php 
        echo $freshness;
        ?>
</span>
<?php 
    }
    do_action('bbp_theme_before_forum_freshness_link');
    ?>
<ul class="list-unstyled ipt_kb_forum_freshness_meta">
        <li class="bbp-topic-freshness-link"><?php 
    echo bbp_topic_freshness_link($og_forum_last_topic_id);
    ?>
  </li>
        <li class="bbp-topic-freshness-author">
                <?php 
    do_action('bbp_theme_before_topic_author');
    ?>
                <?php 
    if (!empty($author_link)) {
        printf(__('by %s', 'ipt_kb'), $author_link);
    }
    ?>
                <?php 
    do_action('bbp_theme_after_topic_author');
    ?>
        </li>
</ul>
<?php 
    do_action('bbp_theme_after_forum_freshness_link');
    ?>
        <?php 
}
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;
}
Example #13
0
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>&nbsp;' . __('Freshness', 'firmasite') . ':';
    } else {
        $anchor = __('No Topics', 'firmasite');
    }
    return apply_filters('bbp_get_forum_freshness_link', $anchor, $forum_id);
}