Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. /**
  2. * Display earned badges for a given user FORUM
  3. *
  4. * @param array $atts Our attributes array
  5. * @return string Concatenated markup
  6. */
  7. function prefix_badgeos_user_achievements_shortcode_forum( $atts = array() ) {
  8.  
  9. // Parse our attributes
  10. $atts = shortcode_atts( array(
  11. 'user' =>  bbp_get_reply_author_id(),
  12. 'type' => 'award',
  13. 'limit' => 5
  14. ), $atts );
  15.  
  16. $output = '';
  17.  
  18. // Grab the user's current achievements, without duplicates
  19. $achievementsforum = array_unique( badgeos_get_user_earned_achievement_ids( $atts['user'], $atts['type'] ) );
  20.  
  21. // Setup a counter
  22. $count = 0;
  23.  
  24. // Loop through the achievements
  25. if ( ! empty( $achievementsforum ) ) {
  26. $output .= '<div class="user_awards">User Awards</div>';
  27. $output .= '<div class="badgeos-user-badges-wrap-forum">';
  28. foreach( $achievementsforum as $achievement_forum_id ) {
  29.  
  30. // If we've hit our limit, quit
  31. if ( $count >= $atts['limit'] ) {
  32. break;
  33. }
  34.  
  35. // Output our achievement image and title
  36. $output .= '<div class="badgeos-badge-wrap-forum">';
  37. $output .= badgeos_get_achievement_post_thumbnail( $achievement_forum_id );
  38. $output .= '</div>';
  39.  
  40.  
  41. // Increase our counter
  42. $count++;
  43. }
  44. $output .= '</div>';
  45. }
  46.  
  47. return $output;
  48. }
  49. add_shortcode( 'custom_badgeos_user_achievements_forum', 'prefix_badgeos_user_achievements_shortcode_forum' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement