Version Description
- TWEAKED: in front end, dashicons are not required anymore!
- TWEAKED: Vertical align of text and stars on yasr_visitor_votes shortcode. The class yasr-total-average-container has be renamed yasr-vv-stats-text-container.
- TWEAKED: Custom texts support.
- TWEAKED: Updated support for Autoptimize, Litespeed, Cache Enabler and WpRocket.
- TWEAKED: Removed "itemListElement" from Recipe microdata.
- TWEAKED: added samesite attribute when cookie is set.
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 2.7.4 |
Comparing to | |
See all releases |
Code changes from version 2.7.3 to 2.7.4
- admin/classes/YasrOnInstall.php +0 -1
- admin/js/src/yasr-settings-page.js +6 -17
- admin/js/yasr-settings.js +1 -1
- admin/settings/classes/YasrSettings.php +25 -29
- admin/yasr-update-functions.php +12 -1
- includes/classes/YasrCustomPostTypes.php +0 -1
- includes/classes/YasrIncludesFilters.php +83 -4
- includes/css/yasr.css +6 -14
- includes/img/chart-bar.svg +6 -0
- includes/js/src/yasr-front.js +17 -11
- includes/js/yasr-front.js +1 -1
- includes/shortcodes/classes/YasrOverallRating.php +1 -3
- includes/shortcodes/classes/YasrVisitorVotes.php +73 -72
- includes/yasr-includes-functions.php +18 -9
- includes/yasr-includes-init.php +4 -11
- public/classes/YasrRichSnippetAdditionalFields.php +1 -8
- public/yasr-public-actions.php +0 -29
- public/yasr-public-functions.php +0 -77
- public/yasr-public-init.php +0 -1
- readme.txt +10 -1
- yet-another-stars-rating.php +2 -2
admin/classes/YasrOnInstall.php
CHANGED
@@ -146,7 +146,6 @@ class YasrOnInstall {
|
|
146 |
$option['stars_title_exclude_pages'] = 'yes';
|
147 |
$option['show_overall_in_loop'] = 'enabled';
|
148 |
$option['show_visitor_votes_in_loop'] = 'enabled';
|
149 |
-
$option['text_before_stars'] = 1;
|
150 |
$option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
|
151 |
$option['text_before_visitor_rating'] = __('Click to rate this post!', 'yet-another-stars-rating');
|
152 |
$option['text_after_visitor_rating'] = sprintf(
|
146 |
$option['stars_title_exclude_pages'] = 'yes';
|
147 |
$option['show_overall_in_loop'] = 'enabled';
|
148 |
$option['show_visitor_votes_in_loop'] = 'enabled';
|
|
|
149 |
$option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
|
150 |
$option['text_before_visitor_rating'] = __('Click to rate this post!', 'yet-another-stars-rating');
|
151 |
$option['text_after_visitor_rating'] = sprintf(
|
admin/js/src/yasr-settings-page.js
CHANGED
@@ -12,7 +12,6 @@ if(tabClass.length > 0){
|
|
12 |
if (activeTab === 'general_settings') {
|
13 |
let autoInsertEnabled = document.getElementById('yasr_auto_insert_switch').checked;
|
14 |
let starsTitleEnabled = document.getElementById('yasr-general-options-stars-title-switch').checked;
|
15 |
-
let textBeforeStars = document.getElementById('yasr-general-options-text-before-stars-switch').checked;
|
16 |
|
17 |
if (autoInsertEnabled === false) {
|
18 |
jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
|
@@ -40,23 +39,13 @@ if (activeTab === 'general_settings') {
|
|
40 |
}
|
41 |
});
|
42 |
|
43 |
-
//for text before stars
|
44 |
-
if (textBeforeStars === false) {
|
45 |
-
jQuery(".yasr-general-options-text-before").find(':input').prop('disabled', true);
|
46 |
-
}
|
47 |
-
|
48 |
-
document.getElementById('yasr-general-options-text-before-stars-switch').addEventListener('change', function() {
|
49 |
-
if (this.checked) {
|
50 |
-
jQuery(".yasr-general-options-text-before").find(':input').prop('disabled', false);
|
51 |
-
jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
|
52 |
-
jQuery('#yasr-general-options-custom-text-before-visitor').val('Click to rate this post!');
|
53 |
-
jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
|
54 |
-
jQuery('#yasr-general-options-custom-text-must-sign-in').val('You must sign in to vote');
|
55 |
-
jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article with %rating%');
|
56 |
-
} else {
|
57 |
-
jQuery(".yasr-general-options-text-before").find(':input').prop('disabled', true);
|
58 |
-
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
});
|
61 |
|
62 |
|
12 |
if (activeTab === 'general_settings') {
|
13 |
let autoInsertEnabled = document.getElementById('yasr_auto_insert_switch').checked;
|
14 |
let starsTitleEnabled = document.getElementById('yasr-general-options-stars-title-switch').checked;
|
|
|
15 |
|
16 |
if (autoInsertEnabled === false) {
|
17 |
jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
|
39 |
}
|
40 |
});
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
document.getElementById('yasr-settings-custom-texts').addEventListener('click', function() {
|
44 |
+
document.getElementById('yasr-settings-custom-text-before-overall').value = 'Our Score';
|
45 |
+
document.getElementById('yasr-settings-custom-text-before-visitor').value = 'Click to rate this post!';
|
46 |
+
document.getElementById('yasr-settings-custom-text-after-visitor').value = '[Total: %total_count% Average: %average%]';
|
47 |
+
document.getElementById('yasr-settings-custom-text-must-sign-in').value = 'You must sign in to vote';
|
48 |
+
document.getElementById('yasr-settings-custom-text-already-rated').value = 'You have already voted for this article with %rating%';
|
49 |
});
|
50 |
|
51 |
|
admin/js/yasr-settings.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(2)},function(t,e){var r;if(document.getElementsByClassName("nav-tab-active").length>0&&(r=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===r){var a=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked,s=document.getElementById("yasr-general-options-text-before-stars-switch").checked;!1===a&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),!1===s&&jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!0),document.getElementById("yasr-general-options-text-before-stars-switch").addEventListener("change",(function(){this.checked?(jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!1),jQuery("#yasr-general-options-custom-text-before-overall").val("Our Score"),jQuery("#yasr-general-options-custom-text-before-visitor").val("Click to rate this post!"),jQuery("#yasr-general-options-custom-text-after-visitor").val("[Total: %total_count% Average: %average%]"),jQuery("#yasr-general-options-custom-text-must-sign-in").val("You must sign in to vote"),jQuery("#yasr-general-options-custom-text-already-rated").val("You have already voted for this article with %rating%")):jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!0)}))}if("style_options"===r&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===r){var o=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===o){var i=jQuery("#yasr-edit-form-number-elements").attr("value");i++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(i>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+i+' <input type="text" name="edit-multi-set-element-'+i+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),i++}))}else o>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===r&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,r){"use strict";var a,n;r.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};for(var y=function(t,e,r){var a=(t=t||{}).random||(t.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return c(a)},m=wp.i18n.__,p=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],g=0;g<p.length;g++)f(p[g]);function f(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;v(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),s=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=_(n),s=_(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),d=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+l,p="yasr-vv-average-container-"+l,g=document.getElementById(y),f=document.getElementById(p),v="yasr-vv-loader-"+l,b=!1;if("yes"===yasrCommonData.ajaxEnabled){var E=r.getAttribute("data-cpt");""===E&&(E="posts");var k="wp/v2/"+E+"/"+o+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+k).done((function(t){var e;(e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),h(u,a,o,e,i,l,d,c,g,f,v),!0!==n)&&(null!==g&&(g.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&(b=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(v).innerHTML=b))})).fail((function(t,e,r,y){console.info(m("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(u,a,o,s,i,l,d,c,g,f,v),!0!==n&&(document.getElementById("yasr-below-stars-hidden-"+l).style.display="")}))}else h(u,a,o,s,i,l,d,c,g,f,v)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),s=n.id,o=n.getAttribute("data-rater-readonly");o=_(o);v(16,s,n,1,o,!1,(function(t,a){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function v(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,r,a,n,s,o,i,l,u,d){e=parseFloat(e),a=_(a);v(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(d).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),document.getElementById(d).innerHTML=t.rating_saved_text})),e()}))}function _(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function b(t){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function w(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=j(t);if(e){var n=j(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return I(this,r)}}function I(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function j(t){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var B=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+y(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return v(r,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",B("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",B("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function Q(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function L(t){var e="after",r=B("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:r}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:r}))}function T(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(Q,{colClass:e,post:t.post}),React.createElement(L,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(T,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,r,a,n=w(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=s,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(B("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(B("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(B(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(B(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:B("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:a},B("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},B("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},B("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},B("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,B("Order By","yet-another-stars-rating-pro"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,s="most-rated-posts-"+r,o="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(S,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(o=u.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,B("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var A,N=function(t){var e=G.value,r=document.getElementById("yasr-builder-shortcode").textContent,a=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];a=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",a),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+r).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.style.display="",r.style.display="none",a.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,r,a,n,s,o,i){n.style.display="",t.style.display="none",r.style.display="none",a.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},U=function(t,e,r,a,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8];s.style.display="",e.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display=""),!0===l?(r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var q=[],J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""};A=J.name,document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!1):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!0):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!1),J.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!0),J.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),J.name=t.target.value,A=J.name+J.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(J.setid=" setid="+t.target.value),q=wp.hooks.applyFilters("yasrBuilderFilterShortcode",J);for(var e=2;J.length;e++)q.hasOwnProperty(J[e])&&(J[e]=q[e]);A=J.name+J.setid+J.rows+J.view+J.minvotesmost+J.minvoteshg+J.size+J.txtPosition+J.txt+J.display+J.category+J.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]"),!0===it&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&N()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){N(),it=!0}}}]);
|
1 |
+
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(2)},function(t,e){var r;if(document.getElementsByClassName("nav-tab-active").length>0&&(r=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===r){var a=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===a&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===r&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===r){var s=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===s){var o=jQuery("#yasr-edit-form-number-elements").attr("value");o++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(o>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+o+' <input type="text" name="edit-multi-set-element-'+o+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),o++}))}else s>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===r&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,r){"use strict";var a,n;r.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};for(var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return c(a)},y=wp.i18n.__,g=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],p=0;p<g.length;p++)v(g[p]);function v(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;f(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),s=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=_(n),s=_(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),d=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v=document.getElementById(m),f=document.getElementById(g),b=document.getElementById(p),E="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var k=r.getAttribute("data-cpt");""===k&&(k="posts");var I="wp/v2/"+k+"/"+o+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+I).done((function(t){var e;e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),h(u,a,o,e,i,l,d,c,v,f,E,b),!0!==n&&(null!==v&&(v.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&null!==b&&(b.innerHTML=t.yasr_visitor_votes.stars_attributes.span_bottom,b.style.display=""))})).fail((function(t,e,r,m){console.info(y("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(u,a,o,s,i,l,d,c,v,f,E,b),!0!==n&&(b.style.display="")}))}else h(u,a,o,s,i,l,d,c,v,f,E,b)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),s=n.id,o=n.getAttribute("data-rater-readonly");o=_(o);f(16,s,n,1,o,!1,(function(t,a){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function f(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,r,a,n,s,o,i,l,u,d,c){e=parseFloat(e),a=_(a);f(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(d).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==c&&(c.innerHTML=t.rating_saved_text),document.getElementById(d).innerHTML=""})),e()}))}function _(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function b(t){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=B(t);if(e){var n=B(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return w(this,r)}}function w(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var j=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return f(r,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",j("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",j("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function L(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function T(t){var e="after",r=j("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:r}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:r}))}function Q(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(L,{colClass:e,post:t.post}),React.createElement(T,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(Q,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,r,a,n=I(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=s,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(j("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(j("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(j(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(j(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:j("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:a},j("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},j("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},j("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},j("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,j("Order By","yet-another-stars-rating-pro"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,s="most-rated-posts-"+r,o="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(S,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(o=u.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,j("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var A,N=function(t){var e=G.value,r=document.getElementById("yasr-builder-shortcode").textContent,a=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];a=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",a),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+r).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.style.display="",r.style.display="none",a.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,r,a,n,s,o,i){n.style.display="",t.style.display="none",r.style.display="none",a.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},U=function(t,e,r,a,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8];s.style.display="",e.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display=""),!0===l?(r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var q=[],J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""};A=J.name,document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!1):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!0):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!1),J.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!0),J.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),J.name=t.target.value,A=J.name+J.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(J.setid=" setid="+t.target.value),q=wp.hooks.applyFilters("yasrBuilderFilterShortcode",J);for(var e=2;J.length;e++)q.hasOwnProperty(J[e])&&(J[e]=q[e]);A=J.name+J.setid+J.rows+J.view+J.minvotesmost+J.minvoteshg+J.size+J.txtPosition+J.txt+J.display+J.category+J.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]"),!0===it&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&N()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){N(),it=!0}}}]);
|
admin/settings/classes/YasrSettings.php
CHANGED
@@ -75,18 +75,28 @@ class YasrSettings {
|
|
75 |
$option['stars_title_where'] = 'archive';
|
76 |
}
|
77 |
|
78 |
-
//
|
79 |
-
if
|
80 |
$option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
|
|
|
|
|
81 |
$option['text_before_visitor_rating'] = __('Click to rate this post!', 'yet-another-stars-rating');
|
|
|
|
|
|
|
82 |
$option['text_after_visitor_rating'] = sprintf(
|
83 |
__('[Total: %s Average: %s]', 'yet-another-stars-rating'),
|
84 |
'%total_count%', '%average%'
|
85 |
);
|
|
|
|
|
|
|
86 |
$option['custom_text_user_voted'] =
|
87 |
__('You have already voted for this article with rating ', 'yet-another-stars-rating') . '%rating%';
|
|
|
88 |
|
89 |
-
|
|
|
90 |
}
|
91 |
|
92 |
//Avoid undefined
|
@@ -507,47 +517,36 @@ class YasrSettings {
|
|
507 |
public function customText($option) {
|
508 |
?>
|
509 |
<div>
|
510 |
-
<div class="yasr-onoffswitch-big">
|
511 |
-
<input type="checkbox" name="yasr_general_options[text_before_stars]" class="yasr-onoffswitch-checkbox"
|
512 |
-
id="yasr-general-options-text-before-stars-switch" <?php if ($option['text_before_stars'] == 1) {
|
513 |
-
echo " checked='checked' ";
|
514 |
-
} ?> >
|
515 |
-
<label class="yasr-onoffswitch-label" for="yasr-general-options-text-before-stars-switch">
|
516 |
-
<span class="yasr-onoffswitch-inner"></span>
|
517 |
-
<span class="yasr-onoffswitch-switch"></span>
|
518 |
-
</label>
|
519 |
-
</div>
|
520 |
-
<br />
|
521 |
<?php
|
522 |
$custom_text = array(
|
523 |
'txt_before_overall' => array (
|
524 |
'name' => 'text_before_overall',
|
525 |
'description' => __('Custom text to display before Overall Rating', 'yet-another-stars-rating'),
|
526 |
-
'id' => 'yasr-
|
527 |
'class' => 'yasr-general-options-text-before'
|
528 |
),
|
529 |
'txt_before_vv' => array (
|
530 |
'name' => 'text_before_visitor_rating',
|
531 |
'description' => __('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating'),
|
532 |
-
'id' => 'yasr-
|
533 |
'class' => 'yasr-general-options-text-before'
|
534 |
),
|
535 |
'txt_after_vv' => array (
|
536 |
'name' => 'text_after_visitor_rating',
|
537 |
'description' => __('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating'),
|
538 |
-
'id' => 'yasr-
|
539 |
'class' => 'yasr-general-options-text-before'
|
540 |
),
|
541 |
'txt_login_required' => array (
|
542 |
'name' => 'custom_text_must_sign_in',
|
543 |
'description' => __('Custom text to display when login is required to vote', 'yet-another-stars-rating'),
|
544 |
-
'id' => 'yasr-
|
545 |
'class' => 'yasr-general-options-text-before'
|
546 |
),
|
547 |
'txt_vv_rated' => array (
|
548 |
'name' => 'custom_text_user_voted',
|
549 |
'description' => __('Custom text to display when an user has already rated', 'yet-another-stars-rating'),
|
550 |
-
'id' => 'yasr-
|
551 |
'class' => 'yasr-general-options-text-before'
|
552 |
)
|
553 |
);
|
@@ -557,6 +556,10 @@ class YasrSettings {
|
|
557 |
<?php
|
558 |
self::echoSettingFields($custom_text, $option);
|
559 |
?>
|
|
|
|
|
|
|
|
|
560 |
</div>
|
561 |
|
562 |
<div id="yasr-doc-custom-text-div">
|
@@ -570,6 +573,8 @@ class YasrSettings {
|
|
570 |
total count, and %s pattern to show the average.', 'yet-another-stars-rating'),
|
571 |
'<strong>%total_count%</strong>', '<strong>%average%</strong>');
|
572 |
|
|
|
|
|
573 |
echo $string_custom_overall;
|
574 |
echo '<br /><br/>';
|
575 |
echo $string_custom_visitor;
|
@@ -581,7 +586,7 @@ class YasrSettings {
|
|
581 |
</div>
|
582 |
</div>
|
583 |
</div>
|
584 |
-
|
585 |
<?php
|
586 |
submit_button(YASR_SAVE_All_SETTINGS_TEXT);
|
587 |
?>
|
@@ -854,15 +859,6 @@ class YasrSettings {
|
|
854 |
$output['show_visitor_votes_in_loop'] = 'enabled';
|
855 |
}
|
856 |
|
857 |
-
//Same as above but for text_before_stars key
|
858 |
-
if (!array_key_exists('text_before_stars', $output)) {
|
859 |
-
$output['text_before_stars'] = 0;
|
860 |
-
}
|
861 |
-
//if exists must be 1
|
862 |
-
else {
|
863 |
-
$output['text_before_stars'] = 1;
|
864 |
-
}
|
865 |
-
|
866 |
//Same as above but for visitors_stats key
|
867 |
if (!array_key_exists('visitors_stats', $output)) {
|
868 |
$output['visitors_stats'] = 'no';
|
75 |
$option['stars_title_where'] = 'archive';
|
76 |
}
|
77 |
|
78 |
+
//Default values
|
79 |
+
if(!isset($option['text_before_overall'])) {
|
80 |
$option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
|
81 |
+
}
|
82 |
+
if(!isset($option['text_before_visitor_rating'])) {
|
83 |
$option['text_before_visitor_rating'] = __('Click to rate this post!', 'yet-another-stars-rating');
|
84 |
+
}
|
85 |
+
|
86 |
+
if(!isset($option['text_after_visitor_rating'])) {
|
87 |
$option['text_after_visitor_rating'] = sprintf(
|
88 |
__('[Total: %s Average: %s]', 'yet-another-stars-rating'),
|
89 |
'%total_count%', '%average%'
|
90 |
);
|
91 |
+
}
|
92 |
+
|
93 |
+
if(!isset($option['custom_text_user_voted'])) {
|
94 |
$option['custom_text_user_voted'] =
|
95 |
__('You have already voted for this article with rating ', 'yet-another-stars-rating') . '%rating%';
|
96 |
+
}
|
97 |
|
98 |
+
if(!isset($option['custom_text_must_sign_in'])) {
|
99 |
+
$option['custom_text_must_sign_in'] = __('You must sign in to vote', 'yet-another-stars-rating');
|
100 |
}
|
101 |
|
102 |
//Avoid undefined
|
517 |
public function customText($option) {
|
518 |
?>
|
519 |
<div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
<?php
|
521 |
$custom_text = array(
|
522 |
'txt_before_overall' => array (
|
523 |
'name' => 'text_before_overall',
|
524 |
'description' => __('Custom text to display before Overall Rating', 'yet-another-stars-rating'),
|
525 |
+
'id' => 'yasr-settings-custom-text-before-overall',
|
526 |
'class' => 'yasr-general-options-text-before'
|
527 |
),
|
528 |
'txt_before_vv' => array (
|
529 |
'name' => 'text_before_visitor_rating',
|
530 |
'description' => __('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating'),
|
531 |
+
'id' => 'yasr-settings-custom-text-before-visitor',
|
532 |
'class' => 'yasr-general-options-text-before'
|
533 |
),
|
534 |
'txt_after_vv' => array (
|
535 |
'name' => 'text_after_visitor_rating',
|
536 |
'description' => __('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating'),
|
537 |
+
'id' => 'yasr-settings-custom-text-after-visitor',
|
538 |
'class' => 'yasr-general-options-text-before'
|
539 |
),
|
540 |
'txt_login_required' => array (
|
541 |
'name' => 'custom_text_must_sign_in',
|
542 |
'description' => __('Custom text to display when login is required to vote', 'yet-another-stars-rating'),
|
543 |
+
'id' => 'yasr-settings-custom-text-must-sign-in',
|
544 |
'class' => 'yasr-general-options-text-before'
|
545 |
),
|
546 |
'txt_vv_rated' => array (
|
547 |
'name' => 'custom_text_user_voted',
|
548 |
'description' => __('Custom text to display when an user has already rated', 'yet-another-stars-rating'),
|
549 |
+
'id' => 'yasr-settings-custom-text-already-rated',
|
550 |
'class' => 'yasr-general-options-text-before'
|
551 |
)
|
552 |
);
|
556 |
<?php
|
557 |
self::echoSettingFields($custom_text, $option);
|
558 |
?>
|
559 |
+
<input type="button"
|
560 |
+
id="yasr-settings-custom-texts"
|
561 |
+
class="button"
|
562 |
+
value="<?php _e('Restore defaults', 'yet-another-stars-rating') ?>">
|
563 |
</div>
|
564 |
|
565 |
<div id="yasr-doc-custom-text-div">
|
573 |
total count, and %s pattern to show the average.', 'yet-another-stars-rating'),
|
574 |
'<strong>%total_count%</strong>', '<strong>%average%</strong>');
|
575 |
|
576 |
+
_e('Leave a field empty to disable it.', 'yet-another-stars-rating');
|
577 |
+
echo '<br /><br/>';
|
578 |
echo $string_custom_overall;
|
579 |
echo '<br /><br/>';
|
580 |
echo $string_custom_visitor;
|
586 |
</div>
|
587 |
</div>
|
588 |
</div>
|
589 |
+
<br />
|
590 |
<?php
|
591 |
submit_button(YASR_SAVE_All_SETTINGS_TEXT);
|
592 |
?>
|
859 |
$output['show_visitor_votes_in_loop'] = 'enabled';
|
860 |
}
|
861 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
862 |
//Same as above but for visitors_stats key
|
863 |
if (!array_key_exists('visitors_stats', $output)) {
|
864 |
$output['visitors_stats'] = 'no';
|
admin/yasr-update-functions.php
CHANGED
@@ -54,7 +54,6 @@ function yasr_update_version() {
|
|
54 |
|
55 |
//remove end 2021
|
56 |
if (version_compare($yasr_version_installed, '2.1.0') === -1) {
|
57 |
-
|
58 |
$old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
|
59 |
|
60 |
$sql_import_multiset = $wpdb->get_results(
|
@@ -193,6 +192,18 @@ function yasr_update_version() {
|
|
193 |
}
|
194 |
}
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
} //Endif yasr_version_installed !== false
|
197 |
|
198 |
|
54 |
|
55 |
//remove end 2021
|
56 |
if (version_compare($yasr_version_installed, '2.1.0') === -1) {
|
|
|
57 |
$old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
|
58 |
|
59 |
$sql_import_multiset = $wpdb->get_results(
|
192 |
}
|
193 |
}
|
194 |
|
195 |
+
//In version 2.7.4 option "text_before_stars" is removed.
|
196 |
+
//if it was set to 0, be sure that text before overall is empty
|
197 |
+
if (version_compare($yasr_version_installed, '2.7.4') === -1) {
|
198 |
+
if (array_key_exists('text_before_stars', $yasr_stored_options)) {
|
199 |
+
if($yasr_stored_options['text_before_stars'] === 0) {
|
200 |
+
$yasr_stored_options['text_before_overall'] = '';
|
201 |
+
|
202 |
+
update_option('yasr_general_options', $yasr_stored_options);
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
} //Endif yasr_version_installed !== false
|
208 |
|
209 |
|
includes/classes/YasrCustomPostTypes.php
CHANGED
@@ -8,7 +8,6 @@
|
|
8 |
*/
|
9 |
class YasrCustomPostTypes {
|
10 |
|
11 |
-
|
12 |
/**
|
13 |
** @since 2.3.3
|
14 |
*
|
8 |
*/
|
9 |
class YasrCustomPostTypes {
|
10 |
|
|
|
11 |
/**
|
12 |
** @since 2.3.3
|
13 |
*
|
includes/classes/YasrIncludesFilters.php
CHANGED
@@ -28,10 +28,36 @@ class YasrIncludesFilters {
|
|
28 |
|
29 |
add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'), 99);
|
30 |
add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 99, 3);
|
31 |
-
add_filter('yasr_cstm_text_after_vv', array($this, 'filterTextVVAfter'), 99,
|
32 |
add_filter('yasr_cstm_text_already_voted', array($this, 'filterTextAlreadyVoted'), 99, 2);
|
33 |
add_filter('yasr_must_sign_in', array($this, 'filterTextMustSignIn'), 99 );
|
|
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
/**
|
@@ -80,16 +106,17 @@ class YasrIncludesFilters {
|
|
80 |
* @author Dario Curvino <@dudo>
|
81 |
* @since 2.6.6
|
82 |
*
|
83 |
-
* @param $default_text
|
84 |
* @param $number_of_votes
|
85 |
* @param $average_rating
|
86 |
* @param $unique_id
|
87 |
*
|
88 |
* @return string|string[]
|
89 |
*/
|
90 |
-
public function filterTextVVAfter ($
|
91 |
if(array_key_exists('text_after_visitor_rating', $this->yasr_stored_options)) {
|
92 |
-
$custom_text =
|
|
|
|
|
93 |
} else {
|
94 |
$custom_text = '';
|
95 |
}
|
@@ -151,4 +178,56 @@ class YasrIncludesFilters {
|
|
151 |
);
|
152 |
}
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
}
|
28 |
|
29 |
add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'), 99);
|
30 |
add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 99, 3);
|
31 |
+
add_filter('yasr_cstm_text_after_vv', array($this, 'filterTextVVAfter'), 99, 3);
|
32 |
add_filter('yasr_cstm_text_already_voted', array($this, 'filterTextAlreadyVoted'), 99, 2);
|
33 |
add_filter('yasr_must_sign_in', array($this, 'filterTextMustSignIn'), 99 );
|
34 |
+
}
|
35 |
|
36 |
+
/**
|
37 |
+
* @author Dario Curvino <@dudo>
|
38 |
+
* @since 2.7.4
|
39 |
+
*/
|
40 |
+
public function cachingPluginSupport () {
|
41 |
+
//Autooptimize
|
42 |
+
add_filter('autoptimize_filter_js_dontmove', static function ($excluded_files) {
|
43 |
+
if(is_array($excluded_files)) {
|
44 |
+
$excluded_files[] = 'wp-includes/js/dist/';
|
45 |
+
}
|
46 |
+
return $excluded_files;
|
47 |
+
});
|
48 |
+
|
49 |
+
//wp rocket
|
50 |
+
add_filter('rocket_exclude_defer_js', static function ($excluded_files) {
|
51 |
+
if(is_array($excluded_files)) {
|
52 |
+
$excluded_files[] = 'wp-includes/js/dist/';
|
53 |
+
}
|
54 |
+
return $excluded_files;
|
55 |
+
});
|
56 |
+
|
57 |
+
//Delete caches for supported plugins on visitor vote
|
58 |
+
//Can't use is_singular() here because always return false
|
59 |
+
add_action('yasr_action_on_visitor_vote', array($this, 'deleteCaches'));
|
60 |
+
add_action('yasr_action_on_visitor_multiset_vote', array($this, 'deleteCaches'));
|
61 |
}
|
62 |
|
63 |
/**
|
106 |
* @author Dario Curvino <@dudo>
|
107 |
* @since 2.6.6
|
108 |
*
|
|
|
109 |
* @param $number_of_votes
|
110 |
* @param $average_rating
|
111 |
* @param $unique_id
|
112 |
*
|
113 |
* @return string|string[]
|
114 |
*/
|
115 |
+
public function filterTextVVAfter ($number_of_votes, $average_rating, $unique_id) {
|
116 |
if(array_key_exists('text_after_visitor_rating', $this->yasr_stored_options)) {
|
117 |
+
$custom_text = '<span id="yasr-vv-text-container-'.$unique_id.'" class="yasr-vv-text-container">';
|
118 |
+
$custom_text .= htmlspecialchars_decode($this->yasr_stored_options['text_after_visitor_rating']);
|
119 |
+
$custom_text .= '</span>';
|
120 |
} else {
|
121 |
$custom_text = '';
|
122 |
}
|
178 |
);
|
179 |
}
|
180 |
|
181 |
+
/**
|
182 |
+
* @author Dario Curvino <@dudo>
|
183 |
+
* @since refactored in 2.7.4
|
184 |
+
* @param $array_action_visitor_vote
|
185 |
+
*/
|
186 |
+
public function deleteCaches($array_action_visitor_vote) {
|
187 |
+
if (isset($array_action_visitor_vote['post_id'])) {
|
188 |
+
$post_id = $array_action_visitor_vote['post_id'];
|
189 |
+
} else {
|
190 |
+
return;
|
191 |
+
}
|
192 |
+
|
193 |
+
if (isset($array_action_visitor_vote['is_singular'])) {
|
194 |
+
$is_singular = $array_action_visitor_vote['is_singular'];
|
195 |
+
} else {
|
196 |
+
return;
|
197 |
+
}
|
198 |
+
|
199 |
+
//Adds support for wp super cache
|
200 |
+
if (function_exists('wp_cache_post_change')) {
|
201 |
+
wp_cache_post_change($post_id);
|
202 |
+
}
|
203 |
+
|
204 |
+
//Adds support for wp rocket, thanks to GeekPress
|
205 |
+
//https://wordpress.org/support/topic/compatibility-with-wp-rocket-2
|
206 |
+
if (function_exists('rocket_clean_post')) {
|
207 |
+
rocket_clean_post($post_id);
|
208 |
+
}
|
209 |
+
|
210 |
+
//Adds support for LiteSpeed Cache plugin
|
211 |
+
if (method_exists('\LiteSpeed\Purge', 'purge_post')) {
|
212 |
+
\LiteSpeed\Purge::purge_post($post_id);
|
213 |
+
}
|
214 |
+
|
215 |
+
//Adds support for Wp Fastest Cache
|
216 |
+
if ($is_singular === 'true') {
|
217 |
+
if (isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'singleDeleteCache')) {
|
218 |
+
$GLOBALS['wp_fastest_cache']->singleDeleteCache(false, $post_id);
|
219 |
+
}
|
220 |
+
} else {
|
221 |
+
if (isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) {
|
222 |
+
$GLOBALS['wp_fastest_cache']->deleteCache();
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
//cache enabler support
|
227 |
+
if(method_exists('Cache_Enabler', 'clear_page_cache_by_post_id')) {
|
228 |
+
Cache_Enabler::clear_page_cache_by_post_id($post_id);
|
229 |
+
}
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
}
|
includes/css/yasr.css
CHANGED
@@ -50,7 +50,6 @@
|
|
50 |
content: none !important;
|
51 |
}
|
52 |
/****** NON ADMIN RULES ******/
|
53 |
-
|
54 |
.yasr-auto-insert-overall {
|
55 |
margin-top: 10px;
|
56 |
}
|
@@ -65,28 +64,21 @@
|
|
65 |
vertical-align: top;
|
66 |
}
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
display: inline-block;
|
71 |
-
}
|
72 |
-
|
73 |
-
.yasr-vv-container-loader {
|
74 |
-
display: inline;
|
75 |
}
|
76 |
|
77 |
-
.yasr-
|
78 |
display: inline-block;
|
79 |
}
|
80 |
|
81 |
.yasr-dashicons-visitor-stats {
|
82 |
-
vertical-align: bottom !important;
|
83 |
-
text-decoration: none;
|
84 |
cursor: pointer;
|
85 |
-
|
86 |
}
|
87 |
|
88 |
-
.yasr-
|
89 |
-
display: block;
|
90 |
}
|
91 |
|
92 |
.yasr-small-block-bold {
|
50 |
content: none !important;
|
51 |
}
|
52 |
/****** NON ADMIN RULES ******/
|
|
|
53 |
.yasr-auto-insert-overall {
|
54 |
margin-top: 10px;
|
55 |
}
|
64 |
vertical-align: top;
|
65 |
}
|
66 |
|
67 |
+
.yasr-vv-second-row-container {
|
68 |
+
line-height: normal;
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
|
71 |
+
.yasr-vv-stats-text-container {
|
72 |
display: inline-block;
|
73 |
}
|
74 |
|
75 |
.yasr-dashicons-visitor-stats {
|
|
|
|
|
76 |
cursor: pointer;
|
77 |
+
vertical-align: bottom;
|
78 |
}
|
79 |
|
80 |
+
.yasr-vv-container-loader {
|
81 |
+
display: inline-block;
|
82 |
}
|
83 |
|
84 |
.yasr-small-block-bold {
|
includes/img/chart-bar.svg
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generated by IcoMoon.io -->
|
3 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4 |
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20">
|
5 |
+
<path d="M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z"></path>
|
6 |
+
</svg>
|
includes/js/src/yasr-front.js
CHANGED
@@ -177,11 +177,12 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
177 |
|
178 |
let containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
|
179 |
let containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
|
|
|
180 |
const containerVotesNumber = document.getElementById(containerVotesNumberName);
|
181 |
const containerAverageNumber = document.getElementById(containerAverageNumberName);
|
|
|
182 |
|
183 |
let loaderContainer = 'yasr-vv-loader-' + uniqueId;
|
184 |
-
let spanBottom = false;
|
185 |
|
186 |
if(yasrCommonData.ajaxEnabled === 'yes') {
|
187 |
let cpt = elem.getAttribute('data-cpt');
|
@@ -211,7 +212,7 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
211 |
rating = parseFloat(rating);
|
212 |
|
213 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
214 |
-
containerVotesNumber, containerAverageNumber, loaderContainer);
|
215 |
|
216 |
//do this only if yasr_visitor_votes has not the readonly attribute
|
217 |
if(readonlyShortcode !== true) {
|
@@ -224,10 +225,10 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
224 |
}
|
225 |
|
226 |
//insert span with text after the average
|
227 |
-
if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
}
|
232 |
}
|
233 |
|
@@ -235,16 +236,16 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
235 |
function(e, x, settings, exception) {
|
236 |
console.info(__('YASR ajax call failed. Showing ratings from html', 'yet-another-stars-rating'));
|
237 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
238 |
-
containerVotesNumber, containerAverageNumber, loaderContainer);
|
239 |
|
240 |
//Unhide the div below the stars
|
241 |
if(readonlyShortcode !== true) {
|
242 |
-
|
243 |
}
|
244 |
});
|
245 |
} else {
|
246 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
247 |
-
containerVotesNumber, containerAverageNumber, loaderContainer);
|
248 |
}
|
249 |
|
250 |
})(i);
|
@@ -254,7 +255,7 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
254 |
}
|
255 |
|
256 |
function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
257 |
-
containerVotesNumber, containerAverageNumber, loaderContainer) {
|
258 |
|
259 |
//Be sure is a number and not a string
|
260 |
rating = parseFloat(rating);
|
@@ -291,7 +292,12 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
|
|
291 |
if(containerAverageNumber !== null) {
|
292 |
containerAverageNumber.innerHTML = response.average_rating;
|
293 |
}
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
});
|
297 |
done();
|
177 |
|
178 |
let containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
|
179 |
let containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
|
180 |
+
let bottomContainerName = 'yasr-vv-bottom-container-' + uniqueId;
|
181 |
const containerVotesNumber = document.getElementById(containerVotesNumberName);
|
182 |
const containerAverageNumber = document.getElementById(containerAverageNumberName);
|
183 |
+
const bottomContainer = document.getElementById(bottomContainerName);
|
184 |
|
185 |
let loaderContainer = 'yasr-vv-loader-' + uniqueId;
|
|
|
186 |
|
187 |
if(yasrCommonData.ajaxEnabled === 'yes') {
|
188 |
let cpt = elem.getAttribute('data-cpt');
|
212 |
rating = parseFloat(rating);
|
213 |
|
214 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
215 |
+
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer);
|
216 |
|
217 |
//do this only if yasr_visitor_votes has not the readonly attribute
|
218 |
if(readonlyShortcode !== true) {
|
225 |
}
|
226 |
|
227 |
//insert span with text after the average
|
228 |
+
if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false
|
229 |
+
&& bottomContainer !== null) {
|
230 |
+
bottomContainer.innerHTML = data.yasr_visitor_votes.stars_attributes.span_bottom;
|
231 |
+
bottomContainer.style.display = '';
|
232 |
}
|
233 |
}
|
234 |
|
236 |
function(e, x, settings, exception) {
|
237 |
console.info(__('YASR ajax call failed. Showing ratings from html', 'yet-another-stars-rating'));
|
238 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
239 |
+
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer);
|
240 |
|
241 |
//Unhide the div below the stars
|
242 |
if(readonlyShortcode !== true) {
|
243 |
+
bottomContainer.style.display = '';
|
244 |
}
|
245 |
});
|
246 |
} else {
|
247 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
248 |
+
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer);
|
249 |
}
|
250 |
|
251 |
})(i);
|
255 |
}
|
256 |
|
257 |
function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
258 |
+
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer) {
|
259 |
|
260 |
//Be sure is a number and not a string
|
261 |
rating = parseFloat(rating);
|
292 |
if(containerAverageNumber !== null) {
|
293 |
containerAverageNumber.innerHTML = response.average_rating;
|
294 |
}
|
295 |
+
if(bottomContainer !== null) {
|
296 |
+
bottomContainer.innerHTML = response.rating_saved_text;
|
297 |
+
}
|
298 |
+
|
299 |
+
//empty loader gif
|
300 |
+
document.getElementById(loaderContainer).innerHTML = '';
|
301 |
|
302 |
});
|
303 |
done();
|
includes/js/yasr-front.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return j})),r.d(e,"yasrSetRaterValue",(function(){return L}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return d(a)};function g(t){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==g(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return L(r,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function I(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function k(t){var e="after",r=b("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:r}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:r}))}function w(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,r,a,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=o,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:a},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),": ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(e.prototype,r),a&&y(e,a),o}();for(var x=wp.i18n.__,B=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],T=0;T<B.length;T++)j(B[T]);function j(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;L(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),c=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y=document.getElementById(m),f=document.getElementById(g),p="yasr-vv-loader-"+l,v=!1;if("yes"===yasrCommonData.ajaxEnabled){var h=r.getAttribute("data-cpt");""===h&&(h="posts");var b="wp/v2/"+h+"/"+s+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+b).done((function(t){var e;(e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),P(u,a,s,e,i,l,c,d,y,f,p),!0!==n)&&(null!==y&&(y.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&(v=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(p).innerHTML=v))})).fail((function(t,e,r,m){console.info(x("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,y,f,p),!0!==n&&(document.getElementById("yasr-below-stars-hidden-"+l).style.display="")}))}else P(u,a,s,o,i,l,c,d,y,f,p)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);L(16,o,n,1,s,!1,(function(t,a){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function L(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,u,c){e=parseFloat(e),a=O(a);L(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(c).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),document.getElementById(c).innerHTML=t.rating_saved_text})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
|
1 |
+
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return j})),r.d(e,"yasrSetRaterValue",(function(){return B}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return d(a)};function y(t){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function g(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==y(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return B(r,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function I(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function k(t){var e="after",r=b("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:r}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:r}))}function w(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,r,a,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=o,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:a},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),": ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,r),a&&g(e,a),o}();for(var T=wp.i18n.__,x=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],L=0;L<x.length;L++)j(x[L]);function j(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;B(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),c=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,y="yasr-vv-average-container-"+l,g="yasr-vv-bottom-container-"+l,f=document.getElementById(m),p=document.getElementById(y),v=document.getElementById(g),h="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var b=r.getAttribute("data-cpt");""===b&&(b="posts");var _="wp/v2/"+b+"/"+s+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+_).done((function(t){var e;e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),P(u,a,s,e,i,l,c,d,f,p,h,v),!0!==n&&(null!==f&&(f.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==p&&(p.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&null!==v&&(v.innerHTML=t.yasr_visitor_votes.stars_attributes.span_bottom,v.style.display=""))})).fail((function(t,e,r,m){console.info(T("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,f,p,h,v),!0!==n&&(v.style.display="")}))}else P(u,a,s,o,i,l,c,d,f,p,h,v)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);B(16,o,n,1,s,!1,(function(t,a){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function B(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,u,c,d){e=parseFloat(e),a=O(a);B(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(c).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==d&&(d.innerHTML=t.rating_saved_text),document.getElementById(c).innerHTML=""})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
|
includes/shortcodes/classes/YasrOverallRating.php
CHANGED
@@ -42,9 +42,7 @@ class YasrOverallRating extends YasrShortcode {
|
|
42 |
|
43 |
$this->shortcode_html = '<!--Yasr Overall Rating Shortcode-->';
|
44 |
|
45 |
-
|
46 |
-
$this->shortcode_html .= $this->customTextBefore();
|
47 |
-
}
|
48 |
|
49 |
$this->shortcode_html .= '<div class="yasr-overall-rating">';
|
50 |
$this->shortcode_html .= $overall_attributes['html_stars'];
|
42 |
|
43 |
$this->shortcode_html = '<!--Yasr Overall Rating Shortcode-->';
|
44 |
|
45 |
+
$this->shortcode_html .= $this->customTextBefore();
|
|
|
|
|
46 |
|
47 |
$this->shortcode_html .= '<div class="yasr-overall-rating">';
|
48 |
$this->shortcode_html .= $overall_attributes['html_stars'];
|
includes/shortcodes/classes/YasrVisitorVotes.php
CHANGED
@@ -54,9 +54,6 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
54 |
* @return string|null
|
55 |
*/
|
56 |
public function returnShortcode() {
|
57 |
-
|
58 |
-
$htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
|
59 |
-
|
60 |
//returns int
|
61 |
$stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
|
62 |
|
@@ -70,23 +67,8 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
70 |
$average_rating=round($average_rating, 1);
|
71 |
|
72 |
//if this come from yasr_visitor_votes_readonly...
|
73 |
-
if ($this->readonly === true || $this->readonly === "yes") {
|
74 |
-
$
|
75 |
-
|
76 |
-
$this->shortcode_html = "<div class='yasr-rater-stars-vv'
|
77 |
-
id='$htmlid'
|
78 |
-
data-rating='$average_rating'
|
79 |
-
data-rater-starsize='".$this->starSize()."'
|
80 |
-
data-rater-postid='$this->post_id'
|
81 |
-
data-rater-readonly='true'
|
82 |
-
data-readonly-attribute='true'
|
83 |
-
data-cpt='$this->post_type'
|
84 |
-
></div>";
|
85 |
-
|
86 |
-
//Use this filter to customize yasr_visitor_votes readonly
|
87 |
-
$this->shortcode_html = apply_filters('yasr_vv_ro_shortcode', $this->shortcode_html, $stored_votes);
|
88 |
-
|
89 |
-
return $this->shortcode_html;
|
90 |
}
|
91 |
|
92 |
$cookie_value = self::checkCookie($this->post_id);
|
@@ -98,12 +80,13 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
98 |
$this->readonly = 'true';
|
99 |
}
|
100 |
|
101 |
-
|
102 |
-
if (YASR_STARS_CUSTOM_TEXT === 1) {
|
103 |
-
$this->shortcode_html .= $this->textBeforeStars($number_of_votes, $average_rating);
|
104 |
-
}
|
105 |
|
106 |
-
$this->shortcode_html
|
|
|
|
|
|
|
|
|
107 |
class='yasr-rater-stars-vv'
|
108 |
data-rater-postid='$this->post_id'
|
109 |
data-rating='$average_rating'
|
@@ -115,7 +98,9 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
115 |
</div>";
|
116 |
|
117 |
$this->shortcode_html .= $this->containerAfterStars($number_of_votes, $average_rating);
|
118 |
-
|
|
|
|
|
119 |
$this->shortcode_html = apply_filters('yasr_vv_shortcode', $this->shortcode_html, $stored_votes);
|
120 |
|
121 |
return $this->returnYasrVisitorVotes($cookie_value, $this->post_id);
|
@@ -123,6 +108,39 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
123 |
} //end function
|
124 |
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
/**
|
127 |
* Function that checks if cookie exists and set the value
|
128 |
*
|
@@ -183,7 +201,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
183 |
public static function showTextBelowStars ($cookie_value, $post_id=false) {
|
184 |
|
185 |
$stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
|
186 |
-
$
|
187 |
$span_bottom_line_content = false;
|
188 |
|
189 |
if ($stars_enabled === 'true_logged' || $stars_enabled === 'false_already_voted') {
|
@@ -216,7 +234,6 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
216 |
|
217 |
}
|
218 |
|
219 |
-
|
220 |
//If only logged in users can vote
|
221 |
elseif ($stars_enabled === 'false_not_logged') {
|
222 |
$span_bottom_line_content = "<span class='yasr-visitor-votes-must-sign-in'>";
|
@@ -227,12 +244,12 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
227 |
}
|
228 |
|
229 |
if($span_bottom_line_content !== false) {
|
230 |
-
$
|
231 |
-
$
|
232 |
-
$
|
233 |
}
|
234 |
|
235 |
-
return $
|
236 |
}
|
237 |
|
238 |
|
@@ -269,18 +286,17 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
269 |
* @return mixed|void $span_text_after_stars
|
270 |
*/
|
271 |
public function containerAfterStars ($number_of_votes, $average_rating) {
|
272 |
-
$
|
273 |
|
274 |
if (YASR_VISITORS_STATS === 'yes') {
|
275 |
-
$
|
276 |
}
|
277 |
|
278 |
-
$
|
279 |
|
280 |
-
$
|
281 |
|
282 |
-
|
283 |
-
return $container_span;
|
284 |
}
|
285 |
|
286 |
/**
|
@@ -290,28 +306,11 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
290 |
* @param $number_of_votes
|
291 |
* @param $average_rating
|
292 |
*
|
293 |
-
* @return string
|
294 |
*/
|
295 |
protected function textAfterStars($number_of_votes, $average_rating) {
|
296 |
-
$
|
297 |
-
|
298 |
-
. ' '
|
299 |
-
. '<span id="yasr-vv-votes-number-container-'. $this->unique_id .'">'
|
300 |
-
. $number_of_votes
|
301 |
-
. '</span>'
|
302 |
-
. ' '
|
303 |
-
. __('Average:', 'yet-another-stars-rating')
|
304 |
-
. ' '
|
305 |
-
. '<span id="yasr-vv-average-container-'. $this->unique_id .'">'
|
306 |
-
. $average_rating
|
307 |
-
. '</span>'
|
308 |
-
. '/5]';
|
309 |
-
|
310 |
-
$custom_text = apply_filters('yasr_cstm_text_after_vv', $default_text, $number_of_votes, $average_rating, $this->unique_id);
|
311 |
-
$default_text = wp_kses_post($custom_text);
|
312 |
-
|
313 |
-
|
314 |
-
return $default_text;
|
315 |
}
|
316 |
|
317 |
|
@@ -327,9 +326,14 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
327 |
public function visitorStats () {
|
328 |
global $yasr_plugin_imported;
|
329 |
|
330 |
-
|
331 |
-
$
|
332 |
-
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
if (is_array($yasr_plugin_imported)) {
|
335 |
$plugin_import_date = null; //avoid undefined
|
@@ -368,21 +372,18 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
368 |
* @return string
|
369 |
*/
|
370 |
protected function returnYasrVisitorVotes ($cookie_value, $post_id) {
|
371 |
-
$div_container_loader = "<div id='yasr-vv-loader-$this->unique_id'
|
372 |
-
class='yasr-vv-container-loader'>";
|
373 |
-
|
374 |
-
$this->shortcode_html .= $div_container_loader;
|
375 |
-
|
376 |
if(YASR_ENABLE_AJAX === 'yes') {
|
377 |
-
$
|
378 |
-
|
379 |
-
|
380 |
-
$this->shortcode_html .= '</div>';
|
381 |
} else {
|
382 |
-
$this->
|
383 |
}
|
384 |
|
385 |
-
$this->shortcode_html .=
|
|
|
|
|
|
|
386 |
$this->shortcode_html .= '</div>'; //close all
|
387 |
$this->shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
|
388 |
|
54 |
* @return string|null
|
55 |
*/
|
56 |
public function returnShortcode() {
|
|
|
|
|
|
|
57 |
//returns int
|
58 |
$stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
|
59 |
|
67 |
$average_rating=round($average_rating, 1);
|
68 |
|
69 |
//if this come from yasr_visitor_votes_readonly...
|
70 |
+
if ($this->readonly === 'true' || $this->readonly === "yes") {
|
71 |
+
return $this->readonlyShortcode($average_rating, $stored_votes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
$cookie_value = self::checkCookie($this->post_id);
|
80 |
$this->readonly = 'true';
|
81 |
}
|
82 |
|
83 |
+
$this->shortcode_html .= $this->textBeforeStars($number_of_votes, $average_rating);
|
|
|
|
|
|
|
84 |
|
85 |
+
$this->shortcode_html .= "<div id='yasr-vv-second-row-container-$this->unique_id'
|
86 |
+
class='yasr-vv-second-row-container'>";
|
87 |
+
|
88 |
+
$stars_htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
|
89 |
+
$this->shortcode_html .= "<div id='$stars_htmlid'
|
90 |
class='yasr-rater-stars-vv'
|
91 |
data-rater-postid='$this->post_id'
|
92 |
data-rating='$average_rating'
|
98 |
</div>";
|
99 |
|
100 |
$this->shortcode_html .= $this->containerAfterStars($number_of_votes, $average_rating);
|
101 |
+
//loader div
|
102 |
+
$this->shortcode_html .= "<div id='yasr-vv-loader-$this->unique_id' class='yasr-vv-container-loader'></div>";
|
103 |
+
$this->shortcode_html .= '</div>'; //close yasr-vv-stars-stats-container
|
104 |
$this->shortcode_html = apply_filters('yasr_vv_shortcode', $this->shortcode_html, $stored_votes);
|
105 |
|
106 |
return $this->returnYasrVisitorVotes($cookie_value, $this->post_id);
|
108 |
} //end function
|
109 |
|
110 |
|
111 |
+
/**
|
112 |
+
* Return YASR VV in read only
|
113 |
+
*
|
114 |
+
* @author Dario Curvino <@dudo>
|
115 |
+
* @since 2.7.4
|
116 |
+
* @param $average_rating
|
117 |
+
* @param $stored_votes
|
118 |
+
*
|
119 |
+
* @return mixed|void
|
120 |
+
*/
|
121 |
+
public function readonlyShortcode ($average_rating, $stored_votes) {
|
122 |
+
$container = '<div id="yasr-vv-stars-stats-container-'.$this->unique_id.'">';
|
123 |
+
|
124 |
+
$htmlid = 'yasr-visitor-votes-readonly-rater-'.$this->unique_id;
|
125 |
+
|
126 |
+
$stars = "<div class='yasr-rater-stars-vv'
|
127 |
+
id='$htmlid'
|
128 |
+
data-rating='$average_rating'
|
129 |
+
data-rater-starsize='".$this->starSize()."'
|
130 |
+
data-rater-postid='$this->post_id'
|
131 |
+
data-rater-readonly='true'
|
132 |
+
data-readonly-attribute='true'
|
133 |
+
data-cpt='$this->post_type'
|
134 |
+
></div>";
|
135 |
+
|
136 |
+
$end_container = '<div>'; //close yasr-vv-stars-stats-container
|
137 |
+
|
138 |
+
$shortcode_html = $container . $stars . $end_container;
|
139 |
+
|
140 |
+
//Use this filter to customize yasr_visitor_votes readonly
|
141 |
+
return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes);
|
142 |
+
}
|
143 |
+
|
144 |
/**
|
145 |
* Function that checks if cookie exists and set the value
|
146 |
*
|
201 |
public static function showTextBelowStars ($cookie_value, $post_id=false) {
|
202 |
|
203 |
$stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
|
204 |
+
$div_bottom_line = false;
|
205 |
$span_bottom_line_content = false;
|
206 |
|
207 |
if ($stars_enabled === 'true_logged' || $stars_enabled === 'false_already_voted') {
|
234 |
|
235 |
}
|
236 |
|
|
|
237 |
//If only logged in users can vote
|
238 |
elseif ($stars_enabled === 'false_not_logged') {
|
239 |
$span_bottom_line_content = "<span class='yasr-visitor-votes-must-sign-in'>";
|
244 |
}
|
245 |
|
246 |
if($span_bottom_line_content !== false) {
|
247 |
+
$div_bottom_line = "<div class='yasr-small-block-bold'>";
|
248 |
+
$div_bottom_line .= $span_bottom_line_content;
|
249 |
+
$div_bottom_line .= '</div>';
|
250 |
}
|
251 |
|
252 |
+
return $div_bottom_line;
|
253 |
}
|
254 |
|
255 |
|
286 |
* @return mixed|void $span_text_after_stars
|
287 |
*/
|
288 |
public function containerAfterStars ($number_of_votes, $average_rating) {
|
289 |
+
$container_div = '<div class="yasr-vv-stats-text-container" id="yasr-vv-stats-text-container-'. $this->unique_id .'">';
|
290 |
|
291 |
if (YASR_VISITORS_STATS === 'yes') {
|
292 |
+
$container_div .= $this->visitorStats();
|
293 |
}
|
294 |
|
295 |
+
$container_div .= $this->textAfterStars($number_of_votes, $average_rating);
|
296 |
|
297 |
+
$container_div .= '</div>';
|
298 |
|
299 |
+
return $container_div;
|
|
|
300 |
}
|
301 |
|
302 |
/**
|
306 |
* @param $number_of_votes
|
307 |
* @param $average_rating
|
308 |
*
|
309 |
+
* @return string
|
310 |
*/
|
311 |
protected function textAfterStars($number_of_votes, $average_rating) {
|
312 |
+
$custom_text = apply_filters('yasr_cstm_text_after_vv', $number_of_votes, $average_rating, $this->unique_id);
|
313 |
+
return wp_kses_post($custom_text);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
}
|
315 |
|
316 |
|
326 |
public function visitorStats () {
|
327 |
global $yasr_plugin_imported;
|
328 |
|
329 |
+
$alt_text = __('Ratings for', 'yet-another-stars-rating');
|
330 |
+
$alt_text .= wp_kses_post(get_the_title($this->post_id));
|
331 |
+
|
332 |
+
$span_dashicon = "<img src='".YASR_IMG_DIR."chart-bar.svg'
|
333 |
+
alt='$alt_text'
|
334 |
+
class='yasr-dashicons-visitor-stats'
|
335 |
+
data-postid='$this->post_id'
|
336 |
+
id='yasr-stats-dashicon-$this->post_id'>";
|
337 |
|
338 |
if (is_array($yasr_plugin_imported)) {
|
339 |
$plugin_import_date = null; //avoid undefined
|
372 |
* @return string
|
373 |
*/
|
374 |
protected function returnYasrVisitorVotes ($cookie_value, $post_id) {
|
|
|
|
|
|
|
|
|
|
|
375 |
if(YASR_ENABLE_AJAX === 'yes') {
|
376 |
+
$container= "<div id='yasr-vv-bottom-container-$this->unique_id'
|
377 |
+
class='yasr-vv-bottom-container'
|
378 |
+
style='display:none'>";
|
|
|
379 |
} else {
|
380 |
+
$container = "<div id='yasr-vv-bottom-container-$this->unique_id' class='yasr-vv-bottom-container'>";
|
381 |
}
|
382 |
|
383 |
+
$this->shortcode_html .= $container;
|
384 |
+
$this->shortcode_html .= self::showTextBelowStars($cookie_value, $post_id);
|
385 |
+
$this->shortcode_html .= '</div>'; //close bottom container
|
386 |
+
|
387 |
$this->shortcode_html .= '</div>'; //close all
|
388 |
$this->shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
|
389 |
|
includes/yasr-includes-functions.php
CHANGED
@@ -207,32 +207,41 @@ function yasr_setcookie($cookiename, $data_to_save) {
|
|
207 |
|
208 |
//sanitize the cookie name
|
209 |
$cookiename = wp_strip_all_tags($cookiename);
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
$existing_data = array(); //avoid undefined index
|
212 |
|
213 |
if (isset($_COOKIE[$cookiename])) {
|
214 |
-
|
215 |
//setcookie add \ , so I need to stripslahes
|
216 |
$existing_data = stripslashes($_COOKIE[$cookiename]);
|
217 |
|
218 |
//By default, json_decode return an object, TRUE to return an array
|
219 |
$existing_data = json_decode($existing_data, true);
|
220 |
-
|
221 |
}
|
222 |
|
223 |
//whetever exists or not, push into at the end of array
|
224 |
$existing_data[] = $data_to_save;
|
225 |
|
226 |
$encoded_data = json_encode($existing_data);
|
|
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
if(defined('DOMAIN_CURRENT_SITE')) {
|
232 |
-
$domain = DOMAIN_CURRENT_SITE;
|
233 |
}
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
}
|
238 |
|
207 |
|
208 |
//sanitize the cookie name
|
209 |
$cookiename = wp_strip_all_tags($cookiename);
|
210 |
+
$domain = COOKIE_DOMAIN;
|
211 |
+
|
212 |
+
//this is for multisite support
|
213 |
+
if(defined('DOMAIN_CURRENT_SITE')) {
|
214 |
+
$domain = DOMAIN_CURRENT_SITE;
|
215 |
+
}
|
216 |
|
217 |
$existing_data = array(); //avoid undefined index
|
218 |
|
219 |
if (isset($_COOKIE[$cookiename])) {
|
|
|
220 |
//setcookie add \ , so I need to stripslahes
|
221 |
$existing_data = stripslashes($_COOKIE[$cookiename]);
|
222 |
|
223 |
//By default, json_decode return an object, TRUE to return an array
|
224 |
$existing_data = json_decode($existing_data, true);
|
|
|
225 |
}
|
226 |
|
227 |
//whetever exists or not, push into at the end of array
|
228 |
$existing_data[] = $data_to_save;
|
229 |
|
230 |
$encoded_data = json_encode($existing_data);
|
231 |
+
$expire = time() + 31536000;
|
232 |
|
233 |
+
if (PHP_VERSION_ID < 70300) {
|
234 |
+
setcookie($cookiename, $encoded_data, $expire, COOKIEPATH . '; samesite=' . 'Lax', $domain, false);
|
235 |
+
return;
|
|
|
|
|
236 |
}
|
237 |
+
setcookie($cookiename, $encoded_data, [
|
238 |
+
'expires' => $expire,
|
239 |
+
'path' => COOKIEPATH,
|
240 |
+
'domain' => $domain,
|
241 |
+
'samesite' => 'Lax',
|
242 |
+
'secure' => false,
|
243 |
+
'httponly' => false,
|
244 |
+
]);
|
245 |
|
246 |
}
|
247 |
|
includes/yasr-includes-init.php
CHANGED
@@ -122,12 +122,6 @@ if(isset($yasr_stored_options['show_visitor_votes_in_loop'])) {
|
|
122 |
define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', null);
|
123 |
}
|
124 |
|
125 |
-
if(isset($yasr_stored_options['text_before_stars'])) {
|
126 |
-
define('YASR_STARS_CUSTOM_TEXT', (int)$yasr_stored_options['text_before_stars']);
|
127 |
-
} else {
|
128 |
-
define('YASR_STARS_CUSTOM_TEXT', null);
|
129 |
-
}
|
130 |
-
|
131 |
if(isset($yasr_stored_options['visitors_stats'])) {
|
132 |
define('YASR_VISITORS_STATS', $yasr_stored_options['visitors_stats']);
|
133 |
} else {
|
@@ -303,10 +297,9 @@ define('YASR_SUPPORTED_SCHEMA_TYPES', $supported_schema_types);
|
|
303 |
define('YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS', $array_item_type_info);
|
304 |
|
305 |
//run includes filters
|
306 |
-
//@todo add all filters that run into includes here
|
307 |
$yasr_includes_filter = new YasrIncludesFilters();
|
308 |
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
122 |
define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', null);
|
123 |
}
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
if(isset($yasr_stored_options['visitors_stats'])) {
|
126 |
define('YASR_VISITORS_STATS', $yasr_stored_options['visitors_stats']);
|
127 |
} else {
|
297 |
define('YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS', $array_item_type_info);
|
298 |
|
299 |
//run includes filters
|
|
|
300 |
$yasr_includes_filter = new YasrIncludesFilters();
|
301 |
|
302 |
+
$yasr_includes_filter->filterCustomTexts($yasr_stored_options);
|
303 |
+
|
304 |
+
//support for caching plugins
|
305 |
+
$yasr_includes_filter->cachingPluginSupport();
|
public/classes/YasrRichSnippetAdditionalFields.php
CHANGED
@@ -103,23 +103,16 @@ class YasrRichSnippetAdditionalFields {
|
|
103 |
}
|
104 |
|
105 |
private function recipe($saved_data) {
|
106 |
-
|
107 |
$instruction_array_clean = array();
|
108 |
$ingredient_array = array();
|
109 |
|
110 |
if(!empty($saved_data['yasr_recipe_recipeinstructions'])) {
|
111 |
$instruction_array = explode(PHP_EOL, $saved_data['yasr_recipe_recipeinstructions']);
|
112 |
$i=0;
|
113 |
-
$j=1;
|
114 |
foreach ($instruction_array as $instrunction) {
|
115 |
$instruction_array_clean[$i]['@type'] = "HowToStep";
|
116 |
-
$instruction_array_clean[$i][
|
117 |
-
'@type' => 'ListItem',
|
118 |
-
'position' => $j,
|
119 |
-
'name' => $instrunction
|
120 |
-
);
|
121 |
$i++;
|
122 |
-
$j++;
|
123 |
}
|
124 |
}
|
125 |
|
103 |
}
|
104 |
|
105 |
private function recipe($saved_data) {
|
|
|
106 |
$instruction_array_clean = array();
|
107 |
$ingredient_array = array();
|
108 |
|
109 |
if(!empty($saved_data['yasr_recipe_recipeinstructions'])) {
|
110 |
$instruction_array = explode(PHP_EOL, $saved_data['yasr_recipe_recipeinstructions']);
|
111 |
$i=0;
|
|
|
112 |
foreach ($instruction_array as $instrunction) {
|
113 |
$instruction_array_clean[$i]['@type'] = "HowToStep";
|
114 |
+
$instruction_array_clean[$i]['text'] = $instrunction;
|
|
|
|
|
|
|
|
|
115 |
$i++;
|
|
|
116 |
}
|
117 |
}
|
118 |
|
public/yasr-public-actions.php
CHANGED
@@ -32,8 +32,6 @@ function yasr_add_scripts() {
|
|
32 |
YASR_VERSION_NUM
|
33 |
);
|
34 |
|
35 |
-
wp_enqueue_style('dashicons'); //dashicons
|
36 |
-
|
37 |
//Run after default css are loaded
|
38 |
do_action('yasr_add_front_script_css');
|
39 |
|
@@ -54,31 +52,4 @@ function yasr_add_scripts() {
|
|
54 |
|
55 |
do_action('yasr_add_front_script_js');
|
56 |
|
57 |
-
}
|
58 |
-
|
59 |
-
//Delete caches for supported plugins
|
60 |
-
//Can't use is_singular() here because always return false
|
61 |
-
add_action('yasr_action_on_visitor_vote', 'yasr_delete_cache');
|
62 |
-
add_action('yasr_action_on_visitor_multiset_vote', 'yasr_delete_cache');
|
63 |
-
|
64 |
-
function yasr_delete_cache($array_action_visitor_vote) {
|
65 |
-
|
66 |
-
if (isset($array_action_visitor_vote['post_id'])) {
|
67 |
-
$post_id = $array_action_visitor_vote['post_id'];
|
68 |
-
} else {
|
69 |
-
return;
|
70 |
-
}
|
71 |
-
|
72 |
-
if (isset($array_action_visitor_vote['is_singular'])) {
|
73 |
-
$is_singular = $array_action_visitor_vote['is_singular'];
|
74 |
-
} else {
|
75 |
-
return;
|
76 |
-
}
|
77 |
-
|
78 |
-
yasr_wp_super_cache_support($post_id);
|
79 |
-
yasr_wp_rocket_support($post_id);
|
80 |
-
yasr_litespeed_cache_support($post_id);
|
81 |
-
yasr_cache_enabler_support($post_id, $is_singular);
|
82 |
-
yasr_wp_fastest_cache($post_id, $is_singular);
|
83 |
-
|
84 |
}
|
32 |
YASR_VERSION_NUM
|
33 |
);
|
34 |
|
|
|
|
|
35 |
//Run after default css are loaded
|
36 |
do_action('yasr_add_front_script_css');
|
37 |
|
52 |
|
53 |
do_action('yasr_add_front_script_js');
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
public/yasr-public-functions.php
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
|
4 |
-
Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
|
5 |
-
|
6 |
-
This program is free software: you can redistribute it and/or modify
|
7 |
-
it under the terms of the GNU General Public License as published by
|
8 |
-
the Free Software Foundation, either version 2 of the License, or
|
9 |
-
(at your option) any later version.
|
10 |
-
|
11 |
-
This program is distributed in the hope that it will be useful,
|
12 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
-
GNU General Public License for more details.
|
15 |
-
|
16 |
-
You should have received a copy of the GNU General Public License
|
17 |
-
along with this program. If not, see <http://www.gnu.org/licenses/>
|
18 |
-
*/
|
19 |
-
|
20 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
21 |
-
exit( 'You\'re not allowed to see this page' );
|
22 |
-
} // Exit if accessed directly
|
23 |
-
|
24 |
-
|
25 |
-
/*** Add support for wp super cache ***/
|
26 |
-
function yasr_wp_super_cache_support($post_id) {
|
27 |
-
if (function_exists('wp_cache_post_change')) {
|
28 |
-
wp_cache_post_change($post_id);
|
29 |
-
}
|
30 |
-
}
|
31 |
-
|
32 |
-
/*** Add support for wp rocket, thanks to GeekPress
|
33 |
-
* https://wordpress.org/support/topic/compatibility-with-wp-rocket-2
|
34 |
-
***/
|
35 |
-
function yasr_wp_rocket_support($post_id) {
|
36 |
-
if (function_exists('rocket_clean_post')) {
|
37 |
-
rocket_clean_post($post_id);
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
/*** Add support for LiteSpeed Cache plugin, thanks to Pako69
|
42 |
-
* https://wordpress.org/support/topic/yasr-is-litespeed-cache-plugin-compatible/
|
43 |
-
***/
|
44 |
-
function yasr_litespeed_cache_support($post_id) {
|
45 |
-
if(class_exists('LiteSpeed_Cache_API')) {
|
46 |
-
if (method_exists('LiteSpeed_Cache_API', 'purge_post')) {
|
47 |
-
LiteSpeed_Cache_API::purge_post($post_id);
|
48 |
-
}
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
/*** Add support for cache enabler ***/
|
53 |
-
function yasr_cache_enabler_support($post_id, $is_singular) {
|
54 |
-
if (has_action('ce_clear_cache') || has_action('ce_clear_post_cache')) {
|
55 |
-
//IF is in the single post or page delete only that cache
|
56 |
-
if ($is_singular === 'true') {
|
57 |
-
do_action('ce_clear_post_cache', $post_id);
|
58 |
-
} //otherwise, delete everything
|
59 |
-
else {
|
60 |
-
do_action('ce_clear_cache');
|
61 |
-
}
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
|
66 |
-
/**** Add support for Wp Fastest Cache ****/
|
67 |
-
function yasr_wp_fastest_cache($post_id, $is_singular) {
|
68 |
-
if ($is_singular === 'true') {
|
69 |
-
if (isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'singleDeleteCache')) {
|
70 |
-
$GLOBALS['wp_fastest_cache']->singleDeleteCache(false, $post_id);
|
71 |
-
}
|
72 |
-
} else {
|
73 |
-
if (isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) {
|
74 |
-
$GLOBALS['wp_fastest_cache']->deleteCache();
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/yasr-public-init.php
CHANGED
@@ -26,7 +26,6 @@ define('YASR_JS_DIR_PUBLIC', plugins_url() . '/' . YASR_RELATIVE_PATH_PUBLIC . '
|
|
26 |
//CSS directory absolute URL
|
27 |
define('YASR_CSS_DIR_PUBLIC', plugins_url() . '/' . YASR_RELATIVE_PATH_PUBLIC . '/css/');
|
28 |
|
29 |
-
require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-functions.php';
|
30 |
require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-actions.php';
|
31 |
|
32 |
/**
|
26 |
//CSS directory absolute URL
|
27 |
define('YASR_CSS_DIR_PUBLIC', plugins_url() . '/' . YASR_RELATIVE_PATH_PUBLIC . '/css/');
|
28 |
|
|
|
29 |
require YASR_ABSOLUTE_PATH_PUBLIC . '/yasr-public-actions.php';
|
30 |
|
31 |
/**
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Requires at least: 5.0
|
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 5.4
|
8 |
-
Stable tag: 2.7.
|
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
|
@@ -192,6 +192,15 @@ If doesn't, you should work on your seo reputation.
|
|
192 |
|
193 |
The full changelog can be found in the plugin's directory. Recent entries:
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
= 2.7.3 =
|
196 |
* NEW FEATURE: new shortcode: yasr_multi_set_ranking : this will show rankings from yasr_multiset
|
197 |
* TWEAKED: code cleanup.
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 5.4
|
8 |
+
Stable tag: 2.7.4
|
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
|
192 |
|
193 |
The full changelog can be found in the plugin's directory. Recent entries:
|
194 |
|
195 |
+
= 2.7.4 =
|
196 |
+
* TWEAKED: in front end, dashicons are not required anymore!
|
197 |
+
* TWEAKED: Vertical align of text and stars on yasr_visitor_votes shortcode.
|
198 |
+
The class yasr-total-average-container has be renamed yasr-vv-stats-text-container.
|
199 |
+
* TWEAKED: Custom texts support.
|
200 |
+
* TWEAKED: Updated support for Autoptimize, Litespeed, Cache Enabler and WpRocket.
|
201 |
+
* TWEAKED: Removed "itemListElement" from Recipe microdata.
|
202 |
+
* TWEAKED: added samesite attribute when cookie is set.
|
203 |
+
|
204 |
= 2.7.3 =
|
205 |
* NEW FEATURE: new shortcode: yasr_multi_set_ranking : this will show rankings from yasr_multiset
|
206 |
* TWEAKED: code cleanup.
|
yet-another-stars-rating.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
-
* Version: 2.7.
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
@@ -76,7 +76,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
76 |
yasr_fs();
|
77 |
// Signal that SDK was initiated.
|
78 |
do_action( 'yasr_fs_loaded' );
|
79 |
-
define( 'YASR_VERSION_NUM', '2.7.
|
80 |
//Plugin absolute path
|
81 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
82 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
+
* Version: 2.7.4
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
76 |
yasr_fs();
|
77 |
// Signal that SDK was initiated.
|
78 |
do_action( 'yasr_fs_loaded' );
|
79 |
+
define( 'YASR_VERSION_NUM', '2.7.4' );
|
80 |
//Plugin absolute path
|
81 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
82 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|