dozent_star_rating_generator( float $current_rating = 0.0,  $echo = true )


Parameters

$current_rating

(float) (Optional)

Default value: 0.0


Return

(string) Generate star rating


Source

File: includes/core-functions.php

	function dozent_star_rating_generator( $current_rating = 0.00, $echo = true ) {
		$output = '<div class="generated-star-rating-wrap">';

		for ( $i = 1; $i <= 5; $i ++ ) {
			$intRating = (int) $current_rating;

			if ( $intRating >= $i ) {
				$output .= '<i class="dicon-star-full" data-rating-value="' . $i . '"></i>';
			} else {
				$fraction = 1 - ( $i - $current_rating );
				if ( $fraction > 0.69 ) {
					$output .= '<i class="dicon-star-full" data-rating-value="' . $i . '"></i>';
				} elseif ( $fraction > 0.39 ) {
					$output .= '<i class="dicon-star-half" data-rating-value="' . $i . '"></i>';
				} else {
					$output .= '<i class="dicon-star-empty" data-rating-value="' . $i . '"></i>';
				}
			}
		}

		$output .= "</div>";

		if ( $echo ) {
			echo $output;
		}

		return $output;
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.