Yasr – Yet Another Stars Rating - Version 2.8.4

Version Description

  • ENHANCEMENT: All gutenberg's blocks have been updated to apiVersion 2. This mean that YASR now requires at least WordPress version 5.6
  • FIX: some errors that occur using yasr_overall_rating and yasr_visitor_votes gutenberg blocks
  • ENHANCEMENT: All gutenberg's blocks now support alignment
Download this release

Release Info

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

Code changes from version 2.8.3 to 2.8.4

admin/editor/YasrEditorHooks.php ADDED
@@ -0,0 +1,703 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Every hooks related to edit page are here
26
+ *
27
+ * @author Dario Curvino <@dudo>
28
+ * @since 2.8.4
29
+ * Class YasrEditorHooks
30
+ */
31
+
32
+ class YasrEditorHooks {
33
+
34
+ public function init() {
35
+
36
+ //enqueue gutenberg stuff outside blocks
37
+ add_action('enqueue_block_editor_assets', array($this, 'initGutenMisc'));
38
+
39
+ add_action('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);
43
+
44
+ //Add yasr constant in gutenberg
45
+ add_action('yasr_add_admin_scripts_end', array($this, 'addJsConstantInGutenberg'));
46
+
47
+ //Save auto insert value to yasrConstantGutenberg
48
+ add_filter('yasr_gutenberg_constants', array($this, 'yasrGutenbergConstants'));
49
+
50
+ // Create 2 metaboxes in post and pages
51
+ add_action('add_meta_boxes', array($this, 'addMetaboxes'));
52
+
53
+ // Add a media content button
54
+ add_action('media_buttons', array($this, 'tinymceButton'), 99);
55
+
56
+ // Create the content for the button shortcode in Tinymce
57
+ //Add ajax action that will be called from the .js for button in tinymce
58
+ add_action('wp_ajax_yasr_create_shortcode', array($this, 'tinymceButtonContent'));
59
+
60
+ // Get Set name from post or page and output the set used in yasr-metabox-multiple-rating
61
+ add_action('wp_ajax_yasr_send_id_nameset', array($this, 'metaboxOutputMultisets'));
62
+
63
+ $yasr_save_post = new YasrOnSavePost();
64
+ add_action('save_post', array($yasr_save_post, 'yasrSavePost'));
65
+
66
+ }
67
+
68
+ //this load guten-block.js, only in admin side
69
+ public function initGutenMisc() {
70
+ //I need to enqueue this only in post-new.php or post.php
71
+ $current_screen = get_current_screen();
72
+ if (property_exists($current_screen, 'base')) {
73
+ if ($current_screen->base === 'post') {
74
+ //Script
75
+ wp_enqueue_script(
76
+ 'yasr-gutenberg',
77
+ YASR_JS_GUTEN . 'yasr-guten-misc.js', array(
78
+ 'wp-blocks',
79
+ 'wp-components',
80
+ 'wp-editor',
81
+ 'wp-edit-post',
82
+ 'wp-element',
83
+ 'wp-i18n',
84
+ 'wp-plugins',
85
+ )
86
+ );
87
+ }
88
+ }
89
+ }
90
+
91
+ public function initGutenBlocks() {
92
+ $this->register_overall_block();
93
+ $this->register_vv_block();
94
+ $this->register_ranking_block();
95
+ $this->register_nostars_rankings();
96
+ }
97
+
98
+ /**
99
+ * @author Dario Curvino <@dudo>
100
+ * @since 2.8.4
101
+ */
102
+ private function register_overall_block() {
103
+ wp_register_script(
104
+ 'yasr-overall-block',
105
+ YASR_JS_GUTEN_BLOCKS . 'overallRating.js',
106
+ array(
107
+ 'wp-blocks',
108
+ 'wp-block-editor',
109
+ 'wp-components',
110
+ 'wp-element',
111
+ 'wp-i18n',
112
+ ),
113
+ 1
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',
121
+ 'title' => __('Yasr: Overall Rating', 'yet-another-stars-rating'),
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
+ }
133
+
134
+ /**
135
+ * @author Dario Curvino <@dudo>
136
+ * @since 2.8.4
137
+ */
138
+ private function register_vv_block() {
139
+ wp_register_script(
140
+ 'yasr-vv-block',
141
+ YASR_JS_GUTEN_BLOCKS . 'visitorVotes.js',
142
+ array(
143
+ 'wp-blocks',
144
+ 'wp-block-editor',
145
+ 'wp-components',
146
+ 'wp-element',
147
+ 'wp-i18n',
148
+ ),
149
+ 1
150
+ );
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
+ }
159
+
160
+ /**
161
+ * @author Dario Curvino <@dudo>
162
+ * @since 2.8.4
163
+ */
164
+ private function register_ranking_block() {
165
+ wp_register_script(
166
+ 'yasr-rankings-blocks',
167
+ YASR_JS_GUTEN_BLOCKS . 'rankings.js',
168
+ array(
169
+ 'wp-blocks',
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
+ }
192
+
193
+ /**
194
+ * @author Dario Curvino <@dudo>
195
+ * @since 2.8.4
196
+ */
197
+ private function register_nostars_rankings() {
198
+ wp_register_script(
199
+ 'yasr-nostars-rankings-blocks',
200
+ YASR_JS_GUTEN_BLOCKS . 'noStarsRankings.js',
201
+ array(
202
+ 'wp-blocks',
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
+ }
225
+
226
+ /**
227
+ * Adds a category in gutenberg blocks list
228
+ *
229
+ * @author Dario Curvino <@dudo>
230
+ * @param $categories
231
+ *
232
+ * @return array
233
+ */
234
+ public function addGutenbergCategory($categories) {
235
+ return array_merge(
236
+ $categories,
237
+ array(
238
+ array(
239
+ 'slug' => 'yet-another-stars-rating',
240
+ 'title' => 'Yasr: Yet Another Stars Rating',
241
+ ),
242
+ )
243
+ );
244
+ }
245
+
246
+ public function addJsConstantInGutenberg($hook) {
247
+ if (($hook === 'post.php' || $hook === 'post-new.php') && yasr_is_gutenberg_page() ) {
248
+
249
+ //create an empty array
250
+ $constants_array = array();
251
+
252
+ //apply filters to empty array
253
+ $constants_array = apply_filters('yasr_gutenberg_constants', $constants_array);
254
+
255
+ //sanitize
256
+ $constants_array = filter_var_array($constants_array,FILTER_SANITIZE_STRING);
257
+
258
+ if(is_array($constants_array) && !empty($constants_array)) {
259
+ wp_localize_script(
260
+ 'yasradmin',
261
+ 'yasrConstantGutenberg',
262
+ $constants_array
263
+ );
264
+ }
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Hook into yasr_gutenberg_constants to add constants used in Gutenberg
270
+ *
271
+ * @author Dario Curvino <@dudo>
272
+ * @param $constants_array
273
+ *
274
+ * @return array
275
+ */
276
+ public function yasrGutenbergConstants($constants_array) {
277
+
278
+ //add after
279
+ if (YASR_AUTO_INSERT_ENABLED === 1) {
280
+ $auto_insert = YASR_AUTO_INSERT_WHAT;
281
+ } else {
282
+ $auto_insert = 'disabled';
283
+ }
284
+
285
+ $auto_insert_array = array (
286
+ 'adminurl' => get_admin_url(),
287
+ 'autoInsert' => $auto_insert
288
+ );
289
+
290
+ return $constants_array + $auto_insert_array;
291
+ }
292
+
293
+ /**
294
+ * Adds to metaboxes
295
+ *
296
+ * @author Dario Curvino <@dudo>
297
+ */
298
+ public function addMetaboxes() {
299
+
300
+ //Default post type where display metabox
301
+ $post_type_where_display_metabox = array('post', 'page');
302
+
303
+ //get the custom post type
304
+ $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
305
+
306
+ if ($custom_post_types) {
307
+ //First merge array then changes keys to int
308
+ $post_type_where_display_metabox = array_values(array_merge($post_type_where_display_metabox, $custom_post_types));
309
+ }
310
+
311
+ //For classic editor, add this metabox
312
+ foreach ($post_type_where_display_metabox as $post_type) {
313
+ add_meta_box(
314
+ 'yasr_metabox_overall_rating',
315
+ 'YASR',
316
+ array($this, 'yasr_metabox_overall_rating_content'),
317
+ $post_type,
318
+ 'side',
319
+ 'high',
320
+ //Set this to true, so this metabox will be only loaded to classic editor
321
+ array(
322
+ '__back_compat_meta_box' => true,
323
+ )
324
+ );
325
+ }
326
+
327
+ foreach ($post_type_where_display_metabox as $post_type) {
328
+ add_meta_box(
329
+ 'yasr_metabox_below_editor_metabox',
330
+ __('Yet Another Stars Rating', 'yet-another-stars-rating'),
331
+ array($this, 'yasr_metabox_below_editor_metabox_callback'),
332
+ $post_type,
333
+ 'normal',
334
+ 'high'
335
+ );
336
+ }
337
+
338
+ } //End function
339
+
340
+ /**
341
+ * Metabox for classic editor
342
+ *
343
+ * @author Dario Curvino <@dudo>
344
+ */
345
+ public function yasr_metabox_overall_rating_content() {
346
+ if (current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
347
+ include(YASR_ABSOLUTE_PATH_ADMIN . '/editor/yasr-metabox-top-right.php');
348
+ } else {
349
+ _e('You don\'t have enought privileges to insert Overall Rating', 'yet-another-stars-rating');
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Metabox below editor
355
+ *
356
+ * @author Dario Curvino <@dudo>
357
+ */
358
+ public function yasr_metabox_below_editor_metabox_callback() {
359
+ if (current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
360
+ include(YASR_ABSOLUTE_PATH_ADMIN . '/editor/yasr-metabox-below-editor.php');
361
+ } else {
362
+ _e('You don\'t have enough privileges to insert a Multi Set', 'yet-another-stars-rating');
363
+ }
364
+ }
365
+
366
+ /**
367
+ * Add YASR button for tinymce
368
+ *
369
+ * @author Dario Curvino <@dudo>
370
+ */
371
+ public function tinymceButton() {
372
+ if (is_admin()) {
373
+ add_thickbox();
374
+ echo '<a href="#TB_inline?width=530&height=600&inlineId=yasr-tinypopup-form"
375
+ id="yasr-shortcode-creator"
376
+ class="button thickbox">
377
+ <span class="dashicons dashicons-star-half" style="vertical-align: middle;"></span> Yasr Shortcode
378
+ </a>';
379
+
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Ajax Callback for tinymce button
385
+ *
386
+ * @author Dario Curvino <@dudo>
387
+ */
388
+ public function tinymceButtonContent() {
389
+ if (!isset($_GET['action'])) {
390
+ exit();
391
+ }
392
+ global $wpdb;
393
+ $multi_set = YasrMultiSetData::returnMultiSetNames();
394
+ $n_multi_set = $wpdb->num_rows;
395
+
396
+ ?>
397
+
398
+ <div id="yasr-tinypopup-form">
399
+ <h2 class="nav-tab-wrapper yasr-underline">
400
+ <a href="#" id="yasr-link-tab-main"
401
+ class="nav-tab nav-tab-active yasr-nav-tab"><?php _e("Main", 'yet-another-stars-rating'); ?></a>
402
+ <a href="#" id="yasr-link-tab-charts"
403
+ class="nav-tab yasr-nav-tab"><?php _e("Rankings", 'yet-another-stars-rating'); ?></a>
404
+ <?php do_action('yasr_add_tabs_on_tinypopupform'); ?>
405
+
406
+ <a href="https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen"
407
+ target="_blank"
408
+ id="yasr-tinypopup-link-doc">
409
+ <?php _e('Read the doc', 'yet-another-stars-rating'); ?>
410
+ </a>
411
+ </h2>
412
+
413
+ <div id="yasr-content-tab-main" class="yasr-content-tab-tinymce">
414
+ <table id="yasr-table-tiny-popup-main" class="form-table">
415
+
416
+ <tr>
417
+ <th>
418
+ <label for="yasr-overall">
419
+ <?php _e('Overall Rating', 'yet-another-stars-rating'); ?>
420
+ </label>
421
+ </th>
422
+ <td>
423
+ <input
424
+ type="button"
425
+ class="button-primary"
426
+ id="yasr-overall"
427
+ name="yasr-overall"
428
+ value="<?php _e('Insert Overall Rating', 'yet-another-stars-rating'); ?>"
429
+ />
430
+ <br/>
431
+ <small>
432
+ <?php _e('Insert the author rating', 'yet-another-stars-rating'); ?>
433
+ </small>
434
+
435
+ <div id="yasr-overall-choose-size">
436
+ <small>
437
+ <?php _e('Choose Size', 'yet-another-stars-rating'); ?>
438
+ </small>
439
+ <div class="yasr-tinymce-button-size">
440
+ <?php
441
+ echo self::yasr_tinymce_return_button('yasr_overall_rating');
442
+ ?>
443
+ </div>
444
+ </div>
445
+
446
+ </td>
447
+ </tr>
448
+
449
+ <tr>
450
+ <th>
451
+ <label for="yasr-id">
452
+ <?php _e("Visitor Votes", 'yet-another-stars-rating'); ?>
453
+ </label>
454
+ </th>
455
+ <td>
456
+ <input type="button" class="button-primary" name="yasr-visitor-votes" id="yasr-visitor-votes"
457
+ value="<?php _e("Insert Visitor Votes", 'yet-another-stars-rating'); ?>"/><br/>
458
+ <small>
459
+ <?php _e('Insert the ability for your visitors to vote', 'yet-another-stars-rating'); ?>
460
+ </small>
461
+
462
+ <div id="yasr-visitor-choose-size">
463
+ <small>
464
+ <?php _e("Choose Size", 'yet-another-stars-rating'); ?>
465
+ </small>
466
+ <div class="yasr-tinymce-button-size">
467
+ <?php
468
+ echo self::yasr_tinymce_return_button('yasr_visitor_votes');
469
+ ?>
470
+ </div>
471
+ </div>
472
+ </td>
473
+ </tr>
474
+
475
+ <?php if ($n_multi_set > 0) { //If multiple Set are found ?>
476
+ <tr>
477
+ <th>
478
+ <?php _e("Insert Multiset:", 'yet-another-stars-rating'); ?>
479
+ </th>
480
+ <td>
481
+ <?php foreach ($multi_set as $name) { ?>
482
+ <label>
483
+ <input type="radio" value="<?php echo $name->set_id ?>" name="yasr_tinymce_pick_set"
484
+ class="yasr_tinymce_select_set">
485
+ <?php echo $name->set_name ?>
486
+ </label>
487
+ <br/>
488
+ <?php } //End foreach ?>
489
+ <small>
490
+ <?php _e('Choose wich set you want to insert.', 'yet-another-stars-rating'); ?>
491
+ </small>
492
+
493
+ <p>
494
+ <label for="yasr-allow-vote-multiset">
495
+ <input type="checkbox" id="yasr-allow-vote-multiset">
496
+ <?php _e("Readonly?", 'yet-another-stars-rating'); ?>
497
+ </label>
498
+ <br/>
499
+ </p>
500
+
501
+ <small>
502
+ <?php _e('If Readonly is checked, only you can insert the votes (in the box above the editor)',
503
+ 'yet-another-stars-rating'); ?>
504
+ </small>
505
+
506
+ <p>
507
+ <label for="yasr-hide-average-multiset">
508
+ <input type="checkbox" id="yasr-hide-average-multiset">
509
+ <?php _e("Hide Average?", 'yet-another-stars-rating'); ?>
510
+ </label>
511
+ <br/>
512
+ </p>
513
+
514
+ <p>
515
+ <input type="button" class="button-primary"
516
+ name="yasr-insert-multiset"
517
+ id="yasr-insert-multiset-select"
518
+ value="<?php _e("Insert Multi Set", 'yet-another-stars-rating') ?>"/
519
+ >
520
+ <br/>
521
+ </p>
522
+
523
+ </td>
524
+ </tr>
525
+ <?php
526
+ } //End if
527
+ ?>
528
+ </table>
529
+
530
+ </div>
531
+
532
+ <div id="yasr-content-tab-charts" class="yasr-content-tab-tinymce" style="display:none">
533
+
534
+ <table id="yasr-table-tiny-popup-charts" class="form-table">
535
+ <tr>
536
+ <th>
537
+ <label for="yasr-10-overall">
538
+ <?php _e("Ranking by overall rating", 'yet-another-stars-rating'); ?>
539
+ </label>
540
+ </th>
541
+ <td>
542
+ <?php
543
+ echo self::yasr_tinymce_return_button(
544
+ 'yasr_ov_ranking', 'Insert Ranking reviews'
545
+ )
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>
553
+ </tr>
554
+
555
+ <tr>
556
+ <th>
557
+ <label for="yasr-10-highest-most-rated">
558
+ <?php _e('Ranking by visitors votes', 'yet-another-stars-rating'); ?>
559
+ </label>
560
+ </th>
561
+ <td>
562
+ <?php
563
+ echo self::yasr_tinymce_return_button(
564
+ 'yasr_most_or_highest_rated_posts', 'Insert Users ranking'
565
+ )
566
+ ?>
567
+ <br/>
568
+ <small>
569
+ <?php _e(
570
+ 'This ranking shows both the highest and most rated posts rated through the
571
+ yasr_visitor_votes shortcode. For an item to appear in this chart, it has to be rated at least twice. ',
572
+ 'yet-another-stars-rating'); ?>
573
+ </small>
574
+ </td>
575
+ </tr>
576
+
577
+ <tr>
578
+ <th>
579
+ <label for="yasr-5-active-reviewers">
580
+ <?php _e('Most Active Authors', 'yet-another-stars-rating'); ?>
581
+ </label>
582
+ </th>
583
+ <td>
584
+ <?php
585
+ echo self::yasr_tinymce_return_button(
586
+ 'yasr_top_reviewers', 'Insert Most Active Reviewers'
587
+ )
588
+ ?>
589
+ <br/>
590
+ <small>
591
+ <?php
592
+ _e('This ranking shows the most active reviewers on your site.',
593
+ 'yet-another-stars-rating'); ?>
594
+ </small>
595
+ </td>
596
+ </tr>
597
+
598
+ <tr>
599
+ <th>
600
+ <label for="yasr-10-active-users">
601
+ <?php _e('Most Active Users', 'yet-another-stars-rating'); ?>
602
+ </label>
603
+ </th>
604
+ <td>
605
+ <?php
606
+ echo self::yasr_tinymce_return_button(
607
+ 'yasr_most_active_users', 'Insert Most Active Reviewers'
608
+ )
609
+ ?>
610
+ <br/>
611
+ <small>
612
+ <?php _e('This ranking shows the most active users, displaying the login name if logged in or “Anonymous” if not.',
613
+ 'yet-another-stars-rating'); ?>
614
+ </small>
615
+ </td>
616
+ </tr>
617
+
618
+ </table>
619
+
620
+ <div style="font-size: medium">
621
+ <?php
622
+ echo(
623
+ sprintf(__('%s Click here %s to customize the ranking and see a live preview',
624
+ 'yet-another-stars-rating'),
625
+ '<a href="options-general.php?page=yasr_settings_page&tab=rankings">', '</a>')
626
+ );
627
+ ?>
628
+ </div>
629
+
630
+ </div>
631
+
632
+ <?php do_action('yasr_add_content_on_tinypopupform'); ?>
633
+
634
+ </div>
635
+
636
+ <?php
637
+
638
+ die();
639
+
640
+ } //End callback function
641
+
642
+ /**
643
+ * @author Dario Curvino <@dudo>
644
+ * @since 2.6.5 returns button to be used in tinymce
645
+ *
646
+ * @param $shortcode
647
+ * @param bool $value
648
+ *
649
+ * @return string
650
+ */
651
+ public static function yasr_tinymce_return_button($shortcode, $value = false) {
652
+ $html_to_return = '';
653
+
654
+ if ($value === false) {
655
+ $array_size = array('Small', 'Medium', 'Large');
656
+
657
+ foreach ($array_size as $size) {
658
+ $size_low = strtolower($size);
659
+ $data_attribute = "[$shortcode size=\"$size_low\"]";
660
+
661
+ $html_to_return .= '<input type="button"
662
+ class="button-secondary yasr-tinymce-shortcode-buttons"
663
+ value="' . __($size, 'yet-another-stars-rating') . '"
664
+ data-shortcode=\'' . $data_attribute . '\'
665
+ />&nbsp;';
666
+ }
667
+ }
668
+ else {
669
+ $data_attribute = "[$shortcode]";
670
+ $html_to_return .= '<input type="button"
671
+ class="button-primary yasr-tinymce-shortcode-buttons"
672
+ value="' . __($value, 'yet-another-stars-rating') . '"
673
+ data-shortcode=\'' . $data_attribute . '\'
674
+ />&nbsp;';
675
+ }
676
+
677
+ return $html_to_return;
678
+ }
679
+
680
+ /**
681
+ * @author Dario Curvino <@dudo>
682
+ * @since
683
+ */
684
+ public function metaboxOutputMultisets() {
685
+ if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
686
+ wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
687
+ }
688
+
689
+ //in version < 2.1.0 set id could be 0
690
+ $set_id = (int) $_POST['set_id'];
691
+ $post_id = (int) $_POST['post_id'];
692
+
693
+ //set fields name and ids
694
+ $set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
695
+
696
+ //set meta values
697
+ $array_to_return = YasrMultiSetData::returnArrayFieldsRatingsAuthor($set_id, $set_fields, $post_id);
698
+
699
+ echo json_encode($array_to_return);
700
+
701
+ die();
702
+ }
703
+ }//End Class
admin/editor/YasrOnSavePost.php CHANGED
@@ -27,17 +27,12 @@ class YasrOnSavePost {
27
 
28
  private $post_id;
29
 
30
- public function __construct($post_id) {
31
- $this->post_id = (int)$post_id;
32
-
33
- $this->yasrSavePost();
34
- }
35
-
36
- private function yasrSavePost() {
37
  //if user can not publish posts
38
  if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
39
  return;
40
  }
 
41
  $this->saveOverallRating();
42
  $this->postIsReview();
43
  $this->saveItemType();
@@ -274,9 +269,3 @@ class YasrOnSavePost {
274
  }
275
 
276
  }
277
-
278
- add_action('save_post', 'yasr_on_save_post_callback');
279
-
280
- function yasr_on_save_post_callback ($post_id) {
281
- new YasrOnSavePost($post_id);
282
- }
27
 
28
  private $post_id;
29
 
30
+ public function yasrSavePost($post_id) {
 
 
 
 
 
 
31
  //if user can not publish posts
32
  if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
33
  return;
34
  }
35
+ $this->post_id = (int)$post_id;
36
  $this->saveOverallRating();
37
  $this->postIsReview();
38
  $this->saveItemType();
269
  }
270
 
271
  }
 
 
 
 
 
 
admin/editor/yasr-editor-functions.php DELETED
@@ -1,495 +0,0 @@
1
- <?php
2
-
3
- /*
4
-
5
- Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 2 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see <http://www.gnu.org/licenses/>
19
- */
20
-
21
- if (!defined('ABSPATH')) {
22
- exit('You\'re not allowed to see this page');
23
- } // Exit if accessed directly
24
-
25
- //this load guten-block.js, only in admin side
26
- add_action('enqueue_block_editor_assets', 'yasr_gutenberg_scripts');
27
- function yasr_gutenberg_scripts() {
28
- //I need to enqueue this only in post-new.php or post.php
29
- $current_screen = get_current_screen();
30
- if (property_exists($current_screen, 'base')) {
31
- if ($current_screen->base === 'post') {
32
- //Script
33
- wp_enqueue_script(
34
- 'yasr-gutenberg',
35
- YASR_JS_DIR_ADMIN . 'yasr-gutenberg.js', array(
36
- 'wp-blocks',
37
- 'wp-components',
38
- 'wp-editor',
39
- 'wp-edit-post',
40
- 'wp-element',
41
- 'wp-i18n',
42
- 'wp-plugins',
43
- )
44
- );
45
- }
46
- }
47
- }
48
-
49
- //This filter is used to add a new category in gutenberg
50
- add_filter('block_categories_all', 'yasr_add_gutenberg_category', 10, 2);
51
-
52
- function yasr_add_gutenberg_category($categories) {
53
- return array_merge(
54
- $categories,
55
- array(
56
- array(
57
- 'slug' => 'yet-another-stars-rating',
58
- 'title' => 'Yasr: Yet Another Stars Rating',
59
- ),
60
- )
61
- );
62
- }
63
-
64
- add_action('yasr_add_admin_scripts_end', 'yasr_add_js_constant_gutenberg');
65
-
66
- function yasr_add_js_constant_gutenberg($hook) {
67
-
68
- if (($hook === 'post.php' || $hook === 'post-new.php') && yasr_is_gutenberg_page() ) {
69
-
70
- //create an empty array
71
- $constants_array = array();
72
-
73
- //apply filters to empty array
74
- $constants_array = apply_filters('yasr_gutenberg_constants', $constants_array);
75
-
76
- //sanitize
77
- $constants_array = filter_var_array($constants_array,FILTER_SANITIZE_STRING);
78
-
79
- if(is_array($constants_array) && !empty($constants_array)) {
80
- wp_localize_script(
81
- 'yasradmin',
82
- 'yasrConstantGutenberg',
83
- $constants_array
84
- );
85
- }
86
- }
87
- }
88
-
89
- //Save auto insert value to yasrConstantGutenberg
90
- add_filter('yasr_gutenberg_constants', 'yasr_gutenberg_constants');
91
-
92
- function yasr_gutenberg_constants($constants_array) {
93
-
94
- //add after
95
- if (YASR_AUTO_INSERT_ENABLED === 1) {
96
- $auto_insert = YASR_AUTO_INSERT_WHAT;
97
- } else {
98
- $auto_insert = 'disabled';
99
- }
100
-
101
- $auto_insert_array = array (
102
- 'adminurl' => get_admin_url(),
103
- 'autoInsert' => $auto_insert
104
- );
105
-
106
- return $constants_array + $auto_insert_array;
107
- }
108
-
109
-
110
- /****** Create 2 metaboxes in post and pages ******/
111
- add_action('add_meta_boxes', 'yasr_add_metaboxes');
112
-
113
- function yasr_add_metaboxes() {
114
-
115
- //Default post type where display metabox
116
- $post_type_where_display_metabox = array('post', 'page');
117
-
118
- //get the custom post type
119
- $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
120
-
121
- if ($custom_post_types) {
122
- //First merge array then changes keys to int
123
- $post_type_where_display_metabox = array_values(array_merge($post_type_where_display_metabox, $custom_post_types));
124
- }
125
-
126
- //For classic editor, add this metabox
127
- foreach ($post_type_where_display_metabox as $post_type) {
128
- add_meta_box(
129
- 'yasr_metabox_overall_rating',
130
- 'YASR',
131
- 'yasr_metabox_overall_rating_content',
132
- $post_type,
133
- 'side',
134
- 'high',
135
- //Set this to true, so this metabox will be only loaded to classic editor
136
- array(
137
- '__back_compat_meta_box' => true,
138
- )
139
- );
140
- }
141
-
142
- foreach ($post_type_where_display_metabox as $post_type) {
143
- add_meta_box(
144
- 'yasr_metabox_below_editor_metabox',
145
- __('Yet Another Stars Rating', 'yet-another-stars-rating'),
146
- 'yasr_metabox_below_editor_metabox_callback',
147
- $post_type,
148
- 'normal',
149
- 'high'
150
- );
151
- }
152
-
153
-
154
- } //End function
155
-
156
- function yasr_metabox_overall_rating_content() {
157
-
158
- if (current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
159
- include(YASR_ABSOLUTE_PATH_ADMIN . '/editor/yasr-metabox-top-right.php');
160
- } else {
161
- _e('You don\'t have enought privileges to insert Overall Rating', 'yet-another-stars-rating');
162
- }
163
-
164
- }
165
-
166
- function yasr_metabox_below_editor_metabox_callback() {
167
- if (current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
168
- include(YASR_ABSOLUTE_PATH_ADMIN . '/editor/yasr-metabox-below-editor.php');
169
- } else {
170
- _e('You don\'t have enough privileges to insert a Multi Set', 'yet-another-stars-rating');
171
- }
172
- }
173
-
174
- /******* Add a media content button ******/
175
- add_action('media_buttons', 'yasr_shortcode_button_media', 99);
176
- function yasr_shortcode_button_media() {
177
- if (is_admin()) {
178
- add_thickbox();
179
- echo '<a href="#TB_inline?width=530&height=600&inlineId=yasr-tinypopup-form"
180
- id="yasr-shortcode-creator"
181
- class="button thickbox">
182
- <span class="dashicons dashicons-star-half" style="vertical-align: middle;"></span> Yasr Shortcode
183
- </a>';
184
-
185
- }
186
- }
187
-
188
- /****** Create the content for the button shortcode in Tinymce ******/
189
- //Add ajax action that will be called from the .js for button in tinymce
190
- add_action('wp_ajax_yasr_create_shortcode', 'wp_ajax_yasr_create_shortcode_callback');
191
- function wp_ajax_yasr_create_shortcode_callback() {
192
- if (!isset($_GET['action'])) {
193
- exit();
194
- }
195
- global $wpdb;
196
- $multi_set = YasrMultiSetData::returnMultiSetNames();
197
- $n_multi_set = $wpdb->num_rows;
198
-
199
- ?>
200
-
201
- <div id="yasr-tinypopup-form">
202
- <h2 class="nav-tab-wrapper yasr-underline">
203
- <a href="#" id="yasr-link-tab-main"
204
- class="nav-tab nav-tab-active yasr-nav-tab"><?php _e("Main", 'yet-another-stars-rating'); ?></a>
205
- <a href="#" id="yasr-link-tab-charts"
206
- class="nav-tab yasr-nav-tab"><?php _e("Rankings", 'yet-another-stars-rating'); ?></a>
207
- <?php do_action('yasr_add_tabs_on_tinypopupform'); ?>
208
-
209
- <a href="https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen"
210
- target="_blank"
211
- id="yasr-tinypopup-link-doc">
212
- <?php _e('Read the doc', 'yet-another-stars-rating'); ?>
213
- </a>
214
- </h2>
215
-
216
- <div id="yasr-content-tab-main" class="yasr-content-tab-tinymce">
217
- <table id="yasr-table-tiny-popup-main" class="form-table">
218
-
219
- <tr>
220
- <th>
221
- <label for="yasr-overall">
222
- <?php _e('Overall Rating', 'yet-another-stars-rating'); ?>
223
- </label>
224
- </th>
225
- <td>
226
- <input
227
- type="button"
228
- class="button-primary"
229
- id="yasr-overall"
230
- name="yasr-overall"
231
- value="<?php _e('Insert Overall Rating', 'yet-another-stars-rating'); ?>"
232
- />
233
- <br/>
234
- <small>
235
- <?php _e('Insert the author rating', 'yet-another-stars-rating'); ?>
236
- </small>
237
-
238
- <div id="yasr-overall-choose-size">
239
- <small>
240
- <?php _e('Choose Size', 'yet-another-stars-rating'); ?>
241
- </small>
242
- <div class="yasr-tinymce-button-size">
243
- <?php
244
- echo yasr_tinymce_return_button('yasr_overall_rating');
245
- ?>
246
- </div>
247
- </div>
248
-
249
- </td>
250
- </tr>
251
-
252
- <tr>
253
- <th>
254
- <label for="yasr-id">
255
- <?php _e("Visitor Votes", 'yet-another-stars-rating'); ?>
256
- </label>
257
- </th>
258
- <td>
259
- <input type="button" class="button-primary" name="yasr-visitor-votes" id="yasr-visitor-votes"
260
- value="<?php _e("Insert Visitor Votes", 'yet-another-stars-rating'); ?>"/><br/>
261
- <small>
262
- <?php _e('Insert the ability for your visitors to vote', 'yet-another-stars-rating'); ?>
263
- </small>
264
-
265
- <div id="yasr-visitor-choose-size">
266
- <small>
267
- <?php _e("Choose Size", 'yet-another-stars-rating'); ?>
268
- </small>
269
- <div class="yasr-tinymce-button-size">
270
- <?php
271
- echo yasr_tinymce_return_button('yasr_visitor_votes');
272
- ?>
273
- </div>
274
- </div>
275
- </td>
276
- </tr>
277
-
278
- <?php if ($n_multi_set > 0) { //If multiple Set are found ?>
279
- <tr>
280
- <th>
281
- <?php _e("Insert Multiset:", 'yet-another-stars-rating'); ?>
282
- </th>
283
- <td>
284
- <?php foreach ($multi_set as $name) { ?>
285
- <label>
286
- <input type="radio" value="<?php echo $name->set_id ?>" name="yasr_tinymce_pick_set"
287
- class="yasr_tinymce_select_set">
288
- <?php echo $name->set_name ?>
289
- </label>
290
- <br/>
291
- <?php } //End foreach ?>
292
- <small>
293
- <?php _e('Choose wich set you want to insert.', 'yet-another-stars-rating'); ?>
294
- </small>
295
-
296
- <p>
297
- <label for="yasr-allow-vote-multiset">
298
- <input type="checkbox" id="yasr-allow-vote-multiset">
299
- <?php _e("Readonly?", 'yet-another-stars-rating'); ?>
300
- </label>
301
- <br/>
302
- </p>
303
-
304
- <small>
305
- <?php _e('If Readonly is checked, only you can insert the votes (in the box above the editor)',
306
- 'yet-another-stars-rating'); ?>
307
- </small>
308
-
309
- <p>
310
- <label for="yasr-hide-average-multiset">
311
- <input type="checkbox" id="yasr-hide-average-multiset">
312
- <?php _e("Hide Average?", 'yet-another-stars-rating'); ?>
313
- </label>
314
- <br/>
315
- </p>
316
-
317
- <p>
318
- <input type="button" class="button-primary"
319
- name="yasr-insert-multiset"
320
- id="yasr-insert-multiset-select"
321
- value="<?php _e("Insert Multi Set", 'yet-another-stars-rating') ?>"/
322
- >
323
- <br/>
324
- </p>
325
-
326
- </td>
327
- </tr>
328
- <?php
329
- } //End if
330
- ?>
331
- </table>
332
-
333
- </div>
334
-
335
- <div id="yasr-content-tab-charts" class="yasr-content-tab-tinymce" style="display:none">
336
-
337
- <table id="yasr-table-tiny-popup-charts" class="form-table">
338
- <tr>
339
- <th>
340
- <label for="yasr-10-overall">
341
- <?php _e("Ranking by overall rating", 'yet-another-stars-rating'); ?>
342
- </label>
343
- </th>
344
- <td>
345
- <?php
346
- echo yasr_tinymce_return_button('yasr_ov_ranking', 'Insert Ranking reviews')
347
- ?>
348
- <br/>
349
- <small>
350
- <?php _e('This ranking shows the highest rated posts rated through the overall_rating shortcode',
351
- 'yet-another-stars-rating'); ?>
352
- </small>
353
- </td>
354
- </tr>
355
-
356
- <tr>
357
- <th>
358
- <label for="yasr-10-highest-most-rated">
359
- <?php _e('Ranking by visitors votes', 'yet-another-stars-rating'); ?>
360
- </label>
361
- </th>
362
- <td>
363
- <?php
364
- echo yasr_tinymce_return_button('yasr_most_or_highest_rated_posts', 'Insert Users ranking')
365
- ?>
366
- <br/>
367
- <small>
368
- <?php _e(
369
- 'This ranking shows both the highest and most rated posts rated through the
370
- yasr_visitor_votes shortcode. For an item to appear in this chart, it has to be rated at least twice. ',
371
- 'yet-another-stars-rating'); ?>
372
- </small>
373
- </td>
374
- </tr>
375
-
376
- <tr>
377
- <th>
378
- <label for="yasr-5-active-reviewers">
379
- <?php _e('Most Active Authors', 'yet-another-stars-rating'); ?>
380
- </label>
381
- </th>
382
- <td>
383
- <?php
384
- echo yasr_tinymce_return_button('yasr_top_reviewers', 'Insert Most Active Reviewers')
385
- ?>
386
- <br/>
387
- <small>
388
- <?php
389
- _e('This ranking shows the most active reviewers on your site.',
390
- 'yet-another-stars-rating'); ?>
391
- </small>
392
- </td>
393
- </tr>
394
-
395
- <tr>
396
- <th>
397
- <label for="yasr-10-active-users">
398
- <?php _e('Most Active Users', 'yet-another-stars-rating'); ?>
399
- </label>
400
- </th>
401
- <td>
402
- <?php
403
- echo yasr_tinymce_return_button('yasr_most_active_users', 'Insert Most Active Reviewers')
404
- ?>
405
- <br/>
406
- <small>
407
- <?php _e('This ranking shows the most active users, displaying the login name if logged in or “Anonymous” if not.',
408
- 'yet-another-stars-rating'); ?>
409
- </small>
410
- </td>
411
- </tr>
412
-
413
- </table>
414
-
415
- <div style="font-size: medium">
416
- <?php
417
- echo(
418
- sprintf(__('%s Click here %s to customize the ranking and see a live preview',
419
- 'yet-another-stars-rating'),
420
- '<a href="options-general.php?page=yasr_settings_page&tab=rankings">', '</a>')
421
- );
422
- ?>
423
- </div>
424
-
425
- </div>
426
-
427
- <?php do_action('yasr_add_content_on_tinypopupform'); ?>
428
-
429
- </div>
430
-
431
- <?php
432
-
433
- die();
434
-
435
- } //End callback function
436
-
437
- /**
438
- * @author Dario Curvino <@dudo>
439
- * @since 2.6.5 returns button to be used in tinymce
440
- *
441
- * @param $shortcode
442
- * @param $value
443
- *
444
- * @return string
445
- */
446
- function yasr_tinymce_return_button ($shortcode, $value=false) {
447
- $html_to_return = '';
448
-
449
- if ($value === false) {
450
- $array_size = array('Small', 'Medium', 'Large');
451
-
452
- foreach ($array_size as $size) {
453
- $size_low = strtolower($size);
454
- $data_attribute = "[$shortcode size=\"$size_low\"]";
455
-
456
- $html_to_return .= '<input type="button"
457
- class="button-secondary yasr-tinymce-shortcode-buttons"
458
- value="' . __($size, 'yet-another-stars-rating') . '"
459
- data-shortcode=\'' . $data_attribute . '\'
460
- />&nbsp;';
461
- }
462
- } else {
463
- $data_attribute = "[$shortcode]";
464
- $html_to_return .= '<input type="button"
465
- class="button-primary yasr-tinymce-shortcode-buttons"
466
- value="' . __($value, 'yet-another-stars-rating') . '"
467
- data-shortcode=\'' . $data_attribute . '\'
468
- />&nbsp;';
469
- }
470
-
471
- return $html_to_return;
472
- }
473
-
474
- /****** Get Set name from post or page and output the set,
475
- * used in yasr-metabox-multiple-rating******/
476
- add_action('wp_ajax_yasr_send_id_nameset', 'yasr_output_multiple_set_callback');
477
- function yasr_output_multiple_set_callback() {
478
- if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
479
- wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
480
- }
481
-
482
- //in version < 2.1.0 set id could be 0
483
- $set_id = (int) $_POST['set_id'];
484
- $post_id = (int) $_POST['post_id'];
485
-
486
- //set fields name and ids
487
- $set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
488
-
489
- //set meta values
490
- $array_to_return = YasrMultiSetData::returnArrayFieldsRatingsAuthor($set_id, $set_fields, $post_id);
491
-
492
- echo json_encode($array_to_return);
493
-
494
- die();
495
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/guten/blocks/noStarsRankings.js ADDED
@@ -0,0 +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]")}})})();
admin/js/guten/blocks/overallRating.js ADDED
@@ -0,0 +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,"]")}})})();
admin/js/guten/blocks/rankings.js ADDED
@@ -0,0 +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]")}})})();
admin/js/guten/blocks/visitorVotes.js ADDED
@@ -0,0 +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,"]")}})})();
admin/js/guten/blocks/yasrGutenUtils.js ADDED
@@ -0,0 +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)})();
admin/js/guten/yasr-guten-misc.js ADDED
@@ -0,0 +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})})()})();
admin/js/src/guten/{yasr-guten-blocks.js → blocks/deprecated/deprecated_blocks.js} RENAMED
@@ -20,17 +20,13 @@ const yasrLeaveThisBlankText = __('Leave this blank if you don\'t know what
20
  const yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
21
  const yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
22
 
23
- /******* function to check ajax response *****/
24
- /*function checkResponse(res) {
25
- if (res.status >= 400 && res.status < 600) {
26
- throw new Error(`Failed with status ${res.status}`);
27
- }
28
 
29
- return res;
30
- }*/
31
 
32
  function YasrProText () {
33
-
34
  const YasrProText1 = __('To be able to customize this ranking, you need', 'yet-another-stars-rating');
35
  const YasrProText2 = __('You can buy the plugin, including support, updates and upgrades, on',
36
  'yet-another-stars-rating');
@@ -62,81 +58,16 @@ function YasrNoSettingsPanel (props) {
62
 
63
  }
64
 
65
- /*function YasrPrintSelectRows () {
66
- let optionValueRows = [];
67
-
68
- for (let i=2; i<=30; i++) {
69
- if (i === 9) {
70
- optionValueRows.push(<option value={i} selected disabled>{i}</option>);
71
- } else {
72
- optionValueRows.push(<option value={i} disabled>{i}</option>);
73
- }
74
-
75
- }
76
-
77
- return(
78
- <form>
79
- <select>
80
- {optionValueRows}
81
- </select>
82
- <span className="dashicons dashicons-lock"></span>
83
- </form>
84
- )
85
-
86
- }
87
-
88
-
89
- function YasrPrintSelectSize () {
90
- return (
91
- <form>
92
- <select>
93
- <option value="--">{yasrSelectSizeChoose}</option>
94
- <option value="small" disabled>{yasrSelectSizeSmall}</option>
95
- <option value="medium" disabled>{yasrSelectSizeMedium}</option>
96
- <option value="large" disabled>{yasrSelectSizeLarge}</option>
97
- </select>
98
- <span className="dashicons dashicons-lock"></span>
99
- </form>
100
- );
101
- }
102
-
103
- function YasrPrintTextPosition () {
104
- return (
105
- <form>
106
- <select>
107
- <option value="before" selected disabled>Before</option>
108
- <option value="after" disabled>After</option>
109
- </select>
110
- <span className="dashicons dashicons-lock"></span>
111
- </form>
112
- );
113
- }
114
- */
115
- /**
116
- * Register: a Gutenberg Block.
117
- *
118
- * Registers a new block provided a unique name and an object defining its
119
- * behavior. Once registered, the block is made editor as an option to any
120
- * editor interface where blocks are implemented.
121
- *
122
- * @link https://wordpress.org/gutenberg/handbook/block-api/
123
- * @param {string} name Block name.
124
- * @param {Object} settings Block settings.
125
- * @return {?WPBlock} The block, if it has been successfully
126
- * registered; otherwise `undefined`.
127
- */
128
-
129
  registerBlockType(
130
  'yet-another-stars-rating/yasr-overall-rating', {
131
- title: __( 'Yasr: Overall Rating', 'yet-another-stars-rating' ),
132
- description: __('Insert the author rating', 'yet-another-stars-rating'),
133
  icon: 'star-half',
134
- category: 'yet-another-stars-rating',
135
  keywords: [
136
- __('rating', 'yet-another-stars-rating'),
137
- __('author', 'yet-another-stars-rating'),
138
- __('overall', 'yet-another-stars-rating')
139
- ],
140
  attributes: {
141
  overallRatingMeta: {
142
  type: 'number',
@@ -337,11 +268,9 @@ registerBlockType(
337
 
338
  registerBlockType(
339
  'yet-another-stars-rating/yasr-visitor-votes', {
340
-
341
- title: __( 'Yasr: Visitor Votes', 'yet-another-stars-rating' ),
342
- description: __('Insert the ability for your visitors to vote', 'yet-another-stars-rating'),
343
  icon: 'star-half',
344
- category: 'yet-another-stars-rating',
345
  keywords: [
346
  __('rating', 'yet-another-stars-rating'),
347
  __('visitor', 'yet-another-stars-rating'),
@@ -493,267 +422,8 @@ registerBlockType(
493
  );
494
  },
495
 
496
- });
497
-
498
- registerBlockType(
499
- 'yet-another-stars-rating/overall-rating-ranking', {
500
-
501
- title: __('Yasr: Ranking by overall rating', 'yet-another-stars-rating'),
502
- description: __(
503
- 'This ranking shows the highest rated posts rated through the overall_rating shortcode.',
504
- 'yet-another-stars-rating'
505
- ),
506
- icon: 'star-half',
507
- category: 'yet-another-stars-rating',
508
- keywords: [
509
- __('ranking', 'yet-another-stars-rating'),
510
- __('highest', 'yet-another-stars-rating'),
511
- __('chart', 'yet-another-stars-rating')
512
- ],
513
-
514
- edit:
515
- function(props) {
516
-
517
- let YasrORRSettings = [<YasrNoSettingsPanel key={0}/>];
518
- {wp.hooks.doAction('yasr_overall_rating_rankings', YasrORRSettings)}
519
-
520
- function YasrORRPanel (props) {
521
- return (
522
- <InspectorControls>
523
- <PanelBody title='Settings'>
524
- <div className="yasr-guten-block-panel">
525
- <div>
526
- {YasrORRSettings}
527
- </div>
528
- </div>
529
-
530
- </PanelBody>
531
- </InspectorControls>
532
- );
533
- }
534
-
535
- return (
536
- <Fragment>
537
- <YasrORRPanel />
538
- <div className={props.className}>
539
- [yasr_ov_ranking]
540
- </div>
541
- </Fragment>
542
- );
543
- },
544
-
545
-
546
- /**
547
- * The save function defines the way in which the different attributes should be combined
548
- * into the final markup, which is then serialized by Gutenberg into post_content.
549
- *
550
- * The "save" property must be specified and must be a valid function.
551
- *
552
- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
553
- */
554
- save:
555
- function(props) {
556
- return (
557
- <div>[yasr_ov_ranking]</div>
558
- );
559
- },
560
-
561
- });
562
-
563
- registerBlockType(
564
- 'yet-another-stars-rating/visitor-votes-ranking', {
565
-
566
- title: __('Yasr: Ranking by visitors votes', 'yet-another-stars-rating'),
567
- description: __(
568
- 'This ranking shows both the highest and most rated posts rated through the yasr_visitor_votes shortcode. ' +
569
- 'For an item to appear in this chart, it has to be rated at least twice. ',
570
- 'yet-another-stars-rating'
571
- ),
572
- icon: 'star-half',
573
- category: 'yet-another-stars-rating',
574
- keywords: [
575
- __('ranking', 'yet-another-stars-rating'),
576
- __('highest', 'yet-another-stars-rating'),
577
- __('most', 'yet-another-stars-rating'),
578
- __('chart', 'yet-another-stars-rating')
579
- ],
580
-
581
- edit:
582
-
583
- function(props) {
584
-
585
- let YasrVVRSettings = [<YasrNoSettingsPanel key={0}/>];
586
- {wp.hooks.doAction('yasr_visitor_votes_rankings', YasrVVRSettings)}
587
-
588
- function YasrVVRPanel (props) {
589
- return (
590
- <InspectorControls>
591
- <PanelBody title='Settings'>
592
- <div className="yasr-guten-block-panel">
593
- <div>
594
- {YasrVVRSettings}
595
- </div>
596
- </div>
597
-
598
- </PanelBody>
599
- </InspectorControls>
600
- );
601
- }
602
-
603
- return (
604
- <Fragment>
605
- <YasrVVRPanel />
606
- <div className={props.className}>
607
- [yasr_most_or_highest_rated_posts]
608
- </div>
609
- </Fragment>
610
- );
611
- },
612
-
613
- /**
614
- * The save function defines the way in which the different attributes should be combined
615
- * into the final markup, which is then serialized by Gutenberg into post_content.
616
- *
617
- * The "save" property must be specified and must be a valid function.
618
- *
619
- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
620
- */
621
- save:
622
- function(props) {
623
- return (
624
- <div>[yasr_most_or_highest_rated_posts]</div>
625
- );
626
- },
627
-
628
- });
629
-
630
- registerBlockType(
631
- 'yet-another-stars-rating/most-active-reviewers', {
632
-
633
- title: __('Yasr: Most Active Authors', 'yet-another-stars-rating'),
634
- description: __('This ranking shows the most active reviewers on your site.',
635
- 'yet-another-stars-rating'
636
- ),
637
- icon: 'star-half',
638
- category: 'yet-another-stars-rating',
639
- keywords: [
640
- __('ranking', 'yet-another-stars-rating'),
641
- __('highest', 'yet-another-stars-rating'),
642
- __('most', 'yet-another-stars-rating'),
643
- __('chart', 'yet-another-stars-rating'),
644
- __('authors', 'yet-another-stars-rating')
645
- ],
646
-
647
- edit:
648
-
649
- function(props) {
650
-
651
- let YasrTopReviewersSettings = [<YasrNoSettingsPanel key={0}/>];
652
- {wp.hooks.doAction('yasr_top_reviewers_setting', YasrTopReviewersSettings)}
653
-
654
- function YasrTopReviewersPanel (props) {
655
- return (
656
- <InspectorControls>
657
- <PanelBody title='Settings'>
658
- <div className="yasr-guten-block-panel">
659
- <div>
660
- {YasrTopReviewersSettings}
661
- </div>
662
- </div>
663
-
664
- </PanelBody>
665
- </InspectorControls>
666
- );
667
- }
668
-
669
- return (
670
- <Fragment>
671
- <YasrTopReviewersPanel />
672
- <div className={props.className}>
673
- [yasr_top_reviewers]
674
- </div>
675
- </Fragment>
676
- );
677
- },
678
-
679
- /**
680
- * The save function defines the way in which the different attributes should be combined
681
- * into the final markup, which is then serialized by Gutenberg into post_content.
682
- *
683
- * The "save" property must be specified and must be a valid function.
684
- *
685
- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
686
- */
687
- save:
688
- function(props) {
689
- return (
690
- <div>[yasr_top_reviewers]</div>
691
- );
692
- },
693
-
694
  });
695
 
696
- registerBlockType(
697
- 'yet-another-stars-rating/most-active-users', {
698
-
699
- title: __('Yasr: Most Active Visitors', 'yet-another-stars-rating'),
700
- description: __('This ranking shows the most active users, displaying the login name if logged in or “Anonymous” if not.',
701
- 'yet-another-stars-rating'
702
- ),
703
- icon: 'star-half',
704
- category: 'yet-another-stars-rating',
705
- keywords: [
706
- __('ranking', 'yet-another-stars-rating'),
707
- __('highest', 'yet-another-stars-rating'),
708
- __('most', 'yet-another-stars-rating'),
709
- __('chart', 'yet-another-stars-rating'),
710
- __('visitors', 'yet-another-stars-rating')
711
- ],
712
-
713
- edit:
714
-
715
- function(props) {
716
-
717
- let YasrTopVisitorSettings = [<YasrNoSettingsPanel key={0}/>];
718
- {wp.hooks.doAction('yasr_top_visitor_setting', YasrTopVisitorSettings)}
719
-
720
- function YasrTopVisitorPanel (props) {
721
- return (
722
- <InspectorControls>
723
- <PanelBody title='Settings'>
724
- <div className="yasr-guten-block-panel">
725
- <div>
726
- {YasrTopVisitorSettings}
727
- </div>
728
- </div>
729
- </PanelBody>
730
- </InspectorControls>
731
- );
732
- }
733
-
734
- return (
735
- <Fragment>
736
- <YasrTopVisitorPanel />
737
- <div className={props.className}>
738
- [yasr_most_active_users]
739
- </div>
740
- </Fragment>
741
- );
742
- },
743
-
744
- /**
745
- * The save function defines the way in which the different attributes should be combined
746
- * into the final markup, which is then serialized by Gutenberg into post_content.
747
- *
748
- * The "save" property must be specified and must be a valid function.
749
- *
750
- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
751
- */
752
- save:
753
- function(props) {
754
- return (
755
- <div>[yasr_most_active_users]</div>
756
- );
757
- },
758
-
759
- });
20
  const yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
21
  const yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
22
 
23
+ const yasrDeprecatedOv = __('This block is now deprecated. It will still work, but I suggest to replace it with the ' +
24
+ 'new one by simply removing it and adding "Yasr Overall Rating" again.','yet-another-stars-rating');
 
 
 
25
 
26
+ const yasrDeprecatedVV = __('This block is now deprecated. It will still work, but I suggest to replace it with the ' +
27
+ 'new one by simply removing it and adding "Yasr Visitors Votes" again.','yet-another-stars-rating');
28
 
29
  function YasrProText () {
 
30
  const YasrProText1 = __('To be able to customize this ranking, you need', 'yet-another-stars-rating');
31
  const YasrProText2 = __('You can buy the plugin, including support, updates and upgrades, on',
32
  'yet-another-stars-rating');
58
 
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  registerBlockType(
62
  'yet-another-stars-rating/yasr-overall-rating', {
63
+ title: __( '[DEPRECATED]Yasr: Overall Rating', 'yet-another-stars-rating' ),
64
+ description: yasrDeprecatedOv,
65
  icon: 'star-half',
 
66
  keywords: [
67
+ __('rating', 'yet-another-stars-rating'),
68
+ __('author', 'yet-another-stars-rating'),
69
+ __('overall', 'yet-another-stars-rating')
70
+ ],
71
  attributes: {
72
  overallRatingMeta: {
73
  type: 'number',
268
 
269
  registerBlockType(
270
  'yet-another-stars-rating/yasr-visitor-votes', {
271
+ title: __( '[DEPRECATED]Yasr: Visitor Votes', 'yet-another-stars-rating' ),
272
+ description: yasrDeprecatedVV,
 
273
  icon: 'star-half',
 
274
  keywords: [
275
  __('rating', 'yet-another-stars-rating'),
276
  __('visitor', 'yet-another-stars-rating'),
422
  );
423
  },
424
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
  });
426
 
427
+ //hide the deprecated blocks from the panel
428
+ wp.data.dispatch('core/edit-post').hideBlockTypes('yet-another-stars-rating/yasr-overall-rating');
429
+ wp.data.dispatch('core/edit-post').hideBlockTypes('yet-another-stars-rating/yasr-visitor-votes');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/src/guten/blocks/noStarsRankings.js ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
5
+ const {useBlockProps, InspectorControls} = wp.blockEditor;
6
+
7
+ import {YasrNoSettingsPanel} from "./yasrGutenUtils";
8
+
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( {
30
+ className: 'yasr-active-users-block'
31
+ } );
32
+
33
+ let YasrTopVisitorSettings = [<YasrNoSettingsPanel key={0}/>];
34
+ {wp.hooks.doAction('yasr_top_visitor_setting', YasrTopVisitorSettings)}
35
+
36
+ function YasrTopVisitorPanel (props) {
37
+ return (
38
+ <InspectorControls>
39
+ <PanelBody title='Settings'>
40
+ <div className="yasr-guten-block-panel">
41
+ <div>
42
+ {YasrTopVisitorSettings}
43
+ </div>
44
+ </div>
45
+ </PanelBody>
46
+ </InspectorControls>
47
+ );
48
+ }
49
+
50
+ return (
51
+ <Fragment>
52
+ <YasrTopVisitorPanel />
53
+ <div {...blockProps}>
54
+ [yasr_most_active_users]
55
+ </div>
56
+ </Fragment>
57
+ );
58
+ },
59
+
60
+ /**
61
+ * The save function defines the way in which the different attributes should be combined
62
+ * into the final markup, which is then serialized by Gutenberg into post_content.
63
+ *
64
+ * The "save" property must be specified and must be a valid function.
65
+ *
66
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
67
+ */
68
+ save:
69
+ function(props) {
70
+ const blockProps = useBlockProps.save( {
71
+ className: 'yasr-active-users-block'
72
+ } );
73
+ return (
74
+ <div {...blockProps}>[yasr_most_active_users]</div>
75
+ );
76
+ },
77
+
78
+ }
79
+ );
80
+
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( {
106
+ className: 'yasr-reviewers-block',
107
+ } );
108
+
109
+ let YasrTopReviewersSettings = [<YasrNoSettingsPanel key={0}/>];
110
+ {wp.hooks.doAction('yasr_top_reviewers_setting', YasrTopReviewersSettings)}
111
+
112
+ function YasrTopReviewersPanel (props) {
113
+ return (
114
+ <InspectorControls>
115
+ <PanelBody title='Settings'>
116
+ <div className="yasr-guten-block-panel">
117
+ <div>
118
+ {YasrTopReviewersSettings}
119
+ </div>
120
+ </div>
121
+ </PanelBody>
122
+ </InspectorControls>
123
+ );
124
+ }
125
+
126
+ return (
127
+ <Fragment>
128
+ <YasrTopReviewersPanel />
129
+ <div {...blockProps}>
130
+ [yasr_top_reviewers]
131
+ </div>
132
+ </Fragment>
133
+ );
134
+ },
135
+
136
+ /**
137
+ * The save function defines the way in which the different attributes should be combined
138
+ * into the final markup, which is then serialized by Gutenberg into post_content.
139
+ *
140
+ * The "save" property must be specified and must be a valid function.
141
+ *
142
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
143
+ */
144
+ save:
145
+ function(props) {
146
+ const blockProps = useBlockProps.save( {
147
+ className: 'yasr-reviewers-block',
148
+ } );
149
+ return (
150
+ <div {...blockProps}>[yasr_top_reviewers]</div>
151
+ );
152
+ },
153
+
154
+ }
155
+ );
admin/js/src/guten/blocks/overallRating.js ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n; // Import __() from wp.i18n
2
+ const {registerBlockType} = wp.blocks; // Import from wp.blocks
3
+ const {Fragment} = wp.element;
4
+ const {useBlockProps} = wp.blockEditor;
5
+
6
+ import {YasrPrintSelectSize, YasrBlocksPanel} from "./yasrGutenUtils";
7
+
8
+ /**
9
+ * Register: a Gutenberg Block.
10
+ *
11
+ * Registers a new block provided a unique name and an object defining its
12
+ * behavior. Once registered, the block is made editor as an option to any
13
+ * editor interface where blocks are implemented.
14
+ *
15
+ * @link https://wordpress.org/gutenberg/handbook/block-api/
16
+ * @param {string} name Block name.
17
+ * @param {Object} settings Block settings.
18
+ * @return {?WPBlock} The block, if it has been successfully
19
+ * registered; otherwise `undefined`.
20
+ */
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( {
52
+ className: 'yasr-overall-block',
53
+ } );
54
+
55
+ const {attributes: {size, postId}, setAttributes, isSelected} = props;
56
+
57
+ let sizeAttribute = null;
58
+ let postIdAttribute = null;
59
+ let isNum;
60
+
61
+ if (size !== 'large') {
62
+ sizeAttribute = ' size="' + size + '"';
63
+ }
64
+
65
+ isNum = /^\d+$/.test(postId);
66
+
67
+ if (isNum === true) {
68
+ postIdAttribute = ' postid="' +postId + '"';
69
+ }
70
+
71
+ return (
72
+ <Fragment>
73
+ {isSelected &&
74
+ <YasrBlocksPanel block='overall' size={size} postId={postId} setAttributes={setAttributes}/> }
75
+ <div { ...blockProps }>
76
+ [yasr_overall_rating{sizeAttribute}{postIdAttribute}]
77
+ {isSelected && <YasrPrintSelectSize size={size} setAttributes={setAttributes}/>}
78
+ </div>
79
+ </Fragment>
80
+ );
81
+ },
82
+
83
+ /**
84
+ * The save function defines the way in which the different attributes should be combined
85
+ * into the final markup, which is then serialized by Gutenberg into post_content.
86
+ *
87
+ * The "save" property must be specified and must be a valid function.
88
+ *
89
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
90
+ */
91
+ save:
92
+ function(props) {
93
+ const blockProps = useBlockProps.save( {
94
+ className: 'yasr-overall-block',
95
+ } );
96
+
97
+ const {attributes: {size, postId}} = props;
98
+
99
+ let yasrOverallAttributes = '';
100
+ let post_id = postId;
101
+
102
+ if (size) {
103
+ yasrOverallAttributes += 'size="' +size+ '"';
104
+ }
105
+ if (postId) {
106
+ yasrOverallAttributes += ' postid="'+post_id+'"';
107
+ }
108
+
109
+ return (
110
+ <div {...blockProps}>[yasr_overall_rating {yasrOverallAttributes}]</div>
111
+ );
112
+ },
113
+
114
+ });
admin/js/src/guten/blocks/rankings.js ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
5
+ const {useBlockProps, InspectorControls} = wp.blockEditor;
6
+
7
+ 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( {
32
+ className: 'yasr-ov-ranking-block',
33
+ } );
34
+
35
+ let YasrORRSettings = [<YasrNoSettingsPanel key={0}/>];
36
+ {wp.hooks.doAction('yasr_overall_rating_rankings', YasrORRSettings)}
37
+
38
+ function YasrORRPanel (props) {
39
+ return (
40
+ <InspectorControls>
41
+ <PanelBody title='Settings'>
42
+ <div className="yasr-guten-block-panel">
43
+ <div>
44
+ {YasrORRSettings}
45
+ </div>
46
+ </div>
47
+
48
+ </PanelBody>
49
+ </InspectorControls>
50
+ );
51
+ }
52
+
53
+ return (
54
+ <Fragment>
55
+ <YasrORRPanel />
56
+ <div {...blockProps}>
57
+ [yasr_ov_ranking]
58
+ </div>
59
+ </Fragment>
60
+ );
61
+ },
62
+
63
+
64
+ /**
65
+ * The save function defines the way in which the different attributes should be combined
66
+ * into the final markup, which is then serialized by Gutenberg into post_content.
67
+ *
68
+ * The "save" property must be specified and must be a valid function.
69
+ *
70
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
71
+ */
72
+ save:
73
+ function(props) {
74
+ const blockProps = useBlockProps.save( {
75
+ className: 'yasr-ov-ranking-block',
76
+ } );
77
+ return (
78
+ <div {...blockProps}>[yasr_ov_ranking]</div>
79
+ );
80
+ },
81
+
82
+ });
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',
107
+ } );
108
+ let YasrVVRSettings = [<YasrNoSettingsPanel key={0}/>];
109
+ {wp.hooks.doAction('yasr_visitor_votes_rankings', YasrVVRSettings)}
110
+
111
+ function YasrVVRPanel (props) {
112
+ return (
113
+ <InspectorControls>
114
+ <PanelBody title='Settings'>
115
+ <div className="yasr-guten-block-panel">
116
+ <div>
117
+ {YasrVVRSettings}
118
+ </div>
119
+ </div>
120
+
121
+ </PanelBody>
122
+ </InspectorControls>
123
+ );
124
+ }
125
+
126
+ return (
127
+ <Fragment>
128
+ <YasrVVRPanel />
129
+ <div {...blockProps}>
130
+ [yasr_most_or_highest_rated_posts]
131
+ </div>
132
+ </Fragment>
133
+ );
134
+ },
135
+
136
+ /**
137
+ * The save function defines the way in which the different attributes should be combined
138
+ * into the final markup, which is then serialized by Gutenberg into post_content.
139
+ *
140
+ * The "save" property must be specified and must be a valid function.
141
+ *
142
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
143
+ */
144
+ save:
145
+ function(props) {
146
+ const blockProps = useBlockProps.save( {
147
+ className: 'yasr-vv-ranking-block',
148
+ } );
149
+ return (
150
+ <div {...blockProps}>[yasr_most_or_highest_rated_posts]</div>
151
+ );
152
+ },
153
+
154
+ });
admin/js/src/guten/blocks/visitorVotes.js ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {YasrBlocksPanel, YasrPrintSelectSize} from "./yasrGutenUtils";
2
+
3
+ const { __ } = wp.i18n; // Import __() from wp.i18n
4
+ const {registerBlockType} = wp.blocks; // Import from wp.blocks
5
+ const {Fragment} = wp.element;
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( {
39
+ className: 'yasr-vv-block',
40
+ } );
41
+ const { attributes: { size, postId }, setAttributes, isSelected } = props;
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 + '"';
51
+ }
52
+
53
+ if (isNum === true) {
54
+ postIdAttribute = ' postid="' +postId + '"';
55
+ }
56
+
57
+ return (
58
+ <Fragment>
59
+ <YasrBlocksPanel block='visitors' size={size} setAttributes={setAttributes} postId={postId}/>
60
+ <div {...blockProps}>
61
+ [yasr_visitor_votes{sizeAttribute}{postIdAttribute}]
62
+ {isSelected && <YasrPrintSelectSize size={size} setAttributes={setAttributes}/>}
63
+ </div>
64
+ </Fragment>
65
+ );
66
+
67
+ },
68
+
69
+ /**
70
+ * The save function defines the way in which the different attributes should be combined
71
+ * into the final markup, which is then serialized by Gutenberg into post_content.
72
+ *
73
+ * The "save" property must be specified and must be a valid function.
74
+ *
75
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
76
+ */
77
+ save:
78
+ function( props ) {
79
+ const blockProps = useBlockProps.save( {
80
+ className: 'yasr-vv-block',
81
+ } );
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 (
95
+ <div {...blockProps}>[yasr_visitor_votes {yasrVVAttributes}]</div>
96
+ );
97
+ },
98
+
99
+ });
admin/js/src/guten/blocks/yasrGutenUtils.js ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
6
+ const {InspectorControls} = wp.blockEditor;
7
+
8
+ export const yasrOptionalText = __('All these settings are optional', 'yet-another-stars-rating');
9
+ export const yasrLabelSelectSize = __('Choose Size', 'yet-another-stars-rating');
10
+
11
+ export const yasrSelectSizeChoose = __('Choose stars size', 'yet-another-stars-rating');
12
+ export const yasrSelectSizeSmall = __('Small', 'yet-another-stars-rating');
13
+ export const yasrSelectSizeMedium = __('Medium', 'yet-another-stars-rating');
14
+ export const yasrSelectSizeLarge = __('Large', 'yet-another-stars-rating');
15
+
16
+ export const yasrLeaveThisBlankText = __('Leave this blank if you don\'t know what you\'re doing.', 'yet-another-stars-rating');
17
+
18
+ export const yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
19
+ export const yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
20
+
21
+
22
+ export function YasrPrintSelectSize (props) {
23
+ return (
24
+ <form>
25
+ <select value={props.size} onChange={(e) => yasrSetStarsSize(props.setAttributes, e)}>
26
+ <option value="--">{yasrGutenUtils.yasrSelectSizeChoose}</option>
27
+ <option value="small">{yasrGutenUtils.yasrSelectSizeSmall}</option>
28
+ <option value="medium">{yasrGutenUtils.yasrSelectSizeMedium}</option>
29
+ <option value="large">{yasrGutenUtils.yasrSelectSizeLarge}</option>
30
+ </select>
31
+ </form>
32
+ );
33
+ }
34
+
35
+ function yasrSetStarsSize(setAttributes, event) {
36
+ const selected = event.target.querySelector( 'option:checked' );
37
+ setAttributes( { size: selected.value } );
38
+ event.preventDefault();
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
+ );
51
+ }
52
+
53
+ function yasrSetPostId (setAttributes, event) {
54
+ if (event.key === 'Enter') {
55
+ const postIdValue = event.target.value;
56
+
57
+ //postID is always a string, here I check if this string is made only by digits
58
+ var isNum = /^\d+$/.test(postIdValue);
59
+
60
+ if (isNum === true || postIdValue === '') {
61
+ setAttributes({postId: postIdValue})
62
+ }
63
+ event.preventDefault();
64
+ }
65
+ }
66
+
67
+ export function YasrProText () {
68
+
69
+ const YasrProText1 = __('To be able to customize this ranking, you need', 'yet-another-stars-rating');
70
+ const YasrProText2 = __('You can buy the plugin, including support, updates and upgrades, on',
71
+ 'yet-another-stars-rating');
72
+
73
+ return (
74
+ <h3>
75
+ {YasrProText1}
76
+ &nbsp;
77
+ <a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro">
78
+ Yasr Pro.
79
+ </a><br />
80
+ {YasrProText2}
81
+ &nbsp;
82
+ <a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings">
83
+ yetanotherstarsrating.com
84
+ </a>
85
+ </h3>
86
+ )
87
+
88
+ }
89
+
90
+ export function YasrNoSettingsPanel (props) {
91
+ return (
92
+ <div>
93
+ <YasrProText/>
94
+ </div>
95
+ );
96
+ }
97
+
98
+ /**
99
+ * This is the main panel that all YASR blocks uses
100
+ *
101
+ * @param props
102
+ * @return {JSX.Element}
103
+ * @constructor
104
+ */
105
+ export function YasrBlocksPanel (props) {
106
+ let bottomDesc;
107
+ if(props.block === 'visitors') {
108
+ bottomDesc = yasrVisitorVotesDescription;
109
+ }
110
+ if(props.block === 'overall') {
111
+ bottomDesc = yasrOverallDescription;
112
+ }
113
+
114
+ return (
115
+ <InspectorControls>
116
+ {props.block === 'overall' && <YasrDivRatingOverall />}
117
+ <PanelBody title='Settings'>
118
+ <h3>{yasrOptionalText}</h3>
119
+
120
+ <div className="yasr-guten-block-panel">
121
+ <label>{yasrLabelSelectSize}</label>
122
+ <div>
123
+ <YasrPrintSelectSize size={props.size} setAttributes={props.setAttributes}/>
124
+ </div>
125
+ </div>
126
+
127
+ <div className="yasr-guten-block-panel">
128
+ <label>Post ID</label>
129
+ <YasrPrintInputId postId={props.postId} setAttributes={props.setAttributes}/>
130
+ <div className="yasr-guten-block-explain">
131
+ {yasrLeaveThisBlankText}
132
+ </div>
133
+ </div>
134
+
135
+ <div className="yasr-guten-block-panel">
136
+ {bottomDesc}
137
+ </div>
138
+ </PanelBody>
139
+ </InspectorControls>
140
+ );
141
+
142
+ }
143
+
144
+ export function YasrDivRatingOverall (props) {
145
+ const yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
146
+ let overallRating = wp.data.select('core/editor').getCurrentPost().meta.yasr_overall_rating;
147
+
148
+ const rateCallback = function (rating, done) {
149
+ rating = rating.toFixed(1);
150
+ rating = parseFloat(rating);
151
+
152
+ wp.data.dispatch('core/editor').editPost(
153
+ { meta: { yasr_overall_rating: rating } }
154
+ );
155
+
156
+ this.setRating(rating);
157
+ done();
158
+ };
159
+ return (
160
+ <div className="yasr-guten-block-panel yasr-guten-block-panel-center">
161
+ {yasrOverallRateThis}
162
+ <div id={'overall-rater'} ref={() =>
163
+ yasrSetRaterValue (
164
+ 32,
165
+ 'overall-rater',
166
+ false,
167
+ 0.1,
168
+ false,
169
+ overallRating,
170
+ rateCallback
171
+ )
172
+ } />
173
+ </div>
174
+ );
175
+ }
admin/js/src/guten/yasr-guten-panel.js CHANGED
@@ -1,84 +1,18 @@
1
- //import ReviewsInComments from '../../../../yasr_pro/js/src/guten/yasr-pro-guten-panel'
2
- import {createHooks} from '@wordpress/hooks';
3
-
4
- const {__} = wp.i18n; // Import __() from wp.i18n
5
- const {registerPlugin} = wp.plugins;
6
- const {PluginSidebar, PluginSidebarMoreMenuItem} = wp.editPost;
7
- const {TextControl, PanelBody, PanelRow} = wp.components;
8
- const {BlockControls,InspectorControls} = wp.editor;
9
- const {Fragment} = wp.element;
10
-
11
- const yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
12
- const yasrRichSnippetOptions = __('Rich snippet options', 'yet-another-stars-rating');
13
- const yasrPostExcluded = __('Is this a review?', 'yet-another-stars-rating');
14
- const yasrSelectSnippetTitle = __('Select ItemType ', 'yet-another-stars-rating');
15
 
