Making WordPress.org


Ignore:
Timestamp:
04/15/2015 09:19:21 AM (12 years ago)
Author:
dd32
Message:

Theme Directory: Consolidate some ratings strings, and round the value to .5 stars, previously it would display 5 stars, yet say 4.8 stars.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/view-templates/theme-single.php

    r1477 r1478  
    7575                                                <span class="four"></span>
    7676                                                <span class="five"></span>
    77                                                 <p class="description"><?php printf( __( '%s out of 5 stars.', 'wporg-themes' ), '<span itemprop="ratingValue">{{ ( data.rating / 20 ).toFixed( 1 ) }}</span>' ); ?></p>
     77                                                <p class="description"><?php printf( __( '%s out of 5 stars.', 'wporg-themes' ), '<span itemprop="ratingValue">{{ Math.round( data.rating / 20 / 0.5 )*0.5 }}</span>' ); ?></p>
    7878                                        </div>
    7979                                        <# } else { #>
    … …  
    8585                                        <# if ( data.ratings ) { #>
    8686                                        <ul>
     87                                                <?php foreach ( range( 5, 1 ) as $stars ) : ?>
    8788                                                <li class="counter-container">
    88                                                         <a href="//wordpress.org/support/view/theme-reviews/{{ data.id }}?filter=5" title="<?php echo esc_attr( sprintf( __( 'Click to see reviews that provided a rating of %d stars', 'wporg-themes' ), 5 ) ); ?>">
    89                                                                 <span class="counter-label"><?php printf( _n( '%d star', '%d stars', 5, 'wporg-themes' ), 5 ); ?></span>
     89                                                        <a href="//wordpress.org/support/view/theme-reviews/{{ data.id }}?filter=<?php echo $stars; ?>" title="<?php echo esc_attr( sprintf( __( 'Click to see reviews that provided a rating of %d stars', 'wporg-themes' ), $stars ) ); ?>">
     90                                                                <span class="counter-label"><?php printf( _n( '%d star', '%d stars', $stars, 'wporg-themes' ), $stars ); ?></span>
    9091                                                                <span class="counter-back">
    91                                                                         <span class="counter-bar" style="width: {{ 100 * data.ratings[5] / data.num_ratings }}%;"></span>
     92                                                                        <span class="counter-bar" style="width: {{ 100 * data.ratings[<?php echo $stars; ?>] / data.num_ratings }}%;"></span>
    9293                                                                </span>
    93                                                                 <span class="counter-count">{{ data.ratings[5] }}</span>
     94                                                                <span class="counter-count">{{ data.ratings[<?php echo $stars; ?>] }}</span>
    9495                                                        </a>
    9596                                                </li>
    96                                                 <li class="counter-container">
    97                                                         <a href="//wordpress.org/support/view/theme-reviews/{{ data.id }}?filter=4" title="<?php echo esc_attr( sprintf( __( 'Click to see reviews that provided a rating of %d stars', 'wporg-themes' ), 4 ) ); ?>">
    98                                                                 <span class="counter-label"><?php printf( _n( '%d star', '%d stars', 4, 'wporg-themes' ), 4 ); ?></span>
    99                                                                 <span class="counter-back">
    100                                                                         <span class="counter-bar" style="width: {{ 100 * data.ratings[4] / data.num_ratings }}%;"></span>
    101                                                                 </span>
    102                                                                 <span class="counter-count">{{ data.ratings[4] }}</span>
    103                                                         </a>
    104                                                 </li>
    105                                                 <li class="counter-container">
    106                                                         <a href="//wordpress.org/support/view/theme-reviews/{{ data.id }}?filter=3" title="<?php echo esc_attr( sprintf( __( 'Click to see reviews that provided a rating of %d stars', 'wporg-themes' ), 3 ) ); ?>">
    107                                                                 <span class="counter-label"><?php printf( _n( '%d star', '%d stars', 3, 'wporg-themes' ), 3 ); ?></span>
    108                                                                 <span class="counter-back">
    109                                                                         <span class="counter-bar" style="width: {{ 100 * data.ratings[3] / data.num_ratings }}%;"></span>
    110                                                                 </span>
    111                                                                 <span class="counter-count">{{ data.ratings[3] }}</span>
    112                                                         </a>
    113                                                 </li>
    114                                                 <li class="counter-container">
    115                                                         <a href="//wordpress.org/support/view/theme-reviews/{{ data.id }}?filter=2" title="<?php echo esc_attr( sprintf( __( 'Click to see reviews that provided a rating of %d stars', 'wporg-themes' ), 2 ) ); ?>">
    116                                                                 <span class="counter-label"><?php printf( _n( '%d star', '%d stars', 2, 'wporg-themes' ), 2 ); ?></span>
    117                                                                 <span class="counter-back">
    118                                                                         <span class="counter-bar" style="width: {{ 100 * data.ratings[2] / data.num_ratings }}%;"></span>
    119                                                                 </span>
    120                                                                 <span class="counter-count">{{ data.ratings[2] }}</span>
    121                                                         </a>
    122                                                 </li>
    123                                                 <li class="counter-container">
    124                                                         <a href="//wordpress.org/support/view/theme-reviews/{{ data.id }}?filter=1" title="<?php esc_attr_e( 'Click to see reviews that provided a rating of 1 star', 'wporg-themes' ); ?>">
    125                                                                 <span class="counter-label"><?php printf( _n( '%d star', '%d stars', 1, 'wporg-themes' ), 1 ); ?></span>
    126                                                                 <span class="counter-back">
    127                                                                         <span class="counter-bar" style="width: {{ 100 * data.ratings[1] / data.num_ratings }}%;"></span>
    128                                                                 </span>
    129                                                                 <span class="counter-count">{{ data.ratings[1] }}</span>
    130                                                         </a>
    131                                                 </li>
     97                                                <?php endforeach; ?>
    13298                                        </ul>
    13399                                        <# } #>
Note: See TracChangeset for help on using the changeset viewer.