Yasr – Yet Another Stars Rating - Version 2.2.6

Version Description

  • TWEAKED: in the editor screen, rich snippet info are moved below the editor
  • NEW FEATURE: Added new fields for these itemTypes: #### Recipe:
  • cookTime
  • prepTime
  • description
  • keywords
  • nutrition
  • recipeCategory
  • recipeCuisine
  • recipeIngredient #### Product:
  • Brand
  • Sku
  • Global identifiers
  • Price
  • Currency
  • Price Valid Until
  • Availability
  • Url #### LocalBuisiness:
  • Address
  • PriceRange
  • Telephone

More to come in the next realeses :)

Download this release

Release Info

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

Code changes from version 2.2.5 to 2.2.6

changelog.txt CHANGED
@@ -1,3 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 2.1.4 =
2
  * FIXED: undefined variable when saving/updating post or page
3
  * TWEAKED: changed delete_post_meta with delete_metadata
1
+ = 2.2.1 =
2
+ * FIXED: MultiSet returns "undefined" in editor screen
3
+ * FIXED: MultiSet average always shows
4
+ * FIXED: Users who cannot publish posts can't access the editor screen
5
+ * FIXED: Password reset display an error page in some circumstances
6
+
7
+ = 2.2.0 =
8
+ * TWEAKED: most of code of the main shortcodes has been rewritten; YASR is faster than ever.
9
+ * FIXED: gutenberg shortcode preview yasr_top_ten_highest_rated shortcode
10
+ [//]: # fs_premium_only_begin
11
+ * FIXED: if user reviews are enabled on a post, rich snippet get printed even if " Create Rich Snippet for comments? "
12
+ is set to "no"
13
+ [//]: # fs_premium_only_end
14
+
15
  = 2.1.4 =
16
  * FIXED: undefined variable when saving/updating post or page
17
  * TWEAKED: changed delete_post_meta with delete_metadata
css/yasr-admin.css CHANGED
@@ -81,6 +81,41 @@
81
  }
82
 
83
  /**** Metabox multi ****/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  #yasr-multi-set-admin-choose-text {
85
  display: none;
86
  margin-bottom: 15px;
81
  }
82
 
83
  /**** Metabox multi ****/
84
+
85
+ .yasr-metabox-below-editor-content {
86
+ border: 1px solid #DDD;
87
+ padding-left: 15px;
88
+ padding-bottom: 10px;
89
+ padding-top: 15px;
90
+ min-height: 200px;
91
+ }
92
+
93
+ .yasr-metabox-info-snippet-container {
94
+ border: 1px solid #DDD;
95
+ margin: 15px;
96
+ padding: 5px;
97
+ min-height: 50px;
98
+ }
99
+
100
+ .yasr-itemtype-row-container-label-input {
101
+ margin-left: 10px;
102
+ margin-right: 10px;
103
+ margin-top: 10px;
104
+ }
105
+
106
+ .yasr-itemtype-row-container-label-input label {
107
+ display: inline-block;
108
+ width: 130px;
109
+ font-weight: bold;
110
+ }
111
+
112
+ .yasr-itemtype-row-container-description {
113
+ color: #928b8b;
114
+ margin-top: 5px;
115
+ margin-left: 10px;
116
+ margin-bottom: 15px;
117
+ }
118
+
119
  #yasr-multi-set-admin-choose-text {
120
  display: none;
121
  margin-bottom: 15px;
js/src/yasr-guten-panel.js CHANGED
@@ -127,14 +127,13 @@ class YasrSideBarAutoInsert extends React.Component {
127
  <span className="yasr-onoffswitch-switch"></span>
128
  </label>
129
  </div>
130
- <hr/>
131
  </div>
132
  );
133
  }
134
 
135
  }
136
 
137
- class YasrDivIsReview extends React.Component {
138
 
139
  constructor(props) {
140
  super(props);
@@ -242,7 +241,7 @@ class YasrSideBarSelectSnippets extends React.Component {
242
  </div>
243
  );
244
  }
245
- }
246
 
247
  class yasrSidebar extends React.Component {
248
 
@@ -271,8 +270,6 @@ class yasrSidebar extends React.Component {
271
  <div className="yasr-guten-block-panel yasr-guten-block-panel-center">
272
  <YasrDivRatingOverall />
273
  {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
274
- <YasrDivIsReview />
275
- <YasrSideBarSelectSnippets/>
276
  {wp.hooks.applyFilters( 'yasr_add_content_bottom_sidebar', <ContentBelowSidebar /> )}
277
  </div>
278
  </PanelBody>
127
  <span className="yasr-onoffswitch-switch"></span>
128
  </label>
129
  </div>
 
130
  </div>
131
  );
132
  }
133
 
134
  }
135
 
136
+ /*class YasrDivIsReview extends React.Component {
137
 
138
  constructor(props) {
139
  super(props);
241
  </div>
242
  );
243
  }
244
+ }*/
245
 
