+}
+
+/**
+ * Output the HTML for restoring the post data from DOM storage
+ *
+ * @since 3.6.0
+ * @access private
+ */
+function _local_storage_notice() {
+ ?>
+ <div id="local-storage-notice" class="hidden notice">
+ <p class="local-restore">
+ <?php _e('The backup of this post in your browser is different from the version below.'); ?>
+ <a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
+ </p>
+ <p class="undo-restore hidden">
+ <?php _e('Post restored successfully.'); ?>
+ <a class="undo-restore-backup" href="#"><?php _e('Undo.'); ?></a>
+ </p>
+ </div>
+ <?php
+}
+
+/**
+ * Output a HTML element with a star rating for a given rating.
+ *
+ * Outputs a HTML element with the star rating exposed on a 0..5 scale in
+ * half star increments (ie. 1, 1.5, 2 stars). Optionally, if specified, the
+ * number of ratings may also be displayed by passing the $number parameter.
+ *
+ * @since 3.8.0
+ * @param array $args {
+ * Optional. Array of star ratings arguments.
+ *
+ * @type int $rating The rating to display, expressed in either a 0.5 rating increment,
+ * or percentage. Default 0.
+ * @type string $type Format that the $rating is in. Valid values are 'rating' (default),
+ * or, 'percent'. Default 'rating'.
+ * @type int $number The number of ratings that makes up this rating. Default 0.
+ * }
+ */
+function wp_star_rating( $args = array() ) {
+ $defaults = array(
+ 'rating' => 0,
+ 'type' => 'rating',
+ 'number' => 0,
+ );
+ $r = wp_parse_args( $args, $defaults );
+
+ // Non-english decimal places when the $rating is coming from a string
+ $rating = str_replace( ',', '.', $r['rating'] );
+
+ // Convert Percentage to star rating, 0..5 in .5 increments
+ if ( 'percent' == $r['type'] ) {
+ $rating = round( $rating / 10, 0 ) / 2;
+ }
+
+ // Calculate the number of each type of star needed
+ $full_stars = floor( $rating );
+ $half_stars = ceil( $rating - $full_stars );
+ $empty_stars = 5 - $full_stars - $half_stars;
+
+ if ( $r['number'] ) {
+ /* translators: 1: The rating, 2: The number of ratings */
+ $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
+ $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
+ } else {
+ /* translators: 1: The rating */
+ $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
+ }
+
+ echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
+ echo '<span class="screen-reader-text">' . $title . '</span>';
+ echo str_repeat( '<div class="star star-full"></div>', $full_stars );
+ echo str_repeat( '<div class="star star-half"></div>', $half_stars );
+ echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
+ echo '</div>';
+}