Yasr – Yet Another Stars Rating - Version 2.8.5

Version Description

  • TWEAKED: YASR js assets are now loaded only if shortcode exists, and every shortcode has is ows js file. This will reduce the unused js code, increasing lighthouse/pagespeed results.
  • NEW FEATURE: new shortcode, ' yasr_user_rate_history ' : this will works only for logged in users, and will show all the ratings that the user has give.
  • FIX: js console error in widget page
Download this release

Release Info

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

Code changes from version 2.8.4 to 2.8.5

Files changed (43) hide show
  1. admin/classes/YasrLogDashboardWidget.php +0 -307
  2. admin/editor/YasrEditorHooks.php +84 -14
  3. admin/js/guten/blocks/noStarsRankings.js +1 -1
  4. admin/js/guten/blocks/overallRating.js +1 -1
  5. admin/js/guten/blocks/rankings.js +1 -1
  6. admin/js/guten/blocks/visitorVotes.js +1 -1
  7. admin/js/guten/blocks/yasrGutenUtils.js +1 -1
  8. admin/js/guten/yasr-guten-misc.js +1 -1
  9. admin/js/src/guten/blocks/noStarsRankings.js +0 -35
  10. admin/js/src/guten/blocks/overallRating.js +0 -25
  11. admin/js/src/guten/blocks/rankings.js +0 -36
  12. admin/js/src/guten/blocks/visitorVotes.js +2 -30
  13. admin/js/src/guten/blocks/yasrGutenUtils.js +6 -2
  14. admin/js/src/yasr-settings-rankings.js +1 -1
  15. admin/js/yasr-settings.js +1 -1
  16. admin/yasr-admin-actions-ajax.php +4 -2
  17. admin/yasr-admin-functions.php +20 -11
  18. admin/yasr-admin-init.php +1 -1
  19. includes/classes/YasrLogDashboardWidget.php +347 -0
  20. includes/css/yasr.css +59 -0
  21. includes/js/rater-js.min.js +1 -2
  22. includes/js/readme +5 -0
  23. includes/js/shortcodes/overall-multiset.js +1 -0
  24. includes/js/shortcodes/rankings.js +1 -0
  25. includes/js/shortcodes/visitorVotes.js +1 -0
  26. includes/js/shortcodes/yasr-log-users-fronted.js +1 -0
  27. includes/js/src/modules/yasrSetRaterValue.js +24 -0
  28. includes/js/src/modules/yasrTrueFalseStringConvertion.js +17 -0
  29. includes/js/src/rater-js-src.js +1 -1
  30. includes/js/src/shortcodes/overall-multiset.js +132 -0
  31. includes/js/src/{ranking.js → shortcodes/ranking.js} +5 -2
  32. includes/js/src/{yasr-front.js → shortcodes/visitorVotes.js} +183 -350
  33. includes/js/src/shortcodes/yasr-log-users-fronted.js +47 -0
  34. includes/js/yasr-front.js +1 -1
  35. includes/shortcodes/classes/YasrNoStarsRankings.php +6 -6
  36. includes/shortcodes/classes/YasrRankings.php +1 -0
  37. includes/shortcodes/classes/YasrShortcode.php +35 -0
  38. includes/shortcodes/classes/YasrVisitorVotes.php +50 -0
  39. includes/shortcodes/yasr-shortcode-functions.php +12 -1
  40. includes/yasr-includes-functions.php +39 -36
  41. public/yasr-public-actions.php +0 -8
  42. readme.txt +15 -2
  43. yet-another-stars-rating.php +2 -2
admin/classes/YasrLogDashboardWidget.php DELETED
@@ -1,307 +0,0 @@
1
- <?php
2
- /*
3
-
4
- Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU General Public License as published by
8
- the Free Software Foundation, either version 2 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU General Public License for more details.
15
-
16
- You should have received a copy of the GNU General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>
18
- */
19
-
20
- if (!defined('ABSPATH')) {
21
- exit('You\'re not allowed to see this page');
22
- } // Exit if accessed directly
23
-
24
- /**
25
- * Class YasrLogDashboardWidget
26
- *
27
- * Class to print the Dashboard widgets
28
- *
29
- */
30
- class YasrLogDashboardWidget {
31
- private $limit = 8;
32
- private $offset = 0;
33
- private $page_num;
34
- private $num_of_pages;
35
- private $n_rows;
36
- private $log_query;
37
- private $is_ajax = false;
38
- private $html_to_return;
39
- private $button_class;
40
- private $span_loader_id;
41
- private $user_widget = false;
42
- private $container_id;
43
- private $span_total_pages;
44
-
45
- public function __construct($widget_user) {
46
- //If $_POST isset it's in ajax response
47
- if (isset($_POST['pagenum'])) {
48
- $this->page_num = (int)$_POST['pagenum'];
49
- $this->num_of_pages = (int)$_POST['totalpages'];
50
- $this->offset = (int)($this->page_num - 1) * $this->limit;
51
- $this->is_ajax = true;
52
-
53
- if ($widget_user === 'admin') {
54
- if (current_user_can('manage_options')) {
55
- $this->adminWidget();
56
- }
57
- return;
58
- }
59
- if ($widget_user === 'user') {
60
- $this->userWidget();
61
- }
62
- } else {
63
- $this->page_num = 1;
64
- }
65
- }
66
-
67
- /**
68
- * This function will set the values for print the admin widget logs
69
- *
70
- * $this->user_widget
71
- * $this->n_rows
72
- * $this->log_query
73
- * $this->container_id
74
- * $this->span_total_pages
75
- * $this->button_class
76
- * $this->span_loader_id
77
- *
78
- */
79
- public function adminWidget() {
80
- global $wpdb;
81
-
82
- //query for admin widget
83
- $this->n_rows = $wpdb->get_var(
84
- "SELECT COUNT(*) FROM "
85
- . YASR_LOG_TABLE
86
- );
87
-
88
- $this->log_query = "SELECT * FROM "
89
- . YASR_LOG_TABLE .
90
- " ORDER BY date DESC LIMIT %d, %d ";
91
-
92
- $this->container_id = 'yasr-log-container';
93
- $this->span_total_pages = 'yasr-log-total-pages';
94
- $this->button_class = 'yasr-log-pagenum';
95
- $this->span_loader_id = 'yasr-loader-log-metabox';
96
-
97
- $this->returnWidget();
98
- }
99
-
100
- /**
101
- * This function will set the values for print the user widget logs
102
- *
103
- * $this->user_widget
104
- * $this->n_rows
105
- * $this->log_query
106
- * $this->container_id
107
- * $this->span_total_pages
108
- * $this->button_class
109
- * $this->span_loader_id
110
- *
111
- */
112
- public function userWidget() {
113
- $user_id = get_current_user_id();
114
-
115
- //set true to user widget
116
- $this->user_widget = true;
117
-
118
- global $wpdb;
119
-
120
- $this->n_rows = $wpdb->get_var(
121
- $wpdb->prepare(
122
- "SELECT COUNT(*) FROM "
123
- . YASR_LOG_TABLE . " WHERE user_id = %d ",
124
- $user_id));
125
-
126
- $this->log_query = "SELECT * FROM "
127
- . YASR_LOG_TABLE .
128
- " WHERE user_id = $user_id
129
- ORDER BY date
130
- DESC LIMIT %d, %d ";
131
-
132
- $this->container_id = 'yasr-user-log-container';
133
- $this->span_total_pages = 'yasr-user-log-total-pages';
134
- $this->button_class = 'yasr-user-log-page-num';
135
- $this->span_loader_id = 'yasr-loader-user-log-metabox';
136
-
137
- $this->returnWidget();
138
- }
139
-
140
- /**
141
- * Print the widget
142
- */
143
- private function returnWidget() {
144
- global $wpdb;
145
-
146
- if($this->n_rows > 0) {
147
- $this->num_of_pages = ceil($this->n_rows / $this->limit);
148
- } else {
149
- $this->num_of_pages = 1;
150
- }
151
-
152
- //do the query
153
- $log_result = $wpdb->get_results(
154
- $wpdb->prepare(
155
- $this->log_query,
156
- $this->offset, $this->limit)
157
- );
158
-
159
- if (!$log_result) {
160
- _e("No Recent votes yet", 'yet-another-stars-rating');
161
- } else {
162
- $this->html_to_return = "<div class='yasr-log-container' id='$this->container_id'>";
163
-
164
- foreach ($log_result as $column) {
165
-
166
- $user = get_user_by('id', $column->user_id); //Get info user from user id
167
-
168
- //If ! user means that the vote are anonymous
169
- if ($user == false) {
170
- $user = (object) array('user_login');
171
- $user->user_login = __('anonymous', 'yet-another-stars-rating');
172
- }
173
-
174
- $avatar = get_avatar($column->user_id, '32'); //Get avatar from user id
175
-
176
- $post_title = wp_strip_all_tags(get_the_title($column->post_id)); //Get post title from post id
177
- $link = get_permalink($column->post_id); //Get post link from post id
178
-
179
- if ($this->user_widget !== true) {
180
- $yasr_log_vote_text = ' ' . sprintf(
181
- __('Vote %d from %s on', 'yet-another-stars-rating'),
182
- $column->vote,
183
- '<strong style="color: blue">' . $user->user_login . '</strong>'
184
- );
185
- } else {
186
- $yasr_log_vote_text = ' ' . sprintf(
187
- __('You rated %s on', 'yet-another-stars-rating'),
188
- '<strong style="color: blue">' . $column->vote . '</strong>'
189
- );
190
- }
191
-
192
- //Default values (for admin widget)
193
- $ip_span = ''; //default value
194
-
195
- //Set value depending if we're on user or admin widget
196
- if ($this->user_widget !== true) {
197
- if (YASR_ENABLE_IP === 'yes') {
198
- $ip_span = '<span class="yasr-log-ip">' . __("Ip address", 'yet-another-stars-rating') . ':
199
- <span style="color:blue">' . $column->ip . '</span>
200
- </span>';
201
- }
202
- } else {
203
- $ip_span = '';
204
- }
205
-
206
- $rows_content = '<div class="yasr-log-div-child">
207
- <div class="yasr-log-image">'
208
- .$avatar.
209
- '</div>
210
- <div class="yasr-log-child-head">
211
- <span id="yasr-log-vote">'.$yasr_log_vote_text.'</span>
212
- <span id="yasr-log-post"><a href="'. $link .'">'.$post_title.'</a></span>
213
- </div>
214
- <div class="yasr-log-ip-date">'
215
- .$ip_span.
216
- '<span class="yasr-log-date">'.$column->date.'</span>
217
- </div>
218
- </div>';
219
-
220
- $this->html_to_return .= $rows_content;
221
-
222
- } //End foreach
223
-
224
- $this->html_to_return .= "<div id='yasr-log-page-navigation'>";
225
-
226
- //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
227
- //the "last" button could not exists
228
- $this->html_to_return .= "<span id='$this->span_total_pages' data-yasr-log-total-pages='$this->num_of_pages'>";
229
- $this->html_to_return .= __("Pages", 'yet-another-stars-rating') . ": ($this->num_of_pages) &nbsp;&nbsp;&nbsp;";
230
- $this->html_to_return .= '</span>';
231
-
232
- $this->pagination();
233
-
234
- $this->html_to_return .= '</div>'; //End yasr-log-page-navigation
235
- $this->html_to_return .= '</div>'; //End Yasr Log Container
236
-
237
- echo $this->html_to_return;
238
-
239
- } // End else if !$log result
240
-
241
- if ($this->is_ajax === true) {
242
- die();
243
- }
244
-
245
- }
246
-
247
- /**
248
- * This function will print the row with pagination
249
- */
250
- private function pagination() {
251
-
252
- if ($this->num_of_pages <= 3) {
253
- for ($i = 1; $i <= $this->num_of_pages; $i++) {
254
- if ($i == $this->page_num) {
255
- $this->html_to_return .= "<button class='button-primary' value='$i'>$i</button>&nbsp;&nbsp;";
256
- } else {
257
- $this->html_to_return .= "<button class=$this->button_class value='$i'>$i</button>&nbsp;&nbsp;";
258
- }
259
- }
260
- $this->html_to_return .= "<span id='yasr-loader-log-metabox' style='display:none;'>&nbsp;
261
- <img alt='loader' src='" . YASR_IMG_DIR . "/loader.gif' >
262
- </span>";
263
- }
264
- else {
265
- $start_for = $this->page_num - 1;
266
-
267
- if ($start_for <= 0) {
268
- $start_for = 1;
269
- }
270
-
271
- $end_for = $this->page_num + 1;
272
-
273
- if ($end_for >= $this->num_of_pages) {
274
- $end_for = $this->num_of_pages;
275
- }
276
-
277
- if ($this->page_num >= 3) {
278
- $this->html_to_return .= "<button class=$this->button_class value='1'>
279
- &laquo; First </button>&nbsp;&nbsp;...&nbsp;&nbsp;";
280
- }
281
-
282
- for ($i = $start_for; $i <= $end_for; $i ++) {
283
- if ($i == $this->page_num) {
284
- $this->html_to_return .= "<button class='button-primary' value='$i'>$i</button>&nbsp;&nbsp;";
285
- } else {
286
- $this->html_to_return .= "<button class=$this->button_class value='$i'>$i</button>&nbsp;&nbsp;";
287
- }
288
- }
289
-
290
- $num_of_page_less_one = $this->num_of_pages - 1;
291
-
292
- if ($this->page_num != $this->num_of_pages && $this->page_num != $num_of_page_less_one) {
293
- $this->html_to_return .= "...&nbsp;&nbsp;
294
- <button class=$this->button_class
295
- value='$this->num_of_pages'>
296
- Last &raquo;</button>
297
- &nbsp;&nbsp;";
298
- }
299
-
300
- $this->html_to_return .= "<span id='$this->span_loader_id' style='display:none;' >&nbsp;
301
- <img alt='loader' src='" . YASR_IMG_DIR . "/loader.gif' >
302
- </span>";
303
-
304
- }
305
-
306
- }
307
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/editor/YasrEditorHooks.php CHANGED
@@ -36,7 +36,7 @@ class YasrEditorHooks {
36
  //enqueue gutenberg stuff outside blocks
37
  add_action('enqueue_block_editor_assets', array($this, 'initGutenMisc'));
38
 
39
- add_action('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);
@@ -114,7 +114,7 @@ class YasrEditorHooks {
114
  );
115
 
116
  register_block_type(
117
- 'yet-another-stars-rating/overall-rating',
118
  array(
119
  'api_version' => 2,
120
  'editor_script' => 'yasr-overall-block',
@@ -122,11 +122,21 @@ class YasrEditorHooks {
122
  'description' => __('Insert the author rating', 'yet-another-stars-rating'),
123
  'icon' => 'star-half',
124
  'category' => 'yet-another-stars-rating',
125
- 'keywords' => array(
126
- __('rating', 'yet-another-stars-rating'),
127
- __('author', 'yet-another-stars-rating'),
128
- __('overall', 'yet-another-stars-rating')
 
 
 
 
 
 
129
  ),
 
 
 
 
130
  )
131
  );
132
  }
@@ -151,8 +161,27 @@ class YasrEditorHooks {
151
 
152
  register_block_type( 'yet-another-stars-rating/visitor-votes',
153
  array(
154
- 'api_version' => 2,
155
  'editor_script' => 'yasr-vv-block',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  )
157
  );
158
  }
@@ -170,22 +199,43 @@ class YasrEditorHooks {
170
  'wp-block-editor',
171
  'wp-components',
172
  'wp-element',
173
- 'wp-i18n',
174
  ),
175
  1
176
  );
177
 
178
  register_block_type( 'yet-another-stars-rating/overall-rating-ranking',
179
  array(
180
- 'api_version' => 2,
181
  'editor_script' => 'yasr-rankings-blocks',
 
 
 
 
 
 
 
 
 
 
182
  )
183
  );
184
 
185
  register_block_type( 'yet-another-stars-rating/visitor-votes-ranking',
186
  array(
187
- 'api_version' => 2,
188
  'editor_script' => 'yasr-rankings-blocks',
 
 
 
 
 
 
 
 
 
 
 
 
189
  )
190
  );
191
  }
@@ -203,22 +253,41 @@ class YasrEditorHooks {
203
  'wp-block-editor',
204
  'wp-components',
205
  'wp-element',
206
- 'wp-i18n',
207
  ),
208
  1
209
  );
210
 
211
  register_block_type( 'yet-another-stars-rating/most-active-users',
212
  array(
213
- 'api_version' => 2,
214
  'editor_script' => 'yasr-nostars-rankings-blocks',
 
 
 
 
 
 
 
 
 
 
215
  )
216
  );
217
 
218
  register_block_type( 'yet-another-stars-rating/most-active-reviewers',
219
  array(
220
- 'api_version' => 2,
221
  'editor_script' => 'yasr-nostars-rankings-blocks',
 
 
 
 
 
 
 
 
 
 
222
  )
223
  );
224
  }
@@ -546,7 +615,8 @@ class YasrEditorHooks {
546
  ?>
547
  <br/>
548
  <small>
549
- <?php _e('This ranking shows the highest rated posts rated through the overall_rating shortcode',
 
550
  'yet-another-stars-rating'); ?>
551
  </small>
552
  </td>
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);
114
  );
115
 
116
  register_block_type(
117
+ 'yet-another-stars-rating/overall-rating',
118
  array(
119
  'api_version' => 2,
120
  'editor_script' => 'yasr-overall-block',
122
  'description' => __('Insert the author rating', 'yet-another-stars-rating'),
123
  'icon' => 'star-half',
124
  'category' => 'yet-another-stars-rating',
125
+ 'keywords' => array('rating', 'author', 'overall'),
126
+ 'attributes' => array(
127
+ 'size' => array(
128
+ 'type' => 'string',
129
+ 'default' => 'large'
130
+ ),
131
+ 'postId' => array(
132
+ 'type' => 'string',
133
+ 'default' => false
134
+ ),
135
  ),
136
+ 'supports' => array(
137
+ // Declare support for specific alignment options.
138
+ 'align' => array('left', 'center', 'right')
139
+ )
140
  )
141
  );
142
  }
161
 
162
  register_block_type( 'yet-another-stars-rating/visitor-votes',
163
  array(
164
+ 'api_version' => 2,
165
  'editor_script' => 'yasr-vv-block',
166
+ 'title' => __('Yasr: Visitor Votes', 'yet-another-stars-rating'),
167
+ 'description' => __('Insert the ability for your visitors to vote', 'yet-another-stars-rating'),
168
+ 'icon' => 'star-half',
169
+ 'category' => 'yet-another-stars-rating',
170
+ 'keywords' => array('rating', 'visitor', 'votes'),
171
+ 'attributes' => array(
172
+ 'size' => array(
173
+ 'type' => 'string',
174
+ 'default' => 'large'
175
+ ),
176
+ 'postId' => array(
177
+ 'type' => 'string',
178
+ 'default' => false
179
+ ),
180
+ ),
181
+ 'supports' => array(
182
+ // Declare support for specific alignment options.
183
+ 'align' => array('left', 'center', 'right')
184
+ )
185
  )
186
  );
187
  }
199
  'wp-block-editor',
200
  'wp-components',
201
  'wp-element',
 
202
  ),
203
  1
204
  );
205
 
206
  register_block_type( 'yet-another-stars-rating/overall-rating-ranking',
207
  array(
208
+ 'api_version' => 2,
209
  'editor_script' => 'yasr-rankings-blocks',
210
+ 'title' => __('Yasr: Ranking by overall rating', 'yet-another-stars-rating'),
211
+ 'description' => __('This ranking shows the highest rated posts rated through the overall_rating shortcode.',
212
+ 'yet-another-stars-rating'),
213
+ 'icon' => 'star-half',
214
+ 'category' => 'yet-another-stars-rating',
215
+ 'keywords' => array('ranking', 'highest', 'chart'),
216
+ 'supports' => array(
217
+ // Declare support for specific alignment options.
218
+ 'align' => array('left', 'center', 'right')
219
+ )
220
  )
221
  );
222
 
223
  register_block_type( 'yet-another-stars-rating/visitor-votes-ranking',
224
  array(
225
+ 'api_version' => 2,
226
  'editor_script' => 'yasr-rankings-blocks',
227
+ 'title' => __('Yasr: Ranking by visitors votes', 'yet-another-stars-rating'),
228
+ 'description' => __('This ranking shows both the highest and most rated posts rated through the
229
+ yasr_visitor_votes shortcode. ' .
230
+ 'For an item to appear in this chart, it has to be rated at least twice. ',
231
+ 'yet-another-stars-rating'),
232
+ 'icon' => 'star-half',
233
+ 'category' => 'yet-another-stars-rating',
234
+ 'keywords' => array('ranking', 'highest', 'most', 'chart'),
235
+ 'supports' => array(
236
+ // Declare support for specific alignment options.
237
+ 'align' => array('left', 'center', 'right')
238
+ )
239
  )
240
  );
241
  }
253
  'wp-block-editor',
254
  'wp-components',
255
  'wp-element',
 
256
  ),
257
  1
258
  );
259
 
260
  register_block_type( 'yet-another-stars-rating/most-active-users',
261
  array(
262
+ 'api_version' => 2,
263
  'editor_script' => 'yasr-nostars-rankings-blocks',
264
+ 'title' => __('Yasr: Most Active Visitors', 'yet-another-stars-rating'),
265
+ 'description' => __('This ranking shows the most active users, displaying the login name if logged in or “Anonymous” if not.',
266
+ 'yet-another-stars-rating'),
267
+ 'icon' => 'star-half',
268
+ 'category' => 'yet-another-stars-rating',
269
+ 'keywords' => array('ranking', 'highest', 'most', 'chart', 'visitors'),
270
+ 'supports' => array(
271
+ // Declare support for specific alignment options.
272
+ 'align' => array('left', 'center', 'right')
273
+ )
274
  )
275
  );
276
 
277
  register_block_type( 'yet-another-stars-rating/most-active-reviewers',
278
  array(
279
+ 'api_version' => 2,
280
  'editor_script' => 'yasr-nostars-rankings-blocks',
281
+ 'title' => __('Yasr: Most Active Authors', 'yet-another-stars-rating'),
282
+ 'description' => __('This ranking shows the most active reviewers on your site.',
283
+ 'yet-another-stars-rating'),
284
+ 'icon' => 'star-half',
285
+ 'category' => 'yet-another-stars-rating',
286
+ 'keywords' => array('ranking', 'highest', 'most', 'chart', 'authors'),
287
+ 'supports' => array(
288
+ // Declare support for specific alignment options.
289
+ 'align' => array('left', 'center', 'right')
290
+ )
291
  )
292
  );
293
  }
615
  ?>
616
  <br/>
617
  <small>
618
+ <?php _e('This ranking shows the highest rated posts rated through the
619
+ yasr_overall_rating shortcode',
620
  'yet-another-stars-rating'); ?>
621
  </small>
622
  </td>
