BP_REST_Learndash_Courses_Endpoint::get_bubble_status( WP_Post $post )

Get bubble status.

Description

Parameters

$post

(Required) Object of wp_post.

Return

(string|void)

Source

File: bp-integrations/learndash/classes/class-bp-rest-learndash-courses-endpoint.php

907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
public function get_bubble_status( $post ) {
    $progress = learndash_course_progress(
        array(
            'user_id'   => get_current_user_id(),
            'course_id' => $post->ID,
            'array'     => true,
        )
    );
 
    $status         = ( 100 === $progress['percentage'] ) ? 'completed' : 'notcompleted';
    $has_access     = sfwd_lms_has_access( $post->ID, get_current_user_id() );
    $course_pricing = learndash_get_course_price( $post->ID );
 
    if ( $progress['percentage'] > 0 && 100 !== $progress['percentage'] ) {
        $status = 'progress';
    }
 
    if ( is_user_logged_in() && isset( $has_access ) && $has_access ) {
 
        if (
            ( 'open' === $course_pricing['type'] && 0 === $progress['percentage'] )
            || ( 'open' !== $course_pricing['type'] && $has_access && 0 === $progress['percentage'] )
        ) {
            return sprintf(
                // translators: placeholder: Start ribbon.
                esc_html_x( 'Start %s ', 'Start ribbon', 'buddyboss' ),
                LearnDash_Custom_Label::get_label( 'course' )
            );
        } else {
            return wp_strip_all_tags( learndash_status_bubble( $status, '', false ) );
        }
    } elseif ( 'free' === $course_pricing['type'] ) {
        return __( 'Free', 'buddyboss' );
    } elseif ( 'open' !== $course_pricing['type'] ) {
        return __( 'Not Enrolled', 'buddyboss' );
    } elseif ( 'open' === $course_pricing['type'] ) {
        return __( 'Start ', 'buddyboss' ) . LearnDash_Custom_Label::get_label( 'course' );
    }
 
    return '';
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.