16
  const ContentBelowSidebar = () => {
17
  return <div/>;
18
  };
19
 
 
20
 
21
- class YasrDivRatingOverall extends React.Component {
22
-
23
- shouldComponentUpdate(nextProps, nextState) {
24
- return false;
25
- }
26
-
27
- constructor(props) {
28
- super(props);
29
- this.yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
30
- this.yasrOverallMoreInfo =
31
- __("This is the same value that you find the \"Yasr: Overall Rating\" block.",
32
- 'yet-another-stars-rating');
33
- }
34
-
35
- printDivOverallRater() {
36
- return(
37
- <div>
38
- <div id="overall-rater-panel" ref={()=>
39
- raterJs({
40
- starSize: 32,
41
- step: 0.1,
42
- showToolTip: false,
43
- rating: wp.data.select('core/editor').getCurrentPost().meta.yasr_overall_rating,
44
- readOnly: false,
45
- element: document.querySelector("#overall-rater-panel"),
46
- rateCallback: function(rating, done){
47
-
48
- rating = rating.toFixed(1);
49
- rating = parseFloat(rating);
50
-
51
- wp.data.dispatch('core/editor').editPost(
52
- { meta: { yasr_overall_rating: rating } }
53
- );
54
-
55
- this.setRating(rating);
56
-
57
- done();
58
- }
59
- })
60
- }
61
- />
62
- <br />
63
- {this.yasrOverallMoreInfo}
64
- </div>
65
- )
66
- }
67
-
68
- render () {
69
- return (
70
- <div>
71
- {this.yasrOverallRateThis}
72
- <div>
73
- {this.printDivOverallRater()}
74
- </div>
75
- </div>
76
-
77
- );
78
- }
79
-
80
- }
81
-
82
  class YasrSideBarAutoInsert extends React.Component {
83
 
84
  constructor(props) {
@@ -117,7 +51,7 @@ class YasrSideBarAutoInsert extends React.Component {
117
  return (
118
  <div className="yasr-guten-block-panel-center">
119
  <hr />
120
- <label><span>{yasrDisableAutoInsert}</span></label>
121
  <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
122
  <input type="checkbox"
123
  name="yasr_auto_insert_disabled"
@@ -138,116 +72,6 @@ class YasrSideBarAutoInsert extends React.Component {
138
 
139
  }
140
 
141
- /*class YasrDivIsReview extends React.Component {
142
-
143
- constructor(props) {
144
- super(props);
145
-
146
- let isThisPostReview = wp.data.select('core/editor').getCurrentPost().meta.yasr_post_is_review;
147
- let isThisPostReviewCheckbox = false;
148
-
149
- if (isThisPostReview === 'yes') {
150
- isThisPostReviewCheckbox = true;
151
- }
152
-
153
- this.state = {postIsReview: isThisPostReviewCheckbox};
154
-
155
- this.yasrUpdatePostMetaIsReview = this.yasrUpdatePostMetaIsReview.bind(this);
156
- }
157
-
158
- yasrUpdatePostMetaIsReview(event) {
159
-
160
- const target = event.target;
161
- const postIsReview = target.type === 'checkbox' ? target.checked : target.value;
162
-
163
- this.setState({postIsReview: postIsReview});
164
-
165
- if (postIsReview === true) {
166
- wp.data.dispatch('core/editor').editPost(
167
- { meta: { yasr_post_is_review: 'yes' } }
168
- );
169
- } else {
170
- wp.data.dispatch('core/editor').editPost(
171
- { meta: { yasr_post_is_review: 'no' } }
172
- );
173
- }
174
-
175
- }
176
-
177
- render () {
178
- return (
179
- <div className="yasr-guten-block-panel-center">
180
- <div className="rich-snippet-title">{yasrRichSnippetOptions}</div>
181
- <label><span>{yasrPostExcluded}</span></label>
182
- <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-post-is-review">
183
- <input type="checkbox"
184
- name="yasr_post_is_review"
185
- className="yasr-onoffswitch-checkbox"
186
- value="yes"
187
- id="yasr-post-is-review-switch"
188
- defaultChecked={this.state.postIsReview}
189
- onChange={this.yasrUpdatePostMetaIsReview}
190
- />
191
- <label className="yasr-onoffswitch-label" htmlFor="yasr-post-is-review-switch">
192
- <span className="yasr-onoffswitch-inner"></span>
193
- <span className="yasr-onoffswitch-switch"></span>
194
- </label>
195
- </div>
196
- <p></p>
197
- </div>
198
- );
199
- }
200
-
201
- }
202
-
203
- class YasrSideBarSelectSnippets extends React.Component {
204
-
205
- supportedItemtype;
206
-
207
- constructor(props) {
208
- super(props);
209
-
210
- //at the begin, get the default type
211
- let snippetType = yasrConstantGutenberg.defaultItemType;
212
-
213
- //get array with all supported itemtypes
214
- this.supportedItemtype = wp.data.select('core/editor').getCurrentPost().yasr_all_itemtypes;
215
-
216
- //get postmeta itemtype
217
- let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
218
-
219
- //if the postmeta is in the array of all item, set in the select the postmeta_itemtype
220
- if(this.supportedItemtype.includes(postMetaItemType)) {
221
- snippetType = postMetaItemType;
222
- }
223
-
224
- this.state = {snippet: snippetType};
225
-
226
- this.yasrSetItemType = this.yasrSetItemType.bind(this);
227
- }
228
-
229
- yasrSetItemType(event) {
230
- this.setState({snippet: event.target.value});
231
-
232
- wp.data.dispatch( 'core/editor' ).editPost(
233
- { meta: { yasr_review_type: event.target.value } }
234
- );
235
- }
236
-
237
- render() {
238
- return (
239
- <div className="yasr-guten-block-panel-center">
240
- <label><span>{yasrSelectSnippetTitle}</span></label>
241
- <select value={this.state.snippet} onChange={this.yasrSetItemType}>
242
- {this.supportedItemtype.map((snippet) => {
243
- return <option value={snippet}>{snippet}</option>;
244
- })}
245
- </select>
246
- </div>
247
- );
248
- }
249
- }*/
250
-
251
  class yasrSidebar extends React.Component {
252
 
253
  constructor(props) {
@@ -269,13 +93,17 @@ class yasrSidebar extends React.Component {
269
  {wp.hooks.doAction('yasr_below_panel', YasrBelowSidebar)}
270
  return (
271
  <Fragment>
272
- <PluginSidebarMoreMenuItem name="yasr-sidebar" type="sidebar" target="yasr-guten-sidebar" >
273
  { __( 'YASR post settings', 'yet-another-stars-rating' ) }
274
  </PluginSidebarMoreMenuItem>
275
  <PluginSidebar name="yasr-guten-sidebar" title="YASR Settings">
276
  <PanelBody>
277
  <div className="yasr-guten-block-panel yasr-guten-block-panel-center">
278
  <YasrDivRatingOverall />
 
 
 
 
279
  {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert />}
280
  {YasrBelowSidebar}
281
  </div>
@@ -286,8 +114,6 @@ class yasrSidebar extends React.Component {
286
  }
287
  }
288
 
289
-
290
-
291
  //Custom sidebar
292
  registerPlugin( 'yasr-sidebar', {
293
  icon: 'star-half',
1
+ const {__} = wp.i18n; // Import __() from wp.i18n
2
+ const {registerPlugin} = wp.plugins;
3
+ const {PluginSidebar, PluginSidebarMoreMenuItem} = wp.editPost;
4
+ const {PanelBody} = wp.components;
5
+ const {Fragment} = wp.element;
 
 
 
 
 
 
 
 
 
6
 
7
  const ContentBelowSidebar = () => {
8
  return <div/>;
9
  };
10
 
11
+ import {YasrDivRatingOverall} from './blocks/yasrGutenUtils';
12
 
13
+ /**
14
+ * Show auto insert option
15
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  class YasrSideBarAutoInsert extends React.Component {
17
 
18
  constructor(props) {
51
  return (
52
  <div className="yasr-guten-block-panel-center">
53
  <hr />
54
+ <label><span>{__('Disable auto insert for this post or page?', 'yet-another-stars-rating')}</span></label>
55
  <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
56
  <input type="checkbox"
57
  name="yasr_auto_insert_disabled"
72
 
73
  }
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  class yasrSidebar extends React.Component {
76
 
77
  constructor(props) {
93
  {wp.hooks.doAction('yasr_below_panel', YasrBelowSidebar)}
94
  return (
95
  <Fragment>
96
+ <PluginSidebarMoreMenuItem name="yasr-sidebar" type="sidebar" target="yasr-guten-sidebar" >
97
  { __( 'YASR post settings', 'yet-another-stars-rating' ) }
98
  </PluginSidebarMoreMenuItem>
99
  <PluginSidebar name="yasr-guten-sidebar" title="YASR Settings">
100
  <PanelBody>
101
  <div className="yasr-guten-block-panel yasr-guten-block-panel-center">
102
  <YasrDivRatingOverall />
103
+ <div>
104
+ {__('This is the same value that you find the "Yasr: Overall Rating" block.',
105
+ 'yet-another-stars-rating')}
106
+ </div>
107
  {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert />}
108
  {YasrBelowSidebar}
109
  </div>
114
  }
115
  }
116
 
 
 
117
  //Custom sidebar
118
  registerPlugin( 'yasr-sidebar', {
119
  icon: 'star-half',
admin/js/yasr-gutenberg.js DELETED
@@ -1 +0,0 @@
1
- (()=>{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 r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function n(t,r){return!r||"object"!==e(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t):r}function a(e){return(a=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,h=(u.BlockControls,u.InspectorControls),y=s("All these settings are optional","yet-another-stars-rating"),m=s("Choose Size","yet-another-stars-rating"),d=s("Choose stars size","yet-another-stars-rating"),f=s("Small","yet-another-stars-rating"),p=s("Medium","yet-another-stars-rating"),g=s("Large","yet-another-stars-rating"),v=s("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),R=s("Remember: only the post author can rate here.","yet-another-stars-rating"),b=s("This is the star set where your users will be able to vote","yet-another-stars-rating");function E(){var e=s("To be able to customize this ranking, you need","yet-another-stars-rating"),t=s("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){return React.createElement("div",null,React.createElement(E,null))}o("yet-another-stars-rating/yasr-overall-rating",{title:s("Yasr: Overall Rating","yet-another-stars-rating"),description:s("Insert the author rating","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",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,b=i.size,E=i.postId,_=e.setAttributes,k=e.isSelected,w=u,A=null,I=null;"--"!==b&&(A=' size="'+b+'"'),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&&r(e,t)}(h,React.Component);var o,i,l,c,u=(l=h,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=a(l);if(c){var r=a(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return n(this,e)});function h(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),(t=u.call(this,e)).yasrOverallRateThis=s("Rate this article / item","yet-another-stars-rating"),t}return o=h,(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:w,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),h}();function O(){return React.createElement("form",null,React.createElement("select",{value:b,onChange:S},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},p),React.createElement("option",{value:"large"},g)))}function S(e){var t=e.target.querySelector("option:checked");_({size:t.value}),e.preventDefault()}function N(){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 C(e){return React.createElement(h,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,y),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,m),React.createElement("div",null,React.createElement(O,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(N,null),React.createElement("div",{className:"yasr-guten-block-explain"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},R)))}return React.createElement(c,null,React.createElement(C,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",A,I,"]",k&&React.createElement(O,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a="",s=n;return r&&(a+='size="'+r+'"'),n&&("--"===n&&(s=wp.data.select("core/editor").getCurrentPostId()),a+=' postid="'+s+'"'),React.createElement("div",null,"[yasr_overall_rating ",a,"]")}}),o("yet-another-stars-rating/yasr-visitor-votes",{title:s("Yasr: Visitor Votes","yet-another-stars-rating"),description:s("Insert the ability for your visitors to vote","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",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,r=e.attributes,n=r.size,a=r.postId,s=e.setAttributes,o=e.isSelected,i=null,u=null;function R(){return React.createElement("form",null,React.createElement("select",{value:n,onChange:E},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},p),React.createElement("option",{value:"large"},g)))}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:k}))}function k(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||s({postId:t}),e.preventDefault()}}function w(e){return React.createElement(h,null,React.createElement(l,{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(R,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"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},b)))}return t=/^\d+$/.test(a),"--"!==n&&(i=' size="'+n+'"'),"--"!==a&&!0===t&&(u=' postid="'+a+'"'),React.createElement(c,null,React.createElement(w,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",i,u,"]",o&&React.createElement(R,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a="",s=n;return r&&(a+='size="'+r+'"'),n&&("--"===n&&(s=wp.data.select("core/editor").getCurrentPostId()),a+=' postid="'+s+'"'),React.createElement("div",null,"[yasr_visitor_votes ",a,"]")}}),o("yet-another-stars-rating/overall-rating-ranking",{title:s("Yasr: Ranking by overall rating","yet-another-stars-rating"),description:s("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:[s("ranking","yet-another-stars-rating"),s("highest","yet-another-stars-rating"),s("chart","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(_,{key:0})];function r(e){return React.createElement(h,null,React.createElement(l,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,t))))}return wp.hooks.doAction("yasr_overall_rating_rankings",t),React.createElement(c,null,React.createElement(r,null),React.createElement("div",{className:e.className},"[yasr_ov_ranking]"))},save:function(e){return React.createElement("div",null,"[yasr_ov_ranking]")}}),o("yet-another-stars-rating/visitor-votes-ranking",{title:s("Yasr: Ranking by visitors votes","yet-another-stars-rating"),description:s("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:[s("ranking","yet-another-stars-rating"),s("highest","yet-another-stars-rating"),s("most","yet-another-stars-rating"),s("chart","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(_,{key:0})];function r(e){return React.createElement(h,null,React.createElement(l,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,t))))}return wp.hooks.doAction("yasr_visitor_votes_rankings",t),React.createElement(c,null,React.createElement(r,null),React.createElement("div",{className:e.className},"[yasr_most_or_highest_rated_posts]"))},save:function(e){return React.createElement("div",null,"[yasr_most_or_highest_rated_posts]")}}),o("yet-another-stars-rating/most-active-reviewers",{title:s("Yasr: Most Active Authors","yet-another-stars-rating"),description:s("This ranking shows the most active reviewers on your site.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[s("ranking","yet-another-stars-rating"),s("highest","yet-another-stars-rating"),s("most","yet-another-stars-rating"),s("chart","yet-another-stars-rating"),s("authors","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(_,{key:0})];function r(e){return React.createElement(h,null,React.createElement(l,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,t))))}return wp.hooks.doAction("yasr_top_reviewers_setting",t),React.createElement(c,null,React.createElement(r,null),React.createElement("div",{className:e.className},"[yasr_top_reviewers]"))},save:function(e){return React.createElement("div",null,"[yasr_top_reviewers]")}}),o("yet-another-stars-rating/most-active-users",{title:s("Yasr: Most Active Visitors","yet-another-stars-rating"),description:s("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:[s("ranking","yet-another-stars-rating"),s("highest","yet-another-stars-rating"),s("most","yet-another-stars-rating"),s("chart","yet-another-stars-rating"),s("visitors","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(_,{key:0})];function r(e){return React.createElement(h,null,React.createElement(l,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,t))))}return wp.hooks.doAction("yasr_top_visitor_setting",t),React.createElement(c,null,React.createElement(r,null),React.createElement("div",{className:e.className},"[yasr_most_active_users]"))},save:function(e){return React.createElement("div",null,"[yasr_most_active_users]")}})})(),(()=>{"use strict";const e=function(e){return"string"!=typeof e||""===e?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)},t=function(e){return"string"!=typeof e||""===e?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(e)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)},r=function(r,n){return function(a,s,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,l=r[n];if(t(a)&&e(s))if("function"==typeof o)if("number"==typeof i){var c={callback:o,priority:i,namespace:s};if(l[a]){var u,h=l[a].handlers;for(u=h.length;u>0&&!(i>=h[u-1].priority);u--);u===h.length?h[u]=c:h.splice(u,0,c),l.__current.forEach((function(e){e.name===a&&e.currentIndex>=u&&e.currentIndex++}))}else l[a]={handlers:[c],runs:0};"hookAdded"!==a&&r.doAction("hookAdded",a,s,o,i)}else console.error("If specified, the hook priority must be a number.");else console.error("The hook callback must be a function.")}},n=function(r,n){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(s,o){var i=r[n];if(t(s)&&(a||e(o))){if(!i[s])return 0;var l=0;if(a)l=i[s].handlers.length,i[s]={runs:i[s].runs,handlers:[]};else for(var c=i[s].handlers,u=function(e){c[e].namespace===o&&(c.splice(e,1),l++,i.__current.forEach((function(t){t.name===s&&t.currentIndex>=e&&t.currentIndex--})))},h=c.length-1;h>=0;h--)u(h);return"hookRemoved"!==s&&r.doAction("hookRemoved",s,o),l}}},a=function(e,t){return function(r,n){var a=e[t];return void 0!==n?r in a&&a[r].handlers.some((function(e){return e.namespace===n})):r in a}},s=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(n){var a=e[t];a[n]||(a[n]={handlers:[],runs:0}),a[n].runs++;for(var s=a[n].handlers,o=arguments.length,i=new Array(o>1?o-1:0),l=1;l<o;l++)i[l-1]=arguments[l];if(!s||!s.length)return r?i[0]:void 0;var c={name:n,currentIndex:0};for(a.__current.push(c);c.currentIndex<s.length;){var u=s[c.currentIndex],h=u.callback.apply(null,i);r&&(i[0]=h),c.currentIndex++}return a.__current.pop(),r?i[0]:void 0}},o=function(e,t){return function(){var r,n,a=e[t];return null!==(r=null===(n=a.__current[a.__current.length-1])||void 0===n?void 0:n.name)&&void 0!==r?r:null}},i=function(e,t){return function(r){var n=e[t];return void 0===r?void 0!==n.__current[0]:!!n.__current[0]&&r===n.__current[0].name}},l=function(e,r){return function(n){var a=e[r];if(t(n))return a[n]&&a[n].runs?a[n].runs:0}};var c=new function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=r(this,"actions"),this.addFilter=r(this,"filters"),this.removeAction=n(this,"actions"),this.removeFilter=n(this,"filters"),this.hasAction=a(this,"actions"),this.hasFilter=a(this,"filters"),this.removeAllActions=n(this,"actions",!0),this.removeAllFilters=n(this,"filters",!0),this.doAction=s(this,"actions"),this.applyFilters=s(this,"filters",!0),this.currentAction=o(this,"actions"),this.currentFilter=o(this,"filters"),this.doingAction=i(this,"actions"),this.doingFilter=i(this,"filters"),this.didAction=l(this,"actions"),this.didFilter=l(this,"filters")};function u(e){return(u="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 h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function m(e,t,r){return t&&y(e.prototype,t),r&&y(e,r),e}function d(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&&f(e,t)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(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 r,n=R(e);if(t){var a=R(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return g(this,r)}}function g(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?v(e):t}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(e){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}c.addAction,c.addFilter,c.removeAction,c.removeFilter,c.hasAction,c.hasFilter,c.removeAllActions,c.removeAllFilters,c.doAction,c.applyFilters,c.currentAction,c.currentFilter,c.doingAction,c.doingFilter,c.didAction,c.didFilter,c.actions,c.filters;var b=wp.i18n.__,E=wp.plugins.registerPlugin,_=wp.editPost,k=_.PluginSidebar,w=_.PluginSidebarMoreMenuItem,A=wp.components,I=(A.TextControl,A.PanelBody),P=(A.PanelRow,wp.editor),O=(P.BlockControls,P.InspectorControls,wp.element.Fragment),S=b("Disable auto insert for this post or page?","yet-another-stars-rating"),N=(b("Rich snippet options","yet-another-stars-rating"),b("Is this a review?","yet-another-stars-rating"),b("Select ItemType ","yet-another-stars-rating"),function(){return React.createElement("div",null)}),T=function(e){d(r,React.Component);var t=p(r);function r(e){var n;return h(this,r),(n=t.call(this,e)).yasrOverallRateThis=b("Rate this article / item","yet-another-stars-rating"),n.yasrOverallMoreInfo=b('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating"),n}return m(r,[{key:"shouldComponentUpdate",value:function(e,t){return!1}},{key:"printDivOverallRater",value:function(){return React.createElement("div",null,React.createElement("div",{id:"overall-rater-panel",ref:function(){return raterJs({starSize:32,step:.1,showToolTip:!1,rating:wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,readOnly:!1,element:document.querySelector("#overall-rater-panel"),rateCallback: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()}})}}),React.createElement("br",null),this.yasrOverallMoreInfo)}},{key:"render",value:function(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,this.printDivOverallRater()))}}]),r}(),C=function(e){d(r,React.Component);var t=p(r);function r(e){var n;h(this,r),n=t.call(this,e);var a=!1;return"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(a=!0),n.state={postExcluded:a},n.yasrUpdatePostMetaAutoInsert=n.yasrUpdatePostMetaAutoInsert.bind(v(n)),n}return m(r,[{key:"yasrUpdatePostMetaAutoInsert",value:function(e){var t=e.target,r="checkbox"===t.type?t.checked:t.value;this.setState({postExcluded:r}),!0===r?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,S)),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"}))))}}]),r}(),x=function(e){d(r,React.Component);var t=p(r);function r(e){var n;h(this,r),n=t.call(this,e);var a=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(a=!0),n.state={yasrAutoInsertEnabled:a},n}return m(r,[{key:"render",value:function(){var e=[React.createElement(N,{key:0})];return wp.hooks.doAction("yasr_below_panel",e),React.createElement(O,null,React.createElement(w,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},b("YASR post settings","yet-another-stars-rating")),React.createElement(k,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(I,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(T,null),this.state.yasrAutoInsertEnabled&&React.createElement(C,null),e))))}}]),r}();E("yasr-sidebar",{icon:"star-half",title:b("Yasr: Page Settings","yet-another-stars-rating"),render:x})})();
 
admin/yasr-admin-functions.php CHANGED
@@ -67,7 +67,7 @@ function yasr_add_admin_scripts($hook) {
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(
73
  'yasrcss-pricing',
@@ -83,7 +83,7 @@ function yasr_add_admin_scripts($hook) {
83
  YASR_VERSION_NUM,
84
  true
85
  );
86
- }
87
 
88
  if ($hook === 'index.php'
89
  || $hook === 'edit.php'
@@ -169,9 +169,9 @@ function yasr_add_pages() {
169
  );
170
 
171
  //Filter the pricing page only if trial is not set
172
- if(isset($_GET['page']) && $_GET['page'] === 'yasr_settings_page-pricing' && !isset($_GET['trial'])) {
173
- yasr_fs()->add_filter( 'templates/pricing.php', 'yasr_pricing_page_callback' );
174
- }
175
 
176
  if (yasr_fs()->is_free_plan() && !yasr_fs()->is_trial()) {
177
  global $submenu;
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(
73
  'yasrcss-pricing',
83
  YASR_VERSION_NUM,
84
  true
85
  );
86
+ }*/
87
 
88
  if ($hook === 'index.php'
89
  || $hook === 'edit.php'
169
  );
170
 
171
  //Filter the pricing page only if trial is not set
172
+ //if(isset($_GET['page']) && $_GET['page'] === 'yasr_settings_page-pricing' && !isset($_GET['trial'])) {
173
+ //yasr_fs()->add_filter( 'templates/pricing.php', 'yasr_pricing_page_callback' );
174
+ //}
175
 
176
  if (yasr_fs()->is_free_plan() && !yasr_fs()->is_trial()) {
177
  global $submenu;
admin/yasr-admin-init.php CHANGED
@@ -28,6 +28,11 @@ if(!is_admin()) {
28
 
29
  //e.g. http://localhost/plugin_development/wp-content/plugins/yet-another-stars-rating/admin/js/
30
  define('YASR_JS_DIR_ADMIN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/js/');
 
 
 
 
 
31
  //CSS directory absolute URL
32
  define('YASR_CSS_DIR_ADMIN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/css/');
33
 
@@ -49,8 +54,6 @@ require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-actions.php';
49
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-actions-ajax.php';
50
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-filters.php';
51
  require YASR_ABSOLUTE_PATH_ADMIN . '/settings/yasr-settings-functions-misc.php';
52
- require YASR_ABSOLUTE_PATH_ADMIN . '/editor/yasr-editor-functions.php';
53
- require YASR_ABSOLUTE_PATH_ADMIN . '/editor/YasrOnSavePost.php';
54
 
55
  /**
56
  * Callback function for the spl_autoload_register above.
@@ -79,10 +82,20 @@ function yasr_autoload_admin_classes($class) {
79
  require($file_name_settings);
80
  }
81
 
 
 
 
 
 
 
 
82
  }
83
 
84
  //AutoLoad Yasr Shortcode Classes, only when a object is created
85
  spl_autoload_register('yasr_autoload_admin_classes');
86
 
87
  $yasr_settings = new YasrSettings();
88
- $yasr_settings->init();
 
 
 
28
 
29
  //e.g. http://localhost/plugin_development/wp-content/plugins/yet-another-stars-rating/admin/js/
30
  define('YASR_JS_DIR_ADMIN', plugins_url() . '/' . YASR_RELATIVE_PATH_ADMIN . '/js/');
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/');
38
 
54
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-actions-ajax.php';
55
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-filters.php';
56
  require YASR_ABSOLUTE_PATH_ADMIN . '/settings/yasr-settings-functions-misc.php';
 
 
57
 
58
  /**
59
  * Callback function for the spl_autoload_register above.
82
  require($file_name_settings);
83
  }
84
 
85
+ $file_name_editor = YASR_ABSOLUTE_PATH_ADMIN . '/editor/' . $class . '.php';
86
+
87
+ // check if file exists, just to be sure
88
+ if (file_exists($file_name_editor)) {
89
+ require($file_name_editor);
90
+ }
91
+
92
  }
93
 
94
  //AutoLoad Yasr Shortcode Classes, only when a object is created
95
  spl_autoload_register('yasr_autoload_admin_classes');
96
 
97
  $yasr_settings = new YasrSettings();
98
+ $yasr_settings->init();
99
+
100
+ $yasr_editor = new YasrEditorHooks();
101
+ $yasr_editor->init();
changelog.txt CHANGED
@@ -1,3 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 2.6.2 =
2
  * TWEAK: yasr_top_ten_highest_rated is now depcrecated. yasr_ov_ranking will take its place
3
  * TWEAK: yasr_top_5_reviewers is now depcrecated. yasr_top_reviewers will take its place
1
+ = 2.6.5 =
2
+ * Code cleanup and minor fixes.
3
+
4
+ = 2.6.4 =
5
+ * FIX: style dependency warning
6
+ * FIX: JS error appering after first installation
7
+
8
+ = 2.6.3 =
9
+ * NEW feature: Now available the new "Rankings" tab in settings, here you can see a live preview of the rankings before adding it to you post
10
+ * TWEAKED: code cleanup
11
+ [//]: # fs_premium_only_begin
12
+ PREMIUM ONLY:
13
+ * NEW feature: brand new shortcode generator for the rankings! Go into the "rankings" tab inside the settings to see it working!
14
+ * FIXED: yasr_pro_rankings_from_comments_reviews was broken
15
+ * TWEAK: yasr_pro_visitor_votes_chart is now deprecated. yasr_most_or_highest_rated_posts will take its place
16
+ [//]: # fs_premium_only_end
17
+
18
  = 2.6.2 =
19
  * TWEAK: yasr_top_ten_highest_rated is now depcrecated. yasr_ov_ranking will take its place
20
  * TWEAK: yasr_top_5_reviewers is now depcrecated. yasr_top_reviewers will take its place
freemius/includes/class-freemius.php CHANGED
@@ -1642,7 +1642,11 @@
1642
 
1643
  if ( $this->is_plugin() ) {
1644
  if ( $this->_is_network_active ) {
 
1645
  add_action( 'wpmu_new_blog', array( $this, '_after_new_blog_callback' ), 10, 6 );
 
 
 
1646
  }
1647
 
1648
  register_deactivation_hook( $this->_plugin_main_file_path, array( $this, '_deactivate_plugin_hook' ) );
@@ -1653,11 +1657,10 @@
1653
  add_action( 'archive_blog', array( $this, '_after_site_deactivated_callback' ) );
1654
  add_action( 'make_spam_blog', array( $this, '_after_site_deactivated_callback' ) );
1655
 
1656
- //call the deprecated version if wp_version < 5.1
1657
- if ( version_compare($GLOBALS['wp_version'],'5.1') === -1) {
1658
  add_action( 'deleted_blog', array( $this, '_after_site_deleted_callback' ), 10, 2);
1659
  } else {
1660
- add_action( 'wp_delete_site', array( $this, '_after_wpsite_deleted_callback' ), 10, 2 );
1661
  }
1662
 
1663
  add_action( 'activate_blog', array( $this, '_after_site_reactivated_callback' ) );
@@ -8609,7 +8612,7 @@
8609
  * @uses Freemius::is_network_anonymous() to check if the super-admin network skipped.
8610
  * @uses Freemius::is_network_delegated_connection() to check if the super-admin network delegated the connection to the site admins.
8611
  */
8612
- function _after_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
8613
  $this->_logger->entrance();
8614
 
8615
  if ( $this->is_premium() &&
@@ -8707,6 +8710,27 @@
8707
  }
8708
  }
8709
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8710
  /**
8711
  * @author Vova Feldman (@svovaf)
8712
  * @since 1.1.3
1642
 
1643
  if ( $this->is_plugin() ) {
1644
  if ( $this->_is_network_active ) {
1645
+ if ( version_compare( $GLOBALS['wp_version'], '5.1', '<' ) ) {
1646
  add_action( 'wpmu_new_blog', array( $this, '_after_new_blog_callback' ), 10, 6 );
1647
+ } else {
1648
+ add_action( 'wp_insert_site', array( $this, '_after_wp_insert_site_callback' ) );
1649
+ }
1650
  }
1651
 
1652
  register_deactivation_hook( $this->_plugin_main_file_path, array( $this, '_deactivate_plugin_hook' ) );
1657
  add_action( 'archive_blog', array( $this, '_after_site_deactivated_callback' ) );
1658
  add_action( 'make_spam_blog', array( $this, '_after_site_deactivated_callback' ) );
1659
 
1660
+ if ( version_compare( $GLOBALS['wp_version'], '5.1', '<' ) ) {
 
1661
  add_action( 'deleted_blog', array( $this, '_after_site_deleted_callback' ), 10, 2);
1662
  } else {
1663
+ add_action( 'wp_delete_site', array( $this, '_after_wpsite_deleted_callback' ) );
1664
  }
1665
 
1666
  add_action( 'activate_blog', array( $this, '_after_site_reactivated_callback' ) );
8612
  * @uses Freemius::is_network_anonymous() to check if the super-admin network skipped.
8613
  * @uses Freemius::is_network_delegated_connection() to check if the super-admin network delegated the connection to the site admins.
8614
  */
8615
+ public function _after_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
8616
  $this->_logger->entrance();
8617
 
8618
  if ( $this->is_premium() &&
8710
  }
8711
  }
8712
 
8713
+ /**
8714
+ * @author Vova Feldman (@svovaf)
8715
+ * @since 2.4.3
8716
+ *
8717
+ * @param \WP_Site $new_site
8718
+ */
8719
+ public function _after_wp_insert_site_callback( WP_Site $new_site ) {
8720
+ $this->_logger->entrance();
8721
+
8722
+ $this->_after_new_blog_callback(
8723
+ $new_site->id,
8724
+ // Dummy user ID (not in use).
8725
+ 0,
8726
+ $new_site->domain,
8727
+ $new_site->path,
8728
+ $new_site->network_id,
8729
+ // Dummy meta, not in use.
8730
+ array()
8731
+ );
8732
+ }
8733
+
8734
  /**
8735
  * @author Vova Feldman (@svovaf)
8736
  * @since 1.1.3
includes/js/rater-js.min.js CHANGED
@@ -1 +1,2 @@
1
- function raterJs(e){let t=!0;if(void 0===e.element||null===e.element)throw new Error("element required");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)L(e.rating);else{var h=u.dataset.rating;h&&L(+h)}function w(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 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 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 E(){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 L(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&&E(),u.addEventListener("mousemove",w),u.addEventListener("mouseleave",x);let S={setRating:L,getRating:function(){return i},disable:E,enable:function(){g=!1,u.removeAttribute("data-title")},dispose:function(){u.removeEventListener("mousemove",w),u.removeEventListener("mouseleave",x),u.removeEventListener("click",A)}};return u.addEventListener("click",A.bind(S)),S}
 
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}
includes/js/src/rater-js-src.js CHANGED
@@ -1,10 +1,16 @@
1
  /*! Based on rater-js. [c] 2018 by Fredrik Olsson. MIT License */
2
- module.exports = function raterJs(options) {
3
  //private fields
4
  let showToolTip = true;
5
 
6
  if (typeof options.element === "undefined" || options.element === null) {
7
- throw new Error("element required");
 
 
 
 
 
 
8
  }
9
 
10
  if (typeof options.showToolTip !== "undefined") {
1
  /*! Based on rater-js. [c] 2018 by Fredrik Olsson. MIT License */
2
+ function raterJs(options) {
3
  //private fields
4
  let showToolTip = true;
5
 
6
  if (typeof options.element === "undefined" || options.element === null) {
7
+ console.info('missing rating element');
8
+ return;
9
+ }
10
+
11
+ //this means that stars has been already applied
12
+ if(options.element !== null && options.element.classList.contains('yasr-star-rating')) {
13
+ return;
14
  }
15
 
16
  if (typeof options.showToolTip !== "undefined") {
readme.txt CHANGED
@@ -4,8 +4,7 @@ Tags: rating, rate post, rate page, star rating, google rating, votes
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.8
7
- Requires PHP: 5.4
8
- Stable tag: 2.8.3
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -194,6 +193,12 @@ Yes, YASR is 100% fully compatible with PHP 8
194
 
195
  The full changelog can be found in the plugin's directory. Recent entries:
196
 
 
 
 
 
 
 
197
  = 2.8.3 =
198
  * FIXED: compatibility with WordPress 5.8
199
  * FIXED: link to trial page
@@ -274,17 +279,5 @@ The class yasr-total-average-container has be renamed yasr-vv-stats-text-contain
274
  * NEW FEATURE: it is now possible to add the %rating% variable when customizing the text for an user that has already rated.
275
  * TWEAKED: added many filters (docs in the official website) and code cleanup.
276
 
277
- = 2.6.5 =
278
- * Code cleanup and minor fixes.
279
-
280
- = 2.6.4 =
281
- * FIX: style dependency warning
282
- * FIX: JS error appering after first installation
283
-
284
- = 2.6.3 =
285
- * NEW feature: Now available the new "Rankings" tab in settings, here you can see a live preview of the rankings before adding it to you post
286
- * TWEAKED: code cleanup
287
-
288
-
289
  = Additional Info =
290
  See credits.txt file
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
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
199
+ * FIX: some errors that occur using yasr_overall_rating and yasr_visitor_votes gutenberg blocks
200
+ * ENHANCEMENT: All gutenberg's blocks now support alignment
201
+
202
  = 2.8.3 =
203
  * FIXED: compatibility with WordPress 5.8
204
  * FIXED: link to trial page
279
  * NEW FEATURE: it is now possible to add the %rating% variable when customizing the text for an user that has already rated.
280
  * TWEAKED: added many filters (docs in the official website) and code cleanup.
281
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  = Additional Info =
283
  See credits.txt file
yet-another-stars-rating.php CHANGED
@@ -4,7 +4,9 @@
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.3
 
 
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
@@ -76,7 +78,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
- define( 'YASR_VERSION_NUM', '2.8.3' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
+ * Version: 2.8.4
8
+ * Requires at least: 5.6
9
+ * Requires PHP: 5.4
10
  * Author: Dario Curvino
11
  * Author URI: https://dariocurvino.it/
12
  * Text Domain: yet-another-stars-rating
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__ );