/** * Count user votes received in percentage * @return integer */ function ap_user_votes_received_percent() { $meta = (int) ap_user_get_the_meta('__up_vote_received'); $total_vote = (int) ap_user_total_votes_received(); if ($total_vote == 0 || $meta == 0) { return 0; } else { return ceil($meta / $total_vote * 100); } }
<div class="ap-about-block"> <h3><?php echo ap_icon('thumbs-up-down', true); ?> <?php _e('Votes', 'anspress-question-answer'); ?> </h3> <div class="ap-about-block-c"> <div class="ap-about-votes row"> <div class="col-md-6"> <span class="ap-about-vote-label"><?php printf(__('%d votes received', 'anspress-question-answer'), ap_user_total_votes_received()); ?> </span> <span data-action="ap_chart" data-type="donut" data-peity='{ "fill": ["#9087FF", "#eeeeee"], "innerRadius": 20, "radius": 25 }'><?php echo ap_user_votes_received_percent(); ?> /100</span> <span class="ap-vote-count"><b><?php ap_user_the_meta('__up_vote_received'); ?> </b><?php _e('up', 'anspress-question-answer'); ?> </span> <span class="ap-vote-count"><b><?php ap_user_the_meta('__down_vote_received');
<div class="ap-about-block"> <h3><?php echo ap_icon('thumbs-up-down', true); ?> <?php _e('Votes', 'ap'); ?> </h3> <div class="ap-about-block-c"> <div class="ap-about-votes row"> <div class="col-md-6"> <span class="ap-about-vote-label"><?php printf(__('%d votes received', 'ap'), ap_user_total_votes_received()); ?> </span> <span data-action="ap_chart" data-type="donut" data-peity='{ "fill": ["#9087FF", "#eeeeee"], "innerRadius": 20, "radius": 25 }'><?php echo ap_user_votes_received_percent(); ?> /100</span> <span class="ap-vote-count"><b><?php ap_user_the_meta('__up_vote_received'); ?> </b><?php _e('up', 'ap'); ?> </span> <span class="ap-vote-count"><b><?php ap_user_the_meta('__down_vote_received');
<h3><?php echo ap_icon('thumbs-up-down', true); ?> <?php _e('Votes', 'ap'); ?> </h3> <div class="ap-about-block-c"> <div class="ap-about-votes row"> <div class="col-md-6"> <span class="ap-about-vote-label"><?php printf(__('%d votes received', 'ap'), ap_user_total_votes_received()); ?> </span> <span data-action="ap_chart" data-type="donut" data-peity='{ "fill": ["#9087FF", "#eeeeee"], "innerRadius": 20, "radius": 25 }'><?php echo ceil(ap_user_get_the_meta('__up_vote_received') / ap_user_total_votes_received() * 100); ?> /100</span> <span class="ap-vote-count"><b><?php ap_user_the_meta('__up_vote_received'); ?> </b><?php _e('up', 'ap'); ?> </span> <span class="ap-vote-count"><b><?php ap_user_the_meta('__down_vote_received'); ?> </b><?php _e('down', 'ap'); ?>