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
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.