Yasr – Yet Another Stars Rating - Version 0.3.5

Version Description

  • Added a new dark style to better suite dark theme
  • Added a new custom text to show when a non logged user has voted
  • Css minor changes
Download this release

Release Info

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

Code changes from version 0.3.4 to 0.3.5

css/yasr-table-dark.css ADDED
@@ -0,0 +1,45 @@
1
+ .yasr_table_multi_set_shortcode {
2
+ border: 1px solid #ffffff;
3
+ border-spacing: 1px;
4
+ border-collapse: separate;
5
+ margin-top: 10px;
6
+ margin-bottom: 24px;
7
+ width: 100%;
8
+ }
9
+
10
+ .yasr_table_multi_set_shortcode td {
11
+ padding: 8px;
12
+ }
13
+
14
+ .yasr_table_multi_set_shortcode tr:nth-child(odd) {
15
+ background: #292929;
16
+ }
17
+ /* Define the background color for all the EVEN background rows */
18
+ .yasr_table_multi_set_shortcode tr:nth-child(even) {
19
+ background: #161616;
20
+ }
21
+
22
+
23
+ .yasr-multi-set-name-field {
24
+ color: #ffffff;
25
+ }
26
+
27
+
28
+ .yasr-top-10-highest-rated {
29
+ border-spacing: 1px;
30
+ margin-top: 10px;
31
+ margin-bottom: 24px;
32
+ width: 100%;
33
+ }
34
+
35
+ .yasr-top-10-highest-rated td {
36
+ padding: 8px;
37
+ }
38
+
39
+ .yasr-top-10-highest-rated tr:nth-child(odd) {
40
+ background: #292929;
41
+ }
42
+ /* Define the background color for all the EVEN background rows */
43
+ .yasr-top-10-highest-rated tr:nth-child(even) {
44
+ background: #161616;
45
+ }
css/yasr-table-light.css ADDED
@@ -0,0 +1,45 @@
1
+ .yasr_table_multi_set_shortcode {
2
+ border-collapse: separate;
3
+ border-spacing: 1px;
4
+ border-width: 1px 0px 0px 1px;
5
+ border-color: #ddd;
6
+ margin-top: 10px;
7
+ margin-bottom: 24px;
8
+ width: 100%;
9
+ }
10
+
11
+ .yasr_table_multi_set_shortcode td {
12
+ padding: 8px;
13
+ }
14
+
15
+ .yasr_table_multi_set_shortcode tr:nth-child(odd) {
16
+ background: #FFFFec;
17
+ }
18
+ /* Define the background color for all the EVEN background rows */
19
+ .yasr_table_multi_set_shortcode tr:nth-child(even) {
20
+ background: #FFFFFF;
21
+ }
22
+
23
+ .yasr-multi-set-name-field {
24
+ color: #555;
25
+ }
26
+
27
+
28
+ .yasr-top-10-highest-rated {
29
+ border-spacing: 1px;
30
+ margin-top: 10px;
31
+ margin-bottom: 24px;
32
+ width: 100%;
33
+ }
34
+
35
+ .yasr-top-10-highest-rated td {
36
+ padding: 8px;
37
+ }
38
+
39
+ .yasr-top-10-highest-rated tr:nth-child(odd) {
40
+ background: #FFFFec;
41
+ }
42
+ /* Define the background color for all the EVEN background rows */
43
+ .yasr-top-10-highest-rated tr:nth-child(even) {
44
+ background: #FFFFFF;
45
+ }
css/yasr.css CHANGED
@@ -68,6 +68,12 @@ h2.nav-tab-wrapper, h3.nav-tab-wrapper {
68
}
69
}
70
71
#yasr-snippet-explained {
72
border: 2px dashed #CCC;
73
padding: 15px;
@@ -293,23 +299,3 @@ h2.nav-tab-wrapper, h3.nav-tab-wrapper {
293
display: inline-block;
294
vertical-align: top;
295
}
296
-
297
- .yasr_table_multi_set_shortcode tr:nth-child(odd) {
298
- background: #FFFFec;
299
- }
300
- /* Define the background color for all the EVEN background rows */
301
- .yasr_table_multi_set_shortcode tr:nth-child(even) {
302
- background: #FFFFFF;
303
- }
304
-
305
- .yasr-multi-set-name-field {
306
- color: #555;
307
- }
308
-
309
- .yasr-top-10-highest-rated tr:nth-child(odd) {
310
- background: #FFFFec;
311
- }
312
- /* Define the background color for all the EVEN background rows */
313
- .yasr-top-10-highest-rated tr:nth-child(even) {
314
- background: #FFFFFF;
315
- }
68
}
69
}
70
71
+ #yasr-color-scheme-preview {
72
+ border: 2px dashed #CCC;
73
+ padding: 15px;
74
+ margin: 10px;
75
+ }
76
+
77
#yasr-snippet-explained {
78
border: 2px dashed #CCC;
79
padding: 15px;
299
display: inline-block;
300
vertical-align: top;
301
}
img/dark-multi-set.png ADDED
Binary file
lib/yasr-ajax-functions.php CHANGED
@@ -851,8 +851,23 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
851
exit();
852
}
853
854
- echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
855
- <br />" . __("Average Rating", "yasr") . " $average_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")<strong><br />" . __("You've already voted this article with $rating", "yasr") . "</strong>";
856
857
858
851
exit();
852
}
853
854
+
855
+ //Check if user specifyed a custom text to display when a vistor har rated
856
+ $option = get_option('yasr_general_options');
857
+
858
+ if($option['text_before_stars'] == 1 && $option['custom_text_user_voted'] != '') {
859
+
860
+ echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
861
+ <br />" . __("Average Rating", "yasr") . " $average_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")<strong><br /> $option[custom_text_user_voted] </strong>";
862
+
863
+ }
864
+
865
+ else {
866
+
867
+ echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
868
+ <br />" . __("Average Rating", "yasr") . " $average_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")<strong><br />" . __("You've already voted this article with $rating", "yasr") . "</strong>";
869
+
870
+ }
871
872
873
lib/yasr-db-functions.php CHANGED
@@ -85,6 +85,7 @@ function yasr_install() {
85
$option['text_before_stars'] = 0;
86
$option['snippet'] = 'overall_rating';
87
$option['allowed_user'] = 'allow_anonymous';
88
89
add_option("yasr_general_options", $option); //Write here the default value if there is not option
90
85
$option['text_before_stars'] = 0;
86
$option['snippet'] = 'overall_rating';
87
$option['allowed_user'] = 'allow_anonymous';
88
+ $option['scheme_color'] = 'light';
89
90
add_option("yasr_general_options", $option); //Write here the default value if there is not option
91
lib/yasr-functions.php CHANGED
@@ -12,6 +12,26 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
12
wp_enqueue_style( 'rateitcss', YASR_CSS_DIR . 'rateit.css', FALSE, NULL, 'all' );
13
wp_enqueue_style( 'rateitbigstars', YASR_CSS_DIR . 'bigstars.css', array('rateitcss'), NULL, 'all' );
14
wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', array('rateitcss'), NULL, 'all' );
15
wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.20', TRUE );
16
wp_enqueue_script( 'cookie', YASR_JS_DIR . 'jquery.cookie.min.js' , array('jquery', 'rateit'), '1.4.0', TRUE );
17
}
@@ -579,4 +599,4 @@ add_action('init', 'yasr_shortcode_button_init');
579
//Add the button ID to the $button array
580
$buttons[] = "yasr_button";
581
return $buttons;
582
- }
12
wp_enqueue_style( 'rateitcss', YASR_CSS_DIR . 'rateit.css', FALSE, NULL, 'all' );
13
wp_enqueue_style( 'rateitbigstars', YASR_CSS_DIR . 'bigstars.css', array('rateitcss'), NULL, 'all' );
14
wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', array('rateitcss'), NULL, 'all' );
15
+
16
+ $chosen_color=NULL;
17
+
18
+ $chosen_color = get_option( 'yasr_general_options' );
19
+
20
+ //default color
21
+ if(!$chosen_color || !$chosen_color['scheme_color'] ) {
22
+ $chosen_color = array();
23
+ $chosen_color['scheme_color'] = 'light';
24
+ }
25
+
26
+ //If choosen is light or not dark (force to be default)
27
+ if ($chosen_color['scheme_color'] === 'light' || $chosen_color['scheme_color'] != 'dark' ) {
28
+ wp_enqueue_style( 'yasrcsslightscheme', YASR_CSS_DIR . 'yasr-table-light.css', array('yasrcss'), NULL, 'all' );
29
+ }
30
+
31
+ elseif ($chosen_color['scheme_color'] === 'dark') {
32
+ wp_enqueue_style( 'yasrcssdarkscheme', YASR_CSS_DIR . 'yasr-table-dark.css', array('yasrcss'), NULL, 'all' );
33
+ }
34
+
35
wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.20', TRUE );
36
wp_enqueue_script( 'cookie', YASR_JS_DIR . 'jquery.cookie.min.js' , array('jquery', 'rateit'), '1.4.0', TRUE );
37
}
599
//Add the button ID to the $button array
600
$buttons[] = "yasr_button";
601
return $buttons;
602
+ }
lib/yasr-settings-functions.php CHANGED
@@ -23,12 +23,14 @@
23
if ($option && $option['text_before_stars']==0) {
24
$option['text_before_overall']='';
25
$option['text_before_visitor_rating']='';
26
}
27
28
add_settings_section( 'yasr_general_options_section_id', __('General settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
29
add_settings_field( 'yasr_use_auto_insert_id', __('Use auto insert?', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
30
add_settings_field( 'yasr_show_overall_in_loop', __('Show overall rating in Home Page?', 'yasr'), 'yasr_show_overall_in_loop_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
31
- add_settings_field( 'yasr_custom_text', __('Insert custom text to show before stars', 'yasr'), 'yasr_custom_text_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
32
add_settings_field( 'yasr_allow_only_logged_in_id', __('Allow only logged in user to vote?', 'yasr'), 'yasr_allow_only_logged_in_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
33
add_settings_field( 'yasr_choose_snippet_id', __('Which rich snippets do you want to use?', 'yasr'), 'yasr_choose_snippet_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
34
@@ -162,6 +164,11 @@
162
163
<input type='text' name='yasr_general_options[text_before_visitor_rating]' class='yasr-general-options-text-before' value='<?php echo ("$option[text_before_visitor_rating]"); ?>' maxlength="40"/>
164
<?php _e('Custom text to display before visitor rating', 'yasr')?>
165
166
167
<p>&nbsp;</p>
@@ -172,6 +179,44 @@
172
}
173
174
175
function yasr_allow_only_logged_in_callback($option) {
176
177
?>
23
if ($option && $option['text_before_stars']==0) {
24
$option['text_before_overall']='';
25
$option['text_before_visitor_rating']='';
26
+ $option['custom_text_user_voted']='';
27
}
28
29
add_settings_section( 'yasr_general_options_section_id', __('General settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
30
add_settings_field( 'yasr_use_auto_insert_id', __('Use auto insert?', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
31
add_settings_field( 'yasr_show_overall_in_loop', __('Show overall rating in Home Page?', 'yasr'), 'yasr_show_overall_in_loop_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
32
+ add_settings_field( 'yasr_custom_text', __('Insert custom text to show before / after stars', 'yasr'), 'yasr_custom_text_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
33
+ add_settings_field( 'yasr_color_scheme', __('Which color scheme do you want to use?', 'yasr') , 'yasr_color_scheme_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
34
add_settings_field( 'yasr_allow_only_logged_in_id', __('Allow only logged in user to vote?', 'yasr'), 'yasr_allow_only_logged_in_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
35
add_settings_field( 'yasr_choose_snippet_id', __('Which rich snippets do you want to use?', 'yasr'), 'yasr_choose_snippet_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
36
164
165
<input type='text' name='yasr_general_options[text_before_visitor_rating]' class='yasr-general-options-text-before' value='<?php echo ("$option[text_before_visitor_rating]"); ?>' maxlength="40"/>
166
<?php _e('Custom text to display before visitor rating', 'yasr')?>
167
+
168
+ <br /> <br />
169
+
170
+ <input type='text' name='yasr_general_options[custom_text_user_voted]' class='yasr-general-options-text-before' value='<?php echo ("$option[custom_text_user_voted]"); ?>' maxlength="60"/>
171
+ <?php _e('Custom text to display when a non logged user has already rated', 'yasr')?>
172
173
174
<p>&nbsp;</p>
179
}
180
181
182
+ function yasr_color_scheme_callback($option) {
183
+
184
+ ?>
185
+
186
+ <input type='radio' name='yasr_general_options[scheme_color]' value='light' class='yasr-general-options-scheme-color' <?php if ($option['scheme_color']==='light') echo " checked=\"checked\" "; ?> />
187
+ <?php _e('Light', 'yasr')?>
188
+
189
+ &nbsp;&nbsp;&nbsp;
190
+
191
+ <input type='radio' name='yasr_general_options[scheme_color]' value='dark' class='yasr-general-options-scheme-color' <?php if ($option['scheme_color']==='dark') echo " checked=\"checked\" "; ?> />
192
+ <?php _e('Dark', 'yasr')?>
193
+ <br />
194
+
195
+ <br />
196
+
197
+ <a href="#" id="yasr-color-scheme-preview-link"><?php _e("Preview", "yasr") ?></a>
198
+
199
+ <div id="yasr-color-scheme-preview" style="display:none">
200
+ <?php
201
+
202
+ _e("Light theme", "yasr");
203
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr-multi-set.png>";
204
+
205
+ echo "<br /> <br />";
206
+
207
+ _e("Dark Theme", "yasr");
208
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "/dark-multi-set.png>";
209
+ ?>
210
+ </div>
211
+
212
+ <p>&nbsp;</p>
213
+
214
+ <hr>
215
+
216
+ <?php
217
+ }
218
+
219
+
220
function yasr_allow_only_logged_in_callback($option) {
221
222
?>
lib/yasr-shortcode-functions.php CHANGED
@@ -358,10 +358,10 @@ function shortcode_multi_set_callback( $atts ) {
358
WHERE parent_set_id=$setid
359
ORDER BY field_id ASC");
360
361
- $shortcode_html="<table>";
362
363
foreach ($set_name as $set_content) {
364
- $shortcode_html .= "<tr> <td>$set_content->name </td>
365
<td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"0\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
366
</tr>";
367
}
358
WHERE parent_set_id=$setid
359
ORDER BY field_id ASC");
360
361
+ $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
362
363
foreach ($set_name as $set_content) {
364
+ $shortcode_html .= "<tr> <td><span class=\"yasr-multi-set-name-field\">$set_content->name </span></td>
365
<td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"0\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
366
</tr>";
367
}
readme.txt CHANGED
@@ -3,7 +3,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
Tags: Rating, Review, Star, Snippet, Rich snippet, Schema, Schema.org, Serp
4
Requires at least: 3.5
5
Tested up to: 3.9.1
6
- Stable tag: 0.3.4
7
License: GPL2
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
@@ -48,6 +48,11 @@ If with gd-star-rating you're using a different number of stars from the default
48
49
== Changelog ==
50
51
= 0.3.4 =
52
* In settings page is now possible add some custom text to make appear before "Overall Rating" or "Visitor's Rating" are showed
53
* In settings page is now possible to show "Overall Rating" only in the post / page or even in Home page, Archive Page, etc.
3
Tags: Rating, Review, Star, Snippet, Rich snippet, Schema, Schema.org, Serp
4
Requires at least: 3.5
5
Tested up to: 3.9.1
6
+ Stable tag: 0.3.5
7
License: GPL2
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
48
49
== Changelog ==
50
51
+ = 0.3.5 =
52
+ * Added a new dark style to better suite dark theme
53
+ * Added a new custom text to show when a non logged user has voted
54
+ * Css minor changes
55
+
56
= 0.3.4 =
57
* In settings page is now possible add some custom text to make appear before "Overall Rating" or "Visitor's Rating" are showed
58
* In settings page is now possible to show "Overall Rating" only in the post / page or even in Home page, Archive Page, etc.
yasr-settings-page.php CHANGED
@@ -309,6 +309,12 @@ if ( !current_user_can( 'manage_options' ) ) {
309
jQuery('.yasr-general-options-text-before').prop('disabled', true);
310
});
311
312
jQuery('#yasr-snippet-explained-link').on('click', function () {
313
jQuery('#yasr-snippet-explained').toggle('slow');
314
return false; // prevent default click action from happening!
309
jQuery('.yasr-general-options-text-before').prop('disabled', true);
310
});
311
312
+ jQuery('#yasr-color-scheme-preview-link').on('click', function () {
313
+ jQuery('#yasr-color-scheme-preview').toggle('slow');
314
+ return false; // prevent default click action from happening!
315
+ preventDefault(); // prevent default click action from happening!
316
+ });
317
+
318
jQuery('#yasr-snippet-explained-link').on('click', function () {
319
jQuery('#yasr-snippet-explained').toggle('slow');
320
return false; // prevent default click action from happening!
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: Rating system with rich snippets
6
- * Version: 0.3.4
7
* Author: Dario Curvino
8
* Author URI: http://profiles.wordpress.org/dudo/
9
* License: GPL2
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
28
*/
29
30
31
- define('YASR_VERSION_NUM', '0.3.4');
32
33
//Plugin absolute path
34
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -72,42 +72,6 @@ if (!$version_installed ) {
72
73
}
74
75
- // If user is using a version < 0.3.0 import option
76
-
77
- if ($version_installed && $version_installed < '0.3.0' ) {
78
-
79
- $old_options = get_option ( 'yasr_auto_insert_options' );
80
-
81
- if ($old_options && $old_options['enabled']==0){
82
-
83
- $new_options = array(
84
- "auto_insert_enabled" => $old_options['enabled'],
85
- "allowed_user" => 'allow_anonymous', //This is not imported, it's just the default value
86
- "snippet" =>$old_options['snippet']
87
- );
88
-
89
- }
90
-
91
- elseif ($old_options && $old_options['enabled']==1) {
92
-
93
- $new_options = array(
94
- "auto_insert_enabled" => $old_options['enabled'],
95
- "auto_insert_what" => $old_options['what'],
96
- "auto_insert_where" => $old_options['where'],
97
- "allowed_user" => 'allow_anonymous', //This is not imported, it's just the default value
98
- "snippet" =>$old_options['snippet']
99
- );
100
- }
101
-
102
- $options_added=add_option("yasr_general_options", $new_options);
103
-
104
- if ($options_added) {
105
- delete_option('yasr_auto_insert_options');
106
- }
107
-
108
- } //End if (!$version_installed || $version_installed < '0.3.0' )
109
-
110
-
111
global $wpdb;
112
113
define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
@@ -138,7 +102,6 @@ if ($version_installed && $version_installed < '0.3.4') {
138
139
}
140
141
-
142
update_option('yasr-version', YASR_VERSION_NUM);
143
144
?>
3
* Plugin Name: Yet Another Stars Rating
4
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
* Description: Rating system with rich snippets
6
+ * Version: 0.3.5
7
* Author: Dario Curvino
8
* Author URI: http://profiles.wordpress.org/dudo/
9
* License: GPL2
28
*/
29
30
31
+ define('YASR_VERSION_NUM', '0.3.5');
32
33
//Plugin absolute path
34
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
72
73
}
74
75
global $wpdb;
76
77
define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
102
103
}
104
105
update_option('yasr-version', YASR_VERSION_NUM);
106
107
?>