$points_tab_slug, 'label'=> $points_tab_title, 'icon' => gamipress_peepso_get_option( 'points_tab_icon', 'ps-icon-star' ) ); } // Achievements tab $achievements_placement = gamipress_peepso_get_option( 'achievements_placement', '' ); if( in_array( $achievements_placement, array( 'tab', 'both' ) ) ) { $achievements_tab_title = gamipress_peepso_get_option( 'achievements_tab_title', __( 'Achievements', 'gamipress' ) ); $achievements_tab_slug = gamipress_peepso_get_option( 'achievements_tab_slug', '' ); // If empty slug generate it from the title if( empty( $achievements_tab_slug ) ) { $achievements_tab_slug = sanitize_title( $achievements_tab_title ); } $links['achievements'] = array( 'href' => $achievements_tab_slug, 'label'=> $achievements_tab_title, 'icon' => gamipress_peepso_get_option( 'achievements_tab_icon', 'ps-icon-certificate' ) ); } // Ranks tab $ranks_placement = gamipress_peepso_get_option( 'ranks_placement', '' ); if( in_array( $ranks_placement, array( 'tab', 'both' ) ) ) { $ranks_tab_title = gamipress_peepso_get_option( 'ranks_tab_title', __( 'Ranks', 'gamipress' ) ); $ranks_tab_slug = gamipress_peepso_get_option( 'ranks_tab_slug', '' ); // If empty slug generate it from the title if( empty( $ranks_tab_slug ) ) { $ranks_tab_slug = sanitize_title( $ranks_tab_title ); } $links['ranks'] = array( 'href' => $ranks_tab_slug, 'label'=> $ranks_tab_title, 'icon' => gamipress_peepso_get_option( 'ranks_tab_icon', 'ps-icon-award' ) ); } return $links; } add_filter( 'peepso_navigation_profile', 'gamipress_peepso_navigation_profile' ); /** * Common render in user profile * * @since 1.0.0 */ function gamipress_peepso_profile_segment() { $current_filter = gamipress_peepso_profile_current_filter(); $profile = PeepSoProfileShortcode::get_instance(); $user_id = PeepSoUrlSegments::get_view_id( $profile->get_view_user_id() ); ?>
'badges')); ?>
implode( ',', $points_types_to_show ), 'current_user' => 'no', 'user_id' => $user_id, 'wpms' => (bool) gamipress_get_option( 'ms_show_all_achievements', false ) ? 'yes' : 'no', ) ); } add_action( 'gamipress_peepso_profile_segment_points_content', 'gamipress_peepso_profile_points_content' ); /** * Render achievements in user profile * * @since 1.0.0 * * @param int $user_id Displayed user ID */ function gamipress_peepso_profile_achievements_content( $user_id ) { $achievements_types_to_show = gamipress_peepso_profile_get_achievements_types(); if ( empty( $achievements_types_to_show ) ) { return; } $prefix = 'profile_achievements_'; // Setup achievement atts $achievement_atts = array(); // Loop achievement shortcode fields to pass to the shortcode call foreach( GamiPress()->shortcodes['gamipress_achievement']->fields as $field_id => $field_args ) { if( $field_id === 'id' ) { continue; } if( $field_args['type'] === 'checkbox' ) { $achievement_atts[$field_id] = ( (bool) gamipress_peepso_get_option( $prefix . $field_id, false ) ? 'yes' : 'no' ); } else { $achievement_atts[$field_id] = gamipress_peepso_get_option( $prefix . $field_id, ( isset( $field_args['default'] ) ? $field_args['default'] : '' ) ); } } echo gamipress_achievements_shortcode( array_merge( array( 'type' => implode( ',', $achievements_types_to_show ), 'columns' => gamipress_peepso_get_option( $prefix . 'columns', '1' ), 'filter' => 'no', 'filter_value' => 'completed', 'search' => 'no', 'current_user' => 'no', 'user_id' => $user_id, 'wpms' => (bool) gamipress_get_option( 'ms_show_all_achievements', false ) ? 'yes' : 'no', 'limit' => gamipress_peepso_get_option( $prefix . 'limit', '10' ), 'orderby' => gamipress_peepso_get_option( $prefix . 'orderby', 'menu_order' ), 'order' => gamipress_peepso_get_option( $prefix . 'order', 'ASC' ), 'include' => '', 'exclude' => '', ), $achievement_atts ) ); } add_action( 'gamipress_peepso_profile_segment_achievements_content', 'gamipress_peepso_profile_achievements_content' ); /** * Render ranks in user profile * * @since 1.0.0 * * @param int $user_id Displayed user ID */ function gamipress_peepso_profile_ranks_content( $user_id ) { $ranks_types_to_show = gamipress_peepso_profile_get_ranks_types(); if ( empty( $ranks_types_to_show ) ) { return; } $prefix = 'profile_ranks_'; // Setup rank atts $rank_atts = array(); // Loop rank shortcode fields to pass to the shortcode call foreach( GamiPress()->shortcodes['gamipress_rank']->fields as $field_id => $field_args ) { if( $field_id === 'id' ) { continue; } if( $field_args['type'] === 'checkbox' ) { $rank_atts[$field_id] = ( (bool) gamipress_peepso_get_option( $prefix . $field_id, false ) ? 'yes' : 'no' ); } else { $rank_atts[$field_id] = gamipress_peepso_get_option( $prefix . $field_id, ( isset( $field_args['default'] ) ? $field_args['default'] : '' ) ); } } echo gamipress_ranks_shortcode( array_merge( array( 'type' => implode( ',', $ranks_types_to_show ), 'columns' => gamipress_peepso_get_option( $prefix . 'columns', '1' ), 'current_user' => 'no', 'user_id' => $user_id, 'wpms' => (bool) gamipress_get_option( 'ms_show_all_achievements', false ) ? 'yes' : 'no', 'orderby' => gamipress_peepso_get_option( $prefix . 'orderby', 'priority' ), 'order' => gamipress_peepso_get_option( $prefix . 'order', 'DESC' ), 'include' => '', 'exclude' => '', ), $rank_atts ) ); } add_action( 'gamipress_peepso_profile_segment_ranks_content', 'gamipress_peepso_profile_ranks_content' ); /** * Display user information at top * * @since 1.0.0 * * @param int $user_id Displayed user ID */ function gamipress_peepso_after_render_user_name( $user_id ) { /* ------------------------------- * Points ------------------------------- */ $points_placement = gamipress_peepso_get_option( 'points_placement', '' ); if( $points_placement === 'top' || $points_placement === 'both' ) { // Setup points types vars $points_types = gamipress_get_points_types(); $points_types_slugs = gamipress_get_points_types_slugs(); // Get points display settings $points_types_to_show = gamipress_peepso_profile_get_points_types(); $points_types_thumbnail = (bool) gamipress_peepso_get_option( 'profile_points_types_top_thumbnail', false ); $points_types_thumbnail_size = (int) gamipress_peepso_get_option( 'profile_points_types_top_thumbnail_size', 25 ); $points_types_label = (bool) gamipress_peepso_get_option( 'profile_points_types_top_label', false ); // Parse thumbnail size if( $points_types_thumbnail_size > 0 ) { $points_types_thumbnail_size = array( $points_types_thumbnail_size, $points_types_thumbnail_size ); } else { $points_types_thumbnail_size = 'gamipress-points'; } if( ! empty( $points_types_to_show ) ) : ?>
0 ) { $achievement_types_thumbnail_size = array( $achievement_types_thumbnail_size, $achievement_types_thumbnail_size ); } else { $achievement_types_thumbnail_size = 'gamipress-achievement'; } if( ! empty( $achievement_types_to_show ) ) : ?>
$user_id, 'achievement_type' => $achievement_type_to_show, 'groupby' => 'achievement_id', 'limit' => $achievement_types_limit ) ); // If user has not earned any achievements of this type, skip if( empty( $user_achievements ) ) { continue; } ?>
: ID, $achievement_types_thumbnail_size ); ?> ID, $achievement_types_thumbnail_size ); ?> ID ); ?> ID ); ?>
0 ) { $rank_types_thumbnail_size = array( $rank_types_thumbnail_size, $rank_types_thumbnail_size ); } else { $rank_types_thumbnail_size = 'gamipress-rank'; } if( ! empty( $rank_types_to_show ) ) : ?>
: ID, $rank_types_thumbnail_size ); ?> ID, $rank_types_thumbnail_size ); ?> post_title; ?> post_title; ?>