Yasr – Yet Another Stars Rating - Version 2.6.8

Version Description

  • FIX: in some circumstances, the text "you've already voted" displayed even in when this is not true
  • TWEAKED: YASR is now saving a lot less data in _postmeta table
Download this release

Release Info

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

Code changes from version 2.6.7 to 2.6.8

admin/classes/YasrLogDashboardWidget.php CHANGED
@@ -34,7 +34,6 @@ class YasrLogDashboardWidget {
34
  private $num_of_pages;
35
  private $n_rows;
36
  private $log_query;
37
- private $log_result;
38
  private $is_ajax = false;
39
  private $html_to_return;
40
  private $button_class;
@@ -151,18 +150,18 @@ class YasrLogDashboardWidget {
151
  }
152
 
153
  //do the query
154
- $this->log_result = $wpdb->get_results(
155
  $wpdb->prepare(
156
  $this->log_query,
157
  $this->offset, $this->limit)
158
  );
159
 
160
- if (!$this->log_result) {
161
  _e("No Recent votes yet", 'yet-another-stars-rating');
162
  } else {
163
  $this->html_to_return = "<div class='yasr-log-container' id='$this->container_id'>";
164
 
165
- foreach ($this->log_result as $column) {
166
 
167
  $user = get_user_by('id', $column->user_id); //Get info user from user id
168
 
34
  private $num_of_pages;
35
  private $n_rows;
36
  private $log_query;
 
37
  private $is_ajax = false;
38
  private $html_to_return;
39
  private $button_class;
150
  }
151
 
152
  //do the query
153
+ $log_result = $wpdb->get_results(
154
  $wpdb->prepare(
155
  $this->log_query,
156
  $this->offset, $this->limit)
157
  );
158
 
159
+ if (!$log_result) {
160
  _e("No Recent votes yet", 'yet-another-stars-rating');
161
  } else {
162
  $this->html_to_return = "<div class='yasr-log-container' id='$this->container_id'>";
163
 
164
+ foreach ($log_result as $column) {
165
 
166
  $user = get_user_by('id', $column->user_id); //Get info user from user id
167
 
admin/editor/YasrMetaboxSchemaFields.php CHANGED
@@ -59,7 +59,7 @@ class YasrMetaboxSchemaFields {
59
  ),
60
  'global_identifier_select' => array(
61
  'type' => 'select',
62
- 'options' => array('gtin8', 'gtin13', 'gtin14', 'mpn', 'isbn'),
63
  'label' => 'Global Identifier',
64
  'name' => 'yasr_product_global_identifier_select'
65
  ),
@@ -266,7 +266,7 @@ class YasrMetaboxSchemaFields {
266
  ),
267
  'book_format' => array(
268
  'type' => 'select',
269
- 'options' => array('AudiobookFormat', 'EBook', 'GraphicNovel', 'Hardcover', 'Paperback'),
270
  'label' => 'bookFormat',
271
  'name' => 'yasr_book_bookformat',
272
  'description' => __('The format of the book. ', 'yet-another-stars-rating')
@@ -355,8 +355,15 @@ class YasrMetaboxSchemaFields {
355
  foreach ($itemType_array as $property) {
356
  if (isset($property['type'])) {
357
  if ($property['type'] === 'select') {
 
 
 
 
 
 
 
358
  $string_input = YasrPhpFieldsHelper::select(
359
- '', $property['label'], $property['options'], $property['name'], '', esc_attr($this->saved_data[$property['name']])
360
  );
361
  }
362
  elseif ($property['type'] === 'textarea') {
@@ -423,8 +430,8 @@ class YasrMetaboxSchemaFields {
423
  foreach ($offer_array as $property => $info) {
424
  if ($property === 'availability') {
425
  $array_global_availability = array (
426
- 'Discontinued', 'InStock', 'InStoreOnly', 'LimitedAvailability',
427
- 'OnlineOnly', 'OutOfStock', 'PreOrder'. 'PreSale', 'SoldOut'
428
  );
429
 
430
  $string_input = YasrPhpFieldsHelper::select(
59
  ),
60
  'global_identifier_select' => array(
61
  'type' => 'select',
62
+ 'options' => array('Select...', 'gtin8', 'gtin13', 'gtin14', 'mpn', 'isbn'),
63
  'label' => 'Global Identifier',
64
  'name' => 'yasr_product_global_identifier_select'
65
  ),
266
  ),
267
  'book_format' => array(
268
  'type' => 'select',
269
+ 'options' => array('Select...', 'AudiobookFormat', 'EBook', 'GraphicNovel', 'Hardcover', 'Paperback'),
270
  'label' => 'bookFormat',
271
  'name' => 'yasr_book_bookformat',
272
  'description' => __('The format of the book. ', 'yet-another-stars-rating')
355
  foreach ($itemType_array as $property) {
356
  if (isset($property['type'])) {
357
  if ($property['type'] === 'select') {
358
+ $default_value = esc_attr($this->saved_data[$property['name']]);
359
+
360
+ //if is not saved the default value for the select, use N/A
361
+ if($default_value === '') {
362
+ $default_value = 'Select...';
363
+ }
364
+
365
  $string_input = YasrPhpFieldsHelper::select(
366
+ '', $property['label'], $property['options'], $property['name'], '', $default_value
367
  );
368
  }
369
  elseif ($property['type'] === 'textarea') {
430
  foreach ($offer_array as $property => $info) {
431
  if ($property === 'availability') {
432
  $array_global_availability = array (
433
+ 'Select...', 'Discontinued', 'InStock', 'InStoreOnly', 'LimitedAvailability',
434
+ 'OnlineOnly', 'OutOfStock', 'PreOrder', 'PreSale', 'SoldOut'
435
  );
436
 
437
  $string_input = YasrPhpFieldsHelper::select(
admin/editor/YasrOnSavePost.php CHANGED
@@ -41,12 +41,13 @@ class YasrOnSavePost {
41
  $this->saveOverallRating();
42
  $this->postIsReview();
43
  $this->saveItemType();
44
- $this->saveItemTypesFields();
45
  $this->saveMultisetEditor();
46
 
47
  if (YASR_AUTO_INSERT_ENABLED === 1) {
48
  $this->excludeAutoInsert();
49
  }
 
 
50
  }
51
 
52
  /********** Save Post actions **********/
@@ -74,27 +75,24 @@ class YasrOnSavePost {
74
  return;
75
  }
76
 
77
- $rating = (float) $rating;
78
 
79
  if ($rating > 5) {
80
  $rating = 5;
81
  }
82
 
 
 
 
 
83
  //Put an action to hook into
84
  do_action('yasr_action_on_overall_rating', $this->post_id, $rating);
85
 
86
- $update_result = update_post_meta($this->post_id, 'yasr_overall_rating', $rating);
87
-
88
- //if update_post_meta returns an integer means this is a new post
89
- //so we're going to insert the default YASR_ITEMTYPE
90
- if (is_int($update_result)) {
91
- add_post_meta($this->post_id, 'yasr_review_type', YASR_ITEMTYPE);
92
- }
93
 
94
  }
95
 
96
  private function postIsReview() {
97
-
98
  //this mean there we're not in the classic editor
99
  if(!isset($_POST['yasr_nonce_is_post_review'])) {
100
  return;
@@ -115,7 +113,6 @@ class YasrOnSavePost {
115
  }
116
 
117
  private function saveItemType() {
118
-
119
  //this mean there we're not in the classic editor
120
  if(!isset($_POST['yasr_nonce_review_type'])) {
121
  return;
@@ -140,16 +137,17 @@ class YasrOnSavePost {
140
  } else {
141
  update_post_meta($this->post_id, 'yasr_review_type', $snippet_type);
142
  }
 
 
 
143
  } else {
144
  return;
145
  }
146
- } else {
147
- return;
148
  }
149
-
150
  }
151
 
152
- private function saveItemTypesFields() {
 
153
  $array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true);
154
  $array_to_save = array();
155
 
@@ -166,26 +164,43 @@ class YasrOnSavePost {
166
  }
167
  }
168
 
169
- //get value, sanitize it and save
170
- if(isset($_POST[$item_type_name])) {
171
-
172
- //if come from textarea, use sanitize_textarea_field, that preservers newlines
173
- if($item_type_name === 'yasr_recipe_recipeingredient'
174
- || $item_type_name === 'yasr_recipe_recipeinstructions'
175
- || $item_type_name === 'yasr_movie_actor'
176
- || $item_type_name === 'yasr_movie_director') {
177
- $item_to_save = sanitize_textarea_field($_POST[$item_type_name]);
178
- } else {
179
- //use sanitize_text_field
180
- $item_to_save = sanitize_text_field($_POST[$item_type_name]);
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
-
183
- $array_to_save[$item_type_name] = $item_to_save;
184
  }
185
 
186
  }
187
 
188
- update_post_meta($this->post_id, 'yasr_schema_additional_fields', $array_to_save);
 
 
 
 
 
 
 
189
 
190
  }
191
 
41
  $this->saveOverallRating();
42
  $this->postIsReview();
43
  $this->saveItemType();
 
44
  $this->saveMultisetEditor();
45
 
46
  if (YASR_AUTO_INSERT_ENABLED === 1) {
47
  $this->excludeAutoInsert();
48
  }
49
+
50
+ do_action('yasr_on_save_post', $this->post_id);
51
  }
52
 
53
  /********** Save Post actions **********/
75
  return;
76
  }
77
 
78
+ $rating = (float)$rating;
79
 
80
  if ($rating > 5) {
81
  $rating = 5;
82
  }
83
 
84
+ if($rating <= 0) {
85
+ return;
86
+ }
87
+
88
  //Put an action to hook into
89
  do_action('yasr_action_on_overall_rating', $this->post_id, $rating);
90
 
91
+ update_post_meta($this->post_id, 'yasr_overall_rating', $rating);
 
 
 
 
 
 
92
 
93
  }
94
 
95
  private function postIsReview() {
 
96
  //this mean there we're not in the classic editor
97
  if(!isset($_POST['yasr_nonce_is_post_review'])) {
98
  return;
113
  }
114
 
115
  private function saveItemType() {
 
116
  //this mean there we're not in the classic editor
117
  if(!isset($_POST['yasr_nonce_review_type'])) {
118
  return;
137
  } else {
138
  update_post_meta($this->post_id, 'yasr_review_type', $snippet_type);
139
  }
140
+ //save additional fields
141
+ $this->saveItemTypesFields($snippet_type);
142
+
143
  } else {
144
  return;
145
  }
 
 
146
  }
 
147
  }
148
 
149
+ private function saveItemTypesFields($snippet_type) {
150
+ $snippet_type = strtolower($snippet_type);
151
  $array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true);
152
  $array_to_save = array();
153
 
164
  }
165
  }
166
 
167
+ //get value, sanitize it and save, only if:
168
+ //$item_type_name contain $snippet_type (e.g. I don't need to save yasr_MOVIE_* if
169
+ //the selected snippet is BOOK)
170
+ //$_POST item_type_name isset
171
+ //$_POST item_type_name is not empty string
172
+ if(strpos($item_type_name, $snippet_type) !== false) {
173
+ if (isset($_POST[$item_type_name])
174
+ && $_POST[$item_type_name] !== ''
175
+ && $_POST[$item_type_name] !== 'Select...'
176
+ ) {
177
+ //if come from textarea, use sanitize_textarea_field, that preservers newlines
178
+ if ($item_type_name === 'yasr_recipe_recipeingredient'
179
+ || $item_type_name === 'yasr_recipe_recipeinstructions'
180
+ || $item_type_name === 'yasr_movie_actor'
181
+ || $item_type_name === 'yasr_movie_director'
182
+ ) {
183
+ $item_to_save = sanitize_textarea_field($_POST[$item_type_name]);
184
+ }
185
+ else {
186
+ //use sanitize_text_field
187
+ $item_to_save = sanitize_text_field($_POST[$item_type_name]);
188
+ }
189
+
190
+ $array_to_save[$item_type_name] = $item_to_save;
191
  }
 
 
192
  }
193
 
194
  }
195
 
196
+ //if the array is not empty, save it
197
+ if(!empty($array_to_save)) {
198
+ update_post_meta($this->post_id, 'yasr_schema_additional_fields', $array_to_save);
199
+ }
200
+ //Otherwise, delete the useless post meta
201
+ else {
202
+ delete_post_meta($this->post_id, 'yasr_schema_additional_fields');
203
+ }
204
 
205
  }
206
 
admin/editor/yasr-editor-functions.php CHANGED
@@ -185,18 +185,13 @@ function yasr_shortcode_button_media() {
185
  //Add ajax action that will be called from the .js for button in tinymce
186
  add_action('wp_ajax_yasr_create_shortcode', 'wp_ajax_yasr_create_shortcode_callback');
187
  function wp_ajax_yasr_create_shortcode_callback() {
188
- if (isset($_GET['action'])) {
189
- $action = $_GET['action'];
190
- } else {
191
  exit();
192
  }
193
-
194
  global $wpdb;
195
-
196
  $multi_set = YasrMultiSetData::returnMultiSetNames();
197
  $n_multi_set = $wpdb->num_rows;
198
 
199
-
200
  ?>
201
 
202
  <div id="yasr-tinypopup-form">
185
  //Add ajax action that will be called from the .js for button in tinymce
186
  add_action('wp_ajax_yasr_create_shortcode', 'wp_ajax_yasr_create_shortcode_callback');
187
  function wp_ajax_yasr_create_shortcode_callback() {
188
+ if (!isset($_GET['action'])) {
 
 
189
  exit();
190
  }
 
191
  global $wpdb;
 
192
  $multi_set = YasrMultiSetData::returnMultiSetNames();
193
  $n_multi_set = $wpdb->num_rows;
194
 
 
195
  ?>
196
 
197
  <div id="yasr-tinypopup-form">
admin/settings/classes/YasrSettings.php CHANGED
@@ -270,7 +270,7 @@ class YasrSettings {
270
  $class = 'yasr-auto-insert-options-class';
271
  $id = 'yasr-auto-insert-options-stars-size-';
272
 
273
- YasrPhpFieldsHelper::radioSelectSize($name, $class, $option['auto_insert_size'], $id, true, false);
274
  ?>
275
  </div>
276
  <div>
270
  $class = 'yasr-auto-insert-options-class';
271
  $id = 'yasr-auto-insert-options-stars-size-';
272
 
273
+ YasrPhpFieldsHelper::radioSelectSize($name, $class, $option['auto_insert_size'], $id);
274
  ?>
275
  </div>
276
  <div>
admin/settings/classes/YasrStats.php CHANGED
@@ -149,6 +149,7 @@ class YasrStats extends YASR_WP_List_Table {
149
  protected function column_default( $item, $column_name ) {
150
 
151
  global $wpdb;
 
152
 
153
  if (isset($item['set_type'])) {
154
  $set_id = (int)$item['set_type'];
149
  protected function column_default( $item, $column_name ) {
150
 
151
  global $wpdb;
152
+ $set_id = '';
153
 
154
  if (isset($item['set_type'])) {
155
  $set_id = (int)$item['set_type'];
admin/settings/multiset/yasr-settings-functions-multiset.php CHANGED
@@ -489,8 +489,8 @@ function yasr_process_new_multi_set_form() {
489
 
490
  //If multi set name has been inserted, now we're going to insert elements
491
  if ($insert_multi_name_success) {
492
-
493
  $field_table_new_id = false; //avoid undefined
 
494
 
495
  //get the highest id in table
496
  $highest_id = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
@@ -725,6 +725,8 @@ function yasr_process_edit_multi_set_form() {
725
  //existing installs where auto_increment didn't work because set_id=1 alredy exists
726
 
727
  $field_table_new_id = false; //avoid undefined
 
 
728
  $highest_id = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
729
 
730
  $highest_field_id = $wpdb->get_results("SELECT field_id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY field_id DESC LIMIT 1 ");
@@ -748,7 +750,7 @@ function yasr_process_edit_multi_set_form() {
748
  array('%d', '%d', '%s', '%d')
749
  );
750
 
751
- if ($insert_set_value == false) {
752
  $error = true;
753
  $array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yet-another-stars-rating');
754
  }
489
 
490
  //If multi set name has been inserted, now we're going to insert elements
491
  if ($insert_multi_name_success) {
 
492
  $field_table_new_id = false; //avoid undefined
493
+ $insert_set_value = false; //avoid undefined
494
 
495
  //get the highest id in table
496
  $highest_id = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
725
  //existing installs where auto_increment didn't work because set_id=1 alredy exists
726
 
727
  $field_table_new_id = false; //avoid undefined
728
+ $new_field_id = false; //avoid undefined
729
+
730
  $highest_id = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
731
 
732
  $highest_field_id = $wpdb->get_results("SELECT field_id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY field_id DESC LIMIT 1 ");
750
  array('%d', '%d', '%s', '%d')
751
  );
752
 
753
+ if ($insert_set_value === false) {
754
  $error = true;
755
  $array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yet-another-stars-rating');
756
  }
admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -1,85 +1,72 @@
1
  <?php
2
 
3
  /**Drow settings tab*/
4
- function yasr_settings_tabs( $active_tab )
5
- {
6
  ?>
7
 
8
  <h2 class="nav-tab-wrapper yasr-no-underline">
9
 
10
  <a href="?page=yasr_settings_page&tab=general_settings"
11
  id="general_settings"
12
- class="nav-tab <?php
13
- if ( $active_tab === 'general_settings' ) {
14
- echo 'nav-tab-active' ;
15
- }
16
- ?>">
17
- <?php
18
- _e( 'General Settings', 'yet-another-stars-rating' );
19
- ?>
20
  </a>
21
 
22
  <a href="?page=yasr_settings_page&tab=style_options"
23
  id="style_options"
24
- class="nav-tab <?php
25
- if ( $active_tab === 'style_options' ) {
26
- echo 'nav-tab-active' ;
27
- }
28
- ?>">
29
- <?php
30
- _e( 'Aspect & Styles', 'yet-another-stars-rating' );
31
- ?>
32
  </a>
33
 
34
  <a href="?page=yasr_settings_page&tab=manage_multi"
35
  id="manage_multi"
36
- class="nav-tab <?php
37
- if ( $active_tab === 'manage_multi' ) {
38
- echo 'nav-tab-active' ;
39
- }
40
- ?>">
41
- <?php
42
- _e( 'Multi Sets', 'yet-another-stars-rating' );
43
- ?>
44
  </a>
45
 
46
  <a href="?page=yasr_settings_page&tab=rankings"
47
  id="rankings"
48
- class="nav-tab <?php
49
- if ( $active_tab === 'rankings' ) {
50
- echo 'nav-tab-active' ;
51
- }
52
- ?>">
53
- <?php
54
- _e( "Rankings", 'yet-another-stars-rating' );
55
- ?>
56
  </a>
57
 
58
- <?php
59
- do_action( 'yasr_add_settings_tab', $active_tab );
60
- $rating_plugin_exists = new YasrImportRatingPlugins();
61
-
62
- if ( $rating_plugin_exists->yasr_search_wppr() || $rating_plugin_exists->yasr_search_rmp() || $rating_plugin_exists->yasr_search_kksr() || $rating_plugin_exists->yasr_search_mr() ) {
63
- ?>
 
64
  <a href="?page=yasr_settings_page&tab=migration_tools"
65
  id="migration_tools"
66
- class="nav-tab <?php
67
- if ( $active_tab === 'migration_tools' ) {
68
- echo 'nav-tab-active' ;
 
 
 
69
  }
70
- ?>">
71
- <?php
72
- _e( "Migration Tools", 'yet-another-stars-rating' );
73
  ?>
74
- </a>
75
- <?php
76
- }
77
-
78
- ?>
79
 
80
  </h2>
81
 
82
- <?php
83
  }
84
 
85
  /**
@@ -89,13 +76,20 @@ function yasr_settings_tabs( $active_tab )
89
  * @since 2.6.6
90
  * @return string
91
  */
92
- function yasr_description_auto_insert()
93
- {
94
- $name = __( 'Auto Insert Options', 'yet_another-stars-rating' );
95
- $div_desc = '<div class="yasr-settings-description">';
96
- $description = sprintf( __( 'Automatically adds YASR in your posts or pages. %s
97
- Disable this if you prefer to use shortcodes.', 'yet-another-stars-rating' ), '<br />' );
98
- $end_div = '</div>';
 
 
 
 
 
 
 
99
  return $name . $div_desc . $description . $end_div;
100
  }
101
 
@@ -105,12 +99,13 @@ function yasr_description_auto_insert()
105
  *
106
  * @return string
107
  */
108
- function yasr_description_stars_title()
109
- {
110
- $name = __( 'Enable stars next to the title?', 'yet_another-stars-rating' );
111
- $div_desc = '<div class="yasr-settings-description">';
112
- $description = __( 'Enable this if you want to show stars next to the title', 'yet-another-stars-rating' );
113
- $end_div = '.</div>';
 
114
  return $name . $div_desc . $description . $end_div;
115
  }
116
 
@@ -119,12 +114,15 @@ function yasr_description_stars_title()
119
  * @since 2.6.6
120
  * @return string
121
  */
122
- function yasr_description_archive_page()
123
- {
124
- $name = __( 'Archive Pages', 'yet_another-stars-rating' );
125
- $div_desc = '<div class="yasr-settings-description">';
126
- $description = __( 'Enable or disable these settings if you want to show ratings in archive pages (categories, tags, etc.)', 'yet-another-stars-rating' );
127
- $end_div = '.</div>';
 
 
 
128
  return $name . $div_desc . $description . $end_div;
129
  }
130
 
@@ -133,12 +131,16 @@ function yasr_description_archive_page()
133
  * @since 2.6.6
134
  * @return string
135
  */
136
- function yasr_description_vv_stats()
137
- {
138
- $name = __( 'Show stats for visitors votes?', 'yet_another-stars-rating' );
139
- $div_desc = '<div class="yasr-settings-description">';
140
- $description = sprintf( __( 'Enable or disable the chart bar icon (and tooltip hover it) next to the %syasr_visitor_votes%s shortcode', 'yet-another-stars-rating' ), '<em>', '</em>' );
141
- $end_div = '.</div>';
 
 
 
 
142
  return $name . $div_desc . $description . $end_div;
143
  }
144
 
@@ -147,32 +149,32 @@ function yasr_description_vv_stats()
147
  * @since 2.6.6
148
  * @return string
149
  */
150
- function yasr_description_allow_vote()
151
- {
152
- $name = __( 'Who is allowed to vote?', 'yet_another-stars-rating' );
153
- $div_desc = '<div class="yasr-settings-description">';
154
- $description = sprintf(
155
- __( 'Select who can rate your posts for %syasr_visitor_votes%s and %syasr_visitor_multiset%s shortcodes', 'yet-another-stars-rating' ),
156
- '<em>',
157
- '</em>',
158
- '<em>',
159
- '</em>'
160
  );
161
- $end_div = '.</div>';
 
162
  return $name . $div_desc . $description . $end_div;
163
  }
164
 
 
165
  /**
166
  * @author Dario Curvino <@dudo>
167
  * @since 2.6.6
168
  * @return string
169
  */
170
- function yasr_description_cstm_txt()
171
- {
172
- $name = __( 'Custom texts', 'yet_another-stars-rating' );
173
- $div_desc = '<div class="yasr-settings-description">';
174
- $description = __( 'Auto insert custom texts to show before or after the stars', 'yet-another-stars-rating' );
175
- $end_div = '.</div>';
 
176
  return $name . $div_desc . $description . $end_div;
177
  }
178
 
@@ -181,91 +183,64 @@ function yasr_description_cstm_txt()
181
  * @since 2.6.6
182
  * @return string
183
  */
184
- function yasr_description_strucutured_data()
185
- {
186
- $name = __( 'Stuctured data options', 'yet_another-stars-rating' );
187
- $div_desc = '<div class="yasr-settings-description">';
188
- $description = __( 'If ratings in a post or page are found, YASR will create structured data to show them in search results
189
- (SERP)', 'yet-another-stars-rating' );
190
- $description .= '<br /><a href="https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_rischnippets_desc"
191
  target="_blank">';
192
- $description .= __( 'More info here', 'yet-another-stars-rating' );
193
- $description .= '</a>';
194
- $end_div = '.</div>';
 
195
  return $name . $div_desc . $description . $end_div;
196
  }
197
 
198
- function yasr_upgrade_pro_box( $position = false )
199
- {
200
-
201
- if ( yasr_fs()->is_free_plan() ) {
202
-
203
- if ( $position && $position === "bottom" ) {
204
  $yasr_upgrade_class = "yasr-donatedivbottom";
205
  } else {
206
  $yasr_upgrade_class = "yasr-donatedivdx";
207
  }
208
-
209
  ?>
210
 
211
- <div class="<?php
212
- echo $yasr_upgrade_class ;
213
- ?>" style="display: none">
214
 
215
  <h2 class="yasr-donate-title" style="color: #34A7C1">
216
- <?php
217
- _e( 'Upgrade to YASR Pro', 'yet-another-stars-rating' );
218
- ?>
219
  </h2>
220
 
221
  <div class="yasr-upgrade-to-pro">
222
  <ul>
223
- <li><strong><?php
224
- _e( ' User Reviews', 'yet-another-stars-rating' );
225
- ?></strong></li>
226
- <li><strong><?php
227
- _e( ' Custom Rankings', 'yet-another-stars-rating' );
228
- ?></strong></li>
229
- <li><strong><?php
230
- _e( ' 20 + ready to use themes', 'yet-another-stars-rating' );
231
- ?></strong></li>
232
- <li><strong><?php
233
- _e( ' Upload your own theme', 'yet-another-stars-rating' );
234
- ?></strong></li>
235
- <li><strong><?php
236
- _e( ' Dedicate support', 'yet-another-stars-rating' );
237
- ?></strong></li>
238
- <li><strong><?php
239
- _e( ' ...And much more!!', 'yet-another-stars-rating' );
240
- ?></strong></li>
241
  </ul>
242
- <a href="<?php
243
- echo yasr_fs()->get_upgrade_url() ;
244
- ?>">
245
  <button class="button button-primary">
246
  <span style="font-size: large; font-weight: bold;">
247
- <?php
248
- _e( 'Upgrade Now', 'yet-another-stars-rating' );
249
- ?>
250
  </span>
251
  </button>
252
  </a>
253
  <div style="display: block; margin-top: 10px; margin-bottom: 10px; ">
254
  --- or ---
255
  </div>
256
- <a href="<?php
257
- echo yasr_fs()->get_trial_url() ;
258
- ?>">
259
  <button class="button button-primary">
260
  <span style="display: block; font-size: large; font-weight: bold; margin: -3px;">
261
- <?php
262
- _e( 'Start Free Trial', 'yet-another-stars-rating' );
263
- ?>
264
  </span>
265
  <span style="display: block; margin-top: -10px; font-size: smaller;">
266
- <?php
267
- _e( 'No credit-card, risk free!', 'yet-another-stars-rating' );
268
- ?>
269
  </span>
270
  </button>
271
  </a>
@@ -273,7 +248,8 @@ function yasr_upgrade_pro_box( $position = false )
273
 
274
  </div>
275
 
276
- <?php
 
277
  }
278
 
279
  }
@@ -283,32 +259,40 @@ function yasr_upgrade_pro_box( $position = false )
283
  * Since version 1.9.5
284
  *
285
  */
286
- function yasr_resources_box( $position = false )
287
- {
288
-
289
- if ( $position && $position === "bottom" ) {
290
  $yasr_metabox_class = "yasr-donatedivbottom";
291
- } else {
292
  $yasr_metabox_class = "yasr-donatedivdx";
293
  }
294
-
295
- $div = "<div class='{$yasr_metabox_class}' id='yasr-resources-box' style='display:none;'>";
 
296
  $text = '<div class="yasr-donate-title">Resources</div>';
297
  $text .= '<div class="yasr-donate-single-resource">
298
  <span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
299
- <a target="blank" href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_official">' . __( 'YASR official website', 'yet-another-stars-rating' ) . '</a>
 
 
300
  </div>';
301
  $text .= '<div class="yasr-donate-single-resource">
302
  <span class="dashicons dashicons-edit" style="color: #ccc"></span>
303
- <a target="blank" href="https://yetanotherstarsrating.com/docs/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=documentation">' . __( 'Documentation', 'yet-another-stars-rating' ) . '</a>
 
 
304
  </div>';
305
  $text .= '<div class="yasr-donate-single-resource">
306
  <span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
307
- <a target="blank" href="https://yetanotherstarsrating.com/docs/faq/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=faq">' . __( 'F.A.Q.', 'yet-another-stars-rating' ) . '</a>
 
 
308
  </div>';
309
  $text .= '<div class="yasr-donate-single-resource">
310
  <span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
311
- <a target="blank" href="https://www.youtube.com/channel/UCU5jbO1PJsUUsCNbME9S-Zw">' . __( 'Youtube channel', 'yet-another-stars-rating' ) . '</a>
 
 
312
  </div>';
313
  $text .= '<div class="yasr-donate-single-resource">
314
  <span class="dashicons dashicons-smiley" style="color: #ccc"></span>
@@ -316,24 +300,28 @@ function yasr_resources_box( $position = false )
316
  Yasr Pro
317
  </a>
318
  </div>';
 
319
  $div_and_text = $div . $text . '</div>';
320
- echo $div_and_text ;
 
 
321
  }
322
 
323
  /** Add a box on the right for asking to rate 5 stars on Wordpress.org
324
  * Since version 0.9.0
325
  */
326
- function yasr_ask_rating( $position = false )
327
- {
328
-
329
- if ( $position && $position === "bottom" ) {
330
  $yasr_metabox_class = "yasr-donatedivbottom";
331
- } else {
332
  $yasr_metabox_class = "yasr-donatedivdx";
333
  }
334
-
335
- $div = "<div class='{$yasr_metabox_class}' id='yasr-ask-five-stars' style='display:none;'>";
336
- $text = '<div class="yasr-donate-title">' . __( 'Can I ask your help?', 'yet-another-stars-rating' ) . '</div>';
 
337
  $text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
338
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
339
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
@@ -341,53 +329,62 @@ function yasr_ask_rating( $position = false )
341
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
342
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
343
  </div>';
344
- $text .= __( 'Please rate YASR 5 stars on', 'yet-another-stars-rating' );
345
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
346
  WordPress.org.</a><br />';
347
- $text .= __( ' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating' );
348
  $text .= "<br /><br />";
349
  $text .= "<em>> Dario Curvino</em>";
 
350
  $div_and_text = $div . $text . '</div>';
351
- echo $div_and_text ;
 
 
352
  }
353
 
 
354
  /****
355
  Yasr Right settings panel, since version 1.9.5
356
  ****/
357
- function yasr_right_settings_panel( $position = false )
358
- {
359
- do_action( 'yasr_right_settings_panel_box', $position );
360
- yasr_upgrade_pro_box( $position );
361
- yasr_resources_box( $position );
362
- yasr_ask_rating( $position );
363
  }
364
 
 
365
  /** Change default admin footer on yasr settings pages
366
  * $text is the default wordpress text
367
  * Since 0.8.9
368
  */
369
- add_filter( 'admin_footer_text', 'yasr_custom_admin_footer' );
370
- function yasr_custom_admin_footer( $text )
371
- {
372
-
373
- if ( isset( $_GET['page'] ) ) {
 
374
  $yasr_page = $_GET['page'];
375
-
376
- if ( $yasr_page === 'yasr_settings_page' ) {
377
  $custom_text = ' | <i>';
378
  $custom_text .= sprintf(
379
- __( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
380
- Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>', 'yet-another-stars-rating' ),
 
 
381
  'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=footer&utm_campaign=yasr_settings',
382
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
383
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
384
  );
385
  $custom_text .= '</i>';
 
386
  return $text . $custom_text;
 
387
  }
388
-
389
  return $text;
390
  }
391
-
392
  return $text;
393
  }
 
 
1
  <?php
2
 
3
  /**Drow settings tab*/
4
+ function yasr_settings_tabs($active_tab) {
5
+
6
  ?>
7
 
8
  <h2 class="nav-tab-wrapper yasr-no-underline">
9
 
10
  <a href="?page=yasr_settings_page&tab=general_settings"
11
  id="general_settings"
12
+ class="nav-tab <?php if ($active_tab === 'general_settings') {
13
+ echo 'nav-tab-active';
14
+ } ?>">
15
+ <?php _e('General Settings', 'yet-another-stars-rating'); ?>
 
 
 
 
16
  </a>
17
 
18
  <a href="?page=yasr_settings_page&tab=style_options"
19
  id="style_options"
20
+ class="nav-tab <?php if ($active_tab === 'style_options') {
21
+ echo 'nav-tab-active';
22
+ } ?>">
23
+ <?php
24
+ _e('Aspect & Styles', 'yet-another-stars-rating');
25
+ echo YASR_LOCKED_FEATURE;
26
+ ?>
 
27
  </a>
28
 
29
  <a href="?page=yasr_settings_page&tab=manage_multi"
30
  id="manage_multi"
31
+ class="nav-tab <?php if ($active_tab === 'manage_multi') {
32
+ echo 'nav-tab-active';
33
+ } ?>">
34
+ <?php _e('Multi Sets', 'yet-another-stars-rating'); ?>
 
 
 
 
35
  </a>
36
 
37
  <a href="?page=yasr_settings_page&tab=rankings"
38
  id="rankings"
39
+ class="nav-tab <?php if ($active_tab === 'rankings') {
40
+ echo 'nav-tab-active';
41
+ } ?>">
42
+ <?php
43
+ _e("Rankings", 'yet-another-stars-rating');
44
+ echo YASR_LOCKED_FEATURE;
45
+ ?>
 
46
  </a>
47
 
48
+ <?php do_action('yasr_add_settings_tab', $active_tab);
49
+
50
+ $rating_plugin_exists = new YasrImportRatingPlugins();
51
+
52
+ if ($rating_plugin_exists->yasr_search_wppr() || $rating_plugin_exists->yasr_search_rmp()
53
+ || $rating_plugin_exists->yasr_search_kksr() || $rating_plugin_exists->yasr_search_mr()) {
54
+ ?>
55
  <a href="?page=yasr_settings_page&tab=migration_tools"
56
  id="migration_tools"
57
+ class="nav-tab <?php if ($active_tab === 'migration_tools') {
58
+ echo 'nav-tab-active';
59
+ } ?>">
60
+ <?php _e("Migration Tools", 'yet-another-stars-rating'); ?>
61
+ </a>
62
+ <?php
63
  }
64
+
 
 
65
  ?>
 
 
 
 
 
66
 
67
  </h2>
68
 
69
+ <?php
70
  }
71
 
72
  /**
76
  * @since 2.6.6
77
  * @return string
78
  */
79
+ function yasr_description_auto_insert () {
80
+
81
+ $name = __('Auto Insert Options', 'yet_another-stars-rating');
82
+
83
+ $div_desc = '<div class="yasr-settings-description">';
84
+ $description = sprintf(
85
+ __('Automatically adds YASR in your posts or pages. %s
86
+ Disable this if you prefer to use shortcodes.',
87
+ 'yet-another-stars-rating'
88
+ ),
89
+ '<br />'
90
+ );
91
+ $end_div = '</div>';
92
+
93
  return $name . $div_desc . $description . $end_div;
94
  }
95
 
99
  *
100
  * @return string
101
  */
102
+ function yasr_description_stars_title() {
103
+ $name = __('Enable stars next to the title?', 'yet_another-stars-rating');
104
+
105
+ $div_desc = '<div class="yasr-settings-description">';
106
+ $description = __('Enable this if you want to show stars next to the title','yet-another-stars-rating');
107
+ $end_div = '.</div>';
108
+
109
  return $name . $div_desc . $description . $end_div;
110
  }
111
 
114
  * @since 2.6.6
115
  * @return string
116
  */
117
+ function yasr_description_archive_page() {
118
+ $name = __('Archive Pages', 'yet_another-stars-rating');
119
+
120
+ $div_desc = '<div class="yasr-settings-description">';
121
+ $description =
122
+ __('Enable or disable these settings if you want to show ratings in archive pages (categories, tags, etc.)',
123
+ 'yet-another-stars-rating');
124
+ $end_div = '.</div>';
125
+
126
  return $name . $div_desc . $description . $end_div;
127
  }
128
 
131
  * @since 2.6.6
132
  * @return string
133
  */
134
+ function yasr_description_vv_stats() {
135
+ $name = __('Show stats for visitors votes?', 'yet_another-stars-rating');
136
+
137
+ $div_desc = '<div class="yasr-settings-description">';
138
+ $description =sprintf(
139
+ __('Enable or disable the chart bar icon (and tooltip hover it) next to the %syasr_visitor_votes%s shortcode',
140
+ 'yet-another-stars-rating'), '<em>', '</em>'
141
+ );
142
+ $end_div = '.</div>';
143
+
144
  return $name . $div_desc . $description . $end_div;
145
  }
146
 
149
  * @since 2.6.6
150
  * @return string
151
  */
152
+ function yasr_description_allow_vote() {
153
+ $name = __('Who is allowed to vote?', 'yet_another-stars-rating');
154
+
155
+ $div_desc = '<div class="yasr-settings-description">';
156
+ $description =sprintf(
157
+ __('Select who can rate your posts for %syasr_visitor_votes%s and %syasr_visitor_multiset%s shortcodes',
158
+ 'yet-another-stars-rating'), '<em>', '</em>', '<em>', '</em>'
 
 
 
159
  );
160
+ $end_div = '.</div>';
161
+
162
  return $name . $div_desc . $description . $end_div;
163
  }
164
 
165
+
166
  /**
167
  * @author Dario Curvino <@dudo>
168
  * @since 2.6.6
169
  * @return string
170
  */
171
+ function yasr_description_cstm_txt() {
172
+ $name = __('Custom texts', 'yet_another-stars-rating');
173
+
174
+ $div_desc = '<div class="yasr-settings-description">';
175
+ $description = __('Auto insert custom texts to show before or after the stars', 'yet-another-stars-rating');
176
+ $end_div = '.</div>';
177
+
178
  return $name . $div_desc . $description . $end_div;
179
  }
180
 
183
  * @since 2.6.6
184
  * @return string
185
  */
186
+ function yasr_description_strucutured_data() {
187
+ $name = __('Stuctured data options', 'yet_another-stars-rating');
188
+
189
+ $div_desc = '<div class="yasr-settings-description">';
190
+ $description = __('If ratings in a post or page are found, YASR will create structured data to show them in search results
191
+ (SERP)', 'yet-another-stars-rating');
192
+ $description .= '<br /><a href="https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_rischnippets_desc"
193
  target="_blank">';
194
+ $description .= __('More info here', 'yet-another-stars-rating');
195
+ $description .= '</a>';
196
+ $end_div = '.</div>';
197
+
198
  return $name . $div_desc . $description . $end_div;
199
  }
200
 
201
+ function yasr_upgrade_pro_box($position = false) {
202
+
203
+ if (yasr_fs()->is_free_plan()) {
204
+ if ($position && $position === "bottom") {
 
 
205
  $yasr_upgrade_class = "yasr-donatedivbottom";
206
  } else {
207
  $yasr_upgrade_class = "yasr-donatedivdx";
208
  }
209
+
210
  ?>
211
 
212
+ <div class="<?php echo $yasr_upgrade_class ?>" style="display: none">
 
 
213
 
214
  <h2 class="yasr-donate-title" style="color: #34A7C1">
215
+ <?php _e('Upgrade to YASR Pro', 'yet-another-stars-rating'); ?>
 
 
216
  </h2>
217
 
218
  <div class="yasr-upgrade-to-pro">
219
  <ul>
220
+ <li><strong><?php _e(' User Reviews', 'yet-another-stars-rating'); ?></strong></li>
221
+ <li><strong><?php _e(' Custom Rankings', 'yet-another-stars-rating'); ?></strong></li>
222
+ <li><strong><?php _e(' 20 + ready to use themes', 'yet-another-stars-rating'); ?></strong></li>
223
+ <li><strong><?php _e(' Upload your own theme', 'yet-another-stars-rating'); ?></strong></li>
224
+ <li><strong><?php _e(' Dedicate support', 'yet-another-stars-rating'); ?></strong></li>
225
+ <li><strong><?php _e(' ...And much more!!', 'yet-another-stars-rating'); ?></strong></li>
 
 
 
 
 
 
 
 
 
 
 
 
226
  </ul>
227
+ <a href="<?php echo yasr_fs()->get_upgrade_url(); ?>">
 
 
228
  <button class="button button-primary">
229
  <span style="font-size: large; font-weight: bold;">
230
+ <?php _e('Upgrade Now', 'yet-another-stars-rating')?>
 
 
231
  </span>
232
  </button>
233
  </a>
234
  <div style="display: block; margin-top: 10px; margin-bottom: 10px; ">
235
  --- or ---
236
  </div>
237
+ <a href="<?php echo yasr_fs()->get_trial_url(); ?>">
 
 
238
  <button class="button button-primary">
239
  <span style="display: block; font-size: large; font-weight: bold; margin: -3px;">
240
+ <?php _e('Start Free Trial', 'yet-another-stars-rating') ?>
 
 
241
  </span>
242
  <span style="display: block; margin-top: -10px; font-size: smaller;">
243
+ <?php _e('No credit-card, risk free!', 'yet-another-stars-rating') ?>
 
 
244
  </span>
245
  </button>
246
  </a>
248
 
249
  </div>
250
 
251
+ <?php
252
+
253
  }
254
 
255
  }
259
  * Since version 1.9.5
260
  *
261
  */
262
+ function yasr_resources_box($position = false) {
263
+
264
+ if ($position && $position === "bottom") {
 
265
  $yasr_metabox_class = "yasr-donatedivbottom";
266
+ } else {
267
  $yasr_metabox_class = "yasr-donatedivdx";
268
  }
269
+
270
+ $div = "<div class='$yasr_metabox_class' id='yasr-resources-box' style='display:none;'>";
271
+
272
  $text = '<div class="yasr-donate-title">Resources</div>';
273
  $text .= '<div class="yasr-donate-single-resource">
274
  <span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
275
+ <a target="blank" href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_official">'
276
+ . __('YASR official website', 'yet-another-stars-rating') .
277
+ '</a>
278
  </div>';
279
  $text .= '<div class="yasr-donate-single-resource">
280
  <span class="dashicons dashicons-edit" style="color: #ccc"></span>
281
+ <a target="blank" href="https://yetanotherstarsrating.com/docs/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=documentation">'
282
+ . __('Documentation', 'yet-another-stars-rating') .
283
+ '</a>
284
  </div>';
285
  $text .= '<div class="yasr-donate-single-resource">
286
  <span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
287
+ <a target="blank" href="https://yetanotherstarsrating.com/docs/faq/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=faq">'
288
+ . __('F.A.Q.', 'yet-another-stars-rating') .
289
+ '</a>
290
  </div>';
291
  $text .= '<div class="yasr-donate-single-resource">
292
  <span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
293
+ <a target="blank" href="https://www.youtube.com/channel/UCU5jbO1PJsUUsCNbME9S-Zw">'
294
+ . __('Youtube channel', 'yet-another-stars-rating') .
295
+ '</a>
296
  </div>';
297
  $text .= '<div class="yasr-donate-single-resource">
298
  <span class="dashicons dashicons-smiley" style="color: #ccc"></span>
300
  Yasr Pro
301
  </a>
302
  </div>';
303
+
304
  $div_and_text = $div . $text . '</div>';
305
+
306
+ echo $div_and_text;
307
+
308
  }
309
 
310
  /** Add a box on the right for asking to rate 5 stars on Wordpress.org
311
  * Since version 0.9.0
312
  */
313
+
314
+ function yasr_ask_rating($position = false) {
315
+
316
+ if ($position && $position === "bottom") {
317
  $yasr_metabox_class = "yasr-donatedivbottom";
318
+ } else {
319
  $yasr_metabox_class = "yasr-donatedivdx";
320
  }
321
+
322
+ $div = "<div class='$yasr_metabox_class' id='yasr-ask-five-stars' style='display:none;'>";
323
+
324
+ $text = '<div class="yasr-donate-title">' . __('Can I ask your help?', 'yet-another-stars-rating') .'</div>';
325
  $text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
326
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
327
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
329
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
330
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
331
  </div>';
332
+ $text .= __('Please rate YASR 5 stars on', 'yet-another-stars-rating');
333
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
334
  WordPress.org.</a><br />';
335
+ $text .= __(' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating');
336
  $text .= "<br /><br />";
337
  $text .= "<em>> Dario Curvino</em>";
338
+
339
  $div_and_text = $div . $text . '</div>';
340
+
341
+ echo $div_and_text;
342
+
343
  }
344
 
345
+
346
  /****
347
  Yasr Right settings panel, since version 1.9.5
348
  ****/
349
+ function yasr_right_settings_panel($position = false) {
350
+ do_action('yasr_right_settings_panel_box', $position);
351
+ yasr_upgrade_pro_box($position);
352
+ yasr_resources_box($position);
353
+ yasr_ask_rating($position);
 
354
  }
355
 
356
+
357
  /** Change default admin footer on yasr settings pages
358
  * $text is the default wordpress text
359
  * Since 0.8.9
360
  */
361
+
362
+ add_filter('admin_footer_text', 'yasr_custom_admin_footer');
363
+
364
+ function yasr_custom_admin_footer($text) {
365
+
366
+ if (isset($_GET['page'])) {
367
  $yasr_page = $_GET['page'];
368
+
369
+ if ($yasr_page === 'yasr_settings_page') {
370
  $custom_text = ' | <i>';
371
  $custom_text .= sprintf(
372
+ __('Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
373
+ Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>',
374
+ 'yet-another-stars-rating'
375
+ ),
376
  'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=footer&utm_campaign=yasr_settings',
377
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
378
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
379
  );
380
  $custom_text .= '</i>';
381
+
382
  return $text . $custom_text;
383
+
384
  }
 
385
  return $text;
386
  }
 
387
  return $text;
388
  }
389
+
390
+ ?>
admin/yasr-admin-actions.php CHANGED
@@ -86,4 +86,3 @@ function yasr_erase_data_on_post_page_remove_callback($post_id) {
86
 
87
 
88
  }
89
- ?>
86
 
87
 
88
  }
 
admin/yasr-admin-functions.php CHANGED
@@ -78,8 +78,7 @@ function yasr_add_admin_scripts($hook) {
78
  'yasrcss',
79
  YASR_CSS_DIR_ADMIN . 'yasr-admin.css',
80
  false,
81
- YASR_VERSION_NUM,
82
- 'all'
83
  );
84
 
85
  wp_enqueue_script(
78
  'yasrcss',
79
  YASR_CSS_DIR_ADMIN . 'yasr-admin.css',
80
  false,
81
+ YASR_VERSION_NUM
 
82
  );
83
 
84
  wp_enqueue_script(
includes/classes/YasrMultiSetData.php CHANGED
@@ -38,9 +38,31 @@ class YasrMultiSetData {
38
  public static function returnMultiSetNames() {
39
  global $wpdb;
40
 
41
- $result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id");
 
42
 
43
- return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
 
46
  /**
@@ -266,7 +288,7 @@ class YasrMultiSetData {
266
  */
267
  public static function returnMultiSetAverage($post_id, $set_id, $visitor_multiset) {
268
  $post_id = (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);
38
  public static function returnMultiSetNames() {
39
  global $wpdb;
40
 
41
+ return $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id");
42
+ }
43
 
44
+ /**
45
+ * Returns the first set id or false if not exists
46
+ *
47
+ * @author Dario Curvino <@dudo>
48
+ * @since 2.6.8
49
+ * @return false|int
50
+ */
51
+ public static function returnFirstSetId() {
52
+ global $wpdb;
53
+ $set_id = false;
54
+
55
+ $result = $wpdb->get_results(
56
+ "SELECT set_id
57
+ FROM " . YASR_MULTI_SET_NAME_TABLE . "
58
+ ORDER BY set_id
59
+ LIMIT 1");
60
+
61
+ if(property_exists($result[0], 'set_id')) {
62
+ $set_id = (int)$result[0]->set_id;
63
+ }
64
+
65
+ return $set_id;
66
  }
67
 
68
  /**
288
  */
289
  public static function returnMultiSetAverage($post_id, $set_id, $visitor_multiset) {
290
  $post_id = (int)$post_id;
291
+ $set_id = (int)$set_id;
292
 
293
  if ($visitor_multiset === true) {
294
  $multiset_content = self::returnMultisetContent($post_id, $set_id, true);
includes/classes/YasrPhpFieldsHelper.php CHANGED
@@ -162,13 +162,16 @@ if (!class_exists('YasrPhpFieldsHelper') ) {
162
  $end_select = "</select>";
163
  $end_container = "</div>";
164
 
 
165
  foreach ($select_options as $key => $option) {
166
  if ($option === $attribute['value']) {
167
- $select .= "<option value='$option' selected>$option</option>";
168
- }
169
- else {
170
- $select .= "<option value='$option'>$option</option>";
171
  }
 
 
 
 
 
172
  }
173
 
174
  return ($container . $label_string . $select . $end_select . $end_container);
162
  $end_select = "</select>";
163
  $end_container = "</div>";
164
 
165
+ $selected = '';
166
  foreach ($select_options as $key => $option) {
167
  if ($option === $attribute['value']) {
168
+ $selected = 'selected';
 
 
 
169
  }
170
+
171
+ $select .= "<option value='$option' $selected>$option</option>";
172
+
173
+ //reset
174
+ $selected = '';
175
  }
176
 
177
  return ($container . $label_string . $select . $end_select . $end_container);
includes/shortcodes/classes/YasrNoStarsRankings.php CHANGED
@@ -111,9 +111,9 @@ class YasrNoStarsRankings extends YasrShortcode {
111
  foreach ($query_result as $result) {
112
  $user_id = (int)$result->user;
113
 
 
114
  //If user is 0 means is anonumous
115
  if($user_id === 0) {
116
- $user_link = '#';
117
  $username = __('Anonymous', 'yet-another-stars-rating');
118
  } else {
119
  $user_data = get_userdata($result->user);
111
  foreach ($query_result as $result) {
112
  $user_id = (int)$result->user;
113
 
114
+ $user_link = '#';
115
  //If user is 0 means is anonumous
116
  if($user_id === 0) {
 
117
  $username = __('Anonymous', 'yet-another-stars-rating');
118
  } else {
119
  $user_data = get_userdata($result->user);
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -51,7 +51,7 @@ abstract class YasrShortcode
51
  'size' => 'large',
52
  'postid' => false,
53
  'readonly' => false,
54
- 'setid' => 1,
55
  'show_average' => null,
56
  ), $atts, $shortcode_name );
57
 
51
  'size' => 'large',
52
  'postid' => false,
53
  'readonly' => false,
54
+ 'setid' => YASR_FIRST_SETID,
55
  'show_average' => null,
56
  ), $atts, $shortcode_name );
57
 
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -189,8 +189,6 @@ class YasrVisitorVotes extends YasrShortcode {
189
  if ($stars_enabled === 'true_logged' || $stars_enabled === 'false_already_voted') {
190
  //default value is false
191
  $rating = false;
192
- //default is empty text
193
- $default_text = '';
194
  $span_bottom_line_content = "<span class='yasr-already-voted-text'>";
195
 
196
  //if it is not false_already_voted means it is true_logged
189
  if ($stars_enabled === 'true_logged' || $stars_enabled === 'false_already_voted') {
190
  //default value is false
191
  $rating = false;
 
 
192
  $span_bottom_line_content = "<span class='yasr-already-voted-text'>";
193
 
194
  //if it is not false_already_voted means it is true_logged
includes/yasr-includes-functions.php CHANGED
@@ -81,7 +81,7 @@ function yasr_add_scripts_includes() {
81
  $yasr_multiset_theme_handle,
82
  YASR_CSS_DIR_INCLUDES . $yasr_multiset_theme,
83
  '',
84
- YASR_VERSION_NUM, 'all'
85
  );
86
 
87
  }
81
  $yasr_multiset_theme_handle,
82
  YASR_CSS_DIR_INCLUDES . $yasr_multiset_theme,
83
  '',
84
+ YASR_VERSION_NUM
85
  );
86
 
87
  }
includes/yasr-includes-init.php CHANGED
@@ -26,6 +26,13 @@ define('YASR_JS_DIR_INCLUDES', plugins_url() . '/' . YASR_RELATIVE_PATH_INCLUDES
26
  //CSS directory absolute URL
27
  define('YASR_CSS_DIR_INCLUDES', plugins_url() . '/' . YASR_RELATIVE_PATH_INCLUDES . '/css/');
28
 
 
 
 
 
 
 
 
29
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-functions.php';
30
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-db-functions.php';
31
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-widgets.php';
@@ -200,24 +207,23 @@ if ($style_options) {
200
  }
201
 
202
  //Multi set options
203
- $multi_set_options = get_option('yasr_multiset_options');
204
-
205
- if ($multi_set_options) {
206
- if (isset($multi_set_options['show_average'])) {
207
- define('YASR_MULTI_SHOW_AVERAGE', $multi_set_options['show_average']);
208
- } else {
209
- define('YASR_MULTI_SHOW_AVERAGE', 'yes');
 
 
 
 
 
 
210
  }
211
  }
212
  /****** End Getting options ******/
213
 
214
- global $wpdb;
215
-
216
- define('YASR_LOG_TABLE', $wpdb->prefix . 'yasr_log');
217
- define('YASR_LOG_MULTI_SET', $wpdb->prefix . 'yasr_log_multi_set');
218
- define('YASR_MULTI_SET_NAME_TABLE', $wpdb->prefix . 'yasr_multi_set');
219
- define('YASR_MULTI_SET_FIELDS_TABLE', $wpdb->prefix . 'yasr_multi_set_fields');
220
-
221
  define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
222
 
223
  //Text for button in settings pages
@@ -255,22 +261,22 @@ $array_item_type_info = json_encode(
255
  'yasr_book_bookformat',
256
  'yasr_book_isbn',
257
  'yasr_book_number_of_pages',
 
 
 
258
  'yasr_movie_actor',
 
259
  'yasr_movie_director',
260
  'yasr_movie_duration',
261
- 'yasr_movie_datecreated',
262
  'yasr_product_brand',
263
- 'yasr_product_sku',
264
  'yasr_product_global_identifier_select',
265
  'yasr_product_global_identifier_value',
266
  'yasr_product_price',
267
- 'yasr_product_price_currency',
268
- 'yasr_product_price_valid_until',
269
  'yasr_product_price_availability',
 
270
  'yasr_product_price_url',
271
- 'yasr_localbusiness_address',
272
- 'yasr_localbusiness_pricerange',
273
- 'yasr_localbusiness_telephone',
274
  'yasr_recipe_cooktime',
275
  'yasr_recipe_description',
276
  'yasr_recipe_keywords',
@@ -284,10 +290,10 @@ $array_item_type_info = json_encode(
284
  'yasr_software_application',
285
  'yasr_software_os',
286
  'yasr_software_price',
287
- 'yasr_software_price_currency',
288
- 'yasr_software_price_valid_until',
289
  'yasr_software_price_availability',
 
290
  'yasr_software_price_url',
 
291
  )
292
  );
293
 
26
  //CSS directory absolute URL
27
  define('YASR_CSS_DIR_INCLUDES', plugins_url() . '/' . YASR_RELATIVE_PATH_INCLUDES . '/css/');
28
 
29
+ global $wpdb;
30
+ //defining tables names
31
+ define('YASR_LOG_TABLE', $wpdb->prefix . 'yasr_log');
32
+ define('YASR_LOG_MULTI_SET', $wpdb->prefix . 'yasr_log_multi_set');
33
+ define('YASR_MULTI_SET_NAME_TABLE', $wpdb->prefix . 'yasr_multi_set');
34
+ define('YASR_MULTI_SET_FIELDS_TABLE', $wpdb->prefix . 'yasr_multi_set_fields');
35
+
36
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-functions.php';
37
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-db-functions.php';
38
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-widgets.php';
207
  }
208
 
209
  //Multi set options
210
+ $first_multiset = YasrMultiSetData::returnFirstSetId();
211
+ define('YASR_FIRST_SETID', $first_multiset);
212
+
213
+ if(YASR_FIRST_SETID !== false) {
214
+ $multi_set_options = get_option('yasr_multiset_options');
215
+
216
+ if ($multi_set_options) {
217
+ if (isset($multi_set_options['show_average'])) {
218
+ define('YASR_MULTI_SHOW_AVERAGE', $multi_set_options['show_average']);
219
+ }
220
+ else {
221
+ define('YASR_MULTI_SHOW_AVERAGE', 'yes');
222
+ }
223
  }
224
  }
225
  /****** End Getting options ******/
226
 
 
 
 
 
 
 
 
227
  define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
228
 
229
  //Text for button in settings pages
261
  'yasr_book_bookformat',
262
  'yasr_book_isbn',
263
  'yasr_book_number_of_pages',
264
+ 'yasr_localbusiness_address',
265
+ 'yasr_localbusiness_pricerange',
266
+ 'yasr_localbusiness_telephone',
267
  'yasr_movie_actor',
268
+ 'yasr_movie_datecreated',
269
  'yasr_movie_director',
270
  'yasr_movie_duration',
 
271
  'yasr_product_brand',
 
272
  'yasr_product_global_identifier_select',
273
  'yasr_product_global_identifier_value',
274
  'yasr_product_price',
 
 
275
  'yasr_product_price_availability',
276
+ 'yasr_product_price_currency',
277
  'yasr_product_price_url',
278
+ 'yasr_product_price_valid_until',
279
+ 'yasr_product_sku',
 
280
  'yasr_recipe_cooktime',
281
  'yasr_recipe_description',
282
  'yasr_recipe_keywords',
290
  'yasr_software_application',
291
  'yasr_software_os',
292
  'yasr_software_price',
 
 
293
  'yasr_software_price_availability',
294
+ 'yasr_software_price_currency',
295
  'yasr_software_price_url',
296
+ 'yasr_software_price_valid_until',
297
  )
298
  );
299
 
public/yasr-public-actions.php CHANGED
@@ -29,8 +29,7 @@ function yasr_add_scripts() {
29
  'yasrcss',
30
  YASR_CSS_DIR_INCLUDES . 'yasr.css',
31
  false,
32
- YASR_VERSION_NUM,
33
- 'all'
34
  );
35
 
36
  wp_enqueue_style('dashicons'); //dashicons
29
  'yasrcss',
30
  YASR_CSS_DIR_INCLUDES . 'yasr.css',
31
  false,
32
+ YASR_VERSION_NUM
 
33
  );
34
 
35
  wp_enqueue_style('dashicons'); //dashicons
public/yasr-public-functions.php CHANGED
@@ -42,8 +42,10 @@ function yasr_wp_rocket_support($post_id) {
42
  * https://wordpress.org/support/topic/yasr-is-litespeed-cache-plugin-compatible/
43
  ***/
44
  function yasr_litespeed_cache_support($post_id) {
45
- if (method_exists('LiteSpeed_Cache_API', 'purge_post') == true) {
46
- LiteSpeed_Cache_API::purge_post($post_id);
 
 
47
  }
48
  }
49
 
42
  * https://wordpress.org/support/topic/yasr-is-litespeed-cache-plugin-compatible/
43
  ***/
44
  function yasr_litespeed_cache_support($post_id) {
45
+ if(class_exists('LiteSpeed_Cache_API')) {
46
+ if (method_exists('LiteSpeed_Cache_API', 'purge_post')) {
47
+ LiteSpeed_Cache_API::purge_post($post_id);
48
+ }
49
  }
50
  }
51
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.7
7
  Requires PHP: 5.4
8
- Stable tag: 2.6.7
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,11 @@ 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.6.7 =
185
  * FIX: if custom text is disabled in the settings, default text for a logged in user that has already rated for a post or page was empty.
186
 
5
  Contributors: Dudo
6
  Tested up to: 5.7
7
  Requires PHP: 5.4
8
+ Stable tag: 2.6.8
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.6.8 =
185
+ * FIX: in some circumstances, the text "you've already voted" displayed even in when this is not true
186
+ * TWEAKED: YASR is now saving a lot less data in _postmeta table
187
+
188
+
189
  = 2.6.7 =
190
  * FIX: if custom text is disabled in the settings, default text for a logged in user that has already rated for a post or page was empty.
191
 
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.6.7
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.6.7' );
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.6.8
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.6.8' );
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__ );