WPBadger
WPBadger copied to clipboard
display badge image on award pages
Badge images are currently displayed on pages for each badge; they should be added to each award page so it's clear what badge was awarded. This is a matter of retrieving the badge post ID from the award post meta field, and displaying the featured image for the badge post id.
I took a crack at this and got it working to some extent. It doesn't yet keep the badge image in view after the accept or decline action has been taken, but it is a start. I edited the includes/awards.php, changing the block if ($award_status == 'Awarded') to the following:
if ($award_status == 'Awarded')
{
$badge_title = esc_html( get_the_title( get_post_meta( $post_id, 'wpbadger-award-choose-badge', true ) ) );
$badge_thumbnailhtml = get_the_post_thumbnail( get_post_meta( $post_id, 'wpbadger-award-choose-badge', true ), 'thumbnail' );
$content = <<<EOHTML
<div id="wpbadger-award-actions-wrap">
<div id="wpbadger-award-actions" class="wpbadger-award-notice">
<p>Congratulations! The "{$badge_title}" badge has been awarded to you.</p>
<p>Please choose to <a href='#' class='acceptBadge'>accept</a> or <a href='#' class='rejectBadge'>decline</a> having the award added to your OpenBadges Backpack.</p>
</div>
<div id="wpbadger-award-browser-support" class="wpbadger-award-error">
<p>Microsoft Internet Explorer is not supported at this time. Please use Firefox or Chrome to retrieve your award.</p>
</div>
<div id="wpbadger-award-actions-errors" class="wpbadger-award-error">
<p>An error occured while adding this badge to your backpack.</p>
</div>
<div id="mybadgeimage" style="margin-left:40px;">{$badge_thumbnailhtml}</div>
</div>
{$content}
EOHTML;
}