Yasr – Yet Another Stars Rating - Version 2.9.7

Version Description

  • NEW FEATURE: auto insert option has now a new feature: it is possible to place shortcodes on both above and below the content
  • TWEAKED: attribute 'custom-fields' is added for all CPTS, to avoid compatibility issue in Gutenberg
  • TWEAKED: nonces are checked only for logged in users.
  • TWEAKED: "Stats" page is now renamed in "Manage Ratings"
  • TWEAKED: below the editor is now easier to manage Multi Sets
Download this release

Release Info

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

Code changes from version 2.9.6 to 2.9.7

admin/classes/YasrOnInstall.php CHANGED
@@ -90,12 +90,13 @@ class YasrOnInstall {
90
  UNIQUE KEY id (id)
91
  ) COLLATE 'utf8_unicode_ci';";
92
 
93
- //Since version 2.1.0
94
  $sql_yasr_log_multi_set_table = "CREATE TABLE $yasr_log_multi_set (
95
  id bigint(20) NOT NULL AUTO_INCREMENT,
96
  field_id int(2) NOT NULL,
97
- set_type int(2) NOT NULL,
98
- post_id bigint(20) NOT NULL,
 
99
  vote decimal(2,1) NOT NULL,
100
  user_id bigint(20) NOT NULL,
101
  date datetime NOT NULL,
90
  UNIQUE KEY id (id)
91
  ) COLLATE 'utf8_unicode_ci';";
92
 
93
+ //log multiset
94
  $sql_yasr_log_multi_set_table = "CREATE TABLE $yasr_log_multi_set (
95
  id bigint(20) NOT NULL AUTO_INCREMENT,
96
  field_id int(2) NOT NULL,
97
+ set_type int(2) NOT NULL,
98
+ post_id bigint(20) NOT NULL,
99
+ comment_id bigint(20) NOT NULL,
100
  vote decimal(2,1) NOT NULL,
101
  user_id bigint(20) NOT NULL,
102
  date datetime NOT NULL,
admin/classes/Yasr_WP_List_Table.php CHANGED
@@ -322,7 +322,7 @@ class Yasr_WP_List_Table {
322
  * @since 3.1.0
323
  */
324
  public function no_items() {
325
- esc_html_e( 'No items found.', 'yet-another-stars-rating' );
326
  }
327
 
328
  /**
322
  * @since 3.1.0
323
  */
324
  public function no_items() {
325
+ esc_html_e( 'No ratings found.', 'yet-another-stars-rating' );
326
  }
327
 
328
  /**
admin/css/yasr-admin.css CHANGED
@@ -43,6 +43,9 @@
43
  background-repeat: repeat-x;
44
  }
45
 
 
 
 
46
 
47
  /********** Edit post / page rules **********/
48
 
@@ -60,13 +63,33 @@
60
  display: block;
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  .rich-snippet-title {
64
  font-weight: bold;
65
  margin-bottom: 5px;
66
  }
67
 
68
- /*** End metabox overall rating ***/
69
-
70
  #multi_rating_table {
71
  vertical-align: text-top;
72
  }
@@ -77,6 +100,19 @@
77
 
78
  /**** Metabox multi ****/
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  .yasr-metabox-below-editor-content {
81
  border: 1px solid #DDD;
82
  padding-left: 15px;
@@ -115,16 +151,62 @@
115
  margin-bottom: 15px;
116
  }
117
 
118
- #yasr-multi-set-admin-choose-text {
119
- display: none;
120
- margin-bottom: 15px;
121
- margin-top: 10px;
122
  }
123
 
124
- #yasr-multi-set-admin-explain {
125
- display: none;
126
- margin-top: 20px;
127
- margin-left: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
 
130
 
@@ -226,15 +308,15 @@
226
  .yasr-onoffswitch-inner:before {
227
  content: "YES";
228
  padding-left: 9px;
229
- background-color: #EEEEEE;
230
  color: #34A7C1;
231
  }
232
 
233
  .yasr-onoffswitch-inner:after {
234
  content: "NO";
235
  padding-right: 15px;
236
- background-color: #EEEEEE;
237
- color: #999999;
238
  text-align: right;
239
  }
240
 
@@ -265,15 +347,15 @@
265
  .yasr-onoffswitch-onoff-inner:before {
266
  content: "ON";
267
  padding-left: 15px;
268
- background-color: #EEEEEE;
269
  color: #34A7C1;
270
  }
271
 
272
  .yasr-onoffswitch-onoff-inner:after {
273
  content: "OFF";
274
  padding-right: 9px;
275
- background-color: #EEEEEE;
276
- color: #999999;
277
  text-align: right;
278
  }
279
 
@@ -434,10 +516,6 @@
434
  font-weight: 600;
435
  }
436
 
437
- .yasr-donate-title a:hover, a:visited, a:link, a:active{
438
- text-decoration: none;
439
- }
440
-
441
  .yasr-donate-single-resource{
442
  margin-bottom: 12px;
443
  padding-bottom: 4px;
@@ -551,13 +629,30 @@
551
  flex: 0 0 45%;
552
  }
553
 
554
- .yasr-settings-row {
 
555
  display: flex;
556
- justify-content: space-between;
 
557
  }
558
 
559
- .yasr-settings-col-20 {
560
- flex: 0 0 30%;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
  }
562
 
563
  .yasr-settings-col-30 {
@@ -576,8 +671,8 @@
576
  flex: 0 0 60%;
577
  }
578
 
579
- .yasr-settings-col-70 {
580
- flex: 0 0 60%;
581
  }
582
 
583
  .yasr-settings-padding-left {
@@ -677,39 +772,11 @@
677
  color: red;
678
  }
679
 
680
- .yasr_table_multi_set_admin {
681
- border: 1px solid rgba(0, 0, 0, 0.1);
682
  padding: 10px;
683
- font-size: 20px;
684
- }
685
-
686
- @media (min-width: 972px) {
687
- .yasr_table_multi_set_admin {
688
- width: 70%;
689
- }
690
- }
691
-
692
-
693
- @media (max-width: 971px) {
694
- .yasr_table_multi_set_admin {
695
- width: 90%;
696
- }
697
  }
698
 
699
- .yasr_table_multi_set_admin td {
700
- width: 50%
701
- }
702
-
703
- .yasr_table_multi_set_admin tr:nth-child(odd) {
704
- background: #feffd3;
705
- }
706
-
707
- /* Define the background color for all the EVEN background rows */
708
- .yasr_table_multi_set_admin tr:nth-child(even) {
709
- background: #FFFFFF;
710
- }
711
-
712
-
713
  .yasr-multi-set-choose-theme {
714
  clear: both;
715
  padding: 10px;
43
  background-repeat: repeat-x;
44
  }
45
 
46
+ .yasr-copy-shortcode {
47
+ cursor: pointer;
48
+ }
49
 
50
  /********** Edit post / page rules **********/
51
 
63
  display: block;
64
  }
65
 
66
+ #yasr-switcher-enable-reviews-in-comments {
67
+ text-align: left;
68
+ margin: 0 auto;
69
+ }
70
+
71
+ .yasr-metabox-editor-pro-only-box {
72
+ border: 1px solid #dcdcde;
73
+ padding-top: 5px;
74
+ padding-bottom: 5px;
75
+ }
76
+
77
+ .yasr-metabox-editor-pro-only-box-padding {
78
+ border-top: 2px solid #dcdcde;
79
+ padding: 10px;
80
+ }
81
+
82
+ .yasr-metabox-doc-link {
83
+ margin-top: 10px;
84
+ }
85
+
86
+ /*** End metabox overall rating ***/
87
+
88
  .rich-snippet-title {
89
  font-weight: bold;
90
  margin-bottom: 5px;
91
  }
92
 
 
 
93
  #multi_rating_table {
94
  vertical-align: text-top;
95
  }
100
 
101
  /**** Metabox multi ****/
102
 
103
+ .yasr-metabox-editor-title-pro-only {
104
+ font-size: 18px;
105
+ font-weight: bold;
106
+ margin-bottom: 10px;
107
+ }
108
+
109
+
110
+ .yasr-metabox-editor-title {
111
+ font-size: 13px;
112
+ font-weight: bold;
113
+ margin-bottom: 10px;
114
+ }
115
+
116
  .yasr-metabox-below-editor-content {
117
  border: 1px solid #DDD;
118
  padding-left: 15px;
151
  margin-bottom: 15px;
152
  }
153
 
154
+ #yasr-editor-multiset-container {
155
+ margin-bottom: 20px;
156
+ padding-right: 2px;
 
157
  }
158
 
159
+ #yasr-visitor-multiset-container{
160
+ border-left: 1px solid #dcdcde;
161
+ padding-left: 10px;
162
+ padding-right: 10px;
163
+ }
164
+
165
+
166
+ .yasr_table_multi_set_admin {
167
+ width: 90%;
168
+ border: solid rgba(0, 0, 0, 0.1);
169
+ border-width: 1px 0 0 1px;
170
+ font-size: 20px;
171
+ }
172
+
173
+ .yasr_table_multi_set_admin td {
174
+ border: solid rgba(0, 0, 0, 0.1);
175
+ border-width: 0 1px 1px 0;
176
+ width: 50%
177
+ }
178
+
179
+ .yasr_table_multi_set_admin td:nth-child(1) {
180
+ overflow-wrap: anywhere;
181
+ }
182
+
183
+ .yasr_table_multi_set_admin tr:nth-child(odd) {
184
+ background: #feffd3;
185
+ }
186
+
187
+ /* Define the background color for all the EVEN background rows */
188
+ .yasr_table_multi_set_admin tr:nth-child(even) {
189
+ background: #FFFFFF;
190
+ }
191
+
192
+ /*@media (max-width: 1440px) {
193
+
194
+ }*/
195
+
196
+
197
+ /*
198
+ @media (min-width: 1177px) {
199
+ .yasr_table_multi_set_admin td:nth-child(1) {
200
+ width: 40%;
201
+ }
202
+ .yasr_table_multi_set_admin td:nth-child(2) {
203
+ width: 60%;
204
+ }
205
+ }*/
206
+
207
+ .yasr-multi-set-admin-explain {
208
+ margin-top: 10px;
209
+ font-size: 14px;
210
  }
211
 
212
 
308
  .yasr-onoffswitch-inner:before {
309
  content: "YES";
310
  padding-left: 9px;
311
+ background-color: #ECECEC;
312
  color: #34A7C1;
313
  }
314
 
315
  .yasr-onoffswitch-inner:after {
316
  content: "NO";
317
  padding-right: 15px;
318
+ background-color: #ECECEC;
319
+ color: #6c6c6c;
320
  text-align: right;
321
  }
322
 
347
  .yasr-onoffswitch-onoff-inner:before {
348
  content: "ON";
349
  padding-left: 15px;
350
+ background-color: #ECECEC;
351
  color: #34A7C1;
352
  }
353
 
354
  .yasr-onoffswitch-onoff-inner:after {
355
  content: "OFF";
356
  padding-right: 9px;
357
+ background-color: #ECECEC;
358
+ color: #6c6c6c;
359
  text-align: right;
360
  }
361
 
516
  font-weight: 600;
517
  }
518
 
 
 
 
 
519
  .yasr-donate-single-resource{
520
  margin-bottom: 12px;
521
  padding-bottom: 4px;
629
  flex: 0 0 45%;
630
  }
631
 
632
+ .yasr-settings-row-48 {
633
+ padding-left: 10px;
634
  display: flex;
635
+ flex-wrap: wrap;
636
+ justify-content: left;
637
  }
638
 
639
+ @media (max-width: 1177px) {
640
+ .yasr-settings-row-48 > div {
641
+ /*It is 45 and applied space between*/
642
+ flex: 0 0 90%;
643
+ }
644
+ }
645
+
646
+ @media (min-width: 1177px) {
647
+ .yasr-settings-row-48 > div {
648
+ /*It is 45 and applied space between*/
649
+ flex: 0 0 48%;
650
+ }
651
+ }
652
+
653
+ .yasr-settings-row {
654
+ display: flex;
655
+ justify-content: space-between;
656
  }
657
 
658
  .yasr-settings-col-30 {
671
  flex: 0 0 60%;
672
  }
673
 
674
+ .yasr-settings-col-65 {
675
+ flex: 0 0 65%;
676
  }
677
 
678
  .yasr-settings-padding-left {
772
  color: red;
773
  }
774
 
775
+ .yasr-multiset-column-container {
776
+ border: 1px solid #dcdcde;
777
  padding: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
  }
