Ejemplo n.º 1
0
/**
 * Output LearnDash Achievements
 *
 * @param WP_User $user
 *
 * @since 1.1.0
 */
function badgeos_gravityforms_learner_profile($user)
{
    $type = null;
    $achievement_types = badgeos_get_network_achievement_types_for_user($user->ID);
    // Eliminate step cpt from array
    if (($key = array_search('step', $achievement_types)) !== false) {
        unset($achievement_types[$key]);
        $achievement_types = array_values($achievement_types);
    }
    $profile_types = get_posts(array('post_type' => 'achievement-type', 'posts_per_page' => -1, 'meta_key' => '_badgeos_show_in_learndash_profile', 'meta_value' => '1'));
    $profile_achievement_types = array();
    foreach ($profile_types as $achievement_type) {
        $achievement_name_singular = get_post_meta($achievement_type->ID, '_badgeos_singular_name', true);
        $profile_achievement_types[] = sanitize_title(substr(strtolower($achievement_name_singular), 0, 20));
    }
    $achievement_types = array_diff($achievement_types, $profile_achievement_types);
    $atts = array('type' => implode(',', $achievement_types), 'limit' => '10', 'show_filter' => 'false', 'show_search' => 'false', 'group_id' => '0', 'user_id' => $user->ID, 'wpms' => badgeos_ms_show_all_achievements());
    echo '<h2>' . __('Achievements Earned', 'badgeos-learndash') . '</h2>';
    echo badgeos_achievements_list_shortcode($atts);
}
Ejemplo n.º 2
0
/**
 * Create array of blog ids in the network if multisite setting is on
 *
 * @since  1.2.0
 * @return array Array of blog_ids
 */
function badgeos_get_network_site_ids()
{
    global $wpdb;
    if (badgeos_ms_show_all_achievements()) {
        $blog_ids = $wpdb->get_results($wpdb->prepare("SELECT blog_id FROM " . $wpdb->base_prefix . "blogs", NULL));
        foreach ($blog_ids as $key => $value) {
            $sites[] = $value->blog_id;
        }
    } else {
        $sites[] = get_current_blog_id();
    }
    return $sites;
}