admin/js/guten/blocks/noStarsRankings.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var t,e,a,r,n,s,o,i,l={702:(t,e,a)=>{var r,n;a.r(e),a.d(e,{YasrBlocksPanel:()=>W,YasrDivRatingOverall:()=>X,YasrNoSettingsPanel:()=>$,YasrPrintInputId:()=>K,YasrPrintSelectSize:()=>q,YasrProText:()=>G,yasrLabelSelectSize:()=>D,yasrLeaveThisBlankText:()=>J,yasrOptionalText:()=>H,yasrOverallDescription:()=>U,yasrSelectSizeChoose:()=>z,yasrSelectSizeLarge:()=>F,yasrSelectSizeMedium:()=>V,yasrSelectSizeSmall:()=>Y,yasrVisitorVotesDescription:()=>Q});var s=new Uint8Array(16);function o(){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(s)}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,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();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=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(t){return(m="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})(t)}function g(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 y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(t,e){return!e||"object"!==m(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var h=wp.i18n.__,f=wp.element.render;function _(t){var e="yasr-ranking-element-"+d(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return L(a,e,!1,.1,!0,t.rating)}})}function b(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",h("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",h("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 E(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===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=h("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(b,{post:t.post,tableId:t.tableId,text:a}),React.createElement(_,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(_,{rating:t.post.rating,tableId:t.tableId}),React.createElement(b,{post:t.post,tableId:t.tableId,text:a}))}function k(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(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function w(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(k,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}for(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&&y(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=p(r);if(n){var a=p(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return v(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(h("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(h("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(h(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(h(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:h("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},h("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},h("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},h("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},h("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,"Post"),React.createElement("th",null,h("Order By","yet-another-stars-rating-pro"),":  ",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(w,{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(w,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(w,{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,h("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,a),o}(),I=wp.i18n.__,C=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],x=0;x<C.length;x++)T(C[x]);function T(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;L(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=N(n),s=N(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,v="yasr-vv-loader-"+l,p=document.getElementById(m),h=document.getElementById(g),f=document.getElementById(y),_=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){null!==_&&(_.innerHTML=yasrCommonData.loaderHtml);var b={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,b).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),B(c,r,o,e,i,0,u,d,p,h,_,f),!0!==n&&(null!==p&&(p.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==h&&(h.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==f&&(f.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,f.style.display=""))})).fail((function(t,e,a,l){console.info(I("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),B(c,r,o,s,i,0,u,d,p,h,_,f),!0!==n&&(f.style.display="")}))}else B(c,r,o,s,i,0,u,d,p,h,_,f)}}(e)}(e),"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(P(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=N(o);L(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var 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 n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function P(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 i=I("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=I("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}function L(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 B(t,e,a,r,n,s,o,i,l,c,u,d){e=parseFloat(e),r=N(r);var m=document.getElementById(n);null!==u&&(u.innerHTML=""),L(t,n,m,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(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!==l&&(l.innerHTML=e),null!==c&&(c.innerHTML=a)):r=t.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function N(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){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);f(React.createElement(S,{source:r,tableId:a,params:n,nonce:s}),o)}}();var A=a(702),j=wp.i18n.__,M=wp.components.PanelBody,O=wp.blockEditor.InspectorControls,H=j("All these settings are optional","yet-another-stars-rating"),D=j("Choose Size","yet-another-stars-rating"),z=j("Choose stars size","yet-another-stars-rating"),Y=j("Small","yet-another-stars-rating"),V=j("Medium","yet-another-stars-rating"),F=j("Large","yet-another-stars-rating"),J=j("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),U=j("Remember: only the post author can rate here.","yet-another-stars-rating"),Q=j("This is the star set where your users will be able to vote","yet-another-stars-rating");function q(t){return React.createElement("form",null,React.createElement("select",{value:t.size,onChange:function(e){return(0,t.setAttributes)({size:(a=e).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},A.yasrSelectSizeChoose),React.createElement("option",{value:"small"},A.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},A.yasrSelectSizeMedium),React.createElement("option",{value:"large"},A.yasrSelectSizeLarge)))}function K(t){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t.postId,onKeyPress:function(e){return function(t,e){if("Enter"===e.key){var a=e.target.value;!0!==/^\d+$/.test(a)&&""!==a||t({postId:a}),e.preventDefault()}}(t.setAttributes,e)}}))}function G(){var t=j("To be able to customize this ranking, you need","yet-another-stars-rating"),e=j("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",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#yasr-pro"},"Yasr Pro."),React.createElement("br",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"},"yetanotherstarsrating.com"))}function $(t){return React.createElement("div",null,React.createElement(G,null))}function W(t){var e;return"visitors"===t.block&&(e=Q),"overall"===t.block&&(e=U),React.createElement(O,null,"overall"===t.block&&React.createElement(X,null),React.createElement(M,{title:"Settings"},React.createElement("h3",null,H),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,D),React.createElement("div",null,React.createElement(q,{size:t.size,setAttributes:t.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(K,{postId:t.postId,setAttributes:t.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},J)),React.createElement("div",{className:"yasr-guten-block-panel"},e)))}function X(t){var e=j("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(t,e){t=t.toFixed(1),t=parseFloat(t),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:t}}),this.setRating(t),e()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},e,React.createElement("div",{id:"overall-rater",ref:function(){return L(32,"overall-rater",!1,.1,!1,a,r)}}))}}},c={};function u(t){var e=c[t];if(void 0!==e)return e.exports;var a=c[t]={exports:{}};return l[t](a,a.exports,u),a.exports}u.d=(t,e)=>{for(var a in e)u.o(e,a)&&!u.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},u.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),u.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},t=u(702),e=wp.i18n.__,a=wp.blocks.registerBlockType,r=wp.components.PanelBody,n=wp.element.Fragment,s=wp.blockEditor,o=s.useBlockProps,i=s.InspectorControls,a("yet-another-stars-rating/most-active-users",{apiVersion:2,title:e("Yasr: Most Active Visitors","yet-another-stars-rating"),description:e("This ranking shows the most active users, displaying the login name if logged in or “Anonymous” if not.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[e("ranking","yet-another-stars-rating"),e("highest","yet-another-stars-rating"),e("most","yet-another-stars-rating"),e("chart","yet-another-stars-rating"),e("visitors","yet-another-stars-rating")],edit:function(e){var a=o({className:"yasr-active-users-block"}),s=[React.createElement(t.YasrNoSettingsPanel,{key:0})];function l(t){return React.createElement(i,null,React.createElement(r,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,s))))}return wp.hooks.doAction("yasr_top_visitor_setting",s),React.createElement(n,null,React.createElement(l,null),React.createElement("div",a,"[yasr_most_active_users]"))},save:function(t){var e=o.save({className:"yasr-active-users-block"});return React.createElement("div",e,"[yasr_most_active_users]")}}),a("yet-another-stars-rating/most-active-reviewers",{apiVersion:2,title:e("Yasr: Most Active Authors","yet-another-stars-rating"),description:e("This ranking shows the most active reviewers on your site.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[e("ranking","yet-another-stars-rating"),e("highest","yet-another-stars-rating"),e("most","yet-another-stars-rating"),e("chart","yet-another-stars-rating"),e("authors","yet-another-stars-rating")],supports:{align:["left","center","right"]},edit:function(e){var a=o({className:"yasr-reviewers-block"}),s=[React.createElement(t.YasrNoSettingsPanel,{key:0})];function l(t){return React.createElement(i,null,React.createElement(r,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,s))))}return wp.hooks.doAction("yasr_top_reviewers_setting",s),React.createElement(n,null,React.createElement(l,null),React.createElement("div",a,"[yasr_top_reviewers]"))},save:function(t){var e=o.save({className:"yasr-reviewers-block"});return React.createElement("div",e,"[yasr_top_reviewers]")}})})();
1
+ (()=>{"use strict";var e,t,a,r,n,s,l,o={245:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>b,YasrDivRatingOverall:()=>_,YasrNoSettingsPanel:()=>R,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>g,YasrProText:()=>E,yasrLabelSelectSize:()=>c,yasrLeaveThisBlankText:()=>v,yasrOptionalText:()=>o,yasrOverallDescription:()=>y,yasrSelectSizeChoose:()=>i,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>d});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"),c=n("Choose Size","yet-another-stars-rating"),i=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),p=n("Large","yet-another-stars-rating"),v=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),y=n("Remember: only the post author can rate here.","yet-another-stars-rating"),d=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 E(){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(E,null))}function b(e){var t;return"visitors"===e.block&&(t=d),"overall"===e.block&&(t=y),React.createElement(l,null,"overall"===e.block&&React.createElement(_,null),React.createElement(s,{title:"Settings"},React.createElement("h3",null,o),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,c),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"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function _(e){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)}}))}}},c={};function i(e){var t=c[e];if(void 0!==t)return t.exports;var a=c[e]={exports:{}};return o[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var a in t)i.o(t,a)&&!i.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=i(245),t=wp.blocks.registerBlockType,a=wp.components.PanelBody,r=wp.element.Fragment,n=wp.blockEditor,s=n.useBlockProps,l=n.InspectorControls,t("yet-another-stars-rating/most-active-users",{edit:function(t){var n=s({className:"yasr-active-users-block"}),o=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function c(e){return React.createElement(l,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,o))))}return wp.hooks.doAction("yasr_top_visitor_setting",o),React.createElement(r,null,React.createElement(c,null),React.createElement("div",n,"[yasr_most_active_users]"))},save:function(e){var t=s.save({className:"yasr-active-users-block"});return React.createElement("div",t,"[yasr_most_active_users]")}}),t("yet-another-stars-rating/most-active-reviewers",{edit:function(t){var n=s({className:"yasr-reviewers-block"}),o=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function c(e){return React.createElement(l,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,o))))}return wp.hooks.doAction("yasr_top_reviewers_setting",o),React.createElement(r,null,React.createElement(c,null),React.createElement("div",n,"[yasr_top_reviewers]"))},save:function(e){var t=s.save({className:"yasr-reviewers-block"});return React.createElement("div",t,"[yasr_top_reviewers]")}})})();
admin/js/guten/blocks/overallRating.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var t,e,a,r,n,s={702:(t,e,a)=>{var r,n;a.r(e),a.d(e,{YasrBlocksPanel:()=>W,YasrDivRatingOverall:()=>X,YasrNoSettingsPanel:()=>G,YasrPrintInputId:()=>K,YasrPrintSelectSize:()=>q,YasrProText:()=>$,yasrLabelSelectSize:()=>H,yasrLeaveThisBlankText:()=>J,yasrOptionalText:()=>z,yasrOverallDescription:()=>U,yasrSelectSizeChoose:()=>D,yasrSelectSizeLarge:()=>V,yasrSelectSizeMedium:()=>F,yasrSelectSizeSmall:()=>Y,yasrVisitorVotesDescription:()=>Q});var s=new Uint8Array(16);function o(){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(s)}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,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();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=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(t){return(m="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})(t)}function g(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 y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t,e){return!e||"object"!==m(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var h=wp.i18n.__,f=wp.element.render;function b(t){var e="yasr-ranking-element-"+d(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return L(a,e,!1,.1,!0,t.rating)}})}function _(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",h("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",h("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 E(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===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=h("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(_,{post:t.post,tableId:t.tableId,text:a}),React.createElement(b,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(b,{rating:t.post.rating,tableId:t.tableId}),React.createElement(_,{post:t.post,tableId:t.tableId,text:a}))}function k(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(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(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(k,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}for(var w=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&&y(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=v(r);if(n){var a=v(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return p(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(h("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(h("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(h(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(h(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:h("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},h("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},h("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},h("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},h("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,"Post"),React.createElement("th",null,h("Order By","yet-another-stars-rating-pro"),":  ",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(S,{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(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(S,{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,h("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,a),o}(),I=wp.i18n.__,C=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],x=0;x<C.length;x++)P(C[x]);function P(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;L(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),s=O(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,p="yasr-vv-loader-"+l,v=document.getElementById(m),h=document.getElementById(g),f=document.getElementById(y),b=document.getElementById(p);if("yes"===yasrCommonData.ajaxEnabled){null!==b&&(b.innerHTML=yasrCommonData.loaderHtml);var _={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,_).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),B(c,r,o,e,i,0,u,d,v,h,b,f),!0!==n&&(null!==v&&(v.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==h&&(h.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==f&&(f.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,f.style.display=""))})).fail((function(t,e,a,l){console.info(I("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),B(c,r,o,s,i,0,u,d,v,h,b,f),!0!==n&&(f.style.display="")}))}else B(c,r,o,s,i,0,u,d,v,h,b,f)}}(e)}(e),"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(T(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=O(o);L(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var 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 n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function T(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 i=I("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=I("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}function L(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 B(t,e,a,r,n,s,o,i,l,c,u,d){e=parseFloat(e),r=O(r);var m=document.getElementById(n);null!==u&&(u.innerHTML=""),L(t,n,m,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(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!==l&&(l.innerHTML=e),null!==c&&(c.innerHTML=a)):r=t.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){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);f(React.createElement(w,{source:r,tableId:a,params:n,nonce:s}),o)}}();var j=a(702),A=wp.i18n.__,M=wp.components.PanelBody,N=wp.blockEditor.InspectorControls,z=A("All these settings are optional","yet-another-stars-rating"),H=A("Choose Size","yet-another-stars-rating"),D=A("Choose stars size","yet-another-stars-rating"),Y=A("Small","yet-another-stars-rating"),F=A("Medium","yet-another-stars-rating"),V=A("Large","yet-another-stars-rating"),J=A("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),U=A("Remember: only the post author can rate here.","yet-another-stars-rating"),Q=A("This is the star set where your users will be able to vote","yet-another-stars-rating");function q(t){return React.createElement("form",null,React.createElement("select",{value:t.size,onChange:function(e){return(0,t.setAttributes)({size:(a=e).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},j.yasrSelectSizeChoose),React.createElement("option",{value:"small"},j.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},j.yasrSelectSizeMedium),React.createElement("option",{value:"large"},j.yasrSelectSizeLarge)))}function K(t){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t.postId,onKeyPress:function(e){return function(t,e){if("Enter"===e.key){var a=e.target.value;!0!==/^\d+$/.test(a)&&""!==a||t({postId:a}),e.preventDefault()}}(t.setAttributes,e)}}))}function $(){var t=A("To be able to customize this ranking, you need","yet-another-stars-rating"),e=A("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",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#yasr-pro"},"Yasr Pro."),React.createElement("br",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"},"yetanotherstarsrating.com"))}function G(t){return React.createElement("div",null,React.createElement($,null))}function W(t){var e;return"visitors"===t.block&&(e=Q),"overall"===t.block&&(e=U),React.createElement(N,null,"overall"===t.block&&React.createElement(X,null),React.createElement(M,{title:"Settings"},React.createElement("h3",null,z),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,H),React.createElement("div",null,React.createElement(q,{size:t.size,setAttributes:t.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(K,{postId:t.postId,setAttributes:t.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},J)),React.createElement("div",{className:"yasr-guten-block-panel"},e)))}function X(t){var e=A("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(t,e){t=t.toFixed(1),t=parseFloat(t),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:t}}),this.setRating(t),e()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},e,React.createElement("div",{id:"overall-rater",ref:function(){return L(32,"overall-rater",!1,.1,!1,a,r)}}))}}},o={};function i(t){var e=o[t];if(void 0!==e)return e.exports;var a=o[t]={exports:{}};return s[t](a,a.exports,i),a.exports}i.d=(t,e)=>{for(var a in e)i.o(e,a)&&!i.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},t=i(702),e=wp.i18n.__,a=wp.blocks.registerBlockType,r=wp.element.Fragment,n=wp.blockEditor.useBlockProps,a("yet-another-stars-rating/overall-rating",{apiVersion:2,title:e("Yasr: Overall Rating","yet-another-stars-rating"),description:e("Insert the author rating","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[e("rating","yet-another-stars-rating"),e("author","yet-another-stars-rating"),e("overall","yet-another-stars-rating")],attributes:{size:{type:"string",default:"large"},postId:{type:"string",default:wp.data.select("core/editor").getCurrentPostId()}},supports:{align:["left","center","right"]},edit:function(e){var a=n({className:"yasr-overall-block"}),s=e.attributes,o=s.size,i=s.postId,l=e.setAttributes,c=e.isSelected,u=null,d=null;return"large"!==o&&(u=' size="'+o+'"'),!0===/^\d+$/.test(i)&&(d=' postid="'+i+'"'),React.createElement(r,null,c&&React.createElement(t.YasrBlocksPanel,{block:"overall",size:o,postId:i,setAttributes:l}),React.createElement("div",a,"[yasr_overall_rating",u,d,"]",c&&React.createElement(t.YasrPrintSelectSize,{size:o,setAttributes:l})))},save:function(t){var e=n.save({className:"yasr-overall-block"}),a=t.attributes,r=a.size,s=a.postId,o="";return r&&(o+='size="'+r+'"'),s&&(o+=' postid="'+s+'"'),React.createElement("div",e,"[yasr_overall_rating ",o,"]")}})})();
1
+ (()=>{"use strict";var e,t,a,r,n={245:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>R,YasrDivRatingOverall:()=>S,YasrNoSettingsPanel:()=>E,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>v,YasrProText:()=>b,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>d,yasrOptionalText:()=>o,yasrOverallDescription:()=>g,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>y});var r=a(245),n=wp.i18n.__,l=wp.components.PanelBody,s=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"),p=n("Large","yet-another-stars-rating"),d=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),g=n("Remember: only the post author can rate here.","yet-another-stars-rating"),y=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 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 b(){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 E(e){return React.createElement("div",null,React.createElement(b,null))}function R(e){var t;return"visitors"===e.block&&(t=y),"overall"===e.block&&(t=g),React.createElement(s,null,"overall"===e.block&&React.createElement(S,null),React.createElement(l,{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(h,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},d)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function S(e){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],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=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:l,rateCallback:s})}(32,"overall-rater",!1,.1,!1,a,r)}}))}}},l={};function s(e){var t=l[e];if(void 0!==t)return t.exports;var a=l[e]={exports:{}};return n[e](a,a.exports,s),a.exports}s.d=(e,t)=>{for(var a in t)s.o(t,a)&&!s.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=s(245),wp.i18n.__,t=wp.blocks.registerBlockType,a=wp.element.Fragment,r=wp.blockEditor.useBlockProps,t("yet-another-stars-rating/overall-rating",{edit:function(t){var n=r({className:"yasr-overall-block"}),l=t.attributes,s=l.size,o=l.postId,i=t.setAttributes,c=t.isSelected,u=null,m=null;return"large"!==s&&(u=' size="'+s+'"'),!0===/^\d+$/.test(o)&&(m=' postid="'+o+'"'),React.createElement(a,null,c&&React.createElement(e.YasrBlocksPanel,{block:"overall",size:s,postId:o,setAttributes:i}),React.createElement("div",n,"[yasr_overall_rating",u,m,"]",c&&React.createElement(e.YasrPrintSelectSize,{size:s,setAttributes:i})))},save:function(e){var t=r.save({className:"yasr-overall-block"}),a=e.attributes,n=a.size,l=a.postId,s="";return n&&(s+='size="'+n+'"'),l&&(s+=' postid="'+l+'"'),React.createElement("div",t,"[yasr_overall_rating ",s,"]")}})})();
admin/js/guten/blocks/rankings.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var t,e,a,r,n,s,o,i,l={702:(t,e,a)=>{var r,n;a.r(e),a.d(e,{YasrBlocksPanel:()=>W,YasrDivRatingOverall:()=>X,YasrNoSettingsPanel:()=>$,YasrPrintInputId:()=>K,YasrPrintSelectSize:()=>q,YasrProText:()=>G,yasrLabelSelectSize:()=>D,yasrLeaveThisBlankText:()=>J,yasrOptionalText:()=>H,yasrOverallDescription:()=>U,yasrSelectSizeChoose:()=>z,yasrSelectSizeLarge:()=>V,yasrSelectSizeMedium:()=>F,yasrSelectSizeSmall:()=>Y,yasrVisitorVotesDescription:()=>Q});var s=new Uint8Array(16);function o(){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(s)}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,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();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=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(t){return(m="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})(t)}function g(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 y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(t,e){return!e||"object"!==m(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var p=wp.i18n.__,f=wp.element.render;function _(t){var e="yasr-ranking-element-"+d(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return L(a,e,!1,.1,!0,t.rating)}})}function b(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",p("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 E(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===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=p("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(b,{post:t.post,tableId:t.tableId,text:a}),React.createElement(_,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(_,{rating:t.post.rating,tableId:t.tableId}),React.createElement(b,{post:t.post,tableId:t.tableId,text:a}))}function k(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(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function w(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(k,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}for(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&&y(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=h(r);if(n){var a=h(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return v(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(p("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(p("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(p(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(p(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:p("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},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("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,"Post"),React.createElement("th",null,p("Order By","yet-another-stars-rating-pro"),":  ",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(w,{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(w,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(w,{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,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,a),o}(),I=wp.i18n.__,C=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],x=0;x<C.length;x++)T(C[x]);function T(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;L(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=N(n),s=N(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,v="yasr-vv-loader-"+l,h=document.getElementById(m),p=document.getElementById(g),f=document.getElementById(y),_=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){null!==_&&(_.innerHTML=yasrCommonData.loaderHtml);var b={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,b).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),B(c,r,o,e,i,0,u,d,h,p,_,f),!0!==n&&(null!==h&&(h.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==p&&(p.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==f&&(f.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,f.style.display=""))})).fail((function(t,e,a,l){console.info(I("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),B(c,r,o,s,i,0,u,d,h,p,_,f),!0!==n&&(f.style.display="")}))}else B(c,r,o,s,i,0,u,d,h,p,_,f)}}(e)}(e),"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(P(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=N(o);L(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var 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 n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function P(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 i=I("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=I("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}function L(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 B(t,e,a,r,n,s,o,i,l,c,u,d){e=parseFloat(e),r=N(r);var m=document.getElementById(n);null!==u&&(u.innerHTML=""),L(t,n,m,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(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!==l&&(l.innerHTML=e),null!==c&&(c.innerHTML=a)):r=t.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function N(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){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);f(React.createElement(S,{source:r,tableId:a,params:n,nonce:s}),o)}}();var j=a(702),O=wp.i18n.__,M=wp.components.PanelBody,A=wp.blockEditor.InspectorControls,H=O("All these settings are optional","yet-another-stars-rating"),D=O("Choose Size","yet-another-stars-rating"),z=O("Choose stars size","yet-another-stars-rating"),Y=O("Small","yet-another-stars-rating"),F=O("Medium","yet-another-stars-rating"),V=O("Large","yet-another-stars-rating"),J=O("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),U=O("Remember: only the post author can rate here.","yet-another-stars-rating"),Q=O("This is the star set where your users will be able to vote","yet-another-stars-rating");function q(t){return React.createElement("form",null,React.createElement("select",{value:t.size,onChange:function(e){return(0,t.setAttributes)({size:(a=e).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},j.yasrSelectSizeChoose),React.createElement("option",{value:"small"},j.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},j.yasrSelectSizeMedium),React.createElement("option",{value:"large"},j.yasrSelectSizeLarge)))}function K(t){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t.postId,onKeyPress:function(e){return function(t,e){if("Enter"===e.key){var a=e.target.value;!0!==/^\d+$/.test(a)&&""!==a||t({postId:a}),e.preventDefault()}}(t.setAttributes,e)}}))}function G(){var t=O("To be able to customize this ranking, you need","yet-another-stars-rating"),e=O("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",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#yasr-pro"},"Yasr Pro."),React.createElement("br",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"},"yetanotherstarsrating.com"))}function $(t){return React.createElement("div",null,React.createElement(G,null))}function W(t){var e;return"visitors"===t.block&&(e=Q),"overall"===t.block&&(e=U),React.createElement(A,null,"overall"===t.block&&React.createElement(X,null),React.createElement(M,{title:"Settings"},React.createElement("h3",null,H),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,D),React.createElement("div",null,React.createElement(q,{size:t.size,setAttributes:t.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(K,{postId:t.postId,setAttributes:t.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},J)),React.createElement("div",{className:"yasr-guten-block-panel"},e)))}function X(t){var e=O("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(t,e){t=t.toFixed(1),t=parseFloat(t),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:t}}),this.setRating(t),e()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},e,React.createElement("div",{id:"overall-rater",ref:function(){return L(32,"overall-rater",!1,.1,!1,a,r)}}))}}},c={};function u(t){var e=c[t];if(void 0!==e)return e.exports;var a=c[t]={exports:{}};return l[t](a,a.exports,u),a.exports}u.d=(t,e)=>{for(var a in e)u.o(e,a)&&!u.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},u.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),u.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},t=u(702),e=wp.i18n.__,a=wp.blocks.registerBlockType,r=wp.components.PanelBody,n=wp.element.Fragment,s=wp.blockEditor,o=s.useBlockProps,i=s.InspectorControls,a("yet-another-stars-rating/overall-rating-ranking",{apiVersion:2,title:e("Yasr: Ranking by overall rating","yet-another-stars-rating"),description:e("This ranking shows the highest rated posts rated through the overall_rating shortcode.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[e("ranking","yet-another-stars-rating"),e("highest","yet-another-stars-rating"),e("chart","yet-another-stars-rating")],supports:{align:["left","center","right"]},edit:function(e){var a=o({className:"yasr-ov-ranking-block"}),s=[React.createElement(t.YasrNoSettingsPanel,{key:0})];function l(t){return React.createElement(i,null,React.createElement(r,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,s))))}return wp.hooks.doAction("yasr_overall_rating_rankings",s),React.createElement(n,null,React.createElement(l,null),React.createElement("div",a,"[yasr_ov_ranking]"))},save:function(t){var e=o.save({className:"yasr-ov-ranking-block"});return React.createElement("div",e,"[yasr_ov_ranking]")}}),a("yet-another-stars-rating/visitor-votes-ranking",{apiVersion:2,title:e("Yasr: Ranking by visitors votes","yet-another-stars-rating"),description:e("This ranking shows both the highest and most rated posts rated through the yasr_visitor_votes shortcode. For an item to appear in this chart, it has to be rated at least twice. ","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[e("ranking","yet-another-stars-rating"),e("highest","yet-another-stars-rating"),e("most","yet-another-stars-rating"),e("chart","yet-another-stars-rating")],edit:function(e){var a=o({className:"yasr-vv-ranking-block"}),s=[React.createElement(t.YasrNoSettingsPanel,{key:0})];function l(t){return React.createElement(i,null,React.createElement(r,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,s))))}return wp.hooks.doAction("yasr_visitor_votes_rankings",s),React.createElement(n,null,React.createElement(l,null),React.createElement("div",a,"[yasr_most_or_highest_rated_posts]"))},save:function(t){var e=o.save({className:"yasr-vv-ranking-block"});return React.createElement("div",e,"[yasr_most_or_highest_rated_posts]")}})})();
1
+ (()=>{"use strict";var e,t,a,r,n,l,s,o={245:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>b,YasrDivRatingOverall:()=>k,YasrNoSettingsPanel:()=>R,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>d,YasrProText:()=>E,yasrLabelSelectSize:()=>c,yasrLeaveThisBlankText:()=>v,yasrOptionalText:()=>o,yasrOverallDescription:()=>p,yasrSelectSizeChoose:()=>i,yasrSelectSizeLarge:()=>g,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>y});var r=a(245),n=wp.i18n.__,l=wp.components.PanelBody,s=wp.blockEditor.InspectorControls,o=n("All these settings are optional","yet-another-stars-rating"),c=n("Choose Size","yet-another-stars-rating"),i=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),g=n("Large","yet-another-stars-rating"),v=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),p=n("Remember: only the post author can rate here.","yet-another-stars-rating"),y=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function d(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 E(){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(E,null))}function b(e){var t;return"visitors"===e.block&&(t=y),"overall"===e.block&&(t=p),React.createElement(s,null,"overall"===e.block&&React.createElement(k,null),React.createElement(l,{title:"Settings"},React.createElement("h3",null,o),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,c),React.createElement("div",null,React.createElement(d,{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"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function k(e){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],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=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:l,rateCallback:s})}(32,"overall-rater",!1,.1,!1,a,r)}}))}}},c={};function i(e){var t=c[e];if(void 0!==t)return t.exports;var a=c[e]={exports:{}};return o[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var a in t)i.o(t,a)&&!i.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=i(245),t=wp.blocks.registerBlockType,a=wp.components.PanelBody,r=wp.element.Fragment,n=wp.blockEditor,l=n.useBlockProps,s=n.InspectorControls,t("yet-another-stars-rating/overall-rating-ranking",{edit:function(t){var n=l({className:"yasr-ov-ranking-block"}),o=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function c(e){return React.createElement(s,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,o))))}return wp.hooks.doAction("yasr_overall_rating_rankings",o),React.createElement(r,null,React.createElement(c,null),React.createElement("div",n,"[yasr_ov_ranking]"))},save:function(e){var t=l.save({className:"yasr-ov-ranking-block"});return React.createElement("div",t,"[yasr_ov_ranking]")}}),t("yet-another-stars-rating/visitor-votes-ranking",{edit:function(t){var n=l({className:"yasr-vv-ranking-block"}),o=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function c(e){return React.createElement(s,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,o))))}return wp.hooks.doAction("yasr_visitor_votes_rankings",o),React.createElement(r,null,React.createElement(c,null),React.createElement("div",n,"[yasr_most_or_highest_rated_posts]"))},save:function(e){var t=l.save({className:"yasr-vv-ranking-block"});return React.createElement("div",t,"[yasr_most_or_highest_rated_posts]")}})})();
admin/js/guten/blocks/visitorVotes.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var t,e,a,r,n,s={702:(t,e,a)=>{var r,n;a.r(e),a.d(e,{YasrBlocksPanel:()=>W,YasrDivRatingOverall:()=>X,YasrNoSettingsPanel:()=>G,YasrPrintInputId:()=>K,YasrPrintSelectSize:()=>q,YasrProText:()=>$,yasrLabelSelectSize:()=>H,yasrLeaveThisBlankText:()=>J,yasrOptionalText:()=>z,yasrOverallDescription:()=>U,yasrSelectSizeChoose:()=>D,yasrSelectSizeLarge:()=>F,yasrSelectSizeMedium:()=>Y,yasrSelectSizeSmall:()=>V,yasrVisitorVotesDescription:()=>Q});var s=new Uint8Array(16);function o(){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(s)}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,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();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=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(t){return(m="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})(t)}function g(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 y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t,e){return!e||"object"!==m(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var f=wp.i18n.__,h=wp.element.render;function b(t){var e="yasr-ranking-element-"+d(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return L(a,e,!1,.1,!0,t.rating)}})}function _(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",f("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",f("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 E(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===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=f("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(_,{post:t.post,tableId:t.tableId,text:a}),React.createElement(b,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(b,{rating:t.post.rating,tableId:t.tableId}),React.createElement(_,{post:t.post,tableId:t.tableId,text:a}))}function k(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(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(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(k,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}for(var w=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&&y(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=v(r);if(n){var a=v(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return p(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(f("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(f("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(f(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(f(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:f("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},f("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},f("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},f("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},f("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,"Post"),React.createElement("th",null,f("Order By","yet-another-stars-rating-pro"),":  ",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(S,{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(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(S,{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,f("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,a),o}(),I=wp.i18n.__,C=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],x=0;x<C.length;x++)P(C[x]);function P(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;L(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=j(n),s=j(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,p="yasr-vv-loader-"+l,v=document.getElementById(m),f=document.getElementById(g),h=document.getElementById(y),b=document.getElementById(p);if("yes"===yasrCommonData.ajaxEnabled){null!==b&&(b.innerHTML=yasrCommonData.loaderHtml);var _={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,_).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),B(c,r,o,e,i,0,u,d,v,f,b,h),!0!==n&&(null!==v&&(v.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,a,l){console.info(I("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),B(c,r,o,s,i,0,u,d,v,f,b,h),!0!==n&&(h.style.display="")}))}else B(c,r,o,s,i,0,u,d,v,f,b,h)}}(e)}(e),"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(T(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=j(o);L(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var 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 n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function T(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 i=I("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=I("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}function L(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 B(t,e,a,r,n,s,o,i,l,c,u,d){e=parseFloat(e),r=j(r);var m=document.getElementById(n);null!==u&&(u.innerHTML=""),L(t,n,m,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(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!==l&&(l.innerHTML=e),null!==c&&(c.innerHTML=a)):r=t.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function j(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){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);h(React.createElement(w,{source:r,tableId:a,params:n,nonce:s}),o)}}();var O=a(702),A=wp.i18n.__,M=wp.components.PanelBody,N=wp.blockEditor.InspectorControls,z=A("All these settings are optional","yet-another-stars-rating"),H=A("Choose Size","yet-another-stars-rating"),D=A("Choose stars size","yet-another-stars-rating"),V=A("Small","yet-another-stars-rating"),Y=A("Medium","yet-another-stars-rating"),F=A("Large","yet-another-stars-rating"),J=A("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),U=A("Remember: only the post author can rate here.","yet-another-stars-rating"),Q=A("This is the star set where your users will be able to vote","yet-another-stars-rating");function q(t){return React.createElement("form",null,React.createElement("select",{value:t.size,onChange:function(e){return(0,t.setAttributes)({size:(a=e).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},O.yasrSelectSizeChoose),React.createElement("option",{value:"small"},O.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},O.yasrSelectSizeMedium),React.createElement("option",{value:"large"},O.yasrSelectSizeLarge)))}function K(t){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t.postId,onKeyPress:function(e){return function(t,e){if("Enter"===e.key){var a=e.target.value;!0!==/^\d+$/.test(a)&&""!==a||t({postId:a}),e.preventDefault()}}(t.setAttributes,e)}}))}function $(){var t=A("To be able to customize this ranking, you need","yet-another-stars-rating"),e=A("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",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#yasr-pro"},"Yasr Pro."),React.createElement("br",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"},"yetanotherstarsrating.com"))}function G(t){return React.createElement("div",null,React.createElement($,null))}function W(t){var e;return"visitors"===t.block&&(e=Q),"overall"===t.block&&(e=U),React.createElement(N,null,"overall"===t.block&&React.createElement(X,null),React.createElement(M,{title:"Settings"},React.createElement("h3",null,z),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,H),React.createElement("div",null,React.createElement(q,{size:t.size,setAttributes:t.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(K,{postId:t.postId,setAttributes:t.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},J)),React.createElement("div",{className:"yasr-guten-block-panel"},e)))}function X(t){var e=A("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(t,e){t=t.toFixed(1),t=parseFloat(t),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:t}}),this.setRating(t),e()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},e,React.createElement("div",{id:"overall-rater",ref:function(){return L(32,"overall-rater",!1,.1,!1,a,r)}}))}}},o={};function i(t){var e=o[t];if(void 0!==e)return e.exports;var a=o[t]={exports:{}};return s[t](a,a.exports,i),a.exports}i.d=(t,e)=>{for(var a in e)i.o(e,a)&&!i.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},t=i(702),e=wp.i18n.__,a=wp.blocks.registerBlockType,r=wp.element.Fragment,n=wp.blockEditor.useBlockProps,a("yet-another-stars-rating/visitor-votes",{apiVersion:2,title:e("Yasr: Visitor Votes","yet-another-stars-rating"),description:e("Insert the ability for your visitors to vote","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[e("rating","yet-another-stars-rating"),e("visitor","yet-another-stars-rating"),e("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"large"},postId:{type:"string",default:wp.data.select("core/editor").getCurrentPostId()}},supports:{align:["left","center","right"]},edit:function(e){var a=n({className:"yasr-vv-block"}),s=e.attributes,o=s.size,i=s.postId,l=e.setAttributes,c=e.isSelected,u=null,d=null;return"large"!==o&&(u=' size="'+o+'"'),!0===/^\d+$/.test(i)&&(d=' postid="'+i+'"'),React.createElement(r,null,React.createElement(t.YasrBlocksPanel,{block:"visitors",size:o,setAttributes:l,postId:i}),React.createElement("div",a,"[yasr_visitor_votes",u,d,"]",c&&React.createElement(t.YasrPrintSelectSize,{size:o,setAttributes:l})))},save:function(t){var e=n.save({className:"yasr-vv-block"}),a=t.attributes,r=a.size,s=a.postId,o="";return r&&(o+='size="'+r+'"'),s&&(o+=' postid="'+s+'"'),React.createElement("div",e,"[yasr_visitor_votes ",o,"]")}})})();
1
+ (()=>{"use strict";var e,t,a,r,n={245:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>R,YasrDivRatingOverall:()=>S,YasrNoSettingsPanel:()=>E,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>y,YasrProText:()=>b,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>d,yasrOptionalText:()=>o,yasrOverallDescription:()=>v,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>g});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"),p=n("Large","yet-another-stars-rating"),d=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),v=n("Remember: only the post author can rate here.","yet-another-stars-rating"),g=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function y(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 b(){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 E(e){return React.createElement("div",null,React.createElement(b,null))}function R(e){var t;return"visitors"===e.block&&(t=g),"overall"===e.block&&(t=v),React.createElement(l,null,"overall"===e.block&&React.createElement(S,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(y,{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"},d)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function S(e){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)}}))}}},s={};function l(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={exports:{}};return n[e](a,a.exports,l),a.exports}l.d=(e,t)=>{for(var a in t)l.o(t,a)&&!l.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=l(245),wp.i18n.__,t=wp.blocks.registerBlockType,a=wp.element.Fragment,r=wp.blockEditor.useBlockProps,t("yet-another-stars-rating/visitor-votes",{edit:function(t){var n=r({className:"yasr-vv-block"}),s=t.attributes,l=s.size,o=s.postId,i=t.setAttributes,c=t.isSelected,u=null,m=null;return"large"!==l&&(u=' size="'+l+'"'),!0===/^\d+$/.test(o)&&(m=' postid="'+o+'"'),React.createElement(a,null,React.createElement(e.YasrBlocksPanel,{block:"visitors",size:l,setAttributes:i,postId:o}),React.createElement("div",n,"[yasr_visitor_votes",u,m,"]",c&&React.createElement(e.YasrPrintSelectSize,{size:l,setAttributes:i})))},save:function(e){var t=r.save({className:"yasr-vv-block"}),a=e.attributes,n=a.size,s=a.postId,l="";return n&&(l+='size="'+n+'"'),s&&(l+=' postid="'+s+'"'),React.createElement("div",t,"[yasr_visitor_votes ",l,"]")}})})();
admin/js/guten/blocks/yasrGutenUtils.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var t={702:(t,e,a)=>{var r,n;a.r(e),a.d(e,{YasrBlocksPanel:()=>W,YasrDivRatingOverall:()=>X,YasrNoSettingsPanel:()=>$,YasrPrintInputId:()=>K,YasrPrintSelectSize:()=>q,YasrProText:()=>G,yasrLabelSelectSize:()=>D,yasrLeaveThisBlankText:()=>V,yasrOptionalText:()=>H,yasrOverallDescription:()=>Y,yasrSelectSizeChoose:()=>z,yasrSelectSizeLarge:()=>U,yasrSelectSizeMedium:()=>J,yasrSelectSizeSmall:()=>F,yasrVisitorVotesDescription:()=>Q});var s=new Uint8Array(16);function o(){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(s)}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,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();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=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(t){return(m="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})(t)}function g(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 y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t,e){return!e||"object"!==m(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var f=wp.i18n.__,h=wp.element.render;function b(t){var e="yasr-ranking-element-"+d(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return P(a,e,!1,.1,!0,t.rating)}})}function _(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",f("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",f("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 E(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===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=f("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(_,{post:t.post,tableId:t.tableId,text:a}),React.createElement(b,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(b,{rating:t.post.rating,tableId:t.tableId}),React.createElement(_,{post:t.post,tableId:t.tableId,text:a}))}function k(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(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(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(k,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}for(var w=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&&y(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=v(r);if(n){var a=v(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return p(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(f("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(f("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(f(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(f(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:f("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},f("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},f("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},f("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},f("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,"Post"),React.createElement("th",null,f("Order By","yet-another-stars-rating-pro"),":  ",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(S,{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(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(S,{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,f("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,a),o}(),I=wp.i18n.__,C=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],x=0;x<C.length;x++)L(C[x]);function L(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;P(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=j(n),s=j(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,p="yasr-vv-loader-"+l,v=document.getElementById(m),f=document.getElementById(g),h=document.getElementById(y),b=document.getElementById(p);if("yes"===yasrCommonData.ajaxEnabled){null!==b&&(b.innerHTML=yasrCommonData.loaderHtml);var _={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,_).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),B(c,r,o,e,i,0,u,d,v,f,b,h),!0!==n&&(null!==v&&(v.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,a,l){console.info(I("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),B(c,r,o,s,i,0,u,d,v,f,b,h),!0!==n&&(h.style.display="")}))}else B(c,r,o,s,i,0,u,d,v,f,b,h)}}(e)}(e),"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(T(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=j(o);P(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var 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 n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function T(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 i=I("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=I("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}function P(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 B(t,e,a,r,n,s,o,i,l,c,u,d){e=parseFloat(e),r=j(r);var m=document.getElementById(n);null!==u&&(u.innerHTML=""),P(t,n,m,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(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!==l&&(l.innerHTML=e),null!==c&&(c.innerHTML=a)):r=t.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function j(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){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);h(React.createElement(w,{source:r,tableId:a,params:n,nonce:s}),o)}}();var O=a(702),M=wp.i18n.__,N=wp.components.PanelBody,A=wp.blockEditor.InspectorControls,H=M("All these settings are optional","yet-another-stars-rating"),D=M("Choose Size","yet-another-stars-rating"),z=M("Choose stars size","yet-another-stars-rating"),F=M("Small","yet-another-stars-rating"),J=M("Medium","yet-another-stars-rating"),U=M("Large","yet-another-stars-rating"),V=M("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),Y=M("Remember: only the post author can rate here.","yet-another-stars-rating"),Q=M("This is the star set where your users will be able to vote","yet-another-stars-rating");function q(t){return React.createElement("form",null,React.createElement("select",{value:t.size,onChange:function(e){return(0,t.setAttributes)({size:(a=e).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},O.yasrSelectSizeChoose),React.createElement("option",{value:"small"},O.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},O.yasrSelectSizeMedium),React.createElement("option",{value:"large"},O.yasrSelectSizeLarge)))}function K(t){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t.postId,onKeyPress:function(e){return function(t,e){if("Enter"===e.key){var a=e.target.value;!0!==/^\d+$/.test(a)&&""!==a||t({postId:a}),e.preventDefault()}}(t.setAttributes,e)}}))}function G(){var t=M("To be able to customize this ranking, you need","yet-another-stars-rating"),e=M("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",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#yasr-pro"},"Yasr Pro."),React.createElement("br",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"},"yetanotherstarsrating.com"))}function $(t){return React.createElement("div",null,React.createElement(G,null))}function W(t){var e;return"visitors"===t.block&&(e=Q),"overall"===t.block&&(e=Y),React.createElement(A,null,"overall"===t.block&&React.createElement(X,null),React.createElement(N,{title:"Settings"},React.createElement("h3",null,H),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,D),React.createElement("div",null,React.createElement(q,{size:t.size,setAttributes:t.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(K,{postId:t.postId,setAttributes:t.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},V)),React.createElement("div",{className:"yasr-guten-block-panel"},e)))}function X(t){var e=M("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(t,e){t=t.toFixed(1),t=parseFloat(t),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:t}}),this.setRating(t),e()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},e,React.createElement("div",{id:"overall-rater",ref:function(){return P(32,"overall-rater",!1,.1,!1,a,r)}}))}}},e={};function a(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,a),s.exports}a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a(702)})();
1
+ (()=>{"use strict";var e={245:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>S,YasrDivRatingOverall:()=>E,YasrNoSettingsPanel:()=>R,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>v,YasrProText:()=>b,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>g,yasrOptionalText:()=>o,yasrOverallDescription:()=>d,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>y});var r=a(245),n=wp.i18n.__,l=wp.components.PanelBody,s=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"),p=n("Large","yet-another-stars-rating"),g=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"),y=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 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 b(){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(b,null))}function S(e){var t;return"visitors"===e.block&&(t=y),"overall"===e.block&&(t=d),React.createElement(s,null,"overall"===e.block&&React.createElement(E,null),React.createElement(l,{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(h,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},g)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function E(e){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],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=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:l,rateCallback:s})}(32,"overall-rater",!1,.1,!1,a,r)}}))}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var l=t[r]={exports:{}};return e[r](l,l.exports,a),l.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})},a(245)})();
admin/js/guten/yasr-guten-misc.js CHANGED
@@ -1 +1 @@
1
- (()=>{var e={702:(e,t,a)=>{"use strict";var r,n;a.r(t),a.d(t,{YasrBlocksPanel:()=>W,YasrDivRatingOverall:()=>X,YasrNoSettingsPanel:()=>G,YasrPrintInputId:()=>$,YasrPrintSelectSize:()=>Q,YasrProText:()=>K,yasrLabelSelectSize:()=>D,yasrLeaveThisBlankText:()=>V,yasrOptionalText:()=>z,yasrOverallDescription:()=>q,yasrSelectSizeChoose:()=>H,yasrSelectSizeLarge:()=>U,yasrSelectSizeMedium:()=>F,yasrSelectSizeSmall:()=>Y,yasrVisitorVotesDescription:()=>J});var s=new Uint8Array(16);function o(){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(s)}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,l=function(e){return"string"==typeof e&&i.test(e)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(e,t,a){var r=(e=e||{}).random||(e.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){a=a||0;for(var n=0;n<16;++n)t[a+n]=r[n];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(e){return(m="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)}function y(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 p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e,t){return!t||"object"!==m(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var v=wp.i18n.__,h=wp.element.render;function b(e){var t="yasr-ranking-element-"+d(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return T(a,t,!1,.1,!0,e.rating)}})}function R(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",v("Total:","yet-another-stars-rating")," ",e.post.number_of_votes,"  ",v("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function E(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=e;var t=r.textContent;return r.innerHTML="",t}(e.post.title)))}function _(e){var t="after",a=v("Rating:","yet-another-stars-rating"),r=new URLSearchParams(e.rankingParams);return null!==r.get("text_position")&&(t=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(R,{post:e.post,tableId:e.tableId,text:a}),React.createElement(b,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(b,{rating:e.post.rating,tableId:e.tableId}),React.createElement(R,{post:e.post,tableId:e.tableId,text:a}))}function w(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(E,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function k(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var r="yasr-rankings-td-colored";return"author_ranking"===e.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===e.source&&(r="yasr-rankings-td-colored")),React.createElement(w,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:r})})))}for(var S=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&&p(e,t)}(o,React.Component);var t,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(e){return!1}}(),function(){var e,t=f(r);if(n){var a=f(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return g(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,(a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(v("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:t});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info(v("Ajax Call Failed. Getting data from source")),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(v(e))}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(v(t)),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:v("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);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)e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);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]"))}e=[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 e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:r},v("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},v("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:n},v("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},v("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,"Post"),React.createElement("th",null,v("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.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(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===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)),t===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 e=this.state,t=e.data,a=e.source,r=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(k,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=t.most,s=t.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(k,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(k,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,v("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(t.prototype,a),o}(),I=wp.i18n.__,P=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],C=0;C<P.length;C++)O(P[C]);function O(e){var t=document.getElementsByClassName(e);if(t.length>0){if("yasr-rater-stars"!==e&&"yasr-ranking-stars"!==e||function(e){for(var t=0;t<e.length;t++)if(!1===e.item(t).classList.contains("yasr-star-rating")){var a=e.item(t),r=a.id;T(a.getAttribute("data-rater-starsize"),r,a)}}(t),"yasr-rater-stars-vv"===e&&(function(e){for(var t=0;t<e.length;t++)!function(t){if(!1===e.item(t).classList.contains("yasr-star-rating")){var a=e.item(t),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=j(n),s=j(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,y="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,g="yasr-vv-loader-"+l,f=document.getElementById(m),v=document.getElementById(y),h=document.getElementById(p),b=document.getElementById(g);if("yes"===yasrCommonData.ajaxEnabled){null!==b&&(b.innerHTML=yasrCommonData.loaderHtml);var R={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,R).done((function(e){var t,a=JSON.parse(e);t=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),N(c,r,o,t,i,0,u,d,f,v,b,h),!0!==n&&(null!==f&&(f.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==v&&(v.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(e,t,a,l){console.info(I("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),N(c,r,o,s,i,0,u,d,f,v,b,h),!0!==n&&(h.style.display="")}))}else N(c,r,o,s,i,0,u,d,f,v,b,h)}}(t)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(e){for(var t,a,r=!1,n=0;n<e.length;n++)!function(n){var s="#"+e.item(n).id,o=e.item(n).getAttribute("data-postid");0===n&&null!==(t=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(t[0],null).getPropertyValue("color")),a&&(document.getElementById(e.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(e){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(t){t=JSON.parse(t),e.setContent(x(t))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===e&&function(e){for(var t="",a=[],r=0;r<e.length;r++)!function(r){if(!1===e.item(r).classList.contains("yasr-star-rating")){var n=e.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=j(o);T(16,s,n,1,o,!1,(function(e,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");e=e.toFixed(1);var l=parseInt(e);this.setRating(l),t={postid:s,setid:o,field:i,rating:l},a.push(t),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var e=this.getAttribute("data-postid"),t=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+e+"-"+t).hide(),jQuery("#yasr-loader-multiset-visitor-"+e+"-"+t).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:e,rating:a,set_id:t};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+e+"-"+t).text(r)}))}))}(t)}}function x(e){var t=e.medium_rating;delete e.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||e[r].n_of_votes>a)&&(a=e[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">'+t+" "+I("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';for(var i=I("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=I("star","yet-another-stars-rating")),void 0!==e[u]&&(l=e[u].progressbar,c=e[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}function T(e,t){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(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:a,step:n,readOnly:s,rating:o,rateCallback:i})}function N(e,t,a,r,n,s,o,i,l,c,u,d){t=parseFloat(t),r=j(r);var m=document.getElementById(n);null!==u&&(u.innerHTML=""),T(e,n,m,1,r,t,(function(e,t){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:e,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(e),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(function(e){var t,a,r;"success"===(e=JSON.parse(e)).status?(t=e.number_of_votes,a=e.average_rating,r=e.rating_saved_text,null!==l&&(l.innerHTML=t),null!==c&&(c.innerHTML=a)):r=e.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),t()}))}function j(e){return null!=e&&""!==e||(e=!0),"true"!==e&&"1"!==e||(e=!0),"false"!==e&&"0"!==e||(e=!1),e}!function(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,r=JSON.parse(e.item(t).dataset.rankingSource),n=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);h(React.createElement(S,{source:r,tableId:a,params:n,nonce:s}),o)}}();var B=a(702),L=wp.i18n.__,A=wp.components.PanelBody,M=wp.blockEditor.InspectorControls,z=L("All these settings are optional","yet-another-stars-rating"),D=L("Choose Size","yet-another-stars-rating"),H=L("Choose stars size","yet-another-stars-rating"),Y=L("Small","yet-another-stars-rating"),F=L("Medium","yet-another-stars-rating"),U=L("Large","yet-another-stars-rating"),V=L("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),q=L("Remember: only the post author can rate here.","yet-another-stars-rating"),J=L("This is the star set where your users will be able to vote","yet-another-stars-rating");function Q(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:"--"},B.yasrSelectSizeChoose),React.createElement("option",{value:"small"},B.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},B.yasrSelectSizeMedium),React.createElement("option",{value:"large"},B.yasrSelectSizeLarge)))}function $(e){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:e.postId,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 K(){var e=L("To be able to customize this ranking, you need","yet-another-stars-rating"),t=L("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 G(e){return React.createElement("div",null,React.createElement(K,null))}function W(e){var t;return"visitors"===e.block&&(t=J),"overall"===e.block&&(t=q),React.createElement(M,null,"overall"===e.block&&React.createElement(X,null),React.createElement(A,{title:"Settings"},React.createElement("h3",null,z),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,D),React.createElement("div",null,React.createElement(Q,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement($,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},V)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function X(e){var t=L("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 T(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})(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})(e,t)}function r(t,a){return!a||"object"!==e(a)&&"function"!=typeof a?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t):a}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var s=wp.i18n.__,o=wp.blocks.registerBlockType,i=wp.components,l=i.PanelBody,c=(i.PanelRow,wp.element.Fragment),u=wp.editor,d=(u.BlockControls,u.InspectorControls),m=s("All these settings are optional","yet-another-stars-rating"),y=s("Choose Size","yet-another-stars-rating"),p=s("Choose stars size","yet-another-stars-rating"),g=s("Small","yet-another-stars-rating"),f=s("Medium","yet-another-stars-rating"),v=s("Large","yet-another-stars-rating"),h=s("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),b=s("Remember: only the post author can rate here.","yet-another-stars-rating"),R=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"),_=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");o("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 o,i=e.attributes,u=i.overallRatingMeta,R=i.size,E=i.postId,_=e.setAttributes,w=e.isSelected,k=u,S=null,I=null;"--"!==R&&(S=' size="'+R+'"'),o=/^\d+$/.test(E),"--"!==E&&!0===o&&(I=' postid="'+E+'"');var P=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)}(d,React.Component);var o,i,l,c,u=(l=d,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(l);if(c){var a=n(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return r(this,e)});function d(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,d),(t=u.call(this,e)).yasrOverallRateThis=s("Rate this article / item","yet-another-stars-rating"),t}return o=d,(i=[{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:k,readOnly:!1,element:document.querySelector("#overall-rater"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),_({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&t(o.prototype,i),d}();function C(){return React.createElement("form",null,React.createElement("select",{value:R,onChange:O},React.createElement("option",{value:"--"},p),React.createElement("option",{value:"small"},g),React.createElement("option",{value:"medium"},f),React.createElement("option",{value:"large"},v)))}function O(e){var t=e.target.querySelector("option:checked");_({size:t.value}),e.preventDefault()}function x(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:T}))}function T(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||_({postId:t}),e.preventDefault()}}function N(e){return React.createElement(d,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(P,null)),React.createElement(l,{title:"Settings"},React.createElement("h3",null,m),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,y),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"},b)))}return React.createElement(c,null,React.createElement(N,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",S,I,"]",w&&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,"]")}}),o("yet-another-stars-rating/yasr-visitor-votes",{title:s("[DEPRECATED]Yasr: Visitor Votes","yet-another-stars-rating"),description:_,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,o=e.isSelected,i=null,u=null;function b(){return React.createElement("form",null,React.createElement("select",{value:r,onChange:E},React.createElement("option",{value:"--"},p),React.createElement("option",{value:"small"},g),React.createElement("option",{value:"medium"},f),React.createElement("option",{value:"large"},v)))}function E(e){var t=e.target.querySelector("option:checked");s({size:t.value}),e.preventDefault()}function _(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:w}))}function w(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||s({postId:t}),e.preventDefault()}}function k(e){return React.createElement(d,null,React.createElement(l,{title:"Settings"},React.createElement("h3",null,m),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,y),React.createElement("div",null,React.createElement(b,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(_,null),React.createElement("div",{className:"yasr-guten-block-explain"},h)),React.createElement("div",{className:"yasr-guten-block-panel"},R)))}return t=/^\d+$/.test(n),"--"!==r&&(i=' size="'+r+'"'),"--"!==n&&!0===t&&(u=' postid="'+n+'"'),React.createElement(c,null,React.createElement(k,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",i,u,"]",o&&React.createElement(b,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(702);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})(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 o(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&&i(e,t)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(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=d(e);if(t){var n=d(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return c(this,a)}}function c(e,a){return!a||"object"!==t(a)&&"function"!=typeof a?u(e):a}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var m=wp.i18n.__,y=wp.plugins.registerPlugin,p=wp.editPost,g=p.PluginSidebar,f=p.PluginSidebarMoreMenuItem,v=wp.components.PanelBody,h=wp.element.Fragment,b=function(){return React.createElement("div",null)},R=function(e){o(a,React.Component);var t=l(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,m("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){o(n,React.Component);var a=l(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(b,{key:0})];return wp.hooks.doAction("yasr_below_panel",t),React.createElement(h,null,React.createElement(f,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},m("YASR post settings","yet-another-stars-rating")),React.createElement(g,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(v,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(e.YasrDivRatingOverall,null),React.createElement("div",null,m('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}();y("yasr-sidebar",{icon:"star-half",title:m("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:()=>R,YasrDivRatingOverall:()=>E,YasrNoSettingsPanel:()=>b,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>g,YasrProText:()=>v,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>m,yasrOptionalText:()=>s,yasrOverallDescription:()=>d,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>y,yasrSelectSizeMedium:()=>p,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>f});var r=a(245),n=wp.i18n.__,l=wp.components.PanelBody,o=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"),p=n("Medium","yet-another-stars-rating"),y=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(o,null,"overall"===e.block&&React.createElement(E,null),React.createElement(l,{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){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],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=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:l,rateCallback:o})}(32,"overall-rater",!1,.1,!1,a,r)}}))}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var l=t[r]={exports:{}};return e[r](l,l.exports,a),l.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})(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})(e,t)}function r(t,a){return!a||"object"!==e(a)&&"function"!=typeof a?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t):a}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=wp.i18n.__,o=wp.blocks.registerBlockType,s=wp.components,i=s.PanelBody,c=(s.PanelRow,wp.element.Fragment),u=wp.editor,p=(u.BlockControls,u.InspectorControls),y=l("All these settings are optional","yet-another-stars-rating"),m=l("Choose Size","yet-another-stars-rating"),d=l("Choose stars size","yet-another-stars-rating"),f=l("Small","yet-another-stars-rating"),g=l("Medium","yet-another-stars-rating"),h=l("Large","yet-another-stars-rating"),v=l("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),b=l("Remember: only the post author can rate here.","yet-another-stars-rating"),R=l("This is the star set where your users will be able to vote","yet-another-stars-rating"),E=l('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=l('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");o("yet-another-stars-rating/yasr-overall-rating",{title:l("[DEPRECATED]Yasr: Overall Rating","yet-another-stars-rating"),description:E,icon:"star-half",keywords:[l("rating","yet-another-stars-rating"),l("author","yet-another-stars-rating"),l("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 o,s=e.attributes,u=s.overallRatingMeta,R=s.size,E=s.postId,w=e.setAttributes,_=e.isSelected,k=u,S=null,P=null;"--"!==R&&(S=' size="'+R+'"'),o=/^\d+$/.test(E),"--"!==E&&!0===o&&(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)}(p,React.Component);var o,s,i,c,u=(i=p,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 p(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,p),(t=u.call(this,e)).yasrOverallRateThis=l("Rate this article / item","yet-another-stars-rating"),t}return o=p,(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:k,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(o.prototype,s),p}();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 C(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:T}))}function T(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||w({postId:t}),e.preventDefault()}}function x(e){return React.createElement(p,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,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(C,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(x,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",S,P,"]",_&&React.createElement(z,null)))},save:function(e){var t=e.attributes,a=t.size,r=t.postId,n="",l=r;return a&&(n+='size="'+a+'"'),r&&("--"===r&&(l=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+l+'"'),React.createElement("div",null,"[yasr_overall_rating ",n,"]")}}),o("yet-another-stars-rating/yasr-visitor-votes",{title:l("[DEPRECATED]Yasr: Visitor Votes","yet-another-stars-rating"),description:w,icon:"star-half",keywords:[l("rating","yet-another-stars-rating"),l("visitor","yet-another-stars-rating"),l("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,l=e.setAttributes,o=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");l({size:t.value}),e.preventDefault()}function w(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:_}))}function _(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||l({postId:t}),e.preventDefault()}}function k(e){return React.createElement(p,null,React.createElement(i,{title:"Settings"},React.createElement("h3",null,y),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(k,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",s,u,"]",o&&React.createElement(b,null)))},save:function(e){var t=e.attributes,a=t.size,r=t.postId,n="",l=r;return a&&(n+='size="'+a+'"'),r&&("--"===r&&(l=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+l+'"'),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})(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 l(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}function o(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})(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=p(e);if(t){var n=p(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return c(this,a)}}function c(e,a){return!a||"object"!==t(a)&&"function"!=typeof a?u(e):a}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var y=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){o(a,React.Component);var t=i(a);function a(e){var n;r(this,a),n=t.call(this,e);var l=!1;return"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(l=!0),n.state={postExcluded:l},n.yasrUpdatePostMetaAutoInsert=n.yasrUpdatePostMetaAutoInsert.bind(u(n)),n}return l(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(t){o(n,React.Component);var a=i(n);function n(e){var t;r(this,n),t=a.call(this,e);var l=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(l=!0),t.state={yasrAutoInsertEnabled:l},t}return l(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"},y("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,y('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:y("Yasr: Page Settings","yet-another-stars-rating"),render:E})})()})();
admin/js/src/guten/blocks/noStarsRankings.js CHANGED
@@ -1,4 +1,3 @@
1
- const { __ } = wp.i18n; // Import __() from wp.i18n
2
  const {registerBlockType} = wp.blocks; // Import from wp.blocks
3
  const {PanelBody} = wp.components;
4
  const {Fragment} = wp.element;
@@ -9,21 +8,6 @@ import {YasrNoSettingsPanel} from "./yasrGutenUtils";
9
  //Most active users
10
  registerBlockType(
11
  'yet-another-stars-rating/most-active-users', {
12
- apiVersion: 2,
13
- title: __('Yasr: Most Active Visitors', 'yet-another-stars-rating'),
14
- description: __('This ranking shows the most active users, displaying the login name if logged in or “Anonymous” if not.',
15
- 'yet-another-stars-rating'
16
- ),
17
- icon: 'star-half',
18
- category: 'yet-another-stars-rating',
19
- keywords: [
20
- __('ranking', 'yet-another-stars-rating'),
21
- __('highest', 'yet-another-stars-rating'),
22
- __('most', 'yet-another-stars-rating'),
23
- __('chart', 'yet-another-stars-rating'),
24
- __('visitors', 'yet-another-stars-rating')
25
- ],
26
-
27
  edit:
28
  function(props) {
29
  const blockProps = useBlockProps( {
@@ -81,25 +65,6 @@ registerBlockType(
81
  //Most Active reviewers
82
  registerBlockType(
83
  'yet-another-stars-rating/most-active-reviewers', {
84
- apiVersion: 2,
85
- title: __('Yasr: Most Active Authors', 'yet-another-stars-rating'),
86
- description: __('This ranking shows the most active reviewers on your site.',
87
- 'yet-another-stars-rating'
88
- ),
89
- icon: 'star-half',
90
- category: 'yet-another-stars-rating',
91
- keywords: [
92
- __('ranking', 'yet-another-stars-rating'),
93
- __('highest', 'yet-another-stars-rating'),
94
- __('most', 'yet-another-stars-rating'),
95
- __('chart', 'yet-another-stars-rating'),
96
- __('authors', 'yet-another-stars-rating')
97
- ],
98
- supports: {
99
- // Declare support for specific alignment options.
100
- align: ['left', 'center', 'right']
101
- },
102
-
103
  edit:
104
  function(props) {
105
  const blockProps = useBlockProps( {
 
1
  const {registerBlockType} = wp.blocks; // Import from wp.blocks
2
  const {PanelBody} = wp.components;
3
  const {Fragment} = wp.element;
8
  //Most active users
9
  registerBlockType(
10
  'yet-another-stars-rating/most-active-users', {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  edit:
12
  function(props) {
13
  const blockProps = useBlockProps( {
65
  //Most Active reviewers
66
  registerBlockType(
67
  'yet-another-stars-rating/most-active-reviewers', {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  edit:
69
  function(props) {
70
  const blockProps = useBlockProps( {
admin/js/src/guten/blocks/overallRating.js CHANGED
@@ -21,31 +21,6 @@ import {YasrPrintSelectSize, YasrBlocksPanel} from "./yasrGutenUtils";
21
 
22
  registerBlockType(
23
  'yet-another-stars-rating/overall-rating', {
24
- apiVersion: 2,
25
- title: __( 'Yasr: Overall Rating', 'yet-another-stars-rating' ),
26
- description: __('Insert the author rating', 'yet-another-stars-rating'),
27
- icon: 'star-half',
28
- category: 'yet-another-stars-rating',
29
- keywords: [
30
- __('rating', 'yet-another-stars-rating'),
31
- __('author', 'yet-another-stars-rating'),
32
- __('overall', 'yet-another-stars-rating')
33
- ],
34
- attributes: {
35
- size: {
36
- type: 'string',
37
- default: 'large'
38
- },
39
- postId: {
40
- type: 'string',
41
- default: wp.data.select("core/editor").getCurrentPostId()
42
- },
43
- },
44
- supports: {
45
- // Declare support for specific alignment options.
46
- align: ['left', 'center', 'right']
47
- },
48
-
49
  edit:
50
  function(props) {
51
  const blockProps = useBlockProps( {
21
 
22
  registerBlockType(
23
  'yet-another-stars-rating/overall-rating', {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  edit:
25
  function(props) {
26
  const blockProps = useBlockProps( {
admin/js/src/guten/blocks/rankings.js CHANGED
@@ -1,4 +1,3 @@
1
- const { __ } = wp.i18n; // Import __() from wp.i18n
2
  const {registerBlockType} = wp.blocks; // Import from wp.blocks
3
  const {PanelBody} = wp.components;
4
  const {Fragment} = wp.element;
@@ -8,24 +7,6 @@ import {YasrNoSettingsPanel} from "./yasrGutenUtils";
8
 
9
  registerBlockType(
10
  'yet-another-stars-rating/overall-rating-ranking', {
11
- apiVersion: 2,
12
- title: __('Yasr: Ranking by overall rating', 'yet-another-stars-rating'),
13
- description: __(
14
- 'This ranking shows the highest rated posts rated through the overall_rating shortcode.',
15
- 'yet-another-stars-rating'
16
- ),
17
- icon: 'star-half',
18
- category: 'yet-another-stars-rating',
19
- keywords: [
20
- __('ranking', 'yet-another-stars-rating'),
21
- __('highest', 'yet-another-stars-rating'),
22
- __('chart', 'yet-another-stars-rating')
23
- ],
24
- supports: {
25
- // Declare support for specific alignment options.
26
- align: ['left', 'center', 'right']
27
- },
28
-
29
  edit:
30
  function(props) {
31
  const blockProps = useBlockProps( {
@@ -83,24 +64,7 @@ registerBlockType(
83
 
84
  registerBlockType(
85
  'yet-another-stars-rating/visitor-votes-ranking', {
86
- apiVersion: 2,
87
- title: __('Yasr: Ranking by visitors votes', 'yet-another-stars-rating'),
88
- description: __(
89
- 'This ranking shows both the highest and most rated posts rated through the yasr_visitor_votes shortcode. ' +
90
- 'For an item to appear in this chart, it has to be rated at least twice. ',
91
- 'yet-another-stars-rating'
92
- ),
93
- icon: 'star-half',
94
- category: 'yet-another-stars-rating',
95
- keywords: [
96
- __('ranking', 'yet-another-stars-rating'),
97
- __('highest', 'yet-another-stars-rating'),
98
- __('most', 'yet-another-stars-rating'),
99
- __('chart', 'yet-another-stars-rating')
100
- ],
101
-
102
  edit:
103
-
104
  function(props) {
105
  const blockProps = useBlockProps( {
106
  className: 'yasr-vv-ranking-block',
 
1
  const {registerBlockType} = wp.blocks; // Import from wp.blocks
2
  const {PanelBody} = wp.components;
3
  const {Fragment} = wp.element;
7
 
8
  registerBlockType(
9
  'yet-another-stars-rating/overall-rating-ranking', {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  edit:
11
  function(props) {
12
  const blockProps = useBlockProps( {
64
 
65
  registerBlockType(
66
  'yet-another-stars-rating/visitor-votes-ranking', {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  edit:
 
68
  function(props) {
69
  const blockProps = useBlockProps( {
70
  className: 'yasr-vv-ranking-block',
admin/js/src/guten/blocks/visitorVotes.js CHANGED
@@ -7,32 +7,6 @@ const {useBlockProps} = wp.blockEditor;
7
 
8
  registerBlockType(
9
  'yet-another-stars-rating/visitor-votes', {
10
- apiVersion: 2,
11
- title: __( 'Yasr: Visitor Votes', 'yet-another-stars-rating' ),
12
- description: __('Insert the ability for your visitors to vote', 'yet-another-stars-rating'),
13
- icon: 'star-half',
14
- category: 'yet-another-stars-rating',
15
- keywords: [
16
- __('rating', 'yet-another-stars-rating'),
17
- __('visitor', 'yet-another-stars-rating'),
18
- __('votes', 'yet-another-stars-rating')
19
- ],
20
- attributes: {
21
- //name of the attribute
22
- size: {
23
- type: 'string',
24
- default: 'large'
25
- },
26
- postId: {
27
- type: 'string',
28
- default: wp.data.select("core/editor").getCurrentPostId()
29
- },
30
- },
31
- supports: {
32
- // Declare support for specific alignment options.
33
- align: ['left', 'center', 'right']
34
- },
35
-
36
  edit:
37
  function( props ) {
38
  const blockProps = useBlockProps( {
@@ -42,9 +16,8 @@ registerBlockType(
42
 
43
  let sizeAttribute = null;
44
  let postIdAttribute = null;
45
- let isNum;
46
 
47
- isNum = /^\d+$/.test(postId);
48
 
49
  if (size !== 'large') {
50
  sizeAttribute = ' size="' + size + '"';
@@ -82,13 +55,12 @@ registerBlockType(
82
  const { attributes: {size, postId} } = props;
83
 
84
  let yasrVVAttributes = '';
85
- let post_id = postId;
86
 
87
  if (size) {
88
  yasrVVAttributes += 'size="' +size+ '"';
89
  }
90
  if (postId) {
91
- yasrVVAttributes += ' postid="'+post_id+'"';
92
  }
93
 
94
  return (
7
 
8
  registerBlockType(
9
  'yet-another-stars-rating/visitor-votes', {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  edit:
11
  function( props ) {
12
  const blockProps = useBlockProps( {
16
 
17
  let sizeAttribute = null;
18
  let postIdAttribute = null;
 
19
 
20
+ let isNum = /^\d+$/.test(postId);
21
 
22
  if (size !== 'large') {
23
  sizeAttribute = ' size="' + size + '"';
55
  const { attributes: {size, postId} } = props;
56
 
57
  let yasrVVAttributes = '';
 
58
 
59
  if (size) {
60
  yasrVVAttributes += 'size="' +size+ '"';
61
  }
62
  if (postId) {
63
+ yasrVVAttributes += ' postid="'+postId+'"';
64
  }
65
 
66
  return (
admin/js/src/guten/blocks/yasrGutenUtils.js CHANGED
@@ -1,5 +1,5 @@
1
  //setting costants
2
- import {yasrSetRaterValue} from "../../../../../includes/js/src/yasr-front";
3
 
4
  const { __ } = wp.i18n; // Import __() from wp.i18n
5
  const {PanelBody} = wp.components;
@@ -39,12 +39,16 @@ function yasrSetStarsSize(setAttributes, event) {
39
  }
40
 
41
  export function YasrPrintInputId(props) {
 
 
 
 
42
  return (
43
  <div>
44
  <input
45
  type="text"
46
  size="4"
47
- defaultValue={props.postId}
48
  onKeyPress={(e) => yasrSetPostId(props.setAttributes, e)} />
49
  </div>
50
  );
1
  //setting costants
2
+ import {yasrSetRaterValue} from "../../../../../includes/js/src/modules/yasrSetRaterValue";
3
 
4
  const { __ } = wp.i18n; // Import __() from wp.i18n
5
  const {PanelBody} = wp.components;
39
  }
40
 
41
  export function YasrPrintInputId(props) {
42
+ let postId;
43
+ if(props.postId !== false) {
44
+ postId = props.postId;
45
+ }
46
  return (
47
  <div>
48
  <input
49
  type="text"
50
  size="4"
51
+ defaultValue={postId}
52
  onKeyPress={(e) => yasrSetPostId(props.setAttributes, e)} />
53
  </div>
54
  );
admin/js/src/yasr-settings-rankings.js CHANGED
@@ -1,4 +1,4 @@
1
- import {yasrDrawRankings} from "../../../includes/js/src/ranking";
2
  import {copyToClipboard} from "./yasr-admin-functions";
3
  const { __ } = wp.i18n; // Import __() from wp.i18n
4
 
1
+ import {yasrDrawRankings} from "../../../includes/js/src/shortcodes/ranking";
2
  import {copyToClipboard} from "./yasr-admin-functions";
3
  const { __ } = wp.i18n; // Import __() from wp.i18n
4
 
admin/js/yasr-settings.js CHANGED
@@ -1 +1 @@
1
- (()=>{var t;if(document.getElementsByClassName("nav-tab-active").length>0&&(t=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===t){var e=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===e&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===t&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===t){var r=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===r){var n=jQuery("#yasr-edit-form-number-elements").attr("value");n++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(n>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+n+' <input type="text" name="edit-multi-set-element-'+n+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),n++}))}else r>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===t&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===t&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";var t,e,a=new Uint8Array(16);function r(){if(!e&&!(e="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 e(a)}const n=/^(?:[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(t){return"string"==typeof t&&n.test(t)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(t,e,a){var n=(t=t||{}).random||(t.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var i=0;i<16;++i)e[a+i]=n[i];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(n)};for(var d=wp.i18n.__,c=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],u=0;u<c.length;u++)y(c[u]);function y(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;g(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=v(n),s=v(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),y=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,h="yasr-vv-bottom-container-"+l,f="yasr-vv-loader-"+l,_=document.getElementById(m),b=document.getElementById(g),E=document.getElementById(h),k=document.getElementById(f);if("yes"===yasrCommonData.ajaxEnabled){null!==k&&(k.innerHTML=yasrCommonData.loaderHtml);var w={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,w).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),p(c,r,o,e,i,0,u,y,_,b,k,E),!0!==n&&(null!==_&&(_.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=r),!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,l){console.info(d("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),p(c,r,o,s,i,0,u,y,_,b,k,E),!0!==n&&(E.style.display="")}))}else p(c,r,o,s,i,0,u,y,_,b,k,E)}}(e)}(e),"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(m(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=v(o);g(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var 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 n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function m(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+" "+d("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';for(var i=d("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=d("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}function g(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 p(t,e,a,r,n,s,o,i,l,d,c,u){e=parseFloat(e),r=v(r);var y=document.getElementById(n);null!==c&&(c.innerHTML=""),g(t,n,y,1,r,e,(function(t,e){null!==c&&(c.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(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!==l&&(l.innerHTML=e),null!==d&&(d.innerHTML=a)):r=t.text,null!==u&&(u.innerHTML=r,u.style.display=""),null!==c&&(c.innerHTML="")})),e()}))}function v(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}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})(t)}function f(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 _(t,e){return(_=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t,e){return!e||"object"!==h(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function E(t){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}T();var k=wp.i18n.__,w=wp.element.render;function I(t){var e="yasr-ranking-element-"+l(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return g(a,e,!1,.1,!0,t.rating)}})}function B(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 j(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===t&&(t=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),t.innerHTML=e;var a=t.textContent;return t.innerHTML="",a}(e.post.title)))}function R(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(B,{post:t.post,tableId:t.tableId,text:a}),React.createElement(I,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(I,{rating:t.post.rating,tableId:t.tableId}),React.createElement(B,{post:t.post,tableId:t.tableId,text:a}))}function x(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(j,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(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(x,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var L=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&&_(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=E(r);if(n){var a=E(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return b(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,"Post"),React.createElement("th",null,k("Order By","yet-another-stars-rating-pro"),":  ",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(C,{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",d=o,c=i,u=new URLSearchParams(r);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:d,source:a}),React.createElement(C,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:c,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())}}])&&f(e.prototype,a),o}();function T(){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);w(React.createElement(L,{source:r,tableId:a,params:n,nonce:s}),o)}}tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var Q,H=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(Q=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===Q){var S,M=function(t){var e=K.value,a=document.getElementById("yasr-builder-shortcode").textContent,r=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];r=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",r),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+a).then((function(t){return!0===t.ok?t.json():(console.info(H("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,V.childNodes.length>0?V.replaceChild(e,V.childNodes[0]):V.appendChild(e)}})).then((function(t){r.forEach((function(t){e===t&&T()}))}))},A=function(t,e,a,r,n,s,o,i,l){t.style.display="",e.style.display="",s.style.display="",l.style.display="",a.style.display="none",r.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},N=function(t,e,a,r,n,s,o,i,l){a.style.display="",r.style.display="",e.style.display="",s.style.display="",l.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},O=function(t,e,a,r,n,s,o,i,l){n.style.display="",l.style.display="none",t.style.display="none",a.style.display="none",r.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},P=function(t,e,a,r,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(W.className="",W.classList.add("yasr-settings-row-24"),a.style.display="",r.style.display="",t.style.display="none"):(a.style.display="none",r.style.display="none",t.style.display=""),s.style.display="",e.style.display="",d.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},D=".yasr-builder-elements-parents",F=".yasr-builder-elements-childs";jQuery(D).prop("disabled",!0),jQuery(F).prop("disabled",!0),jQuery(D).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",D,F);var J=[],z={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};S=z.name,document.getElementById("yasr-builder-shortcode").textContent="["+S+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+S+"]");var U=document.getElementById("yasr-builder-button-preview"),q=document.getElementById("yasr-builder-copy-shortcode"),V=document.getElementById("yasr-builder-preview"),K=document.getElementById("yasr-ranking-source"),Y=document.getElementById("yasr-ranking-multiset-select"),G=document.getElementById("yasr-builder-datepicker-start"),$=document.getElementById("yasr-builder-datepicker-end"),W=document.getElementById("yasr-builder-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),at=document.getElementById("builder-username-options"),rt=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=document.getElementById("yasr-builder-datepicker"),it=K.value,lt=!1;G.value="",$.value="","yasr_ov_ranking"===it?A(et,tt,X,Z,at,rt,nt,st,ot):"yasr_most_active_users"===it||"yasr_top_reviewers"===it?O(et,tt,X,Z,at,rt,nt,st,ot):"yasr_multi_set_ranking"===it?P(et,tt,X,Z,at,rt,nt,st,!1,ot):"yasr_visitor_multi_set_ranking"===it?P(et,tt,X,Z,at,rt,nt,st,!0,ot):N(et,tt,X,Z,at,rt,nt,st,ot),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),V.innerHTML="",G.value="",$.value="",z={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?A(et,tt,X,Z,at,rt,nt,st,ot):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?O(et,tt,X,Z,at,rt,nt,st,ot):"yasr_multi_set_ranking"===t.target.value?(P(et,tt,X,Z,at,rt,nt,st,!1,ot),z.setid=" setid="+Y[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(P(et,tt,X,Z,at,rt,nt,st,!0,ot),z.setid=" setid="+Y[0].value):N(et,tt,X,Z,at,rt,nt,st,ot),z.name=t.target.value,S=z.name+z.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(z.setid=" setid="+t.target.value),J=wp.hooks.applyFilters("yasrBuilderFilterShortcode",z);for(var e=2;z.length;e++)J.hasOwnProperty(z[e])&&(z[e]=J[e]);S=z.name+z.setid+z.rows+z.view+z.minvotesmost+z.minvoteshg+z.size+z.txtPosition+z.txt+z.display+z.start_date+z.end_date+z.category+z.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+S+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+S+"]"),!0===lt&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&M()})),q.onclick=function(t){var e,a;e=document.getElementById(t.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},U.onclick=function(t){M(),lt=!0}}})();
1
+ (()=>{var e;if(document.getElementsByClassName("nav-tab-active").length>0&&(e=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===e){var t=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===t&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===e&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===e){var n=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===n){var r=jQuery("#yasr-edit-form-number-elements").attr("value");r++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(r>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+r+' <input type="text" name="edit-multi-set-element-'+r+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),r++}))}else n>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"migration_tools"===e&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===e&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";var e,t,a=new Uint8Array(16);function n(){if(!t&&!(t="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 t(a)}const r=/^(?:[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&&r.test(e)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(e,t,a){var r=(e=e||{}).random||(e.rng||n)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){a=a||0;for(var i=0;i<16;++i)t[a+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function d(e){return(d="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)}function c(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var p=wp.i18n.__,g=wp.element.render;function h(e){var t="yasr-ranking-element-"+l(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return function(e,t){var a,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=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:n,readOnly:r,rating:s,rateCallback:o})}(a,t,!1,.1,!0,e.rating)}})}function f(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",e.post.number_of_votes,"  ",p("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function v(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===e&&(e=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),e.innerHTML=t;var a=e.textContent;return e.innerHTML="",a}(t.post.title)))}function _(e){var t="after",a=p("Rating:","yet-another-stars-rating"),n=new URLSearchParams(e.rankingParams);return null!==n.get("text_position")&&(t=n.get("text_position")),null!==n.get("custom_txt")&&(a=n.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(f,{post:e.post,tableId:e.tableId,text:a}),React.createElement(h,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(h,{rating:e.post.rating,tableId:e.tableId}),React.createElement(f,{post:e.post,tableId:e.tableId,text:a}))}function b(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(v,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function E(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var n="yasr-rankings-td-colored";return"author_ranking"===e.source&&(n="yasr-rankings-td-white"),a%2==0&&(n="yasr-rankings-td-white","author_ranking"===e.source&&(n="yasr-rankings-td-colored")),React.createElement(b,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:n})})))}var k=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&&u(e,t)}(o,React.Component);var t,a,n,r,s=(n=o,r=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=y(n);if(r){var a=y(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return m(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,(a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(p("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:t});else if(this.state.source){var n=this.returnRestUrl();Promise.all(n.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info(p("Ajax Call Failed. Getting data from source")),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(p(e))}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(p(t)),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:p("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,n="&nonce_rankings="+this.state.nonce,r="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);null!==s.get("order_by")&&(r+="order_by="+s.get("order_by")),null!==s.get("limit")&&(r+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(r+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(r+="&end_date="+s.get("end_date")),null!==s.get("ctg")?r+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(r+="&cpt="+s.get("cpt")),""!==r&&(r="&"+(r=r.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(r+="&setid="+s.get("setid"))}else r="";if("author_ranking"===a||"author_multi"===a)e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+r+n];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);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]"))}e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+r+o+n,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+r+i+n]}return e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:n},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:r},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("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,"Post"),React.createElement("th",null,p("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.target.id,a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),t===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var e=this.state,t=e.data,a=e.source,n=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:n,show:"table-row-group",source:a});var r=t.most,s=t.highest,o="table-row-group",i="none",l="most",d=o,c=i,u=new URLSearchParams(n);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:r,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:n,show:d,source:a}),React.createElement(E,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:n,show:c,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&c(t.prototype,a),o}();function I(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,n=JSON.parse(e.item(t).dataset.rankingSource),r=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);g(React.createElement(k,{source:n,tableId:a,params:r,nonce:s}),o)}}I(),tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var w,B=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(w=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===w){var R,j=function(e){var t=D.value,a=document.getElementById("yasr-builder-shortcode").textContent,n=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];n=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",n),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+t+"&full_shortcode="+a).then((function(e){return!0===e.ok?e.json():(console.info(B("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(e){console.info(e)})).then((function(e){if("KO"!==e){var t=document.createElement("div");t.innerHTML=e,M.childNodes.length>0?M.replaceChild(t,M.childNodes[0]):M.appendChild(t)}})).then((function(e){n.forEach((function(e){t===e&&I()}))}))},x=function(e,t,a,n,r,s,o,i,l){e.style.display="",t.style.display="",s.style.display="",l.style.display="",a.style.display="none",n.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},C=function(e,t,a,n,r,s,o,i,l){a.style.display="",n.style.display="",t.style.display="",s.style.display="",l.style.display="",e.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},Q=function(e,t,a,n,r,s,o,i,l){r.style.display="",l.style.display="none",e.style.display="none",a.style.display="none",n.style.display="none",t.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},L=function(e,t,a,n,r,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(F.className="",F.classList.add("yasr-settings-row-24"),a.style.display="",n.style.display="",e.style.display="none"):(a.style.display="none",n.style.display="none",e.style.display=""),s.style.display="",t.style.display="",d.style.display="",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},T=".yasr-builder-elements-parents",S=".yasr-builder-elements-childs";jQuery(T).prop("disabled",!0),jQuery(S).prop("disabled",!0),jQuery(T).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",T,S);var P=[],H={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};R=H.name,document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]");var O=document.getElementById("yasr-builder-button-preview"),N=document.getElementById("yasr-builder-copy-shortcode"),M=document.getElementById("yasr-builder-preview"),D=document.getElementById("yasr-ranking-source"),A=document.getElementById("yasr-ranking-multiset-select"),U=document.getElementById("yasr-builder-datepicker-start"),q=document.getElementById("yasr-builder-datepicker-end"),F=document.getElementById("yasr-builder-params-container"),z=document.getElementById("builder-vv-default-view"),J=document.getElementById("builder-vv-required-votes"),V=document.getElementById("builder-stars-size"),K=document.getElementById("builder-overall-text"),Y=document.getElementById("builder-username-options"),G=document.getElementById("builder-category"),$=document.getElementById("builder-cpt"),W=document.getElementById("yasr-ranking-multiset"),X=document.getElementById("yasr-builder-datepicker"),Z=D.value,ee=!1;U.value="",q.value="","yasr_ov_ranking"===Z?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===Z||"yasr_top_reviewers"===Z?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===Z?L(K,V,z,J,Y,G,$,W,!1,X):"yasr_visitor_multi_set_ranking"===Z?L(K,V,z,J,Y,G,$,W,!0,X):C(K,V,z,J,Y,G,$,W,X),document.addEventListener("change",(function(e){if("yasr-ranking-source"===e.target.id)F.className="",F.classList.add("yasr-settings-row-33"),M.innerHTML="",U.value="",q.value="",H={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===e.target.value?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===e.target.value||"yasr_top_reviewers"===e.target.value?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===e.target.value?(L(K,V,z,J,Y,G,$,W,!1,X),H.setid=" setid="+A[0].value):"yasr_visitor_multi_set_ranking"===e.target.value?(L(K,V,z,J,Y,G,$,W,!0,X),H.setid=" setid="+A[0].value):C(K,V,z,J,Y,G,$,W,X),H.name=e.target.value,R=H.name+H.setid;else{"yasr-ranking-multiset-select"===e.target.id&&(H.setid=" setid="+e.target.value),P=wp.hooks.applyFilters("yasrBuilderFilterShortcode",H);for(var t=2;H.length;t++)P.hasOwnProperty(H[t])&&(H[t]=P[t]);R=H.name+H.setid+H.rows+H.view+H.minvotesmost+H.minvoteshg+H.size+H.txtPosition+H.txt+H.display+H.start_date+H.end_date+H.category+H.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]"),!0===ee&&"yasr-ranking-source"!==e.target.id&&"yasr-builder-category-radio"!==e.target.name&&j()})),N.onclick=function(e){var t,a;t=document.getElementById(e.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=t,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},O.onclick=function(e){j(),ee=!0}}})();
admin/yasr-admin-actions-ajax.php CHANGED
@@ -22,17 +22,19 @@ if ( ! defined( 'ABSPATH' ) ) {
22
  } // Exit if accessed directly
23
 
24
  //ajax action
 
25
  add_action('wp_ajax_yasr_change_log_page', 'yasr_widget_log_dashboard_callback');
26
  function yasr_widget_log_dashboard_callback() {
27
- $log_widget = new YasrLogDashboardWidget('admin');
28
  $log_widget->adminWidget();
29
  } //End callback function
30
 
31
 
32
  //ajax action
 
33
  add_action('wp_ajax_yasr_change_user_log_page', 'yasr_users_dashboard_widget_callback');
34
  function yasr_users_dashboard_widget_callback() {
35
- $log_widget = new YasrLogDashboardWidget('user');
36
  $log_widget->userWidget();
37
  } //End callback function
38
 
22
  } // Exit if accessed directly
23
 
24
  //ajax action
25
+ //This function is also hooked into yasr-admin-actions
26
  add_action('wp_ajax_yasr_change_log_page', 'yasr_widget_log_dashboard_callback');
27
  function yasr_widget_log_dashboard_callback() {
28
+ $log_widget = new YasrLogDashboardWidget();
29
  $log_widget->adminWidget();
30
  } //End callback function
31
 
32
 
33
  //ajax action
34
+ //This function is also hooked into yasr-admin-actions
35
  add_action('wp_ajax_yasr_change_user_log_page', 'yasr_users_dashboard_widget_callback');
36
  function yasr_users_dashboard_widget_callback() {
37
+ $log_widget = new YasrLogDashboardWidget();
38
  $log_widget->userWidget();
39
  } //End callback function
40
 
admin/yasr-admin-functions.php CHANGED
@@ -54,19 +54,8 @@ add_action('admin_enqueue_scripts', 'yasr_add_admin_scripts');
54
 
55
  //$hook contain the current page in the admin side
56
  function yasr_add_admin_scripts($hook) {
57
-
58
  global $yasr_settings_page;
59
 
60
- if ($hook === 'post.php' || $hook === 'post-new.php') {
61
- wp_enqueue_script(
62
- 'yasr_classic_editor_functions',
63
- YASR_JS_DIR_ADMIN . 'yasr-editor-screen.js',
64
- array('jquery', 'rater'),
65
- YASR_VERSION_NUM,
66
- true
67
- );
68
- }
69
-
70
  /*if ($hook === 'yet-another-stars-rating_page_yasr_pricing_page'
71
  || $hook === 'yet-another-stars-rating_page_yasr_settings_page-pricing') {
72
  wp_enqueue_style(
@@ -97,6 +86,8 @@ function yasr_add_admin_scripts($hook) {
97
  || $hook === 'yet-another-stars-rating_page_yasr_settings_page-pricing'
98
  ) {
99
 
 
 
100
  do_action('yasr_add_admin_scripts_begin', $hook);
101
 
102
  wp_enqueue_style(
@@ -106,6 +97,14 @@ function yasr_add_admin_scripts($hook) {
106
  YASR_VERSION_NUM
107
  );
108
 
 
 
 
 
 
 
 
 
109
  wp_enqueue_script(
110
  'yasradmin',
111
  YASR_JS_DIR_ADMIN . 'yasr-admin.js',
@@ -118,6 +117,16 @@ function yasr_add_admin_scripts($hook) {
118
 
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
121
  //add this only in yasr setting page (admin.php?page=yasr_settings_page)
122
  if ($hook === $yasr_settings_page) {
123
  $cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/css'));
54
 
55
  //$hook contain the current page in the admin side
56
  function yasr_add_admin_scripts($hook) {
 
57
  global $yasr_settings_page;
58
 
 
 
 
 
 
 
 
 
 
 
59
  /*if ($hook === 'yet-another-stars-rating_page_yasr_pricing_page'
60
  || $hook === 'yet-another-stars-rating_page_yasr_settings_page-pricing') {
61
  wp_enqueue_style(
86
  || $hook === 'yet-another-stars-rating_page_yasr_settings_page-pricing'
87
  ) {
88
 
89
+ yasr_enqueue_includes_js_scripts();
90
+
91
  do_action('yasr_add_admin_scripts_begin', $hook);
92
 
93
  wp_enqueue_style(
97
  YASR_VERSION_NUM
98
  );
99
 
100
+ wp_enqueue_script(
101
+ 'tippy',
102
+ YASR_JS_DIR_INCLUDES . 'tippy.all.min.js',
103
+ '',
104
+ '3.6.0',
105
+ true
106
+ );
107
+
108
  wp_enqueue_script(
109
  'yasradmin',
110
  YASR_JS_DIR_ADMIN . 'yasr-admin.js',
117
 
118
  }
119
 
120
+ if ($hook === 'post.php' || $hook === 'post-new.php') {
121
+ wp_enqueue_script(
122
+ 'yasr_classic_editor_functions',
123
+ YASR_JS_DIR_ADMIN . 'yasr-editor-screen.js',
124
+ array('jquery', 'rater'),
125
+ YASR_VERSION_NUM,
126
+ true
127
+ );
128
+ }
129
+
130
  //add this only in yasr setting page (admin.php?page=yasr_settings_page)
131
  if ($hook === $yasr_settings_page) {
132
  $cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/css'));
admin/yasr-admin-init.php CHANGED
@@ -31,7 +31,7 @@ define('YASR_JS_DIR_ADMIN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/j
31
 
32
  //define gutenberg paths
33
  define('YASR_JS_GUTEN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/js/guten/');
34
- define('YASR_JS_GUTEN_BLOCKS', YASR_JS_GUTEN . '/blocks/');
35
 
36
  //CSS directory absolute URL
37
  define('YASR_CSS_DIR_ADMIN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/css/');
31
 
32
  //define gutenberg paths
33
  define('YASR_JS_GUTEN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/js/guten/');
34
+ define('YASR_JS_GUTEN_BLOCKS', YASR_JS_GUTEN . 'blocks/');
35
 
36
  //CSS directory absolute URL
37
  define('YASR_CSS_DIR_ADMIN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/css/');
includes/classes/YasrLogDashboardWidget.php ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 2 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>
18
+ */
19
+
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
+ } // Exit if accessed directly
23
+
24
+ /**
25
+ * Class YasrLogDashboardWidget
26
+ *
27
+ * Class to print the Dashboard widgets
28
+ *
29
+ */
30
+ class YasrLogDashboardWidget {
31
+ private $limit = 8;
32
+ private $offset = 0;
33
+ private $page_num;
34
+ private $num_of_pages;
35
+ private $n_rows;
36
+ private $log_query;
37
+ private $is_ajax = false;
38
+ private $button_class;
39
+ private $span_loader_id;
40
+ private $user_widget = false;
41
+ private $container_id;
42
+ private $span_total_pages;
43
+
44
+ public function __construct() {
45
+ //If $_POST isset it's in ajax response
46
+ if (isset($_POST['pagenum'])) {
47
+ $this->page_num = (int)$_POST['pagenum'];
48
+ $this->num_of_pages = (int)$_POST['totalpages'];
49
+ $this->offset = (int)($this->page_num - 1) * $this->limit;
50
+ $this->is_ajax = true;
51
+ } else {
52
+ $this->page_num = 1;
53
+ }
54
+ }
55
+
56
+ /**
57
+ * This function will set the values for print the admin widget logs
58
+ *
59
+ * $this->user_widget
60
+ * $this->n_rows
61
+ * $this->log_query
62
+ * $this->container_id
63
+ * $this->span_total_pages
64
+ * $this->button_class
65
+ * $this->span_loader_id
66
+ *
67
+ */
68
+ public function adminWidget() {
69
+ if (!current_user_can('manage_options')) {
70
+ return;
71
+ }
72
+ global $wpdb;
73
+
74
+ //query for admin widget
75
+ $this->n_rows = $wpdb->get_var(
76
+ "SELECT COUNT(*) FROM "
77
+ . YASR_LOG_TABLE
78
+ );
79
+
80
+ $this->log_query = "SELECT * FROM "
81
+ . YASR_LOG_TABLE .
82
+ " ORDER BY date DESC LIMIT %d, %d ";
83
+
84
+ $this->container_id = 'yasr-log-container';
85
+ $this->span_total_pages = 'yasr-log-total-pages';
86
+ $this->button_class = 'yasr-log-pagenum';
87
+ $this->span_loader_id = 'yasr-loader-log-metabox';
88
+
89
+ echo $this->returnWidget();
90
+
91
+ $this->die_if_is_ajax();
92
+ }
93
+
94
+ /**
95
+ * This function will set the values for print the user widget logs
96
+ *
97
+ * $this->user_widget
98
+ * $this->n_rows
99
+ * $this->log_query
100
+ * $this->container_id
101
+ * $this->span_total_pages
102
+ * $this->button_class
103
+ * $this->span_loader_id
104
+ *
105
+ * @param $shortcode
106
+ * @return string|void
107
+ */
108
+ public function userWidget($shortcode=false) {
109
+ $user_id = get_current_user_id();
110
+
111
+ if($user_id === 0) {
112
+ return '<p>'.__('You must login to see this widget.', 'yet-another-stars-rating').'</p>';
113
+ }
114
+
115
+ //set true to user widget
116
+ $this->user_widget = true;
117
+
118
+ global $wpdb;
119
+
120
+ $this->n_rows = $wpdb->get_var(
121
+ $wpdb->prepare(
122
+ "SELECT COUNT(*) FROM "
123
+ . YASR_LOG_TABLE . " WHERE user_id = %d ",
124
+ $user_id));
125
+
126
+ $this->log_query = "SELECT * FROM "
127
+ . YASR_LOG_TABLE .
128
+ " WHERE user_id = $user_id
129
+ ORDER BY date
130
+ DESC LIMIT %d, %d ";
131
+
132
+ $this->container_id = 'yasr-user-log-container';
133
+ $this->span_total_pages = 'yasr-user-log-total-pages';
134
+ $this->button_class = 'yasr-user-log-page-num';
135
+ $this->span_loader_id = 'yasr-loader-user-log-metabox';
136
+
137
+ if($shortcode === true) {
138
+ return $this->returnWidget();
139
+ }
140
+
141
+ echo $this->returnWidget();
142
+
143
+ $this->die_if_is_ajax();
144
+
145
+ }
146
+
147
+ /**
148
+ * Callback function to make user widget works as shortcode
149
+ * If it is not under ajax call, shortcode must be returned.
150
+ * Otherwise, printed
151
+ *
152
+ * @author Dario Curvino <@dudo>
153
+ * @since 2.8.5
154
+ * @return string|void
155
+ */
156
+ public function userWidgetShortcode () {
157
+ wp_enqueue_script(
158
+ 'yasr-log-users-frontend',
159
+ YASR_JS_DIR_INCLUDES . 'shortcodes/yasr-log-users-fronted.js',
160
+ array('jquery'),
161
+ YASR_VERSION_NUM,
162
+ true
163
+ );
164
+
165
+ if($this->is_ajax === false) {
166
+ return $this->userWidget(true);
167
+ }
168
+ echo $this->userWidget(true);
169
+ $this->die_if_is_ajax();
170
+ }
171
+
172
+ /**
173
+ * Print the widget
174
+ * @return string|void
175
+ */
176
+ private function returnWidget() {
177
+ global $wpdb;
178
+
179
+ if($this->n_rows > 0) {
180
+ $this->num_of_pages = ceil($this->n_rows / $this->limit);
181
+ } else {
182
+ $this->num_of_pages = 1;
183
+ }
184
+
185
+ //do the query
186
+ $log_result = $wpdb->get_results(
187
+ $wpdb->prepare(
188
+ $this->log_query,
189
+ $this->offset, $this->limit)
190
+ );
191
+
192
+ if (!$log_result) {
193
+ return __("No Recent votes yet", 'yet-another-stars-rating');
194
+ }
195
+
196
+ $html_to_return = "<div class='yasr-log-container' id='$this->container_id'>";
197
+
198
+ foreach ($log_result as $column) {
199
+ $user = get_user_by('id', $column->user_id); //Get info user from user id
200
+
201
+ //If user === false means that the vote are anonymous
202
+ if ($user === false) {
203
+ $user = new stdClass;
204
+ $user->user_login = __('anonymous', 'yet-another-stars-rating');
205
+ }
206
+
207
+ $avatar = get_avatar($column->user_id, '32'); //Get avatar from user id
208
+
209
+ $post_title = wp_strip_all_tags(get_the_title($column->post_id)); //Get post title from post id
210
+ $link = get_permalink($column->post_id); //Get post link from post id
211
+
212
+ if ($this->user_widget !== true) {
213
+ $yasr_log_vote_text = ' ' . sprintf(
214
+ __('Vote %d from %s on', 'yet-another-stars-rating'),
215
+ $column->vote,
216
+ '<strong style="color: blue">' . $user->user_login . '</strong>'
217
+ );
218
+ } else {
219
+ $yasr_log_vote_text = ' ' . sprintf(
220
+ __('You rated %s on', 'yet-another-stars-rating'),
221
+ '<strong style="color: blue">' . $column->vote . '</strong>'
222
+ );
223
+ }
224
+
225
+ //Default values (for admin widget)
226
+ $ip_span = ''; //default value
227
+
228
+ //Set value depending if we're on user or admin widget
229
+ if ($this->user_widget !== true) {
230
+ if (YASR_ENABLE_IP === 'yes') {
231
+ $ip_span = '<span class="yasr-log-ip">' . __("Ip address", 'yet-another-stars-rating') . ':
232
+ <span style="color:blue">' . $column->ip . '</span>
233
+ </span>';
234
+ }
235
+ } else {
236
+ $ip_span = '';
237
+ }
238
+
239
+ $rows_content = '<div class="yasr-log-div-child">
240
+ <div class="yasr-log-image">'
241
+ .$avatar.
242
+ '</div>
243
+ <div class="yasr-log-child-head">
244
+ <span id="yasr-log-vote">'.$yasr_log_vote_text.'</span>
245
+ <span id="yasr-log-post"><a href="'. $link .'">'.$post_title.'</a></span>
246
+ </div>
247
+ <div class="yasr-log-ip-date">'
248
+ .$ip_span.
249
+ '<span class="yasr-log-date">'.$column->date.'</span>
250
+ </div>
251
+ </div>';
252
+
253
+ $html_to_return .= $rows_content;
254
+
255
+ } //End foreach
256
+
257
+ $html_to_return .= "<div id='yasr-log-page-navigation'>";
258
+
259
+ //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
260
+ //the "last" button could not exists
261
+ $html_to_return .= "<span id='$this->span_total_pages' data-yasr-log-total-pages='$this->num_of_pages'>";
262
+ $html_to_return .= __("Pages", 'yet-another-stars-rating') . ": ($this->num_of_pages) &nbsp;&nbsp;&nbsp;";
263
+ $html_to_return .= '</span>';
264
+
265
+ $html_to_return = $this->pagination($html_to_return);
266
+
267
+ $html_to_return .= '</div>'; //End yasr-log-page-navigation
268
+ $html_to_return .= '</div>'; //End Yasr Log Container
269
+
270
+ return $html_to_return; // End else if !$log result
271
+
272
+ }
273
+
274
+ /**
275
+ * This function will print the row with pagination
276
+ */
277
+ private function pagination($html_to_return) {
278
+
279
+ if ($this->num_of_pages <= 3) {
280
+ for ($i = 1; $i <= $this->num_of_pages; $i++) {
281
+ if ($i === $this->page_num) {
282
+ $html_to_return .= "<button class='button-primary' value='$i'>$i</button>&nbsp;&nbsp;";
283
+ } else {
284
+ $html_to_return .= "<button class=$this->button_class value='$i'>$i</button>&nbsp;&nbsp;";
285
+ }
286
+ }
287
+ $html_to_return .= "<span id='yasr-loader-log-metabox' style='display:none;'>&nbsp;
288
+ <img alt='loader' src='" . YASR_IMG_DIR . "/loader.gif' >
289
+ </span>";
290
+ }
291
+ else {
292
+ $start_for = $this->page_num - 1;
293
+
294
+ if ($start_for <= 0) {
295
+ $start_for = 1;
296
+ }
297
+
298
+ $end_for = $this->page_num + 1;
299
+
300
+ if ($end_for >= $this->num_of_pages) {
301
+ $end_for = $this->num_of_pages;
302
+ }
303
+
304
+ if ($this->page_num >= 3) {
305
+ $html_to_return .= "<button class=$this->button_class value='1'>
306
+ &laquo; First </button>&nbsp;&nbsp;...&nbsp;&nbsp;";
307
+ }
308
+
309
+ for ($i = $start_for; $i <= $end_for; $i++) {
310
+ if ($i === $this->page_num) {
311
+ $html_to_return .= "<button class='button-primary' value='$i'>$i</button>&nbsp;&nbsp;";
312
+ } else {
313
+ $html_to_return .= "<button class=$this->button_class value='$i'>$i</button>&nbsp;&nbsp;";
314
+ }
315
+ }
316
+
317
+ $num_of_page_less_one = $this->num_of_pages - 1;
318
+
319
+ if ($this->page_num != $this->num_of_pages && $this->page_num != $num_of_page_less_one) {
320
+ $html_to_return .= "...&nbsp;&nbsp;
321
+ <button class=$this->button_class
322
+ value='$this->num_of_pages'>
323
+ Last &raquo;</button>
324
+ &nbsp;&nbsp;";
325
+ }
326
+
327
+ $html_to_return .= "<span id='$this->span_loader_id' style='display:none;' >&nbsp;
328
+ <img alt='loader' src='" . YASR_IMG_DIR . "/loader.gif' >
329
+ </span>";
330
+
331
+ }
332
+
333
+ return $html_to_return;
334
+
335
+ }
336
+
337
+ /**
338
+ * @author Dario Curvino <@dudo>
339
+ * @since 2.8.5
340
+ * If is_ajax === true, call die()
341
+ */
342
+ private function die_if_is_ajax() {
343
+ if ($this->is_ajax === true) {
344
+ die();
345
+ }
346
+ }
347
+ }
includes/css/yasr.css CHANGED
@@ -199,4 +199,63 @@ yasr_pro_comment_reviews_stats shortcode too***/
199
  .yasr-w3-border-left{border-left:1px solid #ccc!important}.yasr-w3-border-right{border-right:1px solid #ccc!important}
200
  .yasr-w3-amber,.yasr-w3-hover-amber:hover{color:#000!important;background: linear-gradient(to bottom,#ffda44,#f1cb32);
201
  background-color: #ffce00;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  }
199
  .yasr-w3-border-left{border-left:1px solid #ccc!important}.yasr-w3-border-right{border-right:1px solid #ccc!important}
200
  .yasr-w3-amber,.yasr-w3-hover-amber:hover{color:#000!important;background: linear-gradient(to bottom,#ffda44,#f1cb32);
201
  background-color: #ffce00;
202
+ }
203
+
204
+
205
+
206
+ /* Logs widget */
207
+
208
+ .yasr-log-container {
209
+ width: 98%;
210
+ }
211
+
212
+ .yasr-log-div-child {
213
+ padding-top: 5px;
214
+ border-bottom: 1px solid #BBD8E7;
215
+ padding-bottom: 20px;
216
+ }
217
+
218
+ .yasr-log-image {
219
+ list-style-type: none;
220
+ display: inline-block;
221
+ float: left;
222
+ }
223
+
224
+ .yasr-log-child-head {
225
+ padding-left: 37px;
226
+ }
227
+
228
+ #yasr-log-vote {
229
+ color: red;
230
+ }
231
+
232
+ #yasr-log-vote-users {
233
+ color: green;
234
+ }
235
+
236
+ .yasr-log-post {
237
+ color: #2683AE;
238
+ }
239
+
240
+ .yasr-log-ip-date {
241
+ padding-top: 5px;
242
+ }
243
+
244
+ .yasr-log-ip {
245
+ float: left;
246
+ padding-left: 5px;
247
+ }
248
+
249
+ .yasr-log-date {
250
+ float: right;
251
+ }
252
+
253
+ #yasr-log-next-rows {
254
+ padding-top: 15px;
255
+ text-align: right;
256
+ }
257
+
258
+ #yasr-log-page-navigation {
259
+ padding-top: 7px;
260
+ text-align: center;
261
  }
includes/js/rater-js.min.js CHANGED
@@ -1,2 +1 @@
1
- /*! Based on rater-js. [c] 2018 by Fredrik Olsson. MIT License */
2
- function raterJs(e){let t=!0;if(void 0===e.element||null===e.element)return void console.info("missing rating element");if(null!==e.element&&e.element.classList.contains("yasr-star-rating"))return;if(void 0!==e.showToolTip&&(t=!!e.showToolTip),void 0!==e.step&&(e.step<=0||e.step>1))throw new Error("step must be a number between 0 and 1");let i,a,r=5,n=e.starSize||16,s=e.step||1,l=e.onHover,o=e.onLeave,d=JSON.parse(yasrCommonData.isRtl),u=e.element;u.classList.add("yasr-star-rating");let v=document.createElement("div");v.classList.add("yasr-star-value"),v.style.backgroundSize=n+"px",u.appendChild(v),u.style.width=n*r+"px",u.style.height=n+"px",u.style.backgroundSize=n+"px";let c,f,m,y=e.rateCallback,g=!!e.readOnly,p=!1,b=e.isBusyText;if(c=void 0!==e.disableText?e.disableText:"{rating}/{maxRating}",g||(u.style.cursor="pointer"),m=void 0!==e.ratingText?e.ratingText:"{rating}/{maxRating}",e.rating)E(e.rating);else{var h=u.dataset.rating;h&&E(+h)}function x(e){if(!0===g||!0===p)return;let a;if(!0===d){let t=this.getBoundingClientRect(),i=e.pageX-t.left,r=u.offsetWidth;a=(r-i)/(r/100)}else{a=e.offsetX/u.offsetWidth*100}if(a<101){if(1===s)f=Math.ceil(a/100*r);else{let e=a/100*r;for(let t=0;;t+=s)if(t>=e){f=t;break}}if(f>5&&(f=5),u.querySelector(".yasr-star-value").style.width=f/r*100+"%",t){let e=m.replace("{rating}",f);e=e.replace("{maxRating}",r),u.setAttribute("data-title",e)}"function"==typeof l&&l(f,i)}}function w(e){void 0!==i?(u.querySelector(".yasr-star-value").style.width=i/r*100+"%",u.setAttribute("data-rating",i)):(u.querySelector(".yasr-star-value").style.width="0%",u.removeAttribute("data-rating")),"function"==typeof o&&o(f,i)}function A(e){!0!==g&&!0!==p&&(void 0===y&&!1===typeof y||(p=!0,a=f,void 0===b?u.removeAttribute("data-title"):u.setAttribute("data-title",b),y.call(this,a,function(){!1===g&&u.removeAttribute("data-title"),p=!1})))}function L(){if(g=!0,t&&c){let e=c.replace("{rating}",i);e=e.replace("{maxRating}",r),u.setAttribute("data-title",e)}else u.removeAttribute("data-title")}function E(e){if(-1===e&&(e=void 0),"number"!=typeof e&&void 0!==e)throw new Error("Value must be a number or undefined.");e<0&&(e=0),e>5&&(e=5),i=e,u.querySelector(".yasr-star-value").style.width=e/r*100+"%",u.setAttribute("data-rating",e)}void 0===i&&(u.querySelector(".yasr-star-value").style.width="0px"),g&&L(),u.addEventListener("mousemove",x),u.addEventListener("mouseleave",w);let S={setRating:E,getRating:function(){return i},disable:L,enable:function(){g=!1,u.removeAttribute("data-title")},dispose:function(){u.removeEventListener("mousemove",x),u.removeEventListener("mouseleave",w),u.removeEventListener("click",A)}};return u.addEventListener("click",A.bind(S)),S}
1
+ function raterJs(e){let t=!0;if(void 0===e.element||null===e.element)return void console.info("missing rating element");if(null!==e.element&&e.element.classList.contains("yasr-star-rating"))return;if(void 0!==e.showToolTip&&(t=!!e.showToolTip),void 0!==e.step&&(e.step<=0||e.step>1))throw new Error("step must be a number between 0 and 1");let i,a,r=5,n=e.starSize||16,s=e.step||1,l=e.onHover,o=e.onLeave,d=wp.i18n.isRTL(),u=e.element;u.classList.add("yasr-star-rating");let v=document.createElement("div");v.classList.add("yasr-star-value"),v.style.backgroundSize=n+"px",u.appendChild(v),u.style.width=n*r+"px",u.style.height=n+"px",u.style.backgroundSize=n+"px";let c,f,m,g=e.rateCallback,y=!!e.readOnly,p=!1,b=e.isBusyText;if(c=void 0!==e.disableText?e.disableText:"{rating}/{maxRating}",y||(u.style.cursor="pointer"),m=void 0!==e.ratingText?e.ratingText:"{rating}/{maxRating}",e.rating)T(e.rating);else{var h=u.dataset.rating;h&&T(+h)}function w(e){if(!0===y||!0===p)return;let a;if(!0===d){let t=this.getBoundingClientRect(),i=e.pageX-t.left,r=u.offsetWidth;a=(r-i)/(r/100)}else{a=e.offsetX/u.offsetWidth*100}if(a<101){if(1===s)f=Math.ceil(a/100*r);else{let e=a/100*r;for(let t=0;;t+=s)if(t>=e){f=t;break}}if(f>5&&(f=5),u.querySelector(".yasr-star-value").style.width=f/r*100+"%",t){let e=m.replace("{rating}",f);e=e.replace("{maxRating}",r),u.setAttribute("data-title",e)}"function"==typeof l&&l(f,i)}}function x(e){void 0!==i?(u.querySelector(".yasr-star-value").style.width=i/r*100+"%",u.setAttribute("data-rating",i)):(u.querySelector(".yasr-star-value").style.width="0%",u.removeAttribute("data-rating")),"function"==typeof o&&o(f,i)}function L(e){!0!==y&&!0!==p&&(void 0===g&&!1===typeof g||(p=!0,a=f,void 0===b?u.removeAttribute("data-title"):u.setAttribute("data-title",b),g.call(this,a,function(){!1===y&&u.removeAttribute("data-title"),p=!1})))}function A(){if(y=!0,t&&c){let e=c.replace("{rating}",i);e=e.replace("{maxRating}",r),u.setAttribute("data-title",e)}else u.removeAttribute("data-title")}function T(e){if(-1===e&&(e=void 0),"number"!=typeof e&&void 0!==e)throw new Error("Value must be a number or undefined.");e<0&&(e=0),e>5&&(e=5),i=e,u.querySelector(".yasr-star-value").style.width=e/r*100+"%",u.setAttribute("data-rating",e)}void 0===i&&(u.querySelector(".yasr-star-value").style.width="0px"),y&&A(),u.addEventListener("mousemove",w),u.addEventListener("mouseleave",x);let E={setRating:T,getRating:function(){return i},disable:A,enable:function(){y=!1,u.removeAttribute("data-title")},dispose:function(){u.removeEventListener("mousemove",w),u.removeEventListener("mouseleave",x),u.removeEventListener("click",L)}};return u.addEventListener("click",L.bind(E)),E}
 
includes/js/readme ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ the files
2
+ - includes/js/src/shortcodes/yasr-log-users-fronted.js
3
+ - includes/js/src/rater-js-src.js
4
+
5
+ Are not minified bundled with webpack, it is just a simple minifing
includes/js/shortcodes/overall-multiset.js ADDED
@@ -0,0 +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))}})();
includes/js/shortcodes/rankings.js ADDED
@@ -0,0 +1 @@
 
1
+ (()=>{"use strict";var t,e,a=new Uint8Array(16);function n(){if(!e&&!(e="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 e(a)}const r=/^(?:[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,o=function(t){return"string"==typeof t&&r.test(t)};for(var s=[],i=0;i<256;++i)s.push((i+256).toString(16).substr(1));const l=function(t,e,a){var r=(t=t||{}).random||(t.rng||n)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var i=0;i<16;++i)e[a+i]=r[i];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase();if(!o(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function c(t){return(c="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})(t)}function u(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function d(t,e){return(d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function m(t,e){return!e||"object"!==c(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var h=wp.i18n.__,f=wp.element.render;function p(t){var e="yasr-ranking-element-"+l(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return function(t,e){var a,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:r,rating:o,rateCallback:s})}(a,e,!1,.1,!0,t.rating)}})}function y(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",h("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",h("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 v(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===t&&(t=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),t.innerHTML=e;var a=t.textContent;return t.innerHTML="",a}(e.post.title)))}function b(t){var e="after",a=h("Rating:","yet-another-stars-rating"),n=new URLSearchParams(t.rankingParams);return null!==n.get("text_position")&&(e=n.get("text_position")),null!==n.get("custom_txt")&&(a=n.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(y,{post:t.post,tableId:t.tableId,text:a}),React.createElement(p,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(p,{rating:t.post.rating,tableId:t.tableId}),React.createElement(y,{post:t.post,tableId:t.tableId,text:a}))}function R(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(v,{colClass:e,post:t.post}),React.createElement(b,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function E(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var n="yasr-rankings-td-colored";return"author_ranking"===t.source&&(n="yasr-rankings-td-white"),a%2==0&&(n="yasr-rankings-td-white","author_ranking"===t.source&&(n="yasr-rankings-td-colored")),React.createElement(R,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:n})})))}var _=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&&d(t,e)}(s,React.Component);var e,a,n,r,o=(n=s,r=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=g(n);if(r){var a=g(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return m(this,t)});function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=o.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(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(h("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var n=this.returnRestUrl();Promise.all(n.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(h("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(h(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(h(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:h("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,n="&nonce_rankings="+this.state.nonce,r="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(r+="order_by="+o.get("order_by")),null!==o.get("limit")&&(r+="&limit="+o.get("limit")),null!==o.get("start_date")&&"0"!==o.get("start_date")&&(r+="&start_date="+o.get("start_date")),null!==o.get("end_date")&&"0"!==o.get("end_date")&&(r+="&end_date="+o.get("end_date")),null!==o.get("ctg")?r+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(r+="&cpt="+o.get("cpt")),""!==r&&(r="&"+(r=r.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==o.get("setid")&&(r+="&setid="+o.get("setid"))}else r="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+r+n];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&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+r+s+n,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+r+i+n]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:n},h("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},h("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:r},h("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},h("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,"Post"),React.createElement("th",null,h("Order By","yet-another-stars-rating-pro"),":  ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a,o="most-rated-posts-"+a,s="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===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)),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))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,n=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:n,show:"table-row-group",source:a});var r=e.most,o=e.highest,s="table-row-group",i="none",l="most",c=s,u=i,d=new URLSearchParams(n);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=s),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:r,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:n,show:c,source:a}),React.createElement(E,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:n,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,h("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&u(e.prototype,a),s}();!function(){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,n=JSON.parse(t.item(e).dataset.rankingSource),r=JSON.parse(t.item(e).dataset.rankingParams),o=JSON.parse(t.item(e).dataset.rankingNonce),s=document.getElementById(a);f(React.createElement(_,{source:n,tableId:a,params:r,nonce:o}),s)}}()})();
includes/js/shortcodes/visitorVotes.js ADDED
@@ -0,0 +1 @@
 
1
+ (()=>{"use strict";function t(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}const{__:e}=wp.i18n,a=document.getElementsByClassName("yasr-rater-stars-vv");if(a.length>0&&(function(a){for(let r=0;r<a.length;r++)!function(r){if(!1!==a.item(r).classList.contains("yasr-star-rating"))return;const n=a.item(r);let o=n.getAttribute("data-rating"),i=n.getAttribute("data-readonly-attribute"),l=n.getAttribute("data-rater-readonly");null===i&&(i=!1),i=t(i),l=t(l),!0===i&&(l=!0);let d=n.getAttribute("data-rater-postid"),u=n.id,y=u.replace("yasr-visitor-votes-rater-",""),v=parseInt(n.getAttribute("data-rater-starsize")),m=n.getAttribute("data-rater-nonce"),c=n.getAttribute("data-issingular"),g="yasr-vv-votes-number-container-"+y,_="yasr-vv-average-container-"+y,p="yasr-vv-bottom-container-"+y,f="yasr-vv-loader-"+y;const b=document.getElementById(g),h=document.getElementById(_),w=document.getElementById(p),H=document.getElementById(f);if("yes"===yasrCommonData.ajaxEnabled){null!==H&&(H.innerHTML=yasrCommonData.loaderHtml);let t={action:"yasr_load_vv",post_id:d};jQuery.get(yasrCommonData.ajaxurl,t).done((function(t){let e,a=JSON.parse(t);e=!0===i||a.yasr_visitor_votes.stars_attributes.read_only,o=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0,o=o.toFixed(1),o=parseFloat(o),s(v,o,d,e,u,0,m,c,b,h,H,w),!0!==i&&(null!==b&&(b.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==h&&(h.innerHTML=o),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==w&&(w.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,w.style.display=""))})).fail((function(t,a,r,n){console.info(e("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),s(v,o,d,l,u,0,m,c,b,h,H,w),!0!==i&&(w.style.display="")}))}else s(v,o,d,l,u,0,m,c,b,h,H,w)}(r)}(a),"yes"===yasrCommonData.visitorStatsEnabled)){let t=document.getElementsByClassName("yasr-dashicons-visitor-stats");t&&function(t){let e,a,s=!1;for(let n=0;n<t.length;n++)!function(n){let o="#"+t.item(n).id,i=t.item(n).getAttribute("data-postid");0===n&&(e=document.getElementsByClassName("yasr-vv-text-container"),null!==e&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color"))),a&&(document.getElementById(t.item(n).id).style.fill=a);let l={action:"yasr_stats_visitors_votes",post_id:i};tippy(o,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){o!==s&&jQuery.post(yasrCommonData.ajaxurl,l,(function(e){e=JSON.parse(e),t.setContent(r(e))}))},onHidden:function(){s=o}})}(n)}(t)}function s(e,a,s,r,n,o,i,l,d,u,y,v){a=parseFloat(a),r=t(r);const m=document.getElementById(n);null!==y&&(y.innerHTML=""),function(t,e,a=!1,s=.1,r=!0,n=!1,o=!1){let i;i=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:i,step:s,readOnly:r,rating:n,rateCallback:o})}(e,n,m,1,r,a,(function(t,e){null!==y&&(y.innerHTML=yasrCommonData.loaderHtml);var a={action:"yasr_send_visitor_rating",rating:t,post_id:s,nonce_visitor:i,is_singular:l};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){let e,a,s;"success"===(t=JSON.parse(t)).status?(e=t.number_of_votes,a=t.average_rating,s=t.rating_saved_text,null!==d&&(d.innerHTML=e),null!==u&&(u.innerHTML=a)):s=t.text,null!==v&&(v.innerHTML=s,v.style.display=""),null!==y&&(y.innerHTML="")})),e()}))}function r(t){const a=t.medium_rating;delete t.medium_rating;let s=0;for(let e=1;e<=5;e++)(1===e||t[e].n_of_votes>s)&&(s=t[e].n_of_votes);let r=Math.log(s)*Math.LOG10E+1|0,n="5%";r<=3&&(n="5%"),r>3&&r<=5&&(n="10%"),r>5&&(n="15%");let o='<div class="yasr-visitors-stats-tooltip">';o+='<span id="yasr-medium-rating-tooltip">'+a+" "+e("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';let i=e("stars","yet-another-stars-rating"),l=0,d=0;for(let a=5;a>0;a--)1===a&&(i=e("star","yet-another-stars-rating")),void 0!==t[a]&&(l=t[a].progressbar,d=t[a].n_of_votes),o+=`<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>${a} ${i}</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:${l}'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style="flex-basis:${n} ">${d}</div>\n </div>`;return o+="</div></div>",o}})();
includes/js/shortcodes/yasr-log-users-fronted.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(){jQuery(".yasr-user-log-page-num").on("click",function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,function(a){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(a)})}),jQuery(document).ajaxComplete(function(a,e,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_user_log_page_front")&&jQuery(".yasr-user-log-page-num").on("click",function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,function(a){jQuery("#yasr-user-log-container").html(a)})})})});
includes/js/src/modules/yasrSetRaterValue.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //this is the function that print the overall rating shortcode, get overall rating and starsize
2
+ export function yasrSetRaterValue (starSize, htmlId, element=false, step=0.1, readonly=true,
3
+ rating=false, rateCallback=false) {
4
+ let domElement;
5
+ if(element) {
6
+ domElement = element;
7
+ } else {
8
+ domElement = document.getElementById(htmlId)
9
+ }
10
+
11
+ //convert to be a number
12
+ starSize = parseInt(starSize);
13
+
14
+ raterJs({
15
+ starSize: starSize,
16
+ showToolTip: false,
17
+ element: domElement,
18
+ step: step,
19
+ readOnly: readonly,
20
+ rating: rating,
21
+ rateCallback: rateCallback
22
+ });
23
+
24
+ }
includes/js/src/modules/yasrTrueFalseStringConvertion.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export function yasrTrueFalseStringConvertion(string) {
2
+
3
+ if (typeof string === 'undefined' || string === null || string === '') {
4
+ string = true;
5
+ }
6
+
7
+ //Convert string to boolean
8
+ if (string === 'true' || string === '1') {
9
+ string = true;
10
+ }
11
+ if (string === 'false' || string === '0') {
12
+ string = false;
13
+ }
14
+
15
+ return string;
16
+
17
+ }
includes/js/src/rater-js-src.js CHANGED
@@ -28,7 +28,7 @@ function raterJs(options) {
28
  let step = options.step || 1;
29
  let onHover = options.onHover;
30
  let onLeave = options.onLeave;
31
- let isRtl = JSON.parse(yasrCommonData.isRtl);
32
 
33
  let rating;
34
  let myRating;
28
  let step = options.step || 1;
29
  let onHover = options.onHover;
30
  let onLeave = options.onLeave;
31
+ let isRtl = wp.i18n.isRTL();
32
 
33
  let rating;
34
  let myRating;
includes/js/src/shortcodes/overall-multiset.js ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n; // Import __() from wp.i181n
2
+ const arrayClasses = ['yasr-rater-stars', 'yasr-multiset-visitors-rater'];
3
+
4
+ import {yasrSetRaterValue} from "../modules/yasrSetRaterValue";
5
+ import {yasrTrueFalseStringConvertion} from "../modules/yasrTrueFalseStringConvertion";
6
+
7
+ /*** Constant used by yasr
8
+ yasrCommonData (ajaxurl, isrtl)
9
+ ***/
10
+
11
+ for (let i=0; i<arrayClasses.length; i++) {
12
+ //Search and set all div with class yasr-multiset-visitors-rater
13
+ yasrSearchStarsDom(arrayClasses[i]);
14
+ }
15
+
16
+ /**
17
+ * Search for divs with defined classname
18
+ */
19
+ function yasrSearchStarsDom (starsClass) {
20
+ //At pageload, check if there is some shortcode with class yasr-rater-stars
21
+ const yasrRaterInDom = document.getElementsByClassName(starsClass);
22
+ //If so, call the function to set the rating
23
+ if (yasrRaterInDom.length > 0) {
24
+ //stars class for most shortcodes
25
+ if(starsClass === 'yasr-rater-stars') {
26
+ yasrSetRating(yasrRaterInDom);
27
+ }
28
+
29
+ if (starsClass === 'yasr-multiset-visitors-rater') {
30
+ yasrRaterVisitorsMultiSet(yasrRaterInDom)
31
+ }
32
+ }
33
+ }
34
+
35
+ function yasrSetRating (yasrRatingsInDom) {
36
+
37
+ //Check in the object
38
+ for (let i = 0; i < yasrRatingsInDom.length; i++) {
39
+ //yasr-star-rating is the class set by rater.js : so, if already exists,
40
+ //means that rater already run for the element
41
+ if(yasrRatingsInDom.item(i).classList.contains('yasr-star-rating') === false) {
42
+ const element = yasrRatingsInDom.item(i);
43
+ const htmlId = element.id;
44
+ const starSize = element.getAttribute('data-rater-starsize');
45
+ yasrSetRaterValue(starSize, htmlId, element);
46
+ }
47
+ }
48
+
49
+ }
50
+
51
+ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
52
+ //will have field id and vote
53
+ var ratingObject = "";
54
+
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) {
61
+ //yasr-star-rating is the class set by rater.js : so, if already exists,
62
+ //means that rater already run for the element
63
+ if(yasrMultiSetVisitorInDom.item(i).classList.contains('yasr-star-rating') !== false) {
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
+
73
+ const rateCallback = function (rating, done) {
74
+ const postId = elem.getAttribute('data-rater-postid');
75
+ const setId = elem.getAttribute('data-rater-setid');
76
+ const setIdField = elem.getAttribute('data-rater-set-field-id');
77
+
78
+ //Just leave 1 number after the .
79
+ rating = rating.toFixed(1);
80
+ //Be sure is a number and not a string
81
+ const vote = parseInt(rating);
82
+
83
+ this.setRating(vote); //set the new rating
84
+
85
+ ratingObject = {
86
+ postid: postId,
87
+ setid: setId,
88
+ field: setIdField,
89
+ rating: vote
90
+ };
91
+
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
+
103
+ }
104
+
105
+ jQuery('.yasr-send-visitor-multiset').on('click', function() {
106
+ const multiSetPostId = this.getAttribute('data-postid');
107
+ const multiSetId = this.getAttribute('data-setid');
108
+ const nonce = this.getAttribute('data-nonce');
109
+
110
+ jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
111
+ jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
112
+
113
+ var data = {
114
+ action: 'yasr_visitor_multiset_field_vote',
115
+ nonce: nonce,
116
+ post_id: multiSetPostId,
117
+ rating: ratingArray,
118
+ set_id: multiSetId
119
+ };
120
+
121
+ //Send value to the Server
122
+ jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
123
+ let responseText;
124
+ response = JSON.parse(response);
125
+ responseText = response.text
126
+
127
+ jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).text(responseText);
128
+ });
129
+
130
+ });
131
+
132
+ } //End function
includes/js/src/{ranking.js → shortcodes/ranking.js} RENAMED
@@ -1,6 +1,6 @@
1
  import {decodeEntities} from "@wordpress/html-entities";
2
  import {v4 as uuidv4} from 'uuid';
3
- import {yasrSetRaterValue} from './yasr-front';
4
 
5
  const { __ } = wp.i18n; // Import __() from wp.i18n
6
  const {render} = wp.element;
@@ -605,4 +605,7 @@ export function yasrDrawRankings () {
605
  render(<YasrRanking source={source} tableId={tableId} params={params} nonce={nonce} />, rankingTable);
606
  }
607
  }
608
- }
 
 
 
1
  import {decodeEntities} from "@wordpress/html-entities";
2
  import {v4 as uuidv4} from 'uuid';
3
+ import {yasrSetRaterValue} from '../modules/yasrSetRaterValue';
4
 
5
  const { __ } = wp.i18n; // Import __() from wp.i18n
6
  const {render} = wp.element;
605
  render(<YasrRanking source={source} tableId={tableId} params={params} nonce={nonce} />, rankingTable);
606
  }
607
  }
608
+ }
609
+
610
+ //Drow Rankings
611
+ yasrDrawRankings();
includes/js/src/{yasr-front.js → shortcodes/visitorVotes.js} RENAMED
@@ -1,284 +1,23 @@
1
- import {yasrDrawRankings} from "./ranking";
2
-
3
- const { __ } = wp.i18n; // Import __() from wp.i181n
4
- const arrayClasses = ['yasr-rater-stars', 'yasr-rater-stars-vv', 'yasr-multiset-visitors-rater'];
5
-
6
- /*** Constant used by yasr
7
- yasrCommonData (postid, ajaxurl, loggedUser, visitorStatsEnabled, loaderHtml, tooltipValues', isrtl)
8
- ***/
9
-
10
- for (let i=0; i<arrayClasses.length; i++) {
11
- //Search and set all div with class yasr-multiset-visitors-rater
12
- yasrSearchStarsDom(arrayClasses[i]);
13
- }
14
-
15
- //Drow Rankings
16
- yasrDrawRankings();
17
-
18
-
19
- /**
20
- * Search for divs with defined classname
21
- */
22
- export function yasrSearchStarsDom (starsClass) {
23
- //At pageload, check if there is some shortcode with class yasr-rater-stars
24
- const yasrRaterInDom = document.getElementsByClassName(starsClass);
25
- //If so, call the function to set the rating
26
- if (yasrRaterInDom.length > 0) {
27
- //stars class for most shortcodes
28
- if(starsClass === 'yasr-rater-stars' || starsClass === 'yasr-ranking-stars') {
29
- yasrSetRating(yasrRaterInDom);
30
- }
31
-
32
- if(starsClass === 'yasr-rater-stars-vv') {
33
- yasrVisitorVotesFront(yasrRaterInDom);
34
- if (yasrCommonData.visitorStatsEnabled === 'yes') {
35
- let yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
36
- if (yasrStatsInDom) {
37
- yasrVvStats (yasrStatsInDom);
38
- }
39
- }
40
- }
41
-
42
- if (starsClass === 'yasr-multiset-visitors-rater') {
43
- yasrRaterVisitorsMultiSet(yasrRaterInDom)
44
  }
45
  }
46
  }
47
 
48
- /****** Tooltip function ******/
49
-
50
- //used in shortcode page and ajax page
51
- function yasrVvStats (yasrStatsInDom) {
52
- //htmlcheckid declared false
53
- let htmlIdChecked = false;
54
-
55
- let txtContainer; //the container of the text [TOTAL...]; needed to get the text color
56
- let computedcolor;
57
-
58
- for (let i = 0; i < yasrStatsInDom.length; i++) {
59
- (function (i) {
60
-
61
- let htmlId = '#'+yasrStatsInDom.item(i).id;
62
- let postId = yasrStatsInDom.item(i).getAttribute('data-postid');
63
-
64
- //get the font color from yasr-vv-text-container only the first time
65
- if(i===0) {
66
- //main container
67
- txtContainer = document.getElementsByClassName('yasr-vv-text-container');
68
- if(txtContainer !== null) {
69
- computedcolor = window.getComputedStyle(txtContainer[0], null).getPropertyValue("color");
70
- }
71
- }
72
-
73
- //if computed color exists, change the color to the svg
74
- if(computedcolor) {
75
- //get the svg element
76
- let svg = document.getElementById(yasrStatsInDom.item(i).id);
77
- //fill with the same color of the text
78
- svg.style.fill=computedcolor;
79
- }
80
-
81
- let data = {
82
- action: 'yasr_stats_visitors_votes',
83
- post_id: postId
84
- };
85
-
86
- let initialContent = '<span style="color: #0a0a0a">Loading...</span>';
87
-
88
- tippy(htmlId, {
89
- allowHTML: true,
90
- content: initialContent,
91
- theme: 'yasr',
92
- arrow: true,
93
- arrowType: 'round',
94
-
95
- //When support for IE will be dropped out, this will become onShow(tip)
96
- onShow: function onShow(tip) {
97
- if (htmlId !== htmlIdChecked) {
98
- //must be post or wont work
99
- jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
100
- response = JSON.parse(response);
101
- tip.setContent(yasrReturnToolbarStats(response));
102
- });
103
- }
104
- },
105
- onHidden: function onHidden() {
106
- htmlIdChecked = htmlId;
107
- }
108
-
109
- });
110
-
111
- })(i);
112
- }
113
-
114
- }
115
-
116
  /**
117
- * Return the HTML with toolbars
118
- *
119
- * @param ratings MUST be an object
120
- * with 6 params: 1 int and 5 suboject
121
- * int: medium_rating
122
- * subobject: each one must have:
123
- * - progressbar
124
- * - n_of_votes
125
- * - votes (optional)
126
- * e.g.
127
- {
128
- "1": {
129
- "progressbar": "17.14%",
130
- "n_of_votes": 6,
131
- "vote": "1"
132
- },
133
- "2": {
134
- "progressbar": "25.71%",
135
- "n_of_votes": 9,
136
- "vote": "2"
137
- },
138
- "3": {
139
- "progressbar": "8.57%",
140
- "n_of_votes": 3,
141
- "vote": "3"
142
- },
143
- "4": {
144
- "progressbar": "0%",
145
- "n_of_votes": 0,
146
- "vote": 4
147
- },
148
- "5": {
149
- "progressbar": "48.57%",
150
- "n_of_votes": 17,
151
- "vote": "5"
152
- }
153
- }
154
  *
 
155
  */
156
- function yasrReturnToolbarStats (ratings) {
157
- //Get the medium rating
158
- const mediumRating = ratings.medium_rating;
159
-
160
- //remove medium rating from the object, so I can loop only the ratings later
161
- delete ratings['medium_rating'];
162
-
163
- let highestNumberOfVotes = 0;
164
- //loop a first time the array to get the highest number of votes
165
- for (let i = 1; i <= 5; i++) {
166
- if(i === 1) {
167
- highestNumberOfVotes = ratings[i].n_of_votes;
168
- } else {
169
- if (ratings[i].n_of_votes > highestNumberOfVotes) {
170
- highestNumberOfVotes = ratings[i].n_of_votes;
171
- }
172
- }
173
- }
174
- //Later, I need to get the number of digits of the highest number
175
- let lengthHighestNumberOfVotes = Math.log(highestNumberOfVotes) * Math.LOG10E + 1 | 0;
176
-
177
- //Later, I've to calculate the flexbasis based on the lenght of the nummber
178
- //default flexbasis is 5%
179
- let flexbasis = '5%'
180
-
181
- //if the length of the number is less or equal of 3 digits (999)
182
- //flexbasis is 5%
183
- if(lengthHighestNumberOfVotes <= 3) {
184
- flexbasis = '5%';
185
- }
186
- //if the length of the number is major of 3 digits and less or equal of 5 digits (99999)
187
- //flexbasis is 10%
188
- if(lengthHighestNumberOfVotes > 3 && lengthHighestNumberOfVotes <= 5) {
189
- flexbasis = '10%';
190
- }
191
- //if highest of 5 digits, flexbasis is 15 % (note that this will break into a newline when 8 digits are
192
- //reached, but I think that a number of 9,999,999 is enough
193
- if(lengthHighestNumberOfVotes > 5) {
194
- flexbasis = '15%';
195
- }
196
-
197
- //prepare the html to return
198
- let html_to_return = '<div class="yasr-visitors-stats-tooltip">';
199
- html_to_return += '<span id="yasr-medium-rating-tooltip">'
200
- + mediumRating
201
- + ' '
202
- + __('out of 5 stars', 'yet-another-stars-rating')
203
- + '</span>';
204
- html_to_return += '<div class="yasr-progress-bars-container">';
205
-
206
- let stars_text = __('stars', 'yet-another-stars-rating'); //default is plural
207
- let progressbar = 0; //default value for progressbar
208
- let n_votes = 0; //default n_votes
209
-
210
- //Do a for with 5 rows
211
- for (let i = 5; i > 0; i--) {
212
- if (i === 1) {
213
- stars_text = __('star', 'yet-another-stars-rating'); //single form
214
- }
215
-
216
- //should never happen, just to be sage
217
- if(typeof ratings[i] !== 'undefined') {
218
- progressbar = ratings[i].progressbar;
219
- n_votes = ratings[i].n_of_votes;
220
- }
221
-
222
- html_to_return += `<div class='yasr-progress-bar-row-container yasr-w3-container'>
223
- <div class='yasr-progress-bar-name'>${i} ${stars_text}</div>
224
- <div class='yasr-single-progress-bar-container'>
225
- <div class='yasr-w3-border'>
226
- <div class='yasr-w3-amber' style='height:17px;width:${progressbar}'></div>
227
- </div>
228
- </div>
229
- <div class='yasr-progress-bar-votes-count' style="flex-basis:${flexbasis} ">${n_votes}</div>
230
- </div>`;
231
-
232
- } //End foreach
233
-
234
- html_to_return += '</div></div>';
235
-
236
- return html_to_return;
237
- }
238
-
239
- /****** End tooltipfunction ******/
240
-
241
- //this is the function that print the overall rating shortcode, get overall rating and starsize
242
- export function yasrSetRaterValue (starSize, htmlId, element=false, step=0.1, readonly=true,
243
- rating=false, rateCallback=false) {
244
- let domElement;
245
- if(element) {
246
- domElement = element;
247
- } else {
248
- domElement = document.getElementById(htmlId)
249
- }
250
-
251
- //convert to be a number
252
- starSize = parseInt(starSize);
253
-
254
- raterJs({
255
- starSize: starSize,
256
- showToolTip: false,
257
- element: domElement,
258
- step: step,
259
- readOnly: readonly,
260
- rating: rating,
261
- rateCallback: rateCallback
262
- });
263
-
264
- }
265
-
266
- function yasrSetRating (yasrRatingsInDom) {
267
-
268
- //Check in the object
269
- for (let i = 0; i < yasrRatingsInDom.length; i++) {
270
- //yasr-star-rating is the class set by rater.js : so, if already exists,
271
- //means that rater already run for the element
272
- if(yasrRatingsInDom.item(i).classList.contains('yasr-star-rating') === false) {
273
- const element = yasrRatingsInDom.item(i);
274
- const htmlId = element.id;
275
- const starSize = element.getAttribute('data-rater-starsize');
276
- yasrSetRaterValue(starSize, htmlId, element);
277
- }
278
- }
279
-
280
- }
281
-
282
  function yasrVisitorVotesFront (yasrRaterVVInDom) {
283
  //Check in the object
284
  for (let i = 0; i < yasrRaterVVInDom.length; i++) {
@@ -367,12 +106,12 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
367
  //insert span with text after the average
368
  if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false
369
  && bottomContainer !== null) {
370
- bottomContainer.innerHTML = data.yasr_visitor_votes.stars_attributes.span_bottom;
371
- bottomContainer.style.display = '';
372
  }
373
  }
374
 
375
- }).fail(
376
  function(e, x, settings, exception) {
377
  console.info(__('YASR ajax call failed. Showing ratings from html', 'yet-another-stars-rating'));
378
  yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
@@ -393,6 +132,7 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
393
 
394
  }
395
 
 
396
  /**
397
  *
398
  * @param starSize
@@ -486,103 +226,196 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
486
 
487
  }
488
 
489
- function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
490
- //will have field id and vote
491
- var ratingObject = "";
492
 
493
- //an array with all the ratings objects
494
- var ratingArray = [];
495
 
496
- //Check in the object
497
- for (let i = 0; i < yasrMultiSetVisitorInDom.length; i++) {
498
- (function (i) {
499
- //yasr-star-rating is the class set by rater.js : so, if already exists,
500
- //means that rater already run for the element
501
- if(yasrMultiSetVisitorInDom.item(i).classList.contains('yasr-star-rating') !== false) {
502
- return;
503
- }
504
 
505
- let elem = yasrMultiSetVisitorInDom.item(i);
506
- let htmlId = elem.id;
507
- let readonly = elem.getAttribute('data-rater-readonly');
508
 
509
- readonly = yasrTrueFalseStringConvertion(readonly);
 
510
 
511
- const rateCallback = function (rating, done) {
512
- const postId = elem.getAttribute('data-rater-postid');
513
- const setId = elem.getAttribute('data-rater-setid');
514
- const setIdField = elem.getAttribute('data-rater-set-field-id');
515
 
516
- //Just leave 1 number after the .
517
- rating = rating.toFixed(1);
518
- //Be sure is a number and not a string
519
- const vote = parseInt(rating);
 
 
 
 
520
 
521
- this.setRating(vote); //set the new rating
 
 
 
 
 
 
522
 
523
- ratingObject = {
524
- postid: postId,
525
- setid: setId,
526
- field: setIdField,
527
- rating: vote
528
- };
529
 
530
- //creating rating array
531
- ratingArray.push(ratingObject);
532
 
533
- done();
 
 
 
 
 
534
 
535
- }
 
 
 
 
 
 
 
 
 
 
 
 
536
 
537
- yasrSetRaterValue (16, htmlId, elem, 1, readonly, false, rateCallback);
538
 
539
  })(i);
540
-
541
  }
542
 
543
- jQuery('.yasr-send-visitor-multiset').on('click', function() {
544
- const multiSetPostId = this.getAttribute('data-postid');
545
- const multiSetId = this.getAttribute('data-setid');
546
- const nonce = this.getAttribute('data-nonce');
547
-
548
- jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
549
- jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
550
-
551
- var data = {
552
- action: 'yasr_visitor_multiset_field_vote',
553
- nonce: nonce,
554
- post_id: multiSetPostId,
555
- rating: ratingArray,
556
- set_id: multiSetId
557
- };
558
 
559
- //Send value to the Server
560
- jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
561
- let responseText;
562
- response = JSON.parse(response);
563
- responseText = response.text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
 
565
- jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).text(responseText);
566
- });
567
 
568
- });
569
-
570
- } //End function
 
 
 
 
 
 
 
 
 
 
571
 
572
- function yasrTrueFalseStringConvertion(string) {
 
 
573
 
574
- if (typeof string === 'undefined' || string === null || string === '') {
575
- string = true;
 
 
576
  }
577
-
578
- //Convert string to boolean
579
- if (string === 'true' || string === '1') {
580
- string = true;
581
  }
582
- if (string === 'false' || string === '0') {
583
- string = false;
 
 
584
  }
585
 
586
- return string;
 
 
 
 
 
 
 
 
 
 
 
587
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
588
  }
 
 
1
+ const { __ } = wp.i18n; // Import __() from wp.i181n
2
+ import {yasrSetRaterValue} from "../modules/yasrSetRaterValue";
3
+ import {yasrTrueFalseStringConvertion} from "../modules/yasrTrueFalseStringConvertion";
4
+
5
+ const yasrRaterInDom = document.getElementsByClassName('yasr-rater-stars-vv');
6
+
7
+ if (yasrRaterInDom.length > 0) {
8
+ yasrVisitorVotesFront(yasrRaterInDom);
9
+ if (yasrCommonData.visitorStatsEnabled === 'yes') {
10
+ let yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
11
+ if (yasrStatsInDom) {
12
+ yasrVvStats (yasrStatsInDom);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
  }
15
  }
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  *
19
+ * @param yasrRaterVVInDom
20
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  function yasrVisitorVotesFront (yasrRaterVVInDom) {
22
  //Check in the object
23
  for (let i = 0; i < yasrRaterVVInDom.length; i++) {
106
  //insert span with text after the average
107
  if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false
108
  && bottomContainer !== null) {
109
+ bottomContainer.innerHTML = data.yasr_visitor_votes.stars_attributes.span_bottom;
110
+ bottomContainer.style.display = '';
111
  }
112
  }
113
 
114
+ }).fail(
115
  function(e, x, settings, exception) {
116
  console.info(__('YASR ajax call failed. Showing ratings from html', 'yet-another-stars-rating'));
117
  yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
132
 
133
  }
134
 
135
+
136
  /**
137
  *
138
  * @param starSize
226
 
227
  }
228
 
 
 
 
229
 
230
+ /****** Tooltip functions ******/
 
231
 
232
+ //used in shortcode page and ajax page
233
+ function yasrVvStats (yasrStatsInDom) {
234
+ //htmlcheckid declared false
235
+ let htmlIdChecked = false;
 
 
 
 
236
 
237
+ let txtContainer; //the container of the text [TOTAL...]; needed to get the text color
238
+ let computedcolor;
 
239
 
240
+ for (let i = 0; i < yasrStatsInDom.length; i++) {
241
+ (function (i) {
242
 
243
+ let htmlId = '#'+yasrStatsInDom.item(i).id;
244
+ let postId = yasrStatsInDom.item(i).getAttribute('data-postid');
 
 
245
 
246
+ //get the font color from yasr-vv-text-container only the first time
247
+ if(i===0) {
248
+ //main container
249
+ txtContainer = document.getElementsByClassName('yasr-vv-text-container');
250
+ if(txtContainer !== null) {
251
+ computedcolor = window.getComputedStyle(txtContainer[0], null).getPropertyValue("color");
252
+ }
253
+ }
254
 
255
+ //if computed color exists, change the color to the svg
256
+ if(computedcolor) {
257
+ //get the svg element
258
+ let svg = document.getElementById(yasrStatsInDom.item(i).id);
259
+ //fill with the same color of the text
260
+ svg.style.fill=computedcolor;
261
+ }
262
 
263
+ let data = {
264
+ action: 'yasr_stats_visitors_votes',
265
+ post_id: postId
266
+ };
 
 
267
 
268
+ let initialContent = '<span style="color: #0a0a0a">Loading...</span>';
 
269
 
270
+ tippy(htmlId, {
271
+ allowHTML: true,
272
+ content: initialContent,
273
+ theme: 'yasr',
274
+ arrow: true,
275
+ arrowType: 'round',
276
 
277
+ //When support for IE will be dropped out, this will become onShow(tip)
278
+ onShow: function onShow(tip) {
279
+ if (htmlId !== htmlIdChecked) {
280
+ //must be post or wont work
281
+ jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
282
+ response = JSON.parse(response);
283
+ tip.setContent(yasrReturnToolbarStats(response));
284
+ });
285
+ }
286
+ },
287
+ onHidden: function onHidden() {
288
+ htmlIdChecked = htmlId;
289
+ }
290
 
291
+ });
292
 
293
  })(i);
 
294
  }
295
 
296
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
+ /**
299
+ * Return the HTML with toolbars
300
+ *
301
+ * @param ratings MUST be an object
302
+ * with 6 params: 1 int and 5 suboject
303
+ * int: medium_rating
304
+ * subobject: each one must have:
305
+ * - progressbar
306
+ * - n_of_votes
307
+ * - votes (optional)
308
+ * e.g.
309
+ {
310
+ "1": {
311
+ "progressbar": "17.14%",
312
+ "n_of_votes": 6,
313
+ "vote": "1"
314
+ },
315
+ "2": {
316
+ "progressbar": "25.71%",
317
+ "n_of_votes": 9,
318
+ "vote": "2"
319
+ },
320
+ "3": {
321
+ "progressbar": "8.57%",
322
+ "n_of_votes": 3,
323
+ "vote": "3"
324
+ },
325
+ "4": {
326
+ "progressbar": "0%",
327
+ "n_of_votes": 0,
328
+ "vote": 4
329
+ },
330
+ "5": {
331
+ "progressbar": "48.57%",
332
+ "n_of_votes": 17,
333
+ "vote": "5"
334
+ }
335
+ }
336
+ *
337
+ */
338
+ function yasrReturnToolbarStats (ratings) {
339
+ //Get the medium rating
340
+ const mediumRating = ratings.medium_rating;
341
 
342
+ //remove medium rating from the object, so I can loop only the ratings later
343
+ delete ratings['medium_rating'];
344
 
345
+ let highestNumberOfVotes = 0;
346
+ //loop a first time the array to get the highest number of votes
347
+ for (let i = 1; i <= 5; i++) {
348
+ if(i === 1) {
349
+ highestNumberOfVotes = ratings[i].n_of_votes;
350
+ } else {
351
+ if (ratings[i].n_of_votes > highestNumberOfVotes) {
352
+ highestNumberOfVotes = ratings[i].n_of_votes;
353
+ }
354
+ }
355
+ }
356
+ //Later, I need to get the number of digits of the highest number
357
+ let lengthHighestNumberOfVotes = Math.log(highestNumberOfVotes) * Math.LOG10E + 1 | 0;
358
 
359
+ //Later, I've to calculate the flexbasis based on the lenght of the nummber
360
+ //default flexbasis is 5%
361
+ let flexbasis = '5%'
362
 
363
+ //if the length of the number is less or equal of 3 digits (999)
364
+ //flexbasis is 5%
365
+ if(lengthHighestNumberOfVotes <= 3) {
366
+ flexbasis = '5%';
367
  }
368
+ //if the length of the number is major of 3 digits and less or equal of 5 digits (99999)
369
+ //flexbasis is 10%
370
+ if(lengthHighestNumberOfVotes > 3 && lengthHighestNumberOfVotes <= 5) {
371
+ flexbasis = '10%';
372
  }
373
+ //if highest of 5 digits, flexbasis is 15 % (note that this will break into a newline when 8 digits are
374
+ //reached, but I think that a number of 9,999,999 is enough
375
+ if(lengthHighestNumberOfVotes > 5) {
376
+ flexbasis = '15%';
377
  }
378
 
379
+ //prepare the html to return
380
+ let html_to_return = '<div class="yasr-visitors-stats-tooltip">';
381
+ html_to_return += '<span id="yasr-medium-rating-tooltip">'
382
+ + mediumRating
383
+ + ' '
384
+ + __('out of 5 stars', 'yet-another-stars-rating')
385
+ + '</span>';
386
+ html_to_return += '<div class="yasr-progress-bars-container">';
387
+
388
+ let stars_text = __('stars', 'yet-another-stars-rating'); //default is plural
389
+ let progressbar = 0; //default value for progressbar
390
+ let n_votes = 0; //default n_votes
391
 
392
+ //Do a for with 5 rows
393
+ for (let i = 5; i > 0; i--) {
394
+ if (i === 1) {
395
+ stars_text = __('star', 'yet-another-stars-rating'); //single form
396
+ }
397
+
398
+ //should never happen, just to be sage
399
+ if(typeof ratings[i] !== 'undefined') {
400
+ progressbar = ratings[i].progressbar;
401
+ n_votes = ratings[i].n_of_votes;
402
+ }
403
+
404
+ html_to_return += `<div class='yasr-progress-bar-row-container yasr-w3-container'>
405
+ <div class='yasr-progress-bar-name'>${i} ${stars_text}</div>
406
+ <div class='yasr-single-progress-bar-container'>
407
+ <div class='yasr-w3-border'>
408
+ <div class='yasr-w3-amber' style='height:17px;width:${progressbar}'></div>
409
+ </div>
410
+ </div>
411
+ <div class='yasr-progress-bar-votes-count' style="flex-basis:${flexbasis} ">${n_votes}</div>
412
+ </div>`;
413
+
414
+ } //End foreach
415
+
416
+ html_to_return += '</div></div>';
417
+
418
+ return html_to_return;
419
  }
420
+
421
+ /****** End tooltipfunction ******/
includes/js/src/shortcodes/yasr-log-users-fronted.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Vote user log
2
+ jQuery(document).ready(function () {
3
+ //Log
4
+ jQuery('.yasr-user-log-page-num').on('click', function () {
5
+ jQuery('#yasr-loader-user-log-metabox').show();
6
+ var data = {
7
+ action: 'yasr_change_user_log_page_front',
8
+ pagenum: jQuery(this).val(),
9
+ totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
10
+
11
+ };
12
+ jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
13
+ jQuery('#yasr-loader-log-metabox').hide();
14
+ jQuery('#yasr-user-log-container').html(response);
15
+ });
16
+ });
17
+
18
+ jQuery(document).ajaxComplete(function (event, xhr, settings) {
19
+ var isYasrAjaxCall = true;
20
+
21
+ if (typeof settings.data === 'undefined') {
22
+ return;
23
+ }
24
+
25
+ //check if the ajax call is done by yasr with action yasr_change_log_page
26
+ isYasrAjaxCall = settings.data.search("action=yasr_change_user_log_page_front");
27
+
28
+ if (isYasrAjaxCall !== -1) {
29
+ jQuery('.yasr-user-log-page-num').on('click', function () {
30
+ jQuery('#yasr-loader-user-log-metabox').show();
31
+
32
+ var data = {
33
+ action: 'yasr_change_user_log_page_front',
34
+ pagenum: jQuery(this).val(),
35
+ totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
36
+ };
37
+
38
+ jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
39
+ jQuery('#yasr-user-log-container').html(response); //This will hide the loader gif too
40
+ });
41
+ });
42
+
43
+ }
44
+
45
+ });
46
+
47
+ });
includes/js/yasr-front.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var t,e,a={d:(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};a.d({},{a:()=>T});var r=new Uint8Array(16);function n(){if(!e&&!(e="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 e(r)}const s=/^(?:[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,o=function(t){return"string"==typeof t&&s.test(t)};for(var i=[],l=0;l<256;++l)i.push((l+256).toString(16).substr(1));const c=function(t,e,a){var r=(t=t||{}).random||(t.rng||n)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var s=0;s<16;++s)e[a+s]=r[s];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase();if(!o(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function u(t){return(u="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})(t)}function d(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 m(t,e){return(m=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function g(t,e){return!e||"object"!==u(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function y(t){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var v=wp.i18n.__,f=wp.element.render;function p(t){var e="yasr-ranking-element-"+c(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return T(a,e,!1,.1,!0,t.rating)}})}function h(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",v("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",v("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 _(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===t&&(t=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),t.innerHTML=e;var a=t.textContent;return t.innerHTML="",a}(e.post.title)))}function b(t){var e="after",a=v("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(h,{post:t.post,tableId:t.tableId,text:a}),React.createElement(p,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(p,{rating:t.post.rating,tableId:t.tableId}),React.createElement(h,{post:t.post,tableId:t.tableId,text:a}))}function E(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(_,{colClass:e,post:t.post}),React.createElement(b,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function R(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(E,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}for(var k=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&&m(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=y(r);if(n){var a=y(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return g(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(v("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(v("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(v(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(v(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:v("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},v("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},v("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},v("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},v("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,"Post"),React.createElement("th",null,v("Order By","yet-another-stars-rating-pro"),":  ",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(R,{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(R,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(R,{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,v("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&d(e.prototype,a),o}(),I=wp.i18n.__,w=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],C=0;C<w.length;C++)L(w[C]);function L(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;T(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=B(n),s=B(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,v="yasr-vv-loader-"+l,f=document.getElementById(m),p=document.getElementById(g),h=document.getElementById(y),_=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){null!==_&&(_.innerHTML=yasrCommonData.loaderHtml);var b={action:"yasr_load_vv",post_id:o};jQuery.get(yasrCommonData.ajaxurl,b).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),S(c,r,o,e,i,0,u,d,f,p,_,h),!0!==n&&(null!==f&&(f.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==p&&(p.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,a,l){console.info(I("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),S(c,r,o,s,i,0,u,d,f,p,_,h),!0!==n&&(h.style.display="")}))}else S(c,r,o,s,i,0,u,d,f,p,_,h)}}(e)}(e),"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(x(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=B(o);T(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var 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 n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function x(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 i=I("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=I("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</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(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+"</div></div>"}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 S(t,e,a,r,n,s,o,i,l,c,u,d){e=parseFloat(e),r=B(r);var m=document.getElementById(n);null!==u&&(u.innerHTML=""),T(t,n,m,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(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!==l&&(l.innerHTML=e),null!==c&&(c.innerHTML=a)):r=t.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function B(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){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);f(React.createElement(k,{source:r,tableId:a,params:n,nonce:s}),o)}}()})();
1
+ (()=>{"use strict";function t(t,e,r=!1,s=.1,a=!0,i=!1,n=!1){let o;o=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:o,step:s,readOnly:a,rating:i,rateCallback:n})}const{__:e}=wp.i18n,r=["yasr-rater-stars","yasr-rater-stars-vv","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&&"yasr-ranking-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),a=s.id;t(s.getAttribute("data-rater-starsize"),a,s)}}(r),"yasr-multiset-visitors-rater"===e&&function(e){var r="",s=[];for(let a=0;a<e.length;a++)!function(a){if(!1!==e.item(a).classList.contains("yasr-star-rating"))return;let i=e.item(a),n=i.id,o=i.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,i,1,o,!1,(function(t,e){const a=i.getAttribute("data-rater-postid"),n=i.getAttribute("data-rater-setid"),o=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);const l=parseInt(t);this.setRating(l),r={postid:a,setid:n,field:o,rating:l},s.push(r),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 a={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:s,set_id:e};jQuery.post(yasrCommonData.ajaxurl,a,(function(r){let s;s=(r=JSON.parse(r)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(s)}))}))}(r))}})();
includes/shortcodes/classes/YasrNoStarsRankings.php CHANGED
@@ -81,18 +81,18 @@ class YasrNoStarsRankings extends YasrShortcode {
81
  */
82
  private function returnTableHeader() {
83
  if($this->shortcode_name === 'yasr_most_active_users' || 'yasr_top_ten_active_users') {
84
- $first_header = 'User';
85
- $second_header = 'Number of votes';
86
  } else {
87
- $first_header = 'Author';
88
- $second_header = 'Reviews';
89
  }
90
 
91
  return '<table class="yasr-rankings">
92
  <thead>
93
  <tr class="yasr-rankings-td-colored">
94
- <th>' . sprintf(__('%s', 'yet-another-stars-rating'),$first_header) . '</th>
95
- <th>' . sprintf(__('%s', 'yet-another-stars-rating'),$second_header) . '</th>
96
  </tr>
97
  </thead>';
98
  }
81
  */
82
  private function returnTableHeader() {
83
  if($this->shortcode_name === 'yasr_most_active_users' || 'yasr_top_ten_active_users') {
84
+ $first_header = __('User', 'yet-another-stars-rating');
85
+ $second_header = __('Number of votes', 'yet-another-stars-rating');
86
  } else {
87
+ $first_header = __('Author', 'yet-another-stars-rating');
88
+ $second_header = __('Reviews', 'yet-another-stars-rating');
89
  }
90
 
91
  return '<table class="yasr-rankings">
92
  <thead>
93
  <tr class="yasr-rankings-td-colored">
94
+ <th>' . $first_header . '</th>
95
+ <th>' . $second_header . '</th>
96
  </tr>
97
  </thead>';
98
  }
includes/shortcodes/classes/YasrRankings.php CHANGED
@@ -33,6 +33,7 @@ class YasrRankings extends YasrShortcode {
33
 
34
  public function __construct($atts, $shortcode_name) {
35
  parent::__construct($atts, $shortcode_name);
 
36
  $this->ajax_nonce_rankings = wp_create_nonce("yasr_nonce_rankings");
37
  }
38
 
33
 
34
  public function __construct($atts, $shortcode_name) {
35
  parent::__construct($atts, $shortcode_name);
36
+
37
  $this->ajax_nonce_rankings = wp_create_nonce("yasr_nonce_rankings");
38
  }
39
 
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -43,6 +43,8 @@ abstract class YasrShortcode
43
  public $shortcode_name ;
44
  public function __construct( $atts, $shortcode_name )
45
  {
 
 
46
  $this->shortcode_name = $shortcode_name;
47
 
48
  if ( $atts !== false ) {
@@ -68,6 +70,39 @@ abstract class YasrShortcode
68
 
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  /**
72
  * Return the stars size according to size attribute in shortcode.
73
  * If not used, return 32 (default value)
43
  public $shortcode_name ;
44
  public function __construct( $atts, $shortcode_name )
45
  {
46
+ //Enqueue Scripts
47
+ $this->enqueueScripts();
48
  $this->shortcode_name = $shortcode_name;
49
 
50
  if ( $atts !== false ) {
70
 
71
  }
72
 
73
+ /**
74
+ * Enqueue js scripts
75
+ * Js files for vv shortcodes are loaded with method in his own class
76
+ *
77
+ * @author Dario Curvino <@dudo>
78
+ * @since 2.8.5
79
+ */
80
+ public function enqueueScripts()
81
+ {
82
+ //scripts required for all shortocdes
83
+ yasr_enqueue_includes_js_scripts();
84
+ $called_class = static::class;
85
+ if ( $called_class === 'YasrOverallRating' || $called_class === 'YasrMultiSet' || $called_class === 'YasrVisitorMultiSet' ) {
86
+ wp_enqueue_script(
87
+ 'yasr-ov-multi',
88
+ YASR_JS_DIR_INCLUDES . 'shortcodes/overall-multiset.js',
89
+ array( 'jquery', 'rater', 'wp-i18n' ),
90
+ YASR_VERSION_NUM,
91
+ true
92
+ );
93
+ }
94
+ if ( $called_class === 'YasrRankings' || $called_class === 'YasrNoStarsRankings' ) {
95
+ wp_enqueue_script(
96
+ 'yasr-rankings',
97
+ YASR_JS_DIR_INCLUDES . 'shortcodes/rankings.js',
98
+ array( 'jquery', 'rater', 'wp-element' ),
99
+ YASR_VERSION_NUM,
100
+ true
101
+ );
102
+ }
103
+ do_action( 'yasr_enqueue_assets_shortcode' );
104
+ }
105
+
106
  /**
107
  * Return the stars size according to size attribute in shortcode.
108
  * If not used, return 32 (default value)
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -30,6 +30,7 @@ class YasrVisitorVotes extends YasrShortcode {
30
  protected $is_singular;
31
  protected $unique_id;
32
  protected $ajax_nonce_visitor;
 
33
 
34
  public function __construct($atts, $shortcode_name) {
35
  parent::__construct($atts, $shortcode_name);
@@ -46,6 +47,8 @@ class YasrVisitorVotes extends YasrShortcode {
46
  $this->shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
47
  $this->shortcode_html .= "<div id='yasr_visitor_votes_$this->post_id' class='yasr-visitor-votes'>";
48
 
 
 
49
  }
50
 
51
  /**
@@ -106,6 +109,45 @@ class YasrVisitorVotes extends YasrShortcode {
106
 
107
  } //end function
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  /**
111
  * Return YASR VV in read only
@@ -136,6 +178,8 @@ class YasrVisitorVotes extends YasrShortcode {
136
 
137
  $shortcode_html = $container . $stars . $end_container;
138
 
 
 
139
  //Use this filter to customize yasr_visitor_votes readonly
140
  return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes);
141
  }
@@ -356,6 +400,10 @@ class YasrVisitorVotes extends YasrShortcode {
356
  }
357
  } //End if $yasr_plugin_imported
358
 
 
 
 
 
359
  return $span_dashicon;
360
  }
361
 
@@ -383,6 +431,8 @@ class YasrVisitorVotes extends YasrShortcode {
383
  $this->shortcode_html .= '</div>'; //close all
384
  $this->shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
385
 
 
 
386
  return $this->shortcode_html;
387
  }
388
  }
30
  protected $is_singular;
31
  protected $unique_id;
32
  protected $ajax_nonce_visitor;
33
+ protected $tippy_loaded;
34
 
35
  public function __construct($atts, $shortcode_name) {
36
  parent::__construct($atts, $shortcode_name);
47
  $this->shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
48
  $this->shortcode_html .= "<div id='yasr_visitor_votes_$this->post_id' class='yasr-visitor-votes'>";
49
 
50
+ $this->tippy_loaded = false;
51
+
52
  }
53
 
54
  /**
109
 
110
  } //end function
111
 
112
+ /**
113
+ * Load visitorVotes.js if needed
114
+ *
115
+ * @author Dario Curvino <@dudo>
116
+ * @since 2.8.5
117
+ */
118
+ public function loadVVScripts() {
119
+ $array_dep = array('jquery', 'rater', 'wp-i18n');
120
+
121
+ if($this->tippy_loaded === true) {
122
+ $array_dep[] = 'tippy';
123
+ }
124
+
125
+ wp_enqueue_script(
126
+ 'yasr-front-vv',
127
+ YASR_JS_DIR_INCLUDES . 'shortcodes/visitorVotes.js',
128
+ $array_dep,
129
+ YASR_VERSION_NUM,
130
+ true
131
+ );
132
+ }
133
+
134
+ /**
135
+ * Load tippy if needed
136
+ *
137
+ * @author Dario Curvino <@dudo>
138
+ * @since 2.8.5
139
+ */
140
+ public function loadTippy() {
141
+ wp_enqueue_script(
142
+ 'tippy',
143
+ YASR_JS_DIR_INCLUDES . 'tippy.all.min.js',
144
+ '',
145
+ '3.6.0',
146
+ true
147
+ );
148
+
149
+ $this->tippy_loaded = true;
150
+ }
151
 
152
  /**
153
  * Return YASR VV in read only
178
 
179
  $shortcode_html = $container . $stars . $end_container;
180
 
181
+ $this->loadVVScripts();
182
+
183
  //Use this filter to customize yasr_visitor_votes readonly
184
  return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes);
185
  }
400
  }
401
  } //End if $yasr_plugin_imported
402
 
403
+ if($span_dashicon !== '') {
404
+ $this->loadTippy();
405
+ }
406
+
407
  return $span_dashicon;
408
  }
409
 
431
  $this->shortcode_html .= '</div>'; //close all
432
  $this->shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
433
 
434
+ $this->loadVVScripts();
435
+
436
  return $this->shortcode_html;
437
  }
438
  }
includes/shortcodes/yasr-shortcode-functions.php CHANGED
@@ -222,4 +222,15 @@ function yasr_visitor_multi_set_ranking_callback($atts, $content, $shortcode_tag
222
  $yasr_ranking = new YasrRankings($atts, $shortcode_tag);
223
 
224
  return $yasr_ranking->returnMultiVisitor($atts);
225
- } //End function
 
 
 
 
 
 
 
 
 
 
 
222
  $yasr_ranking = new YasrRankings($atts, $shortcode_tag);
223
 
224
  return $yasr_ranking->returnMultiVisitor($atts);
225
+ } //End function
226
+
227
+ /**
228
+ * Add shortcode yasr_users_log_frontend and the ajax action
229
+ */
230
+ add_shortcode('yasr_user_rate_history', 'yasr_users_front_widget_callback');
231
+ add_action('wp_ajax_yasr_change_user_log_page_front', 'yasr_users_front_widget_callback');
232
+ function yasr_users_front_widget_callback() {
233
+ $log_widget = new YasrLogDashboardWidget();
234
+ return $log_widget->userWidgetShortcode();
235
+ } //End callback function
236
+
includes/yasr-includes-functions.php CHANGED
@@ -22,50 +22,30 @@ if (!defined('ABSPATH')) {
22
  exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
25
- /***** Adding javascript and css needed on both admin and public *****/
26
  add_action('wp_enqueue_scripts', 'yasr_add_scripts_includes', 11);
27
  add_action('admin_enqueue_scripts', 'yasr_add_scripts_includes', 11);
28
 
29
  function yasr_add_scripts_includes() {
30
- wp_enqueue_script('jquery');
31
-
32
- wp_enqueue_script(
33
- 'tippy',
34
- YASR_JS_DIR_INCLUDES . 'tippy.all.min.js',
35
- '',
36
- '3.6.0',
37
- true
38
- );
39
-
40
- wp_enqueue_script(
41
- 'rater',
42
- YASR_JS_DIR_INCLUDES .
43
- 'rater-js.min.js',
44
- '',
45
- YASR_VERSION_NUM,
46
- true
47
- );
48
 
49
  $yasr_visitor_votes_loader = '<div id="loader-visitor-rating" style="display: inline-block">&nbsp; '.
50
  ' <img src=' . YASR_IMG_DIR . 'loader.gif title="yasr-loader" alt="yasr-loader"></div>';
51
 
52
- if(is_admin()) {
53
- define ('YASR_HANDLE_SCRIPT', 'yasradmin');
54
- } else {
55
- define ('YASR_HANDLE_SCRIPT', 'yasrfront');
56
- }
57
-
58
- wp_localize_script(YASR_HANDLE_SCRIPT, 'yasrCommonData',
59
- array(
60
- 'restEndpoint' => esc_url_raw(rest_url()),
61
- 'adminUrl' => admin_url(),
62
- 'ajaxurl' => admin_url('admin-ajax.php'),
63
- 'visitorStatsEnabled' => YASR_VISITORS_STATS,
64
- 'ajaxEnabled' => YASR_ENABLE_AJAX,
65
- 'loaderHtml' => $yasr_visitor_votes_loader,
66
- 'nonce' => wp_create_nonce('wp_rest'),
67
- 'isRtl' => json_encode(is_rtl())
68
- )
69
  );
70
 
71
  $yasr_multiset_theme_handle = 'yasrcsslightscheme';
@@ -143,6 +123,29 @@ function yasr_rtl_support() {
143
  }
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  /****** Translating YASR ******/
148
  add_action('init', 'yasr_translate');
22
  exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
25
+ /***** Adding global js and css needed on both admin and public *****/
26
  add_action('wp_enqueue_scripts', 'yasr_add_scripts_includes', 11);
27
  add_action('admin_enqueue_scripts', 'yasr_add_scripts_includes', 11);
28
 
29
  function yasr_add_scripts_includes() {
30
+ //This is required to use wp_add_inline_script without dependency
31
+ //https://wordpress.stackexchange.com/a/311279/48442
32
+ wp_register_script( 'yasr-global-data', '', [], '', true );
33
+ wp_enqueue_script( 'yasr-global-data' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  $yasr_visitor_votes_loader = '<div id="loader-visitor-rating" style="display: inline-block">&nbsp; '.
36
  ' <img src=' . YASR_IMG_DIR . 'loader.gif title="yasr-loader" alt="yasr-loader"></div>';
37
 
38
+ $yasr_common_data = json_encode(array(
39
+ 'ajaxurl' => admin_url('admin-ajax.php'),
40
+ 'visitorStatsEnabled' => YASR_VISITORS_STATS,
41
+ 'ajaxEnabled' => YASR_ENABLE_AJAX,
42
+ 'loaderHtml' => $yasr_visitor_votes_loader,
43
+ ));
44
+
45
+ wp_add_inline_script(
46
+ 'yasr-global-data',
47
+ 'const yasrCommonData = ' . $yasr_common_data,
48
+ 'before'
 
 
 
 
 
 
49
  );
50
 
51
  $yasr_multiset_theme_handle = 'yasrcsslightscheme';
123
  }
124
  }
125
 
126
+ /**
127
+ * This function enqueue the js scripts required on both admin and frontend
128
+ *
129
+ * @author Dario Curvino <@dudo>
130
+ * @since 2.8.5
131
+ */
132
+
133
+ function yasr_enqueue_includes_js_scripts() {
134
+ wp_enqueue_script('jquery');
135
+
136
+ wp_enqueue_script(
137
+ 'rater',
138
+ YASR_JS_DIR_INCLUDES .
139
+ 'rater-js.min.js',
140
+ '',
141
+ YASR_VERSION_NUM,
142
+ true
143
+ );
144
+
145
+ }
146
+
147
+
148
+
149
 
150
  /****** Translating YASR ******/
151
  add_action('init', 'yasr_translate');
public/yasr-public-actions.php CHANGED
@@ -42,14 +42,6 @@ function yasr_add_scripts() {
42
  );
43
  }
44
 
45
- wp_enqueue_script(
46
- 'yasrfront',
47
- YASR_JS_DIR_INCLUDES . 'yasr-front.js',
48
- array('jquery', 'tippy', 'rater', 'wp-i18n', 'wp-element'),
49
- YASR_VERSION_NUM,
50
- true
51
- );
52
-
53
  do_action('yasr_add_front_script_js');
54
 
55
  }
42
  );
43
  }
44
 
 
 
 
 
 
 
 
 
45
  do_action('yasr_add_front_script_js');
46
 
47
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
  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.8
7
- Stable tag: 2.8.4
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
@@ -121,6 +121,10 @@ Further, it comes with a lot of hooks, you can find more info [here](https://yet
121
 
122
  Do you want more feature? [Check out Yasr Pro!](https://yetanotherstarsrating.com/#yasr-pro)
123
 
 
 
 
 
124
  == Installation ==
125
  1. Navigate to Dashboard -> Plugins -> Add New and search for YASR
126
  2. Click on "Installa Now" and than "Activate"
@@ -193,6 +197,13 @@ Yes, YASR is 100% fully compatible with PHP 8
193
 
194
  The full changelog can be found in the plugin's directory. Recent entries:
195
 
 
 
 
 
 
 
 
196
  = 2.8.4 =
197
  * ENHANCEMENT: All gutenberg's blocks have been updated to apiVersion 2. This mean that YASR now requires at least
198
  WordPress version 5.6
@@ -204,9 +215,11 @@ WordPress version 5.6
204
  * FIXED: link to trial page
205
  * TWEAKED: added some hooks
206
 
 
207
  = 2.8.2 =
208
  * FIXED: if "Enable stars next to the title?" is activated, the ratings also appears in rss feed.
209
 
 
210
  = 2.8.1 =
211
  * FIXED: error that could occurs in some circumstances
212
 
3
  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.8.5
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
121
 
122
  Do you want more feature? [Check out Yasr Pro!](https://yetanotherstarsrating.com/#yasr-pro)
123
 
124
+ == Press ==
125
+ [Tutorial by Qode Magazine](https://qodeinteractive.com/magazine/how-to-add-post-rating-to-your-wordpress-website/)
126
+ [Tutorial by Greengeeks](https://www.greengeeks.com/tutorials/star-rating-system-yasr-wordpress/)
127
+
128
  == Installation ==
129
  1. Navigate to Dashboard -> Plugins -> Add New and search for YASR
130
  2. Click on "Installa Now" and than "Activate"
197
 
198
  The full changelog can be found in the plugin's directory. Recent entries:
199
 
200
+ = 2.8.5 =
201
+ * TWEAKED: YASR js assets are now loaded only if shortcode exists, and every shortcode has is ows js file. This will reduce
202
+ the unused js code, increasing lighthouse/pagespeed results.
203
+ * NEW FEATURE: new shortcode, ' yasr_user_rate_history ' : this will works only for logged in users, and will show
204
+ all the ratings that the user has give.
205
+ * FIX: js console error in widget page
206
+
207
  = 2.8.4 =
208
  * ENHANCEMENT: All gutenberg's blocks have been updated to apiVersion 2. This mean that YASR now requires at least
209
  WordPress version 5.6
215
  * FIXED: link to trial page
216
  * TWEAKED: added some hooks
217
 
218
+
219
  = 2.8.2 =
220
  * FIXED: if "Enable stars next to the title?" is activated, the ratings also appears in rss feed.
221
 
222
+
223
  = 2.8.1 =
224
  * FIXED: error that could occurs in some circumstances
225
 
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.8.4
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.8.4' );
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.8.5
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.8.5' );
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__ );