I am trying to extract the total number of likes associated with different posts from the WTI Like Post Pro wordpress plugin, then subtract the number of unlikes and feed this total into a meter gauge (gaugepress in wordpress...which is suspiciously similar to that found in http://justgage.com/).
The meter will look something like this:
https://wordpress.org/plugins/gaugepress/screenshots/ (see link as I don't have the reputation to post images)
In addition, I need one 'like' (vote) to represent several 'units' on the meter, e.g. one like = 8 units.
I've tried asking the authors of both plugins, but have had no response.
Here is the code from WTI Like Post Pro:
function GetWtiLikeCount($post_id) {
global $wpdb;
$show_symbols = get_option('wti_like_post_show_symbols');
$wti_like_count = $wpdb->get_var("SELECT SUM(value) FROM {$wpdb->prefix}wti_like_post WHERE post_id = '$post_id' AND value >= 0");
if (!$wti_like_count) {
$wti_like_count = 0;
} else {
if ($show_symbols) {
$wti_like_count = "+" . $wti_like_count;
} else {
$wti_like_count = $wti_like_count;
}
}
return $wti_like_count;
}
/**
* Get unlike count for a post
* @param $post_id integer
* @return string
*/
function GetWtiUnlikeCount($post_id) {
global $wpdb;
$show_symbols = get_option('wti_like_post_show_symbols');
$wti_unlike_count = $wpdb->get_var("SELECT SUM(value) FROM {$wpdb->prefix}wti_like_post WHERE post_id = '$post_id' AND value <= 0");
if (!$wti_unlike_count) {
$wti_unlike_count = 0;
} else {
if ($show_symbols) {
} else {
$wti_unlike_count = str_replace('-', '', $wti_unlike_count);
}
}
return $wti_unlike_count;
}
So firstly, I need each 'like' to represent 8 units on the meter, and I then need a total figure to enter into a gauge which represents the number of likes, subtracted by the number of unlikes. Would this be something like:
$New_total_figure = ($wti_like_count * 8) - ($wti_unlike_count * 8)
And does anyone know if this "$New_total_figure" can be entered into the shortcode for gaugepress?
Something like:
[gauge width="400px" height="220px" value="$New_total_figure" min="0" max="150" title="First Gauge" label="km" showminmax="true" color="#E16300" backcolor="#EDEDED" widthscale="0.8"]
If anyone knows how to do this with just gauge, rather than gaugepress, that would be just as good.
Thanks!