Created
February 13, 2014 13:32
-
-
Save gabrielmerovingi/8975067 to your computer and use it in GitHub Desktop.
Updated version of the mycred_lottery_results shortcode with added option to use user related template tags for each row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* [mycred_lottery_results] Shortcode Render | |
* @since 1.0 | |
* @version 1.2 | |
*/ | |
if ( ! function_exists( 'mycred_lotto_render_draws' ) ) : | |
function mycred_lotto_render_draws( $atts, $content = NULL ) | |
{ | |
extract( shortcode_atts( array( | |
'id' => NULL, | |
'title_draw' => __( 'Past Winners', 'mycred_lotto' ), | |
'title_pick' => __( 'Drawn Numbers', 'mycred_lotto' ), | |
'user_row' => '%display_name%' | |
), $atts ) ); | |
// Make sure lottery exists | |
$lottery_id = $id; | |
$lottery = new myCRED_Lottery( $lottery_id ); | |
if ( ! $lottery->lottery_exists() ) | |
return __( 'Could not find lottery.', 'mycred_lotto' ); | |
$content = '<div class="mycred-lotto-results">'; | |
$past_winners = get_post_meta( $lottery_id, 'lottery_winners', true ); | |
if ( ! empty( $past_winners ) ) { | |
krsort( $past_winners ); | |
ob_start(); ?> | |
<table style="width: 100%;"> | |
<thead> | |
<?php switch ( $lottery->get_type() ) { | |
case 'draw' : ?> | |
<tr> | |
<th id="mycred-lottery-result-date" class="lottery-result-date"><?php _e( 'Date', 'mycred_lotto' ); ?></th> | |
<th id="mycred-lottery-result-winner" class="lottery-result-winner"><?php _n( 'Winner', 'Winners', count( $past_winners ), 'mycred_lotto' ); ?></th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php foreach ( $past_winners as $time => $numbers ) { ?> | |
<tr> | |
<td class="lottery-result-date"><?php echo $lottery->get_time_formated( $time ); ?></td> | |
<td class="lottery-result-winner"> | |
<ol> | |
<?php foreach ( $numbers as $num => $entry ) { | |
$ticket = explode( '|', $entry ); | |
$user = get_userdata( $ticket[1] ); ?> | |
<li><?php echo $lottery->mycred->template_tags_user( $user_row, false, $user ); ?></li> | |
<?php } ?> | |
</ol> | |
</td> | |
</tr> | |
<?php } | |
break; | |
case 'pick' : ?> | |
<tr> | |
<th id="mycred-lottery-result-date" class="lottery-result-date"><?php _e( 'Date', 'mycred_lotto' ); ?></th> | |
<th id="mycred-lottery-result-draw" class="lottery-result-drawno"><?php _e( 'Draw', 'mycred_lotto' ); ?></th> | |
<th id="mycred-lottery-result-winner" class="lottery-result-winner"><?php _e( 'Winning Numbers', 'mycred_lotto' ); ?></th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php foreach ( $past_winners as $time => $numbers ) { ?> | |
<tr> | |
<td class="lottery-result-date"><?php echo $lottery->get_time_formated( $time ); ?></td> | |
<td class="lottery-result-drawno">#<?php echo $lottery->get_draw_number(); ?></td> | |
<td class="lottery-result-winner"><span><?php echo implode( '</span> <span>', $numbers ); ?></span></td> | |
</tr> | |
<?php } | |
break; | |
} ?> | |
</tbody> | |
</table> | |
<?php | |
$content = ob_get_contents(); | |
ob_end_clean(); | |
} | |
$content .= '</div>'; | |
return apply_filters( 'mycred_lotto_render_draws', $content, $atts, $lottery ); | |
} | |
endif; |
I don't have the rights to it anymore, even if they are not selling it anymore, they might be working on a new version. Either way, they own the code. The only thing you can do is to write a completely new one to suit your needs.
Okay.. thanks for the advice, have a great day 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since the plugin no longer available for sell on their website... do you have the last 2018 version I can purchase from you?