246
  class yasrSidebar extends React.Component {
247
 
270
  <div className="yasr-guten-block-panel yasr-guten-block-panel-center">
271
  <YasrDivRatingOverall />
272
  {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
 
 
273
  {wp.hooks.applyFilters( 'yasr_add_content_bottom_sidebar', <ContentBelowSidebar /> )}
274
  </div>
275
  </PanelBody>
js/yasr-admin.js CHANGED
@@ -23,195 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
23
 
24
  ***/
25
 
26
- /****** Yasr Metabox overall rating, used for classic editor ******/
27
-
28
- function yasrPrintMetaBoxOverall(overallRating) {
29
-
30
- //Convert string to number
31
- overallRating = parseFloat(overallRating);
32
-
33
- raterJs({
34
- starSize: 32,
35
- step: 0.1,
36
- showToolTip: false,
37
- rating: overallRating,
38
- readOnly: false,
39
- element: document.getElementById("yasr-rater-overall"),
40
- rateCallback: function rateCallback(rating, done) {
41
-
42
- rating = rating.toFixed(1);
43
- rating = parseFloat(rating);
44
-
45
- //update hidden field
46
- document.getElementById('yasr-overall-rating-value').value = rating;
47
-
48
- this.setRating(rating);
49
-
50
- yasrOverallString = 'You\'ve rated';
51
-
52
- document.getElementById('yasr_rateit_overall_value').textContent = yasrOverallString + ' ' + rating;
53
-
54
- done();
55
- }
56
- });
57
-
58
- }
59
-
60
- /****** End Yasr Metabox overall rating ******/
61
-
62
-
63
- /****** Yasr Metabox Multiple Rating ******/
64
-
65
- function yasrAdminMultiSet(nMultiSet, postid, setId) {
66
-
67
- nMultiSet = parseInt(nMultiSet);
68
-
69
- if (nMultiSet === 1) {
70
-
71
- yasrPrintAdminMultiSet(setId, postid, false);
72
-
73
- } else {
74
-
75
- jQuery('#yasr-button-select-set').on("click", function () {
76
-
77
- //get the multi data
78
- //overwrite setID
79
- var setId = jQuery('#select_set').val();
80
-
81
- jQuery("#yasr-loader-select-multi-set").show();
82
-
83
- yasrPrintAdminMultiSet(setId, postid, true);
84
-
85
- return false; // prevent default click action from happening!
86
-
87
- });
88
-
89
- }
90
-
91
- }
92
-
93
- //print the table
94
- function yasrPrintAdminMultiSet(setId, postid, moreThanOneMultiSet) {
95
-
96
- var data_id = {
97
- action: 'yasr_send_id_nameset',
98
- set_id: setId,
99
- post_id: postid
100
- };
101
-
102
- jQuery.post(ajaxurl, data_id, function (response) {
103
-
104
- //Hide the loader near the select only if more multiset are used
105
- if (moreThanOneMultiSet === true) {
106
- document.getElementById('yasr-loader-select-multi-set').style.display = 'none';
107
- }
108
-
109
- var yasrMultiSetValue = JSON.parse(response);
110
-
111
- var content = '';
112
-
113
- for (var i = 0; i < yasrMultiSetValue.length; i++) {
114
-
115
- var valueName = yasrMultiSetValue[i]['name'];
116
- var valueRating = yasrMultiSetValue[i]['average_rating'];
117
- var valueID = yasrMultiSetValue[i]['id'];
118
-
119
- content += '<tr>';
120
- content += '<td>' + valueName + '</td>';
121
- content += '<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-' + valueID + '" data-rating="'
122
- + valueRating + '" data-multi-idfield="' + valueID + '"></div>';
123
- content += '<span id="yasr-loader-multi-set-field-' + valueID + '" style="display: none">';
124
- content += '<img src="' + yasrCommonDataAdmin.loaderHtml + '"></span>';
125
- content += '</span>';
126
- content += '</td>';
127
- content += '</tr>';
128
-
129
- var table = document.getElementById('yasr-table-multi-set-admin');
130
-
131
- table.innerHTML = content;
132
-
133
- }
134
-
135
- //Show the text "Choose a vote"
136
- document.getElementById('yasr-multi-set-admin-choose-text').style.display = 'block';
137
-
138
- //Set rater for divs
139
- yasrSetRaterAdminMulti(setId);
140
-
141
- //Show shortcode
142
- document.getElementById('yasr-multi-set-admin-explain').style.display = 'block';
143
-
144
- document.getElementById('yasr-multi-set-admin-explain-with-id-readonly').innerHTML = '<strong>[yasr_multiset setid=' + setId + ']</strong>';
145
- document.getElementById('yasr-multi-set-admin-explain-with-id-visitor').innerHTML = '<strong>[yasr_visitor_multiset setid=' + setId + ']</strong>';
146
-
147
- });
148
-
149
- return false; // prevent default click action from happening!
150
-
151
- }
152
-
153
- //Rater for multiset
154
- function yasrSetRaterAdminMulti(setId) {
155
-
156
- //update hidden field
157
- document.getElementById('yasr-multiset-id').value = setId;
158
-
159
- var yasrMultiSetAdmin = document.getElementsByClassName('yasr-multiset-admin');
160
-
161
- //an array with all the ratings objects
162
- var ratingArray = [];
163
- var ratingValue = false;
164
-
165
- for (var i = 0; i < yasrMultiSetAdmin.length; i++) {
166
-
167
- (function (i) {
168
-
169
- var htmlId = yasrMultiSetAdmin.item(i).id;
170
- var elem = document.getElementById(htmlId);
171
-
172
- raterJs({
173
- starSize: 32,
174
- step: 0.5,
175
- showToolTip: false,
176
- readOnly: false,
177
- element: elem,
178
-
179
- rateCallback: function rateCallback(rating, done) {
180
-
181
- rating = rating.toFixed(1);
182
- //Be sure is a number and not a string
183
- rating = parseFloat(rating);
184
- this.setRating(rating); //Set the rating
185
-
186
- var setIdField = parseInt(elem.getAttribute('data-multi-idfield'));
187
-
188
- ratingObject = {
189
- field: setIdField,
190
- rating: rating
191
- };
192
-
193
- //creating rating array
194
- ratingArray.push(ratingObject);
195
-
196
- ratingValue = JSON.stringify(ratingArray);
197
-
198
- //update hidden field
199
- document.getElementById('yasr-multiset-author-votes').value = ratingValue;
200
-
201
- done();
202
- }
203
-
204
- });
205
-
206
- })(i);
207
-
208
- } //End for
209
-
210
- }//End function
211
-
212
- /****** End Yasr Metabox Multple Rating ******/
213
-
214
-
215
  /****** Yasr Settings Page ******/
216
 
217
  function YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled, textBeforeStars) {
@@ -457,357 +268,6 @@ document.addEventListener('DOMContentLoaded', function(event) {
457
 
458
  /****** End Yasr Settings Page ******/
459
 
460
-
461
- /****** Yasr Ajax Page ******/
462
-
463
-
464
- // When click on chart hide tab-main and show tab-charts
465
-
466
- function yasrShortcodeCreator(nMultiSet) {
467
-
468
- // When click on main tab hide tab-main and show tab-charts
469
- jQuery('#yasr-link-tab-main').on("click", function () {
470
-
471
- jQuery('.yasr-nav-tab').removeClass('nav-tab-active');
472
- jQuery('#yasr-link-tab-main').addClass('nav-tab-active');
473
-
474
- jQuery('.yasr-content-tab-tinymce').hide();
475
- jQuery('#yasr-content-tab-main').show();
476
-
477
- });
478
-
479
- jQuery('#yasr-link-tab-charts').on("click", function () {
480
-
481
- jQuery('.yasr-nav-tab').removeClass('nav-tab-active');
482
- jQuery('#yasr-link-tab-charts').addClass('nav-tab-active');
483
-
484
- jQuery('.yasr-content-tab-tinymce').hide();
485
- jQuery('#yasr-content-tab-charts').show();
486
-
487
- });
488
-
489
- // Add shortcode for overall rating
490
- jQuery('#yasr-overall').on("click", function () {
491
- jQuery('#yasr-overall-choose-size').toggle('slow');
492
- });
493
-
494
- jQuery('#yasr-overall-insert-small').on("click", function () {
495
- var shortcode = '[yasr_overall_rating size="small"]';
496
-
497
- if (tinyMCE.activeEditor == null) {
498
-
499
- //this is for tinymce used in text mode
500
- jQuery("#content").append(shortcode);
501
-
502
- } else {
503
-
504
- // inserts the shortcode into the active editor
505
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
506
-
507
- }
508
-
509
- // close
510
- tb_remove();
511
- //jQuery('#yasr-tinypopup-form').dialog('close');
512
-
513
- });
514
-
515
- jQuery('#yasr-overall-insert-medium').on("click", function () {
516
- var shortcode = '[yasr_overall_rating size="medium"]';
517
-
518
- // inserts the shortcode into the active editor
519
- if (tinyMCE.activeEditor == null) {
520
-
521
- //this is for tinymce used in text mode
522
- jQuery("#content").append(shortcode);
523
-
524
- } else {
525
-
526
- // inserts the shortcode into the active editor
527
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
528
-
529
- }
530
-
531
- // close
532
- tb_remove();
533
- //jQuery('#yasr-tinypopup-form').dialog('close');
534
- });
535
-
536
- jQuery('#yasr-overall-insert-large').on("click", function () {
537
- var shortcode = '[yasr_overall_rating size="large"]';
538
-
539
- if (tinyMCE.activeEditor == null) {
540
-
541
- //this is for tinymce used in text mode
542
- jQuery("#content").append(shortcode);
543
-
544
- } else {
545
-
546
- // inserts the shortcode into the active editor
547
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
548
-
549
- }
550
-
551
- // close
552
- tb_remove();
553
- //jQuery('#yasr-tinypopup-form').dialog('close');
554
- });
555
-
556
- //Add shortcode for visitors rating
557
- jQuery('#yasr-visitor-votes').on("click", function () {
558
- jQuery('#yasr-visitor-choose-size').toggle('slow');
559
- });
560
-
561
- jQuery('#yasr-visitor-insert-small').on("click", function () {
562
- var shortcode = '[yasr_visitor_votes size="small"]';
563
-
564
- // inserts the shortcode into the active editor
565
- if (tinyMCE.activeEditor == null) {
566
-
567
- //this is for tinymce used in text mode
568
- jQuery("#content").append(shortcode);
569
-
570
- } else {
571
- // inserts the shortcode into the active editor
572
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
573
- }
574
-
575
- // close
576
- tb_remove();
577
- //jQuery('#yasr-tinypopup-form').dialog('close');
578
- });
579
-
580
- jQuery('#yasr-visitor-insert-medium').on("click", function () {
581
- var shortcode = '[yasr_visitor_votes size="medium"]';
582
-
583
- if (tinyMCE.activeEditor == null) {
584
-
585
- //this is for tinymce used in text mode
586
- jQuery("#content").append(shortcode);
587
-
588
- } else {
589
-
590
- // inserts the shortcode into the active editor
591
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
592
-
593
- }
594
-
595
- // close
596
- tb_remove();
597
- //jQuery('#yasr-tinypopup-form').dialog('close');
598
- });
599
-
600
- jQuery('#yasr-visitor-insert-large').on("click", function () {
601
- var shortcode = '[yasr_visitor_votes size="large"]';
602
-
603
- // inserts the shortcode into the active editor
604
- if (tinyMCE.activeEditor == null) {
605
-
606
- //this is for tinymce used in text mode
607
- jQuery("#content").append(shortcode);
608
-
609
- } else {
610
-
611
- // inserts the shortcode into the active editor
612
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
613
-
614
- }
615
-
616
- // close
617
- tb_remove();
618
- //jQuery('#yasr-tinypopup-form').dialog('close');
619
- });
620
-
621
- if (nMultiSet > 1) {
622
-
623
- //Add shortcode for multiple set
624
- jQuery('#yasr-insert-multiset-select').on("click", function () {
625
- var setType = jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();
626
- var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
627
- var showAverage = jQuery("#yasr-hide-average-multiset").is(':checked');
628
-
629
- if (!visitorSet) {
630
-
631
- var shortcode = '[yasr_visitor_multiset setid=';
632
-
633
- } else {
634
-
635
- var shortcode = '[yasr_multiset setid=';
636
-
637
- }
638
-
639
- shortcode += setType;
640
-
641
- if (showAverage) {
642
-
643
- shortcode += ' show_average=\'no\'';
644
-
645
- }
646
-
647
-
648
- shortcode += ']';
649
-
650
- // inserts the shortcode into the active editor
651
- if (tinyMCE.activeEditor == null) {
652
-
653
- //this is for tinymce used in text mode
654
- jQuery("#content").append(shortcode);
655
-
656
- } else {
657
-
658
- // inserts the shortcode into the active editor
659
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
660
-
661
- }
662
-
663
- // close
664
- tb_remove();
665
- //jQuery('#yasr-tinypopup-form').dialog('close');
666
- });
667
-
668
- } //End if
669
-
670
- else if (nMultiSet == 1) {
671
-
672
- //Add shortcode for single set (if only 1 are found)
673
- jQuery('#yasr-single-set').on("click", function () {
674
- var setType = jQuery('#yasr-single-set').val();
675
- var showAverage = jQuery("#yasr-hide-average-multiset").is(':checked');
676
-
677
- var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
678
-
679
- if (!visitorSet) {
680
-
681
- var shortcode = '[yasr_visitor_multiset setid=';
682
-
683
- } else {
684
-
685
- var shortcode = '[yasr_multiset setid=';
686
-
687
- }
688
-
689
- shortcode += setType;
690
-
691
- if (showAverage) {
692
-
693
- shortcode += ' show_average=\'no\'';
694
-
695
- }
696
-
697
- shortcode += ']';
698
-
699
- // inserts the shortcode into the active editor
700
- if (tinyMCE.activeEditor == null) {
701
-
702
- //this is for tinymce used in text mode
703
- jQuery("#content").append(shortcode);
704
-
705
- } else {
706
-
707
- // inserts the shortcode into the active editor
708
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
709
-
710
- }
711
-
712
- // close
713
- tb_remove();
714
- //jQuery('#yasr-tinypopup-form').dialog('close');
715
- });
716
-
717
- } //End elseif
718
-
719
- // Add shortcode for top 10 by overall ratings
720
- jQuery('#yasr-top-10-overall-rating').on("click", function () {
721
- var shortcode = '[yasr_top_ten_highest_rated]';
722
-
723
- // inserts the shortcode into the active editor
724
- if (tinyMCE.activeEditor == null) {
725
-
726
- //this is for tinymce used in text mode
727
- jQuery("#content").append(shortcode);
728
-
729
- } else {
730
-
731
- // inserts the shortcode into the active editor
732
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
733
-
734
- }
735
-
736
- // close
737
- tb_remove();
738
- //jQuery('#yasr-tinypopup-form').dialog('close');
739
- });
740
-
741
- // Add shortcode for 10 highest most rated
742
- jQuery('#yasr-10-highest-most-rated').on("click", function () {
743
- var shortcode = '[yasr_most_or_highest_rated_posts]';
744
-
745
- // inserts the shortcode into the active editor
746
- if (tinyMCE.activeEditor == null) {
747
-
748
- //this is for tinymce used in text mode
749
- jQuery("#content").append(shortcode);
750
-
751
- } else {
752
-
753
- // inserts the shortcode into the active editor
754
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
755
-
756
- }
757
-
758
- // close
759
- tb_remove();
760
- //jQuery('#yasr-tinypopup-form').dialog('close');
761
- });
762
-
763
- // Add shortcode for top 5 active reviewer
764
- jQuery('#yasr-5-active-reviewers').on("click", function () {
765
- var shortcode = '[yasr_top_5_reviewers]';
766
-
767
- // inserts the shortcode into the active editor
768
- if (tinyMCE.activeEditor == null) {
769
-
770
- //this is for tinymce used in text mode
771
- jQuery("#content").append(shortcode);
772
-
773
- } else {
774
-
775
- // inserts the shortcode into the active editor
776
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
777
-
778
- }
779
-
780
- // close
781
- tb_remove();
782
- //jQuery('#yasr-tinypopup-form').dialog('close');
783
- });
784
-
785
- // Add shortcode for top 10 active users
786
- jQuery('#yasr-top-10-active-users').on("click", function () {
787
- var shortcode = '[yasr_top_ten_active_users]';
788
-
789
- // inserts the shortcode into the active editor
790
- if (tinyMCE.activeEditor == null) {
791
-
792
- //this is for tinymce used in text mode
793
- jQuery("#content").append(shortcode);
794
-
795
- } else {
796
-
797
- // inserts the shortcode into the active editor
798
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
799
-
800
- }
801
-
802
- // close
803
- tb_remove();
804
- //jQuery('#yasr-tinypopup-form').dialog('close');
805
- });
806
-
807
- } //End function
808
-
809
- /****** End YAsr Ajax page ******/
810
-
811
  /****** Yasr db functions ******/
812
 
813
  //Vote log
23
 
24
  ***/
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  /****** Yasr Settings Page ******/
27
 
28
  function YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled, textBeforeStars) {
268
 
269
  /****** End Yasr Settings Page ******/
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  /****** Yasr db functions ******/
272
 
273
  //Vote log
js/yasr-editor-screen.js ADDED
@@ -0,0 +1,645 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // executes this when the DOM is ready
2
+ document.addEventListener('DOMContentLoaded', function(event) {
3
+
4
+ //check if is gutenberg editor
5
+ let yasrIsGutenbergEditor = document.body.classList.contains('block-editor-page');
6
+
7
+ if(yasrIsGutenbergEditor !== true) {
8
+ //show overall rating in the metabox
9
+ yasrPrintMetaBoxOverall();
10
+
11
+ //run shortcode creator
12
+ shortcodeCreator();
13
+ }
14
+
15
+ //always show snippet or multi set
16
+ yasrPrintMetaBoxBelowEditor();
17
+
18
+ }); //end document ready
19
+
20
+ document.getElementById('yasr-metabox-below-editor-select-schema').addEventListener('change',
21
+ function() {
22
+ let selectedItemtype = this.value;
23
+ yasrSwitchItemTypeDiv(selectedItemtype);
24
+ }
25
+ );
26
+
27
+
28
+ /**
29
+ * Print the stars for top right metabox
30
+ *
31
+ * @return void;
32
+ */
33
+ function yasrPrintMetaBoxOverall() {
34
+
35
+ //Convert string to number
36
+ let overallRating = parseFloat(document.getElementById('yasr-overall-rating-value').value);
37
+
38
+ raterJs({
39
+ starSize: 32,
40
+ step: 0.1,
41
+ showToolTip: false,
42
+ rating: overallRating,
43
+ readOnly: false,
44
+ element: document.getElementById("yasr-rater-overall"),
45
+ rateCallback: function rateCallback(rating, done) {
46
+
47
+ rating = rating.toFixed(1);
48
+ rating = parseFloat(rating);
49
+
50
+ //update hidden field
51
+ document.getElementById('yasr-overall-rating-value').value = rating;
52
+
53
+ this.setRating(rating);
54
+
55
+ yasrOverallString = 'You\'ve rated';
56
+
57
+ document.getElementById('yasr_rateit_overall_value').textContent = yasrOverallString + ' ' + rating;
58
+
59
+ done();
60
+ }
61
+ });
62
+
63
+ }
64
+
65
+ /**
66
+ * Print metabox below editor
67
+ * At the page load, show Schema.org option
68
+ */
69
+ function yasrPrintMetaBoxBelowEditor () {
70
+ // When click on main tab hide multi set content
71
+ jQuery('#yasr-metabox-below-editor-structured-data-tab').on("click", function (e) {
72
+
73
+ //prevent click on link jump to the top
74
+ e.preventDefault();
75
+
76
+ jQuery('.yasr-nav-tab').removeClass('nav-tab-active');
77
+ jQuery('#yasr-metabox-below-editor-structured-data-tab').addClass('nav-tab-active');
78
+
79
+ jQuery('.yasr-metabox-below-editor-content').hide();
80
+ jQuery('#yasr-metabox-below-editor-structured-data').show();
81
+
82
+ });
83
+
84
+ //When click on multi set tab hide snippet content
85
+ jQuery('#yasr-metabox-below-editor-multiset-tab').on("click", function (e) {
86
+
87
+ //prevent click on link jump to the top
88
+ e.preventDefault();
89
+
90
+ jQuery('.yasr-nav-tab').removeClass('nav-tab-active');
91
+ jQuery('#yasr-metabox-below-editor-multiset-tab').addClass('nav-tab-active');
92
+
93
+ jQuery('.yasr-metabox-below-editor-content').hide();
94
+ jQuery('#yasr-metabox-below-editor-multiset').show();
95
+
96
+ });
97
+
98
+ let selectedItemtype = document.getElementById('yasr-metabox-below-editor-select-schema').value;
99
+
100
+ yasrSwitchItemTypeDiv (selectedItemtype);
101
+ }
102
+
103
+ function yasrSwitchItemTypeDiv (itemType) {
104
+ if(itemType === 'Product') {
105
+ //show main div
106
+ document.getElementById('yasr-metabox-info-snippet-container').style.display = '';
107
+ //show product
108
+ document.getElementById('yasr-metabox-info-snippet-container-product').style.display = '';
109
+
110
+ //hide all child divs
111
+ document.getElementById('yasr-metabox-info-snippet-container-localbusiness').style.display = 'none';
112
+ document.getElementById('yasr-metabox-info-snippet-container-recipe').style.display = 'none';
113
+
114
+ //return;
115
+ }
116
+ else if(itemType === 'LocalBusiness') {
117
+ //show main div
118
+ document.getElementById('yasr-metabox-info-snippet-container').style.display = '';
119
+ //show localbusiness
120
+ document.getElementById('yasr-metabox-info-snippet-container-localbusiness').style.display = '';
121
+ //hide all child
122
+ document.getElementById('yasr-metabox-info-snippet-container-product').style.display = 'none';
123
+ document.getElementById('yasr-metabox-info-snippet-container-recipe').style.display = 'none';
124
+ }
125
+ else if(itemType === 'Recipe') {
126
+ //show main div
127
+ document.getElementById('yasr-metabox-info-snippet-container').style.display = '';
128
+ //show recipe
129
+ document.getElementById('yasr-metabox-info-snippet-container-recipe').style.display = '';
130
+ //hide all child
131
+ document.getElementById('yasr-metabox-info-snippet-container-localbusiness').style.display = 'none';
132
+ document.getElementById('yasr-metabox-info-snippet-container-product').style.display = 'none';
133
+ }
134
+ else {
135
+ document.getElementById('yasr-metabox-info-snippet-container').style.display = 'none';
136
+ }
137
+ }
138
+
139
+ /****** Yasr Metabox Multiple Rating ******/
140
+
141
+ function yasrAdminMultiSet(nMultiSet, postid, setId) {
142
+
143
+ nMultiSet = parseInt(nMultiSet);
144
+
145
+ if (nMultiSet === 1) {
146
+ yasrPrintAdminMultiSet(setId, postid, false);
147
+ } else {
148
+
149
+ jQuery('#yasr-button-select-set').on("click", function () {
150
+
151
+ //get the multi data
152
+ //overwrite setID
153
+ var setId = jQuery('#select_set').val();
154
+
155
+ jQuery("#yasr-loader-select-multi-set").show();
156
+
157
+ yasrPrintAdminMultiSet(setId, postid, true);
158
+
159
+ return false; // prevent default click action from happening!
160
+
161
+ });
162
+
163
+ }
164
+
165
+ }
166
+
167
+
168
+ //print the table
169
+ function yasrPrintAdminMultiSet(setId, postid, moreThanOneMultiSet) {
170
+
171
+ var data_id = {
172
+ action: 'yasr_send_id_nameset',
173
+ set_id: setId,
174
+ post_id: postid
175
+ };
176
+
177
+ jQuery.post(ajaxurl, data_id, function (response) {
178
+
179
+ //Hide the loader near the select only if more multiset are used
180
+ if (moreThanOneMultiSet === true) {
181
+ document.getElementById('yasr-loader-select-multi-set').style.display = 'none';
182
+ }
183
+
184
+ var yasrMultiSetValue = JSON.parse(response);
185
+
186
+ var content = '';
187
+
188
+ for (var i = 0; i < yasrMultiSetValue.length; i++) {
189
+
190
+ var valueName = yasrMultiSetValue[i]['name'];
191
+ var valueRating = yasrMultiSetValue[i]['average_rating'];
192
+ var valueID = yasrMultiSetValue[i]['id'];
193
+
194
+ content += '<tr>';
195
+ content += '<td>' + valueName + '</td>';
196
+ content += '<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-' + valueID + '" data-rating="'
197
+ + valueRating + '" data-multi-idfield="' + valueID + '"></div>';
198
+ content += '<span id="yasr-loader-multi-set-field-' + valueID + '" style="display: none">';
199
+ content += '<img src="' + yasrCommonDataAdmin.loaderHtml + '"></span>';
200
+ content += '</span>';
201
+ content += '</td>';
202
+ content += '</tr>';
203
+
204
+ var table = document.getElementById('yasr-table-multi-set-admin');
205
+
206
+ table.innerHTML = content;
207
+
208
+ }
209
+
210
+ //Show the text "Choose a vote"
211
+ document.getElementById('yasr-multi-set-admin-choose-text').style.display = 'block';
212
+
213
+ //Set rater for divs
214
+ yasrSetRaterAdminMulti(setId);
215
+
216
+ //Show shortcode
217
+ document.getElementById('yasr-multi-set-admin-explain').style.display = 'block';
218
+
219
+ document.getElementById('yasr-multi-set-admin-explain-with-id-readonly').innerHTML = '<strong>[yasr_multiset setid=' + setId + ']</strong>';
220
+ document.getElementById('yasr-multi-set-admin-explain-with-id-visitor').innerHTML = '<strong>[yasr_visitor_multiset setid=' + setId + ']</strong>';
221
+
222
+ });
223
+
224
+ return false; // prevent default click action from happening!
225
+
226
+ }
227
+
228
+ //Rater for multiset
229
+ function yasrSetRaterAdminMulti(setId) {
230
+
231
+ //update hidden field
232
+ document.getElementById('yasr-multiset-id').value = setId;
233
+
234
+ var yasrMultiSetAdmin = document.getElementsByClassName('yasr-multiset-admin');
235
+
236
+ //an array with all the ratings objects
237
+ var ratingArray = [];
238
+ var ratingValue = false;
239
+
240
+ for (var i = 0; i < yasrMultiSetAdmin.length; i++) {
241
+
242
+ (function (i) {
243
+
244
+ var htmlId = yasrMultiSetAdmin.item(i).id;
245
+ var elem = document.getElementById(htmlId);
246
+
247
+ raterJs({
248
+ starSize: 32,
249
+ step: 0.5,
250
+ showToolTip: false,
251
+ readOnly: false,
252
+ element: elem,
253
+
254
+ rateCallback: function rateCallback(rating, done) {
255
+
256
+ rating = rating.toFixed(1);
257
+ //Be sure is a number and not a string
258
+ rating = parseFloat(rating);
259
+ this.setRating(rating); //Set the rating
260
+
261
+ var setIdField = parseInt(elem.getAttribute('data-multi-idfield'));
262
+
263
+ ratingObject = {
264
+ field: setIdField,
265
+ rating: rating
266
+ };
267
+
268
+ //creating rating array
269
+ ratingArray.push(ratingObject);
270
+
271
+ ratingValue = JSON.stringify(ratingArray);
272
+
273
+ //update hidden field
274
+ document.getElementById('yasr-multiset-author-votes').value = ratingValue;
275
+
276
+ done();
277
+ }
278
+
279
+ });
280
+
281
+ })(i);
282
+
283
+ } //End for
284
+
285
+ }//End function
286
+
287
+ /****** End Yasr Metabox Multple Rating ******/
288
+
289
+ function shortcodeCreator () {
290
+ var data = {
291
+ action: 'yasr_create_shortcode'
292
+ };
293
+
294
+ jQuery.post(ajaxurl, data, function (button_content) {
295
+ jQuery(button_content).appendTo('body').hide();
296
+ });
297
+ }
298
+
299
+ /****** Yasr Ajax Page ******/
300
+ // When click on chart hide tab-main and show tab-charts
301
+
302
+ function yasrShortcodeCreator(nMultiSet) {
303
+
304
+ // When click on main tab hide tab-main and show tab-charts
305
+ jQuery('#yasr-link-tab-main').on("click", function () {
306
+
307
+ jQuery('.yasr-nav-tab').removeClass('nav-tab-active');
308
+ jQuery('#yasr-link-tab-main').addClass('nav-tab-active');
309
+
310
+ jQuery('.yasr-content-tab-tinymce').hide();
311
+ jQuery('#yasr-content-tab-main').show();
312
+
313
+ });
314
+
315
+ jQuery('#yasr-link-tab-charts').on("click", function () {
316
+
317
+ jQuery('.yasr-nav-tab').removeClass('nav-tab-active');
318
+ jQuery('#yasr-link-tab-charts').addClass('nav-tab-active');
319
+
320
+ jQuery('.yasr-content-tab-tinymce').hide();
321
+ jQuery('#yasr-content-tab-charts').show();
322
+
323
+ });
324
+
325
+ // Add shortcode for overall rating
326
+ jQuery('#yasr-overall').on("click", function () {
327
+ jQuery('#yasr-overall-choose-size').toggle('slow');
328
+ });
329
+
330
+ jQuery('#yasr-overall-insert-small').on("click", function () {
331
+ var shortcode = '[yasr_overall_rating size="small"]';
332
+
333
+ if (tinyMCE.activeEditor == null) {
334
+
335
+ //this is for tinymce used in text mode
336
+ jQuery("#content").append(shortcode);
337
+
338
+ } else {
339
+
340
+ // inserts the shortcode into the active editor
341
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
342
+
343
+ }
344
+
345
+ // close
346
+ tb_remove();
347
+ //jQuery('#yasr-tinypopup-form').dialog('close');
348
+
349
+ });
350
+
351
+ jQuery('#yasr-overall-insert-medium').on("click", function () {
352
+ var shortcode = '[yasr_overall_rating size="medium"]';
353
+
354
+ // inserts the shortcode into the active editor
355
+ if (tinyMCE.activeEditor == null) {
356
+
357
+ //this is for tinymce used in text mode
358
+ jQuery("#content").append(shortcode);
359
+
360
+ } else {
361
+
362
+ // inserts the shortcode into the active editor
363
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
364
+
365
+ }
366
+
367
+ // close
368
+ tb_remove();
369
+ //jQuery('#yasr-tinypopup-form').dialog('close');
370
+ });
371
+
372
+ jQuery('#yasr-overall-insert-large').on("click", function () {
373
+ var shortcode = '[yasr_overall_rating size="large"]';
374
+
375
+ if (tinyMCE.activeEditor == null) {
376
+
377
+ //this is for tinymce used in text mode
378
+ jQuery("#content").append(shortcode);
379
+
380
+ } else {
381
+
382
+ // inserts the shortcode into the active editor
383
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
384
+
385
+ }
386
+
387
+ // close
388
+ tb_remove();
389
+ //jQuery('#yasr-tinypopup-form').dialog('close');
390
+ });
391
+
392
+ //Add shortcode for visitors rating
393
+ jQuery('#yasr-visitor-votes').on("click", function () {
394
+ jQuery('#yasr-visitor-choose-size').toggle('slow');
395
+ });
396
+
397
+ jQuery('#yasr-visitor-insert-small').on("click", function () {
398
+ var shortcode = '[yasr_visitor_votes size="small"]';
399
+
400
+ // inserts the shortcode into the active editor
401
+ if (tinyMCE.activeEditor == null) {
402
+
403
+ //this is for tinymce used in text mode
404
+ jQuery("#content").append(shortcode);
405
+
406
+ } else {
407
+ // inserts the shortcode into the active editor
408
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
409
+ }
410
+
411
+ // close
412
+ tb_remove();
413
+ //jQuery('#yasr-tinypopup-form').dialog('close');
414
+ });
415
+
416
+ jQuery('#yasr-visitor-insert-medium').on("click", function () {
417
+ var shortcode = '[yasr_visitor_votes size="medium"]';
418
+
419
+ if (tinyMCE.activeEditor == null) {
420
+
421
+ //this is for tinymce used in text mode
422
+ jQuery("#content").append(shortcode);
423
+
424
+ } else {
425
+
426
+ // inserts the shortcode into the active editor
427
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
428
+
429
+ }
430
+
431
+ // close
432
+ tb_remove();
433
+ //jQuery('#yasr-tinypopup-form').dialog('close');
434
+ });
435
+
436
+ jQuery('#yasr-visitor-insert-large').on("click", function () {
437
+ var shortcode = '[yasr_visitor_votes size="large"]';
438
+
439
+ // inserts the shortcode into the active editor
440
+ if (tinyMCE.activeEditor == null) {
441
+
442
+ //this is for tinymce used in text mode
443
+ jQuery("#content").append(shortcode);
444
+
445
+ } else {
446
+
447
+ // inserts the shortcode into the active editor
448
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
449
+
450
+ }
451
+
452
+ // close
453
+ tb_remove();
454
+ //jQuery('#yasr-tinypopup-form').dialog('close');
455
+ });
456
+
457
+ if (nMultiSet > 1) {
458
+
459
+ //Add shortcode for multiple set
460
+ jQuery('#yasr-insert-multiset-select').on("click", function () {
461
+ var setType = jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();
462
+ var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
463
+ var showAverage = jQuery("#yasr-hide-average-multiset").is(':checked');
464
+
465
+ if (!visitorSet) {
466
+
467
+ var shortcode = '[yasr_visitor_multiset setid=';
468
+
469
+ } else {
470
+
471
+ var shortcode = '[yasr_multiset setid=';
472
+
473
+ }
474
+
475
+ shortcode += setType;
476
+
477
+ if (showAverage) {
478
+
479
+ shortcode += ' show_average=\'no\'';
480
+
481
+ }
482
+
483
+
484
+ shortcode += ']';
485
+
486
+ // inserts the shortcode into the active editor
487
+ if (tinyMCE.activeEditor == null) {
488
+
489
+ //this is for tinymce used in text mode
490
+ jQuery("#content").append(shortcode);
491
+
492
+ } else {
493
+
494
+ // inserts the shortcode into the active editor
495
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
496
+
497
+ }
498
+
499
+ // close
500
+ tb_remove();
501
+ //jQuery('#yasr-tinypopup-form').dialog('close');
502
+ });
503
+
504
+ } //End if
505
+
506
+ else if (nMultiSet == 1) {
507
+
508
+ //Add shortcode for single set (if only 1 are found)
509
+ jQuery('#yasr-single-set').on("click", function () {
510
+ var setType = jQuery('#yasr-single-set').val();
511
+ var showAverage = jQuery("#yasr-hide-average-multiset").is(':checked');
512
+
513
+ var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
514
+
515
+ if (!visitorSet) {
516
+
517
+ var shortcode = '[yasr_visitor_multiset setid=';
518
+
519
+ } else {
520
+
521
+ var shortcode = '[yasr_multiset setid=';
522
+
523
+ }
524
+
525
+ shortcode += setType;
526
+
527
+ if (showAverage) {
528
+
529
+ shortcode += ' show_average=\'no\'';
530
+
531
+ }
532
+
533
+ shortcode += ']';
534
+
535
+ // inserts the shortcode into the active editor
536
+ if (tinyMCE.activeEditor == null) {
537
+
538
+ //this is for tinymce used in text mode
539
+ jQuery("#content").append(shortcode);
540
+
541
+ } else {
542
+
543
+ // inserts the shortcode into the active editor
544
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
545
+
546
+ }
547
+
548
+ // close
549
+ tb_remove();
550
+ //jQuery('#yasr-tinypopup-form').dialog('close');
551
+ });
552
+
553
+ } //End elseif
554
+
555
+ // Add shortcode for top 10 by overall ratings
556
+ jQuery('#yasr-top-10-overall-rating').on("click", function () {
557
+ var shortcode = '[yasr_top_ten_highest_rated]';
558
+
559
+ // inserts the shortcode into the active editor
560
+ if (tinyMCE.activeEditor == null) {
561
+
562
+ //this is for tinymce used in text mode
563
+ jQuery("#content").append(shortcode);
564
+
565
+ } else {
566
+
567
+ // inserts the shortcode into the active editor
568
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
569
+
570
+ }
571
+
572
+ // close
573
+ tb_remove();
574
+ //jQuery('#yasr-tinypopup-form').dialog('close');
575
+ });
576
+
577
+ // Add shortcode for 10 highest most rated
578
+ jQuery('#yasr-10-highest-most-rated').on("click", function () {
579
+ var shortcode = '[yasr_most_or_highest_rated_posts]';
580
+
581
+ // inserts the shortcode into the active editor
582
+ if (tinyMCE.activeEditor == null) {
583
+
584
+ //this is for tinymce used in text mode
585
+ jQuery("#content").append(shortcode);
586
+
587
+ } else {
588
+
589
+ // inserts the shortcode into the active editor
590
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
591
+
592
+ }
593
+
594
+ // close
595
+ tb_remove();
596
+ //jQuery('#yasr-tinypopup-form').dialog('close');
597
+ });
598
+
599
+ // Add shortcode for top 5 active reviewer
600
+ jQuery('#yasr-5-active-reviewers').on("click", function () {
601
+ var shortcode = '[yasr_top_5_reviewers]';
602
+
603
+ // inserts the shortcode into the active editor
604
+ if (tinyMCE.activeEditor == null) {
605
+
606
+ //this is for tinymce used in text mode
607
+ jQuery("#content").append(shortcode);
608
+
609
+ } else {
610
+
611
+ // inserts the shortcode into the active editor
612
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
613
+
614
+ }
615
+
616
+ // close
617
+ tb_remove();
618
+ //jQuery('#yasr-tinypopup-form').dialog('close');
619
+ });
620
+
621
+ // Add shortcode for top 10 active users
622
+ jQuery('#yasr-top-10-active-users').on("click", function () {
623
+ var shortcode = '[yasr_top_ten_active_users]';
624
+
625
+ // inserts the shortcode into the active editor
626
+ if (tinyMCE.activeEditor == null) {
627
+
628
+ //this is for tinymce used in text mode
629
+ jQuery("#content").append(shortcode);
630
+
631
+ } else {
632
+
633
+ // inserts the shortcode into the active editor
634
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
635
+
636
+ }
637
+
638
+ // close
639
+ tb_remove();
640
+ //jQuery('#yasr-tinypopup-form').dialog('close');
641
+ });
642
+
643
+ } //End function
644
+
645
+ /****** End YAsr Ajax page ******/
js/yasr-guten-panel.js CHANGED
@@ -167,8 +167,7 @@ var YasrSideBarAutoInsert = function (_React$Component2) {
167
  React.createElement('span', { className: 'yasr-onoffswitch-inner' }),
168
  React.createElement('span', { className: 'yasr-onoffswitch-switch' })
169
  )
170
- ),
171
- React.createElement('hr', null)
172
  );
173
  }
174
  }]);
