-
-
Save messaoudi-mounir/5405475 to your computer and use it in GitHub Desktop.
Buddypress Activity shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() ) : ?> | |
· <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 : ?> | |
· <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 ' · '; 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'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment