Changeset 2698 for trunk/bp-blogs/bp-blogs-widgets.php
- Timestamp:
- 02/12/2010 01:27:20 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-blogs/bp-blogs-widgets.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-widgets.php
r2576 r2698 1 1 <?php 2 2 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 4 8 function 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");') ); 6 13 } 7 add_action( ' template_redirect', 'bp_blogs_register_widgets' );14 add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' ); 8 15 9 16 class BP_Blogs_Recent_Posts_Widget extends WP_Widget { … … 26 33 $instance['max_posts'] = 10; ?> 27 34 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'] ) ) : ?> 30 36 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 37 41 <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"> 41 43 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> 46 52 <?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 48 54 </div> 49 55 </li> 50 <?php $counter++; ?> 51 <?php endforeach; ?> 56 57 <?php endwhile; ?> 58 52 59 </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> 56 64 </div> 57 65 <?php endif; ?>
Note: See TracChangeset
for help on using the changeset viewer.