| @@ -1,0 +1,212 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Single Achievement template | |
| 4 | + * | |
| 5 | + * This template can be overridden by copying it to yourtheme/gamipress/single-achievement.php | |
| 6 | + * To override a specific achievement type just copy it as yourtheme/gamipress/single-achievement-{achievement-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 Achievement, and add an 'earned' class | |
| 16 | +if( $credential ) { | |
| 17 | + $earned = true; | |
| 18 | +} else { | |
| 19 | + $earned = gamipress_has_user_earned_achievement( get_the_ID(), get_current_user_id() ); | |
| 20 | +} | |
| 21 | + | |
| 22 | +// Setup achievement classes | |
| 23 | +$classes = array( | |
| 24 | + 'single-achievement', | |
| 25 | + 'achievement-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 achievement classes | |
| 34 | + * | |
| 35 | + * @since 1.4.0 | |
| 36 | + * | |
| 37 | + * @param array $classes Array of achievement classes | |
| 38 | + * @param integer $achievement_id The Achievement ID | |
| 39 | + * @param array $template_args Template received arguments | |
| 40 | + */ | |
| 41 | +$classes = apply_filters( 'gamipress_single_achievement_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_achievement_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 achievement | |
| 54 | + * | |
| 55 | + * @since 1.0.0 | |
| 56 | + * | |
| 57 | + * @param integer $achievement_id The Achievement ID | |
| 58 | + * @param array $template_args Template received arguments | |
| 59 | + */ | |
| 60 | + do_action( 'gamipress_before_single_achievement', get_the_ID(), $a ); ?> | |
| 61 | + | |
| 62 | + <div class="gamipress-achievement-image"> | |
| 63 | + <?php // Thumbnail | |
| 64 | + echo gamipress_get_achievement_post_thumbnail( get_the_ID() ); ?> | |
| 65 | + | |
| 66 | + <?php // Share | |
| 67 | + echo gamipress_achievement_share_markup( get_the_ID(), $a ); ?> | |
| 68 | + </div> | |
| 69 | + | |
| 70 | + <?php | |
| 71 | + /** | |
| 72 | + * After single achievement thumbnail | |
| 73 | + * | |
| 74 | + * @since 1.0.0 | |
| 75 | + * | |
| 76 | + * @param integer $achievement_id The Achievement ID | |
| 77 | + * @param array $template_args Template received arguments | |
| 78 | + */ | |
| 79 | + do_action( 'gamipress_after_single_achievement_thumbnail', get_the_ID(), $a ); ?> | |
| 80 | + | |
| 81 | + <div class="gamipress-achievement-description"> | |
| 82 | + | |
| 83 | + <?php // Points of the achievement | |
| 84 | + echo gamipress_achievement_points_markup( get_the_ID(), $a ); ?> | |
| 85 | + | |
| 86 | + <?php | |
| 87 | + /** | |
| 88 | + * After single achievement points markup | |
| 89 | + * | |
| 90 | + * @since 1.0.0 | |
| 91 | + * | |
| 92 | + * @param integer $achievement_id The Achievement ID | |
| 93 | + * @param array $template_args Template received arguments | |
| 94 | + */ | |
| 95 | + do_action( 'gamipress_after_single_achievement_points', get_the_ID(), $a ); ?> | |
| 96 | + | |
| 97 | + <?php // Achievement content | |
| 98 | + if( isset( $a['original_content'] ) ) : | |
| 99 | + echo wpautop( $a['original_content'] ); | |
| 100 | + endif; ?> | |
| 101 | + | |
| 102 | + <?php // Times earned | |
| 103 | + if ( (bool) gamipress_get_post_meta( get_the_ID(), '_gamipress_show_times_earned' ) ) : | |
| 104 | + | |
| 105 | + echo gamipress_achievement_times_earned_markup( get_the_ID(), $a ); | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * After achievement times earned | |
| 109 | + * | |
| 110 | + * @since 1.5.9 | |
| 111 | + * | |
| 112 | + * @param integer $achievement_id The Achievement ID | |
| 113 | + * @param array $template_args Template received arguments | |
| 114 | + */ | |
| 115 | + do_action( 'gamipress_after_single_achievement_times_earned', get_the_ID(), $a ); | |
| 116 | + | |
| 117 | + endif; ?> | |
| 118 | + | |
| 119 | + <?php // Global Times earned | |
| 120 | + if ( (bool) gamipress_get_post_meta( get_the_ID(), '_gamipress_show_global_times_earned' ) ) : | |
| 121 | + | |
| 122 | + echo gamipress_achievement_global_times_earned_markup( get_the_ID(), $a ); | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * After achievement times earned by all users | |
| 126 | + * | |
| 127 | + * @since 2.0.0 | |
| 128 | + * | |
| 129 | + * @param integer $achievement_id The Achievement ID | |
| 130 | + * @param array $template_args Template received arguments | |
| 131 | + */ | |
| 132 | + do_action( 'gamipress_after_single_achievement_global_times_earned', get_the_ID(), $a ); | |
| 133 | + | |
| 134 | + endif; ?> | |
| 135 | + | |
| 136 | + <?php | |
| 137 | + /** | |
| 138 | + * After single achievement content | |
| 139 | + * | |
| 140 | + * @since 1.0.0 | |
| 141 | + * | |
| 142 | + * @param integer $achievement_id The Achievement ID | |
| 143 | + * @param array $template_args Template received arguments | |
| 144 | + */ | |
| 145 | + do_action( 'gamipress_after_single_achievement_content', get_the_ID(), $a ); ?> | |
| 146 | + | |
| 147 | + <?php // Include output for our steps | |
| 148 | + echo gamipress_get_required_achievements_for_achievement_list( get_the_ID() ); ?> | |
| 149 | + | |
| 150 | + <?php | |
| 151 | + /** | |
| 152 | + * After single achievement steps | |
| 153 | + * | |
| 154 | + * @since 1.0.0 | |
| 155 | + * | |
| 156 | + * @param integer $achievement_id The Achievement ID | |
| 157 | + * @param array $template_args Template received arguments | |
| 158 | + */ | |
| 159 | + do_action( 'gamipress_after_single_achievement_steps', get_the_ID(), $a ); ?> | |
| 160 | + | |
| 161 | + <?php if( ! $credential ) : ?> | |
| 162 | + <?php // Achievement unlock with points | |
| 163 | + echo gamipress_achievement_unlock_with_points_markup( get_the_ID(), $a ); ?> | |
| 164 | + <?php endif; ?> | |
| 165 | + | |
| 166 | + <?php // Include achievement earners, if this achievement supports it | |
| 167 | + if ( (bool) gamipress_get_post_meta( get_the_ID(), '_gamipress_show_earners' ) ) : | |
| 168 | + | |
| 169 | + $maximum_earners = absint( gamipress_get_post_meta( get_the_ID(), '_gamipress_maximum_earners' ) ); | |
| 170 | + | |
| 171 | + echo gamipress_get_achievement_earners_list( get_the_ID(), array( 'limit' => $maximum_earners ) ); | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * After single achievement earners | |
| 175 | + * | |
| 176 | + * @since 1.0.0 | |
| 177 | + * | |
| 178 | + * @param integer $achievement_id The Achievement ID | |
| 179 | + * @param array $template_args Template received arguments | |
| 180 | + */ | |
| 181 | + do_action( 'gamipress_after_single_achievement_earners', get_the_ID(), $a ); | |
| 182 | + | |
| 183 | + endif; ?> | |
| 184 | + | |
| 185 | + <?php | |
| 186 | + /** | |
| 187 | + * Single achievement description bottom | |
| 188 | + * | |
| 189 | + * @since 1.4.0 | |
| 190 | + * | |
| 191 | + * @param integer $achievement_id The Achievement ID | |
| 192 | + * @param array $template_args Template received arguments | |
| 193 | + */ | |
| 194 | + do_action( 'gamipress_single_achievement_description_bottom', get_the_ID(), $a ); ?> | |
| 195 | + | |
| 196 | + </div><!-- .gamipress-achievement-description --> | |
| 197 | + | |
| 198 | + <?php | |
| 199 | + /** | |
| 200 | + * After single achievement | |
| 201 | + * | |
| 202 | + * @since 1.0.0 | |
| 203 | + * | |
| 204 | + * @param integer $achievement_id The Achievement ID | |
| 205 | + * @param array $template_args Template received arguments | |
| 206 | + */ | |
| 207 | + do_action( 'gamipress_after_single_achievement', get_the_ID(), $a ); ?> | |
| 208 | + | |
| 209 | +</div><!-- .achievement-wrap --> | |
| 210 | + | |
| 211 | +<?php // Credentials links | |
| 212 | +echo gamipress_get_credentials_links_html( get_the_ID(), $a ); ?> | |