function mycred_render_users_of_rank($atts, $row_template = NULL) { extract(shortcode_atts(array('rank_id' => NULL, 'login' => '', 'number' => NULL, 'wrap' => 'div', 'col' => 1, 'nothing' => __('No users found with this rank', 'mycred')), $atts)); // Rank ID required if ($rank_id === NULL) { return '<strong>' . __('error', 'mycred') . '</strong> ' . __('Rank ID is required!', 'mycred'); } $mycred = mycred(); // User is not logged in if (!is_user_logged_in()) { return $mycred->template_tags_general($login); } // ID is not a post id but a rank title if (!is_numeric($rank_id)) { $rank_id = mycred_get_rank_id_from_title($rank_id); } $output = ''; $rank = get_post($rank_id); // Make sure rank exist if ($rank !== NULL) { if ($row_template === NULL || empty($row_template)) { $row_template = '<p class="user-row">%user_profile_link% with %balance% %_plural%</p>'; } // Let others play $row_template = apply_filters('mycred_users_of_rank', $row_template, $atts, $mycred); // Get users of this rank if there are any $users = mycred_get_users_of_rank($rank_id, $number); if (!empty($users)) { // Add support for table if ($wrap != 'table' && !empty($wrap)) { $output .= '<' . $wrap . ' class="mycred-users-of-rank-wrapper">'; } // Loop foreach ($users as $user) { $output .= $mycred->template_tags_user($row_template, $user['user_id']); } // Add support for table if ($wrap != 'table' && !empty($wrap)) { $output .= '</' . $wrap . '>' . "\n"; } } else { // Add support for table if ($wrap == 'table') { $output .= '<tr><td'; if ($col > 1) { $output .= ' colspan="' . $col . '"'; } $output .= '>' . $nothing . '</td></tr>'; } else { if (empty($wrap)) { $wrap = 'p'; } $output .= '<' . $wrap . '>' . $nothing . '</' . $wrap . '>' . "\n"; } } } return do_shortcode($output); }
function mycred_get_rank_logo($rank_id, $size = 'post-thumbnail', $attr = NULL) { if (!is_numeric($rank_id)) { $rank_id = mycred_get_rank_id_from_title($rank_id); } if (!mycred_rank_has_logo($rank_id)) { return ''; } if (is_numeric($size)) { $size = array($size, $size); } if (!mycred_override_settings()) { $logo = get_the_post_thumbnail($rank_id, $size, $attr); } else { $original_blog_id = get_current_blog_id(); switch_to_blog(1); $logo = get_the_post_thumbnail($rank_id, $size, $attr); switch_to_blog($original_blog_id); } return apply_filters('mycred_get_rank_logo', $logo, $rank_id, $size, $attr); }