Skip to content
Permalink
Browse files

Merge pull request #68 from Nio-av/master

Include Option for customised suffix.
  • Loading branch information...
kamalkhan committed Mar 14, 2019
2 parents 8a23225 + b677e28 commit 4de5713f8c06e24a41cefcf105f9ec8bdd5408e3
Showing with 11 additions and 1 deletion.
  1. +6 −0 admin.php
  2. +5 −1 index.php
@@ -168,6 +168,12 @@
'field' => 'kksr_legend',
'value' => get_option('kksr_legend')
));
BhittaniPlugin_AdminMarkup::input(array(
'title' => 'Plural Suffix for number of Votes',
'description' => 'Adjust the Suffix for <code>[s]</code> placeholder. (e.G. "15 votes" [English] or "15 Bewertungen" [German].)',
'field' => 'kksr_suffix_votes',
'value' => get_option('kksr_suffix_votes')
));
BhittaniPlugin_AdminMarkup::select(array(
'title' => 'Position',
'description' => 'Choose the position of the ratings',
@@ -63,6 +63,7 @@ public function js()
$Params['ajaxurl'] = admin_url('admin-ajax.php');
$Params['func'] = 'kksr_ajax';
$Params['msg'] = parent::get_options('kksr_init_msg');
$Params['suffix_votes'] = parent::get_options('kksr_suffix_votes');
$Params['fuelspeed'] = (int) parent::get_options('kksr_js_fuelspeed');
$Params['thankyou'] = parent::get_options('kksr_js_thankyou');
$Params['error_msg'] = parent::get_options('kksr_js_error');
@@ -212,6 +213,7 @@ public function activate()
$Options['kksr_stars_yellow'] = 0;
$Options['kksr_stars_orange'] = 0;
$Options['kksr_js_fuelspeed'] = 400;
$Options['kksr_sufix_votes'] = 's';
$Options['kksr_js_thankyou'] = 'Thank you for your vote';
$Options['kksr_js_error'] = 'An error occurred';
$Options['kksr_tooltip'] = 0;
@@ -697,10 +699,12 @@ public function sanitize_legend($legend, $id, $best, $score, $votes, $avg, $per)
return parent::get_options('kksr_init_msg');
}
$pluralSuffix = parent::get_options('kksr_suffix_votes');
$leg = str_replace('[total]', '<span itemprop="ratingCount">'.$votes.'</span>', $legend);
$leg = str_replace('[avg]', '<span itemprop="ratingValue">'.$avg.'</span>', $leg);
$leg = str_replace('[per]', $per .'%', $leg);
$leg = str_replace('[s]', $votes == 1 ? '' : 's', $leg);
$leg = str_replace('[s]', $votes == 1 ? '' : $pluralSuffix, $leg);
$leg = str_replace('[best]', $best, $leg);
return $leg;

0 comments on commit 4de5713

Please sign in to comment.
You can’t perform that action at this time.