I'm using this plugin to show the reading time of my post: https://jasonyingling.me/reading-time-wp/
However, I have modified some stuff because I want to be able to use it with different languages and change the positioning. So far, everything is working smoothly. The only tiny issue is that when the reading time is just a minute, it displays the word "minutes" (plural). The original plugin has a way to deal with this, but since I'm translating it I can't make use of it. To my poor understanding, this should be quite easy to fix if I could use the value returned by the plugin, but I don't know how to do that.
Here is how is currently being displayed in my content-single.php file
<div id="rtime">
<?php pll_e( 'Reading Time:' ); echo do_shortcode('[rt_reading_time]'); pll_e( 'minutes' );?>
</div><!-- #rtime -->
This is the way the plugin determines whether to show "minute" or "minutes" I just don't know how to apply that to my code.
public function rt_reading_time($atts, $content = null) {
extract (shortcode_atts(array(
'label' => '',
'postfix' => '',
'postfix_singular' => '',
), $atts));
$rtReadingOptions = get_option('rt_reading_time_options');
$rtPost = get_the_ID();
$this->rt_calculate_reading_time($rtPost, $rtReadingOptions);
if($this->readingTime > 1) {
$calculatedPostfix = $postfix;
} else {
$calculatedPostfix = $postfix_singular;
}
return "
<span class='span-reading-time'>$label $this->readingTime $calculatedPostfix</span>
";
}
I thought about modifying the plugin's code itself, but I will have issues when a new update comes, and anyway, I wouldn't be sure how to do it.
Thanks in advance!