Version Description
- FIX: yasr_visitor_multiset data didn't save correctly if more than one were used in the same page.
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 2.5.4 |
Comparing to | |
See all releases |
Code changes from version 2.5.3 to 2.5.4
- admin/editor/yasr-editor-functions.php +1 -1
- changelog.txt +15 -0
- includes/classes/YasrMultiSetData.php +78 -27
- includes/rest/classes/YasrCustomEndpoint.php +1 -1
- includes/shortcodes/classes/YasrRankings.php +1 -1
- includes/shortcodes/classes/YasrVisitorMultiSet.php +5 -5
- readme.txt +5 -13
- yet-another-stars-rating.php +2 -2
admin/editor/yasr-editor-functions.php
CHANGED
@@ -435,7 +435,7 @@ function yasr_output_multiple_set_callback() {
|
|
435 |
$set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
|
436 |
|
437 |
//set meta values
|
438 |
-
$array_to_return = YasrMultiSetData::
|
439 |
|
440 |
echo json_encode($array_to_return);
|
441 |
|
435 |
$set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
|
436 |
|
437 |
//set meta values
|
438 |
+
$array_to_return = YasrMultiSetData::returnArrayFieldsRatingsAuthor($set_id, $set_fields, $post_id);
|
439 |
|
440 |
echo json_encode($array_to_return);
|
441 |
|
changelog.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 2.4.0 =
|
2 |
* NEW FEATURE: is now possible to customize the itemType Name: if empty, post title will be used instead.
|
3 |
* TWEAKED: Custom text to show when an user has already voted now shows up even for logged in users
|
1 |
+
= 2.4.3 =
|
2 |
+
* NEW FEATURE: is now possible to show ratings next to the title
|
3 |
+
* FIXED: guten blocks returns error if post_id parameter was set
|
4 |
+
* TWEAKED: added some hooks
|
5 |
+
|
6 |
+
= 2.4.2 =
|
7 |
+
* FIXED: error in gutenberg editor that appear in some circumstances
|
8 |
+
|
9 |
+
= 2.4.1 =
|
10 |
+
* FIXED: minor fix if more yasr_visitor_votes with different differents post_id are used in the same page
|
11 |
+
[//]: # fs_premium_only_begin
|
12 |
+
* NEW FEATURE: is now possible to add fake ratings in yasr_visitor_votes shortcode
|
13 |
+
* PRO ONLY: FIXED: is now possible to translate or create the strings with a software like loco translate
|
14 |
+
[//]: # fs_premium_only_end
|
15 |
+
|
16 |
= 2.4.0 =
|
17 |
* NEW FEATURE: is now possible to customize the itemType Name: if empty, post title will be used instead.
|
18 |
* TWEAKED: Custom text to show when an user has already voted now shows up even for logged in users
|
includes/classes/YasrMultiSetData.php
CHANGED
@@ -85,10 +85,11 @@ class YasrMultiSetData {
|
|
85 |
*
|
86 |
* @param $post_id
|
87 |
* @param $set_id
|
|
|
88 |
*
|
89 |
* @return array|bool
|
90 |
*/
|
91 |
-
public static function returnMultisetContent($post_id, $set_id) {
|
92 |
$set_id = (int)$set_id;
|
93 |
$post_id = (int)$post_id;
|
94 |
|
@@ -103,7 +104,12 @@ class YasrMultiSetData {
|
|
103 |
return false;
|
104 |
}
|
105 |
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
|
109 |
/** This functions returns an array with all the value to print the multiset
|
@@ -127,7 +133,7 @@ class YasrMultiSetData {
|
|
127 |
* @return bool | array
|
128 |
*/
|
129 |
|
130 |
-
public static function
|
131 |
$set_id = (int)$set_id;
|
132 |
|
133 |
if (!$set_fields) {
|
@@ -172,37 +178,82 @@ class YasrMultiSetData {
|
|
172 |
return self::$array_to_return;
|
173 |
}
|
174 |
|
175 |
-
/**
|
176 |
-
* Get from the db all the values for VisitorMultiSet
|
177 |
*
|
178 |
-
*
|
179 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
*
|
181 |
-
* @
|
|
|
|
|
|
|
|
|
182 |
*/
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
186 |
|
187 |
global $wpdb;
|
188 |
|
189 |
-
$
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f LEFT JOIN " . YASR_LOG_MULTI_SET . " AS l
|
194 |
-
ON l.post_id = %d
|
195 |
-
AND f.field_id = l.field_id
|
196 |
-
WHERE f.parent_set_id=%d
|
197 |
-
GROUP BY f.field_name, f.field_id
|
198 |
-
ORDER BY f.field_id", $post_id, $set_type), ARRAY_A);
|
199 |
-
|
200 |
-
if (!empty($result)) {
|
201 |
-
return $result;
|
202 |
}
|
203 |
-
return false;
|
204 |
-
}
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
/**
|
208 |
* @param int $post_id
|
@@ -218,7 +269,7 @@ class YasrMultiSetData {
|
|
218 |
$set_id = (int)$set_id;
|
219 |
|
220 |
if ($visitor_multiset === true) {
|
221 |
-
$multiset_content = self::
|
222 |
} else {
|
223 |
$multiset_content = self::returnMultisetContent($post_id, $set_id);
|
224 |
}
|
85 |
*
|
86 |
* @param $post_id
|
87 |
* @param $set_id
|
88 |
+
* @param bool $visitor_multiset
|
89 |
*
|
90 |
* @return array|bool
|
91 |
*/
|
92 |
+
public static function returnMultisetContent($post_id, $set_id, $visitor_multiset=false) {
|
93 |
$set_id = (int)$set_id;
|
94 |
$post_id = (int)$post_id;
|
95 |
|
104 |
return false;
|
105 |
}
|
106 |
|
107 |
+
if($visitor_multiset === true) {
|
108 |
+
return self::returnArrayFieldsRatingsVisitor($set_id, $set_fields, $post_id);
|
109 |
+
}
|
110 |
+
|
111 |
+
//return
|
112 |
+
return self::returnArrayFieldsRatingsAuthor($set_id, $set_fields, $post_id);
|
113 |
}
|
114 |
|
115 |
/** This functions returns an array with all the value to print the multiset
|
133 |
* @return bool | array
|
134 |
*/
|
135 |
|
136 |
+
public static function returnArrayFieldsRatingsAuthor($set_id, $set_fields, $post_id=false) {
|
137 |
$set_id = (int)$set_id;
|
138 |
|
139 |
if (!$set_fields) {
|
178 |
return self::$array_to_return;
|
179 |
}
|
180 |
|
181 |
+
/** This functions returns an array with all the value to print the multiset
|
|
|
182 |
*
|
183 |
+
* array (
|
184 |
+
* array (
|
185 |
+
* 'value_id' => 0,
|
186 |
+
* 'value_name' => 'Field 1',
|
187 |
+
* 'value_rating' => 3.5,
|
188 |
+
* ),
|
189 |
+
* array (
|
190 |
+
* 'value_id' => 1,
|
191 |
+
* 'value_name' => 'Field 2',
|
192 |
+
* 'value_rating' => 3,
|
193 |
+
* )
|
194 |
*
|
195 |
+
* @param integer $set_id the set id
|
196 |
+
* @param array $set_fields an array with fields names and id
|
197 |
+
* @param integer|bool $post_id the post_id
|
198 |
+
*
|
199 |
+
* @return bool | array
|
200 |
*/
|
201 |
+
|
202 |
+
public static function returnArrayFieldsRatingsVisitor($set_id, $set_fields, $post_id=false) {
|
203 |
+
|
204 |
+
$array_to_return = array();
|
205 |
|
206 |
global $wpdb;
|
207 |
|
208 |
+
$set_id = (int)$set_id;
|
209 |
+
|
210 |
+
if (!$set_fields) {
|
211 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
|
|
|
|
213 |
|
214 |
+
if(!is_int($post_id)) {
|
215 |
+
$post_id = get_the_ID();
|
216 |
+
}
|
217 |
+
|
218 |
+
//get meta values (field id and rating)
|
219 |
+
$ratings = $wpdb->get_results($wpdb->prepare("
|
220 |
+
SELECT CAST((SUM(l.vote)/COUNT(l.vote)) AS DECIMAL(2,1)) AS average_rating,
|
221 |
+
COUNT(l.vote) AS number_of_votes,
|
222 |
+
field_id AS field
|
223 |
+
FROM " . YASR_LOG_MULTI_SET . " AS l
|
224 |
+
WHERE l.post_id=%d
|
225 |
+
AND l.set_type=%d
|
226 |
+
GROUP BY l.field_id
|
227 |
+
ORDER BY l.field_id", $post_id, $set_id), ARRAY_A);
|
228 |
+
|
229 |
+
//index
|
230 |
+
$i = 0;
|
231 |
+
//always returns field id and name
|
232 |
+
foreach ($set_fields as $fields_ids_and_names) {
|
233 |
+
|
234 |
+
$array_to_return[$i]['id'] = (int) $fields_ids_and_names['id'];
|
235 |
+
$array_to_return[$i]['name'] = $fields_ids_and_names['name'];
|
236 |
+
$array_to_return[$i]['average_rating'] = 0;
|
237 |
+
$array_to_return[$i]['number_of_votes'] = 0;
|
238 |
+
|
239 |
+
//if there is post meta
|
240 |
+
if ($ratings) {
|
241 |
+
//loop the saved arrays
|
242 |
+
foreach ($ratings as $single_value) {
|
243 |
+
//if field id is the same, add the rating
|
244 |
+
if ($array_to_return[$i]['id'] === (int)$single_value['field']) {
|
245 |
+
$array_to_return[$i]['average_rating'] = $single_value['average_rating'];
|
246 |
+
$array_to_return[$i]['number_of_votes'] = (int)$single_value['number_of_votes'];
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
}
|
251 |
+
//this is for list the set names
|
252 |
+
$i ++;
|
253 |
+
}
|
254 |
+
|
255 |
+
return $array_to_return;
|
256 |
+
}
|
257 |
|
258 |
/**
|
259 |
* @param int $post_id
|
269 |
$set_id = (int)$set_id;
|
270 |
|
271 |
if ($visitor_multiset === true) {
|
272 |
+
$multiset_content = self::returnMultisetContent($post_id, $set_id, true);
|
273 |
} else {
|
274 |
$multiset_content = self::returnMultisetContent($post_id, $set_id);
|
275 |
}
|
includes/rest/classes/YasrCustomEndpoint.php
CHANGED
@@ -99,7 +99,7 @@ class YasrCustomEndpoint extends WP_REST_Controller {
|
|
99 |
|
100 |
//if $visitor === 1 then get data from yasr_visitor_multiset
|
101 |
if($visitor === 1) {
|
102 |
-
$data_to_return['yasr_visitor_multiset'] = YasrMultiSetData::
|
103 |
if ($data_to_return['yasr_visitor_multiset'] === false) {
|
104 |
$invalid_set = true;
|
105 |
}
|
99 |
|
100 |
//if $visitor === 1 then get data from yasr_visitor_multiset
|
101 |
if($visitor === 1) {
|
102 |
+
$data_to_return['yasr_visitor_multiset'] = YasrMultiSetData::returnMultisetContent($post_id, $set_id, true);
|
103 |
if ($data_to_return['yasr_visitor_multiset'] === false) {
|
104 |
$invalid_set = true;
|
105 |
}
|
includes/shortcodes/classes/YasrRankings.php
CHANGED
@@ -50,7 +50,7 @@ class YasrRankings extends YasrShortcode {
|
|
50 |
* @param false $text_position
|
51 |
* @param false $text
|
52 |
*/
|
53 |
-
protected function returnTableOverall(
|
54 |
if ($this->query_highest_rated_overall) {
|
55 |
|
56 |
$this->shortcode_html .= "<table class='yasr-table-chart'>";
|
50 |
* @param false $text_position
|
51 |
* @param false $text
|
52 |
*/
|
53 |
+
protected function returnTableOverall() {
|
54 |
if ($this->query_highest_rated_overall) {
|
55 |
|
56 |
$this->shortcode_html .= "<table class='yasr-table-chart'>";
|
includes/shortcodes/classes/YasrVisitorMultiSet.php
CHANGED
@@ -75,17 +75,17 @@ class YasrVisitorMultiSet extends YasrMultiSet {
|
|
75 |
//check cookie and assign default values
|
76 |
$this->multisetAttributes();
|
77 |
|
78 |
-
$
|
79 |
|
80 |
-
if (
|
81 |
-
$
|
82 |
-
return $this->shortcode_html;
|
83 |
}
|
84 |
|
85 |
$this->shortcode_html .= "<table class='yasr_table_multi_set_shortcode'>";
|
86 |
|
87 |
//print the single rows
|
88 |
-
$this->printMultisetRows($
|
89 |
|
90 |
//Submit row and button
|
91 |
$this->shortcode_html .="<tr>
|
75 |
//check cookie and assign default values
|
76 |
$this->multisetAttributes();
|
77 |
|
78 |
+
$multiset_content = YasrMultiSetData::returnMultisetContent($this->post_id, $this->set_id, true);
|
79 |
|
80 |
+
if ($multiset_content === false) {
|
81 |
+
$string = __('No Set Found with this ID', 'yet-another-stars-rating');
|
82 |
+
return $this->shortcode_html . $string;
|
83 |
}
|
84 |
|
85 |
$this->shortcode_html .= "<table class='yasr_table_multi_set_shortcode'>";
|
86 |
|
87 |
//print the single rows
|
88 |
+
$this->printMultisetRows($multiset_content, true);
|
89 |
|
90 |
//Submit row and button
|
91 |
$this->shortcode_html .="<tr>
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
|
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.5.3
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.5.
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
@@ -181,6 +181,10 @@ If doesn't, you should work on your seo reputation.
|
|
181 |
|
182 |
The full changelog can be found in the plugin's directory. Recent entries:
|
183 |
|
|
|
|
|
|
|
|
|
184 |
= 2.5.3 =
|
185 |
* FIX: in Yet Another Stars Rating: Stats -> Overall Rating only posts with rating > 0 are shown
|
186 |
|
@@ -241,17 +245,5 @@ be used to customize the shortcodes.
|
|
241 |
* TWEAKED: code cleanup
|
242 |
|
243 |
|
244 |
-
= 2.4.3 =
|
245 |
-
* NEW FEATURE: is now possible to show ratings next to the title
|
246 |
-
* FIXED: guten blocks returns error if post_id parameter was set
|
247 |
-
* TWEAKED: added some hooks
|
248 |
-
|
249 |
-
= 2.4.2 =
|
250 |
-
* FIXED: error in gutenberg editor that appear in some circumstances
|
251 |
-
|
252 |
-
= 2.4.1 =
|
253 |
-
* FIXED: minor fix if more yasr_visitor_votes with different differents post_id are used in the same page
|
254 |
-
|
255 |
-
|
256 |
= Additional Info =
|
257 |
See credits.txt file
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.5.3
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.5.4
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
181 |
|
182 |
The full changelog can be found in the plugin's directory. Recent entries:
|
183 |
|
184 |
+
= 2.5.4 =
|
185 |
+
* FIX: yasr_visitor_multiset data didn't save correctly if more than one were used in the same page.
|
186 |
+
|
187 |
+
|
188 |
= 2.5.3 =
|
189 |
* FIX: in Yet Another Stars Rating: Stats -> Overall Rating only posts with rating > 0 are shown
|
190 |
|
245 |
* TWEAKED: code cleanup
|
246 |
|
247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
= Additional Info =
|
249 |
See credits.txt file
|
yet-another-stars-rating.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
-
* Version: 2.5.
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
@@ -76,7 +76,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
76 |
yasr_fs();
|
77 |
// Signal that SDK was initiated.
|
78 |
do_action( 'yasr_fs_loaded' );
|
79 |
-
define( 'YASR_VERSION_NUM', '2.5.
|
80 |
//Plugin absolute path
|
81 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
82 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
+
* Version: 2.5.4
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
76 |
yasr_fs();
|
77 |
// Signal that SDK was initiated.
|
78 |
do_action( 'yasr_fs_loaded' );
|
79 |
+
define( 'YASR_VERSION_NUM', '2.5.5' );
|
80 |
//Plugin absolute path
|
81 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
82 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|