@@ -176,163 +175,123 @@ var YasrSideBarAutoInsert = function (_React$Component2) {
176
  return YasrSideBarAutoInsert;
177
  }(React.Component);
178
 
179
- var YasrDivIsReview = function (_React$Component3) {
180
- _inherits(YasrDivIsReview, _React$Component3);
181
 
182
- function YasrDivIsReview(props) {
183
- _classCallCheck(this, YasrDivIsReview);
184
 
185
- var _this3 = _possibleConstructorReturn(this, (YasrDivIsReview.__proto__ || Object.getPrototypeOf(YasrDivIsReview)).call(this, props));
186
-
187
- var isThisPostReview = wp.data.select('core/editor').getCurrentPost().meta.yasr_post_is_review;
188
- var isThisPostReviewCheckbox = false;
189
 
190
  if (isThisPostReview === 'yes') {
191
  isThisPostReviewCheckbox = true;
192
  }
193
 
194
- _this3.state = { postIsReview: isThisPostReviewCheckbox };
195
 
196
- _this3.yasrUpdatePostMetaIsReview = _this3.yasrUpdatePostMetaIsReview.bind(_this3);
197
- return _this3;
198
  }
199
 
200
- _createClass(YasrDivIsReview, [{
201
- key: 'yasrUpdatePostMetaIsReview',
202
- value: function yasrUpdatePostMetaIsReview(event) {
203
 
204
- var target = event.target;
205
- var postIsReview = target.type === 'checkbox' ? target.checked : target.value;
206
 
207
- this.setState({ postIsReview: postIsReview });
208
 
209
- if (postIsReview === true) {
210
- wp.data.dispatch('core/editor').editPost({ meta: { yasr_post_is_review: 'yes' } });
211
- } else {
212
- wp.data.dispatch('core/editor').editPost({ meta: { yasr_post_is_review: 'no' } });
213
- }
214
- }
215
- }, {
216
- key: 'render',
217
- value: function render() {
218
- return React.createElement(
219
- 'div',
220
- { className: 'yasr-guten-block-panel-center' },
221
- React.createElement(
222
- 'div',
223
- { className: 'rich-snippet-title' },
224
- yasrRichSnippetOptions
225
- ),
226
- React.createElement(
227
- 'label',
228
- null,
229
- React.createElement(
230
- 'span',
231
- null,
232
- yasrPostExcluded
233
- )
234
- ),
235
- React.createElement(
236
- 'div',
237
- { className: 'yasr-onoffswitch-big yasr-onoffswitch-big-center', id: 'yasr-switcher-post-is-review' },
238
- React.createElement('input', { type: 'checkbox',
239
- name: 'yasr_post_is_review',
240
- className: 'yasr-onoffswitch-checkbox',
241
- value: 'yes',
242
- id: 'yasr-post-is-review-switch',
243
- defaultChecked: this.state.postIsReview,
244
- onChange: this.yasrUpdatePostMetaIsReview
245
- }),
246
- React.createElement(
247
- 'label',
248
- { className: 'yasr-onoffswitch-label', htmlFor: 'yasr-post-is-review-switch' },
249
- React.createElement('span', { className: 'yasr-onoffswitch-inner' }),
250
- React.createElement('span', { className: 'yasr-onoffswitch-switch' })
251
- )
252
- ),
253
- React.createElement('p', null)
254
  );
255
  }
256
- }]);
257
 
258
- return YasrDivIsReview;
259
- }(React.Component);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
- var YasrSideBarSelectSnippets = function (_React$Component4) {
262
- _inherits(YasrSideBarSelectSnippets, _React$Component4);
263
 
264
- function YasrSideBarSelectSnippets(props) {
265
- _classCallCheck(this, YasrSideBarSelectSnippets);
266
 
267
- //at the begin, get the default type
268
- var _this4 = _possibleConstructorReturn(this, (YasrSideBarSelectSnippets.__proto__ || Object.getPrototypeOf(YasrSideBarSelectSnippets)).call(this, props));
269
 
270
- var snippetType = yasrConstantGutenberg.defaultItemType;
 
 
 
 
271
 
272
  //get array with all supported itemtypes
273
- _this4.supportedItemtype = wp.data.select('core/editor').getCurrentPost().yasr_all_itemtypes;
274
 
275
  //get postmeta itemtype
276
- var postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
277
 
278
  //if the postmeta is in the array of all item, set in the select the postmeta_itemtype
279
- if (_this4.supportedItemtype.includes(postMetaItemType)) {
280
  snippetType = postMetaItemType;
281
  }
282
 
283
- _this4.state = { snippet: snippetType };
284
 
285
- _this4.yasrSetItemType = _this4.yasrSetItemType.bind(_this4);
286
- return _this4;
287
  }
288
 
289
- _createClass(YasrSideBarSelectSnippets, [{
290
- key: 'yasrSetItemType',
291
- value: function yasrSetItemType(event) {
292
- this.setState({ snippet: event.target.value });
293
 
294
- wp.data.dispatch('core/editor').editPost({ meta: { yasr_review_type: event.target.value } });
295
- }
296
- }, {
297
- key: 'render',
298
- value: function render() {
299
- return React.createElement(
300
- 'div',
301
- { className: 'yasr-guten-block-panel-center' },
302
- React.createElement(
303
- 'label',
304
- null,
305
- React.createElement(
306
- 'span',
307
- null,
308
- yasrSelectSnippetTitle
309
- )
310
- ),
311
- React.createElement(
312
- 'select',
313
- { value: this.state.snippet, onChange: this.yasrSetItemType },
314
- this.supportedItemtype.map(function (snippet) {
315
- return React.createElement(
316
- 'option',
317
- { value: snippet },
318
- snippet
319
- );
320
- })
321
- )
322
- );
323
- }
324
- }]);
325
 
326
- return YasrSideBarSelectSnippets;
327
- }(React.Component);
 
 
 
 
 
 
 
 
 
 
 
