コード例 #1
0
function bp_get_the_site_blog_latest_post()
{
    global $site_blogs_template;
    if ($post = bp_blogs_get_latest_posts($site_blogs_template->blog->blog_id, 1)) {
        return apply_filters('bp_get_the_site_blog_latest_post', sprintf(__('Latest Post: %s', 'buddypress'), '<a href="' . bp_post_get_permalink($post[0], $site_blogs_template->blog->blog_id) . '">' . apply_filters('the_title', $post[0]->post_title) . '</a>'));
    }
}
コード例 #2
0
ファイル: bp-blogs.php プロジェクト: alvaropereyra/shrekcms
function bp_blogs_format_activity($item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false)
{
    global $bp;
    switch ($action) {
        case 'new_blog':
            $blog = new BP_Blogs_Blog($item_id);
            if (!$blog) {
                return false;
            }
            if (!$user_id) {
                return false;
            }
            $blog_url = get_blog_option($blog->blog_id, 'siteurl');
            $user_link = bp_core_get_userlink($user_id);
            $blog_name = get_blog_option($blog->blog_id, 'blogname');
            return array('primary_link' => $blog_url, 'content' => apply_filters('bp_blogs_new_blog_activity', sprintf(__('%s created a new blog: %s', 'buddypress'), $user_link, '<a href="' . $blog_url . '">' . $blog_name . '</a>') . ' <span class="time-since">%s</span>', $user_link, $blog_url, $blog_name));
            break;
        case 'new_blog_post':
            $post = new BP_Blogs_Post($item_id);
            if (!$post) {
                return false;
            }
            $post = BP_Blogs_Post::fetch_post_content($post);
            if (!$post || $post->post_type != 'post') {
                return false;
            }
            $post_link = bp_post_get_permalink($post, $post->blog_id);
            $user_link = bp_core_get_userlink($user_id);
            $content = sprintf(__('%s wrote a new blog post: %s', 'buddypress'), $user_link, '<a href="' . $post_link . '">' . $post->post_title . '</a>') . ' <span class="time-since">%s</span>';
            $content .= '<blockquote>' . bp_create_excerpt($post->post_content) . '</blockquote>';
            $content = apply_filters('bp_blogs_new_post_activity', $content, $user_link, $post);
            return array('primary_link' => $post_link, 'content' => $content);
            break;
        case 'new_blog_comment':
            if (!is_user_logged_in()) {
                return false;
            }
            $comment = new BP_Blogs_Comment($secondary_item_id);
            if (!$comment) {
                return false;
            }
            $comment = BP_Blogs_Comment::fetch_comment_content($comment);
            if (!$comment) {
                return false;
            }
            $comment_link = bp_post_get_permalink($comment->post, $comment->blog_id);
            $user_link = bp_core_get_userlink($user_id);
            $content = sprintf(__('%s commented on the blog post %s', 'buddypress'), $user_link, '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>') . ' <span class="time-since">%s</span>';
            $content .= '<blockquote>' . bp_create_excerpt($comment->comment_content) . '</blockquote>';
            $content = apply_filters('bp_blogs_new_comment_activity', $content, $user_link, $comment);
            return array('primary_link' => $post_link . '#comment-' . $comment->comment_ID, 'content' => $content);
            break;
    }
    do_action('bp_blogs_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user);
    return false;
}
コード例 #3
0
function bp_blogs_widget_recent_posts($args)
{
    global $current_blog;
    extract($args);
    $options = get_blog_option($current_blog->blog_id, 'bp_blogs_widget_recent_posts');
    ?>
	<?php 
    echo $before_widget;
    ?>
	<?php 
    echo $before_title . $widget_name . $after_title;
    ?>

		<?php 
    $posts = bp_blogs_get_latest_posts(null, $options['max_posts']);
    ?>
		<?php 
    $counter = 0;
    ?>
		
	<?php 
    if ($posts) {
        ?>
		<div class="item-options" id="recent-posts-options">
			<?php 
        _e("Site Wide", 'buddypress');
        ?>
		</div>
		<ul id="recent-posts" class="item-list">
			<?php 
        foreach ($posts as $post) {
            ?>
				<li>
					<div class="item-avatar">
						<a href="<?php 
            echo bp_post_get_permalink($post, $post->blog_id);
            ?>
" title="<?php 
            echo apply_filters('the_title', $post->post_title);
            ?>
"><?php 
            echo bp_core_get_avatar($post->post_author, 1);
            ?>
</a>
					</div>

					<div class="item">
						<h4 class="item-title"><a href="<?php 
            echo bp_post_get_permalink($post, $post->blog_id);
            ?>
" title="<?php 
            echo apply_filters('the_title', $post->post_title);
            ?>
"><?php 
            echo apply_filters('the_title', $post->post_title);
            ?>
</a></h4>
						<?php 
            if (!$counter) {
                ?>
							<div class="item-content"><?php 
                echo bp_create_excerpt($post->post_content);
                ?>
</div>
						<?php 
            }
            ?>
						<div class="item-meta"><em><?php 
            printf(__('by %s from the blog <a href="%s">%s</a>', 'buddypress'), bp_core_get_userlink($post->post_author), get_blog_option($post->blog_id, 'siteurl'), get_blog_option($post->blog_id, 'blogname'));
            ?>
</em></div>
					</div>
				</li>
				<?php 
            $counter++;
            ?>
	
			<?php 
        }
        ?>
		</ul>
	<?php 
    } else {
        ?>
		<div class="widget-error">
			<?php 
        _e('There are no recent blog posts, why not write one?', 'buddypress');
        ?>
		</div>
	<?php 
    }
    ?>

	<?php 
    echo $after_widget;
}