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