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 @@