Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom vote text (singular and plural) #130

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions includes/postratings-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function ratings_activate() {
// Add In Options (4 Records)
add_option('postratings_image', 'stars' );
add_option('postratings_max', '5' );
add_option('postratings_template_vote', '%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> '.__('votes', 'wp-postratings').__(',', 'wp-postratings').' '.__('average', 'wp-postratings').': <strong>%RATINGS_AVERAGE%</strong> '.__('out of', 'wp-postratings').' %RATINGS_MAX%)<br />%RATINGS_TEXT%' );
add_option('postratings_template_text', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> '.__('votes', 'wp-postratings').__(',', 'wp-postratings').' '.__('average', 'wp-postratings').': <strong>%RATINGS_AVERAGE%</strong> '.__('out of', 'wp-postratings').' %RATINGS_MAX%'.__(',', 'wp-postratings').' <strong>'.__('rated', 'wp-postratings').'</strong></em>)' );
add_option('postratings_template_vote', '%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%'.__(',', 'wp-postratings').' '.__('average', 'wp-postratings').': <strong>%RATINGS_AVERAGE%</strong> '.__('out of', 'wp-postratings').' %RATINGS_MAX%)<br />%RATINGS_TEXT%' );
add_option('postratings_template_text', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%'.__(',', 'wp-postratings').' '.__('average', 'wp-postratings').': <strong>%RATINGS_AVERAGE%</strong> '.__('out of', 'wp-postratings').' %RATINGS_MAX%'.__(',', 'wp-postratings').' <strong>'.__('rated', 'wp-postratings').'</strong></em>)' );
add_option('postratings_template_none', '%RATINGS_IMAGES_VOTE% ('.__('No Ratings Yet', 'wp-postratings').')<br />%RATINGS_TEXT%' );
// Database Upgrade For WP-PostRatings 1.02
add_option('postratings_logging_method', '3' );
Expand All @@ -74,13 +74,16 @@ function ratings_activate() {
// Database Upgrade For WP-PostRatings 1.20
add_option('postratings_ratingsvalue', array(1,2,3,4,5) );
add_option('postratings_customrating', 0 );
add_option('postratings_template_permission', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> '.__('votes', 'wp-postratings').__(',', 'wp-postratings').' '.__('average', 'wp-postratings').': <strong>%RATINGS_AVERAGE%</strong> '.__('out of', 'wp-postratings').' %RATINGS_MAX%</em>)<br /><em>'.__('You need to be a registered member to rate this.', 'wp-postratings').'</em>' );
add_option('postratings_template_permission', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%'.__(',', 'wp-postratings').' '.__('average', 'wp-postratings').': <strong>%RATINGS_AVERAGE%</strong> '.__('out of', 'wp-postratings').' %RATINGS_MAX%</em>)<br /><em>'.__('You need to be a registered member to rate this.', 'wp-postratings').'</em>' );
// Database Upgrade For WP-PostRatings 1.30
add_option('postratings_template_mostrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> - %RATINGS_USERS% '.__('votes', 'wp-postratings').'</li>' );
add_option('postratings_template_mostrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> - %RATINGS_USERS% %RATINGS_VOTE_TEXT%'.'</li>' );
// Database Upgrade For WP-PostRatings 1.50
delete_option('widget_ratings_highest_rated');
delete_option('widget_ratings_most_rated');

add_option('postratings_vote_text_singular', 'vote' );
add_option('postratings_vote_text_plural', 'votes' );

// Index
$index = $wpdb->get_results( "SHOW INDEX FROM $wpdb->ratings;" );
$key_name = array();
Expand Down
39 changes: 30 additions & 9 deletions postratings-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
$postratings_richsnippet = intval($_POST['postratings_richsnippet']);
$postratings_ratingstext_array = $_POST['postratings_ratingstext'];
$postratings_ratingstext = array();
$postratings_vote_text_singular = sanitize_text_field(trim($_POST['postratings_vote_text_singular']));
$postratings_vote_text_plural = sanitize_text_field(trim($_POST['postratings_vote_text_plural']));
if( ! empty( $postratings_ratingstext_array ) && is_array( $postratings_ratingstext_array ) ) {
foreach( $postratings_ratingstext_array as $ratingstext ) {
$postratings_ratingstext[] = wp_kses_post(trim( $ratingstext ));
Expand Down Expand Up @@ -79,6 +81,8 @@
$update_ratings_queries[] = update_option('postratings_logging_method', $postratings_logging_method);
$update_ratings_queries[] = update_option('postratings_allowtorate', $postratings_allowtorate);
$update_ratings_queries[] = update_option('postratings_options', $postratings_options);
$update_ratings_queries[] = update_option('postratings_vote_text_singular', $postratings_vote_text_singular);
$update_ratings_queries[] = update_option('postratings_vote_text_plural', $postratings_vote_text_plural);
$update_ratings_text[] = __('Custom Rating', 'wp-postratings');
$update_ratings_text[] = __('Ratings Template Vote', 'wp-postratings');
$update_ratings_text[] = __('Ratings Template Voted', 'wp-postratings');
Expand All @@ -94,6 +98,8 @@
$update_ratings_text[] = __('Logging Method', 'wp-postratings');
$update_ratings_text[] = __('Allow To Vote Option', 'wp-postratings');
$update_ratings_text[] = __('Ratings Settings', 'wp-postratings');
$update_ratings_text[] = __('Custom vote text (singular)', 'wp-postratings');
$update_ratings_text[] = __('Custom vote text (plural)', 'wp-postratings');
$i = 0;
$text = '';
foreach($update_ratings_queries as $update_ratings_query) {
Expand Down Expand Up @@ -124,22 +130,22 @@ function ratings_updown_templates(template, print) {
var default_template;
switch(template) {
case "vote":
default_template = "%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_SCORE%</strong> <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong>%RATINGS_USERS%</strong> <?php esc_html_e('votes', 'wp-postratings'); ?>)<br />%RATINGS_TEXT%";
default_template = "%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_SCORE%</strong> <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%)<br />%RATINGS_TEXT%";
break;
case "text":
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_SCORE%</strong> <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong>%RATINGS_USERS%</strong> <?php esc_html_e('votes', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong><?php esc_html_e('rated', 'wp-postratings'); ?></strong></em>)";
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_SCORE%</strong> <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%<?php esc_html_e(',', 'wp-postratings'); ?> <strong><?php esc_html_e('rated', 'wp-postratings'); ?></strong></em>)";
break;
case "permission":
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_SCORE%</strong> <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong>%RATINGS_USERS%</strong> <?php esc_html_e('votes', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong><?php esc_html_e('rated', 'wp-postratings'); ?></strong></em>)<br /><em><?php esc_html_e('You need to be a registered member to rate this.', 'wp-postratings'); ?></em>";
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_SCORE%</strong> <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%<?php esc_html_e(',', 'wp-postratings'); ?> <strong><?php esc_html_e('rated', 'wp-postratings'); ?></strong></em>)<br /><em><?php esc_html_e('You need to be a registered member to rate this.', 'wp-postratings'); ?></em>";
break;
case "none":
default_template = "%RATINGS_IMAGES_VOTE% (<?php esc_html_e('No Ratings Yet', 'wp-postratings'); ?>)<br />%RATINGS_TEXT%";
break;
case "highestrated":
default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> (%RATINGS_SCORE% <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> %RATINGS_USERS% <?php esc_html_e('votes', 'wp-postratings'); ?>)</li>";
default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> (%RATINGS_SCORE% <?php esc_html_e('rating', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> %RATINGS_USERS% %RATINGS_VOTE_TEXT%)</li>";
break;
case "mostrated":
default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> - %RATINGS_USERS% <?php esc_html_e('votes', 'wp-postratings'); ?></li>";
default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> - %RATINGS_USERS% %RATINGS_VOTE_TEXT%</li>";
break;
}
if(print) {
Expand All @@ -152,13 +158,13 @@ function ratings_default_templates(template, print) {
var default_template;
switch(template) {
case "vote":
default_template = "%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> <?php esc_html_e('votes', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <?php esc_html_e('average', 'wp-postratings'); ?>: <strong>%RATINGS_AVERAGE%</strong> <?php esc_html_e('out of', 'wp-postratings'); ?> %RATINGS_MAX%)<br />%RATINGS_TEXT%";
default_template = "%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%<?php esc_html_e(',', 'wp-postratings'); ?> <?php esc_html_e('average', 'wp-postratings'); ?>: <strong>%RATINGS_AVERAGE%</strong> <?php esc_html_e('out of', 'wp-postratings'); ?> %RATINGS_MAX%)<br />%RATINGS_TEXT%";
break;
case "text":
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> <?php esc_html_e('votes', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <?php esc_html_e('average', 'wp-postratings'); ?>: <strong>%RATINGS_AVERAGE%</strong> <?php esc_html_e('out of', 'wp-postratings'); ?> %RATINGS_MAX%<?php esc_html_e(',', 'wp-postratings'); ?> <strong><?php esc_html_e('rated', 'wp-postratings'); ?></strong></em>)";
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%<?php esc_html_e(',', 'wp-postratings'); ?> <?php esc_html_e('average', 'wp-postratings'); ?>: <strong>%RATINGS_AVERAGE%</strong> <?php esc_html_e('out of', 'wp-postratings'); ?> %RATINGS_MAX%<?php esc_html_e(',', 'wp-postratings'); ?> <strong><?php esc_html_e('rated', 'wp-postratings'); ?></strong></em>)";
break;
case "permission":
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> <?php esc_html_e('votes', 'wp-postratings'); ?><?php esc_html_e(',', 'wp-postratings'); ?> <?php esc_html_e('average', 'wp-postratings'); ?>: <strong>%RATINGS_AVERAGE%</strong> <?php esc_html_e('out of', 'wp-postratings'); ?> %RATINGS_MAX%</em>)<br /><em><?php esc_html_e('You need to be a registered member to rate this.', 'wp-postratings'); ?></em>";
default_template = "%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> %RATINGS_VOTE_TEXT%<?php esc_html_e(',', 'wp-postratings'); ?> <?php esc_html_e('average', 'wp-postratings'); ?>: <strong>%RATINGS_AVERAGE%</strong> <?php esc_html_e('out of', 'wp-postratings'); ?> %RATINGS_MAX%</em>)<br /><em><?php esc_html_e('You need to be a registered member to rate this.', 'wp-postratings'); ?></em>";
break;
case "none":
default_template = "%RATINGS_IMAGES_VOTE% (<?php esc_html_e('No Ratings Yet', 'wp-postratings'); ?>)<br />%RATINGS_TEXT%";
Expand All @@ -167,7 +173,7 @@ function ratings_default_templates(template, print) {
default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> %RATINGS_IMAGES% (%RATINGS_AVERAGE% <?php esc_html_e('out of', 'wp-postratings'); ?> %RATINGS_MAX%)</li>";
break;
case "mostrated":
default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> - %RATINGS_USERS% <?php esc_html_e('votes', 'wp-postratings'); ?></li>";
default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> - %RATINGS_USERS% %RATINGS_VOTE_TEXT%</li>";
break;
}
if(print) {
Expand Down Expand Up @@ -363,6 +369,21 @@ function set_custom(custom, max) {
</tbody>
</table>
</div>
<h2><?php esc_html_e('Custom vote text', 'wp-postratings'); ?></h2>
<table class="form-table">
<tr>
<th scope="row" valign="top"><?php esc_html_e('Vote text (singular):', 'wp-postratings'); ?></th>
<td>
<input type="text" name="postratings_vote_text_singular" value="<?php echo esc_attr(stripslashes(get_option('postratings_vote_text_singular'))) ?>">
</td>
</tr>
<tr>
<th scope="row" valign="top"><?php esc_html_e('Vote text (plural):', 'wp-postratings'); ?></th>
<td>
<input type="text" name="postratings_vote_text_plural" value="<?php echo esc_attr(stripslashes(get_option('postratings_vote_text_plural'))) ?>">
</td>
</tr>
</table>
<?php $postratings_ajax_style = get_option('postratings_ajax_style'); ?>
<h2><?php esc_html_e('Ratings AJAX Style', 'wp-postratings'); ?></h2>
<table class="form-table">
Expand Down
Loading