| @@ -1,0 +1,144 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * User Rank template | |
| 4 | + * | |
| 5 | + * This template can be overridden by copying it to yourtheme/gamipress/user-rank.php | |
| 6 | + * To override a specific rank type just copy it as yourtheme/gamipress/user-rank-{rank-type}.php | |
| 7 | + */ | |
| 8 | +global $gamipress_template_args; | |
| 9 | + | |
| 10 | +// Shorthand | |
| 11 | +$a = $gamipress_template_args; | |
| 12 | + | |
| 13 | +$rank_type = $a['type']; | |
| 14 | + | |
| 15 | +if( isset( $a['user_id'] ) ) { | |
| 16 | + $user_id = $a['user_id']; | |
| 17 | +} else { | |
| 18 | + $user_id = get_current_user_id(); | |
| 19 | +} | |
| 20 | + | |
| 21 | +$user_rank_id = gamipress_get_user_rank_id( $user_id, $rank_type ); | |
| 22 | +?> | |
| 23 | + | |
| 24 | +<div id="gamipress-user-ranks" class="gamipress-user-ranks gamipress-columns-<?php echo esc_attr( $a['columns'] ); ?> gamipress-columns-small-<?php echo esc_attr( $a['columns_small'] ); ?>"> | |
| 25 | + | |
| 26 | + <?php | |
| 27 | + /** | |
| 28 | + * Before render user ranks | |
| 29 | + * | |
| 30 | + * @param $rank_type string Rank type | |
| 31 | + * @param $user_id integer User ID | |
| 32 | + * @param $template_args array Template received arguments | |
| 33 | + */ | |
| 34 | + do_action( 'gamipress_before_render_user_ranks', $rank_type, $user_id, $a ); ?> | |
| 35 | + | |
| 36 | + | |
| 37 | + <?php // Previous rank | |
| 38 | + if( $a['prev_rank'] === 'yes' ) : | |
| 39 | + $prev_rank_id = gamipress_get_prev_rank_id( $user_rank_id ); ?> | |
| 40 | + | |
| 41 | + <?php if( $prev_rank_id !== $user_rank_id && $prev_rank_id !== 0 ) : ?> | |
| 42 | + | |
| 43 | + <?php | |
| 44 | + /** | |
| 45 | + * Before render previous user rank | |
| 46 | + * | |
| 47 | + * @param $rank_type string Rank type slug | |
| 48 | + * @param $rank_id integer Rank ID | |
| 49 | + * @param $user_id integer User ID | |
| 50 | + * @param $template_args array Template received arguments | |
| 51 | + */ | |
| 52 | + do_action( 'gamipress_before_render_previous_user_rank', $rank_type, $prev_rank_id, $user_id, $a ); ?> | |
| 53 | + | |
| 54 | + <?php echo gamipress_render_rank( $prev_rank_id, $a['template_args'] ) ;?> | |
| 55 | + | |
| 56 | + <?php | |
| 57 | + /** | |
| 58 | + * After render previous user rank | |
| 59 | + * | |
| 60 | + * @param $rank_type string Rank type slug | |
| 61 | + * @param $rank_id integer Rank ID | |
| 62 | + * @param $user_id integer User ID | |
| 63 | + * @param $template_args array Template received arguments | |
| 64 | + */ | |
| 65 | + do_action( 'gamipress_after_render_previous_user_rank', $rank_type, $prev_rank_id, $user_id, $a ); ?> | |
| 66 | + | |
| 67 | + <?php endif; ?> | |
| 68 | + | |
| 69 | + <?php endif; ?> | |
| 70 | + | |
| 71 | + <?php // Current rank | |
| 72 | + if( $a['current_rank'] === 'yes' ) : ?> | |
| 73 | + | |
| 74 | + <?php | |
| 75 | + /** | |
| 76 | + * Before render current user rank | |
| 77 | + * | |
| 78 | + * @param $rank_type string Rank type slug | |
| 79 | + * @param $rank_id integer Rank ID | |
| 80 | + * @param $user_id integer User ID | |
| 81 | + * @param $template_args array Template received arguments | |
| 82 | + */ | |
| 83 | + do_action( 'gamipress_before_render_current_user_rank', $rank_type, $user_rank_id, $user_id, $a ); ?> | |
| 84 | + | |
| 85 | + <?php echo gamipress_render_rank( $user_rank_id, $a['template_args'] ) ;?> | |
| 86 | + | |
| 87 | + <?php | |
| 88 | + /** | |
| 89 | + * After render current user rank | |
| 90 | + * | |
| 91 | + * @param $rank_type string Rank type slug | |
| 92 | + * @param $rank_id integer Rank ID | |
| 93 | + * @param $user_id integer User ID | |
| 94 | + * @param $template_args array Template received arguments | |
| 95 | + */ | |
| 96 | + do_action( 'gamipress_after_render_current_user_rank', $rank_type, $user_rank_id, $user_id, $a ); ?> | |
| 97 | + | |
| 98 | + <?php endif; ?> | |
| 99 | + | |
| 100 | + <?php // Next rank | |
| 101 | + if( $a['next_rank'] === 'yes' ) : | |
| 102 | + $next_rank_id = gamipress_get_next_rank_id( $user_rank_id ); ?> | |
| 103 | + | |
| 104 | + <?php if( $next_rank_id !== $user_rank_id && $next_rank_id !== 0 ) : ?> | |
| 105 | + | |
| 106 | + <?php | |
| 107 | + /** | |
| 108 | + * Before render next user rank | |
| 109 | + * | |
| 110 | + * @param $rank_type string Rank type slug | |
| 111 | + * @param $rank_id integer Rank ID | |
| 112 | + * @param $user_id integer User ID | |
| 113 | + * @param $template_args array Template received arguments | |
| 114 | + */ | |
| 115 | + do_action( 'gamipress_before_render_next_user_rank', $rank_type, $next_rank_id, $user_id, $a ); ?> | |
| 116 | + | |
| 117 | + <?php echo gamipress_render_rank( $next_rank_id, $a['template_args'] ) ;?> | |
| 118 | + | |
| 119 | + <?php | |
| 120 | + /** | |
| 121 | + * After render next user rank | |
| 122 | + * | |
| 123 | + * @param $rank_type string Rank type slug | |
| 124 | + * @param $rank_id integer Rank ID | |
| 125 | + * @param $user_id integer User ID | |
| 126 | + * @param $template_args array Template received arguments | |
| 127 | + */ | |
| 128 | + do_action( 'gamipress_after_render_next_user_rank', $rank_type, $next_rank_id, $user_id, $a ); ?> | |
| 129 | + | |
| 130 | + <?php endif; ?> | |
| 131 | + | |
| 132 | + <?php endif; ?> | |
| 133 | + | |
| 134 | + <?php | |
| 135 | + /** | |
| 136 | + * After render user ranks | |
| 137 | + * | |
| 138 | + * @param $rank_type string Rank type | |
| 139 | + * @param $user_id integer User ID | |
| 140 | + * @param $template_args array Template received arguments | |
| 141 | + */ | |
| 142 | + do_action( 'gamipress_after_render_user_ranks', $rank_type, $user_id, $a ); ?> | |
| 143 | + | |
| 144 | +</div> | |