Yasr – Yet Another Stars Rating - Version 1.0.6

Version Description

  • Added a new filter hook on microdata and jsonld info
  • Fixed php notice
Download this release

Release Info

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

Code changes from version 1.0.5 to 1.0.6

css/yasr-admin.css CHANGED
@@ -321,6 +321,7 @@ div.bigstars .rateit-selected
321
margin-left: 10px;
322
}
323
324
/*** Rules for import data from gd star rating ***/
325
326
.yasr-result-step-1{
321
margin-left: 10px;
322
}
323
324
+
325
/*** Rules for import data from gd star rating ***/
326
327
.yasr-result-step-1{
lib/yasr-admin-actions.php CHANGED
@@ -28,6 +28,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
28
29
}
30
31
//add tab on settings page
32
add_action( 'yasr_add_settings_tab', 'yasr_free_settings_tab');
33
@@ -41,7 +44,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
41
}
42
43
44
- //content of the tab above
45
add_action( 'yasr_settings_check_active_tab', 'yasr_free_check_active_tab' );
46
47
function yasr_free_check_active_tab ($active_tab) {
@@ -58,4 +61,25 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
58
59
}
60
61
?>
28
29
}
30
31
+
32
+ /****** Settings Pages ******/
33
+
34
//add tab on settings page
35
add_action( 'yasr_add_settings_tab', 'yasr_free_settings_tab');
36
44
}
45
46
47
+ //content of the bottom in the settings tab
48
add_action( 'yasr_settings_check_active_tab', 'yasr_free_check_active_tab' );
49
50
function yasr_free_check_active_tab ($active_tab) {
61
62
}
63
64
+
65
+ /****** End Settings Pages ******/
66
+
67
+ //Always return False
68
+ add_filter( 'yasr_filter_schema_microdata', 'yasr_filter_schema_microdata_callback');
69
+
70
+ function yasr_filter_schema_microdata_callback () {
71
+
72
+ return FALSE;
73
+
74
+ }
75
+
76
+ //Always return False
77
+ add_filter( 'yasr_filter_schema_jsonld', 'yasr_filter_schema_jsonld_callback');
78
+
79
+ function yasr_filter_schema_jsonld_callback () {
80
+
81
+ return FALSE;
82
+
83
+ }
84
+
85
?>
lib/yasr-ajax-functions.php CHANGED
@@ -169,9 +169,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
169
$review_type = $wpdb->update(
170
YASR_VOTES_TABLE,
171
array (
172
- 'review_type' => $reviewtype
173
),
174
- array('post_id' => $post_id),
175
array('%s'),
176
array('%d')
177
);
@@ -179,7 +179,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
179
//if fail there is no row so make new one
180
if($review_type === 0) {
181
182
- $review_type = $wpdb->insert(
183
YASR_VOTES_TABLE,
184
array (
185
'post_id' => $post_id,
169
$review_type = $wpdb->update(
170
YASR_VOTES_TABLE,
171
array (
172
+ 'review_type' => $reviewtype //data
173
),
174
+ array('post_id' => $post_id), //where
175
array('%s'),
176
array('%d')
177
);
179
//if fail there is no row so make new one
180
if($review_type === 0) {
181
182
+ $review_type = $wpdb->replace(
183
YASR_VOTES_TABLE,
184
array (
185
'post_id' => $post_id,
lib/yasr-functions.php CHANGED
@@ -299,6 +299,14 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
299
300
$review_choosen = yasr_get_snippet_type();
301
302
if (YASR_SNIPPET == 'overall_rating') {
303
304
$overall_rating=yasr_get_overall_rating();
@@ -412,6 +420,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
412
413
}
414
415
if ( is_singular() && is_main_query() && !is_404() ) {
416
return $content . $schema;
417
}
@@ -435,15 +444,23 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
435
436
$rich_snippet["@context"] = "http://schema.org/";
437
438
- if (YASR_SNIPPET == 'overall_rating') {
439
440
- $overall_rating=yasr_get_overall_rating();
441
442
- if($overall_rating && $overall_rating != '-1' && $overall_rating != '0.0') {
443
444
- if(is_singular() && is_main_query() ) {
445
446
- global $post;
447
448
$author = get_the_author();
449
@@ -605,6 +622,21 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
605
606
$review_type_choosen = yasr_get_snippet_type();
607
608
?>
609
610
<select id="yasr-choose-reviews-types-list">
@@ -615,7 +647,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
615
616
foreach ($review_type as $type) {
617
618
- if ($type == $review_type_choosen) {
619
620
echo "<option value=\"$i\" selected>$type</option>";
621
299
300
$review_choosen = yasr_get_snippet_type();
301
302
+ $schema = apply_filters( 'yasr_filter_schema_microdata', $review_choosen );
303
+
304
+ if ($schema) {
305
+
306
+ return $content . $schema;
307
+
308
+ }
309
+
310
if (YASR_SNIPPET == 'overall_rating') {
311
312
$overall_rating=yasr_get_overall_rating();
420
421
}
422
423
+
424
if ( is_singular() && is_main_query() && !is_404() ) {
425
return $content . $schema;
426
}
444
445
$rich_snippet["@context"] = "http://schema.org/";
446
447
+ $schema = apply_filters( 'yasr_filter_schema_jsonld', $review_choosen );
448
449
+ if ($schema) {
450
451
+ return $content . $script_type . $schema . $end_script_type;
452
453
+ }
454
455
+ if (YASR_SNIPPET == 'overall_rating') {
456
+
457
+ $overall_rating=yasr_get_overall_rating();
458
+
459
+ if($overall_rating && $overall_rating != '-1' && $overall_rating != '0.0') {
460
+
461
+ if(is_singular() && is_main_query() ) {
462
+
463
+ global $post;
464
465
$author = get_the_author();
466
622
623
$review_type_choosen = yasr_get_snippet_type();
624
625
+ switch ($review_type_choosen) {
626
+ case 'Product':
627
+ $review_type_choosen = 1;
628
+ break;
629
+ case 'Place':
630
+ $review_type_choosen = 2;
631
+ break;
632
+ case 'Recipe':
633
+ $review_type_choosen = 3;
634
+ break;
635
+ case 'Other':
636
+ $review_type_choosen = 4;
637
+ break;
638
+ }
639
+
640
?>
641
642
<select id="yasr-choose-reviews-types-list">
647
648
foreach ($review_type as $type) {
649
650
+ if ($i == $review_type_choosen) {
651
652
echo "<option value=\"$i\" selected>$type</option>";
653
lib/yasr-settings-functions.php CHANGED
@@ -1305,7 +1305,6 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1305
add_settings_section( 'yasr_style_options_section_id', __('Style Options', 'yet-another-stars-rating'), 'yasr_style_section_callback', 'yasr_style_tab' );
1306
add_settings_field( 'yasr_color_scheme_multiset', __('Which color scheme do you want to use?', 'yet-another-stars-rating') , 'yasr_color_scheme_multiset_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options);
1307
add_settings_field( 'yasr_style_options_textarea', __('Custom CSS Styles', 'yet-another-stars-rating'), 'yasr_style_options_textarea_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
1308
-
1309
}
1310
1311
function yasr_style_section_callback () {
@@ -1529,6 +1528,7 @@ function yasr_fb_box ($position=FALSE) {
1529
<blockquote cite="https://www.facebook.com/yetanotherstarsrating"><a href="https://www.facebook.com/yetanotherstarsrating">YASR - Yet Another Stars Rating</a></blockquote>
1530
</div>
1531
</div>
1532
</div>
1533
1534
<?php
1305
add_settings_section( 'yasr_style_options_section_id', __('Style Options', 'yet-another-stars-rating'), 'yasr_style_section_callback', 'yasr_style_tab' );
1306
add_settings_field( 'yasr_color_scheme_multiset', __('Which color scheme do you want to use?', 'yet-another-stars-rating') , 'yasr_color_scheme_multiset_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options);
1307
add_settings_field( 'yasr_style_options_textarea', __('Custom CSS Styles', 'yet-another-stars-rating'), 'yasr_style_options_textarea_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
1308
}
1309
1310
function yasr_style_section_callback () {
1528
<blockquote cite="https://www.facebook.com/yetanotherstarsrating"><a href="https://www.facebook.com/yetanotherstarsrating">YASR - Yet Another Stars Rating</a></blockquote>
1529
</div>
1530
</div>
1531
+
1532
</div>
1533
1534
<?php
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post r
4
Requires at least: 3.5
5
Contributors: Dudo
6
Tested up to: 4.4
7
- Stable tag: 1.0.5
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
@@ -121,6 +121,10 @@ Of course not: you can easily add it on the visual editor just by clicking on th
121
122
== Changelog ==
123
124
= 1.0.5 =
125
* NEW FEATURE: In the Yasr code have been added a lot of hooks! This means that is much easier to develop Yasr. Further this, other developer can add their own extensions!
126
* TWEAKED: Added the postid parameter on the yasr_multiset and yasr_visitor_multiset shortcodes
4
Requires at least: 3.5
5
Contributors: Dudo
6
Tested up to: 4.4
7
+ Stable tag: 1.0.6
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
121
122
== Changelog ==
123
124
+ = 1.0.6 =
125
+ * Added a new filter hook on microdata and jsonld info
126
+ * Fixed php notice
127
+
128
= 1.0.5 =
129
* NEW FEATURE: In the Yasr code have been added a lot of hooks! This means that is much easier to develop Yasr. Further this, other developer can add their own extensions!
130
* TWEAKED: Added the postid parameter on the yasr_multiset and yasr_visitor_multiset shortcodes
yasr-settings-page.php CHANGED
@@ -81,7 +81,7 @@ $n_multi_set = NULL; //Evoid undefined variable when printed outside multiset ta
81
82
<a href="?page=yasr_settings_page&tab=general_settings" class="nav-tab <?php if ($active_tab == 'general_settings' || ($active_tab != 'manage_multi' && $active_tab != 'style_options' && $active_tab != 'go_pro' && $active_tab != 'pro_general_options' && $active_tab != 'charts_options' && $active_tab != 'activate_license')) echo 'nav-tab-active'; ?>" > <?php _e("General Settings", 'yet-another-stars-rating'); ?> </a>
83
<a href="?page=yasr_settings_page&tab=manage_multi" class="nav-tab <?php if ($active_tab == 'manage_multi') echo 'nav-tab-active'; ?>" > <?php _e("Multi Sets", 'yet-another-stars-rating'); ?> </a>
84
- <a href="?page=yasr_settings_page&tab=style_options" class="nav-tab <?php if ($active_tab == 'style_options') echo 'nav-tab-active'; ?>" > <?php _e("Styles", 'yet-another-stars-rating'); ?> </a>
85
<?php do_action( 'yasr_add_settings_tab', $active_tab ); ?>
86
87
</h2>
@@ -293,6 +293,7 @@ $n_multi_set = NULL; //Evoid undefined variable when printed outside multiset ta
293
submit_button( __('Save') );
294
?>
295
</form>
296
</div>
297
298
<?php
81
82
<a href="?page=yasr_settings_page&tab=general_settings" class="nav-tab <?php if ($active_tab == 'general_settings' || ($active_tab != 'manage_multi' && $active_tab != 'style_options' && $active_tab != 'go_pro' && $active_tab != 'pro_general_options' && $active_tab != 'charts_options' && $active_tab != 'activate_license')) echo 'nav-tab-active'; ?>" > <?php _e("General Settings", 'yet-another-stars-rating'); ?> </a>
83
<a href="?page=yasr_settings_page&tab=manage_multi" class="nav-tab <?php if ($active_tab == 'manage_multi') echo 'nav-tab-active'; ?>" > <?php _e("Multi Sets", 'yet-another-stars-rating'); ?> </a>
84
+ <a href="?page=yasr_settings_page&tab=style_options" class="nav-tab <?php if ($active_tab == 'style_options') echo 'nav-tab-active'; ?>" > <?php _e("Aspect & Styles", 'yet-another-stars-rating'); ?> </a>
85
<?php do_action( 'yasr_add_settings_tab', $active_tab ); ?>
86
87
</h2>
293
submit_button( __('Save') );
294
?>
295
</form>
296
+
297
</div>
298
299
<?php
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: 1.0.5
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.0.5');
36
37
//Plugin relative path
38
define( "YASR_RELATIVE_PATH", dirname(__FILE__) );
@@ -105,16 +105,38 @@ define ("YASR_METABOX_OVERALL_RATING", $stored_options['metabox_overall_rating']
105
//Get stored style options
106
$style_options = get_option ('yasr_style_options');
107
108
- if ($style_options && isset($style_options['textarea'])) {
109
110
- define ("YASR_CUSTOM_CSS_RULES", $style_options['textarea']);
111
- define ("YASR_SCHEME_COLOR", $style_options['scheme_color_multiset']);
112
113
}
114
115
else {
116
117
define ("YASR_CUSTOM_CSS_RULES", NULL);
118
119
}
120
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: 1.0.6
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.0.6');
36
37
//Plugin relative path
38
define( "YASR_RELATIVE_PATH", dirname(__FILE__) );
105
//Get stored style options
106
$style_options = get_option ('yasr_style_options');
107
108
+ if ($style_options) {
109
110
+ if(isset($style_options['textarea'])) {
111
+
112
+ define ("YASR_CUSTOM_CSS_RULES", $style_options['textarea']);
113
+
114
+ }
115
+
116
+ else {
117
+
118
+ define ("YASR_CUSTOM_CSS_RULES", NULL);
119
+
120
+ }
121
+
122
+ if(isset($style_options['scheme_color_multiset'])) {
123
+
124
+ define ("YASR_SCHEME_COLOR", $style_options['scheme_color_multiset']);
125
+
126
+ }
127
+
128
+ else {
129
+
130
+ define ("YASR_SCHEME_COLOR", NULL);
131
+
132
+ }
133
134
}
135
136
else {
137
138
define ("YASR_CUSTOM_CSS_RULES", NULL);
139
+ define ("YASR_SCHEME_COLOR", NULL);
140
141
}
142