Yasr – Yet Another Stars Rating - Version 0.3.0

Version Description

  • Now admin can choose if allow only logged in users to vote or logged in and anonymous
  • Code cleanup and bug fixes
Download this release

Release Info

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

Code changes from version 0.2.10 to 0.3.0

lib/yasr-functions.php CHANGED
@@ -100,9 +100,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
100
 
101
  function yasr_auto_insert_shortcode_callback($content) {
102
 
103
- $option = get_option( 'yasr_auto_insert_options' );
104
 
105
- if ($option['enabled'] == 1) {
106
 
107
  $auto_insert_shortcode=NULL; //To avoid undefined variable notice outside the loop (if (is_singular) )
108
 
@@ -111,8 +111,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
111
  $overall_rating_shortcode='[yasr_overall_rating]';
112
  $visitor_votes_shortcode='[yasr_visitor_votes]';
113
 
114
- if ($option['what']=='overall_rating') {
115
- switch ($option['where']) {
116
  case 'top':
117
  return $overall_rating_shortcode . $content;
118
  break;
@@ -123,8 +123,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
123
  } //End Switch
124
  } //end ($option['what']=='overall_rating')
125
 
126
- elseif ($option['what']=='visitor_rating') {
127
- switch ($option['where']) {
128
  case 'top':
129
  return $visitor_votes_shortcode . $content;
130
  break;
@@ -135,8 +135,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
135
  } //End Switch
136
  }
137
 
138
- elseif ($option['what']=='both') {
139
- switch ($option['where']) {
140
  case 'top':
141
  return $overall_rating_shortcode . $visitor_votes_shortcode . $content;
142
  break;
@@ -168,7 +168,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
168
 
169
  $schema=NULL; //To avoid undefined variable notice outside the loop
170
 
171
- $choosen_snippet = get_option( 'yasr_auto_insert_options' );
172
 
173
  if(!$choosen_snippet) {
174
  $choosen_snippet = array();
100
 
101
  function yasr_auto_insert_shortcode_callback($content) {
102
 
103
+ $option = get_option( 'yasr_general_options' );
104
 
105
+ if ($option['auto_insert_enabled'] == 1) {
106
 
107
  $auto_insert_shortcode=NULL; //To avoid undefined variable notice outside the loop (if (is_singular) )
108
 
111
  $overall_rating_shortcode='[yasr_overall_rating]';
112
  $visitor_votes_shortcode='[yasr_visitor_votes]';
113
 
114
+ if ($option['auto_insert_what']==='overall_rating') {
115
+ switch ($option['auto_insert_where']) {
116
  case 'top':
117
  return $overall_rating_shortcode . $content;
118
  break;
123
  } //End Switch
124
  } //end ($option['what']=='overall_rating')
125
 
126
+ elseif ($option['auto_insert_what']==='visitor_rating') {
127
+ switch ($option['auto_insert_where']) {
128
  case 'top':
129
  return $visitor_votes_shortcode . $content;
130
  break;
135
  } //End Switch
136
  }
137
 
138
+ elseif ($option['auto_insert_what']==='both') {
139
+ switch ($option['auto_insert_where']) {
140
  case 'top':
141
  return $overall_rating_shortcode . $visitor_votes_shortcode . $content;
142
  break;
168
 
169
  $schema=NULL; //To avoid undefined variable notice outside the loop
170
 
171
+ $choosen_snippet = get_option( 'yasr_general_options' );
172
 
173
  if(!$choosen_snippet) {
174
  $choosen_snippet = array();
lib/yasr-settings-functions.php CHANGED
@@ -7,35 +7,35 @@
7
 
8
  function yasr_auto_insert_options_init() {
9
  register_setting(
10
- 'yasr_auto_insert_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
11
- 'yasr_auto_insert_options' //The name of an option to sanitize and save.
12
- );
13
 
14
- $option = get_option( 'yasr_auto_insert_options' );
15
 
16
  //To avoid undifined index, i put here the default value
17
  if (!$option) {
18
  $option = array();
19
- $option['enabled']=0;
20
- $option['what']='overall_rating';
21
- $option['where']='top';
22
- $option['snippet']='overall_rating';
23
- }
24
 
25
- if ($option && $option['enabled']==0) {
26
- $option['what']='overall_rating';
27
- $option['where']='top';
28
- }
29
 
30
- if ($option && !$option['snippet']) {
31
- $option['snippet']='overall_rating';
 
 
32
  }
33
 
34
-
35
  add_settings_section( 'yasr_auto_insert_section_id', __('Auto insert Settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
36
  add_settings_field( 'yasr_use_auto_insert_id', __('Use auto insert?', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option );
37
  add_settings_field( 'yasr_what_auto_insert', __('What?', 'yasr'), 'yasr_what_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
38
  add_settings_field( 'yasr_where_auto_insert', __('Where?', 'yasr'), 'yasr_where_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
 
39
  add_settings_field( 'yasr_choose_snippet_id', __('Which rich snippets do you want to use?', 'yasr'), 'yasr_choose_snippet_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option );
40
 
41
  }
@@ -51,12 +51,12 @@
51
 
52
  <?php _e('Yes', 'yasr') ?>
53
 
54
- <input type='radio' name='yasr_auto_insert_options[enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['enabled']==1) echo " checked=\"checked\" "; ?> />
55
  &nbsp;&nbsp;&nbsp;
56
 
57
  <?php _e('No', 'yasr') ?>
58
- <input type='radio' name='yasr_auto_insert_options[enabled]' value='0' id='yasr_auto_insert_radio_off'
59
- <?php if ($option['enabled']==0) {
60
  echo " checked=\"checked\" />";
61
  echo ("<script>
62
  jQuery( document ).ready(function() {
@@ -73,15 +73,15 @@
73
  function yasr_what_auto_insert_callback($option) {
74
  ?>
75
 
76
- <input type="radio" name="yasr_auto_insert_options[what]" value="overall_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='overall_rating') echo " checked=\"checked\" "; ?> >
77
  <?php _e('Overall Rating / Author Rating', 'yasr') ?>
78
  <br />
79
 
80
- <input type="radio" name="yasr_auto_insert_options[what]" value="visitor_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='visitor_rating') echo " checked=\"checked\" "; ?> >
81
  <?php _e('Visitor Votes', 'yasr')?>
82
  <br />
83
 
84
- <input type="radio" name="yasr_auto_insert_options[what]" value="both" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='both') echo " checked=\"checked\" "; ?> >
85
  <?php _e('Both', 'yasr')?>
86
 
87
  <?php
@@ -90,33 +90,51 @@
90
  function yasr_where_auto_insert_callback($option) {
91
  ?>
92
 
93
- <input type="radio" name="yasr_auto_insert_options[where]" value="top" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='top' ) echo " checked=\"checked\" "; ?> >
94
  <?php _e('Before the post', 'yasr')?>
95
  <br />
96
 
97
- <input type="radio" name="yasr_auto_insert_options[where]" value="bottom" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='bottom') echo " checked=\"checked\" "; ?> >
98
  <?php _e('After the post', 'yasr')?>
99
  <br />
100
 
101
 
102
- <p>&nbsp;</p>
103
-
104
- <hr>
105
-
106
  <?php
107
 
108
  }
109
 
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  function yasr_choose_snippet_callback($option) {
112
 
113
  ?>
114
 
115
- <input type="radio" name="yasr_auto_insert_options[snippet]" value="overall_rating" class="yasr_choose_snippet" <?php if ($option['snippet']==='overall_rating') echo " checked=\"checked\" "; ?> >
116
  <?php _e('Review Rating', 'yasr') ?>
117
  <br />
118
 
119
- <input type="radio" name="yasr_auto_insert_options[snippet]" value="visitor_rating" class="yasr_choose_snippet" <?php if ($option['snippet']==='visitor_rating') echo " checked=\"checked\" "; ?> >
120
  <?php _e('Aggregate Rating', 'yasr')?>
121
  <br />
122
 
@@ -134,11 +152,10 @@
134
  ?>
135
  </div>
136
 
137
-
138
-
139
  <?php
140
 
141
- }
 
142
 
143
 
144
  /****** Create a form for settings page to create new multi set ******/
7
 
8
  function yasr_auto_insert_options_init() {
9
  register_setting(
10
+ 'yasr_general_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
11
+ 'yasr_general_options' //The name of an option to sanitize and save.
12
+ );
13
 
14
+ $option = get_option( 'yasr_general_options' );
15
 
16
  //To avoid undifined index, i put here the default value
17
  if (!$option) {
18
  $option = array();
19
+ $option['auto_insert_enabled'] = 0;
20
+ $option['auto_insert_what'] = 'overall_rating';
21
+ $option['auto_insert_where'] = 'top';
22
+ $option['snippet'] = 'overall_rating';
23
+ $option['allowed_user'] = 'allow_anonymous';
24
 
25
+ add_option("yasr_general_options", $option); //Write here the default value if there is not option
26
+ }
 
 
27
 
28
+ //This is to avoid undefined offset
29
+ if ($option && $option['auto_insert_enabled']==0) {
30
+ $option['auto_insert_what']='overall_rating';
31
+ $option['auto_insert_where']='top';
32
  }
33
 
 
34
  add_settings_section( 'yasr_auto_insert_section_id', __('Auto insert Settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
35
  add_settings_field( 'yasr_use_auto_insert_id', __('Use auto insert?', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option );
36
  add_settings_field( 'yasr_what_auto_insert', __('What?', 'yasr'), 'yasr_what_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
37
  add_settings_field( 'yasr_where_auto_insert', __('Where?', 'yasr'), 'yasr_where_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
38
+ 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_auto_insert_section_id', $option );
39
  add_settings_field( 'yasr_choose_snippet_id', __('Which rich snippets do you want to use?', 'yasr'), 'yasr_choose_snippet_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option );
40
 
41
  }
51
 
52
  <?php _e('Yes', 'yasr') ?>
53
 
54
+ <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['auto_insert_enabled']==1) echo " checked=\"checked\" "; ?> />
55
  &nbsp;&nbsp;&nbsp;
56
 
57
  <?php _e('No', 'yasr') ?>
58
+ <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='0' id='yasr_auto_insert_radio_off'
59
+ <?php if ($option['auto_insert_enabled']==0) {
60
  echo " checked=\"checked\" />";
61
  echo ("<script>
62
  jQuery( document ).ready(function() {
73
  function yasr_what_auto_insert_callback($option) {
74
  ?>
75
 
76
+ <input type="radio" name="yasr_general_options[auto_insert_what]" value="overall_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_what']==='overall_rating') echo " checked=\"checked\" "; ?> >
77
  <?php _e('Overall Rating / Author Rating', 'yasr') ?>
78
  <br />
79
 
80
+ <input type="radio" name="yasr_general_options[auto_insert_what]" value="visitor_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_what']==='visitor_rating') echo " checked=\"checked\" "; ?> >
81
  <?php _e('Visitor Votes', 'yasr')?>
82
  <br />
83
 
84
+ <input type="radio" name="yasr_general_options[auto_insert_what]" value="both" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_what']==='both') echo " checked=\"checked\" "; ?> >
85
  <?php _e('Both', 'yasr')?>
86
 
87
  <?php
90
  function yasr_where_auto_insert_callback($option) {
91
  ?>
92
 
93
+ <input type="radio" name="yasr_general_options[auto_insert_where]" value="top" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_where']==='top' ) echo " checked=\"checked\" "; ?> >
94
  <?php _e('Before the post', 'yasr')?>
95
  <br />
96
 
97
+ <input type="radio" name="yasr_general_options[auto_insert_where]" value="bottom" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_where']==='bottom') echo " checked=\"checked\" "; ?> >
98
  <?php _e('After the post', 'yasr')?>
99
  <br />
100
 
101
 
 
 
 
 
102
  <?php
103
 
104
  }
105
 
106
 
107
+ function yasr_allow_only_logged_in_callback($option) {
108
+
109
+ ?>
110
+
111
+ <input type='radio' name='yasr_general_options[allowed_user]' value='logged_only' class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user']==='logged_only') echo " checked=\"checked\" "; ?> />
112
+ <?php _e('Allow only logged-in users', 'yasr')?>
113
+ <br />
114
+
115
+ <input type='radio' name='yasr_general_options[allowed_user]' value='allow_anonymous' class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user']==='allow_anonymous') echo " checked=\"checked\" "; ?> />
116
+ <?php _e('Allow everybody (logged in and anonymous)', 'yasr')?>
117
+ <br />
118
+
119
+
120
+ <p>&nbsp;</p>
121
+
122
+ <hr>
123
+
124
+ <?php
125
+
126
+ } //End function
127
+
128
+
129
  function yasr_choose_snippet_callback($option) {
130
 
131
  ?>
132
 
133
+ <input type="radio" name="yasr_general_options[snippet]" value="overall_rating" class="yasr_choose_snippet" <?php if ($option['snippet']==='overall_rating') echo " checked=\"checked\" "; ?> >
134
  <?php _e('Review Rating', 'yasr') ?>
135
  <br />
136
 
137
+ <input type="radio" name="yasr_general_options[snippet]" value="visitor_rating" class="yasr_choose_snippet" <?php if ($option['snippet']==='visitor_rating') echo " checked=\"checked\" "; ?> >
138
  <?php _e('Aggregate Rating', 'yasr')?>
139
  <br />
140
 
152
  ?>
153
  </div>
154
 
 
 
155
  <?php
156
 
157
+ } //End function yasr_choose_snippet_callback
158
+
159
 
160
 
161
  /****** Create a form for settings page to create new multi set ******/
lib/yasr-shortcode-functions.php CHANGED
@@ -50,21 +50,68 @@ function shortcode_visitor_votes_callback () {
50
  }
51
  }
52
 
 
 
 
 
 
 
 
53
  $image = YASR_IMG_DIR . "/loader.gif";
54
 
55
  $loader_html = "<div id=\"loader-visitor-rating\" >&nbsp; " . __("Loading, please wait","yasr") . " <img src= \" $image \"></div>";
56
 
57
- $medium_rating=round($medium_rating, 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
- if ($votes_number>0) {
60
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
61
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
62
  }
63
 
 
64
  else {
65
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
66
- </div><br /> " . __("No rating yet" , "yasr") . "</div>";
 
 
 
 
 
 
 
 
 
67
  }
 
 
68
 
69
 
70
  ?>
50
  }
51
  }
52
 
53
+ $allow_logged_option = get_option( 'yasr_general_options' );
54
+
55
+ if (!$allow_logged_option) {
56
+ $allow_logged_option = array();
57
+ $allow_logged_option['allowed_user']='allow_anonymous';
58
+ }
59
+
60
  $image = YASR_IMG_DIR . "/loader.gif";
61
 
62
  $loader_html = "<div id=\"loader-visitor-rating\" >&nbsp; " . __("Loading, please wait","yasr") . " <img src= \" $image \"></div>";
63
 
64
+ $medium_rating=round($medium_rating, 1);
65
+
66
+ //if anonymous are allowed to vote
67
+ if ($allow_logged_option['allowed_user']==='allow_anonymous') {
68
+
69
+ if ($votes_number>0) {
70
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
71
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
72
+ }
73
+
74
+ else {
75
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
76
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
77
+ }
78
+
79
+ }
80
+
81
+ //If only logged in users can vote
82
+ elseif ($allow_logged_option['allowed_user']==='logged_only') {
83
+
84
+ //If user is logged in
85
+ if ( is_user_logged_in() ) {
86
+
87
+ if ($votes_number>0) {
88
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
89
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
90
+ }
91
+
92
+ else {
93
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
94
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
95
+ }
96
 
 
 
 
97
  }
98
 
99
+ //Else mean user is not logged in
100
  else {
101
+
102
+ if ($votes_number>0) {
103
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
104
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br />" . __("You must sign to vote", "yasr") . "</div>";
105
+ }
106
+
107
+ else {
108
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
109
+ </div><br /> " . __("No rating yet" , "yasr") . "<br />" . _e("You must sign to vote", "") . "</div>";
110
+ }
111
+
112
  }
113
+
114
+ }
115
 
116
 
117
  ?>
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.2.10
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -49,6 +49,10 @@ If with gd-star-rating you're using a different number of stars from the default
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = 0.2.10 =
53
  * Added loading image when ajax is called
54
  * Added "select button" when choosing a multi set
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.0
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
49
 
50
  == Changelog ==
51
 
52
+ = 0.3.0 =
53
+ * Now admin can choose if allow only logged in users to vote or logged in and anonymous
54
+ * Code cleanup and bug fixes
55
+
56
  = 0.2.10 =
57
  * Added loading image when ajax is called
58
  * Added "select button" when choosing a multi set
yasr-settings-page.php CHANGED
@@ -71,7 +71,7 @@ if ( !current_user_can( 'manage_options' ) ) {
71
  <div class="yasr-settingsdiv">
72
  <form action="options.php" method="post" id="yasr_settings_form">
73
  <?php
74
- settings_fields( 'yasr_auto_insert_options_group' );
75
  do_settings_sections('yasr_settings_page' );
76
  submit_button( __('Save') );
77
  ?>
71
  <div class="yasr-settingsdiv">
72
  <form action="options.php" method="post" id="yasr_settings_form">
73
  <?php
74
+ settings_fields( 'yasr_general_options_group' );
75
  do_settings_sections('yasr_settings_page' );
76
  submit_button( __('Save') );
77
  ?>
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.2.10
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.2.10');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -71,6 +71,42 @@ if (!$version_installed || $version_installed < '0.2.0' ) {
71
 
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  update_option('yasr-version', YASR_VERSION_NUM);
75
 
76
  global $wpdb;
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.0
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.0');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
71
 
72
  }
73
 
74
+ // If user is using a version < 0.3.0 import option
75
+
76
+ if (!$version_installed || $version_installed < '0.3.0' ) {
77
+
78
+ $old_options = get_option ( 'yasr_auto_insert_options' );
79
+
80
+ if ($old_options && $old_options['enabled']==0){
81
+
82
+ $new_options = array(
83
+ "auto_insert_enabled" => $old_options['enabled'],
84
+ "allowed_user" => 'allow_anonymous', //This is not imported, it's just the default value
85
+ "snippet" =>$old_options['snippet']
86
+ );
87
+
88
+ }
89
+
90
+ elseif ($old_options && $old_options['enabled']==1) {
91
+
92
+ $new_options = array(
93
+ "auto_insert_enabled" => $old_options['enabled'],
94
+ "auto_insert_what" => $old_options['what'],
95
+ "auto_insert_where" => $old_options['where'],
96
+ "allowed_user" => 'allow_anonymous', //This is not imported, it's just the default value
97
+ "snippet" =>$old_options['snippet']
98
+ );
99
+ }
100
+
101
+ $options_added=add_option("yasr_general_options", $new_options);
102
+
103
+ if ($options_added) {
104
+ delete_option('yasr_auto_insert_options');
105
+ }
106
+
107
+ } //End if (!$version_installed || $version_installed < '0.3.0' )
108
+
109
+
110
  update_option('yasr-version', YASR_VERSION_NUM);
111
 
112
  global $wpdb;