Testosterone
Member
- Jun 1, 2019
- 93
- 51
- 18
Hi guys,
I got a problem with a theme:
Warning: A non-numeric value encountered in ...\functions\popcorn_post_like.php on line 60 ($total_count = $like_count + $dislike_count
I don't know why it treats these values as non-numeric.
Can the js file (post-like.min.js) contains errors?
---------------------------
just added (int) before variables and it worked. Silly me.
@Tomz please close the tread.
I got a problem with a theme:
Warning: A non-numeric value encountered in ...\functions\popcorn_post_like.php on line 60 ($total_count = $like_count + $dislike_count
Code:
<?php
function load_postlike_script(){
wp_register_script('like_post', get_template_directory_uri().'/awpt/js/post-like/post-like.min.js', array('jquery'), '1.1', true );
wp_enqueue_script('like_post');
wp_localize_script('like_post', 'ajax_var', array(
'url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('ajax-nonce')
));
add_action('wp_ajax_nopriv_post-like', 'adultwpthemes_post_like');
add_action('wp_ajax_post-like', 'adultwpthemes_post_like');
}
add_action('init', 'load_postlike_script');
$timebeforerevote = 1;//1 * 60min * 24h
function adultwpthemes_hasAlreadyVoted($post_id)
{
global $timebeforerevote;
$meta_IP = get_post_meta($post_id, "voted_IP");
$voted_IP = isset($meta_IP[0]) ? $meta_IP[0] : '';
if(!is_array($voted_IP))
$voted_IP = array();
$ip = $_SERVER['REMOTE_ADDR'];
if(in_array($ip, array_keys($voted_IP)))
{
$time = $voted_IP[$ip];
$now = time();
if(round(($now - $time) / 60) > $timebeforerevote)
return false;
return true;
}
return false;
}
function adultwpthemes_getPostLikeLink($post_id) {
global $awpt,$post;
/*$rates = (int) get_post_meta( $post->ID, 'likes_count', true) + (int) get_post_meta( $post->ID, 'dislikes_count', true);
$votes = adultwpthemes_getItemPostLikeRate( $post_id );*/
$output = '<span class="vote-system">';
$output .= '<div class="vote_buttons"><a href="#" data-post_id="'.$post_id.'" data-post_like="like" class="l-vote positivelike">
<img src="' . get_bloginfo("template_url") . '/awpt/css/images/positivelike.png" alt="' . __('I like this video', 'adultwpthemes') . '">
<i class="tool-tip"><em></em>' . __('Good', 'adultwpthemes') . '</i>
</a>
<a href="#" data-post_id="'.$post_id.'" data-post_like="dislike" class="l-vote negativelike">
<img src="' . get_bloginfo("template_url") . '/awpt/css/images/negativelike.png" alt="' . __('I dont like this video', 'adultwpthemes') . '">
<i class="tool-tip"><em></em>' . __('Bad', 'adultwpthemes') . '</i>
</a>
<div class="vote">
<span>' . get_template_part( 'templates/vote', get_post_format() ) . '</span></div>
</div>
';
$output .= '</span>';
return $output;
}
function adultwpthemes_getPostLikeRate( $post_id ){
$like_count = get_post_meta($post_id, "likes_count", true);
$dislike_count = get_post_meta($post_id, "dislikes_count", true);
$total_count = $like_count + $dislike_count;
if($total_count > 0)
return $like_count / $total_count * 100;
else
return false;
}
function adultwpthemes_getItemPostLikeRate( $post_id ){
if( adultwpthemes_getPostLikeRate($post_id) !== false )
return floor( adultwpthemes_getPostLikeRate($post_id) ) . '%';
else
return '0%';
}
I don't know why it treats these values as non-numeric.
Can the js file (post-like.min.js) contains errors?
---------------------------
just added (int) before variables and it worked. Silly me.
@Tomz please close the tread.
Last edited: