wp_star_rating() – Adding a 5 star rating system to theme

Instead of redefining wp_star_rating() for the front end, you should be able to just use the built-in function.

From the Codex page for wp_star_rating():

In order to use this function on the front end, your template must include the wp-admin/includes/template.php file and enqueue the appropriate dashicons CSS font information.

(emphasis mine)

A code sample is also provided in the Notes section of the Codex page.

Edit

If you’re getting Fatal error: Call to undefined function wp_star_rating() messages, that means that you have not included wp-admin/includes/template.php in your file. Try adding this snippet somewhere prior to your call to wp_star_rating():

require_once( ABSPATH . 'wp-admin/includes/template.php' );

That should allow you to use wp_star_rating() in your front-end code.