function mycred_render_my_ranks($atts, $content = NULL)
 {
     extract(shortcode_atts(array('user_id' => NULL, 'show_title' => 1, 'show_logo' => 0, 'logo_size' => 'post-thumbnail', 'first' => 'logo'), $atts));
     if ($user_id === NULL && !is_user_logged_in()) {
         return;
     }
     if ($user_id === NULL) {
         $user_id = get_current_user_id();
     }
     $mycred_types = mycred_get_types();
     $show = array();
     foreach ($mycred_types as $type_id => $label) {
         $row = array();
         $rank_id = mycred_get_users_rank_id($user_id, $type_id);
         if ($show_logo) {
             $row[] = mycred_get_rank_logo($rank_id, $logo_size);
         }
         if ($show_title) {
             $row[] = get_the_title($rank_id);
         }
         if ($first != 'logo') {
             $row = array_reverse($row);
         }
         $show = array_merge($row, $show);
     }
     if (empty($show)) {
         return;
     }
     return '<div class="mycred-all-ranks">' . implode(' ', $show) . '</div>';
 }
Example #2
0
 /**
  * Insert Rank In bbPress Profile
  * @since 1.6
  * @version 1.0
  */
 public function insert_rank_bb_profile()
 {
     $output = '';
     $user_id = bbp_get_displayed_user_id();
     foreach ($this->point_types as $type_id => $label) {
         // Load type
         $mycred = mycred($type_id);
         // User is excluded from this type
         if ($mycred->exclude_user($user_id)) {
             continue;
         }
         // No settings
         if (!isset($mycred->rank['bp_location'])) {
             continue;
         }
         // Not shown
         if (!in_array($mycred->rank['bp_location'], array('profile', 'both'))) {
             continue;
         }
         // Get rank (if user has one
         $users_rank = mycred_get_users_rank_id($user_id, $type_id);
         if ($users_rank === NULL) {
             continue;
         }
         // Parse template
         $template = $mycred->rank['bp_template'];
         $template = str_replace('%rank_title%', get_the_title($users_rank), $template);
         $template = str_replace('%rank_logo%', mycred_get_rank_logo($users_rank), $template);
         // Let others play
         $output .= apply_filters('mycred_bb_profile_ranks_row', $template, $user_id, $users_rank, $mycred, $this);
     }
     if ($output == '') {
         return;
     }
     echo '<div id="mycred-my-rank">' . apply_filters('mycred_bb_rank_in_profile', $output, $user_id, $this) . '</div>';
 }