WC_Admin_Addons::get_star_class()
Determine which class should be used for a rating star:
- golden
- half-filled (50/50 golden and gray)
- gray
Consider ratings from 3.0 to 4.0 as an example
3.0 will produce 3 stars
3.1 to 3.5 will produce 3 stars and a half star
3.6 to 4.0 will product 4 stars
Метод класса: WC_Admin_Addons{}
Хуков нет.
Возвращает
Строку
. CSS class to use.
Использование
$result = WC_Admin_Addons::get_star_class( $rating, $index );
- $rating(float) (обязательный)
- Rating of a product.
- $index(int) (обязательный)
- Index of a star in a row.
Код WC_Admin_Addons::get_star_class() WC Admin Addons::get star class WC 8.7.0
public static function get_star_class( $rating, $index ) { if ( $rating >= $index ) { // Rating more that current star to show. return 'fill'; } elseif ( abs( $index - 1 - floor( $rating ) ) < 0.0000001 && 0 < ( $rating - floor( $rating ) ) ) { // For rating more than x.0 and less than x.5 or equal it will show a half star. return 50 >= floor( ( $rating - floor( $rating ) ) * 100 ) ? 'half-fill' : 'fill'; } // Don't show a golden star otherwise. return 'no-fill'; }