Version Description
- FIXED: Rankings yasr_top_ten_highest_rated, yasr_most_or_highest_rated_posts and yasr_top_5_reviewers has been fixed (broken in version 1.3.6)
- FIXED: js errors on yasr-front.js, thanks to jg88
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 1.3.7 |
Comparing to | |
See all releases |
Code changes from version 1.3.6 to 1.3.7
- js/yasr-front.js +2 -2
- lib/yasr-functions.php +1 -11
- lib/yasr-shortcode-functions.php +73 -34
- readme.txt +5 -1
- yet-another-stars-rating.php +3 -3
js/yasr-front.js
CHANGED
@@ -122,7 +122,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
|
|
122 |
rating: ratingArray,
|
123 |
set_type: setType
|
124 |
|
125 |
-
}
|
126 |
|
127 |
//Send value to the Server
|
128 |
jQuery.post(ajaxurl, data, function(response) {
|
@@ -204,7 +204,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
|
|
204 |
var data = {
|
205 |
action: 'yasr_stats_visitors_votes',
|
206 |
post_id: yasrCommonData.postid
|
207 |
-
}
|
208 |
|
209 |
jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
|
210 |
varTipsContent = response;
|
122 |
rating: ratingArray,
|
123 |
set_type: setType
|
124 |
|
125 |
+
};
|
126 |
|
127 |
//Send value to the Server
|
128 |
jQuery.post(ajaxurl, data, function(response) {
|
204 |
var data = {
|
205 |
action: 'yasr_stats_visitors_votes',
|
206 |
post_id: yasrCommonData.postid
|
207 |
+
};
|
208 |
|
209 |
jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
|
210 |
varTipsContent = response;
|
lib/yasr-functions.php
CHANGED
@@ -102,16 +102,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
102 |
}
|
103 |
|
104 |
|
105 |
-
//Add the javascript needed for shortcode creator only when necessary
|
106 |
-
/*add_action('wp_enqueue_media', 'yasr_shortcode_creator_javascript');
|
107 |
-
|
108 |
-
function yasr_shortcode_creator_javascript () {
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
}*/
|
113 |
-
|
114 |
-
|
115 |
/*** Css rules for stars set, from version 1.2.7
|
116 |
Here I use add_action instead of directly use wp_add_inline_style so I can
|
117 |
use remove_action if needed (e.g. Yasr Stylish)
|
@@ -705,7 +695,7 @@ add_action('media_buttons', 'yasr_shortcode_button_media', 99);
|
|
705 |
|
706 |
add_thickbox();
|
707 |
|
708 |
-
echo '<a href="#TB_inline?width=530&height=600&inlineId=yasr-tinypopup-form" id="yasr-shortcode-creator" class="button thickbox"><span class="dashicons dashicons-star-half" style="vertical-align:
|
709 |
|
710 |
}
|
711 |
|
102 |
}
|
103 |
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
/*** Css rules for stars set, from version 1.2.7
|
106 |
Here I use add_action instead of directly use wp_add_inline_style so I can
|
107 |
use remove_action if needed (e.g. Yasr Stylish)
|
695 |
|
696 |
add_thickbox();
|
697 |
|
698 |
+
echo '<a href="#TB_inline?width=530&height=600&inlineId=yasr-tinypopup-form" id="yasr-shortcode-creator" class="button thickbox"><span class="dashicons dashicons-star-half" style="vertical-align: midlle;"></span> Yasr Shortcode</a>';
|
699 |
|
700 |
}
|
701 |
|
lib/yasr-shortcode-functions.php
CHANGED
@@ -32,7 +32,7 @@ add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
|
|
32 |
), $atts )
|
33 |
);
|
34 |
|
35 |
-
$overall_rating=yasr_get_overall_rating($postid);
|
36 |
|
37 |
//if still false
|
38 |
if (!$overall_rating) {
|
@@ -476,6 +476,10 @@ add_shortcode ('yasr_multiset', 'shortcode_multi_set_callback');
|
|
476 |
|
477 |
$shortcode_html.="<table class=\"yasr_table_multi_set_shortcode\">";
|
478 |
|
|
|
|
|
|
|
|
|
479 |
foreach ($set_name_content as $set_content) {
|
480 |
|
481 |
$shortcode_html .= "<tr> <td><span class=\"yasr-multi-set-name-field\">$set_content->name </span></td>
|
@@ -782,12 +786,15 @@ add_shortcode ('yasr_top_ten_highest_rated', 'yasr_top_ten_highest_rated_callbac
|
|
782 |
|
783 |
global $wpdb;
|
784 |
|
785 |
-
|
786 |
-
|
787 |
-
|
|
|
|
|
788 |
AND p.post_status = 'publish'
|
789 |
-
AND
|
790 |
-
ORDER BY
|
|
|
791 |
|
792 |
$shortcode_html = '
|
793 |
<!-- Yasr Top 10 highest Rated Shortcode-->
|
@@ -844,20 +851,28 @@ add_shortcode ('yasr_most_or_highest_rated_posts', 'yasr_most_or_highest_rated_p
|
|
844 |
|
845 |
global $wpdb;
|
846 |
|
847 |
-
$query_result_most_rated = $wpdb->get_results("SELECT post_id, number_of_votes, sum_votes
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
861 |
|
862 |
if ($query_result_most_rated) {
|
863 |
|
@@ -965,11 +980,12 @@ add_shortcode ('yasr_top_5_reviewers', 'yasr_top_5_reviewers_callback');
|
|
965 |
|
966 |
global $wpdb;
|
967 |
|
968 |
-
$query_result = $wpdb->get_results("SELECT COUNT(
|
969 |
-
FROM $wpdb->posts AS p,
|
970 |
-
WHERE
|
|
|
971 |
AND p.post_status = 'publish'
|
972 |
-
GROUP BY
|
973 |
ORDER BY (total_count) DESC
|
974 |
LIMIT 5");
|
975 |
|
@@ -1108,25 +1124,40 @@ add_shortcode ('yasr_top_ten_active_users', 'yasr_top_ten_active_users_callback'
|
|
1108 |
|
1109 |
} //End function
|
1110 |
|
|
|
|
|
|
|
1111 |
add_shortcode ('yasr_highest_rated_visitor_multi_set', 'yasr_highest_rated_visitor_multi_set_callback');
|
1112 |
|
1113 |
-
function yasr_highest_rated_visitor_multi_set_callback () {
|
1114 |
|
1115 |
global $wpdb;
|
1116 |
|
1117 |
-
|
1118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1119 |
|
1120 |
-
$set_fields=$wpdb->get_results("SELECT v.post_id, v.sum_votes / v.number_of_votes AS average, v.number_of_votes, f.field_name
|
1121 |
FROM " . YASR_MULTI_SET_VALUES_TABLE . " AS v, " . YASR_MULTI_SET_FIELDS_TABLE . " AS f
|
1122 |
-
WHERE v.set_type =
|
|
|
1123 |
AND v.field_id = f.field_id
|
1124 |
AND v.number_of_votes > 0
|
1125 |
AND v.sum_votes > 0
|
1126 |
-
ORDER BY f.parent_set_id ASC, f.field_id ASC, v.post_id ASC"
|
1127 |
-
);
|
1128 |
|
1129 |
-
|
|
|
|
|
|
|
|
|
|
|
1130 |
|
1131 |
if (!isset($field_name) || $field_name != $results->field_name ) {
|
1132 |
|
@@ -1145,7 +1176,7 @@ function yasr_highest_rated_visitor_multi_set_callback () {
|
|
1145 |
</td>
|
1146 |
<td>
|
1147 |
<div class=\"rateit medium\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$average\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
|
1148 |
-
$average" . sprintf(__('based on %d votes', 'yet-another-stars-rating'), $results->number_of_votes); "
|
1149 |
</td>
|
1150 |
</tr>";
|
1151 |
|
@@ -1154,7 +1185,15 @@ function yasr_highest_rated_visitor_multi_set_callback () {
|
|
1154 |
|
1155 |
}
|
1156 |
|
1157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
|
1159 |
return $shortcode_html;
|
1160 |
|
32 |
), $atts )
|
33 |
);
|
34 |
|
35 |
+
$overall_rating = yasr_get_overall_rating($postid);
|
36 |
|
37 |
//if still false
|
38 |
if (!$overall_rating) {
|
476 |
|
477 |
$shortcode_html.="<table class=\"yasr_table_multi_set_shortcode\">";
|
478 |
|
479 |
+
//this is to avoid undefined, may happens when an user insert the shortcode without insert vote (only happens if more than 1 multiset are used)
|
480 |
+
$set_content = new stdClass();
|
481 |
+
$set_content->vote = NULL; //avoid undefined
|
482 |
+
|
483 |
foreach ($set_name_content as $set_content) {
|
484 |
|
485 |
$shortcode_html .= "<tr> <td><span class=\"yasr-multi-set-name-field\">$set_content->name </span></td>
|
786 |
|
787 |
global $wpdb;
|
788 |
|
789 |
+
|
790 |
+
|
791 |
+
$query_result = $wpdb->get_results("SELECT pm.meta_value AS overall_rating, pm.post_id AS post_id
|
792 |
+
FROM $wpdb->postmeta AS pm, $wpdb->posts AS p
|
793 |
+
WHERE pm.post_id = p.ID
|
794 |
AND p.post_status = 'publish'
|
795 |
+
AND pm.meta_key = 'yasr_overall_rating'
|
796 |
+
ORDER BY pm.meta_value DESC, pm.post_id ASC LIMIT 10");
|
797 |
+
|
798 |
|
799 |
$shortcode_html = '
|
800 |
<!-- Yasr Top 10 highest Rated Shortcode-->
|
851 |
|
852 |
global $wpdb;
|
853 |
|
854 |
+
$query_result_most_rated = $wpdb->get_results ("SELECT post_id, COUNT(post_id) AS number_of_votes, SUM(vote) AS sum_votes
|
855 |
+
FROM " . YASR_LOG_TABLE . " , $wpdb->posts AS p
|
856 |
+
WHERE post_id = p.ID
|
857 |
+
AND p.post_status = 'publish'
|
858 |
+
GROUP BY post_id
|
859 |
+
HAVING number_of_votes > 1
|
860 |
+
ORDER BY number_of_votes DESC, post_id ASC
|
861 |
+
LIMIT 10
|
862 |
+
");
|
863 |
+
|
864 |
+
|
865 |
+
//count run twice but access data only once: tested with query monitor and asked
|
866 |
+
//here http://stackoverflow.com/questions/39201235/does-count-run-twice/39201492
|
867 |
+
$query_result_highest = $wpdb->get_results ("SELECT post_id, COUNT(post_id) AS number_of_votes, (SUM(vote) / COUNT(post_id)) AS result
|
868 |
+
FROM " . YASR_LOG_TABLE . " , $wpdb->posts AS p
|
869 |
+
WHERE post_id = p.ID
|
870 |
+
AND p.post_status = 'publish'
|
871 |
+
GROUP BY post_id
|
872 |
+
HAVING COUNT(post_id) >= 2
|
873 |
+
ORDER BY result DESC, number_of_votes DESC
|
874 |
+
LIMIT 10
|
875 |
+
");
|
876 |
|
877 |
if ($query_result_most_rated) {
|
878 |
|
980 |
|
981 |
global $wpdb;
|
982 |
|
983 |
+
$query_result = $wpdb->get_results("SELECT COUNT( pm.post_id ) AS total_count, p.post_author AS reviewer
|
984 |
+
FROM $wpdb->posts AS p, $wpdb->postmeta AS pm
|
985 |
+
WHERE pm.post_id = p.ID
|
986 |
+
AND pm.meta_key = 'yasr_overall_rating'
|
987 |
AND p.post_status = 'publish'
|
988 |
+
GROUP BY reviewer
|
989 |
ORDER BY (total_count) DESC
|
990 |
LIMIT 5");
|
991 |
|
1124 |
|
1125 |
} //End function
|
1126 |
|
1127 |
+
|
1128 |
+
//this shortcode is in the plugin but not ready to use yet.
|
1129 |
+
//that's why there isn't doc about
|
1130 |
add_shortcode ('yasr_highest_rated_visitor_multi_set', 'yasr_highest_rated_visitor_multi_set_callback');
|
1131 |
|
1132 |
+
function yasr_highest_rated_visitor_multi_set_callback ($atts) {
|
1133 |
|
1134 |
global $wpdb;
|
1135 |
|
1136 |
+
// Attributes
|
1137 |
+
extract( shortcode_atts(
|
1138 |
+
array(
|
1139 |
+
'setid' => '0',
|
1140 |
+
), $atts )
|
1141 |
+
);
|
1142 |
+
|
1143 |
+
$set_fields = FALSE;
|
1144 |
+
$shortcode_html = '';
|
1145 |
|
1146 |
+
$set_fields=$wpdb->get_results($wpdb->prepare("SELECT v.post_id, v.sum_votes / v.number_of_votes AS average, v.number_of_votes, f.field_name
|
1147 |
FROM " . YASR_MULTI_SET_VALUES_TABLE . " AS v, " . YASR_MULTI_SET_FIELDS_TABLE . " AS f
|
1148 |
+
WHERE v.set_type = %d
|
1149 |
+
AND v.set_type = f.parent_set_id
|
1150 |
AND v.field_id = f.field_id
|
1151 |
AND v.number_of_votes > 0
|
1152 |
AND v.sum_votes > 0
|
1153 |
+
ORDER BY f.parent_set_id ASC, f.field_id ASC, v.post_id ASC", $setid));
|
|
|
1154 |
|
1155 |
+
if ($set_fields) {
|
1156 |
+
|
1157 |
+
$shortcode_html = "
|
1158 |
+
<table class=\"yasr-table-chart\">";
|
1159 |
+
|
1160 |
+
foreach ($set_fields as $results) {
|
1161 |
|
1162 |
if (!isset($field_name) || $field_name != $results->field_name ) {
|
1163 |
|
1176 |
</td>
|
1177 |
<td>
|
1178 |
<div class=\"rateit medium\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$average\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
|
1179 |
+
$average" . sprintf(__(' based on %d votes', 'yet-another-stars-rating'), $results->number_of_votes); "
|
1180 |
</td>
|
1181 |
</tr>";
|
1182 |
|
1185 |
|
1186 |
}
|
1187 |
|
1188 |
+
$shortcode_html .= "</table>";
|
1189 |
+
|
1190 |
+
}
|
1191 |
+
|
1192 |
+
else {
|
1193 |
+
|
1194 |
+
_e("No results, try a different setid", "yet-another-stars-rating");
|
1195 |
+
|
1196 |
+
}
|
1197 |
|
1198 |
return $shortcode_html;
|
1199 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post r
|
|
4 |
Requires at least: 4.3.0
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 4.6
|
7 |
-
Stable tag: 1.3.
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
|
@@ -113,6 +113,10 @@ Of course not: you can easily add it on the visual editor just by clicking the "
|
|
113 |
|
114 |
The full changelog can be found in the plugin's directory. Recent entries:
|
115 |
|
|
|
|
|
|
|
|
|
116 |
= 1.3.6 =
|
117 |
* TWEAKED: yasr_visitor_votes doesn't use anymore yasr_votes table. It use only yasr_log instead. From this version, yasr_votes is not created anymore. If after this update everything is ok, if you wish you can drop yasr_votes table
|
118 |
* TWEAKED: add the link to the post on yasr recent ratings widget
|
4 |
Requires at least: 4.3.0
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 4.6
|
7 |
+
Stable tag: 1.3.7
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
|
113 |
|
114 |
The full changelog can be found in the plugin's directory. Recent entries:
|
115 |
|
116 |
+
= 1.3.7 =
|
117 |
+
* FIXED: Rankings yasr_top_ten_highest_rated, yasr_most_or_highest_rated_posts and yasr_top_5_reviewers has been fixed (broken in version 1.3.6)
|
118 |
+
* FIXED: js errors on yasr-front.js, thanks to jg88
|
119 |
+
|
120 |
= 1.3.6 =
|
121 |
* TWEAKED: yasr_visitor_votes doesn't use anymore yasr_votes table. It use only yasr_log instead. From this version, yasr_votes is not created anymore. If after this update everything is ok, if you wish you can drop yasr_votes table
|
122 |
* TWEAKED: add the link to the post on yasr recent ratings widget
|
yet-another-stars-rating.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Yet Another Stars Rating
|
4 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
5 |
* Description: Yet Another Stars Rating turn your WordPress into a complete review website.
|
6 |
-
* Version: 1.3.
|
7 |
* Author: Dario Curvino
|
8 |
* Author URI: https://yetanotherstarsrating.com/
|
9 |
* Text Domain: yet-another-stars-rating
|
@@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
31 |
|
32 |
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
|
33 |
|
34 |
-
define('YASR_VERSION_NUM', '1.3.
|
35 |
|
36 |
//Plugin relative path
|
37 |
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
|
@@ -288,7 +288,7 @@ function yasr_update_version() {
|
|
288 |
|
289 |
$overall_rating_array=$wpdb->get_results("SELECT post_id, overall_rating, review_type
|
290 |
FROM " . YASR_VOTES_TABLE ."
|
291 |
-
WHERE overall_rating >0
|
292 |
OR review_type IS NOT NULL
|
293 |
ORDER BY post_id ASC");
|
294 |
|
3 |
* Plugin Name: Yet Another Stars Rating
|
4 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
5 |
* Description: Yet Another Stars Rating turn your WordPress into a complete review website.
|
6 |
+
* Version: 1.3.7
|
7 |
* Author: Dario Curvino
|
8 |
* Author URI: https://yetanotherstarsrating.com/
|
9 |
* Text Domain: yet-another-stars-rating
|
31 |
|
32 |
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
|
33 |
|
34 |
+
define('YASR_VERSION_NUM', '1.3.7');
|
35 |
|
36 |
//Plugin relative path
|
37 |
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
|
288 |
|
289 |
$overall_rating_array=$wpdb->get_results("SELECT post_id, overall_rating, review_type
|
290 |
FROM " . YASR_VOTES_TABLE ."
|
291 |
+
WHERE overall_rating > 0
|
292 |
OR review_type IS NOT NULL
|
293 |
ORDER BY post_id ASC");
|
294 |
|