wp-ulike icon indicating copy to clipboard operation
wp-ulike copied to clipboard

Filtering counter template doesn't work with AJAX

Open ituk opened this issue 6 years ago • 1 comments

I was trying to use the wp_ulike_count_box_template filter suggested here. in order to add some text to the counter number. for instance "10 people liked this post" or "1 person liked this post" etc. this is working on page first load, but the text is not changing on click. I don't know if this is a problem in my code, or that something is missing in the original hook. here is my script: add_filter('wp_ulike_count_box_template', 'bayadaim_ulike_count', 10, 2); function bayadaim_ulike_count($string, $counter) { $num = preg_replace("/[^0-9,.]/", "", $counter); if($num == 0) $string = "<span class='didit-counter'>Be the first one to Like!</span>"; elseif($num == 1) $string = "<span class='didit-counter'>".$string." Person liked this</span>"; else $string = "<span class='didit-counter'>".$string." People liked this</span>"; return $string; }

Thanks, Itamar

ituk avatar Oct 21 '18 15:10 ituk

found it: `add_filter('wp_ulike_count_box_template', 'bayadaim_ulike_count', 10, 2); function bayadaim_ulike_count($string, $counter) { $num = preg_replace("/[^0-9,.]/", "", $counter); if($num == 0) return "רוצה להיות הראשון?"; else return $string; } add_filter('wp_ulike_format_number','bayadaim_format_number',10,3); function bayadaim_format_number($value, $num, $plus){ if($num == 0) $value = "רוצה להיות הראשון?"; elseif($num == 1) $value = $num." כבר עשה את זה"; elseif ($num >= 1000 && get_option('wp_ulike_format_number') == '1') $value = round($num/1000, 2) . 'K'." כבר עשו את זה"; else $value = $num." כבר עשו את זה";

return $value;

}`

ituk avatar Oct 21 '18 17:10 ituk