Plugin Directory

Changeset 2097498


Ignore:
Timestamp:
05/29/2019 07:58:51 PM (7 years ago)
Author:
Yame
Message:

Division by zero

Location:
multilingual-comments/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • multilingual-comments/trunk/README.txt

    r1700641 r2097498  
    33Tags: wpml, woocommerce, reviews, multilingual, comments, review, comment
    44Requires at least: 3.0.0
    5 Tested up to: 4.8
     5Tested up to: 5.1.1
    66Stable tag: trunk
    77License: GPLv2 or later
     
    2626= 1.0 =
    2727* Initial release
     28
     29= 1.0.1 =
     30* Bugfix - Division by zero when there are 0 comments
  • multilingual-comments/trunk/includes/class-multilingual-comments.php

    r1700073 r2097498  
    2323 * version of the plugin.
    2424 *
    25  * @since      1.0.0
     25 * @since      1.0.1
    2626 * @package    Multilingual_Comments
    2727 * @subpackage Multilingual_Comments/includes
  • multilingual-comments/trunk/public/class-multilingual-comments-public.php

    r1700073 r2097498  
    195195        $rating = 0;
    196196        $comments = get_comments();
     197
     198        if( count( $comments ) == 0 ){
     199            return $rating;
     200        }
     201
    197202        foreach( $comments as $comment ){
    198            
     203
    199204            $rating += get_comment_meta( $comment->comment_ID, 'rating', true );
    200205           
    201206        }
    202        
     207
    203208        $average_rating = $rating / count($comments);
    204209        return $average_rating;
Note: See TracChangeset for help on using the changeset viewer.