| 1 |
<?php |
| 2 |
/** |
| 3 |
* Single Rank template |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/gamipress/single-rank.php |
| 6 |
* To override a specific rank type just copy it as yourtheme/gamipress/single-rank-{rank-type}.php |
| 7 |
*/ |
| 8 |
global $gamipress_template_args; |
| 9 |
|
| 10 |
// Shorthand |
| 11 |
$a = $gamipress_template_args; |
| 12 |
|
| 13 |
// Check if user has earned this rank, rank is earned by default if is the lowest priority of this type |
| 14 |
if( gamipress_is_lowest_priority_rank( get_the_ID() ) ) { |
| 15 |
$earned = true; |
| 16 |
} else { |
| 17 |
$earned = gamipress_has_user_earned_achievement( get_the_ID(), get_current_user_id() ); |
| 18 |
} |
| 19 |
|
| 20 |
// Setup rank classes |
| 21 |
$classes = array( |
| 22 |
'single-rank', |
| 23 |
'rank-wrap', |
| 24 |
( $earned ? 'user-has-earned' : '' ), |
| 25 |
'gamipress-layout-' . $a['layout'], |
| 26 |
'gamipress-align-' . $a['align'] |
| 27 |
); |
| 28 |
|
| 29 |
/** |
| 30 |
* Single rank classes |
| 31 |
* |
| 32 |
* @since 1.4.0 |
| 33 |
* |
| 34 |
* @param array $classes Array of rank classes |
| 35 |
* @param integer $rank_id The Rank ID |
| 36 |
* @param array $template_args Template received arguments |
| 37 |
*/ |
| 38 |
$classes = apply_filters( 'gamipress_single_rank_classes', $classes, get_the_ID(), $a ); ?> |
| 39 |
|
| 40 |
<?php // Check if current user has earned this rank |
| 41 |
echo gamipress_render_earned_rank_text( get_the_ID(), get_current_user_id() ); ?> |
| 42 |
|
| 43 |
<div class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"> |
| 44 |
|
| 45 |
<?php |
| 46 |
/** |
| 47 |
* Before single rank |
| 48 |
* |
| 49 |
* @since 1.0.0 |
| 50 |
* |
| 51 |
* @param integer $rank_id The Rank ID |
| 52 |
* @param array $template_args Template received arguments |
| 53 |
*/ |
| 54 |
do_action( 'gamipress_before_single_rank', get_the_ID(), $a ); ?> |
| 55 |
|
| 56 |
<div class="gamipress-rank-image"> |
| 57 |
<?php // Thumbnail |
| 58 |
echo gamipress_get_rank_post_thumbnail( get_the_ID() ); ?> |
| 59 |
|
| 60 |
<?php // Share |
| 61 |
echo gamipress_rank_share_markup( get_the_ID(), $a ); ?> |
| 62 |
</div> |
| 63 |
|
| 64 |
<?php |
| 65 |
/** |
| 66 |
* After single rank thumbnail |
| 67 |
* |
| 68 |
* @since 1.0.0 |
| 69 |
* |
| 70 |
* @param integer $rank_id The Rank ID |
| 71 |
* @param array $template_args Template received arguments |
| 72 |
*/ |
| 73 |
do_action( 'gamipress_after_single_rank_thumbnail', get_the_ID(), $a ); ?> |
| 74 |
|
| 75 |
<div class="gamipress-rank-description"> |
| 76 |
|
| 77 |
<?php // Rank content |
| 78 |
if( isset( $a['original_content'] ) ) : |
| 79 |
echo wpautop( $a['original_content'] ); |
| 80 |
endif; ?> |
| 81 |
|
| 82 |
<?php |
| 83 |
/** |
| 84 |
* After single rank content |
| 85 |
* |
| 86 |
* @since 1.0.0 |
| 87 |
* |
| 88 |
* @param integer $rank_id The Rank ID |
| 89 |
* @param array $template_args Template received arguments |
| 90 |
*/ |
| 91 |
do_action( 'gamipress_after_single_rank_content', get_the_ID(), $a ); ?> |
| 92 |
|
| 93 |
<?php // Include output for our requirements |
| 94 |
echo gamipress_get_rank_requirements_list( get_the_ID() ); ?> |
| 95 |
|
| 96 |
<?php |
| 97 |
/** |
| 98 |
* After single rank requirements |
| 99 |
* |
| 100 |
* @since 1.0.0 |
| 101 |
* |
| 102 |
* @param integer $rank_id The Rank ID |
| 103 |
* @param array $template_args Template received arguments |
| 104 |
*/ |
| 105 |
do_action( 'gamipress_after_single_rank_requirements', get_the_ID(), $a ); ?> |
| 106 |
|
| 107 |
<?php // Rank unlock with points |
| 108 |
echo gamipress_rank_unlock_with_points_markup( get_the_ID(), $a ); ?> |
| 109 |
|
| 110 |
<?php // Include rank earners, if this rank supports it |
| 111 |
if ( $show_earners = gamipress_get_post_meta( get_the_ID(), '_gamipress_show_earners' ) ) { |
| 112 |
|
| 113 |
$maximum_earners = absint( gamipress_get_post_meta( get_the_ID(), '_gamipress_maximum_earners' ) ); |
| 114 |
|
| 115 |
echo gamipress_get_rank_earners_list( get_the_ID(), array( 'limit' => $maximum_earners ) ); |
| 116 |
|
| 117 |
/** |
| 118 |
* After single rank earners |
| 119 |
* |
| 120 |
* @since 1.0.0 |
| 121 |
* |
| 122 |
* @param integer $rank_id The Rank ID |
| 123 |
* @param array $template_args Template received arguments |
| 124 |
*/ |
| 125 |
do_action( 'gamipress_after_single_rank_earners', get_the_ID(), $a ); |
| 126 |
|
| 127 |
} ?> |
| 128 |
|
| 129 |
<?php |
| 130 |
/** |
| 131 |
* Single rank description bottom |
| 132 |
* |
| 133 |
* @since 1.4.0 |
| 134 |
* |
| 135 |
* @param integer $rank_id The Rank ID |
| 136 |
* @param array $template_args Template received arguments |
| 137 |
*/ |
| 138 |
do_action( 'gamipress_single_rank_description_bottom', get_the_ID(), $a ); ?> |
| 139 |
|
| 140 |
</div><!-- .gamipress-rank-description --> |
| 141 |
|
| 142 |
<?php |
| 143 |
/** |
| 144 |
* After single rank |
| 145 |
* |
| 146 |
* @since 1.0.0 |
| 147 |
* |
| 148 |
* @param integer $rank_id The Rank ID |
| 149 |
* @param array $template_args Template received arguments |
| 150 |
*/ |
| 151 |
do_action( 'gamipress_after_single_rank', get_the_ID(), $a ); ?> |
| 152 |
|
| 153 |
</div><!-- .rank-wrap --> |