@pikashoo
Now I hope I have understood you. Here, this should work (functions.php):
add_shortcode('pikashoo_helpful', function ($atts) {
$defaults = [
'type' => 'pro',
'percentage' => true,
'format_percentage' => '%d%%',
'format' => '%d',
'post_id' => null,
];
$atts = shortcode_atts($defaults, $atts);
extract($atts);
$is_percentage = ($percentage === true);
if ($post_id === null) {
$post_id = get_the_ID();
}
if ($type === 'pro') {
$value = Helpful\Core\Helpers\Stats::get_pro( $post_id, $is_percentage );
} else {
$value = Helpful\Core\Helpers\Stats::get_contra( $post_id, $is_percentage );
}
if ($is_percentage) {
$content = sprintf($format, $value));
} else {
$content = sprintf($format_percentage, $value));
}
return apply_filters('pikashoo_helpful_content', $content, $atts);
});
default options
[pikashoo_helpful type="pro" percentage="true" format_percentage="%d%%" format="%d" post_id="null"]
pro percentage
[pikashoo_helpful type="pro"]
contra percentage
[pikashoo_helpful type="contra"]
It is best to show only one value at a time, as there can sometimes be differences due to rounding.
Greetings Kevin