entry-views
entry-views copied to clipboard
wrong text for counts
_n_noop function not working property because the numbers are passed after formatting.
eg "1,000" says "1,000 View", it should say "1,000 Views"
One workaround is to modify the ev_get_post_views function in template.php as below:
function ev_get_post_views( $args = array() ) {
$defaults = array(
'post_id' => get_the_ID(),
'before' => '',
'after' => '',
/* Translators: %s is the number of views a post has. */
'text' => _n_noop( '%s view', '%s views', 'entry-views' ),
'wrap' => '<span %s>%s</span>'
);
$args = wp_parse_args( $args, $defaults );
$views = ev_get_post_view_count( $args['post_id'] );
$views = (0+str_replace(",", "", $views));
$text = is_array( $args['text'] ) ? translate_nooped_plural( $args['text'], $views ) : $args['text'];
$html = sprintf(
$args['wrap'],
'class="entry-views" itemprop="interactionCount" itemscope="itemscope" itemtype="http://schema.org/UserPageVisits"',
sprintf( $text, number_format_i18n($views) )
);
return $args['before'] . $html . $args['after'];
}
and ev_get_post_view_count in functions.php as this:
function ev_get_post_view_count( $post_id ) {
/* Get the number of views the post has. */
$views = get_post_meta( $post_id, ev_get_meta_key(), true );
/* Return the view count and make sure it's an integer. */
return !empty( $views ) ? absint( $views ) : 0;
}
Thanks