328
 
329
- var yasrSidebar = function (_React$Component5) {
330
- _inherits(yasrSidebar, _React$Component5);
331
 
332
  function yasrSidebar(props) {
333
  _classCallCheck(this, yasrSidebar);
334
 
335
- var _this5 = _possibleConstructorReturn(this, (yasrSidebar.__proto__ || Object.getPrototypeOf(yasrSidebar)).call(this, props));
336
 
337
  var yasrAutoInsertEnabled = false;
338
 
@@ -341,9 +300,9 @@ var yasrSidebar = function (_React$Component5) {
341
  yasrAutoInsertEnabled = true;
342
  }
343
 
344
- _this5.state = { yasrAutoInsertEnabled: yasrAutoInsertEnabled };
345
 
346
- return _this5;
347
  }
348
 
349
  _createClass(yasrSidebar, [{
@@ -368,8 +327,6 @@ var yasrSidebar = function (_React$Component5) {
368
  { className: 'yasr-guten-block-panel yasr-guten-block-panel-center' },
369
  React.createElement(YasrDivRatingOverall, null),
370
  this.state.yasrAutoInsertEnabled && React.createElement(YasrSideBarAutoInsert, null),
371
- React.createElement(YasrDivIsReview, null),
372
- React.createElement(YasrSideBarSelectSnippets, null),
373
  wp.hooks.applyFilters('yasr_add_content_bottom_sidebar', React.createElement(ContentBelowSidebar, null))
374
  )
375
  )
167
  React.createElement('span', { className: 'yasr-onoffswitch-inner' }),
168
  React.createElement('span', { className: 'yasr-onoffswitch-switch' })
169
  )
170
+ )
 
171
  );
172
  }
173
  }]);
175
  return YasrSideBarAutoInsert;
176
  }(React.Component);
177
 
178
+ /*class YasrDivIsReview extends React.Component {
 
179
 
180
+ constructor(props) {
181
+ super(props);
182
 
183
+ let isThisPostReview = wp.data.select('core/editor').getCurrentPost().meta.yasr_post_is_review;
184
+ let isThisPostReviewCheckbox = false;
 
 
185
 
186
  if (isThisPostReview === 'yes') {
187
  isThisPostReviewCheckbox = true;
188
  }
189
 
190
+ this.state = {postIsReview: isThisPostReviewCheckbox};
191
 
192
+ this.yasrUpdatePostMetaIsReview = this.yasrUpdatePostMetaIsReview.bind(this);
 
193
  }
194
 
195
+ yasrUpdatePostMetaIsReview(event) {
 
 
196
 
197
+ const target = event.target;
198
+ const postIsReview = target.type === 'checkbox' ? target.checked : target.value;
199
 
200
+ this.setState({postIsReview: postIsReview});
201
 
202
+ if (postIsReview === true) {
203
+ wp.data.dispatch('core/editor').editPost(
204
+ { meta: { yasr_post_is_review: 'yes' } }
205
+ );
206
+ } else {
207
+ wp.data.dispatch('core/editor').editPost(
208
+ { meta: { yasr_post_is_review: 'no' } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  );
210
  }
 
211
 
212
+ }
213
+
214
+ render () {
215
+ return (
216
+ <div className="yasr-guten-block-panel-center">
217
+ <div className="rich-snippet-title">{yasrRichSnippetOptions}</div>
218
+ <label><span>{yasrPostExcluded}</span></label>
219
+ <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-post-is-review">
220
+ <input type="checkbox"
221
+ name="yasr_post_is_review"
222
+ className="yasr-onoffswitch-checkbox"
223
+ value="yes"
224
+ id="yasr-post-is-review-switch"
225
+ defaultChecked={this.state.postIsReview}
226
+ onChange={this.yasrUpdatePostMetaIsReview}
227
+ />
228
+ <label className="yasr-onoffswitch-label" htmlFor="yasr-post-is-review-switch">
229
+ <span className="yasr-onoffswitch-inner"></span>
230
+ <span className="yasr-onoffswitch-switch"></span>
231
+ </label>
232
+ </div>
233
+ <p></p>
234
+ </div>
235
+ );
236
+ }
237
 
238
+ }
 
239
 
240
+ class YasrSideBarSelectSnippets extends React.Component {
 
241
 
242
+ supportedItemtype;
 
243
 
244
+ constructor(props) {
245
+ super(props);
246
+
247
+ //at the begin, get the default type
248
+ let snippetType = yasrConstantGutenberg.defaultItemType;
249
 
250
  //get array with all supported itemtypes
251
+ this.supportedItemtype = wp.data.select('core/editor').getCurrentPost().yasr_all_itemtypes;
252
 
253
  //get postmeta itemtype
254
+ let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
255
 
256
  //if the postmeta is in the array of all item, set in the select the postmeta_itemtype
257
+ if(this.supportedItemtype.includes(postMetaItemType)) {
258
  snippetType = postMetaItemType;
259
  }
260
 
261
+ this.state = {snippet: snippetType};
262
 
263
+ this.yasrSetItemType = this.yasrSetItemType.bind(this);
 
264
  }
265
 
266
+ yasrSetItemType(event) {
267
+ this.setState({snippet: event.target.value});
 
 
268
 
269
+ wp.data.dispatch( 'core/editor' ).editPost(
270
+ { meta: { yasr_review_type: event.target.value } }
271
+ );
272
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
+ render() {
275
+ return (
276
+ <div className="yasr-guten-block-panel-center">
277
+ <label><span>{yasrSelectSnippetTitle}</span></label>
278
+ <select value={this.state.snippet} onChange={this.yasrSetItemType}>
279
+ {this.supportedItemtype.map((snippet) => {
280
+ return <option value={snippet}>{snippet}</option>;
281
+ })}
282
+ </select>
283
+ </div>
284
+ );
285
+ }
286
+ }*/
287
 
288
+ var yasrSidebar = function (_React$Component3) {
289
+ _inherits(yasrSidebar, _React$Component3);
290
 
291
  function yasrSidebar(props) {
292
  _classCallCheck(this, yasrSidebar);
293
 
294
+ var _this3 = _possibleConstructorReturn(this, (yasrSidebar.__proto__ || Object.getPrototypeOf(yasrSidebar)).call(this, props));
295
 
296
  var yasrAutoInsertEnabled = false;
297
 
300
  yasrAutoInsertEnabled = true;
301
  }
302
 
303
+ _this3.state = { yasrAutoInsertEnabled: yasrAutoInsertEnabled };
304
 
305
+ return _this3;
306
  }
307
 
308
  _createClass(yasrSidebar, [{
327
  { className: 'yasr-guten-block-panel yasr-guten-block-panel-center' },
328
  React.createElement(YasrDivRatingOverall, null),
329
  this.state.yasrAutoInsertEnabled && React.createElement(YasrSideBarAutoInsert, null),
 
 
330
  wp.hooks.applyFilters('yasr_add_content_bottom_sidebar', React.createElement(ContentBelowSidebar, null))
331
  )
332
  )
lib/YasrRichSnippetAdditionalFields.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ new YasrRichSnippetAdditionalFields();
4
+
5
+ class YasrRichSnippetAdditionalFields {
6
+
7
+ public function __construct() {
8
+ add_filter('yasr_filter_existing_schema', array($this, 'additional_schema'));
9
+ }
10
+
11
+ function additional_schema($rich_snippet) {
12
+
13
+ $review_choosen = yasr_get_itemType();
14
+ $saved_data = get_post_meta(get_the_ID(), 'yasr_schema_additional_fields', true);
15
+
16
+ $array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS);
17
+
18
+ foreach ($array_item_type_info as $item_type) {
19
+ //avoid undefined
20
+ if(!isset($saved_data[$item_type])) {
21
+ $saved_data[$item_type] = false;
22
+ }
23
+ }
24
+
25
+ //avoid undefined
26
+ $more_rich_snippet = array();
27
+
28
+ if($review_choosen === 'Product') {
29
+ $more_rich_snippet = $this->itemProduct($saved_data);
30
+ }
31
+ if($review_choosen === 'LocalBusiness') {
32
+ $more_rich_snippet = $this->localBusiness($saved_data);
33
+ }
34
+ if($review_choosen === 'Recipe') {
35
+ $more_rich_snippet = $this->recipe($saved_data);
36
+ }
37
+
38
+ return array_merge($rich_snippet, $more_rich_snippet);
39
+
40
+ }
41
+
42
+ private function itemProduct($saved_data) {
43
+ $global_identifer_name = $saved_data['yasr_product_global_identifier_select'];
44
+
45
+ $rich_snippet['brand'] = $saved_data['yasr_product_brand'];
46
+ $rich_snippet['sku'] = $saved_data['yasr_product_sku'];
47
+ $rich_snippet[$global_identifer_name] = $saved_data['yasr_product_global_identifier_value'];
48
+
49
+ if(!empty($saved_data['yasr_product_price'])) {
50
+ $rich_snippet['offers'] = array(
51
+ '@type' => 'Offer',
52
+ 'price' => $saved_data['yasr_product_price'],
53
+ 'priceCurrency' => $saved_data['yasr_product_price_currency'],
54
+ 'priceValidUntil' => $saved_data['yasr_product_price_valid_until'],
55
+ 'availability' => $saved_data['yasr_product_price_availability'],
56
+ 'url' => $saved_data['yasr_product_price_url'],
57
+ );
58
+
59
+ }
60
+ return $rich_snippet;
61
+ }
62
+
63
+ private function localBusiness($saved_data) {
64
+ $rich_snippet['address'] = $saved_data['yasr_localbusiness_address'];
65
+ $rich_snippet['priceRange'] = $saved_data['yasr_localbusiness_pricerange'];
66
+ $rich_snippet['telephone'] = $saved_data['yasr_localbusiness_telephone'];
67
+
68
+ return $rich_snippet;
69
+ }
70
+
71
+ private function recipe($saved_data) {
72
+
73
+ $instruction_array_clean = array();
74
+ $ingredient_array = array();
75
+
76
+ if(!empty($saved_data['yasr_recipe_recipeinstructions'])) {
77
+ $instruction_array = explode(PHP_EOL, $saved_data['yasr_recipe_recipeinstructions']);
78
+
79
+ $i=0;
80
+ foreach ($instruction_array as $instrunction) {
81
+ $instruction_array_clean[$i]['@type'] = "HowToStep";
82
+ $instruction_array_clean[$i]['text'] = $instrunction;
83
+ $i++;
84
+ }
85
+ }
86
+
87
+ if(!empty($saved_data['yasr_recipe_recipeingredient'])) {
88
+ $ingredient_array = explode(PHP_EOL, $saved_data['yasr_recipe_recipeingredient']);
89
+ }
90
+
91
+ if(!empty($saved_data['yasr_recipe_nutrition'])) {
92
+ $rich_snippet['nutrition'] = array(
93
+ "@type" => "NutritionInformation",
94
+ "calories" => $saved_data['yasr_recipe_nutrition'] . " calories",
95
+ );
96
+
97
+ }
98
+
99
+ $rich_snippet['author'] = array(
100
+ '@type' => 'Person',
101
+ 'name' => get_the_author()
102
+ );
103
+
104
+ $rich_snippet['cookTime'] = $saved_data['yasr_recipe_cooktime'];
105
+ $rich_snippet['description'] = $saved_data['yasr_recipe_description'];
106
+ $rich_snippet['keywords'] = $saved_data['yasr_recipe_keywords'];
107
+ $rich_snippet['prepTime'] = $saved_data['yasr_recipe_preptime'];
108
+ $rich_snippet['recipeCategory'] = $saved_data['yasr_recipe_recipecategory'];
109
+ $rich_snippet['recipeCuisine'] = $saved_data['yasr_recipe_recipecuisine'];
110
+ $rich_snippet['recipeIngredient'] = $ingredient_array;
111
+ $rich_snippet['recipeInstructions'] = $instruction_array_clean;
112
+ $rich_snippet['video'] = $saved_data['yasr_recipe_video'];
113
+
114
+ return $rich_snippet;
115
+ }
116
+ }
lib/admin/editor/YasrOnSavePost.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>
19
+ */
20
+
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
+
25
+
26
+
27
+ class YasrOnSavePost {
28
+
29
+ private $post_id;
30
+
31
+ public function __construct($post_id) {
32
+ $this->post_id = (int)$post_id;
33
+
34
+ $this->yasrSavePost();
35
+ }
36
+
37
+ private function yasrSavePost() {
38
+ //if user can not publish posts
39
+ if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
40
+ return;
41
+ }
42
+ $this->saveOverallRating();
43
+ $this->postIsReview();
44
+ $this->saveItemType();
45
+ $this->saveItemTypesFields();
46
+ $this->saveMultisetEditor();
47
+
48
+ if (YASR_AUTO_INSERT_ENABLED === 1) {
49
+ $this->excludeAutoInsert();
50
+ }
51
+ }
52
+
53
+ /********** Save Post actions **********/
54
+
55
+ private function saveOverallRating() {
56
+ //this mean there we're not in the classic editor
57
+ if (!isset($_POST['yasr_nonce_overall_rating'])) {
58
+ return;
59
+ }
60
+
61
+ $update_result = null;
62
+
63
+ if (isset($_POST['yasr_overall_rating'])) {
64
+ $rating = $_POST['yasr_overall_rating'];
65
+ $nonce = $_POST['yasr_nonce_overall_rating'];
66
+ } else {
67
+ return;
68
+ }
69
+
70
+ if (!wp_verify_nonce($nonce, 'yasr_nonce_overall_rating_action')) {
71
+ return;
72
+ }
73
+
74
+ $rating = (float) $rating;
75
+
76
+ if ($rating > 5) {
77
+ $rating = 5;
78
+ }
79
+
80
+ //Put an action to hook into
81
+ do_action('yasr_action_on_overall_rating', $this->post_id, $rating);
82
+
83
+ $update_result = update_post_meta($this->post_id, 'yasr_overall_rating', $rating);
84
+
85
+ //if update_post_meta returns an integer means this is a new post
86
+ //so we're going to insert the default YASR_ITEMTYPE
87
+ if (is_int($update_result)) {
88
+ add_post_meta($this->post_id, 'yasr_review_type', YASR_ITEMTYPE);
89
+ }
90
+
91
+ }
92
+
93
+ private function postIsReview() {
94
+
95
+ //this mean there we're not in the classic editor
96
+ if(!isset($_POST['yasr_nonce_is_post_review'])) {
97
+ return;
98
+ } else {
99
+ $nonce = $_POST['yasr_nonce_is_post_review'];
100
+ }
101
+
102
+ if (!wp_verify_nonce($nonce, 'yasr_nonce_is_post_review_action')) {
103
+ return;
104
+ }
105
+
106
+ if (isset($_POST['yasr_is_post_review'])) {
107
+ update_post_meta($this->post_id, 'yasr_post_is_review', 'yes');
108
+ }
109
+ else {
110
+ delete_post_meta($this->post_id, 'yasr_post_is_review');
111
+ }
112
+ }
113
+
114
+ private function saveItemType() {
115
+
116
+ //this mean there we're not in the classic editor
117
+ if(!isset($_POST['yasr_nonce_review_type'])) {
118
+ return;
119
+ } else {
120
+ $nonce = $_POST['yasr_nonce_review_type'];
121
+ }
122
+
123
+ //check nonce
124
+ if (!wp_verify_nonce($nonce, 'yasr_nonce_review_type_action')) {
125
+ return;
126
+ }
127
+
128
+ //check if $_POST isset
129
+ if (isset($_POST['yasr-review-type'])) {
130
+ $snippet_type = $_POST['yasr-review-type'];
131
+
132
+ //check if $snippet_type is a supported itemType
133
+ if (yasr_is_supported_schema($snippet_type)===true) {
134
+ //if the selected item type, is the same of the default one, delete the saved postmeta
135
+ if ($snippet_type === YASR_ITEMTYPE) {
136
+ delete_post_meta($this->post_id, 'yasr_review_type');
137
+ } else {
138
+ update_post_meta($this->post_id, 'yasr_review_type', $snippet_type);
139
+ }
140
+ } else {
141
+ return;
142
+ }
143
+ } else {
144
+ return;
145
+ }
146
+
147
+ }
148
+
149
+ private function saveItemTypesFields() {
150
+ $array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS);
151
+ $array_to_save = array();
152
+
153
+ foreach ($array_item_type_info as $item_type_name) {
154
+
155
+ $nonce_action = $item_type_name . '_nonce_action';
156
+ $nonce_name = $item_type_name . '_nonce_name';
157
+
158
+ //verifing nonces
159
+ if(isset($_POST[$nonce_name])) {
160
+ $nonce = $_POST[$nonce_name];
161
+ if(!wp_verify_nonce($nonce, $nonce_action)) {
162
+ return;
163
+ }
164
+ }
165
+
166
+ //get value, sanitize it and save
167
+ if(isset($_POST[$item_type_name])) {
168
+
169
+ //if come from textarea, use sanitize_textarea_field, that preservers newlines
170
+ if($item_type_name === 'yasr_recipe_recipeingredient'
171
+ || $item_type_name === 'yasr_recipe_recipeinstructions') {
172
+ $item_to_save = sanitize_textarea_field($_POST[$item_type_name]);
173
+ } else {
174
+ //use sanitize_text_field
175
+ $item_to_save = sanitize_text_field($_POST[$item_type_name]);
176
+ }
177
+
178
+ $array_to_save[$item_type_name] = $item_to_save;
179
+ }
180
+
181
+ }
182
+
183
+ update_post_meta($this->post_id, 'yasr_schema_additional_fields', $array_to_save);
184
+
185
+ }
186
+
187
+ private function saveMultisetEditor() {
188
+
189
+ if (isset($_POST['yasr_multiset_author_votes']) && isset($_POST['yasr_multiset_id'])) {
190
+ $field_and_vote_array = json_decode(sanitize_text_field(stripslashes($_POST['yasr_multiset_author_votes'])));
191
+ $set_id = (int) $_POST['yasr_multiset_id'];
192
+ $nonce = $_POST['yasr_nonce_save_multi_values'];
193
+
194
+ if (!is_int($set_id) || $field_and_vote_array == '') {
195
+ return;
196
+ }
197
+
198
+ } else {
199
+ return;
200
+ }
201
+
202
+ if (!wp_verify_nonce($nonce, 'yasr_nonce_save_multi_values_action')) {
203
+ die('Security check');
204
+ }
205
+
206
+ $i = 0;
207
+
208
+ $data_to_save[$i] = array(
209
+ 'set_id' => (int)$set_id,
210
+ 'fields_and_ratings' => $field_and_vote_array
211
+ );
212
+
213
+ $i++;
214
+
215
+ $set_post_meta_values = get_post_meta($this->post_id, 'yasr_multiset_author_votes',true);
216
+
217
+ //If data for this post already exists
218
+ if ($set_post_meta_values) {
219
+ //first, loop saved fields and ratings
220
+ foreach ($set_post_meta_values as $saved_set_id) {
221
+ //if the saved set is different from the one that we're trying to save,
222
+ //append data to save to the post meta
223
+ if ($saved_set_id['set_id'] !== $set_id) {
224
+ $data_to_save[$i]['set_id'] = $saved_set_id['set_id'];
225
+ $data_to_save[$i]['fields_and_ratings'] = $saved_set_id['fields_and_ratings'];
226
+
227
+ $i++;
228
+ //Append data to save to the post meta
229
+
230
+ } //if the set is not stored
231
+ }
232
+ }
233
+
234
+ // Write new data
235
+ update_post_meta($this->post_id, 'yasr_multiset_author_votes', $data_to_save);
236
+
237
+ } //End callback function
238
+
239
+ private function excludeAutoInsert() {
240
+
241
+ //this mean there we're not in the classic editor
242
+ if (!isset($_POST['yasr_nonce_auto_insert'])) {
243
+ return;
244
+ } else {
245
+ $nonce = $_POST['yasr_nonce_auto_insert'];
246
+ }
247
+
248
+ if (!wp_verify_nonce($nonce, 'yasr_nonce_auto_insert_action')) {
249
+ return;
250
+ }
251
+
252
+ if (isset($_POST['yasr_auto_insert_disabled'])) {
253
+ update_post_meta($this->post_id, 'yasr_auto_insert_disabled', 'yes');
254
+ } else {
255
+ delete_post_meta($this->post_id, 'yasr_auto_insert_disabled');
256
+ }
257
+
258
+ }
259
+
260
+ }
261
+
262
+ add_action('save_post', 'yasr_on_save_post_callback');
263
+
264
+ function yasr_on_save_post_callback ($post_id) {
265
+ new YasrOnSavePost($post_id);
266
+ return;
267
+ }
lib/admin/editor/yasr-editor-functions.php CHANGED
@@ -127,21 +127,18 @@ function yasr_add_metaboxes() {
127
  );
128
  }
129
 
130
- $multi_set = YasrMultiSetData::returnMultiSetNames();
131
- //If multiset are used then add the second metabox
132
- if ($multi_set) {
133
- foreach ($post_type_where_display_metabox as $post_type) {
134
- add_meta_box(
135
- 'yasr_metabox_multiple_rating',
136
- __('Yet Another Stars Rating: Multiple set', 'yet-another-stars-rating'),
137
- 'yasr_metabox_multiple_rating_content',
138
- $post_type,
139
- 'normal',
140
- 'high'
141
- );
142
- }
143
  }
144
 
 
145
  } //End function
146
 
147
  function yasr_metabox_overall_rating_content() {
@@ -154,10 +151,10 @@ function yasr_metabox_overall_rating_content() {
154
 
155
  }
156
 
157
- function yasr_metabox_multiple_rating_content() {
158
 
159
  if (current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
160
- include(YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-metabox-multiple-rating.php');
161
  } else {
162
  _e("You don't have enough privileges to insert a Multi Set");
163
  }
127
  );
128
  }
129
 
130
+ foreach ($post_type_where_display_metabox as $post_type) {
131
+ add_meta_box(
132
+ 'yasr_metabox_below_editor_metabox',
133
+ __('Yet Another Stars Rating: Multiple set', 'yet-another-stars-rating'),
134
+ 'yasr_metabox_below_editor_metabox_callback',
135
+ $post_type,
136
+ 'normal',
137
+ 'high'
138
+ );
 
 
 
 
139
  }
140
 
141
+
142
  } //End function
143
 
144
  function yasr_metabox_overall_rating_content() {
151
 
152
  }
153
 
154
+ function yasr_metabox_below_editor_metabox_callback() {
155
 
156
  if (current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
157
+ include(YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-metabox-below-editor.php');
158
  } else {
159
  _e("You don't have enough privileges to insert a Multi Set");
160
  }
lib/admin/editor/yasr-metabox-below-editor.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>
19
+ */
20
+
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
+
25
+ $multi_set = YasrMultiSetData::returnMultiSetNames();
26
+
27
+ ?>
28
+
29
+ <div>
30
+ <div style="display: table">
31
+ <a href="#" id="yasr-metabox-below-editor-structured-data-tab"
32
+ class="nav-tab nav-tab-active yasr-nav-tab"><?php _e("Structured Data", 'yet-another-stars-rating'); ?></a>
33
+ <?php if ($multi_set) {
34
+ ?>
35
+ <a href="#" id="yasr-metabox-below-editor-multiset-tab"
36
+ class="nav-tab yasr-nav-tab"><?php _e("Multi Sets", 'yet-another-stars-rating'); ?></a>
37
+ <?php
38
+ }
39
+ ?>
40
+
41
+ </div>
42
+
43
+ <div id="yasr-metabox-below-editor-structured-data" class="yasr-metabox-below-editor-content">
44
+ <?php include(YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-metabox-schema.php'); ?>
45
+ </div>
46
+
47
+ <?php
48
+
49
+ //If multiset are used then add the second metabox
50
+ if ($multi_set) {
51
+ ?>
52
+ <div id="yasr-metabox-below-editor-multiset" class="yasr-metabox-below-editor-content" style="display:none">
53
+ <?php include(YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-metabox-multiple-rating.php'); ?>
54
+ </div>
55
+ <?php
56
+ }
57
+ ?>
58
+
59
+ </div>
lib/admin/editor/yasr-metabox-multiple-rating.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
 
3
  /*
4
 
@@ -21,34 +21,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
21
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
22
 
23
  $multi_set = YasrMultiSetData::returnMultiSetNames();
24
-
25
  $post_id = get_the_ID();
26
-
27
  $yasr_nonce_multi = wp_nonce_field( "yasr_nonce_save_multi_values_action", "yasr_nonce_save_multi_values");
28
 
29
- $set_id=NULL;
30
 
31
  global $wpdb;
32
 
33
  $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count number of rows of the last query
34
 
35
  if ($n_multi_set > 1) {
36
-
37
- _e("Choose wich set you want to use", 'yet-another-stars-rating');
38
-
39
  ?>
 
 
 
 
 
 
 
 
40
 
41
- <br />
42
- <select id="select_set">
43
- <?php foreach ($multi_set as $name) { ?>
44
- <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
45
- <?php } //End foreach ?>
46
- </select>
47
-
48
- <button href="#" class="button-delete" id="yasr-button-select-set"><?php _e("Select"); ?></button>
49
 
50
- <span id="yasr-loader-select-multi-set" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
51
- </span>
 
52
 
53
  <?php
54
 
@@ -56,8 +53,8 @@ if ($n_multi_set > 1) {
56
 
57
  elseif ($n_multi_set === 1) {
58
 
59
- //If multiset is only 1, array index will be always 0
60
- //get the set_id
61
  $set_id = $multi_set[0]->set_id;
62
  $set_id = (int)$set_id;
63
 
@@ -113,7 +110,7 @@ elseif ($n_multi_set === 1) {
113
  document.addEventListener('DOMContentLoaded', function(event) {
114
 
115
  var nMultiSet = <?php echo (json_encode("$n_multi_set")); ?>;
116
- var postid = <?php echo (the_ID()); ?>;
117
  var setId = <?php echo( json_encode( "$set_id" ) ); ?>;
118
 
119
  yasrAdminMultiSet(nMultiSet, postid, setId);
1
+ <?php
2
 
3
  /*
4
 
21
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
22
 
23
  $multi_set = YasrMultiSetData::returnMultiSetNames();
 
24
  $post_id = get_the_ID();
 
25
  $yasr_nonce_multi = wp_nonce_field( "yasr_nonce_save_multi_values_action", "yasr_nonce_save_multi_values");
26
 
27
+ $set_id = NULL;
28
 
29
  global $wpdb;
30
 
31
  $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count number of rows of the last query
32
 
33
  if ($n_multi_set > 1) {
 
 
 
34
  ?>
35
+ <div>
36
+ <?php _e("Choose wich set you want to use", 'yet-another-stars-rating'); ?>
37
+ <br />
38
+ <select id="select_set">
39
+ <?php foreach ($multi_set as $name) { ?>
40
+ <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
41
+ <?php } //End foreach ?>
42
+ </select>
43
 
44
+ <button href="#" class="button-delete" id="yasr-button-select-set"><?php _e("Select"); ?></button>
 
 
 
 
 
 
 
45
 
46
+ <span id="yasr-loader-select-multi-set" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
47
+ </span>
48
+ </div>
49
 
50
  <?php
51
 
53
 
54
  elseif ($n_multi_set === 1) {
55
 
56
+ //If multiset is only 1, array index will be always 0
57
+ ////get the set_id
58
  $set_id = $multi_set[0]->set_id;
59
  $set_id = (int)$set_id;
60
 
110
  document.addEventListener('DOMContentLoaded', function(event) {
111
 
112
  var nMultiSet = <?php echo (json_encode("$n_multi_set")); ?>;
113
+ var postid = <?php echo ($post_id); ?>;
114
  var setId = <?php echo( json_encode( "$set_id" ) ); ?>;
115
 
116
  yasrAdminMultiSet(nMultiSet, postid, setId);
lib/admin/editor/yasr-metabox-schema.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>
19
+ */
20
+
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
+
25
+ global $post;
26
+
27
+ //is post review
28
+ $yasr_nonce_is_post_review = wp_nonce_field("yasr_nonce_is_post_review_action", "yasr_nonce_is_post_review");
29
+
30
+ //itemType select
31
+ $yasr_nonce_review_type = wp_nonce_field("yasr_nonce_review_type_action", "yasr_nonce_review_type");
32
+
33
+ //get all additional post meta
34
+ $saved_data = get_post_meta($post->ID, 'yasr_schema_additional_fields', true);
35
+
36
+ //if empty, create a new array
37
+ if(empty($saved_data)) {
38
+ $saved_data = array();
39
+ }
40
+
41
+ $array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS);
42
+
43
+ //foreach every supported element, create a nonce field
44
+ //and set single element to false if not present in db to avoid undefined
45
+ foreach ($array_item_type_info as $item_type) {
46
+ $nonce_action = $item_type . '_nonce_action';
47
+ $nonce_name = $item_type . '_nonce_name';
48
+ wp_nonce_field($nonce_action, $nonce_name);
49
+
50
+ //avoid undefined
51
+ if(!isset($saved_data[$item_type])) {
52
+ $saved_data[$item_type] = false;
53
+ }
54
+
55
+ }
56
+
57
+ ?>
58
+
59
+ <div>
60
+
61
+ <div id="yasr-schema-metabox-post-is-review">
62
+ <div class="rich-snippet-title">
63
+ <?php _e('Rich snippet options', 'yet-another-stars-rating'); ?>
64
+ </div>
65
+ <?php _e('Is this a review?', 'yet-another-stars-rating'); ?>
66
+ <br />
67
+ <div class="yasr-onoffswitch-big" id="yasr-switcher-post-is-review">
68
+ <input type="checkbox" name="yasr_is_post_review" class="yasr-onoffswitch-checkbox" value="yes"
69
+ id="yasr-post-is-review-switch" <?php if ($post->yasr_post_is_review === 'yes') echo " checked='checked' "; ?> >
70
+ <label class="yasr-onoffswitch-label" for="yasr-post-is-review-switch">
71
+ <span class="yasr-onoffswitch-inner"></span>
72
+ <span class="yasr-onoffswitch-switch"></span>
73
+ </label>
74
+ </div>
75
+ </div>
76
+
77
+ <p>
78
+ <div class="yasr-choose-reviews-types">
79
+ <?php _e("Select ItemType", "yet-another-stars-rating"); ?>
80
+ <br />
81
+ <?php yasr_select_itemtype('yasr-metabox-below-editor-select-schema'); ?>
82
+ </div>
83
+
84
+ <div class="yasr-metabox-info-snippet-container" id="yasr-metabox-info-snippet-container" style="display: none;">
85
+ <!--product-->
86
+ <div id="yasr-metabox-info-snippet-container-product"
87
+ class="yasr-metabox-info-snippet-container-child" style="display: none">
88
+
89
+ <div class="yasr-itemtype-row-container-label-input">
90
+ <label for="yasr-product-brand">Brand</label>
91
+ <input type="text" name="yasr_product_brand" id="yasr-product-brand"
92
+ value="<?php echo $saved_data['yasr_product_brand'] ?>"
93
+ >
94
+ </div>
95
+ <div class="yasr-itemtype-row-container-description">
96
+ <?php _e('The brand of the product.', 'yet-another-stars-rating');?>
97
+ </div>
98
+
99
+ <div class="yasr-itemtype-row-container-label-input">
100
+ <label for="yasr-product-sku">Sku</label>
101
+ <input type="text" name="yasr_product_sku" id="yasr-product-sku"
102
+ value="<?php echo $saved_data['yasr_product_sku'] ?>"
103
+ >
104
+ </div>
105
+ <div class="yasr-itemtype-row-container-description">
106
+ <?php _e('Merchant-specific identifier for product.' , 'yet-another-stars-rating'); ?>
107
+ </div>
108
+
109
+ <div class="yasr-itemtype-row-container-label-input">
110
+ <label for="yasr-product-global-identifier-select">Global identifiers</label>
111
+ <select name="yasr_product_global_identifier_select" id="yasr-product-global-identifier-select">
112
+ <?php
113
+ $array_global_identifiers = array ('gtin8', 'gtin13', 'gtin14', 'mpn', 'isbn');
114
+ foreach ($array_global_identifiers as $identifier) {
115
+ if ($saved_data['yasr_product_global_identifier_select'] === $identifier) {
116
+ echo "<option value=$identifier selected>$identifier</option>";
117
+ } else {
118
+ echo "<option value=$identifier>$identifier</option>";
119
+ }
120
+ }
121
+ ?>
122
+ </select>
123
+ <label for="yasr-product-global-identifier-value" style="width: auto; margin-left: 10px;">Value</label>
124
+ <input type="text" name="yasr_product_global_identifier_value" id="yasr-product-global-identifier-value"
125
+ value="<?php echo $saved_data['yasr_product_global_identifier_value'] ?>"
126
+ >
127
+ </div>
128
+
129
+ <div class="yasr-itemtype-row-container-description">
130
+ <?php
131
+ echo sprintf(
132
+ __('Select global identifier. More info %s here %s', 'yet-another-stars-rating'),
133
+ '<a href="https://schema.org/Product" target="_blank">','</a>'
134
+ );
135
+ ?>
136
+ </div>
137
+
138
+ <div style="border: 1px dotted #cacaca; width: max-content; margin: 10px; padding: 5px;">
139
+ <div class="yasr-itemtype-row-container-label-input">
140
+ <label for="yasr-product-price">Price</label>
141
+ <input type="text" name="yasr_product_price" id="yasr-product-price"
142
+ value="<?php echo $saved_data['yasr_product_price'] ?>"
143
+ >
144
+ </div>
145
+ <div class="yasr-itemtype-row-container-label-input">
146
+ <label for="yasr-product-price-currency">Currency</label>
147
+ <input type="text" name="yasr_product_price_currency" id="yasr-product-price-currency"
148
+ value="<?php echo $saved_data['yasr_product_price_currency'] ?>"
149
+ >
150
+ </div>
151
+ <div class="yasr-itemtype-row-container-label-input">
152
+ <label for="yasr-product-price-valid-until">Price Valid Until</label>
153
+ <input type="text" name="yasr_product_price_valid_until" id="yasr-product-price-valid-until"
154
+ value="<?php echo $saved_data['yasr_product_price_valid_until'] ?>"
155
+ >
156
+ </div>
157
+ <div class="yasr-itemtype-row-container-label-input">
158
+ <label for="yasr-product-price-availability">Availability</label>
159
+ <select name="yasr_product_price_availability" id="yasr-product-price-availability">
160
+ <?php
161
+ $array_global_availability = array (
162
+ 'Discontinued', 'InStock', 'InStoreOnly', 'LimitedAvailability',
163
+ 'OnlineOnly', 'OutOfStock', 'PreOrder'. 'PreSale', 'SoldOut');
164
+ foreach ($array_global_availability as $availability) {
165
+ if ($saved_data['yasr_product_price_availability'] === $availability) {
166
+ echo "<option value=$availability selected>$availability</option>";
167
+ } else {
168
+ echo "<option value=$availability>$availability</option>";
169
+ }
170
+ }
171
+ ?>
172
+ </select>
173
+ </div>
174
+ <div class="yasr-itemtype-row-container-label-input">
175
+ <label for="yasr-product-price-url">Url</label>
176
+ <input type="text" name="yasr_product_price_url" id="yasr-product-price-url"
177
+ value="<?php echo $saved_data['yasr_product_price_url'] ?>"
178
+ >
179
+ </div>
180
+
181
+ <div class="yasr-itemtype-row-container-description">
182
+ <?php
183
+ echo sprintf(
184
+ __('More info %s here %s', 'yet-another-stars-rating'),
185
+ '<a href="https://schema.org/Offer" target="_blank">','</a>'
186
+ );
187
+ ?>
188
+ </div>
189
+
190
+ </div>
191
+ </div>
192
+ <!--End product-->
193
+
194
+ <!-- LocalBuisness -->
195
+ <div id="yasr-metabox-info-snippet-container-localbusiness"
196
+ class="yasr-metabox-info-snippet-container-child" style="display: none">
197
+
198
+ <div class="yasr-itemtype-row-container-label-input">
199
+ <label for="yasr-localbusiness-address">Address</label>
200
+ <input type="text" name="yasr_localbusiness_address" id="yasr-localbusiness-address"
201
+ value="<?php echo $saved_data['yasr_localbusiness_address'] ?>"
202
+ >
203
+ </div>
204
+ <div class="yasr-itemtype-row-container-description">
205
+ <?php _e('The physical location of the business.', 'yet-another-stars-rating');?>
206
+ </div>
207
+
208
+ <div class="yasr-itemtype-row-container-label-input">
209
+ <label for="yasr-localbusiness-pricerange">PriceRange</label>
210
+ <input type="text" name="yasr_localbusiness_pricerange" id="yasr-localbusiness-pricerange"
211
+ value="<?php echo $saved_data['yasr_localbusiness_pricerange'] ?>"
212
+ >
213
+ </div>
214
+ <div class="yasr-itemtype-row-container-description">
215
+ <?php _e('The relative price range of a business, commonly specified by either a numerical range
216
+ (for example, "$10-15") or a normalized number of currency signs (for example, "$$$")',
217
+ 'yet-another-stars-rating');?>
218
+ </div>
219
+
220
+ <div class="yasr-itemtype-row-container-label-input">
221
+ <label for="yasr-localbusiness-telephone">Telephone</label>
222
+ <input type="text" name="yasr_localbusiness_telephone" id="yasr-localbusiness-telephone"
223
+ value="<?php echo $saved_data['yasr_localbusiness_telephone'] ?>"
224
+ >
225
+ </div>
226
+ <div class="yasr-itemtype-row-container-description">
227
+ <?php _e('A business phone number meant to be the primary contact method for customers.',
228
+ 'yet-another-stars-rating');?>
229
+ </div>
230
+ </div>
231
+ <!-- End LocalBuisness -->
232
+
233
+ <!-- Recipe -->
234
+ <div id="yasr-metabox-info-snippet-container-recipe"
235
+ class="yasr-metabox-info-snippet-container-child" style="display: none">
236
+
237
+ <div class="yasr-itemtype-row-container-label-input">
238
+ <label for="yasr-recipe-cooktime">cookTime</label>
239
+ <input type="text" name="yasr_recipe_cooktime" id="yasr-recipe-cooktime"
240
+ value="<?php echo $saved_data['yasr_recipe_cooktime'] ?>"
241
+ >
242
+ </div>
243
+ <div class="yasr-itemtype-row-container-description">
244
+ <?php _e('The time it takes to actually cook the dish in ISO 8601 format. ', 'yet-another-stars-rating');?>
245
+ </div>
246
+
247
+ <div class="yasr-itemtype-row-container-label-input">
248
+ <label for="yasr-recipe-preptime">prepTime</label>
249
+ <input type="text" name="yasr_recipe_preptime" id="yasr-recipe-preptime"
250
+ value="<?php echo $saved_data['yasr_recipe_preptime'] ?>"
251
+ >
252
+ </div>
253
+ <div class="yasr-itemtype-row-container-description">
254
+ <?php _e('The length of time it takes to prepare the dish, in ISO 8601 format.',
255
+ 'yet-another-stars-rating');?>
256
+ </div>
257
+
258
+ <div class="yasr-itemtype-row-container-label-input">
259
+ <label for="yasr-recipe-description">description</label>
260
+ <input type="text" name="yasr_recipe_description" id="yasr-recipe-description"
261
+ value="<?php echo $saved_data['yasr_recipe_description'] ?>"
262
+ >
263
+ </div>
264
+ <div class="yasr-itemtype-row-container-description">
265
+ <?php _e('A short summary describing the dish.','yet-another-stars-rating');?>
266
+ </div>
267
+
268
+ <div class="yasr-itemtype-row-container-label-input">
269
+ <label for="yasr-recipe-keywords">keywords</label>
270
+ <input type="text" name="yasr_recipe_keywords" id="yasr-recipe-keywords"
271
+ value="<?php echo $saved_data['yasr_recipe_keywords'] ?>"
272
+ >
273
+ </div>
274
+ <div class="yasr-itemtype-row-container-description">
275
+ <?php _e('Other terms for your recipe',
276
+ 'yet-another-stars-rating');?>
277
+ </div>
278
+
279
+ <div class="yasr-itemtype-row-container-label-input">
280
+ <label for="yasr-recipe-nutrition">nutrition</label>
281
+ <input type="text" name="yasr_recipe_nutrition" id="yasr-recipe-nutrition"
282
+ value="<?php echo $saved_data['yasr_recipe_nutrition'] ?>"
283
+ >
284
+ </div>
285
+ <div class="yasr-itemtype-row-container-description">
286
+ <?php _e('The number of calories',
287
+ 'yet-another-stars-rating');?>
288
+ </div>
289
+
290
+ <div class="yasr-itemtype-row-container-label-input">
291
+ <label for="yasr-recipe-category">recipeCategory</label>
292
+ <input type="text" name="yasr_recipe_recipecategory" id="yasr-recipe-category"
293
+ value="<?php echo $saved_data['yasr_recipe_recipecategory'] ?>"
294
+ >
295
+ </div>
296
+ <div class="yasr-itemtype-row-container-description">
297
+ <?php _e('The type of meal or course your recipe is about',
298
+ 'yet-another-stars-rating');?>
299
+ </div>
300
+
301
+ <div class="yasr-itemtype-row-container-label-input">
302
+ <label for="yasr-recipe-cuisine">recipeCuisine</label>
303
+ <input type="text" name="yasr_recipe_recipecuisine" id="yasr-recipe-cuisine"
304
+ value="<?php echo $saved_data['yasr_recipe_recipecuisine'] ?>"
305
+ >
306
+ </div>
307
+ <div class="yasr-itemtype-row-container-description">
308
+ <?php _e('The region associated with your recipe. For example, "Mediterranean", or "American".',
309
+ 'yet-another-stars-rating');?>
310
+ </div>
311
+
312
+ <div class="yasr-itemtype-row-container-label-input">
313
+ <label for="yasr-recipe-ingredient" style="vertical-align: top">recipeIngredient</label>
314
+ <textarea name="yasr_recipe_recipeingredient" rows="4"
315
+ id="yasr-recipe-ingredient"><?php echo $saved_data['yasr_recipe_recipeingredient'] ?></textarea>
316
+ </div>
317
+ <div class="yasr-itemtype-row-container-description">
318
+ <?php
319
+ echo sprintf(
320
+ __('A single ingredient used in the recipe, e.g. sugar, flour or garlic. %s
321
+ Use return %s to separate the ingredients.',
322
+ 'yet-another-stars-rating'),
323
+ '<br />',
324
+ '<strong>(&#8629;)</strong>'
325
+ );
326
+
327
+ ?>
328
+ </div>
329
+
330
+ <div class="yasr-itemtype-row-container-label-input">
331
+ <label for="yasr-recipe-instructions" style="vertical-align: top">recipeInstructions</label>
332
+ <textarea name="yasr_recipe_recipeinstructions" rows="4"
333
+ id="yasr-recipe-instructions"><?php echo $saved_data['yasr_recipe_recipeinstructions'] ?></textarea>
334
+ </div>
335
+ <div class="yasr-itemtype-row-container-description">
336
+ <?php
337
+ echo sprintf(
338
+ __('The steps to make dish. Use return %s to separate the steps.',
339
+ 'yet-another-stars-rating'),
340
+ '<strong>(&#8629;)</strong>'
341
+ );
342
+ ?>
343
+ </div>
344
+
345
+ <div class="yasr-itemtype-row-container-label-input">
346
+ <label for="yasr-recipe-video">Video</label>
347
+ <input type="text" name="yasr_recipe_video" id="yasr-recipe-video"
348
+ value="<?php echo $saved_data['yasr_recipe_video'] ?>"
349
+ >
350
+ </div>
351
+ <div class="yasr-itemtype-row-container-description">
352
+ <?php _e('A video depicting the steps to make the dish (URL)',
353
+ 'yet-another-stars-rating');?>
354
+ </div>
355
+
356
+ <div class="yasr-itemtype-row-container-description">
357
+ <?php
358
+ echo sprintf(
359
+ __('More info %s here %s and %s here %s', 'yet-another-stars-rating'),
360
+ '<a href="https://developers.google.com/search/docs/data-types/recipe" target="_blank">','</a>',
361
+ '<a href="https://schema.org/Recipe" target="_blank">','</a>'
362
+ );
363
+ ?>
364
+ </div>
365
+
366
+ </div>
367
+ <!-- End Recipe -->
368
+
369
+ </div>
370
+
371
+ <p>
372
+
373
+ </div>
lib/admin/editor/yasr-metabox-top-right.php CHANGED
@@ -18,17 +18,21 @@ You should have received a copy of the GNU General Public License
18
  along with this program. If not, see <http://www.gnu.org/licenses/>
19
  */
20
 
21
- if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
 
 
22
 
23
- global $post;
24
 
25
- $post_id=get_the_ID();
26
- $overall_rating = $post->yasr_overall_rating;
27
 
28
- $yasr_nonce_overall = wp_nonce_field( "yasr_nonce_overall_rating_action", "yasr_nonce_overall_rating");
29
- $yasr_nonce_auto_insert = wp_nonce_field( "yasr_nonce_auto_insert_action", "yasr_nonce_auto_insert" );
30
- $yasr_nonce_review_type = wp_nonce_field( "yasr_nonce_review_type_action", "yasr_nonce_review_type" );
31
- $yasr_nonce_review_type = wp_nonce_field( "yasr_nonce_is_post_review_action", "yasr_nonce_is_post_review" );
 
 
 
32
 
33
 
34
  ?>
@@ -77,9 +81,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
77
 
78
  <div id="yasr-toprightmetabox-disable-auto-insert">
79
  <?php _e('Disable auto insert for this post or page?', 'yet-another-stars-rating'); ?>
80
-
81
  <br />
82
-
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' "; ?> >
@@ -96,54 +98,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
96
 
97
  } //End if auto insert enabled
98
 
99
- $post_a_review = get_post_meta($post_id, 'yasr_post_is_review', true);
100
-
101
  ?>
102
-
103
- <div id="yasr-toprightmetabox-post-is-review">
104
- <div class="rich-snippet-title">
105
- <?php _e('Rich snippet options', 'yet-another-stars-rating'); ?>
106
- </div>
107
-
108
- <?php _e('Is this a review?', 'yet-another-stars-rating'); ?>
109
-
110
- <br />
111
-
112
- <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-post-is-review">
113
- <input type="checkbox" name="yasr_is_post_review" class="yasr-onoffswitch-checkbox" value="yes"
114
- id="yasr-post-is-review-switch" <?php if ($post_a_review === 'yes') echo " checked='checked' "; ?> >
115
- <label class="yasr-onoffswitch-label" for="yasr-post-is-review-switch">
116
- <span class="yasr-onoffswitch-inner"></span>
117
- <span class="yasr-onoffswitch-switch"></span>
118
- </label>
119
- </div>
120
- </div>
121
-
122
  <p>
123
-
124
- <div class="yasr-choose-reviews-types">
125
- <?php _e("Select ItemType", "yet-another-stars-rating"); ?>
126
- <br />
127
-
128
- <?php yasr_select_itemtype(); ?>
129
- </div>
130
-
131
- <p>
132
-
133
  <?php
134
  do_action( 'yasr_add_content_bottom_topright_metabox', $post_id );
135
  ?>
136
 
137
- </div>
138
-
139
- <script type="text/javascript">
140
-
141
- jQuery(document).ready(function() {
142
-
143
- var overallRating = <?php echo (json_encode($overall_rating)); ?>;
144
-
145
- yasrPrintMetaBoxOverall (overallRating);
146
-
147
- }); //End document ready
148
-
149
- </script>
18
  along with this program. If not, see <http://www.gnu.org/licenses/>
19
  */
20
 
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
 
25
+ global $post;
26
 
27
+ $post_id=get_the_ID();
 
28
 
29
+ //equivalent to get_post_meta
30
+ $overall_rating = $post->yasr_overall_rating;
31
+
32
+ $yasr_nonce_overall = wp_nonce_field( "yasr_nonce_overall_rating_action", "yasr_nonce_overall_rating");
33
+ $yasr_nonce_auto_insert = wp_nonce_field( "yasr_nonce_auto_insert_action", "yasr_nonce_auto_insert" );
34
+ $yasr_nonce_review_type = wp_nonce_field( "yasr_nonce_review_type_action", "yasr_nonce_review_type" );
35
+ $yasr_nonce_review_type = wp_nonce_field( "yasr_nonce_is_post_review_action", "yasr_nonce_is_post_review" );
36
 
37
 
38
  ?>
81
 
82
  <div id="yasr-toprightmetabox-disable-auto-insert">
83
  <?php _e('Disable auto insert for this post or page?', 'yet-another-stars-rating'); ?>
 
84
  <br />
 
85
  <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
86
  <input type="checkbox" name="yasr_auto_insert_disabled" class="yasr-onoffswitch-checkbox" value="yes"
87
  id="yasr-auto-insert-disabled-switch" <?php if ($is_this_post_exluded === 'yes') echo " checked='checked' "; ?> >
98
 
99
  } //End if auto insert enabled
100
 
 
 
101
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  <p>
 
 
 
 
 
 
 
 
 
 
103
  <?php
104
  do_action( 'yasr_add_content_bottom_topright_metabox', $post_id );
105
  ?>
106
 
107
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
lib/rest/YasrCustomFields.php CHANGED
@@ -26,6 +26,7 @@ class YasrCustomFields extends WP_REST_Controller {
26
  */
27
  $this->visitorVotes();
28
  $this->allItemTypes();
 
29
  }
30
 
31
  /**
@@ -83,4 +84,27 @@ class YasrCustomFields extends WP_REST_Controller {
83
  )
84
  );
85
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
26
  */
27
  $this->visitorVotes();
28
  $this->allItemTypes();
29
+ $this->itemTypesAdditionalFields();
30
  }
31
 
32
  /**
84
  )
85
  );
86
  }
87
+
88
+ /**
89
+ * Helper function to return supported itemtype additional info
90
+ */
91
+ private function itemTypesAdditionalFields() {
92
+ $post_types = yasr_return_all_post_types();
93
+ $yasr__additional_itemtype_schema = array(
94
+ 'description' => 'Yasr Item Types Additional Info',
95
+ 'type' => 'object',
96
+ 'context' => array('edit'),
97
+ );
98
+
99
+ //Register Visitor Votes
100
+ register_rest_field(
101
+ $post_types,
102
+ 'yasr_all_itemtypes',
103
+ array(
104
+ 'get_callback' => function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS); },
105
+ 'update_callback' => null,
106
+ 'schema' => $yasr__additional_itemtype_schema
107
+ )
108
+ );
109
+ }
110
  }
lib/yasr-db-classes.php CHANGED
@@ -35,10 +35,6 @@ class YasrDatabaseRatings {
35
  if (!is_int($post_id)) {
36
  $post_id = get_the_ID();
37
  }
38
- if (!is_int($post_id)) {
39
- return null;
40
- }
41
- $post_id = (int)$post_id;
42
 
43
  $overall_rating = get_post_meta($post_id, 'yasr_overall_rating', true);
44
  if (!$overall_rating) {
@@ -75,9 +71,7 @@ class YasrDatabaseRatings {
75
  $array_to_return['number_of_votes'] = (int)$user_votes->number_of_votes;
76
  $array_to_return['sum_votes'] = (int)$user_votes->sum_votes;
77
  }
78
-
79
  return $array_to_return;
80
-
81
  }
82
 
83
  /**
35
  if (!is_int($post_id)) {
36
  $post_id = get_the_ID();
37
  }
 
 
 
 
38
 
39
  $overall_rating = get_post_meta($post_id, 'yasr_overall_rating', true);
40
  if (!$overall_rating) {
71
  $array_to_return['number_of_votes'] = (int)$user_votes->number_of_votes;
72
  $array_to_return['sum_votes'] = (int)$user_votes->sum_votes;
73
  }
 
74
  return $array_to_return;
 
75
  }
76
 
77
  /**
lib/yasr-db-functions.php CHANGED
@@ -190,7 +190,7 @@ function yasr_on_delete_blog($tables) {
190
 
191
 
192
  /****** Return the snippet choosen for a post or page ******/
193
- function yasr_get_snippet_type() {
194
 
195
  $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
196
 
@@ -338,229 +338,4 @@ function yasr_erase_data_on_post_page_remove_callback($post_id) {
338
  );
339
 
340
 
341
- }
342
-
343
-
344
- /****** Function to get always the last id in the log table ******/
345
-
346
- function yasr_count_logged_vote() {
347
-
348
- global $wpdb;
349
-
350
- $result = $wpdb->get_var("SELECT COUNT(id) FROM " . YASR_LOG_TABLE);
351
-
352
- if ($result) {
353
- return $result;
354
- } else {
355
- return '0';
356
- }
357
-
358
- }
359
-
360
-
361
- /********** Save Post actions **********/
362
-
363
- add_action('save_post', 'yasr_insert_overall_rating_callback');
364
-
365
- function yasr_insert_overall_rating_callback($post_id) {
366
-
367
- //this mean there we're not in the classic editor
368
- if (!isset($_POST['yasr_nonce_overall_rating'])) {
369
- return;
370
- }
371
-
372
- $update_result = null;
373
-
374
- if (isset($_POST['yasr_overall_rating'])) {
375
- $rating = $_POST['yasr_overall_rating'];
376
- $nonce = $_POST['yasr_nonce_overall_rating'];
377
- } else {
378
- return;
379
- }
380
-
381
- if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
382
- return;
383
- }
384
-
385
- if (!wp_verify_nonce($nonce, 'yasr_nonce_overall_rating_action')) {
386
- return;
387
- }
388
-
389
- $rating = (float) $rating;
390
-
391
- if ($rating > 5) {
392
- $rating = 5;
393
- }
394
-
395
- //Put an action to hook into
396
- do_action('yasr_action_on_overall_rating', $post_id, $rating);
397
-
398
- $update_result = update_post_meta($post_id, 'yasr_overall_rating', $rating);
399
-
400
- //if update_post_meta returns an integer means this is a new post
401
- //so we're going to insert the default YASR_ITEMTYPE
402
- if (is_int($update_result)) {
403
- add_post_meta($post_id, 'yasr_review_type', YASR_ITEMTYPE);
404
- }
405
-
406
- }
407
-
408
- add_action('save_post', 'yasr_insert_review_type_callback');
409
-
410
- function yasr_insert_review_type_callback($post_id) {
411
- //if user can not publish posts
412
- if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
413
- return;
414
- }
415
-
416
- //this mean there we're not in the classic editor
417
- if(!isset($_POST['yasr_nonce_review_type'])) {
418
- return;
419
- } else {
420
- $nonce = $_POST['yasr_nonce_review_type'];
421
- }
422
-
423
- //check nonce
424
- if (!wp_verify_nonce($nonce, 'yasr_nonce_review_type_action')) {
425
- return;
426
- }
427
-
428
- $post_id = (int)$post_id;
429
-
430
- //check if $_POST isset
431
- if (isset($_POST['yasr-review-type'])) {
432
- $snippet_type = $_POST['yasr-review-type'];
433
-
434
- //check if $snippet_type is a supported itemType
435
- if (yasr_is_supported_schema($snippet_type)===true) {
436
- //if the selected item type, is the same of the default one, delete the saved postmeta
437
- if ($snippet_type === YASR_ITEMTYPE) {
438
- delete_post_meta($post_id, 'yasr_review_type');
439
- } else {
440
- update_post_meta($post_id, 'yasr_review_type', $snippet_type);
441
- }
442
- } else {
443
- return;
444
- }
445
- } else {
446
- return;
447
- }
448
-
449
- }
450
-
451
- add_action('save_post', 'yasr_post_a_review');
452
-
453
- function yasr_post_a_review($post_id) {
454
-
455
- //this mean there we're not in the classic editor
456
- if(!isset($_POST['yasr_nonce_is_post_review'])) {
457
- return;
458
- } else {
459
- $nonce = $_POST['yasr_nonce_is_post_review'];
460
- }
461
-
462
- if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
463
- return;
464
- }
465
-
466
- if (!wp_verify_nonce($nonce, 'yasr_nonce_is_post_review_action')) {
467
- return;
468
- }
469
-
470
- if (isset($_POST['yasr_is_post_review'])) {
471
- update_post_meta($post_id, 'yasr_post_is_review', 'yes');
472
- }
473
- else {
474
- delete_post_meta($post_id, 'yasr_post_is_review');
475
- }
476
- }
477
-
478
-
479
- /****** Get multiple value and insert into database, used in yasr-metabox-multiple-rating ******/
480
-
481
- add_action('save_post', 'yasr_save_multiset_editor');
482
-
483
- function yasr_save_multiset_editor($post_id) {
484
-
485
- if (isset($_POST['yasr_multiset_author_votes']) && isset($_POST['yasr_multiset_id'])) {
486
- $field_and_vote_array = json_decode(sanitize_text_field(stripslashes($_POST['yasr_multiset_author_votes'])));
487
- $set_id = (int) $_POST['yasr_multiset_id'];
488
- $nonce = $_POST['yasr_nonce_save_multi_values'];
489
-
490
- if (!is_int($set_id) || $field_and_vote_array == '') {
491
- return;
492
- }
493
-
494
- } else {
495
- return;
496
- }
497
-
498
- if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
499
- return;
500
- }
501
-
502
- if (!wp_verify_nonce($nonce, 'yasr_nonce_save_multi_values_action')) {
503
- die('Security check');
504
- }
505
-
506
- $i = 0;
507
-
508
- $data_to_save[$i] = array(
509
- 'set_id' => (int)$set_id,
510
- 'fields_and_ratings' => $field_and_vote_array
511
- );
512
-
513
- $i++;
514
-
515
- $set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes',true);
516
-
517
- //If data for this post already exists
518
- if ($set_post_meta_values) {
519
- //first, loop saved fields and ratings
520
- foreach ($set_post_meta_values as $saved_set_id) {
521
- //if the saved set is different from the one that we're trying to save,
522
- //append data to save to the post meta
523
- if ($saved_set_id['set_id'] !== $set_id) {
524
- $data_to_save[$i]['set_id'] = $saved_set_id['set_id'];
525
- $data_to_save[$i]['fields_and_ratings'] = $saved_set_id['fields_and_ratings'];
526
-
527
- $i++;
528
- //Append data to save to the post meta
529
-
530
- } //if the set is not stored
531
- }
532
- }
533
-
534
- // Write new data
535
- update_post_meta($post_id, 'yasr_multiset_author_votes', $data_to_save);
536
-
537
- } //End callback function
538
-
539
- /******* Add post_meta on save_post if this post is excluded for auto insert *******/
540
-
541
- if (YASR_AUTO_INSERT_ENABLED == 1) {
542
-
543
- add_action('save_post', 'yasr_exclude_auto_insert_callback');
544
-
545
- function yasr_exclude_auto_insert_callback($post_id) {
546
-
547
- //this mean there we're not in the classic editor
548
- if (!isset($_POST['yasr_nonce_auto_insert'])) {
549
- return;
550
- } else {
551
- $nonce = $_POST['yasr_nonce_auto_insert'];
552
- }
553
-
554
- if (!wp_verify_nonce($nonce, 'yasr_nonce_auto_insert_action')) {
555
- return;
556
- }
557
-
558
- if (isset($_POST['yasr_auto_insert_disabled'])) {
559
- update_post_meta($post_id, 'yasr_auto_insert_disabled', 'yes');
560
- } else {
561
- delete_post_meta($post_id, 'yasr_auto_insert_disabled');
562
- }
563
-
564
- }
565
-
566
  }
190
 
191
 
192
  /****** Return the snippet choosen for a post or page ******/
193
+ function yasr_get_itemType() {
194
 
195
  $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
196
 
338
  );
339
 
340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  }
lib/yasr-functions.php CHANGED
@@ -89,8 +89,14 @@ function yasr_add_admin_scripts($hook) {
89
 
90
  global $yasr_settings_page;
91
 
92
- if ($hook === 'edit.php' || $hook === 'post.php' || $hook === 'post-new.php') {
93
- wp_enqueue_script('yasr_shortcode_creator', YASR_JS_DIR . 'yasr-shortcode-creator.js', array('jquery'), YASR_VERSION_NUM, true);
 
 
 
 
 
 
94
  }
95
 
96
  if ($hook === 'index.php' || $hook === 'edit.php' || $hook === 'post.php' || $hook === 'post-new.php' ||
@@ -391,14 +397,20 @@ function yasr_add_schema($content) {
391
 
392
  $is_post_a_review = get_post_meta(get_the_ID(), 'yasr_post_is_review', true);
393
 
394
- if (!$overall_rating && !$visitor_votes['number_of_votes'] && !$visitor_votes['sum_votes']) {
395
- return $content;
 
 
 
 
 
 
396
  }
397
 
398
  $script_type = '<script type="application/ld+json">';
399
  $end_script_type = '</script>';
400
 
401
- $review_choosen = yasr_get_snippet_type();
402
 
403
  //if doesn't exists a filter for yasr_filter_schema_jsonld $review_chosen value is assigned to $filtered_schema...
404
  $filtered_schema = apply_filters('yasr_filter_schema_jsonld', $review_choosen);
@@ -506,7 +518,8 @@ function yasr_add_schema($content) {
506
  'reviewRating' => array(
507
  '@type' => 'Rating',
508
  'ratingValue' => $overall_rating,
509
- 'bestRating' => 5
 
510
  ),
511
  );
512
  }
@@ -523,7 +536,8 @@ function yasr_add_schema($content) {
523
  '@type' => 'AggregateRating',
524
  'ratingValue' => $average_rating,
525
  'ratingCount' => $visitor_votes['number_of_votes'],
526
- 'bestRating' => 5
 
527
  );
528
  }
529
  }
@@ -546,40 +560,40 @@ function yasr_add_schema($content) {
546
 
547
  } //End function
548
 
549
- /****** Create a select menu to choose the rich snippet itemtype ******/
 
 
 
 
 
 
550
 
551
- function yasr_select_itemtype() {
 
 
552
 
553
  $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
554
 
555
  sort($review_types);
556
- $review_type_choosen = yasr_get_snippet_type();
557
-
558
  ?>
559
 
560
- <select name="yasr-review-type" id="yasr-choose-reviews-types-list">
561
-
562
  <?php
563
-
564
- foreach ($review_types as $type) {
565
-
566
- $type = trim($type);
567
- $type_option = $type;
568
-
569
- if ($type === $review_type_choosen) {
570
- echo "<option value=\"$type\" selected>$type_option</option>";
571
- } else {
572
- echo "<option value=\"$type\">$type_option</option>";
573
  }
574
-
575
- }
576
-
577
  ?>
578
-
579
  </select>
580
 
581
  <?php
582
-
583
  } //End function yasr_select_itemtype()
584
 
585
 
@@ -739,7 +753,7 @@ function yasr_setcookie($cookiename, $data_to_save) {
739
 
740
  $encoded_data = json_encode($existing_data);
741
 
742
- setcookie($cookiename, $encoded_data, time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, true);
743
 
744
  }
745
 
89
 
90
  global $yasr_settings_page;
91
 
92
+ if ($hook === 'post.php' || $hook === 'post-new.php') {
93
+ wp_enqueue_script(
94
+ 'yasr_classic_editor_functions',
95
+ YASR_JS_DIR . 'yasr-editor-screen.js',
96
+ array('jquery'),
97
+ YASR_VERSION_NUM,
98
+ true
99
+ );
100
  }
101
 
102
  if ($hook === 'index.php' || $hook === 'edit.php' || $hook === 'post.php' || $hook === 'post-new.php' ||
397
 
398
  $is_post_a_review = get_post_meta(get_the_ID(), 'yasr_post_is_review', true);
399
 
400
+ if (!$visitor_votes['number_of_votes'] || !$visitor_votes['sum_votes']) {
401
+ $visitor_votes['number_of_votes'] = 0;
402
+ $visitor_votes['sum_votes'] = 0;
403
+ }
404
+
405
+ //can't be between 0.1 and 1
406
+ if($overall_rating > 0 && $overall_rating < 1) {
407
+ $overall_rating = 1;
408
  }
409
 
410
  $script_type = '<script type="application/ld+json">';
411
  $end_script_type = '</script>';
412
 
413
+ $review_choosen = yasr_get_itemType();
414
 
415
  //if doesn't exists a filter for yasr_filter_schema_jsonld $review_chosen value is assigned to $filtered_schema...
416
  $filtered_schema = apply_filters('yasr_filter_schema_jsonld', $review_choosen);
518
  'reviewRating' => array(
519
  '@type' => 'Rating',
520
  'ratingValue' => $overall_rating,
521
+ 'bestRating' => 5,
522
+ 'worstRating' => 1
523
  ),
524
  );
525
  }
536
  '@type' => 'AggregateRating',
537
  'ratingValue' => $average_rating,
538
  'ratingCount' => $visitor_votes['number_of_votes'],
539
+ 'bestRating' => 5,
540
+ 'worstRating' => 1
541
  );
542
  }
543
  }
560
 
561
  } //End function
562
 
563
+ /**
564
+ * Create a select menu to choose the rich snippet itemtype
565
+ *
566
+ * @param bool|string $html_id
567
+ */
568
+
569
+ function yasr_select_itemtype($html_id=false) {
570
 
571
+ if($html_id === false) {
572
+ $html_id = 'yasr-choose-reviews-types-list';
573
+ }
574
 
575
  $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
576
 
577
  sort($review_types);
578
+ $review_type_choosen = yasr_get_itemType();
 
579
  ?>
580
 
581
+ <label for="<?php echo $html_id ?>"></label>
582
+ <select name="yasr-review-type" id="<?php echo $html_id ?>">
583
  <?php
584
+ foreach ($review_types as $type) {
585
+ $type = trim($type);
586
+ $type_option = $type;
587
+ if ($type === $review_type_choosen) {
588
+ echo "<option value=\"$type\" selected>$type_option</option>";
589
+ } else {
590
+ echo "<option value=\"$type\">$type_option</option>";
591
+ }
 
 
592
  }
 
 
 
593
  ?>
 
594
  </select>
595
 
596
  <?php
 
597
  } //End function yasr_select_itemtype()
598
 
599
 
753
 
754
  $encoded_data = json_encode($existing_data);
755
 
756
+ setcookie($cookiename, $encoded_data, time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false);
757
 
758
  }
759
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
5
  Contributors: Dudo
6
  Tested up to: 5.4
7
  Requires PHP: 5.3
8
- Stable tag: 2.2.5
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
@@ -125,6 +125,34 @@ If doesn't, it's suggested to ask in a SEO oriented forum.
125
 
126
  The full changelog can be found in the plugin's directory. Recent entries:
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  = 2.2.5 =
129
  * FIXED: bug if upgrading from version before than 2.0.9
130
 
@@ -153,17 +181,6 @@ The full changelog can be found in the plugin's directory. Recent entries:
153
  * Enhancement: Added REST responses. More info in the official site
154
 
155
 
156
- = 2.2.1 =
157
- * FIXED: MultiSet returns "undefined" in editor screen
158
- * FIXED: MultiSet average always shows
159
- * FIXED: Users who cannot publish posts can't access the editor screen
160
- * FIXED: Password reset display an error page in some circumstances
161
-
162
- = 2.2.0 =
163
- * TWEAKED: most of code of the main shortcodes has been rewritten; YASR is faster than ever.
164
- * FIXED: gutenberg shortcode preview yasr_top_ten_highest_rated shortcode
165
-
166
-
167
  = Additional Info =
168
  External Libraries: [Rater](https://github.com/fredolss/rater-js)
169
  [tippy](https://atomiks.github.io/tippyjs/)
5
  Contributors: Dudo
6
  Tested up to: 5.4
7
  Requires PHP: 5.3
8
+ Stable tag: 2.2.6
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
125
 
126
  The full changelog can be found in the plugin's directory. Recent entries:
127
 
128
+ = 2.2.6 =
129
+ * TWEAKED: in the editor screen, rich snippet info are moved below the editor
130
+ * NEW FEATURE: Added new fields for these itemTypes:
131
+ #### Recipe:
132
+ * cookTime
133
+ * prepTime
134
+ * description
135
+ * keywords
136
+ * nutrition
137
+ * recipeCategory
138
+ * recipeCuisine
139
+ * recipeIngredient
140
+ #### Product:
141
+ * Brand
142
+ * Sku
143
+ * Global identifiers
144
+ * Price
145
+ * Currency
146
+ * Price Valid Until
147
+ * Availability
148
+ * Url
149
+ #### LocalBuisiness:
150
+ * Address
151
+ * PriceRange
152
+ * Telephone
153
+
154
+ More to come in the next realeses :)
155
+
156
  = 2.2.5 =
157
  * FIXED: bug if upgrading from version before than 2.0.9
158
 
181
  * Enhancement: Added REST responses. More info in the official site
182
 
183
 
 
 
 
 
 
 
 
 
 
 
 
184
  = Additional Info =
185
  External Libraries: [Rater](https://github.com/fredolss/rater-js)
186
  [tippy](https://atomiks.github.io/tippyjs/)
yet-another-stars-rating.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
- * Version: 2.2.5
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
@@ -77,7 +77,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
- define( 'YASR_VERSION_NUM', '2.2.5' );
81
  //Plugin relative path
82
  define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
  //Plugin RELATIVE PATH without slashes (just the directory's name)
@@ -95,9 +95,9 @@ if ( !function_exists( 'yasr_fs' ) ) {
95
  //Get general options
96
  $yasr_stored_options = get_option( 'yasr_general_options' );
97
  global $yasr_stored_options ;
98
- define( "YASR_AUTO_INSERT_ENABLED", $yasr_stored_options['auto_insert_enabled'] );
99
 
100
- if ( YASR_AUTO_INSERT_ENABLED == 1 ) {
101
  define( "YASR_AUTO_INSERT_WHAT", $yasr_stored_options['auto_insert_what'] );
102
  define( "YASR_AUTO_INSERT_WHERE", $yasr_stored_options['auto_insert_where'] );
103
  define( "YASR_AUTO_INSERT_ALIGN", $yasr_stored_options['auto_insert_align'] );
@@ -191,15 +191,17 @@ if ( !function_exists( 'yasr_fs' ) ) {
191
  require YASR_ABSOLUTE_PATH . '/lib/yasr-db-classes.php';
192
  require YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php';
193
  require YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php';
 
 
194
  require YASR_ABSOLUTE_PATH . '/lib/rest/YasrPostMeta.php';
195
  require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomFields.php';
196
  require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomEndpoint.php';
197
  require YASR_ABSOLUTE_PATH . '/lib/rest/yasr-rest.php';
198
- require YASR_ABSOLUTE_PATH . '/lib/yasr-widgets.php';
199
 
200
  if ( is_admin() ) {
201
  require YASR_ABSOLUTE_PATH . '/lib/admin/yasr-admin-classes.php';
202
  require YASR_ABSOLUTE_PATH . '/lib/admin/yasr-admin-actions.php';
 
203
  require YASR_ABSOLUTE_PATH . '/lib/admin/settings/yasr-settings-functions.php';
204
  require YASR_ABSOLUTE_PATH . '/lib/admin/class-wp-list-table.php';
205
  require YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-editor-functions.php';
@@ -234,7 +236,32 @@ if ( !function_exists( 'yasr_fs' ) ) {
234
  'Product',
235
  'Recipe'
236
  ) );
237
- define( "YASR_SUPPORTED_SCHEMA_TYPES", $supported_schema_types );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  //role to save overall_rating and multi set
239
  define( 'YASR_USER_CAPABILITY_EDIT_POST', 'edit_posts' );
240
  $yasr_version_installed = get_option( 'yasr-version' );
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
+ * Version: 2.2.6
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
+ define( 'YASR_VERSION_NUM', '2.2.6' );
81
  //Plugin relative path
82
  define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
  //Plugin RELATIVE PATH without slashes (just the directory's name)
95
  //Get general options
96
  $yasr_stored_options = get_option( 'yasr_general_options' );
97
  global $yasr_stored_options ;
98
+ define( "YASR_AUTO_INSERT_ENABLED", (int) $yasr_stored_options['auto_insert_enabled'] );
99
 
100
+ if ( YASR_AUTO_INSERT_ENABLED === 1 ) {
101
  define( "YASR_AUTO_INSERT_WHAT", $yasr_stored_options['auto_insert_what'] );
102
  define( "YASR_AUTO_INSERT_WHERE", $yasr_stored_options['auto_insert_where'] );
103
  define( "YASR_AUTO_INSERT_ALIGN", $yasr_stored_options['auto_insert_align'] );
191
  require YASR_ABSOLUTE_PATH . '/lib/yasr-db-classes.php';
192
  require YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php';
193
  require YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php';
194
+ require YASR_ABSOLUTE_PATH . '/lib/yasr-widgets.php';
195
+ require YASR_ABSOLUTE_PATH . '/lib/YasrRichSnippetAdditionalFields.php';
196
  require YASR_ABSOLUTE_PATH . '/lib/rest/YasrPostMeta.php';
197
  require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomFields.php';
198
  require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomEndpoint.php';
199
  require YASR_ABSOLUTE_PATH . '/lib/rest/yasr-rest.php';
 
200
 
201
  if ( is_admin() ) {
202
  require YASR_ABSOLUTE_PATH . '/lib/admin/yasr-admin-classes.php';
203
  require YASR_ABSOLUTE_PATH . '/lib/admin/yasr-admin-actions.php';
204
+ require YASR_ABSOLUTE_PATH . '/lib/admin/editor/YasrOnSavePost.php';
205
  require YASR_ABSOLUTE_PATH . '/lib/admin/settings/yasr-settings-functions.php';
206
  require YASR_ABSOLUTE_PATH . '/lib/admin/class-wp-list-table.php';
207
  require YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-editor-functions.php';
236
  'Product',
237
  'Recipe'
238
  ) );
239
+ $array_item_type_info = json_encode( array(
240
+ 'yasr_product_brand',
241
+ 'yasr_product_sku',
242
+ 'yasr_product_global_identifier_select',
243
+ 'yasr_product_global_identifier_value',
244
+ 'yasr_product_price',
245
+ 'yasr_product_price_currency',
246
+ 'yasr_product_price_valid_until',
247
+ 'yasr_product_price_availability',
248
+ 'yasr_product_price_url',
249
+ 'yasr_localbusiness_address',
250
+ 'yasr_localbusiness_pricerange',
251
+ 'yasr_localbusiness_telephone',
252
+ 'yasr_recipe_cooktime',
253
+ 'yasr_recipe_description',
254
+ 'yasr_recipe_keywords',
255
+ 'yasr_recipe_nutrition',
256
+ 'yasr_recipe_preptime',
257
+ 'yasr_recipe_recipecategory',
258
+ 'yasr_recipe_recipecuisine',
259
+ 'yasr_recipe_recipeingredient',
260
+ 'yasr_recipe_recipeinstructions',
261
+ 'yasr_recipe_video'
262
+ ) );
263
+ define( 'YASR_SUPPORTED_SCHEMA_TYPES', $supported_schema_types );
264
+ define( 'YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS', $array_item_type_info );
265
  //role to save overall_rating and multi set
266
  define( 'YASR_USER_CAPABILITY_EDIT_POST', 'edit_posts' );
267
  $yasr_version_installed = get_option( 'yasr-version' );