dozent_get_course_ratings( int $course_id )
Get the course rating by course ID
Description
This function return you always course rating by given course ID, if you don’t pass any course id on this function parameter, then course id will be current loop course ID using get_the_ID() function
Example usage:
dozent_get_course_ratings();
dozent_get_course_ratings( $course_id );
Note: It will always return same format if the rating exists or not.
See also
Parameters
- $course_id
-
(int) (Required) Course ID
Return
(array|bool|mixed) return course rating in detail
Source
File: includes/core-functions.php
function dozent_get_course_ratings( $course_id = 0 ) { $course_id = dozent_get_post_id( $course_id ); $rating_overview = [ 'rating_count' => 0, 'rating_avg' => '0.00', 'rating_stats' => [ 5 => [ 'count' => 0, 'percent' => 0, ], 4 => [ 'count' => 0, 'percent' => 0, ], 3 => [ 'count' => 0, 'percent' => 0, ], 2 => [ 'count' => 0, 'percent' => 0, ], 1 => [ 'one_count' => 0, 'percent' => 0, ] ] ]; $cache_overview = get_post_meta( $course_id, '_rating_overview', true ); if ( $cache_overview ) { $rating_overview = maybe_unserialize( $cache_overview ); } return apply_filters( 'dozent_get_course_ratings', $rating_overview, $course_id ); }
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |