Created
February 24, 2012 17:31
-
-
Save imjjss/1902252 to your computer and use it in GitHub Desktop.
add favorit (not working since bp1.3)
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
<?php | |
//For the functions.php file | |
function my_bp_activity_is_favorite($activity_id) { | |
global $bp, $activities_template; | |
return apply_filters( 'bp_get_activity_is_favorite', in_array( $activity_id, (array)$activities_template->my_favs ) ); | |
} | |
function my_bp_activity_favorite_link($activity_id) { | |
global $activities_template; | |
echo apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/favorite/' . $activity_id . '/' ), 'mark_favorite' ) ); | |
} | |
function my_bp_activity_unfavorite_link($activity_id) { | |
global $activities_template; | |
echo apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/unfavorite/' . $activity_id . '/' ), 'unmark_favorite' ) ); | |
} | |
?> | |
<? | |
//For single.php - put within the WP loop | |
global $bp; | |
$activity_id = bp_activity_get_activity_id( array( | |
'user_id' => $post->author_id, | |
'type' => 'new_blog_post', | |
'component' => 'blogs', | |
'item_id' => 1, | |
'secondary_item_id' => $post->ID | |
) ); | |
?> | |
<?php if ( is_user_logged_in() ) : ?> | |
<?php bp_has_activities(); | |
if ( !my_bp_activity_is_favorite($activity_id) ) : ?> | |
<a href="<?php my_bp_activity_favorite_link($activity_id) ?>" class="fav" title="<?php _e( 'Mark as Favorite', 'buddypress' ) ?>"><?php _e( 'Favorite', 'buddypress' ) ?></a> | |
<?php else : ?> | |
<a href="<?php my_bp_activity_unfavorite_link($activity_id) ?>" class="unfav" title="<?php _e( 'Remove Favorite', 'buddypress' ) ?>"><?php _e( 'Un-favorite', 'buddypress' ) ?></a><br> | |
<a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/favorites/' ?>" style="font-size: 12px;">View Your Favorites</a> | |
<?php endif; ?> | |
<?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment