Yasr – Yet Another Stars Rating - Version 2.4.3

Version Description

  • NEW FEATURE: is now possible to show ratings next to the title
  • FIXED: guten blocks returns error if post_id parameter was set
  • TWEAKED: added some hooks
Download this release

Release Info

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

Code changes from version 2.4.2 to 2.4.3

admin/classes/YasrOnInstall.php CHANGED
@@ -141,6 +141,9 @@ class YasrOnInstall {
141
  $option['auto_insert_align'] = 'center';
142
  $option['auto_insert_exclude_pages'] = 'yes';
143
  $option['auto_insert_custom_post_only'] = 'no';
 
 
 
144
  $option['show_overall_in_loop'] = 'disabled';
145
  $option['show_visitor_votes_in_loop'] = 'disabled';
146
  $option['text_before_stars'] = 1;
141
  $option['auto_insert_align'] = 'center';
142
  $option['auto_insert_exclude_pages'] = 'yes';
143
  $option['auto_insert_custom_post_only'] = 'no';
144
+ $option['stars_title'] = 'yes';
145
+ $option['stars_title_what'] = 'visitor_rating';
146
+ $option['stars_title_where'] = 'archive';
147
  $option['show_overall_in_loop'] = 'disabled';
148
  $option['show_visitor_votes_in_loop'] = 'disabled';
149
  $option['text_before_stars'] = 1;
admin/editor/yasr-editor-functions.php CHANGED
@@ -61,7 +61,7 @@ add_action('yasr_add_admin_scripts_end', 'yasr_add_js_constant_gutenberg');
61
 
62
  function yasr_add_js_constant_gutenberg($hook) {
63
 
64
- if (yasr_is_gutenberg_page() && ($hook === 'post.php' || $hook === 'post-new.php')) {
65
 
66
  //create an empty array
67
  $constants_array = array();
@@ -83,9 +83,9 @@ function yasr_add_js_constant_gutenberg($hook) {
83
  }
84
 
85
  //Save auto insert value to yasrConstantGutenberg
86
- add_filter('yasr_gutenberg_constants', 'yasr_gutenberg_auto_insert');
87
 
88
- function yasr_gutenberg_auto_insert($constants_array) {
89
 
90
  //add after
91
  if (YASR_AUTO_INSERT_ENABLED === 1) {
@@ -95,6 +95,7 @@ function yasr_gutenberg_auto_insert($constants_array) {
95
  }
96
 
97
  $auto_insert_array = array (
 
98
  'autoInsert' => $auto_insert
99
  );
100
 
61
 
62
  function yasr_add_js_constant_gutenberg($hook) {
63
 
64
+ if (($hook === 'post.php' || $hook === 'post-new.php') && yasr_is_gutenberg_page() ) {
65
 
66
  //create an empty array
67
  $constants_array = array();
83
  }
84
 
85
  //Save auto insert value to yasrConstantGutenberg
86
+ add_filter('yasr_gutenberg_constants', 'yasr_gutenberg_constants');
87
 
88
+ function yasr_gutenberg_constants($constants_array) {
89
 
90
  //add after
91
  if (YASR_AUTO_INSERT_ENABLED === 1) {
95
  }
96
 
97
  $auto_insert_array = array (
98
+ 'adminurl' => get_admin_url(),
99
  'autoInsert' => $auto_insert
100
  );
101
 
admin/editor/yasr-metabox-top-right.php CHANGED
@@ -48,7 +48,7 @@ wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
48
  <div id="yasr-rater-overall" >
49
  </div>
50
 
51
- </p>
52
 
53
  <div>
54
  <span id="yasr_rateit_overall_value"></span>
@@ -61,36 +61,33 @@ wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
61
  //Show this message if auto insert is off or if auto insert is not set to show overall rating (so if it is set to visitor rating)
62
  if( YASR_AUTO_INSERT_ENABLED == 0 || (YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_WHAT === 'visitor_rating') ) {
63
  echo "<div>";
64
- _e (
65
- 'Remember to insert this shortcode <strong>[yasr_overall_rating]</strong>
66
  where you want to display this rating',
67
  'yet-another-stars-rating');
68
  echo "</div>";
69
  }
70
  ?>
71
  </div>
72
- <hr>
73
 
74
  <?php
75
 
76
- if (YASR_AUTO_INSERT_ENABLED == 1) {
77
  $is_this_post_exluded = get_post_meta($post_id, 'yasr_auto_insert_disabled', true);
78
- ?>
79
-
80
- <div id="yasr-toprightmetabox-disable-auto-insert">
81
- <?php _e('Disable auto insert for this post or page?', 'yet-another-stars-rating'); ?>
82
- <br />
83
- <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
84
- <input type="checkbox" name="yasr_auto_insert_disabled" class="yasr-onoffswitch-checkbox" value="yes"
85
- id="yasr-auto-insert-disabled-switch" <?php if ($is_this_post_exluded === 'yes') echo " checked='checked' "; ?> >
86
- <label class="yasr-onoffswitch-label" for="yasr-auto-insert-disabled-switch">
87
- <span class="yasr-onoffswitch-inner"></span>
88
- <span class="yasr-onoffswitch-switch"></span>
89
- </label>
90
- </div>
91
- </div>
92
 
93
- <hr>
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  <?php
96
 
48
  <div id="yasr-rater-overall" >
49
  </div>
50
 
51
+ <p />
52
 
53
  <div>
54
  <span id="yasr_rateit_overall_value"></span>
61
  //Show this message if auto insert is off or if auto insert is not set to show overall rating (so if it is set to visitor rating)
62
  if( YASR_AUTO_INSERT_ENABLED == 0 || (YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_WHAT === 'visitor_rating') ) {
63
  echo "<div>";
64
+ _e ('Remember to insert this shortcode <strong>[yasr_overall_rating]</strong>
 
65
  where you want to display this rating',
66
  'yet-another-stars-rating');
67
  echo "</div>";
68
  }
69
  ?>
70
  </div>
 
71
 
72
  <?php
73
 
74
+ if (YASR_AUTO_INSERT_ENABLED === 1) {
75
  $is_this_post_exluded = get_post_meta($post_id, 'yasr_auto_insert_disabled', true);
76
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
+ <hr>
79
+ <div id="yasr-toprightmetabox-disable-auto-insert">
80
+ <?php _e('Disable auto insert for this post or page?', 'yet-another-stars-rating'); ?>
81
+ <br />
82
+ <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
83
+ <input type="checkbox" name="yasr_auto_insert_disabled" class="yasr-onoffswitch-checkbox" value="yes"
84
+ id="yasr-auto-insert-disabled-switch" <?php if ($is_this_post_exluded === 'yes') echo " checked='checked' "; ?> >
85
+ <label class="yasr-onoffswitch-label" for="yasr-auto-insert-disabled-switch">
86
+ <span class="yasr-onoffswitch-inner"></span>
87
+ <span class="yasr-onoffswitch-switch"></span>
88
+ </label>
89
+ </div>
90
+ </div>
91
 
92
  <?php
93
 
admin/js/src/guten/yasr-guten-blocks.js CHANGED
@@ -32,7 +32,7 @@ const yasrVisitorVotesDescription = __('This is the star set where your users wi
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 one year of support, updates and upgrades, on',
36
  'yet-another-stars-rating');
37
 
38
  return (
@@ -55,11 +55,9 @@ function YasrProText () {
55
  function YasrNoSettingsPanel (props) {
56
 
57
  return (
58
- <InspectorControls>
59
- <PanelBody title='Settings'>
60
- <YasrProText/>
61
- </PanelBody>
62
- </InspectorControls>
63
  );
64
 
65
  }
@@ -151,8 +149,8 @@ registerBlockType(
151
  default: '--'
152
  },
153
  postId: {
154
- type: 'number',
155
- default: ''
156
  },
157
  },
158
 
@@ -174,7 +172,7 @@ registerBlockType(
174
 
175
  isNum = /^\d+$/.test(postId);
176
 
177
- if (postId && isNum === true) {
178
  postIdAttribute = ' postid="' +postId + '"';
179
  }
180
 
@@ -255,7 +253,7 @@ registerBlockType(
255
  //postID is always a string, here I check if this string is made only by digits
256
  var isNum = /^\d+$/.test(postIdValue);
257
 
258
- if (isNum === true) {
259
  setAttributes({postId: postIdValue})
260
  }
261
  event.preventDefault();
@@ -320,13 +318,17 @@ registerBlockType(
320
  function( props ) {
321
  const {attributes: {size, postId}} = props;
322
 
323
- let yasrOverallAttributes = null;
 
324
 
325
  if (size) {
326
- yasrOverallAttributes += ' size="' +size+ '"';
327
  }
328
  if (postId) {
329
- yasrOverallAttributes += ' postid="'+postId+'"';
 
 
 
330
  }
331
 
332
  return (
@@ -355,13 +357,12 @@ registerBlockType(
355
  default: '--'
356
  },
357
  postId: {
358
- type: 'number',
359
- default: ''
360
  },
361
  },
362
 
363
  edit:
364
-
365
  function( props ) {
366
 
367
  const { attributes: { size, postId }, setAttributes, isSelected } = props;
@@ -376,11 +377,10 @@ registerBlockType(
376
  sizeAttribute = ' size="' + size + '"';
377
  }
378
 
379
- if (postId && isNum === true) {
380
  postIdAttribute = ' postid="' +postId + '"';
381
  }
382
 
383
-
384
  function YasrPrintSelectSize () {
385
  return (
386
  <form>
@@ -415,7 +415,8 @@ registerBlockType(
415
  //postID is always a string, here I check if this string is made only by digits
416
  var isNum = /^\d+$/.test(postIdValue);
417
 
418
- if (isNum === true) {
 
419
  setAttributes({postId: postIdValue})
420
  }
421
  event.preventDefault();
@@ -462,6 +463,7 @@ registerBlockType(
462
  </div>
463
  </Fragment>
464
  );
 
465
  },
466
 
467
  /**
@@ -476,13 +478,17 @@ registerBlockType(
476
  function( props ) {
477
  const { attributes: {size, postId} } = props;
478
 
479
- let yasrVVAttributes = null;
 
480
 
481
  if (size) {
482
- yasrVVAttributes += ' size="' +size+ '"';
483
  }
484
  if (postId) {
485
- yasrVVAttributes += ' postid="'+postId+'"';
 
 
 
486
  }
487
 
488
  return (
@@ -510,9 +516,28 @@ registerBlockType(
510
 
511
  edit:
512
  function(props) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
513
  return (
514
  <Fragment>
515
- <YasrNoSettingsPanel />
516
  <div className={props.className}>
517
  [yasr_top_ten_highest_rated]
518
  </div>
@@ -559,9 +584,27 @@ registerBlockType(
559
 
560
  function(props) {
561
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
  return (
563
  <Fragment>
564
- <YasrNoSettingsPanel />
565
  <div className={props.className}>
566
  [yasr_most_or_highest_rated_posts]
567
  </div>
@@ -607,9 +650,27 @@ registerBlockType(
607
 
608
  function(props) {
609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
  return (
611
  <Fragment>
612
- <YasrNoSettingsPanel />
613
  <div className={props.className}>
614
  [yasr_top_5_reviewers]
615
  </div>
@@ -655,9 +716,26 @@ registerBlockType(
655
 
656
  function(props) {
657
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
  return (
659
  <Fragment>
660
- <YasrNoSettingsPanel />
661
  <div className={props.className}>
662
  [yasr_top_ten_active_users]
663
  </div>
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');
37
 
38
  return (
55
  function YasrNoSettingsPanel (props) {
56
 
57
  return (
58
+ <div>
59
+ <YasrProText/>
60
+ </div>
 
 
61
  );
62
 
63
  }
149
  default: '--'
150
  },
151
  postId: {
152
+ type: 'string',
153
+ default: '--'
154
  },
155
  },
156
 
172
 
173
  isNum = /^\d+$/.test(postId);
174
 
175
+ if (postId !== '--' && isNum === true) {
176
  postIdAttribute = ' postid="' +postId + '"';
177
  }
178
 
253
  //postID is always a string, here I check if this string is made only by digits
254
  var isNum = /^\d+$/.test(postIdValue);
255
 
256
+ if (isNum === true || postIdValue === '') {
257
  setAttributes({postId: postIdValue})
258
  }
259
  event.preventDefault();
318
  function( props ) {
319
  const {attributes: {size, postId}} = props;
320
 
321
+ let yasrOverallAttributes = '';
322
+ let post_id = postId;
323
 
324
  if (size) {
325
+ yasrOverallAttributes += 'size="' +size+ '"';
326
  }
327
  if (postId) {
328
+ if(postId === '--') {
329
+ post_id = wp.data.select("core/editor").getCurrentPostId();
330
+ }
331
+ yasrOverallAttributes += ' postid="'+post_id+'"';
332
  }
333
 
334
  return (
357
  default: '--'
358
  },
359
  postId: {
360
+ type: 'string',
361
+ default: '--'
362
  },
363
  },
364
 
365
  edit:
 
366
  function( props ) {
367
 
368
  const { attributes: { size, postId }, setAttributes, isSelected } = props;
377
  sizeAttribute = ' size="' + size + '"';
378
  }
379
 
380
+ if (postId !== '--' && isNum === true) {
381
  postIdAttribute = ' postid="' +postId + '"';
382
  }
383
 
 
384
  function YasrPrintSelectSize () {
385
  return (
386
  <form>
415
  //postID is always a string, here I check if this string is made only by digits
416
  var isNum = /^\d+$/.test(postIdValue);
417
 
418
+ //if isNum or if is empty (to remove the value)
419
+ if (isNum === true || postIdValue === '') {
420
  setAttributes({postId: postIdValue})
421
  }
422
  event.preventDefault();
463
  </div>
464
  </Fragment>
465
  );
466
+
467
  },
468
 
469
  /**
478
  function( props ) {
479
  const { attributes: {size, postId} } = props;
480
 
481
+ let yasrVVAttributes = '';
482
+ let post_id = postId;
483
 
484
  if (size) {
485
+ yasrVVAttributes += 'size="' +size+ '"';
486
  }
487
  if (postId) {
488
+ if(postId === '--') {
489
+ post_id = wp.data.select("core/editor").getCurrentPostId();
490
+ }
491
+ yasrVVAttributes += ' postid="'+post_id+'"';
492
  }
493
 
494
  return (
516
 
517
  edit:
518
  function(props) {
519
+
520
+ let YasrORRSettings = [<YasrNoSettingsPanel key={0}/>];
521
+ {wp.hooks.doAction('yasr_overall_rating_rankings', YasrORRSettings)}
522
+
523
+ function YasrORRPanel (props) {
524
+ return (
525
+ <InspectorControls>
526
+ <PanelBody title='Settings'>
527
+ <div className="yasr-guten-block-panel">
528
+ <div>
529
+ {YasrORRSettings}
530
+ </div>
531
+ </div>
532
+
533
+ </PanelBody>
534
+ </InspectorControls>
535
+ );
536
+ }
537
+
538
  return (
539
  <Fragment>
540
+ <YasrORRPanel />
541
  <div className={props.className}>
542
  [yasr_top_ten_highest_rated]
543
  </div>
584
 
585
  function(props) {
586
 
587
+ let YasrVVRSettings = [<YasrNoSettingsPanel key={0}/>];
588
+ {wp.hooks.doAction('yasr_visitor_votes_rankings', YasrVVRSettings)}
589
+
590
+ function YasrVVRPanel (props) {
591
+ return (
592
+ <InspectorControls>
593
+ <PanelBody title='Settings'>
594
+ <div className="yasr-guten-block-panel">
595
+ <div>
596
+ {YasrVVRSettings}
597
+ </div>
598
+ </div>
599
+
600
+ </PanelBody>
601
+ </InspectorControls>
602
+ );
603
+ }
604
+
605
  return (
606
  <Fragment>
607
+ <YasrVVRPanel />
608
  <div className={props.className}>
609
  [yasr_most_or_highest_rated_posts]
610
  </div>
650
 
651
  function(props) {
652
 
653
+ let Yasr5ReviewersSettings = [<YasrNoSettingsPanel key={0}/>];
654
+ {wp.hooks.doAction('yasr_top_5_reviewers_setting', Yasr5ReviewersSettings)}
655
+
656
+ function Yasr5RPanel (props) {
657
+ return (
658
+ <InspectorControls>
659
+ <PanelBody title='Settings'>
660
+ <div className="yasr-guten-block-panel">
661
+ <div>
662
+ {Yasr5ReviewersSettings}
663
+ </div>
664
+ </div>
665
+
666
+ </PanelBody>
667
+ </InspectorControls>
668
+ );
669
+ }
670
+
671
  return (
672
  <Fragment>
673
+ <Yasr5RPanel />
674
  <div className={props.className}>
675
  [yasr_top_5_reviewers]
676
  </div>
716
 
717
  function(props) {
718
 
719
+ let YasrTopVisitorSettings = [<YasrNoSettingsPanel key={0}/>];
720
+ {wp.hooks.doAction('yasr_top_visitor_setting', YasrTopVisitorSettings)}
721
+
722
+ function YasrTopVisitorPanel (props) {
723
+ return (
724
+ <InspectorControls>
725
+ <PanelBody title='Settings'>
726
+ <div className="yasr-guten-block-panel">
727
+ <div>
728
+ {YasrTopVisitorSettings}
729
+ </div>
730
+ </div>
731
+ </PanelBody>
732
+ </InspectorControls>
733
+ );
734
+ }
735
+
736
  return (
737
  <Fragment>
738
+ <YasrTopVisitorPanel />
739
  <div className={props.className}>
740
  [yasr_top_ten_active_users]
741
  </div>
admin/js/src/yasr-settings-page.js CHANGED
@@ -13,12 +13,18 @@ document.addEventListener('DOMContentLoaded', function(event) {
13
  if (activeTab === 'general_settings') {
14
 
15
  let autoInsertEnabled = document.getElementById('yasr_auto_insert_switch').checked;
 
16
  let textBeforeStars = document.getElementById('yasr-general-options-text-before-stars-switch').checked;
17
 
 
18
  if (autoInsertEnabled === false) {
19
  jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
20
  }
21
 
 
 
 
 
22
  //First Div, for auto insert
23
  jQuery('#yasr_auto_insert_switch').change(function () {
24
  if (jQuery(this).is(':checked')) {
@@ -28,6 +34,15 @@ document.addEventListener('DOMContentLoaded', function(event) {
28
  }
29
  });
30
 
 
 
 
 
 
 
 
 
 
31
  //for text before stars
32
  if (textBeforeStars === false) {
33
  jQuery('.yasr-general-options-text-before').prop('disabled', true);
13
  if (activeTab === 'general_settings') {
14
 
15
  let autoInsertEnabled = document.getElementById('yasr_auto_insert_switch').checked;
16
+ let starsTitleEnabled = document.getElementById('yasr-general-options-stars-title-switch').checked;
17
  let textBeforeStars = document.getElementById('yasr-general-options-text-before-stars-switch').checked;
18
 
19
+
20
  if (autoInsertEnabled === false) {
21
  jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
22
  }
23
 
24
+ if(starsTitleEnabled === false) {
25
+ jQuery('.yasr-stars-title-options-class').prop('disabled', true);
26
+ }
27
+
28
  //First Div, for auto insert
29
  jQuery('#yasr_auto_insert_switch').change(function () {
30
  if (jQuery(this).is(':checked')) {
34
  }
35
  });
36
 
37
+ //Second Div, for stars title
38
+ jQuery('#yasr-general-options-stars-title-switch').change(function () {
39
+ if (jQuery(this).is(':checked')) {
40
+ jQuery('.yasr-stars-title-options-class').prop('disabled', false);
41
+ } else {
42
+ jQuery('.yasr-stars-title-options-class').prop('disabled', true);
43
+ }
44
+ });
45
+
46
  //for text before stars
47
  if (textBeforeStars === false) {
48
  jQuery('.yasr-general-options-text-before').prop('disabled', true);
admin/js/yasr-admin.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(o,a,function(t){return e[t]}.bind(null,a));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),r(2),e.exports=r(3)},function(e,t){copyToClipboard=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)},tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"})},function(e,t){jQuery(document).ready((function(){jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){var o=!0;"undefined"!==r.data&&(o=r.data.search("action=yasr_change_log_page")),-1!==o&&jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-log-container").html(e)}))}))}))})),jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_user_log_page")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-user-log-container").html(e)}))}))}))}))},function(e,t){document.addEventListener("DOMContentLoaded",(function(e){if(void 0===document.getElementsByClassName("nav-tab-active")[0])return;let t=document.getElementsByClassName("nav-tab-active")[0].id;if("general_settings"===t){let e=document.getElementById("yasr_auto_insert_switch").checked,t=document.getElementById("yasr-general-options-text-before-stars-switch").checked;!1===e&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),jQuery("#yasr_auto_insert_switch").change((function(){jQuery(this).is(":checked")?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),!1===t&&jQuery(".yasr-general-options-text-before").prop("disabled",!0),jQuery("#yasr-general-options-text-before-stars-switch").change((function(){jQuery(this).is(":checked")?(jQuery(".yasr-general-options-text-before").prop("disabled",!1),jQuery("#yasr-general-options-custom-text-before-overall").val("Our Score"),jQuery("#yasr-general-options-custom-text-before-visitor").val("Click to rate this post!"),jQuery("#yasr-general-options-custom-text-after-visitor").val("[Total: %total_count% Average: %average%]"),jQuery("#yasr-general-options-custom-text-must-sign-in").val("You must sign in to vote"),jQuery("#yasr-general-options-custom-text-already-rated").val("You have already voted for this article")):jQuery(".yasr-general-options-text-before").prop("disabled",!0)})),jQuery("#yasr-doc-custom-text-link").on("click",(function(){return jQuery("#yasr-doc-custom-text-div").toggle("slow"),!1})),jQuery("#yasr-stats-explained-link").on("click",(function(){return jQuery("#yasr-stats-explained").toggle("slow"),!1}))}if("manage_multi"===t){let e=document.getElementById("n-multiset").value;if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===e){var r=jQuery("#yasr-edit-form-number-elements").attr("value");r++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(r>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+r+' <input type="text" name="edit-multi-set-element-'+r+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),r++}))}e>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"style_options"===t&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1}))),"migration_tools"===t&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})))}))}]);
1
+ !function(e){var t={};function r(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(o,a,function(t){return e[t]}.bind(null,a));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),r(2),e.exports=r(3)},function(e,t){copyToClipboard=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)},tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"})},function(e,t){jQuery(document).ready((function(){jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){var o=!0;"undefined"!==r.data&&(o=r.data.search("action=yasr_change_log_page")),-1!==o&&jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-log-container").html(e)}))}))}))})),jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_user_log_page")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-user-log-container").html(e)}))}))}))}))},function(e,t){document.addEventListener("DOMContentLoaded",(function(e){if(void 0===document.getElementsByClassName("nav-tab-active")[0])return;let t=document.getElementsByClassName("nav-tab-active")[0].id;if("general_settings"===t){let e=document.getElementById("yasr_auto_insert_switch").checked,t=document.getElementById("yasr-general-options-stars-title-switch").checked,r=document.getElementById("yasr-general-options-text-before-stars-switch").checked;!1===e&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===t&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),jQuery("#yasr_auto_insert_switch").change((function(){jQuery(this).is(":checked")?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),jQuery("#yasr-general-options-stars-title-switch").change((function(){jQuery(this).is(":checked")?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),!1===r&&jQuery(".yasr-general-options-text-before").prop("disabled",!0),jQuery("#yasr-general-options-text-before-stars-switch").change((function(){jQuery(this).is(":checked")?(jQuery(".yasr-general-options-text-before").prop("disabled",!1),jQuery("#yasr-general-options-custom-text-before-overall").val("Our Score"),jQuery("#yasr-general-options-custom-text-before-visitor").val("Click to rate this post!"),jQuery("#yasr-general-options-custom-text-after-visitor").val("[Total: %total_count% Average: %average%]"),jQuery("#yasr-general-options-custom-text-must-sign-in").val("You must sign in to vote"),jQuery("#yasr-general-options-custom-text-already-rated").val("You have already voted for this article")):jQuery(".yasr-general-options-text-before").prop("disabled",!0)})),jQuery("#yasr-doc-custom-text-link").on("click",(function(){return jQuery("#yasr-doc-custom-text-div").toggle("slow"),!1})),jQuery("#yasr-stats-explained-link").on("click",(function(){return jQuery("#yasr-stats-explained").toggle("slow"),!1}))}if("manage_multi"===t){let e=document.getElementById("n-multiset").value;if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===e){var r=jQuery("#yasr-edit-form-number-elements").attr("value");r++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(r>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+r+' <input type="text" name="edit-multi-set-element-'+r+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),r++}))}e>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"style_options"===t&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1}))),"migration_tools"===t&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})))}))}]);
admin/js/yasr-gutenberg.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),e.exports=r(2)},function(e,t){function r(e){return(r="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 n(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 a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(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 Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=i(e);if(t){var a=i(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return s(this,r)}}function s(e,t){return!t||"object"!==r(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 i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=wp.i18n.__,c=wp.blocks.registerBlockType,u=wp.components,y=u.PanelBody,h=(u.PanelRow,wp.element.Fragment),f=wp.editor,d=(f.BlockControls,f.InspectorControls),m=l("All these settings are optional","yet-another-stars-rating"),p=l("Choose Size","yet-another-stars-rating"),g=l("Choose stars size","yet-another-stars-rating"),v=l("Small","yet-another-stars-rating"),b=l("Medium","yet-another-stars-rating"),R=l("Large","yet-another-stars-rating"),_=l("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),E=l("Remember: only the post author can rate here.","yet-another-stars-rating"),w=l("This is the star set where your users will be able to vote","yet-another-stars-rating");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 one year of 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 A(e){return React.createElement(d,null,React.createElement(y,{title:"Settings"},React.createElement(k,null)))}c("yet-another-stars-rating/yasr-overall-rating",{title:l("Yasr: Overall Rating","yet-another-stars-rating"),description:l("Insert the author rating",""),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("rating","yet-another-stars-rating"),l("author","yet-another-stars-rating"),l("overall","yet-another-stars-rating")],attributes:{overallRatingMeta:{type:"number",source:"meta",meta:"yasr_overall_rating"},size:{type:"string",default:"--"},postId:{type:"number",default:""}},edit:function(e){var t,r=e.attributes,s=r.overallRatingMeta,i=r.size,c=r.postId,u=e.setAttributes,f=e.isSelected,w=s,k=null,A=null;"--"!==i&&(k=' size="'+i+'"'),t=/^\d+$/.test(c),c&&!0===t&&(A=' postid="'+c+'"');var O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(c,React.Component);var t,r,s,i=o(c);function c(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(t=i.call(this,e)).yasrOverallRateThis=l("Rate this article / item","yet-another-stars-rating"),t}return t=c,(r=[{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),u({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&n(t.prototype,r),s&&n(t,s),c}();function P(){return React.createElement("form",null,React.createElement("select",{value:i,onChange:S},React.createElement("option",{value:"--"},g),React.createElement("option",{value:"small"},v),React.createElement("option",{value:"medium"},b),React.createElement("option",{value:"large"},R)))}function S(e){var t=e.target.querySelector("option:checked");u({size:t.value}),e.preventDefault()}function I(){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)&&u({postId:t}),e.preventDefault()}}function x(e){return React.createElement(d,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(O,null)),React.createElement(y,{title:"Settings"},React.createElement("h3",null,m),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(P,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(I,null),React.createElement("div",{className:"yasr-guten-block-explain"},_)),React.createElement("div",{className:"yasr-guten-block-panel"},E)))}return React.createElement(h,null,React.createElement(x,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",k,A,"]",f&&React.createElement(P,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a=null;return r&&(a+=' size="'+r+'"'),n&&(a+=' postid="'+n+'"'),React.createElement("div",null,"[yasr_overall_rating ",a,"]")}}),c("yet-another-stars-rating/yasr-visitor-votes",{title:l("Yasr: Visitor Votes","yet-another-stars-rating"),description:l("Insert the ability for your visitors to vote","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("rating","yet-another-stars-rating"),l("visitor","yet-another-stars-rating"),l("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"--"},postId:{type:"number",default:""}},edit:function(e){var t,r=e.attributes,n=r.size,a=r.postId,o=e.setAttributes,s=e.isSelected,i=null,l=null;function c(){return React.createElement("form",null,React.createElement("select",{value:n,onChange:u},React.createElement("option",{value:"--"},g),React.createElement("option",{value:"small"},v),React.createElement("option",{value:"medium"},b),React.createElement("option",{value:"large"},R)))}function u(e){var t=e.target.querySelector("option:checked");o({size:t.value}),e.preventDefault()}function f(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:E}))}function E(e){if("Enter"===e.key){var t=e.target.value;!0===/^\d+$/.test(t)&&o({postId:t}),e.preventDefault()}}function k(e){return React.createElement(d,null,React.createElement(y,{title:"Settings"},React.createElement("h3",null,m),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(c,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(f,null),React.createElement("div",{className:"yasr-guten-block-explain"},_)),React.createElement("div",{className:"yasr-guten-block-panel"},w)))}return t=/^\d+$/.test(a),"--"!==n&&(i=' size="'+n+'"'),a&&!0===t&&(l=' postid="'+a+'"'),React.createElement(h,null,React.createElement(k,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",i,l,"]",s&&React.createElement(c,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a=null;return r&&(a+=' size="'+r+'"'),n&&(a+=' postid="'+n+'"'),React.createElement("div",null,"[yasr_visitor_votes ",a,"]")}}),c("yet-another-stars-rating/overall-rating-ranking",{title:l("Yasr: Top 10 Reviews","yet-another-stars-rating"),description:l("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:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("chart","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,null),React.createElement("div",{className:e.className},"[yasr_top_ten_highest_rated]"))},save:function(e){return React.createElement("div",null,"[yasr_top_ten_highest_rated]")}}),c("yet-another-stars-rating/visitor-votes-ranking",{title:l("Yasr: Top 10 By Visitors Votes","yet-another-stars-rating"),description:l("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:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,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]")}}),c("yet-another-stars-rating/most-active-reviewers",{title:l("Yasr: Most Active Authors","yet-another-stars-rating"),description:l("This ranking shows the 5 most active reviewers on your site.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating"),l("authors","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,null),React.createElement("div",{className:e.className},"[yasr_top_5_reviewers]"))},save:function(e){return React.createElement("div",null,"[yasr_top_5_reviewers]")}}),c("yet-another-stars-rating/most-active-users",{title:l("Yasr: Most Active Visitors","yet-another-stars-rating"),description:l("This ranking shows the 10 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:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating"),l("visitors","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,null),React.createElement("div",{className:e.className},"[yasr_top_ten_active_users]"))},save:function(e){return React.createElement("div",null,"[yasr_top_ten_active_users]")}})},function(e,t,r){"use strict";r.r(t);var n=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)};var a=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)};var o=function(e){return function(t,r,o){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10;if(a(t)&&n(r))if("function"==typeof o)if("number"==typeof s){var i={callback:o,priority:s,namespace:r};if(e[t]){var l,c=e[t].handlers;for(l=c.length;l>0&&!(s>=c[l-1].priority);l--);l===c.length?c[l]=i:c.splice(l,0,i),(e.__current||[]).forEach((function(e){e.name===t&&e.currentIndex>=l&&e.currentIndex++}))}else e[t]={handlers:[i],runs:0};"hookAdded"!==t&&f("hookAdded",t,r,o,s)}else console.error("If specified, the hook priority must be a number.");else console.error("The hook callback must be a function.")}};var s=function(e,t){return function(r,o){if(a(r)&&(t||n(o))){if(!e[r])return 0;var s=0;if(t)s=e[r].handlers.length,e[r]={runs:e[r].runs,handlers:[]};else for(var i=e[r].handlers,l=function(t){i[t].namespace===o&&(i.splice(t,1),s++,(e.__current||[]).forEach((function(e){e.name===r&&e.currentIndex>=t&&e.currentIndex--})))},c=i.length-1;c>=0;c--)l(c);return"hookRemoved"!==r&&f("hookRemoved",r,o),s}}};var i=function(e){return function(t,r){return void 0!==r?t in e&&e[t].handlers.some((function(e){return e.namespace===r})):t in e}};var l=function(e,t){return function(r){e[r]||(e[r]={handlers:[],runs:0}),e[r].runs++;var n=e[r].handlers;for(var a=arguments.length,o=new Array(a>1?a-1:0),s=1;s<a;s++)o[s-1]=arguments[s];if(!n||!n.length)return t?o[0]:void 0;var i={name:r,currentIndex:0};for(e.__current.push(i);i.currentIndex<n.length;){var l=n[i.currentIndex],c=l.callback.apply(null,o);t&&(o[0]=c),i.currentIndex++}return e.__current.pop(),t?o[0]:void 0}};var c=function(e){return function(){return e.__current&&e.__current.length?e.__current[e.__current.length-1].name:null}};var u=function(e){return function(t){return void 0===t?void 0!==e.__current[0]:!!e.__current[0]&&t===e.__current[0].name}};var y=function(e){return function(t){if(a(t))return e[t]&&e[t].runs?e[t].runs:0}};var h=function(){var e=Object.create(null),t=Object.create(null);return e.__current=[],t.__current=[],{addAction:o(e),addFilter:o(t),removeAction:s(e),removeFilter:s(t),hasAction:i(e),hasFilter:i(t),removeAllActions:s(e,!0),removeAllFilters:s(t,!0),doAction:l(e),applyFilters:l(t,!0),currentAction:c(e),currentFilter:c(t),doingAction:u(e),doingFilter:u(t),didAction:y(e),didFilter:y(t),actions:e,filters:t}}(),f=(h.addAction,h.addFilter,h.removeAction,h.removeFilter,h.hasAction,h.hasFilter,h.removeAllActions,h.removeAllFilters,h.doAction);h.applyFilters,h.currentAction,h.currentFilter,h.doingAction,h.doingFilter,h.didAction,h.didFilter,h.actions,h.filters;function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(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 g(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),e}function v(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&&b(e,t)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function R(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 Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=w(e);if(t){var a=w(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return _(this,r)}}function _(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?E(e):t}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=wp.i18n.__,A=wp.plugins.registerPlugin,O=wp.editPost,P=O.PluginSidebar,S=O.PluginSidebarMoreMenuItem,I=wp.components,T=(I.TextControl,I.PanelBody),x=(I.PanelRow,wp.editor),N=(x.BlockControls,x.InspectorControls,wp.element.Fragment),F=k("Disable auto insert for this post or page?","yet-another-stars-rating"),j=(k("Rich snippet options","yet-another-stars-rating"),k("Is this a review?","yet-another-stars-rating"),k("Select ItemType ","yet-another-stars-rating"),function(){return React.createElement("div",null)}),z=function(e){v(r,React.Component);var t=R(r);function r(e){var n;return m(this,r),(n=t.call(this,e)).yasrOverallRateThis=k("Rate this article / item","yet-another-stars-rating"),n.yasrOverallMoreInfo=k('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating"),n}return g(r,[{key:"shouldComponentUpdate",value:function(e,t){return!1}}]),g(r,[{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){v(r,React.Component);var t=R(r);function r(e){var n;m(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(E(n)),n}return g(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,F)),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}(),M=function(e){v(r,React.Component);var t=R(r);function r(e){var n;m(this,r),n=t.call(this,e);var a=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(a=!0),n.state={yasrAutoInsertEnabled:a},n}return g(r,[{key:"render",value:function(){var e=[React.createElement(j,{key:0})];return wp.hooks.doAction("yasr_below_panel",e),React.createElement(N,null,React.createElement(S,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},k("YASR post settings","yet-another-stars-rating")),React.createElement(P,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(T,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(z,null),this.state.yasrAutoInsertEnabled&&React.createElement(C,null),e))))}}]),r}();A("yasr-sidebar",{icon:"star-half",title:k("Yasr: Page Settings","yet-another-stars-rating"),render:M})}]);
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),e.exports=r(2)},function(e,t){function r(e){return(r="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 n(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 a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(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 Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=i(e);if(t){var a=i(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return s(this,r)}}function s(e,t){return!t||"object"!==r(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 i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=wp.i18n.__,c=wp.blocks.registerBlockType,u=wp.components,y=u.PanelBody,d=(u.PanelRow,wp.element.Fragment),m=wp.editor,h=(m.BlockControls,m.InspectorControls),f=l("All these settings are optional","yet-another-stars-rating"),p=l("Choose Size","yet-another-stars-rating"),g=l("Choose stars size","yet-another-stars-rating"),v=l("Small","yet-another-stars-rating"),R=l("Medium","yet-another-stars-rating"),b=l("Large","yet-another-stars-rating"),_=l("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),E=l("Remember: only the post author can rate here.","yet-another-stars-rating"),k=l("This is the star set where your users will be able to vote","yet-another-stars-rating");function w(){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 A(e){return React.createElement("div",null,React.createElement(w,null))}c("yet-another-stars-rating/yasr-overall-rating",{title:l("Yasr: Overall Rating","yet-another-stars-rating"),description:l("Insert the author rating",""),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("rating","yet-another-stars-rating"),l("author","yet-another-stars-rating"),l("overall","yet-another-stars-rating")],attributes:{overallRatingMeta:{type:"number",source:"meta",meta:"yasr_overall_rating"},size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var t,r=e.attributes,s=r.overallRatingMeta,i=r.size,c=r.postId,u=e.setAttributes,m=e.isSelected,k=s,w=null,A=null;"--"!==i&&(w=' size="'+i+'"'),t=/^\d+$/.test(c),"--"!==c&&!0===t&&(A=' postid="'+c+'"');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&&a(e,t)}(c,React.Component);var t,r,s,i=o(c);function c(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(t=i.call(this,e)).yasrOverallRateThis=l("Rate this article / item","yet-another-stars-rating"),t}return t=c,(r=[{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),u({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&n(t.prototype,r),s&&n(t,s),c}();function P(){return React.createElement("form",null,React.createElement("select",{value:i,onChange:O},React.createElement("option",{value:"--"},g),React.createElement("option",{value:"small"},v),React.createElement("option",{value:"medium"},R),React.createElement("option",{value:"large"},b)))}function O(e){var t=e.target.querySelector("option:checked");u({size:t.value}),e.preventDefault()}function I(){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||u({postId:t}),e.preventDefault()}}function x(e){return React.createElement(h,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(S,null)),React.createElement(y,{title:"Settings"},React.createElement("h3",null,f),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(P,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(I,null),React.createElement("div",{className:"yasr-guten-block-explain"},_)),React.createElement("div",{className:"yasr-guten-block-panel"},E)))}return React.createElement(d,null,React.createElement(x,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",w,A,"]",m&&React.createElement(P,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a="",o=n;return r&&(a+='size="'+r+'"'),n&&("--"===n&&(o=wp.data.select("core/editor").getCurrentPostId()),a+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_overall_rating ",a,"]")}}),c("yet-another-stars-rating/yasr-visitor-votes",{title:l("Yasr: Visitor Votes","yet-another-stars-rating"),description:l("Insert the ability for your visitors to vote","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("rating","yet-another-stars-rating"),l("visitor","yet-another-stars-rating"),l("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var t,r=e.attributes,n=r.size,a=r.postId,o=e.setAttributes,s=e.isSelected,i=null,l=null;function c(){return React.createElement("form",null,React.createElement("select",{value:n,onChange:u},React.createElement("option",{value:"--"},g),React.createElement("option",{value:"small"},v),React.createElement("option",{value:"medium"},R),React.createElement("option",{value:"large"},b)))}function u(e){var t=e.target.querySelector("option:checked");o({size:t.value}),e.preventDefault()}function m(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:E}))}function E(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||o({postId:t}),e.preventDefault()}}function w(e){return React.createElement(h,null,React.createElement(y,{title:"Settings"},React.createElement("h3",null,f),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(c,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(m,null),React.createElement("div",{className:"yasr-guten-block-explain"},_)),React.createElement("div",{className:"yasr-guten-block-panel"},k)))}return t=/^\d+$/.test(a),"--"!==n&&(i=' size="'+n+'"'),"--"!==a&&!0===t&&(l=' postid="'+a+'"'),React.createElement(d,null,React.createElement(w,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",i,l,"]",s&&React.createElement(c,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a="",o=n;return r&&(a+='size="'+r+'"'),n&&("--"===n&&(o=wp.data.select("core/editor").getCurrentPostId()),a+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_visitor_votes ",a,"]")}}),c("yet-another-stars-rating/overall-rating-ranking",{title:l("Yasr: Top 10 Reviews","yet-another-stars-rating"),description:l("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:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("chart","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(A,{key:0})];function r(e){return React.createElement(h,null,React.createElement(y,{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(d,null,React.createElement(r,null),React.createElement("div",{className:e.className},"[yasr_top_ten_highest_rated]"))},save:function(e){return React.createElement("div",null,"[yasr_top_ten_highest_rated]")}}),c("yet-another-stars-rating/visitor-votes-ranking",{title:l("Yasr: Top 10 By Visitors Votes","yet-another-stars-rating"),description:l("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:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(A,{key:0})];function r(e){return React.createElement(h,null,React.createElement(y,{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(d,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]")}}),c("yet-another-stars-rating/most-active-reviewers",{title:l("Yasr: Most Active Authors","yet-another-stars-rating"),description:l("This ranking shows the 5 most active reviewers on your site.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating"),l("authors","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(A,{key:0})];function r(e){return React.createElement(h,null,React.createElement(y,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,t))))}return wp.hooks.doAction("yasr_top_5_reviewers_setting",t),React.createElement(d,null,React.createElement(r,null),React.createElement("div",{className:e.className},"[yasr_top_5_reviewers]"))},save:function(e){return React.createElement("div",null,"[yasr_top_5_reviewers]")}}),c("yet-another-stars-rating/most-active-users",{title:l("Yasr: Most Active Visitors","yet-another-stars-rating"),description:l("This ranking shows the 10 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:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating"),l("visitors","yet-another-stars-rating")],edit:function(e){var t=[React.createElement(A,{key:0})];function r(e){return React.createElement(h,null,React.createElement(y,{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(d,null,React.createElement(r,null),React.createElement("div",{className:e.className},"[yasr_top_ten_active_users]"))},save:function(e){return React.createElement("div",null,"[yasr_top_ten_active_users]")}})},function(e,t,r){"use strict";r.r(t);var n=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)};var a=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)};var o=function(e){return function(t,r,o){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10;if(a(t)&&n(r))if("function"==typeof o)if("number"==typeof s){var i={callback:o,priority:s,namespace:r};if(e[t]){var l,c=e[t].handlers;for(l=c.length;l>0&&!(s>=c[l-1].priority);l--);l===c.length?c[l]=i:c.splice(l,0,i),(e.__current||[]).forEach((function(e){e.name===t&&e.currentIndex>=l&&e.currentIndex++}))}else e[t]={handlers:[i],runs:0};"hookAdded"!==t&&m("hookAdded",t,r,o,s)}else console.error("If specified, the hook priority must be a number.");else console.error("The hook callback must be a function.")}};var s=function(e,t){return function(r,o){if(a(r)&&(t||n(o))){if(!e[r])return 0;var s=0;if(t)s=e[r].handlers.length,e[r]={runs:e[r].runs,handlers:[]};else for(var i=e[r].handlers,l=function(t){i[t].namespace===o&&(i.splice(t,1),s++,(e.__current||[]).forEach((function(e){e.name===r&&e.currentIndex>=t&&e.currentIndex--})))},c=i.length-1;c>=0;c--)l(c);return"hookRemoved"!==r&&m("hookRemoved",r,o),s}}};var i=function(e){return function(t,r){return void 0!==r?t in e&&e[t].handlers.some((function(e){return e.namespace===r})):t in e}};var l=function(e,t){return function(r){e[r]||(e[r]={handlers:[],runs:0}),e[r].runs++;var n=e[r].handlers;for(var a=arguments.length,o=new Array(a>1?a-1:0),s=1;s<a;s++)o[s-1]=arguments[s];if(!n||!n.length)return t?o[0]:void 0;var i={name:r,currentIndex:0};for(e.__current.push(i);i.currentIndex<n.length;){var l=n[i.currentIndex],c=l.callback.apply(null,o);t&&(o[0]=c),i.currentIndex++}return e.__current.pop(),t?o[0]:void 0}};var c=function(e){return function(){return e.__current&&e.__current.length?e.__current[e.__current.length-1].name:null}};var u=function(e){return function(t){return void 0===t?void 0!==e.__current[0]:!!e.__current[0]&&t===e.__current[0].name}};var y=function(e){return function(t){if(a(t))return e[t]&&e[t].runs?e[t].runs:0}};var d=function(){var e=Object.create(null),t=Object.create(null);return e.__current=[],t.__current=[],{addAction:o(e),addFilter:o(t),removeAction:s(e),removeFilter:s(t),hasAction:i(e),hasFilter:i(t),removeAllActions:s(e,!0),removeAllFilters:s(t,!0),doAction:l(e),applyFilters:l(t,!0),currentAction:c(e),currentFilter:c(t),doingAction:u(e),doingFilter:u(t),didAction:y(e),didFilter:y(t),actions:e,filters:t}}(),m=(d.addAction,d.addFilter,d.removeAction,d.removeFilter,d.hasAction,d.hasFilter,d.removeAllActions,d.removeAllFilters,d.doAction);d.applyFilters,d.currentAction,d.currentFilter,d.doingAction,d.doingFilter,d.didAction,d.didFilter,d.actions,d.filters;function h(e){return(h="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 f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(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 g(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),e}function v(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)}function R(e,t){return(R=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(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 Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=k(e);if(t){var a=k(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return _(this,r)}}function _(e,t){return!t||"object"!==h(t)&&"function"!=typeof t?E(e):t}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var w=wp.i18n.__,A=wp.plugins.registerPlugin,S=wp.editPost,P=S.PluginSidebar,O=S.PluginSidebarMoreMenuItem,I=wp.components,T=(I.TextControl,I.PanelBody),x=(I.PanelRow,wp.editor),N=(x.BlockControls,x.InspectorControls,wp.element.Fragment),C=w("Disable auto insert for this post or page?","yet-another-stars-rating"),F=(w("Rich snippet options","yet-another-stars-rating"),w("Is this a review?","yet-another-stars-rating"),w("Select ItemType ","yet-another-stars-rating"),function(){return React.createElement("div",null)}),j=function(e){v(r,React.Component);var t=b(r);function r(e){var n;return f(this,r),(n=t.call(this,e)).yasrOverallRateThis=w("Rate this article / item","yet-another-stars-rating"),n.yasrOverallMoreInfo=w('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating"),n}return g(r,[{key:"shouldComponentUpdate",value:function(e,t){return!1}}]),g(r,[{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}(),z=function(e){v(r,React.Component);var t=b(r);function r(e){var n;f(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(E(n)),n}return g(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,C)),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}(),M=function(e){v(r,React.Component);var t=b(r);function r(e){var n;f(this,r),n=t.call(this,e);var a=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(a=!0),n.state={yasrAutoInsertEnabled:a},n}return g(r,[{key:"render",value:function(){var e=[React.createElement(F,{key:0})];return wp.hooks.doAction("yasr_below_panel",e),React.createElement(N,null,React.createElement(O,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},w("YASR post settings","yet-another-stars-rating")),React.createElement(P,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(T,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(j,null),this.state.yasrAutoInsertEnabled&&React.createElement(z,null),e))))}}]),r}();A("yasr-sidebar",{icon:"star-half",title:w("Yasr: Page Settings","yet-another-stars-rating"),render:M})}]);
admin/settings/yasr-settings-functions.php CHANGED
@@ -46,6 +46,11 @@ function yasr_general_options_init() {
46
  $option['auto_insert_custom_post_only'] = 'no';
47
  }
48
 
 
 
 
 
 
49
  //This is to avoid undefined offset
50
  if ($option && $option['text_before_stars'] === 0) {
51
  $option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
@@ -76,11 +81,14 @@ function yasr_general_options_init() {
76
  $option['enable_ajax'] = 'no';
77
  }
78
 
79
- $description_auto_insert = sprintf(__('Auto Insert Options %s
80
- Automatically adds YASR in your post or page. %s
81
- Disable this if you prefer to use shortcodes.',
82
- 'yet-another-stars-rating'),
83
- '<p>&nbsp;</p>', '<br />');
 
 
 
84
 
85
  add_settings_section(
86
  'yasr_general_options_section_id',
@@ -90,37 +98,50 @@ function yasr_general_options_init() {
90
  );
91
 
92
  add_settings_field(
93
- 'yasr_use_auto_insert_id',
94
- $description_auto_insert,
95
- 'yasr_auto_insert_callback',
96
- 'yasr_general_settings_tab',
97
- 'yasr_general_options_section_id',
98
- $option
99
  );
 
100
  add_settings_field(
101
- 'yasr_custom_text',
102
- __('Insert custom text to show before / after stars', 'yet-another-stars-rating'),
103
- 'yasr_custom_text_callback',
104
- 'yasr_general_settings_tab',
105
- 'yasr_general_options_section_id',
106
- $option
107
  );
 
108
  add_settings_field(
109
- 'yasr_visitors_stats',
110
- __('Do you want show stats for visitors votes?', 'yet-another-stars-rating'),
111
- 'yasr_visitors_stats_callback',
112
- 'yasr_general_settings_tab',
113
- 'yasr_general_options_section_id',
114
- $option
115
  );
 
116
  add_settings_field(
117
- 'yasr_allow_only_logged_in_id',
118
- __('Allow only logged in user to vote?', 'yet-another-stars-rating'),
119
- 'yasr_allow_only_logged_in_callback',
120
- 'yasr_general_settings_tab',
121
- 'yasr_general_options_section_id',
122
- $option
123
  );
 
 
 
 
 
 
 
 
 
 
124
  add_settings_field(
125
  'yasr_show_overall_in_loop',
126
  __('Show "Overall Rating" in Archive Page?', 'yet-another-stars-rating'),
@@ -129,6 +150,7 @@ function yasr_general_options_init() {
129
  'yasr_general_options_section_id',
130
  $option
131
  );
 
132
  add_settings_field(
133
  'yasr_show_visitor_votes_in_loop',
134
  __('Show "Visitor Votes" in Archive Page?', 'yet-another-stars-rating'),
@@ -137,21 +159,23 @@ function yasr_general_options_init() {
137
  'yasr_general_options_section_id',
138
  $option
139
  );
 
140
  add_settings_field(
141
- 'yasr_enable_ip',
142
- __('Do you want to save ip address?', 'yet-another-stars-rating'),
143
- 'yasr_enable_ip_callback',
144
- 'yasr_general_settings_tab',
145
- 'yasr_general_options_section_id',
146
- $option
147
  );
 
148
  add_settings_field(
149
- 'yasr_choose_snippet_id',
150
- __('Rich snippet options', 'yet-another-stars-rating'),
151
- 'yasr_choose_snippet_callback',
152
- 'yasr_general_settings_tab',
153
- 'yasr_general_options_section_id',
154
- $option
155
  );
156
 
157
  add_settings_field(
@@ -169,9 +193,7 @@ function yasr_section_callback() {
169
  }
170
 
171
  function yasr_auto_insert_callback($option) {
172
-
173
  ?>
174
-
175
  <div>
176
  <strong><?php _e('Use Auto Insert?', 'yet-another-stars-rating'); ?></strong>
177
  <div class="yasr-onoffswitch-big">
@@ -236,21 +258,19 @@ function yasr_auto_insert_callback($option) {
236
 
237
  echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
238
  ?>
239
-
240
  </div>
241
 
242
  <p>&nbsp;</p>
243
 
244
- <div>
245
  <strong><?php _e('Size', 'yet-another-stars-rating'); ?></strong>
246
- <div class="yasr-indented-answer">
247
- <?php
248
- $name = 'yasr_general_options[auto_insert_size]';
249
- $class = 'yasr-auto-insert-options-class';
250
- $id = 'yasr-auto-insert-options-stars-size-';
251
-
252
- YasrSettings::radioSelectSize($name, $class, $option['auto_insert_size'], $id);
253
- ?>
254
  </div>
255
 
256
  <p>&nbsp;</p>
@@ -320,6 +340,61 @@ function yasr_auto_insert_callback($option) {
320
 
321
  } //End yasr_auto_insert_callback
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  function yasr_custom_text_callback($option) {
324
 
325
  $text_before_overall = $option['text_before_overall'];
@@ -399,7 +474,7 @@ function yasr_custom_text_callback($option) {
399
  $string_custom_overall = sprintf(__('In the first field you can use %s pattern to show the overall rating.',
400
  'yet-another-stars-rating'), '<strong>%overall_rating%</strong>');
401
 
402
- $string_custom_visitor = sprintf(__('In the Second and Third fields you can use %s pattern to show the
403
  total count, and %s pattern to show the average', 'yet-another-stars-rating'),
404
  '<strong>%total_count%</strong>', '<strong>%average%</strong>');
405
 
@@ -422,9 +497,7 @@ function yasr_custom_text_callback($option) {
422
  }
423
 
424
  function yasr_visitors_stats_callback($option) {
425
-
426
  ?>
427
-
428
  <div class="yasr-onoffswitch-big">
429
  <input type="checkbox" name="yasr_general_options[visitors_stats]" class="yasr-onoffswitch-checkbox"
430
  id="yasr-general-options-visitors-stats-switch" <?php if ($option['visitors_stats'] === 'yes') {
@@ -436,7 +509,7 @@ function yasr_visitors_stats_callback($option) {
436
  </label>
437
  </div>
438
 
439
- <br/> <br/>
440
 
441
  <?php
442
  _e('Enable or disable the chart bar icon (and tooltip hover it) near the yasr_visitor_votes shortcode.');
@@ -517,10 +590,10 @@ function yasr_show_overall_in_loop_callback($option) {
517
  </label>
518
  </div>
519
 
520
- <br/> <br/>
521
 
522
- <?php _e('If you enable this, "Overall Rating" will be showed not only in the single article or page, but also
523
- in pages like Home Page, category pages or archives.', 'yet-another-stars-rating') ?>
524
 
525
  <p>&nbsp;</p>
526
 
@@ -543,9 +616,11 @@ function yasr_show_visitor_votes_in_loop_callback($option) {
543
  </label>
544
  </div>
545
 
546
- <br/> <br/>
547
 
548
- <?php _e('If you enable this, "Visitor Votes" will be showed not only in the single article or page, but also in pages like Home Page, category pages or archives.', 'yet-another-stars-rating') ?>
 
 
549
 
550
  <br/>
551
 
@@ -583,7 +658,6 @@ function yasr_enable_ip_callback($option) {
583
  '<strong>', '</strong>', '<br />'
584
  );
585
  echo $string;
586
-
587
  ?>
588
 
589
  <br/><p>&nbsp;</p>
@@ -799,6 +873,9 @@ function yasr_general_options_sanitize($option) {
799
 
800
  } // end foreach
801
 
 
 
 
802
  //if in array doesn't exists [auto_insert_enabled] key, create it and set to 0
803
  if (!array_key_exists('auto_insert_enabled', $output)) {
804
  $output['auto_insert_enabled'] = 0;
@@ -808,6 +885,15 @@ function yasr_general_options_sanitize($option) {
808
  $output['auto_insert_enabled'] = 1;
809
  }
810
 
 
 
 
 
 
 
 
 
 
811
  //Same as above but for [show_overall_in_loop] key
812
  if (!array_key_exists('show_overall_in_loop', $output)) {
813
  $output['show_overall_in_loop'] = 'disabled';
46
  $option['auto_insert_custom_post_only'] = 'no';
47
  }
48
 
49
+ if ($option && $option['stars_title'] === 'no') {
50
+ $option['stars_title_what'] = 'visitor_rating';
51
+ $option['stars_title_where'] = 'archive';
52
+ }
53
+
54
  //This is to avoid undefined offset
55
  if ($option && $option['text_before_stars'] === 0) {
56
  $option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
81
  $option['enable_ajax'] = 'no';
82
  }
83
 
84
+ $description_auto_insert = sprintf(
85
+ __('Auto Insert Options %s
86
+ Automatically adds YASR in your posts or pages. %s
87
+ Disable this if you prefer to use shortcodes.',
88
+ 'yet-another-stars-rating'
89
+ ),
90
+ '<p>&nbsp;</p>', '<br />'
91
+ );
92
 
93
  add_settings_section(
94
  'yasr_general_options_section_id',
98
  );
99
 
100
  add_settings_field(
101
+ 'yasr_use_auto_insert_id',
102
+ $description_auto_insert,
103
+ 'yasr_auto_insert_callback',
104
+ 'yasr_general_settings_tab',
105
+ 'yasr_general_options_section_id',
106
+ $option
107
  );
108
+
109
  add_settings_field(
110
+ 'yasr_stars_title',
111
+ __('Enable stars next to the title?', 'yet-another-stars-rating'),
112
+ 'yasr_stars_title_callback',
113
+ 'yasr_general_settings_tab',
114
+ 'yasr_general_options_section_id',
115
+ $option
116
  );
117
+
118
  add_settings_field(
119
+ 'yasr_custom_text',
120
+ __('Insert custom text to show before / after stars', 'yet-another-stars-rating'),
121
+ 'yasr_custom_text_callback',
122
+ 'yasr_general_settings_tab',
123
+ 'yasr_general_options_section_id',
124
+ $option
125
  );
126
+
127
  add_settings_field(
128
+ 'yasr_visitors_stats',
129
+ __('Do you want show stats for visitors votes?', 'yet-another-stars-rating'),
130
+ 'yasr_visitors_stats_callback',
131
+ 'yasr_general_settings_tab',
132
+ 'yasr_general_options_section_id',
133
+ $option
134
  );
135
+
136
+ add_settings_field(
137
+ 'yasr_allow_only_logged_in_id',
138
+ __('Allow only logged in user to vote?', 'yet-another-stars-rating'),
139
+ 'yasr_allow_only_logged_in_callback',
140
+ 'yasr_general_settings_tab',
141
+ 'yasr_general_options_section_id',
142
+ $option
143
+ );
144
+
145
  add_settings_field(
146
  'yasr_show_overall_in_loop',
147
  __('Show "Overall Rating" in Archive Page?', 'yet-another-stars-rating'),
150
  'yasr_general_options_section_id',
151
  $option
152
  );
153
+
154
  add_settings_field(
155
  'yasr_show_visitor_votes_in_loop',
156
  __('Show "Visitor Votes" in Archive Page?', 'yet-another-stars-rating'),
159
  'yasr_general_options_section_id',
160
  $option
161
  );
162
+
163
  add_settings_field(
164
+ 'yasr_enable_ip',
165
+ __('Do you want to save ip address?', 'yet-another-stars-rating'),
166
+ 'yasr_enable_ip_callback',
167
+ 'yasr_general_settings_tab',
168
+ 'yasr_general_options_section_id',
169
+ $option
170
  );
171
+
172
  add_settings_field(
173
+ 'yasr_choose_snippet_id',
174
+ __('Rich snippet options', 'yet-another-stars-rating'),
175
+ 'yasr_choose_snippet_callback',
176
+ 'yasr_general_settings_tab',
177
+ 'yasr_general_options_section_id',
178
+ $option
179
  );
180
 
181
  add_settings_field(
193
  }
194
 
195
  function yasr_auto_insert_callback($option) {
 
196
  ?>
 
197
  <div>
198
  <strong><?php _e('Use Auto Insert?', 'yet-another-stars-rating'); ?></strong>
199
  <div class="yasr-onoffswitch-big">
258
 
259
  echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
260
  ?>
 
261
  </div>
262
 
263
  <p>&nbsp;</p>
264
 
265
+ <div class="yasr-indented-answer">
266
  <strong><?php _e('Size', 'yet-another-stars-rating'); ?></strong>
267
+ <?php
268
+ $name = 'yasr_general_options[auto_insert_size]';
269
+ $class = 'yasr-auto-insert-options-class';
270
+ $id = 'yasr-auto-insert-options-stars-size-';
271
+
272
+ YasrSettings::radioSelectSize($name, $class, $option['auto_insert_size'], $id);
273
+ ?>
 
274
  </div>
275
 
276
  <p>&nbsp;</p>
340
 
341
  } //End yasr_auto_insert_callback
342
 
343
+ function yasr_stars_title_callback($option) {
344
+ ?>
345
+ <div class="yasr-onoffswitch-big">
346
+ <input type="checkbox" name="yasr_general_options[stars_title]" class="yasr-onoffswitch-checkbox"
347
+ id="yasr-general-options-stars-title-switch" <?php if ($option['stars_title'] === 'yes') {
348
+ echo " checked='checked' ";
349
+ } ?> >
350
+ <label class="yasr-onoffswitch-label" for="yasr-general-options-stars-title-switch">
351
+ <span class="yasr-onoffswitch-inner"></span>
352
+ <span class="yasr-onoffswitch-switch"></span>
353
+ </label>
354
+ </div>
355
+
356
+ <br/>
357
+
358
+ <div>
359
+ <?php
360
+ $option_title = __('What?', 'yet-another-stars-rating');
361
+ $array_options = array (
362
+ 'visitor_rating' => __('Visitor Votes', 'yet-another-stars-rating'),
363
+ 'overall_rating' => __('Overall Rating / Author Rating', 'yet-another-stars-rating'),
364
+ );
365
+ $default = $option['stars_title_what'];
366
+ $name = 'yasr_general_options[stars_title_what]';
367
+ $class = 'yasr-stars-title-options-class';
368
+
369
+ echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
370
+ ?>
371
+ </div>
372
+
373
+ <p>&nbsp;</p>
374
+
375
+ <div>
376
+ <?php
377
+ $option_title = __('Where do you want show ratings?', 'yet-another-stars-rating');
378
+ $array_options = array (
379
+ 'archive' => __('Only on archive pages (categories, tags, etc.)', 'yet-another-stars-rating'),
380
+ 'single' => __('Only on single posts or pages', 'yet-another-stars-rating'),
381
+ 'both' => __('Both', 'yet-another-stars-rating'),
382
+ );
383
+ $default = $option['stars_title_where'];
384
+ $name = 'yasr_general_options[stars_title_where]';
385
+ $class = 'yasr-stars-title-options-class';
386
+
387
+ echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
388
+ ?>
389
+ </div>
390
+
391
+ <p>&nbsp;</p>
392
+ <hr />
393
+
394
+ <?php
395
+
396
+ }
397
+
398
  function yasr_custom_text_callback($option) {
399
 
400
  $text_before_overall = $option['text_before_overall'];
474
  $string_custom_overall = sprintf(__('In the first field you can use %s pattern to show the overall rating.',
475
  'yet-another-stars-rating'), '<strong>%overall_rating%</strong>');
476
 
477
+ $string_custom_visitor = sprintf(__('In the second and third fields you can use %s pattern to show the
478
  total count, and %s pattern to show the average', 'yet-another-stars-rating'),
479
  '<strong>%total_count%</strong>', '<strong>%average%</strong>');
480
 
497
  }
498
 
499
  function yasr_visitors_stats_callback($option) {
 
500
  ?>
 
501
  <div class="yasr-onoffswitch-big">
502
  <input type="checkbox" name="yasr_general_options[visitors_stats]" class="yasr-onoffswitch-checkbox"
503
  id="yasr-general-options-visitors-stats-switch" <?php if ($option['visitors_stats'] === 'yes') {
509
  </label>
510
  </div>
511
 
512
+ <br/>
513
 
514
  <?php
515
  _e('Enable or disable the chart bar icon (and tooltip hover it) near the yasr_visitor_votes shortcode.');
590
  </label>
591
  </div>
592
 
593
+ <br/>
594
 
595
+ <?php _e('"Overall Rating" will be also shown in archive page (categories, tags, etc.)',
596
+ 'yet-another-stars-rating') ?>
597
 
598
  <p>&nbsp;</p>
599
 
616
  </label>
617
  </div>
618
 
619
+ <br/>
620
 
621
+ <?php _e('If you enable this, "Visitor Votes" will be showed not only in the single article or page, but also
622
+ in pages like Home Page, category pages or archives.',
623
+ 'yet-another-stars-rating') ?>
624
 
625
  <br/>
626
 
658
  '<strong>', '</strong>', '<br />'
659
  );
660
  echo $string;
 
661
  ?>
662
 
663
  <br/><p>&nbsp;</p>
873
 
874
  } // end foreach
875
 
876
+
877
+ /** The following steps are needed to avoid undefined index if a setting is saved to "no" **/
878
+
879
  //if in array doesn't exists [auto_insert_enabled] key, create it and set to 0
880
  if (!array_key_exists('auto_insert_enabled', $output)) {
881
  $output['auto_insert_enabled'] = 0;
885
  $output['auto_insert_enabled'] = 1;
886
  }
887
 
888
+ //if in array doesn't exists [stars title] key, create it and set to 'no'
889
+ if (!array_key_exists('stars_title', $output)) {
890
+ $output['stars_title'] = 'no';
891
+ }
892
+ //if exists value must be 1
893
+ else {
894
+ $output['stars_title'] = 'yes';
895
+ }
896
+
897
  //Same as above but for [show_overall_in_loop] key
898
  if (!array_key_exists('show_overall_in_loop', $output)) {
899
  $output['show_overall_in_loop'] = 'disabled';
admin/yasr-update-functions.php CHANGED
@@ -190,8 +190,15 @@ function yasr_update_version() {
190
 
191
  }
192
 
 
 
 
 
 
 
193
  } //Endif yasr_version_installed !== false
194
 
 
195
  /****** End backward compatibility functions ******/
196
  if ($yasr_version_installed != YASR_VERSION_NUM) {
197
  update_option('yasr-version', YASR_VERSION_NUM);
190
 
191
  }
192
 
193
+ //In version 2.4.3 is added setting to show stars near the post title
194
+ if (version_compare($yasr_version_installed, '2.4.3') === -1) {
195
+ $yasr_stored_options['stars_title'] = 'no';
196
+ update_option('yasr_general_options', $yasr_stored_options);
197
+ }
198
+
199
  } //Endif yasr_version_installed !== false
200
 
201
+
202
  /****** End backward compatibility functions ******/
203
  if ($yasr_version_installed != YASR_VERSION_NUM) {
204
  update_option('yasr-version', YASR_VERSION_NUM);
includes/classes/YasrPhpFieldsHelper.php CHANGED
@@ -51,20 +51,20 @@ class YasrPhpFieldsHelper {
51
  $container .= '<div class="yasr-indented-answer">';
52
 
53
  $radio_fields = '';
54
- foreach ( $options as $value => $label ) {
55
- $id_string = $id . '-' . strtolower( trim( str_replace( ' ', '', $value ) ) );
56
  //must be inside foreach, or when loop arrive to last element
57
  //checked is defined
58
  $checked = '';
59
 
60
  //If db_value === false, there is no need to check for db value
61
  //so checked is the medium star (i.e. ranking page)
62
- if ( $default_value === $value ) {
63
  $checked = 'checked';
64
  }
65
 
66
  //string value must be empty
67
- if ( $value === 0 ) {
68
  $value = '';
69
  }
70
 
@@ -80,8 +80,8 @@ class YasrPhpFieldsHelper {
80
  %s
81
  </label>
82
  </div>',
83
- $id_string, $name, $value, $class, $id_string, $checked,
84
- __( ucwords( $label ), 'yet-another-stars-rating' ) );
85
 
86
  } //end foreach
87
 
51
  $container .= '<div class="yasr-indented-answer">';
52
 
53
  $radio_fields = '';
54
+ foreach ( $radio_options as $value => $label ) {
55
+ $id_string = $attribute['id'] . '-' . strtolower( trim( str_replace( ' ', '', $value ) ) );
56
  //must be inside foreach, or when loop arrive to last element
57
  //checked is defined
58
  $checked = '';
59
 
60
  //If db_value === false, there is no need to check for db value
61
  //so checked is the medium star (i.e. ranking page)
62
+ if ($attribute['value'] === $value) {
63
  $checked = 'checked';
64
  }
65
 
66
  //string value must be empty
67
+ if ($value === 0) {
68
  $value = '';
69
  }
70
 
80
  %s
81
  </label>
82
  </div>',
83
+ $id_string, $attribute['name'], $value, $attribute['class'], $id_string, $checked,
84
+ __( ucfirst( $label ), 'yet-another-stars-rating' ) );
85
 
86
  } //end foreach
87
 
includes/css/yasr.css CHANGED
@@ -123,6 +123,17 @@
123
  vertical-align: super;
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
  /*** Widgets ***/
128
 
123
  vertical-align: super;
124
  }
125
 
126
+ .yasr-stars-title {
127
+ margin-left: 4px;
128
+ vertical-align: baseline;
129
+ }
130
+
131
+ .yasr-stars-title-average {
132
+ font-size: 12px;
133
+ margin-left: 4px;
134
+ vertical-align: baseline;
135
+ }
136
+
137
 
138
  /*** Widgets ***/
139
 
includes/shortcodes/classes/YasrOverallRating.php CHANGED
@@ -32,31 +32,20 @@ class YasrOverallRating extends YasrShortcode {
32
  protected $overall_rating;
33
 
34
  /**
35
- * Print the visitor votes shortcode
36
  *
37
  * @return string|null
38
  */
 
39
 
40
- function printOverallRating () {
41
 
42
- $stars_size = $this->starSize();
43
- $this->overall_rating = YasrDatabaseRatings::getOverallRating($this->post_id);
44
 
45
- $this->shortcode_html = '<!--Yasr Overall Rating Shortcode-->';
 
 
46
 
47
- //generate an unique id to be sure that every element has a different ID
48
- $unique_id = str_shuffle(uniqid());
49
- $overall_rating_html_id = 'yasr-overall-rating-rater-' . $unique_id;
50
-
51
- $this->html_stars = "<div class='yasr-overall-rating'>
52
- <div class='yasr-rater-stars'
53
- id='$overall_rating_html_id'
54
- data-rating='$this->overall_rating'
55
- data-rater-starsize='$stars_size' >
56
- </div>
57
- </div>";
58
-
59
- $this->customTextBefore();
60
  $this->shortcode_html .= '<!--End Yasr Overall Rating Shortcode-->';
61
 
62
  //If overall rating in loop is enabled don't use is_singular && is main_query
@@ -71,24 +60,60 @@ class YasrOverallRating extends YasrShortcode {
71
  return null;
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  /**
75
  * If enabled in the settings, this function will show the custom text
76
- * before or after the stars in yasr_visitor_votes
77
  *
78
  * @param void
79
- * @return void
80
  *
81
  */
82
  protected function customTextBefore() {
83
  if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
84
  $text_before_star = str_replace('%overall_rating%', $this->overall_rating, YASR_TEXT_BEFORE_OVERALL);
85
- $this->shortcode_html = "<div class='yasr-container-custom-text-and-overall'>
86
- <span id='yasr-custom-text-before-overall'>" . $text_before_star . "</span>
87
- $this->html_stars
88
- </div>";
89
- } else {
90
- $this->shortcode_html .= $this->html_stars;
91
  }
 
92
  }
93
 
94
  }
32
  protected $overall_rating;
33
 
34
  /**
35
+ * This is called when shortcode is used
36
  *
37
  * @return string|null
38
  */
39
+ public function returnShortcode () {
40
 
41
+ $this->shortcode_html = '<!--Yasr Overall Rating Shortcode-->';
42
 
43
+ $this->shortcode_html .= $this->customTextBefore();
 
44
 
45
+ $this->shortcode_html .= '<div class="yasr-overall-rating">';
46
+ $this->shortcode_html .= $this->returnHtml();
47
+ $this->shortcode_html .= '</div>';
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  $this->shortcode_html .= '<!--End Yasr Overall Rating Shortcode-->';
50
 
51
  //If overall rating in loop is enabled don't use is_singular && is main_query
60
  return null;
61
  }
62
 
63
+ /**
64
+ * @param int | bool $stars_size
65
+ * @param int | bool $post_id
66
+ *
67
+ * @param string | bool $class
68
+ *
69
+ * @return string
70
+ */
71
+ public function returnHtml($stars_size=false, $post_id=false, $class=false) {
72
+
73
+ if(!is_int($stars_size)) {
74
+ $stars_size = $this->starSize();
75
+ }
76
+
77
+ if(!is_int($post_id)) {
78
+ $post_id = $this->post_id;
79
+ }
80
+
81
+ $class .= ' yasr-rater-stars';
82
+
83
+ $overall_rating = YasrDatabaseRatings::getOverallRating($post_id);
84
+
85
+ $unique_id = str_shuffle(uniqid());
86
+ $overall_rating_html_id = 'yasr-overall-rating-rater-' . $unique_id;
87
+
88
+ $html_stars = "<div class='$class'
89
+ id='$overall_rating_html_id'
90
+ data-rating='$overall_rating'
91
+ data-rater-starsize='$stars_size'>
92
+ </div>";
93
+
94
+ return $html_stars;
95
+
96
+ }
97
+
98
  /**
99
  * If enabled in the settings, this function will show the custom text
100
+ * before yasr_overall_rating
101
  *
102
  * @param void
103
+ * @return string | void
104
  *
105
  */
106
  protected function customTextBefore() {
107
  if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
108
  $text_before_star = str_replace('%overall_rating%', $this->overall_rating, YASR_TEXT_BEFORE_OVERALL);
109
+ $shortcode_html = "<div class='yasr-container-custom-text-and-overall'>
110
+ <span id='yasr-custom-text-before-overall'>" . $text_before_star . "</span>
111
+ </div>";
112
+
113
+ return $shortcode_html;
114
+
115
  }
116
+
117
  }
118
 
119
  }
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -54,11 +54,11 @@ class YasrVisitorVotes extends YasrShortcode {
54
  *
55
  * @return string|null
56
  */
57
- public function printVisitorVotes() {
58
 
59
  $htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
60
 
61
- //return int
62
  $stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
63
 
64
  $number_of_votes = $stored_votes['number_of_votes'];
@@ -82,8 +82,7 @@ class YasrVisitorVotes extends YasrShortcode {
82
  data-rater-readonly='true'
83
  data-readonly-attribute='true'
84
  data-cpt='$this->post_type'
85
- >
86
- </div>";
87
 
88
  return $this->shortcode_html;
89
  }
54
  *
55
  * @return string|null
56
  */
57
+ public function returnShortcode() {
58
 
59
  $htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
60
 
61
+ //returns int
62
  $stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
63
 
64
  $number_of_votes = $stored_votes['number_of_votes'];
82
  data-rater-readonly='true'
83
  data-readonly-attribute='true'
84
  data-cpt='$this->post_type'
85
+ ></div>";
 
86
 
87
  return $this->shortcode_html;
88
  }
includes/shortcodes/yasr-shortcode-functions.php CHANGED
@@ -65,7 +65,7 @@ function shortcode_overall_rating_callback ($atts) {
65
  $shortcode_name = 'yasr_overall_rating';
66
  $overall_rating = new YasrOverallRating($atts, $shortcode_name);
67
 
68
- return $overall_rating->printOverallRating();
69
  } //end function
70
 
71
 
@@ -86,7 +86,7 @@ function shortcode_visitor_votes_callback($atts) {
86
  $shortcode_name = 'yasr_visitor_votes';
87
  $visitor_votes = new YasrVisitorVotes($atts, $shortcode_name);
88
 
89
- return $visitor_votes->printVisitorVotes();
90
 
91
  } //End function shortcode_visitor_votes_callback
92
 
65
  $shortcode_name = 'yasr_overall_rating';
66
  $overall_rating = new YasrOverallRating($atts, $shortcode_name);
67
 
68
+ return $overall_rating->returnShortcode();
69
  } //end function
70
 
71
 
86
  $shortcode_name = 'yasr_visitor_votes';
87
  $visitor_votes = new YasrVisitorVotes($atts, $shortcode_name);
88
 
89
+ return $visitor_votes->returnShortcode();
90
 
91
  } //End function shortcode_visitor_votes_callback
92
 
includes/yasr-includes-init.php CHANGED
@@ -74,8 +74,7 @@ if (YASR_AUTO_INSERT_ENABLED === 1) {
74
  define('YASR_AUTO_INSERT_SIZE', $yasr_stored_options['auto_insert_size']);
75
  define('YASR_AUTO_INSERT_EXCLUDE_PAGES', $yasr_stored_options['auto_insert_exclude_pages']);
76
  define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', $yasr_stored_options['auto_insert_custom_post_only']);
77
- }
78
- else {
79
  define('YASR_AUTO_INSERT_WHAT', null);
80
  define('YASR_AUTO_INSERT_WHERE', null);
81
  define('YASR_AUTO_INSERT_ALIGN', null);
@@ -84,6 +83,17 @@ else {
84
  define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', null);
85
  }
86
 
 
 
 
 
 
 
 
 
 
 
 
87
  define('YASR_SHOW_OVERALL_IN_LOOP', $yasr_stored_options['show_overall_in_loop']);
88
  define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', $yasr_stored_options['show_visitor_votes_in_loop']);
89
  define('YASR_TEXT_BEFORE_STARS', (int)$yasr_stored_options['text_before_stars']);
74
  define('YASR_AUTO_INSERT_SIZE', $yasr_stored_options['auto_insert_size']);
75
  define('YASR_AUTO_INSERT_EXCLUDE_PAGES', $yasr_stored_options['auto_insert_exclude_pages']);
76
  define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', $yasr_stored_options['auto_insert_custom_post_only']);
77
+ } else {
 
78
  define('YASR_AUTO_INSERT_WHAT', null);
79
  define('YASR_AUTO_INSERT_WHERE', null);
80
  define('YASR_AUTO_INSERT_ALIGN', null);
83
  define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', null);
84
  }
85
 
86
+ define('YASR_STARS_TITLE', $yasr_stored_options['stars_title']);
87
+
88
+ if (YASR_STARS_TITLE === 'yes') {
89
+ define('YASR_STARS_TITLE_WHAT', $yasr_stored_options['stars_title_what']);
90
+ define('YASR_STARS_TITLE_WHERE', $yasr_stored_options['stars_title_where']);
91
+ } else {
92
+ define('YASR_STARS_TITLE_WHAT', null);
93
+ define('YASR_STARS_TITLE_WHERE', null);
94
+ }
95
+
96
+
97
  define('YASR_SHOW_OVERALL_IN_LOOP', $yasr_stored_options['show_overall_in_loop']);
98
  define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', $yasr_stored_options['show_visitor_votes_in_loop']);
99
  define('YASR_TEXT_BEFORE_STARS', (int)$yasr_stored_options['text_before_stars']);
public/classes/YasrPublicFilters.php ADDED
@@ -0,0 +1,425 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit( 'You\'re not allowed to see this page' );
5
+ } // Exit if accessed directly
6
+
7
+ /**
8
+ * Public filters
9
+ *
10
+ * @since 2.4.3
11
+ *
12
+ * Class YasrPublicFilters
13
+ */
14
+ class YasrPublicFilters {
15
+ public static function addFilters() {
16
+
17
+ // Auto insert overall rating and visitor rating
18
+ if (YASR_AUTO_INSERT_ENABLED === 1) {
19
+ add_filter('the_content', 'YasrPublicFilters::autoInsert');
20
+ }
21
+
22
+ add_filter('the_content', 'YasrPublicFilters::addSchema');
23
+
24
+ //stars next to the title
25
+ if (YASR_STARS_TITLE === 'yes') {
26
+ add_filter('the_title', 'YasrPublicFilters::filterTitle');
27
+ }
28
+ }
29
+
30
+ /**
31
+ * @param $content
32
+ *
33
+ * @return bool|string|void
34
+ */
35
+ public static function autoInsert($content) {
36
+
37
+ $post_id = get_the_ID();
38
+
39
+ //check if for this post or page auto insert is off
40
+ $post_excluded = get_post_meta($post_id, 'yasr_auto_insert_disabled', true);
41
+
42
+ if ($post_excluded === 'yes') {
43
+ return $content;
44
+ }
45
+
46
+ $shortcode_align = YASR_AUTO_INSERT_ALIGN;
47
+
48
+ //if it is not left, or right, default is center
49
+ if ($shortcode_align !== 'left' && $shortcode_align !== 'right') {
50
+ $shortcode_align = 'center';
51
+ }
52
+
53
+ $container_div_overall='<div style="text-align:'.$shortcode_align.'" class="yasr-auto-insert-overall">';
54
+ $container_div_visitor='<div style="text-align:'.$shortcode_align.'" class="yasr-auto-insert-visitor">';
55
+ $closing_div = '</div>';
56
+
57
+ $auto_insert_shortcode = null; //To avoid undefined variable notice outside the loop (if (is_singular) )
58
+ $overall_rating_code = $container_div_overall. '[yasr_overall_rating size="' . YASR_AUTO_INSERT_SIZE . '"]' . $closing_div;
59
+ $visitor_votes_code = $container_div_visitor. '[yasr_visitor_votes size="' . YASR_AUTO_INSERT_SIZE . '"]' . $closing_div;
60
+
61
+ //avoid undefined
62
+ $content_and_stars = false;
63
+
64
+ if (YASR_AUTO_INSERT_WHAT === 'overall_rating') {
65
+ switch (YASR_AUTO_INSERT_WHERE) {
66
+ case 'top':
67
+ $content_and_stars = $overall_rating_code . $content;
68
+ break;
69
+
70
+ case 'bottom':
71
+ $content_and_stars = $content . $overall_rating_code;
72
+ break;
73
+ } //End Switch
74
+ } elseif (YASR_AUTO_INSERT_WHAT === 'visitor_rating') {
75
+ switch (YASR_AUTO_INSERT_WHERE) {
76
+ case 'top':
77
+ $content_and_stars = $visitor_votes_code . $content;
78
+ break;
79
+
80
+ case 'bottom':
81
+ $content_and_stars = $content . $visitor_votes_code;
82
+ break;
83
+ } //End Switch
84
+ } elseif (YASR_AUTO_INSERT_WHAT === 'both') {
85
+ switch (YASR_AUTO_INSERT_WHERE) {
86
+ case 'top':
87
+ $content_and_stars = $overall_rating_code . $visitor_votes_code . $content;
88
+ break;
89
+
90
+ case 'bottom':
91
+ $content_and_stars = $content . $overall_rating_code . $visitor_votes_code;
92
+ break;
93
+ } //End Switch
94
+ }
95
+
96
+ //IF auto insert must work only in custom post type
97
+ if (YASR_AUTO_INSERT_CUSTOM_POST_ONLY === 'yes') {
98
+ $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
99
+ //If is a post type return content and stars
100
+ if (is_singular($custom_post_types)) {
101
+ return $content_and_stars;
102
+ } //else return just content
103
+
104
+ return $content;
105
+ }
106
+
107
+ //If page are not excluded
108
+ if (YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no') {
109
+ return $content_and_stars;
110
+ }
111
+
112
+ if (YASR_AUTO_INSERT_EXCLUDE_PAGES === 'yes') {
113
+ if (is_page()) {
114
+ return $content;
115
+ } //If is a page return the content without stars
116
+
117
+ return $content_and_stars;
118
+ } //else return only if it is not a page
119
+
120
+ } //End function yasr_auto_insert_shortcode_callback
121
+
122
+
123
+ /**
124
+ * @param $content
125
+ *
126
+ * @return string
127
+ */
128
+ public static function addSchema($content) {
129
+
130
+ //Add buddypress compatibility
131
+ //If this is a page, return $content without adding schema.
132
+ if (function_exists('bp_is_active') && is_page()) {
133
+ return $content;
134
+ }
135
+
136
+ if (is_404() || did_action('get_footer') || (!is_singular() && is_main_query())) {
137
+ return $content;
138
+ }
139
+
140
+ $overall_rating = YasrDatabaseRatings::getOverallRating();
141
+ $visitor_votes = YasrDatabaseRatings::getVisitorVotes(false);
142
+
143
+ if (!$overall_rating && !$visitor_votes['number_of_votes'] && !$visitor_votes['sum_votes']) {
144
+ return $content;
145
+ }
146
+
147
+ //can't be between 0.1 and 1
148
+ if($overall_rating > 0 && $overall_rating < 1) {
149
+ $overall_rating = 1;
150
+ }
151
+
152
+ $is_post_a_review = get_post_meta(get_the_ID(), 'yasr_post_is_review', true);
153
+
154
+ $script_type = '<script type="application/ld+json">';
155
+ $end_script_type = '</script>';
156
+
157
+ $review_choosen = yasr_get_itemType();
158
+
159
+ //Use this hook to write your custom microdata from scratch
160
+ //if doesn't exists a filter for yasr_filter_schema_jsonld
161
+ // $review_chosen value is assigned to $filtered_schema.
162
+ $filtered_schema = apply_filters('yasr_filter_schema_jsonld', $review_choosen);
163
+
164
+ //So check here if $schema != $review_choosen
165
+ if ($filtered_schema !== $review_choosen) {
166
+ return $content . $script_type . $filtered_schema . $end_script_type;
167
+ }
168
+
169
+ //YASR adds microdata only if is_singular() && is_main_query() && !is_404()
170
+ if (is_singular() && is_main_query() && !is_404()) {
171
+
172
+ $rich_snippet['@context'] = 'http://schema.org/';
173
+
174
+ $author = get_the_author();
175
+
176
+ //use this hook to change the itemType name
177
+ $review_name = wp_strip_all_tags(apply_filters('yasr_filter_schema_title', get_the_title()));
178
+
179
+ $date = get_the_date('c');
180
+ $date_modified = get_the_modified_date('c');
181
+
182
+ $post_image_url = ''; //avoid undefined
183
+ $logo_image_url = ''; //avoid undefined
184
+
185
+ if (defined('YASR_PUBLISHER_LOGO')) {
186
+ $logo_image_url = YASR_PUBLISHER_LOGO;
187
+ $post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
188
+
189
+ $logo_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url(YASR_PUBLISHER_LOGO, PHP_URL_PATH);
190
+
191
+ $post_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
192
+ $logo_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
193
+ } else {
194
+ $post_image_size[0] = 0;
195
+ $post_image_size[1] = 0;
196
+ $logo_image_size[0] = 0;
197
+ $logo_image_size[1] = 0;
198
+ }
199
+
200
+ //if exists featuread image get the url and overwrite the variable
201
+ if (has_post_thumbnail()) {
202
+ $post_image_url = wp_get_attachment_url(get_post_thumbnail_id());
203
+ $post_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url($post_image_url, PHP_URL_PATH);
204
+ $post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
205
+ }
206
+
207
+ $rich_snippet['@type'] = $review_choosen;
208
+ $rich_snippet['name'] = $review_name;
209
+ $cleaned_content = wp_strip_all_tags(strip_shortcodes($content));
210
+
211
+ $rich_snippet['description'] = wp_trim_words( $cleaned_content, 55, '...' );
212
+
213
+ $rich_snippet['image'] = array(
214
+ '@type' => 'ImageObject',
215
+ 'url' => $post_image_url,
216
+ 'width' => $post_image_size[0],
217
+ 'height' => $post_image_size[1]
218
+ );
219
+
220
+ $publisher_image_index = 'logo';
221
+ if(YASR_PUBLISHER_TYPE === 'Person') {
222
+ $publisher_image_index = 'image';
223
+ }
224
+
225
+ if ($review_choosen === 'Place') {
226
+ $rich_snippet['@type'] = 'LocalBusiness';
227
+ }
228
+
229
+ elseif ($review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
230
+ $rich_snippet['datePublished'] = $date;
231
+ $rich_snippet['headline'] = $review_name;
232
+ $rich_snippet['mainEntityOfPage'] = array(
233
+ '@type' => 'WebPage',
234
+ '@id' => get_permalink()
235
+ );
236
+ $rich_snippet['author'] = array(
237
+ '@type' => 'Person',
238
+ 'name' => $author
239
+ );
240
+ $rich_snippet['publisher'] = array(
241
+ '@type' => 'Organization',
242
+ 'name' => wp_strip_all_tags(YASR_PUBLISHER_NAME), //already sanitized in the settings, just to be safe
243
+ 'logo' => array(
244
+ '@type' => 'ImageObject',
245
+ 'url' => $logo_image_url,
246
+ 'width' => $logo_image_size[0],
247
+ 'height' => $logo_image_size[1]
248
+ ),
249
+ );
250
+
251
+ $rich_snippet['dateModified'] = $date_modified;
252
+
253
+ $rich_snippet['image'] = array(
254
+ '@type' => 'ImageObject',
255
+ 'url' => $post_image_url,
256
+ 'width' => $post_image_size[0],
257
+ 'height' => $post_image_size[1]
258
+ );
259
+
260
+ }
261
+
262
+ //Do not add rating if blogposting
263
+ if ($review_choosen !== 'Other' && $review_choosen !== 'BlogPosting') {
264
+ if ($overall_rating) {
265
+ $rich_snippet['Review'] = array(
266
+ '@type' => 'Review',
267
+ 'name' => $review_name,
268
+ 'reviewBody' => $cleaned_content,
269
+ 'author' => array(
270
+ '@type' => 'Person',
271
+ 'name' => $author
272
+ ),
273
+ 'datePublished' => $date,
274
+ 'dateModified' => $date_modified,
275
+ 'reviewRating' => array(
276
+ '@type' => 'Rating',
277
+ 'ratingValue' => $overall_rating,
278
+ 'bestRating' => 5,
279
+ 'worstRating' => 1
280
+ ),
281
+ );
282
+ }
283
+
284
+ //if both are included, google will index AggregateRating instead of Review.
285
+ //So, is post is selected as review, exclude AggregateRating
286
+ if($is_post_a_review !== 'yes') {
287
+ if ($visitor_votes) {
288
+ if ($visitor_votes['sum_votes'] !== 0 && $visitor_votes['number_of_votes'] !== 0) {
289
+ $average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
290
+ $average_rating = round($average_rating, 1);
291
+
292
+ $rich_snippet['aggregateRating'] = array(
293
+ '@type' => 'AggregateRating',
294
+ 'ratingValue' => $average_rating,
295
+ 'ratingCount' => $visitor_votes['number_of_votes'],
296
+ 'bestRating' => 5,
297
+ 'worstRating' => 1,
298
+ );
299
+ }
300
+ }
301
+ }
302
+ }
303
+
304
+ if(isset($rich_snippet['Review']) || $review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
305
+ $publisher = array(
306
+ '@type' => YASR_PUBLISHER_TYPE,
307
+ 'name' => wp_strip_all_tags( YASR_PUBLISHER_NAME ),//already sanitized in the settings, just to be safe
308
+ $publisher_image_index => array(
309
+ '@type' => 'ImageObject',
310
+ 'url' => $logo_image_url,
311
+ 'width' => $logo_image_size[0],
312
+ 'height' => $logo_image_size[1]
313
+ ),
314
+ );
315
+
316
+ /** @noinspection NotOptimalIfConditionsInspection */
317
+ if(isset($rich_snippet['Review'])) {
318
+ $rich_snippet['Review']['publisher'] = $publisher;
319
+ } else {
320
+ $rich_snippet['publisher'] = $publisher;
321
+ }
322
+ }
323
+
324
+ //Use this hook to add additional schema
325
+ //if doesn't exists a filter for yasr_filter_existing_schema, put $rich_snippet into $more_rich_snippet
326
+ $more_rich_snippet = apply_filters('yasr_filter_existing_schema', $rich_snippet);
327
+
328
+ if ($more_rich_snippet !== $rich_snippet && is_array($more_rich_snippet)) {
329
+ $rich_snippet = $more_rich_snippet;
330
+ }
331
+
332
+ return $content . $script_type . json_encode($rich_snippet) . $end_script_type;
333
+ }
334
+
335
+ return $content;
336
+
337
+ } //End function
338
+
339
+
340
+ /**
341
+ * @since 2.4.3
342
+ *
343
+ * Filter the_title to show stars next it
344
+ *
345
+ * @param $title
346
+ *
347
+ * @return string
348
+ */
349
+ public static function filterTitle ($title) {
350
+
351
+ if(in_the_loop()) {
352
+ $post_id = get_the_ID();
353
+
354
+ $content_after_title = false;
355
+
356
+ if (YASR_STARS_TITLE_WHAT === 'visitor_rating') {
357
+ //returns int
358
+ $stored_votes = YasrDatabaseRatings::getVisitorVotes();
359
+
360
+ $number_of_votes = $stored_votes['number_of_votes'];
361
+ if ( $number_of_votes > 0 ) {
362
+ $average_rating = $stored_votes['sum_votes'] / $number_of_votes;
363
+ } else {
364
+ $average_rating = 0;
365
+ }
366
+
367
+ $average_rating = round($average_rating, 1);
368
+
369
+ $htmlid = 'yasr-visitor-votes-readonly-rater-' . str_shuffle(uniqid());
370
+
371
+ $post_type = YasrCustomPostTypes::returnBaseUrl($post_id);
372
+
373
+ $vv_widget = "<div class='yasr-stars-title yasr-rater-stars-visitor-votes'
374
+ id='$htmlid'
375
+ data-rating='$average_rating'
376
+ data-rater-starsize='16'
377
+ data-rater-postid='$post_id'
378
+ data-rater-readonly='true'
379
+ data-readonly-attribute='true'
380
+ data-cpt='$post_type'
381
+ ></div>";
382
+
383
+ $vv_widget .= "<span class='yasr-stars-title-average'>$average_rating ($number_of_votes)</span>";
384
+
385
+ //Use this hook to customize widget overall
386
+ //if doesn't exists a filter for yasr_title_overall_widget, put $vv_widget into $content_after_title
387
+ $content_after_title = apply_filters('yasr_title_vv_widget', $vv_widget);
388
+ }
389
+
390
+ if ( YASR_STARS_TITLE_WHAT === 'overall_rating' ) {
391
+ $overall_rating = YasrDatabaseRatings::getOverallRating($post_id);
392
+ $overall_rating_obj = new YasrOverallRating(false, false);
393
+
394
+ $overall_widget = $overall_rating_obj->returnHtml(16, $post_id, 'yasr-stars-title');
395
+ $overall_widget .= "<span class='yasr-stars-title-average'>$overall_rating</span>";
396
+
397
+
398
+ //Use this hook to customize widget overall
399
+ //if doesn't exists a filter for yasr_title_overall_widget, put $overall_widget into $content_after_title
400
+ $content_after_title = apply_filters('yasr_title_overall_widget', $overall_widget);
401
+ }
402
+
403
+ //if only in archive pages
404
+ if ( YASR_STARS_TITLE_WHERE === 'archive' ) {
405
+ if ( is_archive() || is_home() ) {
406
+ return $title . $content_after_title;
407
+ }
408
+ } //if only in single posts/pages
409
+ elseif ( YASR_STARS_TITLE_WHERE === 'single' ) {
410
+ if ( is_singular() ) {
411
+ return $title . $content_after_title;
412
+ }
413
+ } //always return in both
414
+ elseif ( YASR_STARS_TITLE_WHERE === 'both' ) {
415
+ return $title . $content_after_title;
416
+ } //else return just the title (should never happens)
417
+ else {
418
+ return $title;
419
+ }
420
+ }
421
+
422
+ //if not in the loop
423
+ return $title;
424
+ }
425
+ }
public/yasr-public-init.php CHANGED
@@ -28,7 +28,6 @@ define('YASR_CSS_DIR_PUBLIC', plugins_url() . '/' . YASR_RELATIVE_PATH_PUBLIC .
28
 
29
  require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-functions.php';
30
  require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-actions.php';
31
- require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-filters.php';
32
 
33
  /**
34
  * Callback function for the spl_autoload_register above.
@@ -56,4 +55,6 @@ spl_autoload_register('yasr_autoload_public_classes');
56
 
57
  //filter yasr rich snippet
58
  $yasr_additional_rich_fields = new YasrRichSnippetAdditionalFields;
59
- $yasr_additional_rich_fields->addFilters();
 
 
28
 
29
  require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-functions.php';
30
  require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-actions.php';
 
31
 
32
  /**
33
  * Callback function for the spl_autoload_register above.
55
 
56
  //filter yasr rich snippet
57
  $yasr_additional_rich_fields = new YasrRichSnippetAdditionalFields;
58
+ $yasr_additional_rich_fields->addFilters();
59
+
60
+ YasrPublicFilters::addFilters();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
5
  Contributors: Dudo
6
  Tested up to: 5.5
7
  Requires PHP: 5.3
8
- Stable tag: 2.4.2
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
@@ -168,6 +168,11 @@ If doesn't, you should work on your seo reputation.
168
 
169
  The full changelog can be found in the plugin's directory. Recent entries:
170
 
 
 
 
 
 
171
  = 2.4.2 =
172
  * FIXED: error in gutenberg editor that appear in some circumstances
173
 
5
  Contributors: Dudo
6
  Tested up to: 5.5
7
  Requires PHP: 5.3
8
+ Stable tag: 2.4.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
168
 
169
  The full changelog can be found in the plugin's directory. Recent entries:
170
 
171
+ = 2.4.3 =
172
+ * NEW FEATURE: is now possible to show ratings next to the title
173
+ * FIXED: guten blocks returns error if post_id parameter was set
174
+ * TWEAKED: added some hooks
175
+
176
  = 2.4.2 =
177
  * FIXED: error in gutenberg editor that appear in some circumstances
178
 
yet-another-stars-rating.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
- * Version: 2.4.2
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
@@ -76,7 +76,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
- define( 'YASR_VERSION_NUM', '2.4.2' );
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.4.3
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
+ define( 'YASR_VERSION_NUM', '2.4.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__ );