779
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
780
  .yasr-multi-set-choose-theme {
781
  clear: both;
782
  padding: 10px;
admin/editor/YasrEditorHooks.php CHANGED
@@ -31,12 +31,17 @@ if (!defined('ABSPATH')) {
31
 
32
  class YasrEditorHooks {
33
 
 
 
34
  public function init() {
35
 
 
 
 
36
  //enqueue gutenberg stuff outside blocks
37
  add_action('enqueue_block_editor_assets', array($this, 'initGutenMisc'));
38
 
39
- add_action('admin_init', array($this, 'initGutenBlocks'));
40
 
41
  //This filter is used to add a new category in gutenberg
42
  add_filter('block_categories_all', array($this, 'addGutenbergCategory'), 10, 2);
@@ -65,6 +70,25 @@ class YasrEditorHooks {
65
 
66
  }
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  //this load guten-block.js, only in admin side
69
  public function initGutenMisc() {
70
  //I need to enqueue this only in post-new.php or post.php
@@ -314,11 +338,17 @@ class YasrEditorHooks {
314
  );
315
  }
316
 
 
 
 
 
 
317
  public function addJsConstantInGutenberg($hook) {
318
  if (($hook === 'post.php' || $hook === 'post-new.php' || $hook === 'appearance_page_gutenberg-edit-site')
319
  && yasr_is_gutenberg_page() ) {
320
 
321
  //create an empty array
 
322
  $constants_array = array();
323
 
324
  //apply filters to empty array
@@ -357,6 +387,10 @@ class YasrEditorHooks {
357
  $auto_insert_array = array (
358
  'adminurl' => get_admin_url(),
359
  'autoInsert' => $auto_insert,
 
 
 
 
360
  'isFseElement' => json_encode($this->isFseElement())
361
  );
362
 
@@ -364,7 +398,7 @@ class YasrEditorHooks {
364
  }
365
 
366
  /**
367
- * Adds to metaboxes
368
  *
369
  * @author Dario Curvino <@dudo>
370
  */
@@ -373,8 +407,7 @@ class YasrEditorHooks {
373
  //Default post type where display metabox
374
  $post_type_where_display_metabox = array('post', 'page', 'wp_template', 'wp_template_part');
375
 
376
- //get the custom post type
377
- $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
378
 
379
  if ($custom_post_types) {
380
  //First merge array then changes keys to int
@@ -803,4 +836,19 @@ class YasrEditorHooks {
803
 
804
  return false;
805
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
806
  }//End Class
31
 
32
  class YasrEditorHooks {
33
 
34
+ private $custom_post_types = null;
35
+
36
  public function init() {
37
 
38
+ //enable attribute "custom-fields" in cpt
39
+ add_action('init', array($this, 'enableCptCustomFields'), 100);
40
+
41
  //enqueue gutenberg stuff outside blocks
42
  add_action('enqueue_block_editor_assets', array($this, 'initGutenMisc'));
43
 
44
+ add_action('admin_init', array($this, 'initGutenBlocks'));
45
 
46
  //This filter is used to add a new category in gutenberg
47
  add_filter('block_categories_all', array($this, 'addGutenbergCategory'), 10, 2);
70
 
71
  }
72
 
73
+ /**
74
+ * Adds attribute custom-fields for all cpts
75
+ *
76
+ * @author Dario Curvino <@dudo>
77
+ * @since 2.9.7
78
+ */
79
+ public function enableCptCustomFields () {
80
+
81
+ $custom_post_types = $this->cptAttribute();
82
+
83
+ //if custom post type exists, add attribute 'custom-fields'
84
+ if($custom_post_types) {
85
+ foreach ( $custom_post_types as $cpt ) {
86
+ YasrCustomPostTypes::enableCustomFields( $cpt );
87
+ }
88
+ }
89
+
90
+ }
91
+
92
  //this load guten-block.js, only in admin side
93
  public function initGutenMisc() {
94
  //I need to enqueue this only in post-new.php or post.php
338
  );
339
  }
340
 
341
+ /**
342
+ * @author Dario Curvino <@dudo>
343
+ * @since
344
+ * @param $hook
345
+ */
346
  public function addJsConstantInGutenberg($hook) {
347
  if (($hook === 'post.php' || $hook === 'post-new.php' || $hook === 'appearance_page_gutenberg-edit-site')
348
  && yasr_is_gutenberg_page() ) {
349
 
350
  //create an empty array
351
+ //do not add elements here, use yasrGutenbergConstants method instead
352
  $constants_array = array();
353
 
354
  //apply filters to empty array
387
  $auto_insert_array = array (
388
  'adminurl' => get_admin_url(),
389
  'autoInsert' => $auto_insert,
390
+ 'proVersion' => json_encode(false),
391
+ 'lockedClass' => 'dashicons dashicons-lock',
392
+ 'lockedText' => esc_html__('This feature is available only in the pro version',
393
+ 'yet-another-stars-rating'),
394
  'isFseElement' => json_encode($this->isFseElement())
395
  );
396
 
398
  }
399
 
400
  /**
401
+ * Adds two metaboxes
402
  *
403
  * @author Dario Curvino <@dudo>
404
  */
407
  //Default post type where display metabox
408
  $post_type_where_display_metabox = array('post', 'page', 'wp_template', 'wp_template_part');
409
 
410
+ $custom_post_types = $this->cptAttribute();
 
411
 
412
  if ($custom_post_types) {
413
  //First merge array then changes keys to int
836
 
837
  return false;
838
  }
839
+
840
+ /**
841
+ * Return the value of the attribute $custom_post_type
842
+ *
843
+ * @return bool|array
844
+ */
845
+ protected function cptAttribute() {
846
+ if($this->custom_post_types === null) {
847
+ //get the custom post type
848
+ $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
849
+ } else {
850
+ $custom_post_types = $this->custom_post_types;
851
+ }
852
+ return $custom_post_types;
853
+ }
854
  }//End Class
admin/editor/YasrOnSavePost.php CHANGED
@@ -86,7 +86,6 @@ class YasrOnSavePost {
86
  }
87
 
88
  private function postIsReview() {
89
- //this mean there we're not in the classic editor
90
  if(!isset($_POST['yasr_nonce_is_post_review'])) {
91
  return;
92
  }
@@ -133,8 +132,6 @@ class YasrOnSavePost {
133
  //save additional fields
134
  $this->saveItemTypesFields($snippet_type);
135
 
136
- } else {
137
- return;
138
  }
139
  }
140
  }
86
  }
87
 
88
  private function postIsReview() {
 
89
  if(!isset($_POST['yasr_nonce_is_post_review'])) {
90
  return;
91
  }
132
  //save additional fields
133
  $this->saveItemTypesFields($snippet_type);
134
 
 
 
135
  }
136
  }
137
  }
admin/editor/yasr-metabox-multiple-rating.php CHANGED
@@ -24,13 +24,12 @@ if (!defined( 'ABSPATH')) {
24
 
25
  $multi_set = YasrMultiSetData::returnMultiSetNames();
26
  $post_id = get_the_ID();
27
- $yasr_nonce_multi = wp_nonce_field( "yasr_nonce_save_multi_values_action", "yasr_nonce_save_multi_values");
28
-
29
- $set_id = NULL;
30
 
31
  global $wpdb;
32
 
33
- $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count number of rows of the last query
34
 
35
  //this is always the first set id
36
  $set_id = $multi_set[0]->set_id;
@@ -38,11 +37,11 @@ $set_id = (int)$set_id;
38
 
39
  if ($n_multi_set > 1) {
40
  ?>
41
- <div>
42
  <?php esc_html_e("Choose which set you want to use", 'yet-another-stars-rating'); ?>
43
  <br />
44
- <label for="select_set">
45
- <select id="select_set" autocomplete="off">
46
  <?php
47
  foreach ($multi_set as $name) {
48
  echo "<option value='".esc_attr($name->set_id)."'>".esc_attr($name->set_name)."</option>";
@@ -51,8 +50,6 @@ if ($n_multi_set > 1) {
51
  </select>
52
  </label>
53
 
54
- <button href="#" class="button-delete" id="yasr-button-select-set"><?php esc_html_e("Select"); ?></button>
55
-
56
  <span id="yasr-loader-select-multi-set" style="display:none;" >&nbsp;
57
  <img src="<?php echo esc_url(YASR_IMG_DIR . "/loader.gif") ?>" alt="yasr-loader">
58
  </span>
@@ -64,48 +61,135 @@ if ($n_multi_set > 1) {
64
 
65
  ?>
66
 
67
- <div id="yasr-editor-multiset-container"
68
- data-nmultiset="<?php echo esc_attr($n_multi_set) ?>"
69
- data-setid="<?php echo esc_attr($set_id) ?>"
70
- data-postid="<?php echo esc_attr($post_id) ?>
71
- ">
72
 
73
- <span id="yasr-multi-set-admin-choose-text">
74
- <?php esc_html_e( 'Choose a vote for each element', 'yet-another-stars-rating' ); ?>
75
- </span>
76
 
77
- <input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
78
- <input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="">
79
 
80
- <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin">
81
 
82
- </table>
 
 
 
 
 
 
83
 
84
- <div id="yasr-multi-set-admin-explain">
85
- <?php esc_html_e( "If you want to insert this multiset, paste this shortcode", 'yet-another-stars-rating' ); ?>
86
- <span id="yasr-multi-set-admin-explain-with-id-readonly"></span>. <br />
87
 
88
- <?php esc_html_e( "If, instead, you want allow your visitor to vote on this multiset, use this shortcode", 'yet-another-stars-rating' ); ?>
89
- <span id='yasr-multi-set-admin-explain-with-id-visitor'></span>.
90
- <?php esc_html_e('In this case, you don\'t need to vote here', 'yet-another-stars-rating');?>
91
 
92
- <br />
93
- <br />
94
 
95
- <?php
96
- $yasr_pro_string = sprintf(
97
- __( "With %sYasr Pro%s you can use %s yasr_pro_average_multiset %s and
98
- %s yasr_pro_average_visitor_multiset %s to print a separate average of the Multi Set.",
99
- 'yet-another-stars-rating' ),
100
- '<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=metabox_multiple_rating&utm_campaign=yasr_editor_screen&utm_content=yasr-pro#yasr-pro">',
101
- '</a>',
102
- '<strong>', '</strong>',
103
- '<strong>', '</strong>');
104
 
105
- echo wp_kses_post($yasr_pro_string);
106
- ?>
107
- <span id='yasr-multi-set-admin-explain-with-id-visitor'></span>
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  </div>
110
 
111
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  $multi_set = YasrMultiSetData::returnMultiSetNames();
26
  $post_id = get_the_ID();
27
+ wp_nonce_field('yasr_nonce_save_multi_values_action', 'yasr_nonce_save_multi_values');
28
+ wp_nonce_field('yasr_nonce_multiset_review_enabled_action','yasr_nonce_multiset_review_enabled');
 
29
 
30
  global $wpdb;
31
 
32
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the count number of rows of the last query
33
 
34
  //this is always the first set id
35
  $set_id = $multi_set[0]->set_id;
37
 
38
  if ($n_multi_set > 1) {
39
  ?>
40
+ <div style="margin-bottom: 15px">
41
  <?php esc_html_e("Choose which set you want to use", 'yet-another-stars-rating'); ?>
42
  <br />
43
+ <label for="yasr_select_set">
44
+ <select id="yasr_select_set" autocomplete="off">
45
  <?php
46
  foreach ($multi_set as $name) {
47
  echo "<option value='".esc_attr($name->set_id)."'>".esc_attr($name->set_name)."</option>";
50
  </select>
51
  </label>
52
 
 
 
53
  <span id="yasr-loader-select-multi-set" style="display:none;" >&nbsp;
54
  <img src="<?php echo esc_url(YASR_IMG_DIR . "/loader.gif") ?>" alt="yasr-loader">
55
  </span>
61
 
62
  ?>
63
 
64
+ <div class="yasr-settings-row-48" style="justify-content: left;">
65
+ <div id="yasr-editor-multiset-container"
66
+ data-nmultiset="<?php echo esc_attr($n_multi_set) ?>"
67
+ data-setid="<?php echo esc_attr($set_id) ?>"
68
+ data-postid="<?php echo esc_attr($post_id) ?>">
69
 
70
+ <input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
71
+ <input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="">
 
72
 
73
+ <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin">
 
74
 
75
+ </table>
76
 
77
+ <div class="yasr-multi-set-admin-explain">
78
+ <div>
79
+ <?php
80
+ $span = '<span title="'.esc_attr__('Copy Shortcode', 'yet-another-stars-rating').'">
81
+ <code id="yasr-editor-copy-readonly-multiset"
82
+ class="yasr-copy-shortcode">[yasr_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
83
+ </span>';
84
 
85
+ $text_multiset = sprintf(esc_html__( 'Rate each element, and copy this shortcode %s where you want to display this rating.',
86
+ 'yet-another-stars-rating'), $span);
 
87
 
88
+ echo wp_kses_post($text_multiset);
89
+ ?>
 
90
 
91
+ </div>
92
+ </div>
93
 
94
+ </div>
 
 
 
 
 
 
 
 
95
 
96
+ <div id="yasr-visitor-multiset-container">
97
+ <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin-visitor">
 
98
 
99
+ </table>
100
+
101
+ <div class="yasr-multi-set-admin-explain">
102
+ <?php
103
+ esc_html_e( 'If, you want allow your visitor to vote on this multiset, use this shortcode',
104
+ 'yet-another-stars-rating' );
105
+ ?>
106
+ <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
107
+ <code id="yasr-editor-copy-visitor-multiset"
108
+ class="yasr-copy-shortcode">[yasr_visitor_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
109
+ </span>
110
+
111
+ <br />
112
+ <?php esc_html_e('This is just a preview, you can\'t vote here.', 'yet-another-stars-rating');?>
113
+ </div>
114
  </div>
115
 
116
  </div>
117
+
118
+ <p></p>
119
+
120
+ <div style="width: 98%">
121
+ <div class="yasr-metabox-editor-pro-only-box-padding">
122
+ <div class="yasr-metabox-editor-title-pro-only">
123
+ <?php
124
+ esc_html_e('Pro Only features', 'yet-another-stars-rating');
125
+ echo '&nbsp;'.YASR_LOCKED_FEATURE;
126
+ ?>
127
+ </div>
128
+
129
+ <div class="yasr-settings-row">
130
+ <div class="yasr-settings-col-30">
131
+ <div class="yasr-metabox-editor-title">
132
+ <?php
133
+ esc_html_e('Insert this Multi Set in the comment form?', 'yet-another-stars-rating');
134
+ ?>
135
+ </div>
136
+ <div class="yasr-onoffswitch-big" id="yasr-pro-multiset-review-switcher-container">
137
+ <input type="checkbox"
138
+ name="yasr_pro_multiset_review_enabled"
139
+ class="yasr-onoffswitch-checkbox"
140
+ value='yes'
141
+ id="yasr-pro-multiset-review-switcher"
142
+ <?php
143
+ //required to check !== otherwise setid=0 is checked even if not enabled
144
+ if ($post->yasr_pro_review_setid !== '' && (int)$post->yasr_pro_review_setid === $set_id) {
145
+ echo " checked='checked' ";
146
+ }
147
+ echo YASR_LOCKED_FEATURE_HTML_ATTRIBUTE;
148
+ ?>
149
+ >
150
+ <label class="yasr-onoffswitch-label" for="yasr-pro-multiset-review-switcher">
151
+ <span class="yasr-onoffswitch-inner"></span>
152
+ <span class="yasr-onoffswitch-switch"></span>
153
+ </label>
154
+ </div>
155
+ <div class="yasr-element-row-container-description">
156
+ <?php
157
+ esc_html_e('By enabling this, all ratings fields will be mandatory.',
158
+ 'yet-another-stars-rating')
159
+ ?>
160
+ </div>
161
+ </div>
162
+
163
+ <div class="yasr-settings-col-65">
164
+ <div class="yasr-metabox-editor-title">
165
+ <?php
166
+ esc_html_e('Shortcodes', 'yet-another-stars-rating');
167
+ ?>
168
+ </div>
169
+
170
+ <div>
171
+ <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
172
+ <code id="yasr-editor-copy-average-multiset" class="yasr-copy-shortcode">
173
+ [yasr_pro_average_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
174
+ </span>
175
+
176
+ <?php esc_html_e('Use this shortcode to print only the average of '); ?>
177
+ [yasr_multiset setid=<span class="yasr-editor-multiset-id"></span>]
178
+ </div>
179
+
180
+ <p></p>
181
+ <div>
182
+ <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
183
+ <code id="yasr-editor-copy-average-vvmultiset" class="yasr-copy-shortcode">
184
+ [yasr_pro_average_visitor_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
185
+ </span>
186
+
187
+ <?php esc_html_e('Use this shortcode to print only the average of '); ?>
188
+ [yasr_visitor_multiset setid=<span class="yasr-editor-multiset-id"></span>]
189
+ </div>
190
+ </div>
191
+ </div>
192
+
193
+ </div>
194
+
195
+ </div>
admin/editor/yasr-metabox-top-right.php CHANGED
@@ -28,11 +28,20 @@ $post_id=get_the_ID();
28
 
29
  //equivalent to get_post_meta
30
  $overall_rating = $post->yasr_overall_rating;
 
 
 
 
 
 
31
 
32
  wp_nonce_field('yasr_nonce_overall_rating_action', 'yasr_nonce_overall_rating');
33
  wp_nonce_field('yasr_nonce_auto_insert_action', 'yasr_nonce_auto_insert');
34
  wp_nonce_field('yasr_nonce_review_type_action', 'yasr_nonce_review_type');
35
  wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
 
 
 
36
 
37
  ?>
38
 
@@ -41,69 +50,195 @@ wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
41
  <input type='hidden'
42
  name='yasr_overall_rating'
43
  id='yasr-overall-rating-value'
44
- value='<?php echo esc_attr($overall_rating);?>'>
45
- <div id="yasr-vote-overall-stars-container">
46
- <div id="yasr-vote-overall-stars">
47
- <span id="yasr-overall-rating-text">
48
- <?php esc_html_e('Rate this article / item', 'yet-another-stars-rating'); ?>
49
- </span>
50
-
51
- <div id="yasr-rater-overall" >
52
- </div>
53
 
54
- <p />
 
 
 
 
55
 
56
- <div>
57
- <span id="yasr_overall_text"></span>
58
- </div>
59
 
 
 
 
 
60
  </div>
61
- </div> <!--End stars container-->
62
- <div>
63
- <?php
64
- //Show this message if auto insert is off or if auto insert is not set to show overall rating (so if it is set to visitor rating)
65
- if( YASR_AUTO_INSERT_ENABLED === 0 || (YASR_AUTO_INSERT_ENABLED === 1 && YASR_AUTO_INSERT_WHAT === 'visitor_rating') ) {
66
- echo "<div>";
67
- printf(esc_html__ ('Remember to insert this shortcode %s[yasr_overall_rating]%s
68
- where you want to display this rating.','yet-another-stars-rating'), '<strong>', '</strong>');
69
- echo "</div>";
70
- }
71
- ?>
72
  </div>
 
73
 
74
- <?php
 
 
 
 
 
 
 
 
 
 
 
75
 
 
 
 
 
 
 
76
  if (YASR_AUTO_INSERT_ENABLED === 1) {
77
  $is_this_post_exluded = get_post_meta($post_id, 'yasr_auto_insert_disabled', true);
78
  ?>
79
-
80
  <hr>
81
  <div id="yasr-toprightmetabox-disable-auto-insert">
82
  <?php esc_html_e('Disable auto insert for this post or page?', 'yet-another-stars-rating'); ?>
83
- <br />
84
- <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
85
- <input type="checkbox"
86
- name="yasr_auto_insert_disabled"
87
- class="yasr-onoffswitch-checkbox"
88
- value="yes"
89
- id="yasr-auto-insert-disabled-switch"
90
- <?php if ($is_this_post_exluded === 'yes') {echo " checked='checked' ";} ?>
91
- >
92
- <label class="yasr-onoffswitch-label" for="yasr-auto-insert-disabled-switch">
93
- <span class="yasr-onoffswitch-inner"></span>
94
- <span class="yasr-onoffswitch-switch"></span>
95
- </label>
96
- </div>
97
  </div>
98
-
99
  <?php
100
 
101
  } //End if auto insert enabled
102
-
103
  ?>
 
104
  <p>
105
- <?php
106
- do_action( 'yasr_add_content_bottom_topright_metabox', $post_id );
107
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  </div>
28
 
29
  //equivalent to get_post_meta
30
  $overall_rating = $post->yasr_overall_rating;
31
+ $comment_review_enabled = false;
32
+
33
+ if(class_exists('YasrCommentsRatingData')) {
34
+ $yasr_comment_rating_data_obj = new YasrCommentsRatingData();
35
+ $comment_review_enabled = (bool)$yasr_comment_rating_data_obj->commentReviewEnabled();
36
+ }
37
 
38
  wp_nonce_field('yasr_nonce_overall_rating_action', 'yasr_nonce_overall_rating');
39
  wp_nonce_field('yasr_nonce_auto_insert_action', 'yasr_nonce_auto_insert');
40
  wp_nonce_field('yasr_nonce_review_type_action', 'yasr_nonce_review_type');
41
  wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
42
+ wp_nonce_field('yasr_nonce_comment_review_enabled_action', 'yasr_nonce_comment_review_enabled');
43
+ wp_nonce_field('yasr_pro_nonce_fake_ratings_action', 'yasr_pro_nonce_fake_ratings');
44
+
45
 
46
  ?>
47
 
50
  <input type='hidden'
51
  name='yasr_overall_rating'
52
  id='yasr-overall-rating-value'
53
+ value='<?php echo esc_attr($overall_rating);?>' />
 
 
 
 
 
 
 
 
54
 
55
+ <div id="yasr-vote-overall-stars-container">
56
+ <div id="yasr-vote-overall-stars">
57
+ <span id="yasr-overall-rating-text">
58
+ <?php esc_html_e('Rate this article / item', 'yet-another-stars-rating'); ?>
59
+ </span>
60
 
61
+ <div id="yasr-rater-overall" >
62
+ </div>
 
63
 
64
+ <p />
65
+
66
+ <div>
67
+ <span id="yasr_overall_text"></span>
68
  </div>
69
+
 
 
 
 
 
 
 
 
 
 
70
  </div>
71
+ </div> <!--End stars container-->
72
 
73
+ <div>
74
+ <?php
75
+ //Show this message if auto insert is off or if auto insert is not set to show overall rating (so if it is set to visitor rating)
76
+ if(YASR_AUTO_INSERT_ENABLED === 0 || (YASR_AUTO_INSERT_ENABLED === 1 && YASR_AUTO_INSERT_WHAT === 'visitor_rating') ) {
77
+ $message_html = '<div title="'.esc_attr__('Copy Shortcode', 'yet-another-stars-rating').'" >';
78
+
79
+ $message_html .= sprintf(
80
+ __('Remember to insert this shortcode %s where you want to display this rating.',
81
+ 'yet-another-stars-rating'),
82
+ '<code id="yasr-editor-copy-overall" class="yasr-copy-shortcode">[yasr_overall_rating]</code>');
83
+
84
+ $message_html .= '</div>';
85
 
86
+ echo wp_kses_post($message_html);
87
+ }
88
+ ?>
89
+ </div>
90
+
91
+ <?php
92
  if (YASR_AUTO_INSERT_ENABLED === 1) {
93
  $is_this_post_exluded = get_post_meta($post_id, 'yasr_auto_insert_disabled', true);
94
  ?>
 
95
  <hr>
96
  <div id="yasr-toprightmetabox-disable-auto-insert">
97
  <?php esc_html_e('Disable auto insert for this post or page?', 'yet-another-stars-rating'); ?>
98
+ <br />
99
+ <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
100
+ <input type="checkbox"
101
+ name="yasr_auto_insert_disabled"
102
+ class="yasr-onoffswitch-checkbox"
103
+ value="yes"
104
+ id="yasr-auto-insert-disabled-switch"
105
+ <?php if ($is_this_post_exluded === 'yes') {echo " checked='checked' ";} ?>
106
+ >
107
+ <label class="yasr-onoffswitch-label" for="yasr-auto-insert-disabled-switch">
108
+ <span class="yasr-onoffswitch-inner"></span>
109
+ <span class="yasr-onoffswitch-switch"></span>
110
+ </label>
111
+ </div>
112
  </div>
 
113
  <?php
114
 
115
  } //End if auto insert enabled
 
116
  ?>
117
+
118
  <p>
119
+
120
+ <div class="yasr-metabox-editor-pro-only-box">
121
+ <div class="yasr-metabox-editor-title-pro-only">
122
+ <?php
123
+ esc_html_e('Pro Only features', 'yet-another-stars-rating');
124
+ echo '&nbsp;'.YASR_LOCKED_FEATURE;
125
+ ?>
126
+ </div>
127
+
128
+ <hr style="width: 90%">
129
+
130
+ <!-- Begin Reviews in comment -->
131
+ <div>
132
+ <div class="yasr-metabox-editor-title">
133
+ <?php esc_html_e('Enable Comment Reviews', 'yet-another-stars-rating'); ?>
134
+ </div>
135
+ <div id="yasr-toprightmetabox-reviews-in-comments-switcher">
136
+ <div class="yasr-onoffswitch-big" id="yasr-switcher-enable-reviews-in-comments">
137
+ <input type="checkbox" name="yasr_pro_review_in_comments"
138
+ class="yasr-onoffswitch-checkbox" value="yes"
139
+ id="yasr-pro-comments-enabled-yes"
140
+ <?php
141
+ if ($comment_review_enabled === true) { echo " checked='checked' "; }
142
+ echo YASR_LOCKED_FEATURE_HTML_ATTRIBUTE;
143
+ ?>
144
+ >
145
+ <label class="yasr-onoffswitch-label" for="yasr-pro-comments-enabled-yes">
146
+ <span class="yasr-onoffswitch-inner yasr-onoffswitch-onoff-inner"></span>
147
+ <span class="yasr-onoffswitch-switch"></span>
148
+ </label>
149
+ </div>
150
+ </div>
151
+
152
+ <div>
153
+ <?php
154
+ if ($comment_review_enabled === true ) {
155
+ esc_html_e('Reviews in comments for this post / page are ENABLED', 'yet-another-stars-rating');
156
+ } else {
157
+ esc_html_e('Reviews in comments for this post / page are DISABLED', 'yet-another-stars-rating');
158
+ }
159
+ ?>
160
+ </div>
161
+
162
+ <div class="yasr-metabox-doc-link">
163
+ <a href="https://yetanotherstarsrating.com/yasr-pro/reviews-in-comments/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_top_right"
164
+ target="_blank">
165
+ <?php esc_html_e('Help', 'yet-another-stars-rating'); ?>
166
+ </a>
167
+ </div>
168
+ </div>
169
+ <!-- End reviews in comment -->
170
+
171
+ <hr style="width: 90%">
172
+
173
+ <!-- Begin Fake Ratings in comment -->
174
+ <div>
175
+ <div class="yasr-metabox-editor-title">
176
+ <?php esc_html_e('Add fake ratings', 'yet-another-stars-rating'); ?>
177
+ </div>
178
+ <div>
179
+ <?php esc_html_e('Number of votes', 'yet-another-stars-rating') ?>
180
+ <br />
181
+ <div>
182
+ <label for="yasr-pro-fake-number-of-votes">
183
+ <select name="yasr_pro_fake_number_of_votes" id="yasr-pro-fake-number-of-votes"
184
+ <?php
185
+ echo YASR_LOCKED_FEATURE_HTML_ATTRIBUTE;
186
+ ?>
187
+ >
188
+ <option value="none" selected>0</option>
189
+ <option value="1">1</option>
190
+ <option value="2">2</option>
191
+ <option value="5">5</option>
192
+ <option value="10">10</option>
193
+ <option value="20">20</option>
194
+ <option value="50">50</option>
195
+ <option value="100">100</option>
196
+ <option value="200">200</option>
197
+ </select>
198
+ </label>
199
+ </div>
200
+ <?php
201
+ esc_html_e('Rating:', 'yet-another-stars-rating');
202
+ ?>
203
+ <div>
204
+ <label for="yasr-pro-fake-ratings">
205
+ <select name="yasr_pro_fake_ratings" id="yasr-pro-fake-ratings"
206
+ <?php
207
+ echo YASR_LOCKED_FEATURE_HTML_ATTRIBUTE;
208
+ ?>
209
+ >
210
+ <?php
211
+ for ($i=5; $i>0; $i--) {
212
+ if($i === 5) {
213
+ $selected = 'selected';
214
+ } else {
215
+ $selected = '';
216
+ }
217
+ echo '<option value="'.esc_attr($i).'" ' .esc_attr($selected).'>'.esc_attr($i).'</option>';
218
+ }
219
+ ?>
220
+ </select>
221
+ </label>
222
+ <p />
223
+ <div>
224
+ <?php esc_html_e(
225
+ 'This will add ratings for yasr_visitor_votes shortcode.',
226
+ 'yet-another-stars-rating')
227
+ ?>
228
+ </div>
229
+ <div class="yasr-metabox-doc-link">
230
+ <a href="https://yetanotherstarsrating.com/yasr_fake_ratings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_top_right"
231
+ target="_blank">
232
+ <?php esc_html_e('Help', 'yet-another-stars-rating'); ?>
233
+ </a>
234
+ </div>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ <!-- End Fake Ratings -->
239
+
240
+ </div>
241
+
242
+ <?php do_action( 'yasr_add_content_bottom_topright_metabox', $post_id ); ?>
243
 
244
  </div>
admin/js/guten/yasr-guten-misc.js CHANGED
@@ -1 +1 @@
1
- (()=>{var e={245:(e,t,a)=>{"use strict";a.r(t),a.d(t,{YasrBlocksPanel:()=>R,YasrDivRatingOverall:()=>E,YasrNoSettingsPanel:()=>b,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>g,YasrProText:()=>v,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>m,yasrOptionalText:()=>s,yasrOverallDescription:()=>d,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>y,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>f});var r=a(245),n=wp.i18n.__,o=wp.components.PanelBody,l=wp.blockEditor.InspectorControls,s=n("All these settings are optional","yet-another-stars-rating"),i=n("Choose Size","yet-another-stars-rating"),c=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),y=n("Medium","yet-another-stars-rating"),p=n("Large","yet-another-stars-rating"),m=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),d=n("Remember: only the post author can rate here.","yet-another-stars-rating"),f=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function g(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(a=t).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},r.yasrSelectSizeChoose),React.createElement("option",{value:"small"},r.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},r.yasrSelectSizeMedium),React.createElement("option",{value:"large"},r.yasrSelectSizeLarge)))}function h(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var a=t.target.value;!0!==/^\d+$/.test(a)&&""!==a||e({postId:a}),t.preventDefault()}}(e.setAttributes,t)}}))}function v(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function b(e){return React.createElement("div",null,React.createElement(v,null))}function R(e){var t;return"visitors"===e.block&&(t=f),"overall"===e.block&&(t=d),React.createElement(l,null,"overall"===e.block&&React.createElement(E,null),React.createElement(o,{title:"Settings"},React.createElement("h3",null,s),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,i),React.createElement("div",null,React.createElement(g,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(h,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},m)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function E(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return function(e,t){var a,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:a,step:r,readOnly:n,rating:o,rateCallback:l})}(32,"overall-rater",!1,.1,!1,a,r)}}))}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,a),o.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function r(t,a){if(a&&("object"===e(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}var o=wp.i18n.__,l=wp.blocks.registerBlockType,s=wp.components,i=s.PanelBody,c=(s.PanelRow,wp.element.Fragment),u=wp.editor,y=(u.BlockControls,u.InspectorControls),p=o("All these settings are optional","yet-another-stars-rating"),m=o("Choose Size","yet-another-stars-rating"),d=o("Choose stars size","yet-another-stars-rating"),f=o("Small","yet-another-stars-rating"),g=o("Medium","yet-another-stars-rating"),h=o("Large","yet-another-stars-rating"),v=o("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),b=o("Remember: only the post author can rate here.","yet-another-stars-rating"),R=o("This is the star set where your users will be able to vote","yet-another-stars-rating"),E=o('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Overall Rating" again.',"yet-another-stars-rating"),w=o('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Visitors Votes" again.',"yet-another-stars-rating");l("yet-another-stars-rating/yasr-overall-rating",{title:o("[DEPRECATED]Yasr: Overall Rating","yet-another-stars-rating"),description:E,icon:"star-half",keywords:[o("rating","yet-another-stars-rating"),o("author","yet-another-stars-rating"),o("overall","yet-another-stars-rating")],attributes:{overallRatingMeta:{type:"number",source:"meta",meta:"yasr_overall_rating"},size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var l,s=e.attributes,u=s.overallRatingMeta,R=s.size,E=s.postId,w=e.setAttributes,k=e.isSelected,_=u,S=null,P=null;"--"!==R&&(S=' size="'+R+'"'),l=/^\d+$/.test(E),"--"!==E&&!0===l&&(P=' postid="'+E+'"');var O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(y,React.Component);var l,s,i,c,u=(i=y,c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=n(i);if(c){var a=n(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return r(this,e)});function y(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,y),(t=u.call(this,e)).yasrOverallRateThis=o("Rate this article / item","yet-another-stars-rating"),t}return l=y,(s=[{key:"render",value:function(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,React.createElement("div",{id:"overall-rater",ref:function(){return raterJs({starSize:32,step:.1,showToolTip:!1,rating:_,readOnly:!1,element:document.querySelector("#overall-rater"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),w({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&t(l.prototype,s),y}();function z(){return React.createElement("form",null,React.createElement("select",{value:R,onChange:I},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},g),React.createElement("option",{value:"large"},h)))}function I(e){var t=e.target.querySelector("option:checked");w({size:t.value}),e.preventDefault()}function T(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:C}))}function C(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||w({postId:t}),e.preventDefault()}}function N(e){return React.createElement(y,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(O,null)),React.createElement(i,{title:"Settings"},React.createElement("h3",null,p),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,m),React.createElement("div",null,React.createElement(z,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(T,null),React.createElement("div",{className:"yasr-guten-block-explain"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},b)))}return React.createElement(c,null,React.createElement(N,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",S,P,"]",k&&React.createElement(z,null)))},save:function(e){var t=e.attributes,a=t.size,r=t.postId,n="",o=r;return a&&(n+='size="'+a+'"'),r&&("--"===r&&(o=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_overall_rating ",n,"]")}}),l("yet-another-stars-rating/yasr-visitor-votes",{title:o("[DEPRECATED]Yasr: Visitor Votes","yet-another-stars-rating"),description:w,icon:"star-half",keywords:[o("rating","yet-another-stars-rating"),o("visitor","yet-another-stars-rating"),o("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var t,a=e.attributes,r=a.size,n=a.postId,o=e.setAttributes,l=e.isSelected,s=null,u=null;function b(){return React.createElement("form",null,React.createElement("select",{value:r,onChange:E},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},g),React.createElement("option",{value:"large"},h)))}function E(e){var t=e.target.querySelector("option:checked");o({size:t.value}),e.preventDefault()}function w(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:k}))}function k(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||o({postId:t}),e.preventDefault()}}function _(e){return React.createElement(y,null,React.createElement(i,{title:"Settings"},React.createElement("h3",null,p),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,m),React.createElement("div",null,React.createElement(b,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(w,null),React.createElement("div",{className:"yasr-guten-block-explain"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},R)))}return t=/^\d+$/.test(n),"--"!==r&&(s=' size="'+r+'"'),"--"!==n&&!0===t&&(u=' postid="'+n+'"'),React.createElement(c,null,React.createElement(_,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",s,u,"]",l&&React.createElement(b,null)))},save:function(e){var t=e.attributes,a=t.size,r=t.postId,n="",o=r;return a&&(n+='size="'+a+'"'),r&&("--"===r&&(o=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_visitor_votes ",n,"]")}}),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-overall-rating"),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-visitor-votes")})(),(()=>{"use strict";var e=a(245);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function i(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var a,r=y(e);if(t){var n=y(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return c(this,a)}}function c(e,a){if(a&&("object"===t(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}var p=wp.i18n.__,m=wp.plugins.registerPlugin,d=wp.editPost,f=d.PluginSidebar,g=d.PluginSidebarMoreMenuItem,h=wp.components.PanelBody,v=wp.element.Fragment,b=function(){return React.createElement("div",null)},R=function(e){l(a,React.Component);var t=i(a);function a(e){var n;r(this,a),n=t.call(this,e);var o=!1;return"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(o=!0),n.state={postExcluded:o},n.yasrUpdatePostMetaAutoInsert=n.yasrUpdatePostMetaAutoInsert.bind(u(n)),n}return o(a,[{key:"yasrUpdatePostMetaAutoInsert",value:function(e){var t=e.target,a="checkbox"===t.type?t.checked:t.value;this.setState({postExcluded:a}),!0===a?wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"yes"}}):wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"no"}})}},{key:"render",value:function(){return React.createElement("div",{className:"yasr-guten-block-panel-center"},React.createElement("hr",null),React.createElement("label",null,React.createElement("span",null,p("Disable auto insert for this post or page?","yet-another-stars-rating"))),React.createElement("div",{className:"yasr-onoffswitch-big yasr-onoffswitch-big-center",id:"yasr-switcher-disable-auto-insert"},React.createElement("input",{type:"checkbox",name:"yasr_auto_insert_disabled",className:"yasr-onoffswitch-checkbox",value:"yes",id:"yasr-auto-insert-disabled-switch",defaultChecked:this.state.postExcluded,onChange:this.yasrUpdatePostMetaAutoInsert}),React.createElement("label",{className:"yasr-onoffswitch-label",htmlFor:"yasr-auto-insert-disabled-switch"},React.createElement("span",{className:"yasr-onoffswitch-inner"}),React.createElement("span",{className:"yasr-onoffswitch-switch"}))))}}]),a}(),E=function(t){l(n,React.Component);var a=i(n);function n(e){var t;r(this,n),t=a.call(this,e);var o=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(o=!0),t.state={yasrAutoInsertEnabled:o},t}return o(n,[{key:"render",value:function(){var t=[React.createElement(b,{key:0})];return wp.hooks.doAction("yasr_below_panel",t),React.createElement(v,null,React.createElement(g,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},p("YASR post settings","yet-another-stars-rating")),React.createElement(f,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(h,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(e.YasrDivRatingOverall,null),React.createElement("div",null,p('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating")),this.state.yasrAutoInsertEnabled&&React.createElement(R,null),t))))}}]),n}();m("yasr-sidebar",{icon:"star-half",title:p("Yasr: Page Settings","yet-another-stars-rating"),render:E})})()})();
1
+ (()=>{var e={245:(e,t,a)=>{"use strict";a.r(t),a.d(t,{YasrBlocksPanel:()=>b,YasrDivRatingOverall:()=>E,YasrNoSettingsPanel:()=>R,YasrPrintInputId:()=>g,YasrPrintSelectSize:()=>v,YasrProText:()=>h,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>p,yasrOptionalText:()=>o,yasrOverallDescription:()=>d,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>y,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>f});var r=a(245),n=wp.i18n.__,s=wp.components.PanelBody,l=wp.blockEditor.InspectorControls,o=n("All these settings are optional","yet-another-stars-rating"),i=n("Choose Size","yet-another-stars-rating"),c=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),y=n("Large","yet-another-stars-rating"),p=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),d=n("Remember: only the post author can rate here.","yet-another-stars-rating"),f=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function v(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(a=t).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},r.yasrSelectSizeChoose),React.createElement("option",{value:"small"},r.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},r.yasrSelectSizeMedium),React.createElement("option",{value:"large"},r.yasrSelectSizeLarge)))}function g(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var a=t.target.value;!0!==/^\d+$/.test(a)&&""!==a||e({postId:a}),t.preventDefault()}}(e.setAttributes,t)}}))}function h(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function R(e){return React.createElement("div",null,React.createElement(h,null))}function b(e){var t;return"visitors"===e.block&&(t=f),"overall"===e.block&&(t=d),React.createElement(l,null,"overall"===e.block&&React.createElement(E,null),React.createElement(s,{title:"Settings"},React.createElement("h3",null,o),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,i),React.createElement("div",null,React.createElement(v,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(g,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},p)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function E(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return function(e,t){var a,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:a,step:r,readOnly:n,rating:s,rateCallback:l})}(32,"overall-rater",!1,.1,!1,a,r)}}))}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,a),s.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function r(t,a){if(a&&("object"===e(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}var s=wp.i18n.__,l=wp.blocks.registerBlockType,o=wp.components,i=o.PanelBody,c=(o.PanelRow,wp.element.Fragment),u=wp.editor,m=(u.BlockControls,u.InspectorControls),y=s("All these settings are optional","yet-another-stars-rating"),p=s("Choose Size","yet-another-stars-rating"),d=s("Choose stars size","yet-another-stars-rating"),f=s("Small","yet-another-stars-rating"),v=s("Medium","yet-another-stars-rating"),g=s("Large","yet-another-stars-rating"),h=s("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),R=s("Remember: only the post author can rate here.","yet-another-stars-rating"),b=s("This is the star set where your users will be able to vote","yet-another-stars-rating"),E=s('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Overall Rating" again.',"yet-another-stars-rating"),w=s('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Visitors Votes" again.',"yet-another-stars-rating");l("yet-another-stars-rating/yasr-overall-rating",{title:s("[DEPRECATED]Yasr: Overall Rating","yet-another-stars-rating"),description:E,icon:"star-half",keywords:[s("rating","yet-another-stars-rating"),s("author","yet-another-stars-rating"),s("overall","yet-another-stars-rating")],attributes:{overallRatingMeta:{type:"number",source:"meta",meta:"yasr_overall_rating"},size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var l,o=e.attributes,u=o.overallRatingMeta,b=o.size,E=o.postId,w=e.setAttributes,k=e.isSelected,_=u,S=null,P=null;"--"!==b&&(S=' size="'+b+'"'),l=/^\d+$/.test(E),"--"!==E&&!0===l&&(P=' postid="'+E+'"');var O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(m,React.Component);var l,o,i,c,u=(i=m,c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=n(i);if(c){var a=n(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return r(this,e)});function m(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,m),(t=u.call(this,e)).yasrOverallRateThis=s("Rate this article / item","yet-another-stars-rating"),t}return l=m,(o=[{key:"render",value:function(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,React.createElement("div",{id:"overall-rater",ref:function(){return raterJs({starSize:32,step:.1,showToolTip:!1,rating:_,readOnly:!1,element:document.querySelector("#overall-rater"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),w({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&t(l.prototype,o),m}();function C(){return React.createElement("form",null,React.createElement("select",{value:b,onChange:N},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},v),React.createElement("option",{value:"large"},g)))}function N(e){var t=e.target.querySelector("option:checked");w({size:t.value}),e.preventDefault()}function x(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:I}))}function I(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||w({postId:t}),e.preventDefault()}}function z(e){return React.createElement(m,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(O,null)),React.createElement(i,{title:"Settings"},React.createElement("h3",null,y),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(C,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(x,null),React.createElement("div",{className:"yasr-guten-block-explain"},h)),React.createElement("div",{className:"yasr-guten-block-panel"},R)))}return React.createElement(c,null,React.createElement(z,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",S,P,"]",k&&React.createElement(C,null)))},save:function(e){var t=e.attributes,a=t.size,r=t.postId,n="",s=r;return a&&(n+='size="'+a+'"'),r&&("--"===r&&(s=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+s+'"'),React.createElement("div",null,"[yasr_overall_rating ",n,"]")}}),l("yet-another-stars-rating/yasr-visitor-votes",{title:s("[DEPRECATED]Yasr: Visitor Votes","yet-another-stars-rating"),description:w,icon:"star-half",keywords:[s("rating","yet-another-stars-rating"),s("visitor","yet-another-stars-rating"),s("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var t,a=e.attributes,r=a.size,n=a.postId,s=e.setAttributes,l=e.isSelected,o=null,u=null;function R(){return React.createElement("form",null,React.createElement("select",{value:r,onChange:E},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},v),React.createElement("option",{value:"large"},g)))}function E(e){var t=e.target.querySelector("option:checked");s({size:t.value}),e.preventDefault()}function w(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:k}))}function k(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||s({postId:t}),e.preventDefault()}}function _(e){return React.createElement(m,null,React.createElement(i,{title:"Settings"},React.createElement("h3",null,y),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(R,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(w,null),React.createElement("div",{className:"yasr-guten-block-explain"},h)),React.createElement("div",{className:"yasr-guten-block-panel"},b)))}return t=/^\d+$/.test(n),"--"!==r&&(o=' size="'+r+'"'),"--"!==n&&!0===t&&(u=' postid="'+n+'"'),React.createElement(c,null,React.createElement(_,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",o,u,"]",l&&React.createElement(R,null)))},save:function(e){var t=e.attributes,a=t.size,r=t.postId,n="",s=r;return a&&(n+='size="'+a+'"'),r&&("--"===r&&(s=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+s+'"'),React.createElement("div",null,"[yasr_visitor_votes ",n,"]")}}),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-overall-rating"),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-visitor-votes")})(),(()=>{"use strict";var e=a(245);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function i(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var a,r=m(e);if(t){var n=m(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return c(this,a)}}function c(e,a){if(a&&("object"===t(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}var y=wp.i18n.__,p=wp.plugins.registerPlugin,d=wp.editPost,f=d.PluginSidebar,v=d.PluginSidebarMoreMenuItem,g=wp.components.PanelBody,h=wp.element.Fragment,R=function(){return React.createElement("div",null)},b=function(e){l(a,React.Component);var t=i(a);function a(e){var n;r(this,a),n=t.call(this,e);var s=!1;return"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(s=!0),n.state={postExcluded:s},n.yasrUpdatePostMetaAutoInsert=n.yasrUpdatePostMetaAutoInsert.bind(u(n)),n}return s(a,[{key:"yasrUpdatePostMetaAutoInsert",value:function(e){var t=e.target,a="checkbox"===t.type?t.checked:t.value;this.setState({postExcluded:a}),!0===a?wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"yes"}}):wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"no"}})}},{key:"render",value:function(){return React.createElement("div",{className:"yasr-guten-block-panel-center"},React.createElement("hr",null),React.createElement("label",null,React.createElement("span",null,y("Disable auto insert for this post or page?","yet-another-stars-rating"))),React.createElement("div",{className:"yasr-onoffswitch-big yasr-onoffswitch-big-center",id:"yasr-switcher-disable-auto-insert"},React.createElement("input",{type:"checkbox",name:"yasr_auto_insert_disabled",className:"yasr-onoffswitch-checkbox",value:"yes",id:"yasr-auto-insert-disabled-switch",defaultChecked:this.state.postExcluded,onChange:this.yasrUpdatePostMetaAutoInsert}),React.createElement("label",{className:"yasr-onoffswitch-label",htmlFor:"yasr-auto-insert-disabled-switch"},React.createElement("span",{className:"yasr-onoffswitch-inner"}),React.createElement("span",{className:"yasr-onoffswitch-switch"}))))}}]),a}(),E=function(e){l(a,React.Component);var t=i(a);function a(e){var n,s,l,o;r(this,a),o=void 0,(l="yasrProLabelReviewsEnabled")in(s=u(n=t.call(this,e)))?Object.defineProperty(s,l,{value:o,enumerable:!0,configurable:!0,writable:!0}):s[l]=o,n.yasrProLabelReviewsEnabled=y("Reviews in comments for this post / page are disabled","yet-another-stars-rating");var i=+wp.data.select("core/editor").getCurrentPost().yasr_pro_comment_review_enabled;return 1===i&&(n.yasrProLabelReviewsEnabled=y("Reviews in comments for this post / page are enabled","yet-another-stars-rating")),n.state={reviewEnabled:i},n.yasrUpdatePostMetaReviewsEnabled=n.yasrUpdatePostMetaReviewsEnabled.bind(u(n)),n}return s(a,[{key:"yasrUpdatePostMetaReviewsEnabled",value:function(e){var t=e.target,a="checkbox"===t.type?t.checked:t.value,r=document.getElementById("yasr-pro-multiset-review-switcher");this.setState({reviewEnabled:a}),!0===a?wp.data.dispatch("core/editor").editPost({meta:{yasr_pro_reviews_in_comment_enabled:"1"}}):(r.checked=!1,wp.data.dispatch("core/editor").editPost({meta:{yasr_pro_reviews_in_comment_enabled:"0"}}))}},{key:"render",value:function(){return React.createElement("div",null,React.createElement("hr",null),React.createElement("label",null,React.createElement("span",null,this.yasrProLabelReviewsEnabled)),React.createElement("div",{className:"yasr-onoffswitch-big yasr-onoffswitch-big-center",id:"yasr-switcher-disable-comment-reviews"},React.createElement("input",{type:"checkbox",name:"yasr_comment_reviews_disabled",className:"yasr-onoffswitch-checkbox",value:"1",id:"yasr-comment-reviews-disabled-switch",defaultChecked:this.state.reviewEnabled,onChange:this.yasrUpdatePostMetaReviewsEnabled}),React.createElement("label",{className:"yasr-onoffswitch-label",htmlFor:"yasr-comment-reviews-disabled-switch"},React.createElement("span",{className:"yasr-onoffswitch-inner yasr-onoffswitch-onoff-inner"}),React.createElement("span",{className:"yasr-onoffswitch-switch"}))),React.createElement("div",{className:"yasr-metabox-doc-link"},React.createElement("a",{href:"https://yetanotherstarsrating.com/yasr-pro/reviews-in-comments/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_top_right",target:"_blank"},y("Help","yet-another-stars-rating"))))}}]),a}(),w=function(e){l(a,React.Component);var t=i(a);function a(e){var n;return r(this,a),(n=t.call(this,e)).state={numberFakeRatings:0},n.state={fakeRating:5},n.state={ajaxResponse:""},n.yasrNumberFakeRatings=n.yasrNumberFakeRatings.bind(u(n)),n.yasrFakeRating=n.yasrFakeRating.bind(u(n)),n.yasrSaveFakeRatings=n.yasrSaveFakeRatings.bind(u(n)),n}return s(a,[{key:"yasrNumberFakeRatings",value:function(e){this.setState({numberFakeRatings:e.target.value})}},{key:"yasrFakeRating",value:function(e){this.setState({fakeRating:e.target.value})}},{key:"yasrSaveFakeRatings",value:function(e){var t=wp.data.select("core/editor").getCurrentPostId();if(this.state.numberFakeRatings>0&&this.state.numberFakeRatings<201){var a=function(e){"OK"===e?s.setState({ajaxResponse:y("Done!","yet-another-stars-rating")}):s.setState({ajaxResponse:y("Error","yet-another-stars-rating")})};this.setState({ajaxResponse:y("Loading, please wait","yet-another-stars-rating")});var r=this.state.fakeRating,n=this.state.numberFakeRatings;null==r&&(r=5);var s=this,l={action:"yasr_adds_fake_ratings",yasr_pro_nonce_fake_ratings:yasrConstantGutenberg.yasr_pro_nonce_fake_ratings,yasr_pro_fake_number_of_votes:n,yasr_pro_fake_ratings:r,post_id:t};jQuery.post(ajaxurl,l,(function(e){a(e)})).fail((function(e,t,r,n){a("KO")}))}}},{key:"render",value:function(){var e=!0;return!0===JSON.parse(yasrConstantGutenberg.proVersion)&&(e=!1),React.createElement("div",null,React.createElement("hr",null),React.createElement("strong",null,y("Add fake ratings","yet-another-stars-rating")),React.createElement("p",null),React.createElement("div",null,y("Number of votes","yet-another-stars-rating"),React.createElement("br",null),React.createElement("div",null,React.createElement("label",{htmlFor:"yasr-pro-fake-number-of-votes"},React.createElement("select",{name:"yasr-pro-fake-number-of-votes",id:"yasr-pro-fake-number-of-votes",onChange:this.yasrNumberFakeRatings,disabled:e},React.createElement("option",{value:"none",defaultValue:!0},"0"),React.createElement("option",{value:"1"},"1"),React.createElement("option",{value:"2"},"2"),React.createElement("option",{value:"5"},"5"),React.createElement("option",{value:"10"},"10"),React.createElement("option",{value:"20"},"20"),React.createElement("option",{value:"50"},"50"),React.createElement("option",{value:"100"},"100"),React.createElement("option",{value:"200"},"200"))))),y("Rating:","yet-another-stars-rating"),React.createElement("div",null,React.createElement("label",{htmlFor:"yasr-pro-fake-ratings"},React.createElement("select",{name:"yasr-pro-fake-ratings",id:"yasr-pro-fake-ratings",value:this.state.fakeRating,onChange:this.yasrFakeRating,disabled:e},React.createElement("option",{value:"5"},"5"),React.createElement("option",{value:"4"},"4"),React.createElement("option",{value:"3"},"3"),React.createElement("option",{value:"2"},"2"),React.createElement("option",{value:"1"},"1"))),React.createElement("p",null),React.createElement("div",null,y("This will add ratings for yasr_visitor_votes shortcode.","yet-another-stars-rating"))),React.createElement("div",null,React.createElement("br",null),React.createElement("button",{onClick:this.yasrSaveFakeRatings,disabled:e},"Save"),React.createElement("br",null),this.state.ajaxResponse),React.createElement("div",{className:"yasr-metabox-doc-link"},React.createElement("a",{href:"https://yetanotherstarsrating.com/yasr_fake_ratings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_top_right",target:"_blank"},y("Help","yet-another-stars-rating"))))}}]),a}(),k=function(t){l(n,React.Component);var a=i(n);function n(e){var t;r(this,n),t=a.call(this,e);var s=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(s=!0),t.state={yasrAutoInsertEnabled:s},t}return s(n,[{key:"render",value:function(){var t=[React.createElement(R,{key:0})];return wp.hooks.doAction("yasr_below_panel",t),React.createElement(h,null,React.createElement(v,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},y("YASR post settings","yet-another-stars-rating")),React.createElement(f,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(g,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(e.YasrDivRatingOverall,null),React.createElement("div",null,y('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating")),this.state.yasrAutoInsertEnabled&&React.createElement(b,null),React.createElement("p",null),React.createElement("div",{className:"yasr-metabox-editor-pro-only-box"},React.createElement("div",{className:"yasr-metabox-editor-title-pro-only"},y("Pro Only features","yet-another-stars-rating"),React.createElement("span",{className:yasrConstantGutenberg.lockedClass,title:yasrConstantGutenberg.lockedText})),React.createElement(E,null),React.createElement(w,null)),t))))}}]),n}();p("yasr-sidebar",{name:"Yet Another Stars Rating",icon:"star-half",title:y("Yasr: Settings","yet-another-stars-rating"),render:k})})()})();
admin/js/src/guten/yasr-guten-panel.js CHANGED
@@ -72,6 +72,238 @@ class YasrSideBarAutoInsert extends React.Component {
72
 
73
  }
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  class yasrSidebar extends React.Component {
76
 
77
  constructor(props) {
@@ -105,6 +337,15 @@ class yasrSidebar extends React.Component {
105
  'yet-another-stars-rating')}
106
  </div>
107
  {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert />}
 
 
 
 
 
 
 
 
 
108
  {YasrBelowSidebar}
109
  </div>
110
  </PanelBody>
@@ -116,7 +357,8 @@ class yasrSidebar extends React.Component {
116
 
117
  //Custom sidebar
118
  registerPlugin( 'yasr-sidebar', {
 
119
  icon: 'star-half',
120
- title: __( 'Yasr: Page Settings', 'yet-another-stars-rating' ),
121
  render: yasrSidebar
122
  } );
72
 
73
  }
74
 
75
+ /**
76
+ * Auto insert Comment Reviews
77
+ */
78
+ class YasrCommentReviewsEnabled extends React.Component {
79
+ yasrProLabelReviewsEnabled;
80
+
81
+ constructor(props) {
82
+ super(props);
83
+
84
+ //by default, set to disable
85
+ this.yasrProLabelReviewsEnabled = __('Reviews in comments for this post / page are disabled', 'yet-another-stars-rating');
86
+
87
+ //get rest yasr_pro_comment_review_enabled
88
+ //YOURSITE.COM/wp-json/wp/v2/posts/<POSTID>?_fields=yasr_pro_comment_review_enabled
89
+ //with + convert bool to int
90
+ let reviewEnabledForPost = + wp.data.select('core/editor').getCurrentPost().yasr_pro_comment_review_enabled;
91
+
92
+ if (reviewEnabledForPost === 1) {
93
+ this.yasrProLabelReviewsEnabled = __('Reviews in comments for this post / page are enabled', 'yet-another-stars-rating');
94
+ }
95
+
96
+ this.state = {reviewEnabled: reviewEnabledForPost};
97
+
98
+ this.yasrUpdatePostMetaReviewsEnabled = this.yasrUpdatePostMetaReviewsEnabled.bind(this);
99
+ }
100
+
101
+ yasrUpdatePostMetaReviewsEnabled(event) {
102
+ const target = event.target;
103
+ const reviewEnabled = target.type === 'checkbox' ? target.checked : target.value;
104
+
105
+ const multiSetinReview = document.getElementById('yasr-pro-multiset-review-switcher');
106
+
107
+ this.setState({reviewEnabled: reviewEnabled});
108
+
109
+ //MUST be saved as a string
110
+ if (reviewEnabled === true) {
111
+ wp.data.dispatch('core/editor').editPost(
112
+ { meta: { yasr_pro_reviews_in_comment_enabled: '1' } }
113
+ );
114
+ } else {
115
+ multiSetinReview.checked = false;
116
+ wp.data.dispatch('core/editor').editPost(
117
+ { meta: { yasr_pro_reviews_in_comment_enabled: '0' } }
118
+ );
119
+ }
120
+ }
121
+
122
+ render () {
123
+ return (
124
+ <div>
125
+ <hr/>
126
+ <label><span>{this.yasrProLabelReviewsEnabled}</span></label>
127
+ <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-comment-reviews">
128
+ <input type="checkbox"
129
+ name="yasr_comment_reviews_disabled"
130
+ className="yasr-onoffswitch-checkbox"
131
+ value="1"
132
+ id="yasr-comment-reviews-disabled-switch"
133
+ defaultChecked={this.state.reviewEnabled}
134
+ onChange={this.yasrUpdatePostMetaReviewsEnabled}
135
+ />
136
+
137
+ <label className="yasr-onoffswitch-label" htmlFor="yasr-comment-reviews-disabled-switch">
138
+ <span className="yasr-onoffswitch-inner yasr-onoffswitch-onoff-inner" />
139
+ <span className="yasr-onoffswitch-switch" />
140
+ </label>
141
+ </div>
142
+ <div className="yasr-metabox-doc-link">
143
+ <a href="https://yetanotherstarsrating.com/yasr-pro/reviews-in-comments/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_top_right"
144
+ target="_blank"
145
+ >
146
+ {__('Help', 'yet-another-stars-rating')}
147
+ </a>
148
+ </div>
149
+ </div>
150
+ );
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Fake Ratings
156
+ */
157
+ class YasrFakeRatings extends React.Component {
158
+
159
+ constructor(props) {
160
+ super(props);
161
+
162
+ this.state = {numberFakeRatings: 0};
163
+ this.state = {fakeRating: 5};
164
+
165
+ this.state = {ajaxResponse: ''};
166
+
167
+ this.yasrNumberFakeRatings = this.yasrNumberFakeRatings.bind(this);
168
+ this.yasrFakeRating = this.yasrFakeRating.bind(this);
169
+ this.yasrSaveFakeRatings = this.yasrSaveFakeRatings.bind(this);
170
+ }
171
+
172
+ yasrNumberFakeRatings(event) {
173
+ this.setState({numberFakeRatings: event.target.value});
174
+ }
175
+
176
+ yasrFakeRating(event) {
177
+ this.setState({fakeRating: event.target.value});
178
+ }
179
+
180
+ yasrSaveFakeRatings(event) {
181
+
182
+ const currentPostId = wp.data.select("core/editor").getCurrentPostId();
183
+
184
+ if(this.state.numberFakeRatings > 0 && this.state.numberFakeRatings < 201) {
185
+ this.setState({ajaxResponse: __('Loading, please wait', 'yet-another-stars-rating')});
186
+
187
+ let rating = this.state.fakeRating;
188
+ let number_of_votes = this.state.numberFakeRatings
189
+
190
+ //if select doesn't change value is undefined
191
+ if(rating == null) {
192
+ rating = 5;
193
+ }
194
+
195
+ //declaring function to set response
196
+ let self = this;
197
+ function setResponse(response) {
198
+ if(response === 'OK') {
199
+ self.setState({
200
+ ajaxResponse: __('Done!', 'yet-another-stars-rating'),
201
+ });
202
+ } else {
203
+ self.setState({
204
+ ajaxResponse: __('Error', 'yet-another-stars-rating'),
205
+ });
206
+ }
207
+ }
208
+
209
+ let data = {
210
+ action: 'yasr_adds_fake_ratings',
211
+ yasr_pro_nonce_fake_ratings: yasrConstantGutenberg.yasr_pro_nonce_fake_ratings,
212
+ yasr_pro_fake_number_of_votes: number_of_votes,
213
+ yasr_pro_fake_ratings: rating,
214
+ post_id: currentPostId
215
+ };
216
+
217
+ //Send value to the Server
218
+ jQuery.post(ajaxurl, data, function (response) {
219
+ setResponse(response);
220
+ }).fail(
221
+ function(e, x, settings, exception) {
222
+ setResponse('KO');
223
+ }
224
+ );
225
+
226
+ }
227
+
228
+ }
229
+
230
+ render () {
231
+ let selectDisabled = true;
232
+
233
+ if(JSON.parse(yasrConstantGutenberg.proVersion) === true) {
234
+ selectDisabled = false;
235
+ }
236
+
237
+ return (
238
+ <div>
239
+ <hr/>
240
+ <strong>{__('Add fake ratings', 'yet-another-stars-rating')}</strong>
241
+ <p />
242
+ <div>
243
+ {__('Number of votes', 'yet-another-stars-rating')}
244
+ <br />
245
+ <div>
246
+ <label htmlFor="yasr-pro-fake-number-of-votes">
247
+ <select name="yasr-pro-fake-number-of-votes"
248
+ id="yasr-pro-fake-number-of-votes"
249
+ onChange={this.yasrNumberFakeRatings}
250
+ disabled={selectDisabled}
251
+ >
252
+ <option value="none" defaultValue>0</option>
253
+ <option value="1">1</option>
254
+ <option value="2">2</option>
255
+ <option value="5">5</option>
256
+ <option value="10">10</option>
257
+ <option value="20">20</option>
258
+ <option value="50">50</option>
259
+ <option value="100">100</option>
260
+ <option value="200">200</option>
261
+ </select>
262
+ </label>
263
+ </div>
264
+ </div>
265
+ {__('Rating:', 'yet-another-stars-rating')}
266
+ <div>
267
+ <label htmlFor="yasr-pro-fake-ratings">
268
+ <select name="yasr-pro-fake-ratings"
269
+ id="yasr-pro-fake-ratings"
270
+ value={this.state.fakeRating}
271
+ onChange={this.yasrFakeRating}
272
+ disabled={selectDisabled}
273
+ >
274
+ <option value="5">5</option>
275
+ <option value="4">4</option>
276
+ <option value="3">3</option>
277
+ <option value="2">2</option>
278
+ <option value="1">1</option>
279
+ </select>
280
+ </label>
281
+ <p />
282
+ <div>
283
+ {__(
284
+ 'This will add ratings for yasr_visitor_votes shortcode.',
285
+ 'yet-another-stars-rating')
286
+ }
287
+ </div>
288
+ </div>
289
+ <div>
290
+ <br />
291
+ <button onClick={this.yasrSaveFakeRatings} disabled={selectDisabled}>Save</button>
292
+ <br />
293
+ {this.state.ajaxResponse}
294
+ </div>
295
+ <div className="yasr-metabox-doc-link">
296
+ <a href="https://yetanotherstarsrating.com/yasr_fake_ratings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_top_right"
297
+ target="_blank"
298
+ >
299
+ {__('Help', 'yet-another-stars-rating')}
300
+ </a>
301
+ </div>
302
+ </div>
303
+ );
304
+ }
305
+ }
306
+
307
  class yasrSidebar extends React.Component {
308
 
309
  constructor(props) {
337
  'yet-another-stars-rating')}
338
  </div>
339
  {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert />}
340
+ <p />
341
+ <div className='yasr-metabox-editor-pro-only-box'>
342
+ <div className="yasr-metabox-editor-title-pro-only">
343
+ {__('Pro Only features', 'yet-another-stars-rating')}
344
+ <span className={yasrConstantGutenberg.lockedClass} title={yasrConstantGutenberg.lockedText}/>
345
+ </div>
346
+ <YasrCommentReviewsEnabled />
347
+ <YasrFakeRatings />
348
+ </div>
349
  {YasrBelowSidebar}
350
  </div>
351
  </PanelBody>
357
 
358
  //Custom sidebar
359
  registerPlugin( 'yasr-sidebar', {
360
+ name: 'Yet Another Stars Rating',
361
  icon: 'star-half',
362
+ title: __( 'Yasr: Settings', 'yet-another-stars-rating' ),
363
  render: yasrSidebar
364
  } );
admin/js/src/yasr-editor-screen.js CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  // executes this when the DOM is ready
2
  document.addEventListener('DOMContentLoaded', function(event) {
3
 
@@ -34,6 +39,12 @@ function yasrPrintMetaBoxOverall() {
34
 
35
  //Convert string to number
36
  let overallRating = parseFloat(document.getElementById('yasr-overall-rating-value').value);
 
 
 
 
 
 
37
 
38
  raterJs({
39
  starSize: 32,
@@ -196,19 +207,74 @@ function yasrSwitchItemTypeDiv (itemType) {
196
 
197
  function yasrAdminMultiSet() {
198
 
199
- let divContainer = document.getElementById('yasr-editor-multiset-container');
200
- let nMultiSet = parseInt(divContainer.getAttribute('data-nmultiset'));
201
- let setId = parseInt(divContainer.getAttribute('data-setid'));
202
- let postId = parseInt(divContainer.getAttribute('data-postid'));
 
 
 
 
 
 
 
203
 
204
  yasrPrintAdminMultiSet(setId, postId, nMultiSet);
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  if (nMultiSet > 1) {
207
- jQuery('#yasr-button-select-set').on("click", function () {
208
 
209
  //get the multi data
210
  //overwrite setID
211
- setId = jQuery('#select_set').val();
212
 
213
  jQuery("#yasr-loader-select-multi-set").show();
214
 
@@ -236,46 +302,66 @@ function yasrPrintAdminMultiSet(setId, postid, nMultiSet) {
236
  document.getElementById('yasr-loader-select-multi-set').style.display = 'none';
237
  }
238
 
239
- var yasrMultiSetValue = JSON.parse(response);
 
 
240
 
241
- var content = '';
 
242
 
243
- for (var i = 0; i < yasrMultiSetValue.length; i++) {
244
- var valueName = yasrMultiSetValue[i]['name'];
245
- var valueRating = yasrMultiSetValue[i]['average_rating'];
246
- var valueID = yasrMultiSetValue[i]['id'];
247
 
248
- content += '<tr>';
249
- content += '<td>' + valueName + '</td>';
250
- content += '<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-' + valueID + '" data-rating="'
251
- + valueRating + '" data-multi-idfield="' + valueID + '"></div>';
252
- content += '<span id="yasr-loader-multi-set-field-' + valueID + '" style="display: none">';
253
- content += '<img src="' + yasrCommonData.loaderHtml + '" alt="yasr-loader"></span>';
254
- content += '</span>';
255
- content += '</td>';
256
- content += '</tr>';
257
 
258
- var table = document.getElementById('yasr-table-multi-set-admin');
 
 
259
 
260
- table.innerHTML = content;
261
 
262
- }
263
 
264
- //Show the text "Choose a vote"
265
- document.getElementById('yasr-multi-set-admin-choose-text').style.display = 'block';
266
 
267
- //Set rater for divs
268
- yasrSetRaterAdminMulti(setId);
 
 
 
 
 
269
 
270
- //Show shortcode
271
- document.getElementById('yasr-multi-set-admin-explain').style.display = 'block';
272
 
273
- document.getElementById('yasr-multi-set-admin-explain-with-id-readonly').innerHTML = '<strong>[yasr_multiset setid=' + setId + ']</strong>';
274
- document.getElementById('yasr-multi-set-admin-explain-with-id-visitor').innerHTML = '<strong>[yasr_visitor_multiset setid=' + setId + ']</strong>';
 
 
 
275
 
276
- });
 
 
 
 
277
 
278
- return false; // prevent default click action from happening!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
 
280
  }
281
 
@@ -300,6 +386,8 @@ function yasrSetRaterAdminMulti(setId) {
300
 
301
  let setIdField = parseInt(elem.getAttribute('data-multi-idfield'));
302
  let ratingOnLoad = parseInt(elem.getAttribute('data-rating'));
 
 
303
 
304
  let ratingObjectOnLoad = {
305
  field: setIdField,
@@ -309,37 +397,30 @@ function yasrSetRaterAdminMulti(setId) {
309
  //creating rating array
310
  ratingArray.push(ratingObjectOnLoad);
311
 
312
- raterJs({
313
- starSize: 32,
314
- step: 0.5,
315
- showToolTip: false,
316
- readOnly: false,
317
- element: elem,
318
-
319
- rateCallback: function rateCallback(rating, done) {
320
- rating = rating.toFixed(1);
321
- //Be sure is a number and not a string
322
- rating = parseFloat(rating);
323
- this.setRating(rating); //Set the rating
324
-
325
- //loop the array with existing rates
326
- for (let j = 0; j < ratingArray.length; j++) {
327
- //if the field of the array is the same of the rated field, get the rating
328
- if(ratingArray[j].field === setIdField) {
329
- //the selected rating overwrite the existing one
330
- ratingArray[j].rating = rating;
331
- }
332
  }
 
333
 
334
- ratingValue = JSON.stringify(ratingArray);
335
 
336
- //update hidden field
337
- document.getElementById('yasr-multiset-author-votes').value = ratingValue;
338
 
339
- done();
340
- }
341
 
342
- });
343
 
344
  })(i);
345
 
@@ -425,7 +506,7 @@ function yasrShortcodeCreator() {
425
 
426
  if (nMultiSet === true) {
427
  //Add shortcode for multiple set
428
- jQuery('#yasr-insert-multiset-select').on("click", function () {
429
  var setType = jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();
430
  var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
431
  var showAverage = jQuery("#yasr-hide-average-multiset").is(':checked');
1
+ import {copyToClipboard} from "./yasr-admin-functions";
2
+ import {yasrSetRaterValue} from "../../../includes/js/src/modules/yasrSetRaterValue";
3
+ import {v4 as uuidv4} from 'uuid';
4
+
5
+
6
  // executes this when the DOM is ready
7
  document.addEventListener('DOMContentLoaded', function(event) {
8
 
39
 
40
  //Convert string to number
41
  let overallRating = parseFloat(document.getElementById('yasr-overall-rating-value').value);
42
+ const copyOverall = document.getElementById('yasr-editor-copy-overall');
43
+
44
+ copyOverall.onclick = function (event) {
45
+ let el = document.getElementById(event.target.id);
46
+ copyToClipboard(el.textContent.trim());
47
+ }
48
 
49
  raterJs({
50
  starSize: 32,
207
 
208
  function yasrAdminMultiSet() {
209
 
210
+ let divContainer = document.getElementById('yasr-editor-multiset-container');
211
+ let nMultiSet = parseInt(divContainer.getAttribute('data-nmultiset'));
212
+ let setId = parseInt(divContainer.getAttribute('data-setid'));
213
+ let postId = parseInt(divContainer.getAttribute('data-postid'));
214
+ const copyRoMultiset = document.getElementById('yasr-editor-copy-readonly-multiset');
215
+ const copyVisitorMultiset = document.getElementById('yasr-editor-copy-visitor-multiset');
216
+ const copyAverageMultiSet = document.getElementById('yasr-editor-copy-average-multiset');
217
+ const copyAverageVVMultiSet = document.getElementById('yasr-editor-copy-average-vvmultiset');
218
+ const reviewsEnabled = document.getElementById('yasr-pro-comments-enabled-yes');
219
+ const multiSetinReview = document.getElementById('yasr-pro-multiset-review-switcher');
220
+
221
 
222
  yasrPrintAdminMultiSet(setId, postId, nMultiSet);
223
 
224
+ copyRoMultiset.onclick = function (event) {
225
+ let el = document.getElementById(event.target.id);
226
+ copyToClipboard(el.textContent.trim());
227
+ }
228
+
229
+ copyVisitorMultiset.onclick = function (event) {
230
+ let el = document.getElementById(event.target.id);
231
+ copyToClipboard(el.textContent.trim());
232
+ }
233
+
234
+ copyAverageMultiSet.onclick = function (event) {
235
+ let el = document.getElementById(event.target.id);
236
+ copyToClipboard(el.textContent.trim());
237
+ }
238
+
239
+ copyAverageVVMultiSet.onclick = function (event) {
240
+ let el = document.getElementById(event.target.id);
241
+ copyToClipboard(el.textContent.trim());
242
+ }
243
+
244
+ //add event listener to synchronize switchers
245
+ if(multiSetinReview !== null) {
246
+
247
+ //this only works in classic editor
248
+ if(reviewsEnabled !== null) {
249
+ //when reviews in comment are disabled, disable also multiset switcher
250
+ reviewsEnabled.addEventListener('change', (event) => {
251
+ if (!event.currentTarget.checked) {
252
+ multiSetinReview.checked = false;
253
+ }
254
+ })
255
+ }
256
+
257
+ //when multiset switcher is enabled, enable also reviews in comment switcher
258
+ multiSetinReview.addEventListener('change', (event) => {
259
+ if (event.currentTarget.checked) {
260
+ //if it is classic editor, check reviewsEnabled on true
261
+ if(reviewsEnabled !== null) {
262
+ reviewsEnabled.checked = true;
263
+ } else {
264
+ //if this is gutenberg, use document.getElementById on change to get the current state and check it
265
+ document.getElementById('yasr-comment-reviews-disabled-switch').checked = true;
266
+ }
267
+ }
268
+ });
269
+
270
+ }
271
+
272
  if (nMultiSet > 1) {
273
+ jQuery('#yasr_select_set').on("change", function () {
274
 
275
  //get the multi data
276
  //overwrite setID
277
+ setId = jQuery('#yasr_select_set').val();
278
 
279
  jQuery("#yasr-loader-select-multi-set").show();
280
 
302
  document.getElementById('yasr-loader-select-multi-set').style.display = 'none';
303
  }
304
 
305
+ let yasrMultiSetValue = JSON.parse(response);
306
+ let tableAuthorMulti = document.getElementById('yasr-table-multi-set-admin');
307
+ let tableAuthorVisitor = document.getElementById('yasr-table-multi-set-admin-visitor');
308
 
309
+ yasrReturnTableMultiset(yasrMultiSetValue, tableAuthorMulti);
310
+ yasrReturnTableMultiset(yasrMultiSetValue, tableAuthorVisitor, false);
311
 
312
+ //Set rater for divs
313
+ yasrSetRaterAdminMulti(setId);
 
 
314
 
315
+ let spanWithSetID = document.getElementsByClassName('yasr-editor-multiset-id');
 
 
 
 
 
 
 
 
316
 
317
+ for (let i = 0; i < spanWithSetID.length; i++) {
318
+ spanWithSetID[i].innerText = setId;
319
+ }
320
 
321
+ });
322
 
323
+ return false; // prevent default click action from happening!
324
 
325
+ }
 
326
 
327
+ /**
328
+ *
329
+ * @param yasrMultiSetValue
330
+ * @param table
331
+ * @param authorMultiset
332
+ */
333
+ function yasrReturnTableMultiset (yasrMultiSetValue, table, authorMultiset=true) {
334
 
335
+ let content = '';
 
336
 
337
+ for (let i = 0; i < yasrMultiSetValue.length; i++) {
338
+ let valueName = yasrMultiSetValue[i]['name'];
339
+ let valueRating = 0;
340
+ let loader = '';
341
+ let readonly = true;
342
 
343
+ if(authorMultiset !== false) {
344
+ valueRating = yasrMultiSetValue[i]['average_rating'];
345
+ loader = '<img src="' + yasrCommonData.loaderHtml + '" alt="yasr-loader"></span>';
346
+ readonly = false;
347
+ }
348
 
349
+ let valueID = yasrMultiSetValue[i]['id'];
350
+
351
+ content += '<tr>';
352
+ content += '<td>' + valueName + '</td>';
353
+ content += '<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-' + uuidv4() + '" data-rating="'
354
+ + valueRating + '" data-multi-idfield="' + valueID + '" data-readonly="'+ readonly +'"></div>';
355
+ content += '</td>';
356
+ content += '</tr>';
357
+ }
358
+
359
+ if(authorMultiset === false) {
360
+ let button = '<tr><td colspan="2"><input type="submit" class="button button-primary" value="Submit!" disabled></td></tr>';
361
+ content += button;
362
+ }
363
+
364
+ table.innerHTML = content;
365
 
366
  }
367
 
386
 
387
  let setIdField = parseInt(elem.getAttribute('data-multi-idfield'));
388
  let ratingOnLoad = parseInt(elem.getAttribute('data-rating'));
389
+ //convert into boolean https://stackoverflow.com/a/264037/3472877
390
+ let readOnly = (elem.getAttribute('data-readonly') === 'true');
391
 
392
  let ratingObjectOnLoad = {
393
  field: setIdField,
397
  //creating rating array
398
  ratingArray.push(ratingObjectOnLoad);
399
 
400
+ const rateCallback = function (rating, done) {
401
+ rating = rating.toFixed(1);
402
+ //Be sure is a number and not a string
403
+ rating = parseFloat(rating);
404
+ this.setRating(rating); //Set the rating
405
+
406
+ //loop the array with existing rates
407
+ for (let j = 0; j < ratingArray.length; j++) {
408
+ //if the field of the array is the same of the rated field, get the rating
409
+ if(ratingArray[j].field === setIdField) {
410
+ //the selected rating overwrite the existing one
411
+ ratingArray[j].rating = rating;
 
 
 
 
 
 
 
 
412
  }
413
+ }
414
 
415
+ ratingValue = JSON.stringify(ratingArray);
416
 
417
+ //update hidden field
418
+ document.getElementById('yasr-multiset-author-votes').value = ratingValue;
419
 
420
+ done();
421
+ }
422
 
423
+ yasrSetRaterValue(32, htmlId, false, 0.5, readOnly, false, rateCallback);
424
 
425
  })(i);
426
 
506
 
507
  if (nMultiSet === true) {
508
  //Add shortcode for multiple set
509
+ jQuery('#yasr-insert-multiset-select').on("change", function () {
510
  var setType = jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();
511
  var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
512
  var showAverage = jQuery("#yasr-hide-average-multiset").is(':checked');
admin/js/yasr-editor-screen.js CHANGED
@@ -1 +1 @@
1
- (()=>{function e(e){"Product"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"LocalBusiness"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Recipe"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"SoftwareApplication"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Book"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Movie"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none"):document.getElementById("yasr-metabox-info-snippet-container").style.display="none"}function t(e,t,n){const a={action:"yasr_send_id_nameset",set_id:e,post_id:t};return jQuery.post(ajaxurl,a,(function(t){n>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");for(var a=JSON.parse(t),o="",s=0;s<a.length;s++){var i=a[s].name,r=a[s].average_rating,l=a[s].id;o+="<tr>",o+="<td>"+i+"</td>",o+='<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-'+l+'" data-rating="'+r+'" data-multi-idfield="'+l+'"></div>',o+='<span id="yasr-loader-multi-set-field-'+l+'" style="display: none">',o+='<img src="'+yasrCommonData.loaderHtml+'" alt="yasr-loader"></span>',o+="</span>",o+="</td>",o+="</tr>",document.getElementById("yasr-table-multi-set-admin").innerHTML=o}document.getElementById("yasr-multi-set-admin-choose-text").style.display="block",function(e){document.getElementById("yasr-multiset-id").value=e;let t=document.getElementsByClassName("yasr-multiset-admin"),n=[],a=!1;for(let e=0;e<t.length;e++)!function(e){let o=t.item(e).id,s=document.getElementById(o),i=parseInt(s.getAttribute("data-multi-idfield")),r=parseInt(s.getAttribute("data-rating")),l={field:i,rating:r};n.push(l),raterJs({starSize:32,step:.5,showToolTip:!1,readOnly:!1,element:s,rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);for(let t=0;t<n.length;t++)n[t].field===i&&(n[t].rating=e);a=JSON.stringify(n),document.getElementById("yasr-multiset-author-votes").value=a,t()}})}(e)}(e),document.getElementById("yasr-multi-set-admin-explain").style.display="block",document.getElementById("yasr-multi-set-admin-explain-with-id-readonly").innerHTML="<strong>[yasr_multiset setid="+e+"]</strong>",document.getElementById("yasr-multi-set-admin-explain-with-id-visitor").innerHTML="<strong>[yasr_visitor_multiset setid="+e+"]</strong>"})),!1}document.addEventListener("DOMContentLoaded",(function(n){var a;!0!==document.body.classList.contains("block-editor-page")&&(function(){let e=parseFloat(document.getElementById("yasr-overall-rating-value").value);raterJs({starSize:32,step:.1,showToolTip:!1,rating:e,readOnly:!1,element:document.getElementById("yasr-rater-overall"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),document.getElementById("yasr-overall-rating-value").value=e,this.setRating(e);document.getElementById("yasr_overall_text").textContent="You've rated "+e,t()}})}(),a={action:"yasr_create_shortcode"},jQuery.get(ajaxurl,a,(function(e){jQuery(e).appendTo("body").hide(),function(){let e=!1;null!==document.getElementById("yasr-editor-multiset-container")&&(e=!0);const t=document.getElementById("yasr-tinypopup-link-doc");jQuery("#yasr-link-tab-main").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-main").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-main").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-link-tab-charts").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-charts").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-charts").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-rankings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-overall").on("click",(function(){jQuery("#yasr-overall-choose-size").toggle("slow")})),jQuery("#yasr-visitor-votes").on("click",(function(){jQuery("#yasr-visitor-choose-size").toggle("slow")})),jQuery(".yasr-tinymce-shortcode-buttons").on("click",(function(){let e=this.getAttribute("data-shortcode");null==tinyMCE.activeEditor?jQuery("#content").append(e):tinyMCE.activeEditor.execCommand("mceInsertContent",0,e),tb_remove()})),!0===e&&jQuery("#yasr-insert-multiset-select").on("click",(function(){var e=jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();let t;t=jQuery("#yasr-allow-vote-multiset").is(":checked")?"[yasr_multiset setid=":"[yasr_visitor_multiset setid=",t+=e,jQuery("#yasr-hide-average-multiset").is(":checked")&&(t+=" show_average='no'"),t+="]",null==tinyMCE.activeEditor?jQuery("#content").append(t):tinyMCE.activeEditor.execCommand("mceInsertContent",0,t),tb_remove()}))}()}))),function(){jQuery("#yasr-metabox-below-editor-structured-data-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-structured-data-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-structured-data").show()})),jQuery("#yasr-metabox-below-editor-multiset-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-multiset-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-multiset").show()}));let n=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let e=document.getElementById("yasr-editor-multiset-container"),n=parseInt(e.getAttribute("data-nmultiset")),a=parseInt(e.getAttribute("data-setid")),o=parseInt(e.getAttribute("data-postid"));t(a,o,n),n>1&&jQuery("#yasr-button-select-set").on("click",(function(){return a=jQuery("#select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),t(a,o,n),!1}))}(),e(n)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){e(this.value)}))})();
1
+ (()=>{"use strict";const e=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)};function t(e,t,n=!1,o=.1,a=!0,i=!1,s=!1){let r;r=n||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:r,step:o,readOnly:a,rating:i,rateCallback:s})}var n;tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var o=new Uint8Array(16);function a(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}const i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&i.test(e)};for(var r=[],l=0;l<256;++l)r.push((l+256).toString(16).substr(1));const d=function(e,t,n){var o=(e=e||{}).random||(e.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=o[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n}(o)};function y(e){"Product"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"LocalBusiness"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Recipe"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"SoftwareApplication"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Book"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Movie"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none"):document.getElementById("yasr-metabox-info-snippet-container").style.display="none"}function c(e,n,o){const a={action:"yasr_send_id_nameset",set_id:e,post_id:n};return jQuery.post(ajaxurl,a,(function(n){o>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");let a=JSON.parse(n),i=document.getElementById("yasr-table-multi-set-admin"),s=document.getElementById("yasr-table-multi-set-admin-visitor");m(a,i),m(a,s,!1),function(e){document.getElementById("yasr-multiset-id").value=e;let n=document.getElementsByClassName("yasr-multiset-admin"),o=[],a=!1;for(let e=0;e<n.length;e++)!function(e){let i=n.item(e).id,s=document.getElementById(i),r=parseInt(s.getAttribute("data-multi-idfield")),l=parseInt(s.getAttribute("data-rating")),d="true"===s.getAttribute("data-readonly"),y={field:r,rating:l};o.push(y),t(32,i,!1,.5,d,!1,(function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);for(let t=0;t<o.length;t++)o[t].field===r&&(o[t].rating=e);a=JSON.stringify(o),document.getElementById("yasr-multiset-author-votes").value=a,t()}))}(e)}(e);let r=document.getElementsByClassName("yasr-editor-multiset-id");for(let t=0;t<r.length;t++)r[t].innerText=e})),!1}function m(e,t,n=!0){let o="";for(let t=0;t<e.length;t++){let a=e[t].name,i=0,s="",r=!0;!1!==n&&(i=e[t].average_rating,s='<img src="'+yasrCommonData.loaderHtml+'" alt="yasr-loader"></span>',r=!1);let l=e[t].id;o+="<tr>",o+="<td>"+a+"</td>",o+='<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-'+d()+'" data-rating="'+i+'" data-multi-idfield="'+l+'" data-readonly="'+r+'"></div>',o+="</td>",o+="</tr>"}!1===n&&(o+='<tr><td colspan="2"><input type="submit" class="button button-primary" value="Submit!" disabled></td></tr>'),t.innerHTML=o}document.addEventListener("DOMContentLoaded",(function(t){var n;!0!==document.body.classList.contains("block-editor-page")&&(function(){let t=parseFloat(document.getElementById("yasr-overall-rating-value").value);document.getElementById("yasr-editor-copy-overall").onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},raterJs({starSize:32,step:.1,showToolTip:!1,rating:t,readOnly:!1,element:document.getElementById("yasr-rater-overall"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),document.getElementById("yasr-overall-rating-value").value=e,this.setRating(e);document.getElementById("yasr_overall_text").textContent="You've rated "+e,t()}})}(),n={action:"yasr_create_shortcode"},jQuery.get(ajaxurl,n,(function(e){jQuery(e).appendTo("body").hide(),function(){let e=!1;null!==document.getElementById("yasr-editor-multiset-container")&&(e=!0);const t=document.getElementById("yasr-tinypopup-link-doc");jQuery("#yasr-link-tab-main").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-main").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-main").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-link-tab-charts").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-charts").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-charts").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-rankings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-overall").on("click",(function(){jQuery("#yasr-overall-choose-size").toggle("slow")})),jQuery("#yasr-visitor-votes").on("click",(function(){jQuery("#yasr-visitor-choose-size").toggle("slow")})),jQuery(".yasr-tinymce-shortcode-buttons").on("click",(function(){let e=this.getAttribute("data-shortcode");null==tinyMCE.activeEditor?jQuery("#content").append(e):tinyMCE.activeEditor.execCommand("mceInsertContent",0,e),tb_remove()})),!0===e&&jQuery("#yasr-insert-multiset-select").on("change",(function(){var e=jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();let t;t=jQuery("#yasr-allow-vote-multiset").is(":checked")?"[yasr_multiset setid=":"[yasr_visitor_multiset setid=",t+=e,jQuery("#yasr-hide-average-multiset").is(":checked")&&(t+=" show_average='no'"),t+="]",null==tinyMCE.activeEditor?jQuery("#content").append(t):tinyMCE.activeEditor.execCommand("mceInsertContent",0,t),tb_remove()}))}()}))),function(){jQuery("#yasr-metabox-below-editor-structured-data-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-structured-data-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-structured-data").show()})),jQuery("#yasr-metabox-below-editor-multiset-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-multiset-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-multiset").show()}));let t=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let t=document.getElementById("yasr-editor-multiset-container"),n=parseInt(t.getAttribute("data-nmultiset")),o=parseInt(t.getAttribute("data-setid")),a=parseInt(t.getAttribute("data-postid"));const i=document.getElementById("yasr-editor-copy-readonly-multiset"),s=document.getElementById("yasr-editor-copy-visitor-multiset"),r=document.getElementById("yasr-editor-copy-average-multiset"),l=document.getElementById("yasr-editor-copy-average-vvmultiset"),d=document.getElementById("yasr-pro-comments-enabled-yes"),y=document.getElementById("yasr-pro-multiset-review-switcher");c(o,a,n),i.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},s.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},r.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},l.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},null!==y&&(null!==d&&d.addEventListener("change",(e=>{e.currentTarget.checked||(y.checked=!1)})),y.addEventListener("change",(e=>{e.currentTarget.checked&&(null!==d?d.checked=!0:document.getElementById("yasr-comment-reviews-disabled-switch").checked=!0)}))),n>1&&jQuery("#yasr_select_set").on("change",(function(){return o=jQuery("#yasr_select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),c(o,a,n),!1}))}(),y(t)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){y(this.value)}))})();
admin/settings/classes/YasrSettings.php CHANGED
@@ -258,6 +258,7 @@ class YasrSettings {
258
  $array_options = array (
259
  'top' => __('Before the content', 'yet-another-stars-rating'),
260
  'bottom' => __('After the content', 'yet-another-stars-rating'),
 
261
  );
262
  $default = $option['auto_insert_where'];
263
  $name = 'yasr_general_options[auto_insert_where]';
@@ -465,7 +466,7 @@ class YasrSettings {
465
  public function vvStats($option) {
466
  ?>
467
  <div class="yasr-settings-row">
468
- <div class="yasr-settings-col-20">
469
  <div class="yasr-onoffswitch-big">
470
  <input type="checkbox" name="yasr_general_options[visitors_stats]" class="yasr-onoffswitch-checkbox"
471
  id="yasr-general-options-visitors-stats-switch" <?php if ($option['visitors_stats'] === 'yes') {
@@ -483,7 +484,7 @@ class YasrSettings {
483
  <br />
484
  <p>&nbsp;</p>
485
  </div>
486
- <div class="yasr-settings-col-70">
487
  <strong>
488
  <?php esc_html_e('Example', 'yet-another-stars-rating') ?>:
489
  </strong>
@@ -925,13 +926,20 @@ class YasrSettings {
925
 
926
  }
927
 
928
- public static function echoSettingFields($elementsType_array, $option) {
 
 
 
 
 
 
 
929
  $string_input = false;
930
 
931
  foreach($elementsType_array as $property) {
932
 
933
  //concatenate yasr_general_options with property name
934
- $element_name = 'yasr_general_options[' . $property['name'] . ']';
935
 
936
  if(isset($property['type'])) {
937
  if($property['type'] === 'select') {
@@ -944,8 +952,9 @@ class YasrSettings {
944
  }
945
  } //to use text, there is no need to set the type element
946
  else {
 
947
  $string_input = YasrPhpFieldsHelper::text(
948
- $property['class'], '', $element_name, $property['id'], '', esc_attr($option[$property['name']])
949
  );
950
  }
951
 
258
  $array_options = array (
259
  'top' => __('Before the content', 'yet-another-stars-rating'),
260
  'bottom' => __('After the content', 'yet-another-stars-rating'),
261
+ 'both' => __('Both', 'yet-another-stars-rating')
262
  );
263
  $default = $option['auto_insert_where'];
264
  $name = 'yasr_general_options[auto_insert_where]';
466
  public function vvStats($option) {
467
  ?>
468
  <div class="yasr-settings-row">
469
+ <div class="yasr-settings-col-30">
470
  <div class="yasr-onoffswitch-big">
471
  <input type="checkbox" name="yasr_general_options[visitors_stats]" class="yasr-onoffswitch-checkbox"
472
  id="yasr-general-options-visitors-stats-switch" <?php if ($option['visitors_stats'] === 'yes') {
484
  <br />
485
  <p>&nbsp;</p>
486
  </div>
487
+ <div class="yasr-settings-col-60">
488
  <strong>
489
  <?php esc_html_e('Example', 'yet-another-stars-rating') ?>:
490
  </strong>
926
 
927
  }
928
 
929
+ /**
930
+ * @author Dario Curvino <@dudo>
931
+ * @since
932
+ * @param $elementsType_array
933
+ * @param $option
934
+ * @param string $option_prefix
935
+ */
936
+ public static function echoSettingFields($elementsType_array, $option, $option_prefix='yasr_general_options') {
937
  $string_input = false;
938
 
939
  foreach($elementsType_array as $property) {
940
 
941
  //concatenate yasr_general_options with property name
942
+ $element_name = $option_prefix.'[' . $property['name'] . ']';
943
 
944
  if(isset($property['type'])) {
945
  if($property['type'] === 'select') {
952
  }
953
  } //to use text, there is no need to set the type element
954
  else {
955
+ $placeholder = isset($property['placeholder']) ? $property['placeholder'] : '';
956
  $string_input = YasrPhpFieldsHelper::text(
957
+ $property['class'], '', $element_name, $property['id'], $placeholder, esc_attr($option[$property['name']])
958
  );
959
  }
960
 
admin/settings/classes/YasrSettingsRankings.php CHANGED
@@ -84,7 +84,7 @@ class YasrSettingsRankings {
84
  <strong>
85
  <?php
86
  esc_html_e( 'How many rows?', 'yet-another-stars-rating');
87
- echo wp_kses_post(YASR_LOCKED_FEATURE);
88
  ?>
89
  </strong>
90
  <br/>
@@ -116,7 +116,7 @@ class YasrSettingsRankings {
116
  <strong>
117
  <?php esc_html_e('Size', 'yet-another-stars-rating'); ?>
118
  </strong>
119
- <?php echo wp_kses_post(YASR_LOCKED_FEATURE); ?>
120
  <br/>
121
  <?php
122
  $name = 'yasr-builder-size';
@@ -157,7 +157,7 @@ class YasrSettingsRankings {
157
  <strong>
158
  <?php
159
  esc_html_e('At least...', 'yet-another-stars-rating');
160
- echo wp_kses_post(YASR_LOCKED_FEATURE);
161
  ?>
162
  </strong>
163
  <!-- Min. number of votes for most rated -->
84
  <strong>
85
  <?php
86
  esc_html_e( 'How many rows?', 'yet-another-stars-rating');
87
+ echo YASR_LOCKED_FEATURE;
88
  ?>
89
  </strong>
90
  <br/>
116
  <strong>
117
  <?php esc_html_e('Size', 'yet-another-stars-rating'); ?>
118
  </strong>
119
+ <?php echo YASR_LOCKED_FEATURE; ?>
120
  <br/>
121
  <?php
122
  $name = 'yasr-builder-size';
157
  <strong>
158
  <?php
159
  esc_html_e('At least...', 'yet-another-stars-rating');
160
+ echo YASR_LOCKED_FEATURE;
161
  ?>
162
  </strong>
163
  <!-- Min. number of votes for most rated -->
admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -437,7 +437,7 @@ function yasr_custom_admin_footer( $text )
437
  if ( isset( $_GET['page'] ) ) {
438
  $yasr_page = $_GET['page'];
439
 
440
- if ( $yasr_page === 'yasr_settings_page' ) {
441
  $custom_text = ' | <i>';
442
  $custom_text .= sprintf(
443
  __( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
437
  if ( isset( $_GET['page'] ) ) {
438
  $yasr_page = $_GET['page'];
439
 
440
+ if ( $yasr_page === 'yasr_settings_page' || $yasr_page === 'yasr_stats_page' ) {
441
  $custom_text = ' | <i>';
442
  $custom_text .= sprintf(
443
  __( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
admin/yasr-admin-functions.php CHANGED
@@ -151,6 +151,8 @@ function yasr_add_pages() {
151
 
152
  global $yasr_settings_page;
153
 
 
 
154
  //Add Settings Page
155
  $yasr_settings_page = add_menu_page(
156
  __('Yet Another Stars Rating: settings', 'yet-another-stars-rating'), //Page Title
@@ -171,8 +173,8 @@ function yasr_add_pages() {
171
 
172
  add_submenu_page(
173
  'yasr_settings_page',
174
- 'Yet Another Stars Rating: All Rating',
175
- 'Stats',
176
  'manage_options',
177
  'yasr_stats_page',
178
  'yasr_stats_page_callback'
151
 
152
  global $yasr_settings_page;
153
 
154
+ $stats_menu_title = 'Manage Ratings <span class="dashicons dashicons-chart-line"></span>';
155
+
156
  //Add Settings Page
157
  $yasr_settings_page = add_menu_page(
158
  __('Yet Another Stars Rating: settings', 'yet-another-stars-rating'), //Page Title
173
 
174
  add_submenu_page(
175
  'yasr_settings_page',
176
+ 'Yet Another Stars Rating: All Ratings',
177
+ $stats_menu_title,
178
  'manage_options',
179
  'yasr_stats_page',
180
  'yasr_stats_page_callback'
admin/yasr-admin-init.php CHANGED
@@ -38,13 +38,18 @@ define('YASR_CSS_DIR_ADMIN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/
38
 
39
  //this define must triggered after the active theme's functions.php file is loaded
40
  add_action('init', function (){
 
41
  $text = __('This feature is available only in the pro version', 'yet-another-stars-rating');
42
- $lockImage =
43
  apply_filters('yasr_feature_locked',
44
  '<span class="dashicons dashicons-lock" title="'.$text.'"></span>',
45
  10,
46
  1);
47
- define ('YASR_LOCKED_FEATURE', $lockImage);
 
 
 
 
48
  });
49
 
50
 
38
 
39
  //this define must triggered after the active theme's functions.php file is loaded
40
  add_action('init', function (){
41
+
42
  $text = __('This feature is available only in the pro version', 'yet-another-stars-rating');
43
+ $lock_image =
44
  apply_filters('yasr_feature_locked',
45
  '<span class="dashicons dashicons-lock" title="'.$text.'"></span>',
46
  10,
47
  1);
48
+
49
+ $html_disabled_attribute = apply_filters('yasr_feature_locked_html_attribute', 'disabled', 10, 1);
50
+
51
+ define ('YASR_LOCKED_FEATURE', $lock_image);
52
+ define ('YASR_LOCKED_FEATURE_HTML_ATTRIBUTE', $html_disabled_attribute);
53
  });
54
 
55
 
admin/yasr-update-functions.php CHANGED
@@ -16,172 +16,15 @@ function yasr_update_version() {
16
 
17
  if (YASR_VERSION_INSTALLED !== false) {
18
 
19
- //remove end 2021
20
- if (version_compare(YASR_VERSION_INSTALLED, '2.0.9') === -1) {
21
-
22
- //drop useless multi_set_id on yasr log table
23
- $wpdb->query("ALTER TABLE " . YASR_LOG_TABLE . " DROP multi_set_id");
24
-
25
- //change user_id in bigint 20 (just like the users table do)
26
- //change vote to useless 11,1 to 2,1
27
- //format DECIMAL(M, D) where M is the maximum number of digits (the precision) and D is the
28
- //number of digits to the right of the decimal point (the scale).
29
- $wpdb->query("ALTER TABLE " . YASR_LOG_TABLE .
30
- " CHANGE user_id user_id bigint(20) NOT NULL AFTER post_id,
31
- CHANGE vote vote decimal(2,1) NOT NULL AFTER user_id");
32
-
33
- $sql_yasr_log_multi_set_table = "CREATE TABLE " . YASR_LOG_MULTI_SET . " (
34
- id bigint(20) NOT NULL AUTO_INCREMENT,
35
- field_id int(2) NOT NULL,
36
- set_type int(2) NOT NULL,
37
- post_id bigint(20) NOT NULL,
38
- vote decimal(2,1) NOT NULL,
39
- user_id bigint(20) NOT NULL,
40
- date datetime NOT NULL,
41
- ip varchar(45) COLLATE 'utf8_unicode_ci' NOT NULL,
42
- PRIMARY KEY (id),
43
- UNIQUE KEY id (id)
44
- ) COLLATE 'utf8_unicode_ci'";
45
-
46
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
47
-
48
- dbDelta($sql_yasr_log_multi_set_table);
49
-
50
- yasr_import_multiset_author();
51
-
52
- }
53
-
54
- //remove end 2021
55
- if (version_compare(YASR_VERSION_INSTALLED, '2.1.0') === -1) {
56
- $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
57
-
58
- $sql_import_multiset = $wpdb->get_results(
59
- "SELECT
60
- post_id,
61
- set_type,
62
- field_id,
63
- number_of_votes,
64
- sum_votes/number_of_votes as average
65
- FROM $old_yasr_table
66
- WHERE number_of_votes > 0
67
- AND sum_votes > 0
68
- ORDER BY post_id, set_type",
69
- ARRAY_A
70
- );
71
-
72
- if (!empty($sql_import_multiset)) {
73
- foreach ($sql_import_multiset as $multiset_ratings) {
74
- for ($i = 0; $i < $multiset_ratings['number_of_votes']; $i++) {
75
- $rating_to_save = array(
76
- 'field_id' => $multiset_ratings['field_id'],
77
- 'set_type' => $multiset_ratings['set_type'],
78
- 'post_id' => $multiset_ratings['post_id'],
79
- 'vote' => $multiset_ratings['average']
80
- );
81
- $data_format = array('%d', '%d', '%d', '%f');
82
- $wpdb->insert(YASR_LOG_MULTI_SET, $rating_to_save, $data_format);
83
- }
84
- }
85
- }
86
- }
87
-
88
- //remove end 2021
89
- //this fix a bug of table not created on version 2.0.9 and 2.1.0
90
- if (version_compare(YASR_VERSION_INSTALLED, '2.1.1') === -1) {
91
- $multi_set_name_exists = $wpdb->get_var("SELECT COUNT(1) FROM " . YASR_MULTI_SET_NAME_TABLE);
92
-
93
- $multi_set_field_exists = $wpdb->get_var("SELECT COUNT(1) FROM " . YASR_MULTI_SET_FIELDS_TABLE);
94
-
95
- if ($multi_set_name_exists === NULL || $multi_set_field_exists === NULL) {
96
- YasrOnInstall::createTables();
97
- }
98
- }
99
-
100
- /*
101
- * On version 2.1.0 set_id in YASR_MULTI_SET_NAME_TABLE is set as autoincrement by default
102
- * In the existing installations, set_id could be = 0
103
- * Altering set_id to auto_increment will cause a change from 0 to 1
104
- * Here is the fix
105
- */
106
-
107
- if (YASR_VERSION_INSTALLED === '2.1.0' || YASR_VERSION_INSTALLED === '2.1.1') {
108
- //First I've to check if the column set_id is auto increment
109
- $column_auto_increment = null;
110
- $sql_check_auto_increment = "
111
- SELECT EXTRA
112
- FROM INFORMATION_SCHEMA.COLUMNS
113
- WHERE TABLE_NAME='" . YASR_MULTI_SET_NAME_TABLE . "'
114
- AND COLUMN_NAME = 'set_id'
115
- AND EXTRA like '%auto_increment%'
116
- ";
117
-
118
- $column_auto_increment = $wpdb->get_var($sql_check_auto_increment);
119
-
120
- //if the column is not auto increment, return
121
- if ($column_auto_increment === 'auto_increment') {
122
-
123
- $set_with_id_zero_exists = $wpdb->get_results("
124
- SELECT parent_set_id FROM "
125
- . YASR_MULTI_SET_FIELDS_TABLE .
126
- " WHERE parent_set_id = 0
127
- LIMIT 1", ARRAY_A
128
- );
129
-
130
- //if array is not empty
131
- if (!empty($set_with_id_zero_exists)) {
132
- $sql_no_auto_increment = $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_NAME_TABLE .
133
- " CHANGE set_id set_id int(2)
134
- NOT NULL FIRST");
135
-
136
- //if autoincrement has been removed,
137
- //change set value from 1 to 0
138
- //At this point, we're 100% sure that 1 was 0 before
139
- if ($sql_no_auto_increment === true) {
140
- $wpdb->update(
141
- YASR_MULTI_SET_NAME_TABLE,
142
- //new data
143
- array(
144
- 'set_id' => 0
145
- ),
146
- //where
147
- array(
148
- 'set_id' => 1
149
- ),
150
- '%d',
151
- '%d'
152
- );
153
- }
154
- }
155
-
156
- }
157
-
158
- }
159
-
160
- //yasr before 2.1.3 was using JSON_OBJECT to import data.
161
- //This function doesn't works with all servers, and import can fail
162
- //Here I check if no meta exists and try to import it again
163
- if (YASR_VERSION_INSTALLED === '2.0.9' || YASR_VERSION_INSTALLED === '2.1.0'
164
- || YASR_VERSION_INSTALLED === '2.1.1' || YASR_VERSION_INSTALLED === '2.1.2') {
165
-
166
- $sql_meta_multiset = $wpdb->query('SELECT * FROM ' . $wpdb->postmeta .
167
- ' WHERE (meta_key LIKE \'%yasr_multiset_author_votes%\'
168
- OR meta_value LIKE \'%yasr_multiset_author_votes%\')
169
- ');
170
-
171
- //if no meta are found, try to import data again
172
- if ($sql_meta_multiset === 0) {
173
- yasr_import_multiset_author();
174
- }
175
-
176
- }
177
-
178
  //In version 2.4.3 is added a setting to show stars near the post title
 
179
  if (version_compare(YASR_VERSION_INSTALLED, '2.4.3') === -1) {
180
  $yasr_stored_options['stars_title'] = 'no';
181
  update_option('yasr_general_options', $yasr_stored_options);
182
  }
183
 
184
  //In version 2.6.6 %overall_rating% pattern is replaced with %rating%
 
185
  if (version_compare(YASR_VERSION_INSTALLED, '2.6.6') === -1) {
186
  if(array_key_exists('text_before_overall', $yasr_stored_options)) {
187
  $yasr_stored_options['text_before_overall'] =
@@ -193,6 +36,7 @@ function yasr_update_version() {
193
 
194
  //In version 2.7.4 option "text_before_stars" is removed.
195
  //if it was set to 0, be sure that text before overall is empty
 
196
  if (version_compare(YASR_VERSION_INSTALLED, '2.7.4') === -1) {
197
  if (array_key_exists('text_before_stars', $yasr_stored_options)) {
198
  if($yasr_stored_options['text_before_stars'] === 0) {
@@ -203,6 +47,12 @@ function yasr_update_version() {
203
  }
204
  }
205
 
 
 
 
 
 
 
206
  } //Endif yasr_version_installed !== false
207
 
208
 
@@ -213,71 +63,4 @@ function yasr_update_version() {
213
 
214
  }
215
 
216
- }
217
-
218
- function yasr_import_multiset_author () {
219
-
220
- global $wpdb;
221
-
222
- $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
223
-
224
- $sql_import_author_multiset = $wpdb->get_results(
225
- "SELECT post_id, set_type AS set_id,
226
- CONCAT(
227
- '[',
228
- GROUP_CONCAT(
229
- CONCAT(
230
- '{\"field\":', field_id,', \"rating\":',votes,'}'
231
- )
232
- ),
233
- ']'
234
- ) AS fields_and_ratings
235
- FROM $old_yasr_table
236
- WHERE post_id IN (
237
- SELECT post_id
238
- FROM $old_yasr_table
239
- GROUP BY post_id
240
- HAVING SUM(votes)>0
241
- )
242
- GROUP BY post_id, set_type
243
- ORDER BY post_id, set_type", ARRAY_A
244
- );
245
-
246
- if(!empty($sql_import_author_multiset)) {
247
- //just the same code used in yasr_save_multiset_editor
248
- $i = 0;
249
- foreach ($sql_import_author_multiset as $multiset_ratings) {
250
-
251
- $post_id = $multiset_ratings['post_id'];
252
- $set_id = (int)$multiset_ratings['set_id'];
253
- $field_and_vote_array = json_decode($multiset_ratings['fields_and_ratings']);
254
-
255
- //convert in a object with json_decode
256
- $data_to_save[$i] = array(
257
- 'set_id' => $set_id,
258
- 'fields_and_ratings' => $field_and_vote_array
259
- );
260
-
261
- $set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes',true);
262
-
263
- if ($set_post_meta_values) {
264
- //first, loop saved fields and ratings
265
- foreach ($set_post_meta_values as $saved_set) {
266
- //if the saved set is different from the one that we're trying to save,
267
- //append data to save to the post meta
268
- if ($saved_set['set_id'] !== $set_id) {
269
- //increment i
270
- $i++;
271
- $data_to_save[$i]['set_id'] = $saved_set['set_id'];
272
- $data_to_save[$i]['fields_and_ratings'] = $saved_set['fields_and_ratings'];
273
-
274
- }
275
- }
276
- }
277
- update_post_meta($multiset_ratings['post_id'], 'yasr_multiset_author_votes', $data_to_save);
278
- //empty array
279
- $data_to_save = array();
280
- }
281
-
282
- }
283
  }
16
 
17
  if (YASR_VERSION_INSTALLED !== false) {
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  //In version 2.4.3 is added a setting to show stars near the post title
20
+ //remove August 2022
21
  if (version_compare(YASR_VERSION_INSTALLED, '2.4.3') === -1) {
22
  $yasr_stored_options['stars_title'] = 'no';
23
  update_option('yasr_general_options', $yasr_stored_options);
24
  }
25
 
26
  //In version 2.6.6 %overall_rating% pattern is replaced with %rating%
27
+ //Remove March 2023
28
  if (version_compare(YASR_VERSION_INSTALLED, '2.6.6') === -1) {
29
  if(array_key_exists('text_before_overall', $yasr_stored_options)) {
30
  $yasr_stored_options['text_before_overall'] =
36
 
37
  //In version 2.7.4 option "text_before_stars" is removed.
38
  //if it was set to 0, be sure that text before overall is empty
39
+ //Remove May 2023
40
  if (version_compare(YASR_VERSION_INSTALLED, '2.7.4') === -1) {
41
  if (array_key_exists('text_before_stars', $yasr_stored_options)) {
42
  if($yasr_stored_options['text_before_stars'] === 0) {
47
  }
48
  }
49
 
50
+ //In version 2.9.7 the column comment_id is added
51
+ //Remove Dec 2023
52
+ if (version_compare(YASR_VERSION_INSTALLED, '2.9.7') === -1) {
53
+ $wpdb->query("ALTER TABLE " . YASR_LOG_MULTI_SET . " ADD comment_id bigint(20) NOT NULL AFTER post_id");
54
+ }
55
+
56
  } //Endif yasr_version_installed !== false
57
 
58
 
63
 
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
includes/classes/YasrCustomPostTypes.php CHANGED
@@ -136,4 +136,7 @@ class YasrCustomPostTypes {
136
  return $post_type;
137
  }
138
 
 
 
 
139
  }
136
  return $post_type;
137
  }
138
 
139
+ public static function enableCustomFields ($cpt) {
140
+ add_post_type_support($cpt, 'custom-fields');
141
+ }
142
  }
includes/classes/YasrMultiSetData.php CHANGED
@@ -60,6 +60,32 @@ class YasrMultiSetData {
60
  return $set_id;
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  /**
64
  * This function returns an multidimensional array of multiset ID and Fields
65
  * array (
@@ -213,16 +239,18 @@ class YasrMultiSetData {
213
  * @param integer $set_id the set id
214
  * @param array $set_fields an array with fields names and id
215
  * @param integer|bool $post_id the post_id
 
216
  *
217
  * @return bool | array
218
  */
219
 
220
- public static function returnArrayFieldsRatingsVisitor($set_id, $set_fields, $post_id=false) {
221
  $array_to_return = array();
222
 
223
  global $wpdb;
224
 
225
- $set_id = (int)$set_id;
 
226
 
227
  if (!$set_fields) {
228
  return false;
@@ -240,8 +268,9 @@ class YasrMultiSetData {
240
  FROM " . YASR_LOG_MULTI_SET . " AS l
241
  WHERE l.post_id=%d
242
  AND l.set_type=%d
 
243
  GROUP BY l.field_id
244
- ORDER BY l.field_id", $post_id, $set_id), ARRAY_A);
245
 
246
  //index
247
  $i = 0;
60
  return $set_id;
61
  }
62
 
63
+ /**
64
+ * Returns the length of a MultiSet
65
+ *
66
+ * @author Dario Curvino <@dudo>
67
+ * @since 2.9.7
68
+ * @param $set_id
69
+ *
70
+ * @return int
71
+ */
72
+ public static function multisetLength($set_id) {
73
+ $set_id = (int)$set_id;
74
+
75
+ global $wpdb;
76
+
77
+
78
+ $result = $wpdb->get_results(
79
+ $wpdb->prepare(
80
+ "SELECT f.field_id AS id
81
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f
82
+ WHERE f.parent_set_id=%d",
83
+ $set_id)
84
+ );
85
+
86
+ return (int)$wpdb->num_rows;
87
+ }
88
+
89
  /**
90
  * This function returns an multidimensional array of multiset ID and Fields
91
  * array (
239
  * @param integer $set_id the set id
240
  * @param array $set_fields an array with fields names and id
241
  * @param integer|bool $post_id the post_id
242
+ * @param integer $comment_id the comment_id
243
  *
244
  * @return bool | array
245
  */
246
 
247
+ public static function returnArrayFieldsRatingsVisitor($set_id, $set_fields, $post_id=false, $comment_id=0) {
248
  $array_to_return = array();
249
 
250
  global $wpdb;
251
 
252
+ $set_id = (int)$set_id;
253
+ $comment_id = (int)$comment_id;
254
 
255
  if (!$set_fields) {
256
  return false;
268
  FROM " . YASR_LOG_MULTI_SET . " AS l
269
  WHERE l.post_id=%d
270
  AND l.set_type=%d
271
+ AND l.comment_id=%d
272
  GROUP BY l.field_id
273
+ ORDER BY l.field_id", $post_id, $set_id, $comment_id), ARRAY_A);
274
 
275
  //index
276
  $i = 0;
includes/js/catch-inifite-scroll.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";function t(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:s,rating:o,rateCallback:i})}function e(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}wp.i18n.__;for(var a=["yasr-rater-stars","yasr-multiset-visitors-rater"],r=0;r<a.length;r++)n(a[r]);function n(a){var r=document.getElementsByClassName(a);r.length>0&&("yasr-rater-stars"===a&&function(e){for(var a=0;a<e.length;a++)if(!1===e.item(a).classList.contains("yasr-star-rating")){var r=e.item(a),n=r.id;t(r.getAttribute("data-rater-starsize"),n,r)}}(r),"yasr-multiset-visitors-rater"===a&&function(a){for(var r="",n=[],s=0;s<a.length;s++)!function(s){if(!1===a.item(s).classList.contains("yasr-star-rating")){var o=a.item(s),i=o.id,l=o.getAttribute("data-rater-readonly");l=e(l);t(16,i,o,1,l,!1,(function(t,e){var a=o.getAttribute("data-rater-postid"),s=o.getAttribute("data-rater-setid"),i=o.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),r={postid:a,setid:s,field:i,rating:l},n.push(r),e()}))}}(s);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var r={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:n,set_id:e};jQuery.post(yasrCommonData.ajaxurl,r,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(r))}var s,o,i=wp.i18n.__;function l(t){if(t.length>0&&(function(t){for(var a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var r=t.item(a),n=r.getAttribute("data-rating"),s=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===s&&(s=!1),s=e(s),o=e(o),!0===s&&(o=!0);var l=r.getAttribute("data-rater-postid"),u=r.id,d=u.replace("yasr-visitor-votes-rater-",""),m=parseInt(r.getAttribute("data-rater-starsize")),g=r.getAttribute("data-rater-nonce"),y=r.getAttribute("data-issingular"),v="yasr-vv-votes-number-container-"+d,f="yasr-vv-average-container-"+d,p="yasr-vv-bottom-container-"+d,h="yasr-vv-loader-"+d,_=document.getElementById(v),b=document.getElementById(f),E=document.getElementById(p),R=document.getElementById(h);if("yes"===yasrCommonData.ajaxEnabled){null!==R&&(R.innerHTML=yasrCommonData.loaderHtml);var k={action:"yasr_load_vv",post_id:l};jQuery.get(yasrCommonData.ajaxurl,k).done((function(t){var e,a=JSON.parse(t);e=!0===s||a.yasr_visitor_votes.stars_attributes.read_only,n=(n=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),n=parseFloat(n),c(m,n,l,e,u,0,g,y,_,b,R,E),!0!==s&&(null!==_&&(_.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=n),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,a,r){console.info(i("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),c(m,n,l,o,u,0,g,y,_,b,R,E),!0!==s&&(E.style.display="")}))}else c(m,n,l,o,u,0,g,y,_,b,R,E)}}(a)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(u(e))}))},onHidden:function(){r=s}})}(n)}(a)}}function c(a,r,n,s,o,i,l,c,u,d,m,g){r=parseFloat(r),s=e(s);var y=document.getElementById(o);null!==m&&(m.innerHTML=""),t(a,o,y,1,s,r,(function(t,e){null!==m&&(m.innerHTML=yasrCommonData.loaderHtml);var a={action:"yasr_send_visitor_rating",rating:t,post_id:n,nonce_visitor:l,is_singular:c};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){var e,a,r;"success"===(t=JSON.parse(t)).status?(e=t.number_of_votes,a=t.average_rating,r=t.rating_saved_text,null!==u&&(u.innerHTML=e),null!==d&&(d.innerHTML=a)):r=t.text,null!==g&&(g.innerHTML=r,g.style.display=""),null!==m&&(m.innerHTML="")})),e()}))}function u(t){var e=t.medium_rating;delete t.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||t[r].n_of_votes>a)&&(a=t[r].n_of_votes);var n=Math.log(a)*Math.LOG10E+1|0,s="5%";n<=3&&(s="5%"),n>3&&n<=5&&(s="10%"),n>5&&(s="15%");var o='<div class="yasr-visitors-stats-tooltip">';o+='<span id="yasr-medium-rating-tooltip">'+e+" "+i("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';for(var l=i("stars","yet-another-stars-rating"),c=0,u=0,d=5;d>0;d--)1===d&&(l=i("star","yet-another-stars-rating")),void 0!==t[d]&&(c=t[d].progressbar,u=t[d].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(d," ").concat(l,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(c,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(u,"</div>\n </div>");return o+"</div></div>"}l(document.getElementsByClassName("yasr-rater-stars-vv"));var d=new Uint8Array(16);function m(){if(!o&&!(o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return o(d)}const g=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,y=function(t){return"string"==typeof t&&g.test(t)};for(var v=[],f=0;f<256;++f)v.push((f+256).toString(16).substr(1));const p=function(t,e,a){var r=(t=t||{}).random||(t.rng||m)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(v[t[e+0]]+v[t[e+1]]+v[t[e+2]]+v[t[e+3]]+"-"+v[t[e+4]]+v[t[e+5]]+"-"+v[t[e+6]]+v[t[e+7]]+"-"+v[t[e+8]]+v[t[e+9]]+"-"+v[t[e+10]]+v[t[e+11]]+v[t[e+12]]+v[t[e+13]]+v[t[e+14]]+v[t[e+15]]).toLowerCase();if(!y(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function _(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function b(t,e){return b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},b(t,e)}function E(t,e){if(e&&("object"===h(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function R(t){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},R(t)}var k=wp.i18n.__,I=wp.element.render;function w(e){var a="yasr-ranking-element-"+p(),r=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:a,ref:function(){return t(r,a,!1,.1,!0,e.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",k("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",k("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function x(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===s&&(s=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),s.innerHTML=t;var e=s.textContent;return s.innerHTML="",e}(t.post.title)))}function L(t){var e="after",a=k("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:a}),React.createElement(w,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(w,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:a}))}function T(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(x,{colClass:e,post:t.post}),React.createElement(L,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function B(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(T,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e)}(o,React.Component);var e,a,r,n,s=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=R(r);if(n){var a=R(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return E(this,t)});function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=s.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(k("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(k("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(k(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(k(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:k("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},k("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},k("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},k("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},k("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,k("Post","yet-another-stars-rating")),React.createElement("th",null,k("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(B,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="table-row-group",i="none",l="most",c=o,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(B,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(B,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,k("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&_(e.prototype,a),o}();function j(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);I(React.createElement(S,{source:r,tableId:a,params:n,nonce:s}),o)}}j(),jQuery(document).ajaxComplete((function(t,e,a){var r=yasrCommonData.siteUrl+"/page/";a.url.includes(r)&&(function(){for(var t=["yasr-rater-stars","yasr-multiset-visitors-rater"],e=0;e<t.length;e++)n(t[e])}(),l(document.getElementsByClassName("yasr-rater-stars-vv")),j())}))})();
1
+ (()=>{"use strict";function t(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:s,rating:o,rateCallback:i})}function e(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}wp.i18n.__;for(var a=["yasr-rater-stars","yasr-multiset-visitors-rater"],r=0;r<a.length;r++)n(a[r]);function n(a){var r=document.getElementsByClassName(a);r.length>0&&("yasr-rater-stars"===a&&function(e){for(var a=0;a<e.length;a++)if(!1===e.item(a).classList.contains("yasr-star-rating")){var r=e.item(a),n=r.id;t(r.getAttribute("data-rater-starsize"),n,r)}}(r),"yasr-multiset-visitors-rater"===a&&function(a){for(var r="",n=[],s=document.getElementById("yasr-pro-multiset-review-rating"),o=0;o<a.length;o++)!function(o){if(!1===a.item(o).classList.contains("yasr-star-rating")){var i=a.item(o),l=i.id,c=i.getAttribute("data-rater-readonly"),u=i.getAttribute("data-rater-starsize");u||(u=16),c=e(c);t(u,l,i,1,c,!1,(function(t,e){var a=i.getAttribute("data-rater-postid"),o=i.getAttribute("data-rater-setid"),l=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var c=parseInt(t);this.setRating(c),r={postid:a,setid:o,field:l,rating:c},n.push(r),s&&(s.value=JSON.stringify(n)),e()}))}}(o);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var r={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:n,set_id:e};jQuery.post(yasrCommonData.ajaxurl,r,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(r))}var s,o,i=wp.i18n.__;function l(t){if(t.length>0&&(function(t){for(var a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var r=t.item(a),n=r.getAttribute("data-rating"),s=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===s&&(s=!1),s=e(s),o=e(o),!0===s&&(o=!0);var l=r.getAttribute("data-rater-postid"),u=r.id,d=u.replace("yasr-visitor-votes-rater-",""),m=parseInt(r.getAttribute("data-rater-starsize")),g=r.getAttribute("data-rater-nonce"),y=r.getAttribute("data-issingular"),v="yasr-vv-votes-number-container-"+d,f="yasr-vv-average-container-"+d,p="yasr-vv-bottom-container-"+d,h="yasr-vv-loader-"+d,_=document.getElementById(v),b=document.getElementById(f),E=document.getElementById(p),R=document.getElementById(h);if("yes"===yasrCommonData.ajaxEnabled){null!==R&&(R.innerHTML=yasrCommonData.loaderHtml);var k={action:"yasr_load_vv",post_id:l};jQuery.get(yasrCommonData.ajaxurl,k).done((function(t){var e,a=JSON.parse(t);e=!0===s||a.yasr_visitor_votes.stars_attributes.read_only,n=(n=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),n=parseFloat(n),c(m,n,l,e,u,0,g,y,_,b,R,E),!0!==s&&(null!==_&&(_.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=n),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,a,r){console.info(i("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),c(m,n,l,o,u,0,g,y,_,b,R,E),!0!==s&&(E.style.display="")}))}else c(m,n,l,o,u,0,g,y,_,b,R,E)}}(a)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(u(e))}))},onHidden:function(){r=s}})}(n)}(a)}}function c(a,r,n,s,o,i,l,c,u,d,m,g){r=parseFloat(r),s=e(s);var y=document.getElementById(o);null!==m&&(m.innerHTML=""),t(a,o,y,1,s,r,(function(t,e){null!==m&&(m.innerHTML=yasrCommonData.loaderHtml);var a={action:"yasr_send_visitor_rating",rating:t,post_id:n,nonce_visitor:l,is_singular:c};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){var e,a,r;"success"===(t=JSON.parse(t)).status?(e=t.number_of_votes,a=t.average_rating,r=t.rating_saved_text,null!==u&&(u.innerHTML=e),null!==d&&(d.innerHTML=a)):r=t.text,null!==g&&(g.innerHTML=r,g.style.display=""),null!==m&&(m.innerHTML="")})),e()}))}function u(t){var e=t.medium_rating;delete t.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||t[r].n_of_votes>a)&&(a=t[r].n_of_votes);var n=Math.log(a)*Math.LOG10E+1|0,s="5%";n<=3&&(s="5%"),n>3&&n<=5&&(s="10%"),n>5&&(s="15%");var o='<div class="yasr-visitors-stats-tooltip">';o+='<span id="yasr-medium-rating-tooltip">'+e+" "+i("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';for(var l=i("stars","yet-another-stars-rating"),c=0,u=0,d=5;d>0;d--)1===d&&(l=i("star","yet-another-stars-rating")),void 0!==t[d]&&(c=t[d].progressbar,u=t[d].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(d," ").concat(l,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(c,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(u,"</div>\n </div>");return o+"</div></div>"}l(document.getElementsByClassName("yasr-rater-stars-vv"));var d=new Uint8Array(16);function m(){if(!o&&!(o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return o(d)}const g=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,y=function(t){return"string"==typeof t&&g.test(t)};for(var v=[],f=0;f<256;++f)v.push((f+256).toString(16).substr(1));const p=function(t,e,a){var r=(t=t||{}).random||(t.rng||m)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(v[t[e+0]]+v[t[e+1]]+v[t[e+2]]+v[t[e+3]]+"-"+v[t[e+4]]+v[t[e+5]]+"-"+v[t[e+6]]+v[t[e+7]]+"-"+v[t[e+8]]+v[t[e+9]]+"-"+v[t[e+10]]+v[t[e+11]]+v[t[e+12]]+v[t[e+13]]+v[t[e+14]]+v[t[e+15]]).toLowerCase();if(!y(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function _(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function b(t,e){return b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},b(t,e)}function E(t,e){if(e&&("object"===h(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function R(t){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},R(t)}var k=wp.i18n.__,I=wp.element.render;function w(e){var a="yasr-ranking-element-"+p(),r=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:a,ref:function(){return t(r,a,!1,.1,!0,e.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",k("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",k("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function x(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===s&&(s=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),s.innerHTML=t;var e=s.textContent;return s.innerHTML="",e}(t.post.title)))}function L(t){var e="after",a=k("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:a}),React.createElement(w,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(w,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:a}))}function B(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(x,{colClass:e,post:t.post}),React.createElement(L,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function T(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(B,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e)}(o,React.Component);var e,a,r,n,s=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=R(r);if(n){var a=R(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return E(this,t)});function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=s.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(k("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(k("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(k(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(k(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:k("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},k("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},k("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},k("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},k("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,k("Post","yet-another-stars-rating")),React.createElement("th",null,k("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(T,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="table-row-group",i="none",l="most",c=o,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(T,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(T,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,k("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&_(e.prototype,a),o}();function j(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);I(React.createElement(S,{source:r,tableId:a,params:n,nonce:s}),o)}}j(),jQuery(document).ajaxComplete((function(t,e,a){var r=yasrCommonData.siteUrl+"/page/";a.url.includes(r)&&(function(){for(var t=["yasr-rater-stars","yasr-multiset-visitors-rater"],e=0;e<t.length;e++)n(t[e])}(),l(document.getElementsByClassName("yasr-rater-stars-vv")),j())}))})();
includes/js/shortcodes/overall-multiset.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";function t(t,e,r=!1,s=.1,i=!0,a=!1,n=!1){let o;o=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:o,step:s,readOnly:i,rating:a,rateCallback:n})}const{__:e}=wp.i18n,r=["yasr-rater-stars","yasr-multiset-visitors-rater"];for(let t=0;t<r.length;t++)s(r[t]);function s(e){const r=document.getElementsByClassName(e);r.length>0&&("yasr-rater-stars"===e&&function(e){for(let r=0;r<e.length;r++)if(!1===e.item(r).classList.contains("yasr-star-rating")){const s=e.item(r),i=s.id;t(s.getAttribute("data-rater-starsize"),i,s)}}(r),"yasr-multiset-visitors-rater"===e&&function(e){var r="",s=[];for(let i=0;i<e.length;i++)!function(i){if(!1!==e.item(i).classList.contains("yasr-star-rating"))return;let a=e.item(i),n=a.id,o=a.getAttribute("data-rater-readonly");var l;null!=(l=o)&&""!==l||(l=!0),"true"!==l&&"1"!==l||(l=!0),"false"!==l&&"0"!==l||(l=!1),o=l;t(16,n,a,1,o,!1,(function(t,e){const i=a.getAttribute("data-rater-postid"),n=a.getAttribute("data-rater-setid"),o=a.getAttribute("data-rater-set-field-id");t=t.toFixed(1);const l=parseInt(t);this.setRating(l),r={postid:i,setid:n,field:o,rating:l},s.push(r),e()}))}(i);jQuery(".yasr-send-visitor-multiset").on("click",(function(){const t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var i={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:s,set_id:e};jQuery.post(yasrCommonData.ajaxurl,i,(function(r){let s;s=(r=JSON.parse(r)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(s)}))}))}(r))}})();
1
+ (()=>{"use strict";function t(t,e,r=!1,s=.1,i=!0,a=!1,n=!1){let o;o=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:o,step:s,readOnly:i,rating:a,rateCallback:n})}const{__:e}=wp.i18n,r=["yasr-rater-stars","yasr-multiset-visitors-rater"];for(let t=0;t<r.length;t++)s(r[t]);function s(e){const r=document.getElementsByClassName(e);r.length>0&&("yasr-rater-stars"===e&&function(e){for(let r=0;r<e.length;r++)if(!1===e.item(r).classList.contains("yasr-star-rating")){const s=e.item(r),i=s.id;t(s.getAttribute("data-rater-starsize"),i,s)}}(r),"yasr-multiset-visitors-rater"===e&&function(e){var r="",s=[];const i=document.getElementById("yasr-pro-multiset-review-rating");for(let a=0;a<e.length;a++)!function(a){if(!1!==e.item(a).classList.contains("yasr-star-rating"))return;let n=e.item(a),o=n.id,l=n.getAttribute("data-rater-readonly"),u=n.getAttribute("data-rater-starsize");var d;u||(u=16),null!=(d=l)&&""!==d||(d=!0),"true"!==d&&"1"!==d||(d=!0),"false"!==d&&"0"!==d||(d=!1),l=d;t(u,o,n,1,l,!1,(function(t,e){const a=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),l=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);const u=parseInt(t);this.setRating(u),r={postid:a,setid:o,field:l,rating:u},s.push(r),i&&(i.value=JSON.stringify(s)),e()}))}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){const t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var i={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:s,set_id:e};jQuery.post(yasrCommonData.ajaxurl,i,(function(r){let s;s=(r=JSON.parse(r)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(s)}))}))}(r))}})();
includes/js/src/shortcodes/overall-multiset.js CHANGED
@@ -55,6 +55,8 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
55
  //an array with all the ratings objects
56
  var ratingArray = [];
57
 
 
 
58
  //Check in the object
59
  for (let i = 0; i < yasrMultiSetVisitorInDom.length; i++) {
60
  (function (i) {
@@ -64,9 +66,13 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
64
  return;
65
  }
66
 
67
- let elem = yasrMultiSetVisitorInDom.item(i);
68
- let htmlId = elem.id;
69
- let readonly = elem.getAttribute('data-rater-readonly');
 
 
 
 
70
 
71
  readonly = yasrTrueFalseStringConvertion(readonly);
72
 
@@ -92,11 +98,15 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
92
  //creating rating array
93
  ratingArray.push(ratingObject);
94
 
 
 
 
 
95
  done();
96
 
97
  }
98
 
99
- yasrSetRaterValue (16, htmlId, elem, 1, readonly, false, rateCallback);
100
 
101
  })(i);
102
 
55
  //an array with all the ratings objects
56
  var ratingArray = [];
57
 
58
+ const hiddenFieldMultiReview = document.getElementById('yasr-pro-multiset-review-rating');
59
+
60
  //Check in the object
61
  for (let i = 0; i < yasrMultiSetVisitorInDom.length; i++) {
62
  (function (i) {
66
  return;
67
  }
68
 
69
+ let elem = yasrMultiSetVisitorInDom.item(i);
70
+ let htmlId = elem.id;
71
+ let readonly = elem.getAttribute('data-rater-readonly');
72
+ let starSize = elem.getAttribute('data-rater-starsize');
73
+ if(!starSize) {
74
+ starSize = 16;
75
+ }
76
 
77
  readonly = yasrTrueFalseStringConvertion(readonly);
78
 
98
  //creating rating array
99
  ratingArray.push(ratingObject);
100
 
101
+ if(hiddenFieldMultiReview) {
102
+ hiddenFieldMultiReview.value = JSON.stringify(ratingArray);
103
+ }
104
+
105
  done();
106
 
107
  }
108
 
109
+ yasrSetRaterValue (starSize, htmlId, elem, 1, readonly, false, rateCallback);
110
 
111
  })(i);
112
 
includes/rest/classes/YasrCustomFields.php CHANGED
@@ -95,9 +95,14 @@ class YasrCustomFields extends WP_REST_Controller {
95
  $post_types,
96
  'yasr_all_itemtypes',
97
  array(
98
- 'get_callback' => static function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES, true); },
 
 
99
  'update_callback' => null,
100
- 'schema' => $yasr_itemtype_schema
 
 
 
101
  )
102
  );
103
  }
@@ -114,14 +119,16 @@ class YasrCustomFields extends WP_REST_Controller {
114
  'context' => array('edit'),
115
  );
116
 
117
- //Register Visitor Votes
118
  register_rest_field(
119
  $post_types,
120
  'yasr_all_itemtypes_addition_info',
121
  array(
122
  'get_callback' => static function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true); },
123
  'update_callback' => null,
124
- 'schema' => $yasr_additional_itemtype_schema
 
 
 
125
  )
126
  );
127
  }
95
  $post_types,
96
  'yasr_all_itemtypes',
97
  array(
98
+ 'get_callback' => static function() {
99
+ return json_decode(YASR_SUPPORTED_SCHEMA_TYPES, true);
100
+ },
101
  'update_callback' => null,
102
+ 'schema' => $yasr_itemtype_schema,
103
+ 'auth_callback' => static function() {
104
+ return current_user_can('edit_posts');
105
+ }
106
  )
107
  );
108
  }
119
  'context' => array('edit'),
120
  );
121
 
 
122
  register_rest_field(
123
  $post_types,
124
  'yasr_all_itemtypes_addition_info',
125
  array(
126
  'get_callback' => static function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true); },
127
  'update_callback' => null,
128
+ 'schema' => $yasr_additional_itemtype_schema,
129
+ 'auth_callback' => static function() {
130
+ return current_user_can('edit_posts');
131
+ }
132
  )
133
  );
134
  }
includes/shortcodes/classes/YasrShortcodesAjax.php CHANGED
@@ -391,6 +391,7 @@ class YasrShortcodesAjax {
391
  public function mvSaveRating ($id_field, $set_id, $post_id, $rating, $user_id, $ip_address) {
392
  global $wpdb;
393
 
 
394
  return $wpdb->replace(
395
  YASR_LOG_MULTI_SET,
396
  array(
@@ -423,6 +424,7 @@ class YasrShortcodesAjax {
423
  public function mvUpdateRating ($id_field, $set_id, $post_id, $rating, $user_id, $ip_address) {
424
  global $wpdb;
425
 
 
426
  return $wpdb->update(
427
  YASR_LOG_MULTI_SET,
428
  array(
@@ -608,16 +610,17 @@ class YasrShortcodesAjax {
608
  * @return string|bool;
609
  */
610
  public static function validNonce($nonce, $action_name, $error=false) {
611
- if (!wp_verify_nonce($nonce, $action_name)) {
612
- if(!$error) {
613
  $error = __('Wrong nonce. Rating can\'t be updated', 'yet-another-stars-rating');
614
  } else {
615
  $error = sanitize_text_field($error);
616
  }
617
  $error_nonce = array(
618
  'status' => 'error',
619
- 'text' => $error
620
  );
 
621
  return json_encode($error_nonce);
622
  }
623
  return true;
391
  public function mvSaveRating ($id_field, $set_id, $post_id, $rating, $user_id, $ip_address) {
392
  global $wpdb;
393
 
394
+ //no need to insert 'comment_id', it is 0 by default
395
  return $wpdb->replace(
396
  YASR_LOG_MULTI_SET,
397
  array(
424
  public function mvUpdateRating ($id_field, $set_id, $post_id, $rating, $user_id, $ip_address) {
425
  global $wpdb;
426
 
427
+ //no need to insert 'comment_id', it is 0 by default
428
  return $wpdb->update(
429
  YASR_LOG_MULTI_SET,
430
  array(
610
  * @return string|bool;
611
  */
612
  public static function validNonce($nonce, $action_name, $error=false) {
613
+ if (is_user_logged_in() && !wp_verify_nonce($nonce, $action_name)){
614
+ if (!$error) {
615
  $error = __('Wrong nonce. Rating can\'t be updated', 'yet-another-stars-rating');
616
  } else {
617
  $error = sanitize_text_field($error);
618
  }
619
  $error_nonce = array(
620
  'status' => 'error',
621
+ 'text' => $error
622
  );
623
+
624
  return json_encode($error_nonce);
625
  }
626
  return true;
includes/shortcodes/classes/YasrVisitorMultiSet.php CHANGED
@@ -41,7 +41,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
41
  * @return string
42
  */
43
  public function printVisitorMultiSet () {
44
- $ajax_nonce_visitor_multiset = wp_create_nonce("yasr_nonce_insert_visitor_rating_multiset");
45
 
46
  $this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
47
 
41
  * @return string
42
  */
43
  public function printVisitorMultiSet () {
44
+ $ajax_nonce_visitor_multiset = wp_create_nonce('yasr_nonce_insert_visitor_rating_multiset');
45
 
46
  $this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
47
 
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -42,7 +42,7 @@ class YasrVisitorVotes extends YasrShortcode {
42
  }
43
 
44
  $this->unique_id = str_shuffle(uniqid());
45
- $this->ajax_nonce_visitor = wp_create_nonce("yasr_nonce_vv");
46
 
47
  self::$tippy_loaded = false;
48
  }
42
  }
43
 
44
  $this->unique_id = str_shuffle(uniqid());
45
+ $this->ajax_nonce_visitor = wp_create_nonce('yasr_nonce_vv');
46
 
47
  self::$tippy_loaded = false;
48
  }
includes/yasr-includes-init.php CHANGED
@@ -28,9 +28,9 @@ define('YASR_CSS_DIR_INCLUDES', plugins_url() . '/' . YASR_RELATIVE_PATH_INCLUDE
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';
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';
public/classes/YasrPublicFilters.php CHANGED
@@ -78,7 +78,6 @@ class YasrPublicFilters {
78
  $container_div_visitor = '<div style="text-align:' . $shortcode_align . '" class="yasr-auto-insert-visitor">';
79
  $closing_div = '</div>';
80
 
81
- $auto_insert_shortcode = null; //To avoid undefined variable notice outside the loop (if (is_singular) )
82
  $overall_rating_code = $container_div_overall . '[yasr_overall_rating size="' . YASR_AUTO_INSERT_SIZE . '"]'
83
  . $closing_div;
84
  $visitor_votes_code = $container_div_visitor . '[yasr_visitor_votes size="' . YASR_AUTO_INSERT_SIZE . '"]'
@@ -96,6 +95,10 @@ class YasrPublicFilters {
96
  case 'bottom':
97
  $content_and_stars = $content . $overall_rating_code;
98
  break;
 
 
 
 
99
  } //End Switch
100
  }
101
  elseif (YASR_AUTO_INSERT_WHAT === 'visitor_rating') {
@@ -107,6 +110,10 @@ class YasrPublicFilters {
107
  case 'bottom':
108
  $content_and_stars = $content . $visitor_votes_code;
109
  break;
 
 
 
 
110
  } //End Switch
111
  }
112
  elseif (YASR_AUTO_INSERT_WHAT === 'both') {
@@ -118,6 +125,12 @@ class YasrPublicFilters {
118
  case 'bottom':
119
  $content_and_stars = $content . $overall_rating_code . $visitor_votes_code;
120
  break;
 
 
 
 
 
 
121
  } //End Switch
122
  }
123
 
78
  $container_div_visitor = '<div style="text-align:' . $shortcode_align . '" class="yasr-auto-insert-visitor">';
79
  $closing_div = '</div>';
80
 
 
81
  $overall_rating_code = $container_div_overall . '[yasr_overall_rating size="' . YASR_AUTO_INSERT_SIZE . '"]'
82
  . $closing_div;
83
  $visitor_votes_code = $container_div_visitor . '[yasr_visitor_votes size="' . YASR_AUTO_INSERT_SIZE . '"]'
95
  case 'bottom':
96
  $content_and_stars = $content . $overall_rating_code;
97
  break;
98
+
99
+ case 'both' :
100
+ $content_and_stars = $overall_rating_code . $content . $overall_rating_code;
101
+ break;
102
  } //End Switch
103
  }
104
  elseif (YASR_AUTO_INSERT_WHAT === 'visitor_rating') {
110
  case 'bottom':
111
  $content_and_stars = $content . $visitor_votes_code;
112
  break;
113
+
114
+ case 'both':
115
+ $content_and_stars = $visitor_votes_code . $content . $visitor_votes_code;
116
+ break;
117
  } //End Switch
118
  }
119
  elseif (YASR_AUTO_INSERT_WHAT === 'both') {
125
  case 'bottom':
126
  $content_and_stars = $content . $overall_rating_code . $visitor_votes_code;
127
  break;
128
+
129
+ case 'both':
130
+ $content_and_stars = $overall_rating_code . $visitor_votes_code .
131
+ $content .
132
+ $overall_rating_code . $visitor_votes_code;
133
+ break;
134
  } //End Switch
135
  }
136
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: rating, rate post, rate page, star rating, google rating, votes
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.9
7
- Stable tag: 2.9.6
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  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
@@ -180,7 +180,7 @@ YASR has been tested with:
180
  [Read here](https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/) and find out how to set up rich snippets.
181
  You can use the [Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool/u/0/) to validate your pages.
182
  Also [read this](https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html) google announcement.
183
- If you set up everythings fine, in 99% of cases your stars will appear in a week.
184
  If doesn't, you should work on your seo reputation.
185
 
186
  = Does it work with PHP 8? =
@@ -197,6 +197,14 @@ Yes, YASR is 100% fully compatible with PHP 8
197
 
198
  The full changelog can be found in the plugin's directory. Recent entries:
199
 
 
 
 
 
 
 
 
 
200
  = 2.9.6 =
201
  * FIXED: support for wp_template and wp_template_part CPT, used by FSE
202
  * FIXED: html tags in custom texts didn't work
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.9
7
+ Stable tag: 2.9.7
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  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
180
  [Read here](https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/) and find out how to set up rich snippets.
181
  You can use the [Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool/u/0/) to validate your pages.
182
  Also [read this](https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html) google announcement.
183
+ If you set up everything fine, in 99% of cases your stars will appear in a week.
184
  If doesn't, you should work on your seo reputation.
185
 
186
  = Does it work with PHP 8? =
197
 
198
  The full changelog can be found in the plugin's directory. Recent entries:
199
 
200
+ = 2.9.7 =
201
+ * NEW FEATURE: auto insert option has now a new feature: it is possible to place shortcodes on both above and below the content
202
+ * TWEAKED: attribute 'custom-fields' is added for all CPTS, to avoid compatibility issue in Gutenberg
203
+ * TWEAKED: nonces are checked only for logged in users.
204
+ * TWEAKED: "Stats" page is now renamed in "Manage Ratings"
205
+ * TWEAKED: below the editor is now easier to manage Multi Sets
206
+
207
+
208
  = 2.9.6 =
209
  * FIXED: support for wp_template and wp_template_part CPT, used by FSE
210
  * FIXED: html tags in custom texts didn't work
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.9.6
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
@@ -78,7 +78,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
- define( 'YASR_VERSION_NUM', '2.9.6' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  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.9.7
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
+ define( 'YASR_VERSION_NUM', '2.9.7' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );