Skip to:
Content

BuddyPress.org

Changeset 2698


Ignore:
Timestamp:
02/12/2010 01:27:20 PM (16 years ago)
Author:
apeatling
Message:

Fixing up the sitewide blog posts widget to only show on multisite installations, and also to use the activity loop filtered on blog posts.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r2696 r2698  
    99require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
    1010require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
    11 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
     11
     12/* Include the sitewide blog posts widget if this is a multisite installation */
     13if ( bp_core_is_multisite() )
     14        require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
    1215
    1316function bp_blogs_install() {
     
    437440                if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
    438441                        /* Now re-record the post in the activity streams */
    439                         $post_permalink = bp_post_get_permalink( $post, $blog_id );
     442                        $post_permalink = get_permalink( $post_id );
    440443
    441444                        $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
     
    495498        if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
    496499                /* Record in activity streams */
    497                 $comment_link = bp_post_get_permalink( $comment->post, $wpdb->blogid ) . '#comment-' . $comment_id;
     500                $comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id;
    498501                $activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
    499502                $activity_content = $comment->comment_content;
  • trunk/bp-blogs/bp-blogs-widgets.php

    r2576 r2698  
    11<?php
    22
    3 /* Register widgets for blogs component */
     3/***
     4 * The recent blogs widget is actually just the activity feed filtered on "new_blog_post".
     5 * Why not make some of your own widgets using a filtered activity stream?
     6 */
     7
    48function bp_blogs_register_widgets() {
    5         add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");') );
     9        global $current_blog, $bp;
     10
     11        if ( bp_is_active( 'activity' ) && (int)$current_blog->blog_id == BP_ROOT_BLOG )
     12                add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");') );
    613}
    7 add_action( 'template_redirect', 'bp_blogs_register_widgets' );
     14add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
    815
    916class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
     
    2633                        $instance['max_posts'] = 10; ?>
    2734
    28                 <?php $posts = bp_blogs_get_latest_posts( null, $instance['max_posts'] ) ?>
    29                 <?php $counter = 0; ?>
     35                <?php if ( bp_has_activities( 'action=new_blog_post&max=' . $instance['max_posts'] . '&per_page=' . $instance['max_posts'] ) ) : ?>
    3036
    31                 <?php if ( $posts ) : ?>
    32                         <div class="item-options" id="recent-posts-options">
    33                                 <?php _e("Site Wide", 'buddypress') ?>
    34                         </div>
    35                         <ul id="recent-posts" class="item-list">
    36                                 <?php foreach ( (array)$posts as $post ) : ?>
     37                        <ul id="blog-post-list" class="activity-list item-list">
     38
     39                                <?php while ( bp_activities() ) : bp_the_activity(); ?>
     40
    3741                                        <li>
    38                                                 <div class="item-avatar">
    39                                                         <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_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ?></a>
    40                                                 </div>
     42                                                <div class="activity-content" style="margin: 0">
    4143
    42                                                 <div class="item">
    43                                                         <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>
    44                                                         <?php if ( !$counter ) : ?>
    45                                                                 <div class="item-content"><?php echo bp_create_excerpt($post->post_content) ?></div>
     44                                                        <div class="activity-header">
     45                                                                <?php bp_activity_action() ?>
     46                                                        </div>
     47
     48                                                        <?php if ( bp_get_activity_content_body() ) : ?>
     49                                                                <div class="activity-inner">
     50                                                                        <?php bp_activity_content_body() ?>
     51                                                                </div>
    4652                                                        <?php endif; ?>
    47                                                         <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>
     53
    4854                                                </div>
    4955                                        </li>
    50                                         <?php $counter++; ?>
    51                                 <?php endforeach; ?>
     56
     57                                <?php endwhile; ?>
     58
    5259                        </ul>
    53                 <?php else: ?>
    54                         <div class="widget-error">
    55                                 <?php _e('There are no recent blog posts, why not write one?', 'buddypress') ?>
     60
     61                <?php else : ?>
     62                        <div id="message" class="info">
     63                                <p><?php _e( 'Sorry, there were no blog posts found. Why not write one?', 'buddypress' ) ?></p>
    5664                        </div>
    5765                <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.