/** * Adjust Badge Column Content * @version 1.0 */ public function adjust_column_content($column_name, $post_id) { // Default Image if ($column_name == 'badge-default-image') { $default_image = get_post_meta($post_id, 'default_image', true); if ($default_image != '') { echo '<img src="' . $default_image . '" style="max-width: ' . MYCRED_BADGE_WIDTH . 'px;height: auto;" alt="" />'; } $main_image = get_post_meta($post_id, 'main_image', true); if ($main_image != '') { echo '<img src="' . $main_image . '" style="max-width: ' . MYCRED_BADGE_WIDTH . 'px;height: auto;" alt="" />'; } if ($default_image == '' && $main_image == '') { echo '-'; } $requirements = mycred_get_badge_requirements($post_id); if (count($requirements) > 1) { foreach ($requirements as $level => $needs) { $level_image = get_post_meta($post_id, 'level_image' . $level, true); if ($level_image != '') { echo '<img src="' . $level_image . '" style="max-width: ' . MYCRED_BADGE_WIDTH . 'px;height: auto;" alt="" />'; } } } } elseif ($column_name == 'badge-reqs') { echo '<small>' . __('A user must have gained or lost:', 'mycred') . '</small><br />'; echo mycred_display_badge_requirements($post_id); } elseif ($column_name == 'badge-users') { echo mycred_count_users_with_badge($post_id); } }
function mycred_render_badges($atts, $content = '') { extract(shortcode_atts(array('show' => 'default', 'title' => 0, 'requires' => 0, 'show_count' => 0, 'width' => MYCRED_BADGE_WIDTH, 'height' => MYCRED_BADGE_HEIGHT), $atts)); $all_badges = mycred_get_badges(); if ($width != '') { $width = ' width="' . $width . '"'; } if ($height != '') { $height = ' height="' . $height . '"'; } ob_start(); echo '<div id="mycred-all-badges">'; if (!empty($all_badges)) { foreach ($all_badges as $badge) { echo '<div class="the-badge">'; if ($title == 1) { echo '<h3 class="badge-title">' . $badge->post_title . '</h3>'; } if ($requires == 1) { echo '<div class="badge-requirements">' . mycred_display_badge_requirements($badge->ID) . '</div>'; } if ($show_count == 1) { echo '<div class="users-with-badge">' . mycred_count_users_with_badge($badge->ID) . '</div>'; } // Show default image if ($show == 'default') { echo '<img src="' . $badge->default_img . '"' . $width . $height . ' class="mycred-badge dislay-default" alt="' . $badge->post_title . '" title="' . $badge->post_title . '" />'; } elseif ($show == 'main') { echo '<img src="' . $badge->main_img . '"' . $width . $height . ' class="mycred-badge display-main" alt="' . $badge->post_title . '" title="' . $badge->post_title . '" />'; } else { echo '<img src="' . $badge->default_img . '"' . $width . $height . ' class="mycred-badge dislay-default" alt="' . $badge->post_title . '" title="' . $badge->post_title . '" />'; echo '<img src="' . $badge->main_img . '"' . $width . $height . ' class="mycred-badge display-main" alt="' . $badge->post_title . '" title="' . $badge->post_title . '" />'; } echo '</div>'; } } echo '</div>'; $output = ob_get_contents(); ob_end_clean(); return apply_filters('mycred_badges', $output); }
/** * Adjust Badge Column Content * @version 1.0 */ public function adjust_column_content($column_name, $post_id) { // Default Image if ($column_name == 'badge-default-image') { $default_image = get_post_meta($post_id, 'default_image', true); if ($default_image != '') { echo '<img src="' . $default_image . '" style="max-width: 100px;height: auto;" alt="" />'; } $main_image = get_post_meta($post_id, 'main_image', true); if ($main_image != '') { echo '<img src="' . $main_image . '" style="max-width: 100px;height: auto;" alt="" />'; } if ($default_image == '' && $main_image == '') { echo '-'; } } elseif ($column_name == 'badge-reqs') { echo '<small>' . __('A user must have gained or lost:', 'mycred') . '</small><br />'; echo mycred_display_badge_requirements($post_id); } elseif ($column_name == 'badge-users') { echo mycred_count_users_with_badge($post_id); } }