PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.6
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.6
8.0.6 8.0.5 8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 All 48 releases
← All changes | integrations/ultimate-member/includes/ultimate-member-profile.php +650 -0 7.9.2 → 8.0.6 View file →
@@ -1,0 +1,650 @@
1 +<?php
2 +/**
3 + * User Profile
4 + *
5 + * @package GamiPress\Ultimate_Member\User_Profile
6 + * @since 1.0.0
7 + */
8 +// Exit if accessed directly
9 +if( !defined( 'ABSPATH' ) ) exit;
10 +
11 +/**
12 + * Add new user profile tabs
13 + *
14 + * @since 1.0.0
15 + *
16 + * @param array $tabs Array of current profile tabs
17 + *
18 + * @return array
19 + */
20 +function gamipress_ultimate_member_user_profile_tabs( $tabs ) {
21 +
22 + // Points tab
23 + $points_placement = gamipress_ultimate_member_get_option( 'points_placement', '' );
24 +
25 + if( in_array( $points_placement, array( 'tab', 'both' ) ) ) {
26 +
27 + $points_tab_title = gamipress_ultimate_member_get_option( 'points_tab_title', __( 'Achievements', 'gamipress' ) );
28 + $points_tab_slug = gamipress_ultimate_member_get_option( 'points_tab_slug', '' );
29 +
30 + // If empty slug generate it from the title
31 + if( empty( $points_tab_slug ) )
32 + $points_tab_slug = sanitize_title( $points_tab_title );
33 +
34 + $tabs[$points_tab_slug] = array(
35 + 'name' => $points_tab_title,
36 + 'icon' => gamipress_ultimate_member_get_option( 'points_tab_icon', 'um-faicon-star' ),
37 + 'custom' => true
38 + );
39 +
40 + }
41 +
42 + // Achievements tab
43 + $achievements_placement = gamipress_ultimate_member_get_option( 'achievements_placement', '' );
44 +
45 + if( in_array( $achievements_placement, array( 'tab', 'both' ) ) ) {
46 +
47 + $achievements_tab_title = gamipress_ultimate_member_get_option( 'achievements_tab_title', __( 'Achievements', 'gamipress' ) );
48 + $achievements_tab_slug = gamipress_ultimate_member_get_option( 'achievements_tab_slug', '' );
49 +
50 + // If empty slug generate it from the title
51 + if( empty( $achievements_tab_slug ) )
52 + $achievements_tab_slug = sanitize_title( $achievements_tab_title );
53 +
54 + $tabs[$achievements_tab_slug] = array(
55 + 'name' => $achievements_tab_title,
56 + 'icon' => gamipress_ultimate_member_get_option( 'achievements_tab_icon', 'um-faicon-flag' ),
57 + 'custom' => true
58 + );
59 +
60 + }
61 +
62 + // Ranks tab
63 + $ranks_placement = gamipress_ultimate_member_get_option( 'ranks_placement', '' );
64 +
65 + if( in_array( $ranks_placement, array( 'tab', 'both' ) ) ) {
66 +
67 + $ranks_tab_title = gamipress_ultimate_member_get_option( 'ranks_tab_title', __( 'Ranks', 'gamipress' ) );
68 + $ranks_tab_slug = gamipress_ultimate_member_get_option( 'ranks_tab_slug', '' );
69 +
70 + // If empty slug generate it from the title
71 + if( empty( $ranks_tab_slug ) )
72 + $ranks_tab_slug = sanitize_title( $ranks_tab_title );
73 +
74 + $tabs[$ranks_tab_slug] = array(
75 + 'name' => $ranks_tab_title,
76 + 'icon' => gamipress_ultimate_member_get_option( 'ranks_tab_icon', 'um-faicon-certificate' ),
77 + 'custom' => true
78 + );
79 +
80 + }
81 +
82 + return $tabs;
83 +
84 +}
85 +add_filter( 'um_profile_tabs', 'gamipress_ultimate_member_user_profile_tabs' );
86 +add_filter( 'um_user_profile_tabs', 'gamipress_ultimate_member_user_profile_tabs' );
87 +
88 +/**
89 + * Load the tabs hooks based on tab slug setup through settings
90 + *
91 + * @since 1.0.0
92 + */
93 +function gamipress_ultimate_member_hook_user_profile_tabs_content() {
94 +
95 + // Points tab
96 + $points_placement = gamipress_ultimate_member_get_option( 'points_placement', '' );
97 +
98 + if( in_array( $points_placement, array( 'tab', 'both' ) ) ) {
99 +
100 + $points_tab_title = gamipress_ultimate_member_get_option( 'points_tab_title', __( 'Achievements', 'gamipress' ) );
101 + $points_tab_slug = gamipress_ultimate_member_get_option( 'points_tab_slug', '' );
102 +
103 + // If empty slug generate it from the title
104 + if( empty( $points_tab_slug ) )
105 + $points_tab_slug = sanitize_title( $points_tab_title );
106 +
107 + add_action( "um_profile_content_{$points_tab_slug}_default", 'gamipress_ultimate_member_points_profile_content' );
108 +
109 + }
110 +
111 + // Achievements tab
112 + $achievements_placement = gamipress_ultimate_member_get_option( 'achievements_placement', '' );
113 +
114 + if( in_array( $achievements_placement, array( 'tab', 'both' ) ) ) {
115 +
116 + $achievements_tab_title = gamipress_ultimate_member_get_option( 'achievements_tab_title', __( 'Achievements', 'gamipress' ) );
117 + $achievements_tab_slug = gamipress_ultimate_member_get_option( 'achievements_tab_slug', '' );
118 +
119 + // If empty slug generate it from the title
120 + if( empty( $achievements_tab_slug ) )
121 + $achievements_tab_slug = sanitize_title( $achievements_tab_title );
122 +
123 + add_action( "um_profile_content_{$achievements_tab_slug}_default", 'gamipress_ultimate_member_achievements_profile_content' );
124 +
125 + }
126 +
127 + // Ranks tab
128 + $ranks_placement = gamipress_ultimate_member_get_option( 'ranks_placement', '' );
129 +
130 + if( in_array( $ranks_placement, array( 'tab', 'both' ) ) ) {
131 +
132 + $ranks_tab_title = gamipress_ultimate_member_get_option( 'ranks_tab_title', __( 'Ranks', 'gamipress' ) );
133 + $ranks_tab_slug = gamipress_ultimate_member_get_option( 'ranks_tab_slug', '' );
134 +
135 + // If empty slug generate it from the title
136 + if( empty( $ranks_tab_slug ) )
137 + $ranks_tab_slug = sanitize_title( $ranks_tab_title );
138 +
139 + add_action( "um_profile_content_{$ranks_tab_slug}_default", 'gamipress_ultimate_member_ranks_profile_content' );
140 +
141 + }
142 +
143 +}
144 +add_action( 'init', 'gamipress_ultimate_member_hook_user_profile_tabs_content' );
145 +
146 +/**
147 + * Render points in user profile
148 + *
149 + * @since 1.0.0
150 + *
151 + * @param array $args
152 + */
153 +function gamipress_ultimate_member_points_profile_content( $args ) {
154 +
155 + $user_id = um_profile_id();
156 +
157 + $points_types_to_show = gamipress_ultimate_member_profile_get_points_types();
158 +
159 + if ( empty( $points_types_to_show ) ) {
160 + return;
161 + }
162 +
163 + echo gamipress_points_shortcode( array(
164 + 'type' => implode( ',', $points_types_to_show ),
165 + 'current_user' => 'no',
166 + 'user_id' => $user_id,
167 + 'wpms' => (bool) gamipress_get_option( 'ms_show_all_achievements', false ) ? 'yes' : 'no',
168 + ) );
169 +
170 +}
171 +
172 +/**
173 + * Render achievements in user profile
174 + *
175 + * @since 1.0.0
176 + *
177 + * @param array $args
178 + */
179 +function gamipress_ultimate_member_achievements_profile_content( $args ) {
180 +
181 + $user_id = um_profile_id();
182 +
183 + $achievements_types_to_show = gamipress_ultimate_member_profile_get_achievements_types();
184 +
185 + if ( empty( $achievements_types_to_show ) ) return;
186 +
187 + $prefix = 'profile_achievements_';
188 +
189 + // Setup achievement atts
190 + $achievement_atts = array();
191 +
192 + // Loop achievement shortcode fields to pass to the shortcode call
193 + foreach( GamiPress()->shortcodes['gamipress_achievement']->fields as $field_id => $field_args ) {
194 +
195 + if( $field_id === 'id' ) continue;
196 +
197 + if( $field_args['type'] === 'checkbox' ) {
198 + $achievement_atts[$field_id] = ( (bool) gamipress_ultimate_member_get_option( $prefix . $field_id, false ) ? 'yes' : 'no' );
199 + } else {
200 + $achievement_atts[$field_id] = gamipress_ultimate_member_get_option( $prefix . $field_id, ( isset( $field_args['default'] ) ? $field_args['default'] : '' ) );
201 + }
202 +
203 + }
204 +
205 + echo gamipress_achievements_shortcode( array_merge( array(
206 + 'type' => implode( ',', $achievements_types_to_show ),
207 + 'columns' => gamipress_ultimate_member_get_option( $prefix . 'columns', '1' ),
208 + 'filter' => 'no',
209 + 'filter_value' => 'completed',
210 + 'search' => 'no',
211 + 'current_user' => 'no',
212 + 'user_id' => $user_id,
213 + 'wpms' => (bool) gamipress_get_option( 'ms_show_all_achievements', false ) ? 'yes' : 'no',
214 + 'limit' => gamipress_ultimate_member_get_option( $prefix . 'limit', '10' ),
215 + 'orderby' => gamipress_ultimate_member_get_option( $prefix . 'orderby', 'menu_order' ),
216 + 'order' => gamipress_ultimate_member_get_option( $prefix . 'order', 'ASC' ),
217 + 'include' => '',
218 + 'exclude' => '',
219 + ), $achievement_atts ) );
220 +
221 +}
222 +
223 +/**
224 + * Render ranks in user profile
225 + *
226 + * @since 1.0.0
227 + *
228 + * @param array $args
229 + */
230 +function gamipress_ultimate_member_ranks_profile_content( $args ) {
231 +
232 + $user_id = um_profile_id();
233 +
234 + $ranks_types_to_show = gamipress_ultimate_member_profile_get_ranks_types();
235 +
236 + if ( empty( $ranks_types_to_show ) ) return;
237 +
238 + $prefix = 'profile_ranks_';
239 +
240 + // Setup rank atts
241 + $rank_atts = array();
242 +
243 + // Loop rank shortcode fields to pass to the shortcode call
244 + foreach( GamiPress()->shortcodes['gamipress_rank']->fields as $field_id => $field_args ) {
245 +
246 + if( $field_id === 'id' ) continue;
247 +
248 + if( $field_args['type'] === 'checkbox' ) {
249 + $rank_atts[$field_id] = ( (bool) gamipress_ultimate_member_get_option( $prefix . $field_id, false ) ? 'yes' : 'no' );
250 + } else {
251 + $rank_atts[$field_id] = gamipress_ultimate_member_get_option( $prefix . $field_id, ( isset( $field_args['default'] ) ? $field_args['default'] : '' ) );
252 + }
253 +
254 + }
255 +
256 + echo gamipress_ranks_shortcode( array_merge( array(
257 + 'type' => implode( ',', $ranks_types_to_show ),
258 + 'columns' => gamipress_ultimate_member_get_option( $prefix . 'columns', '1' ),
259 + 'current_user' => 'no',
260 + 'user_id' => $user_id,
261 + 'wpms' => (bool) gamipress_get_option( 'ms_show_all_achievements', false ) ? 'yes' : 'no',
262 + 'orderby' => gamipress_ultimate_member_get_option( $prefix . 'orderby', 'priority' ),
263 + 'order' => gamipress_ultimate_member_get_option( $prefix . 'order', 'DESC' ),
264 + 'include' => '',
265 + 'exclude' => '',
266 + ), $rank_atts ) );
267 +
268 +}
269 +
270 +/**
271 + * Display user information at top
272 + *
273 + * @since 1.0.0
274 + *
275 + * @param int $user_id Displayed user ID
276 + * @param array $args
277 + */
278 +function gamipress_ultimate_member_after_header_meta( $user_id, $args ) {
279 +
280 + /* -------------------------------
281 + * Points
282 + ------------------------------- */
283 +
284 + $points_placement = gamipress_ultimate_member_get_option( 'points_placement', '' );
285 +
286 + if( $points_placement === 'top' || $points_placement === 'both' ) {
287 +
288 + // Setup points types vars
289 + $points_types = gamipress_get_points_types();
290 + $points_types_slugs = gamipress_get_points_types_slugs();
291 +
292 + // Get points display settings
293 + $points_types_to_show = gamipress_ultimate_member_profile_get_points_types();
294 + $points_types_thumbnail = (bool) gamipress_ultimate_member_get_option( 'profile_points_types_top_thumbnail', false );
295 + $points_types_thumbnail_size = (int) gamipress_ultimate_member_get_option( 'profile_points_types_top_thumbnail_size', 25 );
296 + $points_types_label = (bool) gamipress_ultimate_member_get_option( 'profile_points_types_top_label', false );
297 +
298 + // Parse thumbnail size
299 + if( $points_types_thumbnail_size > 0 ) {
300 + $points_types_thumbnail_size = array( $points_types_thumbnail_size, $points_types_thumbnail_size );
301 + } else {
302 + $points_types_thumbnail_size = 'gamipress-points';
303 + }
304 +
305 + if( ! empty( $points_types_to_show ) ) : ?>
306 +
307 + <div class="gamipress-ultimate-member-points">
308 +
309 + <?php foreach( $points_types_to_show as $points_type_to_show ) :
310 +
311 + // If points type not registered, skip
312 + if( ! in_array( $points_type_to_show, $points_types_slugs ) )
313 + continue;
314 +
315 + $points_type = $points_types[$points_type_to_show];
316 + $user_points = gamipress_get_user_points( $user_id, $points_type_to_show ); ?>
317 +
318 + <div class="gamipress-ultimate-member-points-type gamipress-ultimate-member-<?php echo $points_type_to_show; ?>">
319 +
320 + <?php // The points thumbnail ?>
321 + <?php if( $points_types_thumbnail ) : ?>
322 +
323 + <span class="gamipress-ultimate-member-points-thumbnail gamipress-ultimate-member-<?php echo $points_type_to_show; ?>-thumbnail">
324 + <?php echo gamipress_get_points_type_thumbnail( $points_type_to_show, $points_types_thumbnail_size ); ?>
325 + </span>
326 +
327 + <?php endif; ?>
328 +
329 + <?php // The user points amount ?>
330 + <span class="gamipress-ultimate-member-user-points gamipress-ultimate-member-user-<?php echo $points_type_to_show; ?>">
331 + <?php echo $user_points; ?>
332 + </span>
333 +
334 + <?php // The points label ?>
335 + <?php if( $points_types_label ) : ?>
336 +
337 + <span class="gamipress-ultimate-member-points-label gamipress-ultimate-member-<?php echo $points_type_to_show; ?>-label">
338 + <?php echo _n( $points_type['singular_name'], $points_type['plural_name'], $user_points ); ?>
339 + </span>
340 +
341 + <?php endif; ?>
342 +
343 + </div>
344 +
345 + <?php endforeach; ?>
346 + </div>
347 + <?php endif;
348 +
349 + }
350 +
351 + /* -------------------------------
352 + * Achievements
353 + ------------------------------- */
354 +
355 + $achievements_placement = gamipress_ultimate_member_get_option( 'achievements_placement', '' );
356 +
357 + if( $achievements_placement === 'top' || $achievements_placement === 'both' ) {
358 +
359 + // Setup achievement types vars
360 + $achievement_types = gamipress_get_achievement_types();
361 + $achievement_types_slugs = gamipress_get_achievement_types_slugs();
362 +
363 + // Get achievements display settings
364 + $achievement_types_to_show = gamipress_ultimate_member_profile_get_achievements_types();
365 + $achievement_types_thumbnail = (bool) gamipress_ultimate_member_get_option( 'profile_achievements_top_thumbnail', false );
366 + $achievement_types_thumbnail_size = (int) gamipress_ultimate_member_get_option( 'profile_achievements_top_thumbnail_size', 25 );
367 + $achievement_types_title = (bool) gamipress_ultimate_member_get_option( 'profile_achievements_top_title', false );
368 + $achievement_types_link = (bool) gamipress_ultimate_member_get_option( 'profile_achievements_top_link', false );
369 + $achievement_types_label = (bool) gamipress_ultimate_member_get_option( 'profile_achievements_top_label', false );
370 + $achievement_types_limit = (int) gamipress_ultimate_member_get_option( 'profile_achievements_top_limit', 10 );
371 +
372 + // Parse thumbnail size
373 + if( $achievement_types_thumbnail_size > 0 ) {
374 + $achievement_types_thumbnail_size = array( $achievement_types_thumbnail_size, $achievement_types_thumbnail_size );
375 + } else {
376 + $achievement_types_thumbnail_size = 'gamipress-achievement';
377 + }
378 +
379 + if( ! empty( $achievement_types_to_show ) ) : ?>
380 +
381 + <div class="gamipress-ultimate-member-achievements">
382 +
383 + <?php foreach( $achievement_types_to_show as $achievement_type_to_show ) :
384 +
385 + // If achievements type not registered, skip
386 + if( ! in_array( $achievement_type_to_show, $achievement_types_slugs ) )
387 + continue;
388 +
389 + $achievement_type = $achievement_types[$achievement_type_to_show];
390 + $user_achievements = gamipress_get_user_achievements( array(
391 + 'user_id' => $user_id,
392 + 'achievement_type' => $achievement_type_to_show,
393 + 'groupby' => 'achievement_id',
394 + 'limit' => $achievement_types_limit,
395 + ) );
396 +
397 + // If user has not earned any achievements of this type, skip
398 + if( empty( $user_achievements ) ) {
399 + continue;
400 + } ?>
401 +
402 + <div class="gamipress-ultimate-member-achievement gamipress-ultimate-member-<?php echo $achievement_type_to_show; ?>">
403 +
404 + <?php // The achievement type label ?>
405 + <?php if( $achievement_types_label ) : ?>
406 + <span class="gamipress-ultimate-member-achievement-type-label gamipress-ultimate-member-<?php echo $achievement_type_to_show; ?>-label">
407 + <?php echo $achievement_type['plural_name']; ?>:
408 + </span>
409 + <?php endif; ?>
410 +
411 + <?php // Lets to get just the achievement thumbnail and title
412 + foreach( $user_achievements as $user_achievement ) : ?>
413 +
414 + <?php // The achievement thumbnail ?>
415 + <?php if( $achievement_types_thumbnail ) : ?>
416 +
417 + <?php // The achievement link ?>
418 + <?php if( $achievement_types_link ) : ?>
419 +
420 + <a href="<?php echo get_permalink( $user_achievement->ID ); ?>" title="<?php echo get_the_title( $user_achievement->ID ); ?>" class="gamipress-ultimate-member-achievement-thumbnail gamipress-ultimate-member-<?php echo $achievement_type_to_show; ?>-thumbnail">
421 + <?php echo gamipress_get_achievement_post_thumbnail( $user_achievement->ID, $achievement_types_thumbnail_size ); ?>
422 + </a>
423 +
424 + <?php else : ?>
425 +
426 + <span title="<?php echo get_the_title( $user_achievement->ID ); ?>" class="gamipress-ultimate-member-achievement-thumbnail gamipress-ultimate-member-<?php echo $achievement_type_to_show; ?>-thumbnail">
427 + <?php echo gamipress_get_achievement_post_thumbnail( $user_achievement->ID, $achievement_types_thumbnail_size ); ?>
428 + </span>
429 +
430 + <?php endif; ?>
431 +
432 + <?php endif; ?>
433 +
434 + <?php // The achievement title ?>
435 + <?php if( $achievement_types_title ) : ?>
436 +
437 + <?php // The achievement link ?>
438 + <?php if( $achievement_types_link ) : ?>
439 +
440 + <a href="<?php echo get_permalink( $user_achievement->ID ); ?>" title="<?php echo get_the_title( $user_achievement->ID ); ?>" class="gamipress-ultimate-member-achievement-title gamipress-ultimate-member-<?php echo $achievement_type_to_show; ?>-title">
441 + <?php echo get_the_title( $user_achievement->ID ); ?>
442 + </a>
443 +
444 + <?php else : ?>
445 +
446 + <span class="gamipress-ultimate-member-achievement-title gamipress-ultimate-member-<?php echo $achievement_type_to_show; ?>-title">
447 + <?php echo get_the_title( $user_achievement->ID ); ?>
448 + </span>
449 +
450 + <?php endif; ?>
451 +
452 + <?php endif; ?>
453 +
454 + <?php endforeach; ?>
455 +
456 + </div>
457 +
458 + <?php endforeach; ?>
459 +
460 + </div>
461 +
462 + <?php endif;
463 +
464 + }
465 +
466 + /* -------------------------------
467 + * Ranks
468 + ------------------------------- */
469 +
470 + $ranks_placement = gamipress_ultimate_member_get_option( 'ranks_placement', '' );
471 +
472 + if( $ranks_placement === 'top' || $ranks_placement === 'both' ) {
473 +
474 + // Setup rank types vars
475 + $rank_types = gamipress_get_rank_types();
476 + $rank_types_slugs = gamipress_get_rank_types_slugs();
477 +
478 + // Get ranks display settings
479 + $rank_types_to_show = gamipress_ultimate_member_profile_get_ranks_types();
480 + $rank_types_thumbnail = (bool) gamipress_ultimate_member_get_option( 'profile_ranks_top_thumbnail', false );
481 + $rank_types_thumbnail_size = (int) gamipress_ultimate_member_get_option( 'profile_ranks_top_thumbnail_size', 25 );
482 + $rank_types_title = (bool) gamipress_ultimate_member_get_option( 'profile_ranks_top_title', false );
483 + $rank_types_link = (bool) gamipress_ultimate_member_get_option( 'profile_ranks_top_link', false );
484 + $rank_types_label = (bool) gamipress_ultimate_member_get_option( 'profile_ranks_top_label', false );
485 +
486 + // Parse thumbnail size
487 + if( $rank_types_thumbnail_size > 0 ) {
488 + $rank_types_thumbnail_size = array( $rank_types_thumbnail_size, $rank_types_thumbnail_size );
489 + } else {
490 + $rank_types_thumbnail_size = 'gamipress-rank';
491 + }
492 +
493 + if( ! empty( $rank_types_to_show ) ) : ?>
494 +
495 + <div class="gamipress-ultimate-member-ranks">
496 +
497 + <?php foreach( $rank_types_to_show as $rank_type_to_show ) :
498 +
499 + // If rank type not registered, skip
500 + if( ! in_array( $rank_type_to_show, $rank_types_slugs ) )
501 + continue;
502 +
503 + $rank_type = $rank_types[$rank_type_to_show];
504 + $user_rank = gamipress_get_user_rank( $user_id, $rank_type_to_show ); ?>
505 +
506 + <div class="gamipress-ultimate-member-rank gamipress-ultimate-member-<?php echo $rank_type_to_show; ?>">
507 +
508 + <?php // The rank type label ?>
509 + <?php if( $rank_types_label ) : ?>
510 + <span class="gamipress-ultimate-member-rank-label gamipress-ultimate-member-<?php echo $rank_type_to_show; ?>-label">
511 + <?php echo $rank_type['singular_name']; ?>:
512 + </span>
513 + <?php endif; ?>
514 +
515 + <?php // The rank thumbnail ?>
516 + <?php if( $rank_types_thumbnail ) : ?>
517 +
518 + <?php // The rank link ?>
519 + <?php if( $rank_types_link ) : ?>
520 +
521 + <a href="<?php echo get_permalink( $user_rank->ID ); ?>" title="<?php echo $user_rank->post_title; ?>" class="gamipress-ultimate-member-rank-thumbnail gamipress-ultimate-member-<?php echo $rank_type_to_show; ?>-thumbnail">
522 + <?php echo gamipress_get_rank_post_thumbnail( $user_rank->ID, $rank_types_thumbnail_size ); ?>
523 + </a>
524 +
525 + <?php else : ?>
526 +
527 + <span title="<?php echo $user_rank->post_title; ?>" class="gamipress-ultimate-member-rank-thumbnail gamipress-ultimate-member-<?php echo $rank_type_to_show; ?>-thumbnail">
528 + <?php echo gamipress_get_rank_post_thumbnail( $user_rank->ID, $rank_types_thumbnail_size ); ?>
529 + </span>
530 +
531 + <?php endif; ?>
532 +
533 + <?php endif; ?>
534 +
535 + <?php // The rank title ?>
536 + <?php if( $rank_types_title ) : ?>
537 +
538 + <?php // The rank link ?>
539 + <?php if( $rank_types_link ) : ?>
540 +
541 + <a href="<?php echo get_permalink( $user_rank->ID ); ?>" title="<?php echo $user_rank->post_title; ?>" class="gamipress-ultimate-member-rank-title gamipress-ultimate-member-<?php echo $rank_type_to_show; ?>-title">
542 + <?php echo $user_rank->post_title; ?>
543 + </a>
544 +
545 + <?php else : ?>
546 +
547 + <span class="gamipress-ultimate-member-rank-title gamipress-ultimate-member-<?php echo $rank_type_to_show; ?>-title">
548 + <?php echo $user_rank->post_title; ?>
549 + </span>
550 +
551 + <?php endif; ?>
552 +
553 + <?php endif; ?>
554 +
555 + </div>
556 +
557 + <?php endforeach; ?>
558 + </div>
559 + <?php endif;
560 +
561 + }
562 +
563 +}
564 +add_action( 'um_after_header_meta', 'gamipress_ultimate_member_after_header_meta', 10, 2 );
565 +
566 +/**
567 + * Helper function to retrieve the points types configured at profile screen
568 + *
569 + * @since 1.0.0
570 + *
571 + * @return array
572 + */
573 +function gamipress_ultimate_member_profile_get_points_types() {
574 +
575 + $points_types = array();
576 +
577 + $points_types_slugs = gamipress_get_points_types_slugs();
578 +
579 + $points_types_to_show = gamipress_ultimate_member_get_option( 'profile_points_types', array() );
580 +
581 + foreach( $points_types_to_show as $points_type_slug ) {
582 +
583 + if( ! in_array( $points_type_slug, $points_types_slugs ) ) {
584 + continue;
585 + }
586 +
587 + $points_types[] = $points_type_slug;
588 + }
589 +
590 + return $points_types;
591 +
592 +}
593 +
594 +/**
595 + * Helper function to retrieve the achievement types configured at profile screen
596 + *
597 + * @since 1.0.0
598 + *
599 + * @return array
600 + */
601 +function gamipress_ultimate_member_profile_get_achievements_types() {
602 +
603 + $achievements_types = array();
604 +
605 + $achievement_types_slugs = gamipress_get_achievement_types_slugs();
606 +
607 + $achievements_types_to_show = gamipress_ultimate_member_get_option( 'profile_achievements_types', array() );
608 +
609 + foreach( $achievements_types_to_show as $achievement_type_slug ) {
610 +
611 + // Skip if not registered
612 + if( ! in_array( $achievement_type_slug, $achievement_types_slugs ) ) {
613 + continue;
614 + }
615 +
616 + $achievements_types[] = $achievement_type_slug;
617 + }
618 +
619 + return $achievements_types;
620 +
621 +}
622 +
623 +/**
624 + * Helper function to retrieve the rank types configured at profile screen
625 + *
626 + * @since 1.0.0
627 + *
628 + * @return array
629 + */
630 +function gamipress_ultimate_member_profile_get_ranks_types() {
631 +
632 + $ranks_types = array();
633 +
634 + $rank_types_slugs = gamipress_get_rank_types_slugs();
635 +
636 + $ranks_types_to_show = gamipress_ultimate_member_get_option( 'profile_ranks_types', array() );
637 +
638 + foreach( $ranks_types_to_show as $rank_type_slug ) {
639 +
640 + // Skip if not registered
641 + if( ! in_array( $rank_type_slug, $rank_types_slugs ) ) {
642 + continue;
643 + }
644 +
645 + $ranks_types[] = $rank_type_slug;
646 + }
647 +
648 + return $ranks_types;
649 +
650 +}