Make WordPress Core

Ticket #22599: 22599.diff

File 22599.diff, 2.4 KB (added by nacin, 10 years ago)

Patch from tellyworth ripped from WordPress.org code (as in, needs work)

  • src/wp-admin/includes/plugin-install.php

     
    311311function install_plugin_information() {
    312312        global $tab;
    313313
    314         $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl() ) );
     314        $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl(), 'fields' => array( 'reviews' => true ) ) );
    315315
    316316        if ( is_wp_error( $api ) )
    317317                wp_die( $api );
     
    331331                'faq'          => _x('FAQ',          'Plugin installer section title'),
    332332                'screenshots'  => _x('Screenshots',  'Plugin installer section title'),
    333333                'changelog'    => _x('Changelog',    'Plugin installer section title'),
     334                'reviews'      => _x('Reviews',      'Plugin installer section title'),
    334335                'other_notes'  => _x('Other Notes',  'Plugin installer section title')
    335336        );
    336337
     
    401402                <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
    402403                <small><?php printf( _n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings) ); ?></small>
    403404                <?php endif; ?>
     405
     406                <?php
     407                if ( ! empty( $api->ratings ) ) {
     408                        foreach( $api->ratings as $key=>$ratecount ) {
     409                        // avoid div-by-zero
     410                        $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
     411                ?>
     412                <div class="counter-container">
     413                        <a href="//wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
     414                                title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>">
     415                                <span class="counter-label" style="float:left; margin-right:5px;"><?php echo $key; ?> stars</span>
     416                                <span class="counter-back" style="height:17px;width:92px;background-color:#ececec;float:left;">
     417                                        <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;height:17px;background-color:#fddb5a;float:left;"></span>
     418                                </span>
     419                        </a>
     420                        <span class="counter-count" style="margin-left:5px;"><?php echo $ratecount; ?></span>
     421                </div>
     422                <?php
     423                        }
     424                }
     425        ?>
    404426        </div>
    405427        <div id="section-holder" class="wrap">
    406428        <?php