public
Created

Buddypress Activity shortcode

  • Download Gist
bp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
function bp_get_activities($atts, $content = null ){
extract(shortcode_atts(array(
'max' => '10',
'per_page' => '10'
), $atts));
 
$activities = '<ul class="activity-list item-list">';
 
if ( bp_has_activities( 'activity&per_page='. $per_page .'max='. $max ) ) :
ob_start();
while ( bp_activities() ) : bp_the_activity();
do_action( 'bp_directory_members_item' );
?>
 
<?php do_action( 'bp_before_activity_entry' ); ?>
 
<li class="<?php bp_activity_css_class(); ?>" id="activity-<?php bp_activity_id(); ?>">
<div class="row-fluid">
 
<div class="span12">
<div class="activity-avatar pull-left">
<a href="<?php bp_activity_user_link(); ?>">
<?php bp_activity_avatar(); ?>
</a>
</div>
<div class="activity-content">
 
<div class="activity-header">
 
<?php bp_activity_action(); ?>
 
</div>
 
<?php if ( 'activity_comment' == bp_get_activity_type() ) : ?>
 
<div class="activity-inreplyto">
<strong><?php _e( 'In reply to: ', 'buddypress' ); ?></strong><?php bp_activity_parent_content(); ?> <a href="<?php bp_activity_thread_permalink(); ?>" class="view" title="<?php _e( 'View Thread / Permalink', 'buddypress' ); ?>"><?php _e( 'View', 'buddypress' ); ?></a>
</div>
 
<?php endif; ?>
 
<?php if ( bp_activity_has_content() ) : ?>
 
<div class="activity-inner">
 
<?php bp_activity_content_body(); ?>
 
</div>
 
<?php endif; ?>
 
<?php do_action( 'bp_activity_entry_content' ); ?>
 
<?php if ( is_user_logged_in() ) : ?>
 
<div class="activity-meta">
 
<?php if ( bp_activity_can_comment() ) : ?>
 
<a href="<?php bp_get_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf( __( 'Comment (<span>%s</span>)', 'buddypress' ), bp_activity_get_comment_count() ); ?></a>
 
<?php endif; ?>
 
<?php if ( bp_activity_can_favorite() ) : ?>
 
<?php if ( !bp_get_activity_is_favorite() ) : ?>
 
&middot; <a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e( 'Mark as Favorite', 'buddypress' ); ?>"><?php _e( 'Favorite', 'buddypress' ); ?></a>
 
<?php else : ?>
 
&middot; <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( 'Remove Favorite', 'buddypress' ); ?>"><?php _e( 'Remove Favorite', 'buddypress' ); ?></a>
 
<?php endif; ?>
 
<?php endif; ?>
 
<?php if ( bp_activity_user_can_delete() ) { echo ' &middot; '; bp_activity_delete_link(); } ?>
 
<span class="activity-time-since text-info"><?php echo bp_core_time_since( bp_get_activity_date_recorded() ) ?></span>
 
<?php do_action( 'bp_activity_entry_meta' ); ?>
 
</div>
 
<?php endif; ?>
 
</div>
 
</div>
</div>
</li>
 
<?php do_action( 'bp_after_activity_entry' ); ?>
 
 
<?php
//locate_template( array( 'activity/entry.php' ), true, false );
endwhile;
endif;
$activities .= ob_get_contents();
ob_end_clean();
$activities .='</ul>';
return $activities;
}
add_shortcode('activity', 'bp_get_activities');

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.