Making WordPress.org

Changeset 3207


Ignore:
Timestamp:
05/20/2016 10:24:28 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Chack for $rating rather than $ratings.

$ratings can be truthy when it's populated with 0 amounts of ratings per
star level.

See #1719.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php

    r3203 r3207  
    4040
    4141        <?php if ( $rating ) : ?>
    42         <div class="rating">
    43             <?php echo Template::dashicons_stars( $rating ); ?>
    44             <meta itemprop="ratingValue" content="<?php echo esc_attr( $rating ) ?>">
    45         </div>
    46         <?php else : ?>
    47         <div class="rating">
    48             <p><?php _e( 'This plugin has not been rated yet.', 'wporg-plugins' ); ?></p>
    49         </div>
    50         <?php endif; // $rating
    5142
    52         if ( $ratings ) : ?>
    53         <ul class="ratings-list">
    54             <?php foreach ( range( 5, 1 ) as $stars ) :
    55                 $rating_bar_width = $num_ratings ? 100 * $ratings[ $stars ] / $num_ratings : 0;
    56             ?>
    57             <li class="counter-container">
    58                 <a href="<?php echo esc_url( 'https://wordpress.org/support/view/plugin-reviews/' . $post->post_name . '?filter=' . $stars ); ?>">
    59                     <span class="counter-label"><?php printf( _n( '%d star', '%d stars', $stars, 'wporg-plugin' ), $stars ); ?></span>
     43            <div class="rating">
     44                <?php echo Template::dashicons_stars( $rating ); ?>
     45                <meta itemprop="ratingValue" content="<?php echo esc_attr( $rating ) ?>">
     46            </div>
     47
     48            <ul class="ratings-list">
     49                <?php foreach ( range( 5, 1 ) as $stars ) :
     50                    $rating_bar_width = $num_ratings ? 100 * $ratings[ $stars ] / $num_ratings : 0;
     51                    ?>
     52                    <li class="counter-container">
     53                        <a href="<?php echo esc_url( 'https://wordpress.org/support/view/plugin-reviews/' . $post->post_name . '?filter=' . $stars ); ?>">
     54                            <span class="counter-label"><?php printf( _n( '%d star', '%d stars', $stars, 'wporg-plugin' ), $stars ); ?></span>
    6055                    <span class="counter-back">
    6156                        <span class="counter-bar" style="width: <?php echo $rating_bar_width; ?>%;"></span>
    6257                    </span>
    63                     <span class="counter-count"><?php echo $ratings[ $stars ]; ?></span>
    64                 </a>
    65             </li>
    66             <?php endforeach; ?>
    67         </ul>
    68         <?php
    69         endif; // $ratings
     58                            <span class="counter-count"><?php echo $ratings[ $stars ]; ?></span>
     59                        </a>
     60                    </li>
     61                <?php endforeach; ?>
     62            </ul>
     63
     64        <?php else : ?>
     65           
     66            <div class="rating">
     67                <p><?php _e( 'This plugin has not been rated yet.', 'wporg-plugins' ); ?></p>
     68            </div>
     69
     70        <?php endif; // $rating
    7071
    7172        if ( is_user_logged_in() ) : ?>
Note: See TracChangeset for help on using the changeset viewer.