0 Commentaires

Laisser une réponse

Votre adresse e-mail ne sera pas publiée.

*

function get_fav_or_unfav_button_for_post( $post ) { global $bp, $activities_template, $post; // only show the button to logged-in users if ( ! is_user_logged_in() ) { return ''; } $activity_id = bp_activity_get_activity_id( array( 'user_id' => $post->post_author, 'type' => 'new_blog_post', 'component' => 'page', 'item_id' => 1, // page_ID 'secondary_item_id' => $link->ID // post_ID ) ); if ( ! $activity_id ) { return ''; } bp_has_activities(); // update $activities_template with user's favs $old_value = false; if ( isset( $activities_template->activity->id ) ) { $old_value = $activities_template->activity->id; $activities_template->activity->id = $activity_id; } else { $activities_template->activity = (object) array( 'id' => $activity_id ); } // build the template $code = ''; $code .= '
'."\n"; if ( ! bp_get_activity_is_favorite() ) { // if not favorited, add a "Favorite" button $code .= ' Favorite'."\n"; } else { // else, add "Unfavorite" button $code .= ' Unfavorite'."\n"; // Bonus button: "View all my favorites" $code .= ' View all my favs'."\n"; } // closing .activity-meta $code .= '
'."\n"; if ( false !== $old_value ) { $activities_template->activity->id = $old_value; } else { //$activities_template->activity = null; $activities_template->activity = (object) array( 'id' => $activity_id ); } return $code; }

©2025 KLEO Template a premium and multipurpose theme from Seventh Queen

Nous contacter

En cours d’envoi

Vous connecter avec vos identifiants

ou    

Vous avez oublié vos informations ?

Create Account