Yasr – Yet Another Stars Rating - Version 1.2.4

Version Description

  • FIXED: Settings lost on update
  • FIXED: error if logo image are not set
  • FIXED: it was passible to rate twice a same field in a yasr_visitor_mutliset
  • Minor changes
Download this release

Release Info

Developer Dudo
Plugin Icon 128x128 Yasr – Yet Another Stars Rating
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

js/yasr-admin.js CHANGED
@@ -129,7 +129,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
129
}) ;
130
131
return false;
132
- preventDefault(); // same thing as above
133
134
});
135
@@ -154,7 +153,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
154
}) ;
155
156
return false;
157
- preventDefault();
158
159
});
160
@@ -240,7 +238,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
240
});
241
242
return false; // prevent default click action from happening!
243
- e.preventDefault(); // same thing as above
244
245
});
246
@@ -499,7 +496,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
499
});
500
501
return false; // prevent default click action from happening!
502
- preventDefault(); // same thing as above
503
504
});
505
129
}) ;
130
131
return false;
132
133
});
134
153
}) ;
154
155
return false;
156
157
});
158
238
});
239
240
return false; // prevent default click action from happening!
241
242
});
243
496
});
497
498
return false; // prevent default click action from happening!
499
500
});
501
lib/yasr-ajax-functions.php CHANGED
@@ -1507,7 +1507,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1507
1508
$array_error = array();
1509
1510
- foreach ($rating as $rating_values) {
1511
1512
$id_field = $rating_values['field'];
1513
$rating = $rating_values['rating'];
1507
1508
$array_error = array();
1509
1510
+ //clean array, so if an user rate same field twice, take only the last rating
1511
+ $cleaned_array = yasr_unique_multidim_array($rating, 'field');
1512
+
1513
+ foreach ($cleaned_array as $rating_values) {
1514
1515
$id_field = $rating_values['field'];
1516
$rating = $rating_values['rating'];
lib/yasr-functions.php CHANGED
@@ -346,23 +346,37 @@ add_filter('the_content', 'yasr_add_schema');
346
347
$date_modified = get_the_modified_date('c');
348
349
- //if exists featuread image get the url
350
- if (has_post_thumbnail() ) {
351
352
- $post_image_url = wp_get_attachment_url(get_post_thumbnail_id());
353
354
}
355
356
- //if doesn't exists get the site logo url
357
else {
358
359
- $post_image_url = YASR_BLOGPOSTING_ORGANIZATION_LOGO;
360
361
}
362
363
- $logo_image_size = @getimagesize(YASR_BLOGPOSTING_ORGANIZATION_LOGO);
364
365
- $post_image_size = @getimagesize($post_image_url);
366
367
if ($review_choosen == "Product") {
368
@@ -413,7 +427,7 @@ add_filter('the_content', 'yasr_add_schema');
413
"name" => YASR_BLOGPOSTING_ORGANIZATION_NAME,
414
"logo" => array(
415
"@type" => "ImageObject",
416
- "url" => YASR_BLOGPOSTING_ORGANIZATION_LOGO,
417
"width" => $logo_image_size[0],
418
"height" => $logo_image_size[1]
419
)
@@ -687,7 +701,7 @@ function yasr_wp_rocket_support($post_id) {
687
function yasr_setcookie($cookiename, $value) {
688
689
if (!$value || !$cookiename) {
690
- exit();
691
}
692
693
setcookie( $cookiename, $value, time() + 31536000, COOKIEPATH, COOKIE_DOMAIN );
@@ -743,4 +757,44 @@ function yasr_get_ip() {
743
744
}
745
746
?>
346
347
$date_modified = get_the_modified_date('c');
348
349
+ if (defined('YASR_BLOGPOSTING_ORGANIZATION_LOGO')) {
350
351
+ $post_image_url = YASR_BLOGPOSTING_ORGANIZATION_LOGO;
352
+
353
+ $post_image_size = @getimagesize($post_image_url); //the @ should be useless, just to be safe
354
+
355
+ $logo_image_size = @getimagesize(YASR_BLOGPOSTING_ORGANIZATION_LOGO); //the @ should be useless, just to be safe
356
357
}
358
359
else {
360
361
+ $post_image_url = '';
362
+
363
+ $post_image_size[0] = 0;
364
+ $post_image_size[1] = 0;
365
+
366
+ $logo_image_size[0] = 0;
367
+ $logo_image_size[1] = 0;
368
369
}
370
371
+ //if exists featuread image get the url and overwrite the variable
372
+ if (has_post_thumbnail() ) {
373
+
374
+ $post_image_url = wp_get_attachment_url(get_post_thumbnail_id());
375
+
376
+ $post_image_size = @getimagesize($post_image_url); //the @ should be useless, just to be safe
377
+
378
+ }
379
380
381
if ($review_choosen == "Product") {
382
427
"name" => YASR_BLOGPOSTING_ORGANIZATION_NAME,
428
"logo" => array(
429
"@type" => "ImageObject",
430
+ "url" => $post_image_url,
431
"width" => $logo_image_size[0],
432
"height" => $logo_image_size[1]
433
)
701
function yasr_setcookie($cookiename, $value) {
702
703
if (!$value || !$cookiename) {
704
+ exit('Error setting yasr cookie');
705
}
706
707
setcookie( $cookiename, $value, time() + 31536000, COOKIEPATH, COOKIE_DOMAIN );
757
758
}
759
760
+
761
+
762
+
763
+ /*function to remove duplicate in an array for a specific key
764
+ Taken value: array to search, key
765
+ */
766
+
767
+
768
+
769
+ function yasr_unique_multidim_array($array, $key) {
770
+
771
+ $temp_array = array();
772
+ $i = 0;
773
+
774
+ //creo un array vuoto che conterrà solo gli indici
775
+ $key_array = array();
776
+
777
+ foreach($array as $val) {
778
+
779
+ $result_search_array = array_search($val[$key], $key_array);
780
+
781
+ $key_array[$i] = $val[$key];
782
+ $temp_array[$i] = $val;
783
+
784
+ //if result is found
785
+ if ($result_search_array !== FALSE) {
786
+
787
+ unset($key_array[$result_search_array], $temp_array[$result_search_array]);
788
+
789
+ }
790
+
791
+ $i++;
792
+
793
+ }
794
+
795
+ return $temp_array;
796
+
797
+ }
798
+
799
+
800
?>
lib/yasr-shortcode-functions.php CHANGED
@@ -1048,7 +1048,8 @@ function yasr_highest_rated_visitor_multi_set_callback () {
1048
1049
global $wpdb;
1050
1051
- $shortcode_html = '';
1052
1053
$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
1054
FROM " . YASR_MULTI_SET_VALUES_TABLE . " AS v, " . YASR_MULTI_SET_FIELDS_TABLE . " AS f
@@ -1063,7 +1064,7 @@ function yasr_highest_rated_visitor_multi_set_callback () {
1063
1064
if (!isset($field_name) || $field_name != $results->field_name ) {
1065
1066
- $shortcode_html .= "<h3> $results->field_name </h3>";
1067
1068
}
1069
@@ -1072,15 +1073,22 @@ function yasr_highest_rated_visitor_multi_set_callback () {
1072
1073
$average = round($results->average, 1);
1074
1075
- $shortcode_html .= "<a href=\"$link\">$title</a> ";
1076
- $shortcode_html .= $average . ", " . sprintf(__('based on %d votes', 'yet-another-stars-rating'), $results->number_of_votes);
1077
- $shortcode_html .= "<br />";
1078
1079
$field_name = $results->field_name;
1080
1081
}
1082
1083
-
1084
1085
return $shortcode_html;
1086
1048
1049
global $wpdb;
1050
1051
+ $shortcode_html = "
1052
+ <table class=\"yasr-table-chart\">";
1053
1054
$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
1055
FROM " . YASR_MULTI_SET_VALUES_TABLE . " AS v, " . YASR_MULTI_SET_FIELDS_TABLE . " AS f
1064
1065
if (!isset($field_name) || $field_name != $results->field_name ) {
1066
1067
+ $shortcode_html .= "<tr><td colspan=\"2\"><h3> $results->field_name</h3></td></tr>";
1068
1069
}
1070
1073
1074
$average = round($results->average, 1);
1075
1076
+ $shortcode_html .= "<tr>
1077
+ <td>
1078
+ <a href=\"$link\">$title</a>
1079
+ </td>
1080
+ <td>
1081
+ <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>
1082
+ $average" . sprintf(__('based on %d votes', 'yet-another-stars-rating'), $results->number_of_votes); "
1083
+ </td>
1084
+ </tr>";
1085
+
1086
1087
$field_name = $results->field_name;
1088
1089
}
1090
1091
+ $shortcode_html .= "</table>";
1092
1093
return $shortcode_html;
1094
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.4.2
7
- Stable tag: 1.2.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
@@ -98,7 +98,7 @@ When a visitor (logged in or not) rates a post/page, his rating is stored in the
98
[Demo page for Rankings](https://yetanotherstarsrating.com/yasr-rankings/)
99
100
= Wait, wait! Do I need to keep in mind all this shortcode? =
101
- Of course not: you can easily add it on the visual editor just by clicking on the yellow star and then choose what to insert.
102
103
104
@@ -111,6 +111,12 @@ Of course not: you can easily add it on the visual editor just by clicking on th
111
112
== Changelog ==
113
114
= 1.2.3 =
115
* TWEAKED: image is avaible for recipe tipe too
116
* FIXED: inverted width and height on rich snippets
4
Requires at least: 4.3.0
5
Contributors: Dudo
6
Tested up to: 4.4.2
7
+ Stable tag: 1.2.4
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
98
[Demo page for Rankings](https://yetanotherstarsrating.com/yasr-rankings/)
99
100
= Wait, wait! Do I need to keep in mind all this shortcode? =
101
+ Of course not: you can easily add it on the visual editor just by clicking the "Yasr Shortcode" button just above the editor
102
103
104
111
112
== Changelog ==
113
114
+ = 1.2.4 =
115
+ * FIXED: Settings lost on update
116
+ * FIXED: error if logo image are not set
117
+ * FIXED: it was passible to rate twice a same field in a yasr_visitor_mutliset
118
+ * Minor changes
119
+
120
= 1.2.3 =
121
* TWEAKED: image is avaible for recipe tipe too
122
* FIXED: inverted width and height on rich snippets
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.2.3
7
* Author: Dario Curvino
8
* Author URI: https://yetanotherstarsrating.com/
9
* Text Domain: yet-another-stars-rating
@@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
32
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
34
35
- define('YASR_VERSION_NUM', '1.2.3');
36
37
//Plugin relative path
38
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -59,6 +59,8 @@ define ("YASR_IMG_DIR", plugins_url() .'/'. YASR_RELATIVE_PATH . '/img/');
59
//Get general options
60
$stored_options = get_option( 'yasr_general_options' );
61
62
define ("YASR_AUTO_INSERT_ENABLED", $stored_options['auto_insert_enabled']);
63
64
if ( YASR_AUTO_INSERT_ENABLED == 1 ) {
@@ -73,6 +75,7 @@ if ( YASR_AUTO_INSERT_ENABLED == 1 ) {
73
74
//Avoid undefined index
75
else {
76
define ("YASR_AUTO_INSERT_WHAT", NULL);
77
define ("YASR_AUTO_INSERT_WHERE", NULL);
78
define ("YASR_AUTO_INSERT_SIZE", NULL);
@@ -98,8 +101,33 @@ define ("YASR_VISITORS_STATS", $stored_options['visitors_stats']);
98
define ("YASR_ALLOWED_USER", $stored_options['allowed_user']);
99
define ("YASR_SNIPPET", $stored_options['snippet']);
100
define ("YASR_ITEMTYPE", $stored_options['snippet_itemtype']);
101
- define ("YASR_BLOGPOSTING_ORGANIZATION_NAME", $stored_options['blogposting_organization_name']);
102
- define ("YASR_BLOGPOSTING_ORGANIZATION_LOGO", $stored_options['blogposting_organization_logo']);
103
define ("YASR_METABOX_OVERALL_RATING", $stored_options['metabox_overall_rating']);
104
105
@@ -214,6 +242,8 @@ function yasr_update_version() {
214
215
global $version_installed;
216
217
//Remove end Sept 2016
218
if ($version_installed && $version_installed < '1.2.2') {
219
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.2.4
7
* Author: Dario Curvino
8
* Author URI: https://yetanotherstarsrating.com/
9
* Text Domain: yet-another-stars-rating
32
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
34
35
+ define('YASR_VERSION_NUM', '1.2.4');
36
37
//Plugin relative path
38
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
59
//Get general options
60
$stored_options = get_option( 'yasr_general_options' );
61
62
+ global $stored_options;
63
+
64
define ("YASR_AUTO_INSERT_ENABLED", $stored_options['auto_insert_enabled']);
65
66
if ( YASR_AUTO_INSERT_ENABLED == 1 ) {
75
76
//Avoid undefined index
77
else {
78
+
79
define ("YASR_AUTO_INSERT_WHAT", NULL);
80
define ("YASR_AUTO_INSERT_WHERE", NULL);
81
define ("YASR_AUTO_INSERT_SIZE", NULL);
101
define ("YASR_ALLOWED_USER", $stored_options['allowed_user']);
102
define ("YASR_SNIPPET", $stored_options['snippet']);
103
define ("YASR_ITEMTYPE", $stored_options['snippet_itemtype']);
104
+
105
+ if (isset($stored_options['blogposting_organization_name'])) {
106
+
107
+ if (filter_var($stored_options['blogposting_organization_name'], FILTER_VALIDATE_URL) === FALSE) {
108
+
109
+ define ("YASR_BLOGPOSTING_ORGANIZATION_NAME", $stored_options['blogposting_organization_name']);
110
+
111
+ }
112
+
113
+ else {
114
+
115
+ define ("YASR_BLOGPOSTING_ORGANIZATION_NAME", '');
116
+
117
+ }
118
+
119
+ }
120
+
121
+ if (isset($stored_options['blogposting_organization_logo'])) {
122
+
123
+ if (filter_var($stored_options['blogposting_organization_logo'], FILTER_VALIDATE_URL) === FALSE) {
124
+
125
+ define ("YASR_BLOGPOSTING_ORGANIZATION_LOGO", $stored_options['blogposting_organization_logo']);
126
+
127
+ }
128
+
129
+ }
130
+
131
define ("YASR_METABOX_OVERALL_RATING", $stored_options['metabox_overall_rating']);
132
133
242
243
global $version_installed;
244
245
+ global $stored_options;
246
+
247
//Remove end Sept 2016
248
if ($version_installed && $version_installed < '1.2.2') {
249