diff --git a/core/helpers/class-stats.php b/core/helpers/class-stats.php index 93e8cc6..85cb0fc 100644 --- a/core/helpers/class-stats.php +++ b/core/helpers/class-stats.php @@ -1289,14 +1289,21 @@ public static function get_recently_contra( $limit = null ) public static function get_single_post_stats( $post_id ) { $post = get_post( $post_id ); - $pro = self::get_pro( $post->ID ) ? self::get_pro( $post->ID ) : 0; - $contra = self::get_contra( $post->ID ) ? self::get_contra( $post->ID ) : 0; + $pro = self::get_pro( $post->ID ) ? intval( self::get_pro( $post->ID ) ) : 0; + $contra = self::get_contra( $post->ID ) ? intval( self::get_contra( $post->ID ) ) : 0; $prop = self::get_pro( $post->ID, true ); $conp = self::get_contra( $post->ID, true ); - $average = (int) ( $pro - $contra ); - $total = (int) ( $pro + $contra ); - $percentage = ( $pro / $total ) * 100; - $percentage = round( $percentage, 2 ); + + $average = 0; + $total = 0; + $percentage = 0; + + if ( 0 !== $pro ) { + $average = (int) ( $pro - $contra ); + $total = (int) ( $pro + $contra ); + $percentage = ( $pro / $total ) * 100; + $percentage = round( $percentage, 2 ); + } $post_type = get_post_type_object( $post->post_type ); diff --git a/helpful.php b/helpful.php index f36082f..b802bdd 100644 --- a/helpful.php +++ b/helpful.php @@ -2,7 +2,7 @@ /** * Plugin Name: Helpful * Description: Add a fancy feedback form under your posts or post-types and ask your visitors a question. Give them the abbility to vote with yes or no. - * Version: 4.4.0 + * Version: 4.4.1 * Author: Pixelbart * Author URI: https://pixelbart.de * Text Domain: helpful diff --git a/readme.txt b/readme.txt index 9a4c8f2..08d81ed 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: helpful, poll, feedback, reviews, vote, review, voting Requires at least: 4.6 Tested up to: 5.6 Requires PHP: 5.6.20 -Stable tag: 4.4.0 +Stable tag: 4.4.1 License: MIT License License URI: https://opensource.org/licenses/MIT