Version Description
- NEW FEATURE: is now possible to customize the itemType Name: if empty, post title will be used instead-
- TWEAKED: Custom text to show when an user has already voted now shows up even for logged in users
- TWEAKED: Added new hooks: yasr_filter_schema_title and yasr_below_panel (for gutenberg)
- TWEAKED: admin .js files are now bundled into a single one
- TWEAKED: support for IE11 (will be dropped in 12 months)
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 2.4.0 |
Comparing to | |
See all releases |
Code changes from version 2.3.9 to 2.4.0
- admin/editor/YasrOnSavePost.php +1 -1
- admin/editor/yasr-editor-functions.php +5 -14
- admin/editor/yasr-metabox-schema.php +17 -2
- admin/js/src/guten/yasr-guten-panel.js +9 -2
- admin/js/yasr-gutenberg.js +1 -0
- admin/settings/yasr-settings-functions.php +3 -3
- changelog.txt +1 -1
- includes/js/src/yasr-front.js +11 -2
- includes/js/yasr-front.js +1 -1
- includes/shortcodes/classes/YasrVisitorVotes.php +30 -26
- includes/yasr-includes-init.php +1 -0
- public/classes/YasrRichSnippetAdditionalFields.php +32 -13
- public/yasr-public-filters.php +133 -126
- public/yasr-public-init.php +1 -1
- readme.txt +9 -1
- yet-another-stars-rating.php +2 -2
admin/editor/YasrOnSavePost.php
CHANGED
@@ -146,7 +146,7 @@ class YasrOnSavePost {
|
|
146 |
}
|
147 |
|
148 |
private function saveItemTypesFields() {
|
149 |
-
$array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS);
|
150 |
$array_to_save = array();
|
151 |
|
152 |
foreach ($array_item_type_info as $item_type_name) {
|
146 |
}
|
147 |
|
148 |
private function saveItemTypesFields() {
|
149 |
+
$array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true);
|
150 |
$array_to_save = array();
|
151 |
|
152 |
foreach ($array_item_type_info as $item_type_name) {
|
admin/editor/yasr-editor-functions.php
CHANGED
@@ -29,25 +29,16 @@ function yasr_gutenberg_scripts() {
|
|
29 |
|
30 |
//Script
|
31 |
wp_enqueue_script(
|
32 |
-
'
|
33 |
-
YASR_JS_DIR_ADMIN . 'yasr-
|
34 |
array(
|
35 |
-
'wp-i18n',
|
36 |
'wp-blocks',
|
37 |
'wp-components',
|
38 |
-
'wp-element',
|
39 |
'wp-editor',
|
40 |
-
)
|
41 |
-
);
|
42 |
-
|
43 |
-
wp_enqueue_script(
|
44 |
-
'yasr_guten_panel',
|
45 |
-
YASR_JS_DIR_ADMIN . 'yasr-guten-panel.js',
|
46 |
-
array(
|
47 |
-
'wp-plugins',
|
48 |
'wp-edit-post',
|
49 |
'wp-element',
|
50 |
-
'wp-
|
|
|
51 |
)
|
52 |
);
|
53 |
|
@@ -73,7 +64,7 @@ add_action('yasr_add_admin_scripts_end', 'yasr_add_js_constant_gutenberg');
|
|
73 |
function yasr_add_js_constant_gutenberg($hook) {
|
74 |
|
75 |
if ($hook === 'post.php' || $hook === 'post-new.php') {
|
76 |
-
if (YASR_AUTO_INSERT_ENABLED
|
77 |
$auto_insert = YASR_AUTO_INSERT_WHAT;
|
78 |
} else {
|
79 |
$auto_insert = 'disabled';
|
29 |
|
30 |
//Script
|
31 |
wp_enqueue_script(
|
32 |
+
'yasr-gutenberg',
|
33 |
+
YASR_JS_DIR_ADMIN . 'yasr-gutenberg.js',
|
34 |
array(
|
|
|
35 |
'wp-blocks',
|
36 |
'wp-components',
|
|
|
37 |
'wp-editor',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
'wp-edit-post',
|
39 |
'wp-element',
|
40 |
+
'wp-i18n',
|
41 |
+
'wp-plugins',
|
42 |
)
|
43 |
);
|
44 |
|
64 |
function yasr_add_js_constant_gutenberg($hook) {
|
65 |
|
66 |
if ($hook === 'post.php' || $hook === 'post-new.php') {
|
67 |
+
if (YASR_AUTO_INSERT_ENABLED === 1) {
|
68 |
$auto_insert = YASR_AUTO_INSERT_WHAT;
|
69 |
} else {
|
70 |
$auto_insert = 'disabled';
|
admin/editor/yasr-metabox-schema.php
CHANGED
@@ -40,7 +40,7 @@ if(empty($saved_data)) {
|
|
40 |
$saved_data = array();
|
41 |
}
|
42 |
|
43 |
-
$array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS);
|
44 |
|
45 |
//foreach every supported element, create a nonce field
|
46 |
//and set single element to false if not present in db to avoid undefined
|
@@ -75,11 +75,26 @@ $itemType_obj = new YasrMetaboxSchemaFields($saved_data);
|
|
75 |
<span class="yasr-onoffswitch-switch"></span>
|
76 |
</label>
|
77 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
</div>
|
79 |
|
80 |
<p>
|
81 |
<div class="yasr-choose-reviews-types">
|
82 |
-
<?php _e(
|
83 |
<br />
|
84 |
<?php yasr_select_itemtype('yasr-metabox-below-editor-select-schema'); ?>
|
85 |
</div>
|
40 |
$saved_data = array();
|
41 |
}
|
42 |
|
43 |
+
$array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true);
|
44 |
|
45 |
//foreach every supported element, create a nonce field
|
46 |
//and set single element to false if not present in db to avoid undefined
|
75 |
<span class="yasr-onoffswitch-switch"></span>
|
76 |
</label>
|
77 |
</div>
|
78 |
+
|
79 |
+
<div style="margin-top: 10px;">
|
80 |
+
<label for="yasr-schema-title" style="display:block;"><?php _e('ItemType Name') ?></label>
|
81 |
+
<input
|
82 |
+
type="text"
|
83 |
+
id="yasr-schema-title"
|
84 |
+
name="yasr_schema_title"
|
85 |
+
placeholder="<?php echo wp_strip_all_tags(get_the_title()) ?>"
|
86 |
+
value="<?php echo $saved_data['yasr_schema_title'] ?>"
|
87 |
+
>
|
88 |
+
</div>
|
89 |
+
<div class="yasr-itemtype-row-container-description">
|
90 |
+
<?php _e('Optional. If empty, post title will be used instead.', 'yet-another-stars-rating') ?>
|
91 |
+
</div>
|
92 |
+
|
93 |
</div>
|
94 |
|
95 |
<p>
|
96 |
<div class="yasr-choose-reviews-types">
|
97 |
+
<?php _e('Select ItemType', 'yet-another-stars-rating'); ?>
|
98 |
<br />
|
99 |
<?php yasr_select_itemtype('yasr-metabox-below-editor-select-schema'); ?>
|
100 |
</div>
|
admin/js/src/guten/yasr-guten-panel.js
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
const {registerPlugin} = wp.plugins;
|
2 |
const {PluginSidebar, PluginSidebarMoreMenuItem} = wp.editPost;
|
3 |
const {TextControl, PanelBody, PanelRow} = wp.components;
|
@@ -261,6 +266,8 @@ class yasrSidebar extends React.Component {
|
|
261 |
}
|
262 |
|
263 |
render() {
|
|
|
|
|
264 |
return (
|
265 |
<Fragment>
|
266 |
<PluginSidebarMoreMenuItem name="yasr-sidebar" type="sidebar" target="yasr-guten-sidebar" >
|
@@ -270,8 +277,8 @@ class yasrSidebar extends React.Component {
|
|
270 |
<PanelBody>
|
271 |
<div className="yasr-guten-block-panel yasr-guten-block-panel-center">
|
272 |
<YasrDivRatingOverall />
|
273 |
-
{this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
|
274 |
-
{
|
275 |
</div>
|
276 |
</PanelBody>
|
277 |
</PluginSidebar>
|
1 |
+
//import ReviewsInComments from '../../../../yasr_pro/js/src/guten/yasr-pro-guten-panel'
|
2 |
+
|
3 |
+
import {createHooks} from '@wordpress/hooks';
|
4 |
+
|
5 |
+
const {__} = wp.i18n; // Import __() from wp.i18n
|
6 |
const {registerPlugin} = wp.plugins;
|
7 |
const {PluginSidebar, PluginSidebarMoreMenuItem} = wp.editPost;
|
8 |
const {TextControl, PanelBody, PanelRow} = wp.components;
|
266 |
}
|
267 |
|
268 |
render() {
|
269 |
+
let YasrBelowSidebar = [<ContentBelowSidebar key={0}/>];
|
270 |
+
{wp.hooks.doAction('yasr_below_panel', YasrBelowSidebar)}
|
271 |
return (
|
272 |
<Fragment>
|
273 |
<PluginSidebarMoreMenuItem name="yasr-sidebar" type="sidebar" target="yasr-guten-sidebar" >
|
277 |
<PanelBody>
|
278 |
<div className="yasr-guten-block-panel yasr-guten-block-panel-center">
|
279 |
<YasrDivRatingOverall />
|
280 |
+
{this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert />}
|
281 |
+
{YasrBelowSidebar}
|
282 |
</div>
|
283 |
</PanelBody>
|
284 |
</PluginSidebar>
|
admin/js/yasr-gutenberg.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),e.exports=r(2)},function(e,t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=i(e);if(t){var a=i(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return s(this,r)}}function s(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=wp.i18n.__,c=wp.blocks.registerBlockType,u=wp.components,y=u.PanelBody,h=(u.PanelRow,wp.element.Fragment),f=wp.editor,d=(f.BlockControls,f.InspectorControls),m=l("All these settings are optional","yet-another-stars-rating"),p=l("Choose Size","yet-another-stars-rating"),g=l("Choose stars size","yet-another-stars-rating"),v=l("Small","yet-another-stars-rating"),b=l("Medium","yet-another-stars-rating"),R=l("Large","yet-another-stars-rating"),_=l("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),E=l("Remember: only the post author can rate here.","yet-another-stars-rating"),w=l("This is the star set where your users will be able to vote","yet-another-stars-rating");function k(){var e=l("To be able to customize this ranking, you need","yet-another-stars-rating"),t=l("You can buy the plugin, including one year of support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function A(e){return React.createElement(d,null,React.createElement(y,{title:"Settings"},React.createElement(k,null)))}c("yet-another-stars-rating/yasr-overall-rating",{title:l("Yasr: Overall Rating","yet-another-stars-rating"),description:l("Insert the author rating",""),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("rating","yet-another-stars-rating"),l("author","yet-another-stars-rating"),l("overall","yet-another-stars-rating")],attributes:{overallRatingMeta:{type:"number",source:"meta",meta:"yasr_overall_rating"},size:{type:"string",default:"--"},postId:{type:"number",default:""}},edit:function(e){var t,r=e.attributes,s=r.overallRatingMeta,i=r.size,c=r.postId,u=e.setAttributes,f=e.isSelected,w=s,k=null,A=null;"--"!==i&&(k=' size="'+i+'"'),t=/^\d+$/.test(c),c&&!0===t&&(A=' postid="'+c+'"');var O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(c,React.Component);var t,r,s,i=o(c);function c(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(t=i.call(this,e)).yasrOverallRateThis=l("Rate this article / item","yet-another-stars-rating"),t}return t=c,(r=[{key:"render",value:function(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,React.createElement("div",{id:"overall-rater",ref:function(){return raterJs({starSize:32,step:.1,showToolTip:!1,rating:w,readOnly:!1,element:document.querySelector("#overall-rater"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),u({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&n(t.prototype,r),s&&n(t,s),c}();function P(){return React.createElement("form",null,React.createElement("select",{value:i,onChange:S},React.createElement("option",{value:"--"},g),React.createElement("option",{value:"small"},v),React.createElement("option",{value:"medium"},b),React.createElement("option",{value:"large"},R)))}function S(e){var t=e.target.querySelector("option:checked");u({size:t.value}),e.preventDefault()}function I(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:T}))}function T(e){if("Enter"===e.key){var t=e.target.value;!0===/^\d+$/.test(t)&&u({postId:t}),e.preventDefault()}}function x(e){return React.createElement(d,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(O,null)),React.createElement(y,{title:"Settings"},React.createElement("h3",null,m),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(P,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(I,null),React.createElement("div",{className:"yasr-guten-block-explain"},_)),React.createElement("div",{className:"yasr-guten-block-panel"},E)))}return React.createElement(h,null,React.createElement(x,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",k,A,"]",f&&React.createElement(P,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a=null;return r&&(a+=' size="'+r+'"'),n&&(a+=' postid="'+n+'"'),React.createElement("div",null,"[yasr_overall_rating ",a,"]")}}),c("yet-another-stars-rating/yasr-visitor-votes",{title:l("Yasr: Visitor Votes","yet-another-stars-rating"),description:l("Insert the ability for your visitors to vote","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("rating","yet-another-stars-rating"),l("visitor","yet-another-stars-rating"),l("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"--"},postId:{type:"number",default:""}},edit:function(e){var t,r=e.attributes,n=r.size,a=r.postId,o=e.setAttributes,s=e.isSelected,i=null,l=null;function c(){return React.createElement("form",null,React.createElement("select",{value:n,onChange:u},React.createElement("option",{value:"--"},g),React.createElement("option",{value:"small"},v),React.createElement("option",{value:"medium"},b),React.createElement("option",{value:"large"},R)))}function u(e){var t=e.target.querySelector("option:checked");o({size:t.value}),e.preventDefault()}function f(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:E}))}function E(e){if("Enter"===e.key){var t=e.target.value;!0===/^\d+$/.test(t)&&o({postId:t}),e.preventDefault()}}function k(e){return React.createElement(d,null,React.createElement(y,{title:"Settings"},React.createElement("h3",null,m),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,p),React.createElement("div",null,React.createElement(c,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(f,null),React.createElement("div",{className:"yasr-guten-block-explain"},_)),React.createElement("div",{className:"yasr-guten-block-panel"},w)))}return t=/^\d+$/.test(a),"--"!==n&&(i=' size="'+n+'"'),a&&!0===t&&(l=' postid="'+a+'"'),React.createElement(h,null,React.createElement(k,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",i,l,"]",s&&React.createElement(c,null)))},save:function(e){var t=e.attributes,r=t.size,n=t.postId,a=null;return r&&(a+=' size="'+r+'"'),n&&(a+=' postid="'+n+'"'),React.createElement("div",null,"[yasr_visitor_votes ",a,"]")}}),c("yet-another-stars-rating/overall-rating-ranking",{title:l("Yasr: Top 10 Reviews","yet-another-stars-rating"),description:l("This ranking shows the highest rated posts rated through the overall_rating shortcode.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("chart","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,null),React.createElement("div",{className:e.className},"[yasr_top_ten_highest_rated]"))},save:function(e){return React.createElement("div",null,"[yasr_top_ten_highest_rated]")}}),c("yet-another-stars-rating/visitor-votes-ranking",{title:l("Yasr: Top 10 By Visitors Votes","yet-another-stars-rating"),description:l("This ranking shows both the highest and most rated posts rated through the yasr_visitor_votes shortcode. For an item to appear in this chart, it has to be rated at least twice. ","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,null),React.createElement("div",{className:e.className},"[yasr_most_or_highest_rated_posts]"))},save:function(e){return React.createElement("div",null,"[yasr_most_or_highest_rated_posts]")}}),c("yet-another-stars-rating/most-active-reviewers",{title:l("Yasr: Most Active Authors","yet-another-stars-rating"),description:l("This ranking shows the 5 most active reviewers on your site.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating"),l("authors","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,null),React.createElement("div",{className:e.className},"[yasr_top_5_reviewers]"))},save:function(e){return React.createElement("div",null,"[yasr_top_5_reviewers]")}}),c("yet-another-stars-rating/most-active-users",{title:l("Yasr: Most Active Visitors","yet-another-stars-rating"),description:l("This ranking shows the 10 most active users, displaying the login name if logged in or “Anonymous” if not.","yet-another-stars-rating"),icon:"star-half",category:"yet-another-stars-rating",keywords:[l("ranking","yet-another-stars-rating"),l("highest","yet-another-stars-rating"),l("most","yet-another-stars-rating"),l("chart","yet-another-stars-rating"),l("visitors","yet-another-stars-rating")],edit:function(e){return React.createElement(h,null,React.createElement(A,null),React.createElement("div",{className:e.className},"[yasr_top_ten_active_users]"))},save:function(e){return React.createElement("div",null,"[yasr_top_ten_active_users]")}})},function(e,t,r){"use strict";r.r(t);var n=function(e){return"string"!=typeof e||""===e?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)};var a=function(e){return"string"!=typeof e||""===e?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(e)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)};var o=function(e){return function(t,r,o){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10;if(a(t)&&n(r))if("function"==typeof o)if("number"==typeof s){var i={callback:o,priority:s,namespace:r};if(e[t]){var l,c=e[t].handlers;for(l=c.length;l>0&&!(s>=c[l-1].priority);l--);l===c.length?c[l]=i:c.splice(l,0,i),(e.__current||[]).forEach((function(e){e.name===t&&e.currentIndex>=l&&e.currentIndex++}))}else e[t]={handlers:[i],runs:0};"hookAdded"!==t&&f("hookAdded",t,r,o,s)}else console.error("If specified, the hook priority must be a number.");else console.error("The hook callback must be a function.")}};var s=function(e,t){return function(r,o){if(a(r)&&(t||n(o))){if(!e[r])return 0;var s=0;if(t)s=e[r].handlers.length,e[r]={runs:e[r].runs,handlers:[]};else for(var i=e[r].handlers,l=function(t){i[t].namespace===o&&(i.splice(t,1),s++,(e.__current||[]).forEach((function(e){e.name===r&&e.currentIndex>=t&&e.currentIndex--})))},c=i.length-1;c>=0;c--)l(c);return"hookRemoved"!==r&&f("hookRemoved",r,o),s}}};var i=function(e){return function(t,r){return void 0!==r?t in e&&e[t].handlers.some((function(e){return e.namespace===r})):t in e}};var l=function(e,t){return function(r){e[r]||(e[r]={handlers:[],runs:0}),e[r].runs++;var n=e[r].handlers;for(var a=arguments.length,o=new Array(a>1?a-1:0),s=1;s<a;s++)o[s-1]=arguments[s];if(!n||!n.length)return t?o[0]:void 0;var i={name:r,currentIndex:0};for(e.__current.push(i);i.currentIndex<n.length;){var l=n[i.currentIndex],c=l.callback.apply(null,o);t&&(o[0]=c),i.currentIndex++}return e.__current.pop(),t?o[0]:void 0}};var c=function(e){return function(){return e.__current&&e.__current.length?e.__current[e.__current.length-1].name:null}};var u=function(e){return function(t){return void 0===t?void 0!==e.__current[0]:!!e.__current[0]&&t===e.__current[0].name}};var y=function(e){return function(t){if(a(t))return e[t]&&e[t].runs?e[t].runs:0}};var h=function(){var e=Object.create(null),t=Object.create(null);return e.__current=[],t.__current=[],{addAction:o(e),addFilter:o(t),removeAction:s(e),removeFilter:s(t),hasAction:i(e),hasFilter:i(t),removeAllActions:s(e,!0),removeAllFilters:s(t,!0),doAction:l(e),applyFilters:l(t,!0),currentAction:c(e),currentFilter:c(t),doingAction:u(e),doingFilter:u(t),didAction:y(e),didFilter:y(t),actions:e,filters:t}}(),f=(h.addAction,h.addFilter,h.removeAction,h.removeFilter,h.hasAction,h.hasFilter,h.removeAllActions,h.removeAllFilters,h.doAction);h.applyFilters,h.currentAction,h.currentFilter,h.doingAction,h.doingFilter,h.didAction,h.didFilter,h.actions,h.filters;function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function g(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),e}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function R(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=w(e);if(t){var a=w(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return _(this,r)}}function _(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?E(e):t}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=wp.i18n.__,A=wp.plugins.registerPlugin,O=wp.editPost,P=O.PluginSidebar,S=O.PluginSidebarMoreMenuItem,I=wp.components,T=(I.TextControl,I.PanelBody),x=(I.PanelRow,wp.editor),N=(x.BlockControls,x.InspectorControls,wp.element.Fragment),F=k("Disable auto insert for this post or page?","yet-another-stars-rating"),j=(k("Rich snippet options","yet-another-stars-rating"),k("Is this a review?","yet-another-stars-rating"),k("Select ItemType ","yet-another-stars-rating"),function(){return React.createElement("div",null)}),z=function(e){v(r,React.Component);var t=R(r);function r(e){var n;return m(this,r),(n=t.call(this,e)).yasrOverallRateThis=k("Rate this article / item","yet-another-stars-rating"),n.yasrOverallMoreInfo=k('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating"),n}return g(r,[{key:"shouldComponentUpdate",value:function(e,t){return!1}}]),g(r,[{key:"printDivOverallRater",value:function(){return React.createElement("div",null,React.createElement("div",{id:"overall-rater-panel",ref:function(){return raterJs({starSize:32,step:.1,showToolTip:!1,rating:wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,readOnly:!1,element:document.querySelector("#overall-rater-panel"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()}})}}),React.createElement("br",null),this.yasrOverallMoreInfo)}},{key:"render",value:function(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,this.printDivOverallRater()))}}]),r}(),C=function(e){v(r,React.Component);var t=R(r);function r(e){var n;m(this,r),n=t.call(this,e);var a=!1;return"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(a=!0),n.state={postExcluded:a},n.yasrUpdatePostMetaAutoInsert=n.yasrUpdatePostMetaAutoInsert.bind(E(n)),n}return g(r,[{key:"yasrUpdatePostMetaAutoInsert",value:function(e){var t=e.target,r="checkbox"===t.type?t.checked:t.value;this.setState({postExcluded:r}),!0===r?wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"yes"}}):wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"no"}})}},{key:"render",value:function(){return React.createElement("div",{className:"yasr-guten-block-panel-center"},React.createElement("hr",null),React.createElement("label",null,React.createElement("span",null,F)),React.createElement("div",{className:"yasr-onoffswitch-big yasr-onoffswitch-big-center",id:"yasr-switcher-disable-auto-insert"},React.createElement("input",{type:"checkbox",name:"yasr_auto_insert_disabled",className:"yasr-onoffswitch-checkbox",value:"yes",id:"yasr-auto-insert-disabled-switch",defaultChecked:this.state.postExcluded,onChange:this.yasrUpdatePostMetaAutoInsert}),React.createElement("label",{className:"yasr-onoffswitch-label",htmlFor:"yasr-auto-insert-disabled-switch"},React.createElement("span",{className:"yasr-onoffswitch-inner"}),React.createElement("span",{className:"yasr-onoffswitch-switch"}))))}}]),r}(),M=function(e){v(r,React.Component);var t=R(r);function r(e){var n;m(this,r),n=t.call(this,e);var a=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(a=!0),n.state={yasrAutoInsertEnabled:a},n}return g(r,[{key:"render",value:function(){var e=[React.createElement(j,{key:0})];return wp.hooks.doAction("yasr_below_panel",e),React.createElement(N,null,React.createElement(S,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},k("YASR post settings","yet-another-stars-rating")),React.createElement(P,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(T,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(z,null),this.state.yasrAutoInsertEnabled&&React.createElement(C,null),e))))}}]),r}();A("yasr-sidebar",{icon:"star-half",title:k("Yasr: Page Settings","yet-another-stars-rating"),render:M})}]);
|
admin/settings/yasr-settings-functions.php
CHANGED
@@ -54,8 +54,8 @@ function yasr_general_options_init() {
|
|
54 |
__('[Total: %s Average: %s]', 'yet-another-stars-rating'),
|
55 |
'%total_count%', '%average%'
|
56 |
);
|
57 |
-
$option['custom_text_user_voted'] = __('You
|
58 |
-
$option['custom_text_must_sign_in'] = __('You
|
59 |
}
|
60 |
|
61 |
|
@@ -387,7 +387,7 @@ function yasr_custom_text_callback($option) {
|
|
387 |
id="yasr-general-options-custom-text-already-rated"
|
388 |
class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_user_votes); ?>
|
389 |
maxlength="60"/>
|
390 |
-
<?php _e('Custom text to display when
|
391 |
</label>
|
392 |
|
393 |
<br/> <br/>
|
54 |
__('[Total: %s Average: %s]', 'yet-another-stars-rating'),
|
55 |
'%total_count%', '%average%'
|
56 |
);
|
57 |
+
$option['custom_text_user_voted'] = __('You have already voted for this article', 'yet-another-stars-rating');
|
58 |
+
$option['custom_text_must_sign_in'] = __('You must sign in to vote', 'yet-another-stars-rating');
|
59 |
}
|
60 |
|
61 |
|
387 |
id="yasr-general-options-custom-text-already-rated"
|
388 |
class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_user_votes); ?>
|
389 |
maxlength="60"/>
|
390 |
+
<?php _e('Custom text to display when an user has already rated', 'yet-another-stars-rating') ?>
|
391 |
</label>
|
392 |
|
393 |
<br/> <br/>
|
changelog.txt
CHANGED
@@ -486,7 +486,7 @@ A database backup is strongly suggested.
|
|
486 |
|
487 |
= 0.9.3 =
|
488 |
* NEW FEATURE: wp rocket support, thanks to geek press
|
489 |
-
* FIXED: missing filed if a multiset element is
|
490 |
|
491 |
= 0.9.2 =
|
492 |
* FIXED: bugfix on yasr_visitor_multiset
|
486 |
|
487 |
= 0.9.3 =
|
488 |
* NEW FEATURE: wp rocket support, thanks to geek press
|
489 |
+
* FIXED: missing filed if a multiset element is left empty in the edit screen
|
490 |
|
491 |
= 0.9.2 =
|
492 |
* FIXED: bugfix on yasr_visitor_multiset
|
includes/js/src/yasr-front.js
CHANGED
@@ -162,11 +162,20 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
162 |
(function(i) {
|
163 |
|
164 |
let rating = yasrRaterVVInDom.item(i).getAttribute('data-rating');
|
165 |
-
let readonlyShortcode = yasrRaterVVInDom.item(i).getAttribute('data-
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
readonlyShortcode = yasrTrueFalseStringConvertion(readonlyShortcode);
|
|
|
168 |
|
169 |
-
|
|
|
|
|
|
|
170 |
|
171 |
let postId = yasrRaterVVInDom.item(i).getAttribute('data-rater-postid');
|
172 |
let htmlId = yasrRaterVVInDom.item(i).id;
|
162 |
(function(i) {
|
163 |
|
164 |
let rating = yasrRaterVVInDom.item(i).getAttribute('data-rating');
|
165 |
+
let readonlyShortcode = yasrRaterVVInDom.item(i).getAttribute('data-readonly-attribute');
|
166 |
+
let readonly = yasrRaterVVInDom.item(i).getAttribute('data-rater-readonly');
|
167 |
+
|
168 |
+
if (readonlyShortcode === null) {
|
169 |
+
readonlyShortcode = false;
|
170 |
+
}
|
171 |
|
172 |
readonlyShortcode = yasrTrueFalseStringConvertion(readonlyShortcode);
|
173 |
+
readonly = yasrTrueFalseStringConvertion(readonly);
|
174 |
|
175 |
+
//if comes from shortcode attribute, and is true, readonly is always true
|
176 |
+
if (readonlyShortcode === true) {
|
177 |
+
readonly = true;
|
178 |
+
}
|
179 |
|
180 |
let postId = yasrRaterVVInDom.item(i).getAttribute('data-rater-postid');
|
181 |
let htmlId = yasrRaterVVInDom.item(i).id;
|
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){
|
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){var r=wp.i18n.__;function a(t,e){t=parseInt(t),raterJs({starSize:t,step:.1,showToolTip:!1,readOnly:!0,element:document.getElementById(e)})}function n(t,e,r,a,n,i,s,u,d){e=parseFloat(e),a=o(a),raterJs({starSize:t,rating:e,step:1,showToolTip:!1,readOnly:a,element:document.getElementById(n),rateCallback:function(t,e){document.getElementById(d).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:u};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),document.getElementById(d).innerHTML=t})),e()}})}function o(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}document.addEventListener("DOMContentLoaded",(function(t){var e=document.getElementsByClassName("yasr-rater-stars");e.length>0&&function(t){for(var e=0;e<t.length;e++){var r=t.item(e).id;a(t.item(e).getAttribute("data-rater-starsize"),r)}}(e);var i=document.getElementsByClassName("yasr-rater-stars-visitor-votes");i.length>0&&function(t){for(var e=0;e<t.length;e++)!function(e){var a=t.item(e).getAttribute("data-rating"),i=t.item(e).getAttribute("data-readonly-attribute"),s=t.item(e).getAttribute("data-rater-readonly");null===i&&(i=!1),i=o(i),s=o(s),!0===i&&(s=!0);var u=t.item(e).getAttribute("data-rater-postid"),d=t.item(e).id,l=d.replace("yasr-visitor-votes-rater-",""),m=parseInt(t.item(e).getAttribute("data-rater-starsize")),y=t.item(e).getAttribute("data-rater-nonce"),c=t.item(e).getAttribute("data-issingular"),v="yasr-vv-votes-number-container-"+l,f="yasr-vv-average-container-"+l,g="yasr-visitor-votes-container-after-stars-"+l,p=!1;if("yes"===yasrCommonData.ajaxEnabled){var _=t.item(e).getAttribute("data-cpt");""===_&&(_="posts");var b="wp/v2/"+_+"/"+u+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+b).done((function(t){var e;(e=!0===i||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),n(m,a,u,e,d,l,y,c,g),!0!==i)&&(document.getElementById(v).innerHTML=t.yasr_visitor_votes.number_of_votes,document.getElementById(f).innerHTML=a,!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&(p=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(g).insertAdjacentHTML("beforeend",p)))})).fail((function(t,e,o,i){console.info(r("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),n(m,a,u,s,d,l,y,c,g)}))}else n(m,a,u,s,d,l,y,c,g)}(e)}(i);var s=document.getElementsByClassName("yasr-multiset-visitors-rater");if(s.length>0&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){var n=t.item(a).id,i=t.item(a).getAttribute("data-rater-readonly");i=o(i);var s=document.querySelector("#"+n);raterJs({starSize:16,step:1,showToolTip:!1,readOnly:i,element:s,rateCallback:function(t,a){var n=s.getAttribute("data-rater-postid"),o=s.getAttribute("data-rater-setid"),i=s.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var u=parseInt(t);this.setRating(u),e={postid:n,setid:o,field:i,rating:u},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)}))}))}(s),i&&"yes"===yasrCommonData.visitorStatsEnabled){var u=document.getElementsByClassName("yasr-dashicons-visitor-stats");u&&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)}(u)}"undefined"!=typeof yasrMostHighestRanking&&(document.getElementById("yasr-highest-rated-posts").style.display="none")}))}]);
|
includes/shortcodes/classes/YasrVisitorVotes.php
CHANGED
@@ -80,6 +80,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
80 |
data-rater-starsize='".$this->starSize()."'
|
81 |
data-rater-postid='$this->post_id'
|
82 |
data-rater-readonly='true'
|
|
|
83 |
data-cpt='$this->post_type'
|
84 |
>
|
85 |
</div>";
|
@@ -141,8 +142,8 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
141 |
$cookie_post_id = (int)$value['post_id'];
|
142 |
if ($cookie_post_id === $post_id) {
|
143 |
$cookie_value = (int)$value['rating'];
|
144 |
-
//
|
145 |
-
|
146 |
}
|
147 |
}
|
148 |
}
|
@@ -176,17 +177,20 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
176 |
$span_bottom_line = false;
|
177 |
$span_bottom_line_content = false;
|
178 |
|
179 |
-
//If user is logged
|
180 |
if ($stars_enabled === 'true_logged') {
|
181 |
//Check if a logged in user has already rated for this post
|
182 |
$vote_if_user_already_rated = YasrDatabaseRatings::visitorVotesHasUserVoted();
|
183 |
|
184 |
//If user has already rated
|
185 |
if ($vote_if_user_already_rated) {
|
186 |
-
$span_bottom_line_content = "<span class='yasr-already-voted-text'
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
190 |
}
|
191 |
} //true_logged
|
192 |
|
@@ -215,7 +219,6 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
215 |
|
216 |
if($span_bottom_line_content !== false) {
|
217 |
$span_bottom_line = "<span class='yasr-small-block-bold'>";
|
218 |
-
//remove \n in the string and use trim
|
219 |
$span_bottom_line .= $span_bottom_line_content;
|
220 |
$span_bottom_line .= '</span>';
|
221 |
}
|
@@ -253,19 +256,19 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
253 |
$average_rating_container = '<span id="yasr-vv-average-container-'. $this->unique_id .'">';
|
254 |
$closing_span = '</span>';
|
255 |
|
256 |
-
if (YASR_TEXT_BEFORE_STARS === 1 && YASR_TEXT_BEFORE_VISITOR_RATING
|
257 |
$text_before_star = str_replace(
|
258 |
-
|
259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
YASR_TEXT_BEFORE_VISITOR_RATING
|
261 |
);
|
262 |
|
263 |
-
$text_before_star = str_replace(
|
264 |
-
'%average%',
|
265 |
-
$average_rating_container.$average_rating.$closing_span,
|
266 |
-
$text_before_star
|
267 |
-
);
|
268 |
-
|
269 |
$this->shortcode_html .= "<div class='yasr-container-custom-text-and-visitor-rating'>
|
270 |
<span id='yasr-custom-text-before-visitor-rating'>"
|
271 |
. $text_before_star .
|
@@ -273,18 +276,19 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
273 |
</div>";
|
274 |
}
|
275 |
|
276 |
-
if (YASR_TEXT_BEFORE_STARS === 1 && YASR_TEXT_AFTER_VISITOR_RATING
|
277 |
$text_after_star = str_replace(
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
YASR_TEXT_AFTER_VISITOR_RATING
|
281 |
);
|
282 |
|
283 |
-
$text_after_star = str_replace(
|
284 |
-
'%average%',
|
285 |
-
$average_rating_container.$average_rating.$closing_span,
|
286 |
-
$text_after_star
|
287 |
-
);
|
288 |
$this->span_text_after_stars .= $text_after_star;
|
289 |
}
|
290 |
|
@@ -369,7 +373,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
369 |
$this->shortcode_html .= $span_container_after_stars;
|
370 |
$this->shortcode_html .= $this->visitorStats();
|
371 |
$this->shortcode_html .= $this->span_text_after_stars;
|
372 |
-
if(
|
373 |
$this->shortcode_html .= self::showTextBelowStars($cookie_value);
|
374 |
}
|
375 |
$this->shortcode_html .= '</span>'; //Close yasr-visitor-votes-after-stars and yasr_visitor_votes
|
80 |
data-rater-starsize='".$this->starSize()."'
|
81 |
data-rater-postid='$this->post_id'
|
82 |
data-rater-readonly='true'
|
83 |
+
data-readonly-attribute='true'
|
84 |
data-cpt='$this->post_type'
|
85 |
>
|
86 |
</div>";
|
142 |
$cookie_post_id = (int)$value['post_id'];
|
143 |
if ($cookie_post_id === $post_id) {
|
144 |
$cookie_value = (int)$value['rating'];
|
145 |
+
//since version 2.4.0 break is removed, because yasr_setcookie PUSH the value (for logged in users)
|
146 |
+
//so to be sure to get the correct value, I need the last
|
147 |
}
|
148 |
}
|
149 |
}
|
177 |
$span_bottom_line = false;
|
178 |
$span_bottom_line_content = false;
|
179 |
|
|
|
180 |
if ($stars_enabled === 'true_logged') {
|
181 |
//Check if a logged in user has already rated for this post
|
182 |
$vote_if_user_already_rated = YasrDatabaseRatings::visitorVotesHasUserVoted();
|
183 |
|
184 |
//If user has already rated
|
185 |
if ($vote_if_user_already_rated) {
|
186 |
+
$span_bottom_line_content = "<span class='yasr-already-voted-text'>";
|
187 |
+
if (YASR_TEXT_BEFORE_STARS === 1 && YASR_CUSTOM_TEXT_USER_VOTED != '') {
|
188 |
+
$span_bottom_line_content .= YASR_CUSTOM_TEXT_USER_VOTED;
|
189 |
+
} else {
|
190 |
+
$span_bottom_line_content .=
|
191 |
+
__('You\'ve already voted this article with', 'yet-another-stars-rating') . ' ' . $vote_if_user_already_rated;
|
192 |
+
}
|
193 |
+
$span_bottom_line_content .= '</span>';
|
194 |
}
|
195 |
} //true_logged
|
196 |
|
219 |
|
220 |
if($span_bottom_line_content !== false) {
|
221 |
$span_bottom_line = "<span class='yasr-small-block-bold'>";
|
|
|
222 |
$span_bottom_line .= $span_bottom_line_content;
|
223 |
$span_bottom_line .= '</span>';
|
224 |
}
|
256 |
$average_rating_container = '<span id="yasr-vv-average-container-'. $this->unique_id .'">';
|
257 |
$closing_span = '</span>';
|
258 |
|
259 |
+
if (YASR_TEXT_BEFORE_STARS === 1 && YASR_TEXT_BEFORE_VISITOR_RATING !== '') {
|
260 |
$text_before_star = str_replace(
|
261 |
+
array(
|
262 |
+
'%total_count%',
|
263 |
+
'%average%'
|
264 |
+
),
|
265 |
+
array(
|
266 |
+
$number_of_votes_container . $number_of_votes . $closing_span,
|
267 |
+
$average_rating_container . $average_rating . $closing_span
|
268 |
+
),
|
269 |
YASR_TEXT_BEFORE_VISITOR_RATING
|
270 |
);
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
$this->shortcode_html .= "<div class='yasr-container-custom-text-and-visitor-rating'>
|
273 |
<span id='yasr-custom-text-before-visitor-rating'>"
|
274 |
. $text_before_star .
|
276 |
</div>";
|
277 |
}
|
278 |
|
279 |
+
if (YASR_TEXT_BEFORE_STARS === 1 && YASR_TEXT_AFTER_VISITOR_RATING !== '') {
|
280 |
$text_after_star = str_replace(
|
281 |
+
array(
|
282 |
+
'%total_count%',
|
283 |
+
'%average%'
|
284 |
+
),
|
285 |
+
array(
|
286 |
+
$number_of_votes_container . $number_of_votes . $closing_span,
|
287 |
+
$average_rating_container . $average_rating . $closing_span
|
288 |
+
),
|
289 |
YASR_TEXT_AFTER_VISITOR_RATING
|
290 |
);
|
291 |
|
|
|
|
|
|
|
|
|
|
|
292 |
$this->span_text_after_stars .= $text_after_star;
|
293 |
}
|
294 |
|
373 |
$this->shortcode_html .= $span_container_after_stars;
|
374 |
$this->shortcode_html .= $this->visitorStats();
|
375 |
$this->shortcode_html .= $this->span_text_after_stars;
|
376 |
+
if(YASR_ENABLE_AJAX !== 'yes') {
|
377 |
$this->shortcode_html .= self::showTextBelowStars($cookie_value);
|
378 |
}
|
379 |
$this->shortcode_html .= '</span>'; //Close yasr-visitor-votes-after-stars and yasr_visitor_votes
|
includes/yasr-includes-init.php
CHANGED
@@ -220,6 +220,7 @@ $supported_schema_types = json_encode(
|
|
220 |
);
|
221 |
$array_item_type_info = json_encode(
|
222 |
array(
|
|
|
223 |
'yasr_product_brand',
|
224 |
'yasr_product_sku',
|
225 |
'yasr_product_global_identifier_select',
|
220 |
);
|
221 |
$array_item_type_info = json_encode(
|
222 |
array(
|
223 |
+
'yasr_schema_title',
|
224 |
'yasr_product_brand',
|
225 |
'yasr_product_sku',
|
226 |
'yasr_product_global_identifier_select',
|
public/classes/YasrRichSnippetAdditionalFields.php
CHANGED
@@ -9,25 +9,25 @@
|
|
9 |
*/
|
10 |
class YasrRichSnippetAdditionalFields {
|
11 |
|
12 |
-
public function
|
|
|
13 |
add_filter('yasr_filter_existing_schema', array($this, 'additional_schema'));
|
14 |
}
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
21 |
}
|
22 |
|
23 |
-
$
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
if(!isset($saved_data[$item_type])) {
|
28 |
-
$saved_data[$item_type] = '';
|
29 |
-
}
|
30 |
-
}
|
31 |
|
32 |
//avoid undefined
|
33 |
$more_rich_snippet = array();
|
@@ -151,4 +151,23 @@ class YasrRichSnippetAdditionalFields {
|
|
151 |
}
|
152 |
return $rich_snippet;
|
153 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
}
|
9 |
*/
|
10 |
class YasrRichSnippetAdditionalFields {
|
11 |
|
12 |
+
public function addFilters() {
|
13 |
+
add_filter('yasr_filter_schema_title', array($this, 'filter_title'));
|
14 |
add_filter('yasr_filter_existing_schema', array($this, 'additional_schema'));
|
15 |
}
|
16 |
|
17 |
+
//hook to filter title
|
18 |
+
public function filter_title($schema_title) {
|
19 |
+
$saved_data = $this->saved_data();
|
20 |
+
|
21 |
+
//if is not empty, overwrite the title with custom itemType name
|
22 |
+
if(!empty($saved_data['yasr_schema_title'])) {
|
23 |
+
$schema_title = $saved_data['yasr_schema_title'];
|
24 |
}
|
25 |
|
26 |
+
return $schema_title;
|
27 |
+
}
|
28 |
|
29 |
+
public function additional_schema($rich_snippet) {
|
30 |
+
$saved_data = $this->saved_data();
|
|
|
|
|
|
|
|
|
31 |
|
32 |
//avoid undefined
|
33 |
$more_rich_snippet = array();
|
151 |
}
|
152 |
return $rich_snippet;
|
153 |
}
|
154 |
+
|
155 |
+
private function saved_data() {
|
156 |
+
$saved_data = get_post_meta(get_the_ID(), 'yasr_schema_additional_fields', true);
|
157 |
+
//avoid undefined
|
158 |
+
if(!is_array($saved_data)) {
|
159 |
+
$saved_data = array();
|
160 |
+
}
|
161 |
+
|
162 |
+
$array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true);
|
163 |
+
|
164 |
+
foreach ($array_item_type_info as $item_type) {
|
165 |
+
//avoid undefined
|
166 |
+
if(!isset($saved_data[$item_type])) {
|
167 |
+
$saved_data[$item_type] = '';
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
return $saved_data;
|
172 |
+
}
|
173 |
}
|
public/yasr-public-filters.php
CHANGED
@@ -153,7 +153,9 @@ function yasr_add_schema($content) {
|
|
153 |
|
154 |
$review_choosen = yasr_get_itemType();
|
155 |
|
156 |
-
//
|
|
|
|
|
157 |
$filtered_schema = apply_filters('yasr_filter_schema_jsonld', $review_choosen);
|
158 |
|
159 |
//So check here if $schema != $review_choosen
|
@@ -161,164 +163,169 @@ function yasr_add_schema($content) {
|
|
161 |
return $content . $script_type . $filtered_schema . $end_script_type;
|
162 |
}
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
$author = get_the_author();
|
167 |
-
$review_name = wp_strip_all_tags(get_the_title());
|
168 |
-
|
169 |
-
$date = get_the_date('c');
|
170 |
-
$date_modified = get_the_modified_date('c');
|
171 |
-
|
172 |
-
$post_image_url = ''; //avoid undefined
|
173 |
-
$logo_image_url = ''; //avoid undefined
|
174 |
|
175 |
-
|
176 |
-
$logo_image_url = YASR_PUBLISHER_LOGO;
|
177 |
-
$post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
|
178 |
|
179 |
-
$
|
180 |
|
181 |
-
|
182 |
-
$
|
183 |
-
} else {
|
184 |
-
$post_image_size[0] = 0;
|
185 |
-
$post_image_size[1] = 0;
|
186 |
-
$logo_image_size[0] = 0;
|
187 |
-
$logo_image_size[1] = 0;
|
188 |
-
}
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
$post_image_url = wp_get_attachment_url(get_post_thumbnail_id());
|
193 |
-
$post_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url($post_image_url, PHP_URL_PATH);
|
194 |
-
$post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
|
195 |
-
}
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
$cleaned_content = wp_strip_all_tags(strip_shortcodes($content));
|
200 |
|
201 |
-
|
|
|
|
|
202 |
|
203 |
-
|
204 |
-
'@type' => 'ImageObject',
|
205 |
-
'url' => $post_image_url,
|
206 |
-
'width' => $post_image_size[0],
|
207 |
-
'height' => $post_image_size[1]
|
208 |
-
);
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
218 |
|
219 |
-
|
220 |
-
$rich_snippet['
|
221 |
-
$
|
222 |
-
$rich_snippet['mainEntityOfPage'] = array(
|
223 |
-
'@type' => 'WebPage',
|
224 |
-
'@id' => get_permalink()
|
225 |
-
);
|
226 |
-
$rich_snippet['author'] = array(
|
227 |
-
'@type' => 'Person',
|
228 |
-
'name' => $author
|
229 |
-
);
|
230 |
-
$rich_snippet['publisher'] = array(
|
231 |
-
'@type' => 'Organization',
|
232 |
-
'name' => wp_strip_all_tags(YASR_PUBLISHER_NAME), //already sanitized in the settings, just to be safe
|
233 |
-
'logo' => array(
|
234 |
-
'@type' => 'ImageObject',
|
235 |
-
'url' => $logo_image_url,
|
236 |
-
'width' => $logo_image_size[0],
|
237 |
-
'height' => $logo_image_size[1]
|
238 |
-
),
|
239 |
-
);
|
240 |
|
241 |
-
$rich_snippet['
|
242 |
|
243 |
-
$rich_snippet['image']
|
244 |
'@type' => 'ImageObject',
|
245 |
'url' => $post_image_url,
|
246 |
'width' => $post_image_size[0],
|
247 |
'height' => $post_image_size[1]
|
248 |
);
|
249 |
|
250 |
-
|
|
|
|
|
|
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
'
|
265 |
-
'
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
270 |
),
|
271 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
}
|
273 |
|
274 |
-
//
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
'
|
284 |
-
|
285 |
-
|
|
|
|
|
|
|
|
|
286 |
'bestRating' => 5,
|
287 |
-
'worstRating' => 1
|
288 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
290 |
}
|
291 |
}
|
292 |
-
}
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
|
|
311 |
}
|
312 |
-
}
|
313 |
|
314 |
-
|
315 |
-
|
|
|
316 |
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
|
321 |
-
if (is_singular() && is_main_query() && !is_404()) {
|
322 |
return $content . $script_type . json_encode($rich_snippet) . $end_script_type;
|
323 |
}
|
324 |
|
153 |
|
154 |
$review_choosen = yasr_get_itemType();
|
155 |
|
156 |
+
//Use this hook to write your custom microdata from scratch
|
157 |
+
//if doesn't exists a filter for yasr_filter_schema_jsonld
|
158 |
+
// $review_chosen value is assigned to $filtered_schema.
|
159 |
$filtered_schema = apply_filters('yasr_filter_schema_jsonld', $review_choosen);
|
160 |
|
161 |
//So check here if $schema != $review_choosen
|
163 |
return $content . $script_type . $filtered_schema . $end_script_type;
|
164 |
}
|
165 |
|
166 |
+
//YASR adds microdata only if is_singular() && is_main_query() && !is_404()
|
167 |
+
if (is_singular() && is_main_query() && !is_404()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
+
$rich_snippet['@context'] = 'http://schema.org/';
|
|
|
|
|
170 |
|
171 |
+
$author = get_the_author();
|
172 |
|
173 |
+
//use this hook to change the itemType name
|
174 |
+
$review_name = wp_strip_all_tags(apply_filters('yasr_filter_schema_title', get_the_title()));
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
+
$date = get_the_date('c');
|
177 |
+
$date_modified = get_the_modified_date('c');
|
|
|
|
|
|
|
|
|
178 |
|
179 |
+
$post_image_url = ''; //avoid undefined
|
180 |
+
$logo_image_url = ''; //avoid undefined
|
|
|
181 |
|
182 |
+
if (defined('YASR_PUBLISHER_LOGO')) {
|
183 |
+
$logo_image_url = YASR_PUBLISHER_LOGO;
|
184 |
+
$post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
|
185 |
|
186 |
+
$logo_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url(YASR_PUBLISHER_LOGO, PHP_URL_PATH);
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
+
$post_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
|
189 |
+
$logo_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
|
190 |
+
} else {
|
191 |
+
$post_image_size[0] = 0;
|
192 |
+
$post_image_size[1] = 0;
|
193 |
+
$logo_image_size[0] = 0;
|
194 |
+
$logo_image_size[1] = 0;
|
195 |
+
}
|
196 |
|
197 |
+
//if exists featuread image get the url and overwrite the variable
|
198 |
+
if (has_post_thumbnail()) {
|
199 |
+
$post_image_url = wp_get_attachment_url(get_post_thumbnail_id());
|
200 |
+
$post_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url($post_image_url, PHP_URL_PATH);
|
201 |
+
$post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
|
202 |
+
}
|
203 |
|
204 |
+
$rich_snippet['@type'] = $review_choosen;
|
205 |
+
$rich_snippet['name'] = $review_name;
|
206 |
+
$cleaned_content = wp_strip_all_tags(strip_shortcodes($content));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
+
$rich_snippet['description'] = wp_trim_words( $cleaned_content, 55, '...' );
|
209 |
|
210 |
+
$rich_snippet['image'] = array(
|
211 |
'@type' => 'ImageObject',
|
212 |
'url' => $post_image_url,
|
213 |
'width' => $post_image_size[0],
|
214 |
'height' => $post_image_size[1]
|
215 |
);
|
216 |
|
217 |
+
$publisher_image_index = 'logo';
|
218 |
+
if(YASR_PUBLISHER_TYPE === 'Person') {
|
219 |
+
$publisher_image_index = 'image';
|
220 |
+
}
|
221 |
|
222 |
+
if ($review_choosen === 'Place') {
|
223 |
+
$rich_snippet['@type'] = 'LocalBusiness';
|
224 |
+
}
|
225 |
+
|
226 |
+
elseif ($review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
|
227 |
+
$rich_snippet['datePublished'] = $date;
|
228 |
+
$rich_snippet['headline'] = $review_name;
|
229 |
+
$rich_snippet['mainEntityOfPage'] = array(
|
230 |
+
'@type' => 'WebPage',
|
231 |
+
'@id' => get_permalink()
|
232 |
+
);
|
233 |
+
$rich_snippet['author'] = array(
|
234 |
+
'@type' => 'Person',
|
235 |
+
'name' => $author
|
236 |
+
);
|
237 |
+
$rich_snippet['publisher'] = array(
|
238 |
+
'@type' => 'Organization',
|
239 |
+
'name' => wp_strip_all_tags(YASR_PUBLISHER_NAME), //already sanitized in the settings, just to be safe
|
240 |
+
'logo' => array(
|
241 |
+
'@type' => 'ImageObject',
|
242 |
+
'url' => $logo_image_url,
|
243 |
+
'width' => $logo_image_size[0],
|
244 |
+
'height' => $logo_image_size[1]
|
245 |
),
|
246 |
);
|
247 |
+
|
248 |
+
$rich_snippet['dateModified'] = $date_modified;
|
249 |
+
|
250 |
+
$rich_snippet['image'] = array(
|
251 |
+
'@type' => 'ImageObject',
|
252 |
+
'url' => $post_image_url,
|
253 |
+
'width' => $post_image_size[0],
|
254 |
+
'height' => $post_image_size[1]
|
255 |
+
);
|
256 |
+
|
257 |
}
|
258 |
|
259 |
+
//Do not add rating if blogposting
|
260 |
+
if ($review_choosen !== 'Other' && $review_choosen !== 'BlogPosting') {
|
261 |
+
if ($overall_rating) {
|
262 |
+
$rich_snippet['Review'] = array(
|
263 |
+
'@type' => 'Review',
|
264 |
+
'name' => $review_name,
|
265 |
+
'reviewBody' => $cleaned_content,
|
266 |
+
'author' => array(
|
267 |
+
'@type' => 'Person',
|
268 |
+
'name' => $author
|
269 |
+
),
|
270 |
+
'datePublished' => $date,
|
271 |
+
'dateModified' => $date_modified,
|
272 |
+
'reviewRating' => array(
|
273 |
+
'@type' => 'Rating',
|
274 |
+
'ratingValue' => $overall_rating,
|
275 |
'bestRating' => 5,
|
276 |
+
'worstRating' => 1
|
277 |
+
),
|
278 |
+
);
|
279 |
+
}
|
280 |
+
|
281 |
+
//if both are included, google will index AggregateRating instead of Review.
|
282 |
+
//So, is post is selected as review, exclude AggregateRating
|
283 |
+
if($is_post_a_review !== 'yes') {
|
284 |
+
if ($visitor_votes) {
|
285 |
+
if ($visitor_votes['sum_votes'] !== 0 && $visitor_votes['number_of_votes'] !== 0) {
|
286 |
+
$average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
|
287 |
+
$average_rating = round($average_rating, 1);
|
288 |
+
|
289 |
+
$rich_snippet['aggregateRating'] = array(
|
290 |
+
'@type' => 'AggregateRating',
|
291 |
+
'ratingValue' => $average_rating,
|
292 |
+
'ratingCount' => $visitor_votes['number_of_votes'],
|
293 |
+
'bestRating' => 5,
|
294 |
+
'worstRating' => 1,
|
295 |
+
);
|
296 |
+
}
|
297 |
}
|
298 |
}
|
299 |
}
|
|
|
300 |
|
301 |
+
if(isset($rich_snippet['Review']) || $review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
|
302 |
+
$publisher = array(
|
303 |
+
'@type' => YASR_PUBLISHER_TYPE,
|
304 |
+
'name' => wp_strip_all_tags( YASR_PUBLISHER_NAME ),//already sanitized in the settings, just to be safe
|
305 |
+
$publisher_image_index => array(
|
306 |
+
'@type' => 'ImageObject',
|
307 |
+
'url' => $logo_image_url,
|
308 |
+
'width' => $logo_image_size[0],
|
309 |
+
'height' => $logo_image_size[1]
|
310 |
+
),
|
311 |
+
);
|
312 |
|
313 |
+
/** @noinspection NotOptimalIfConditionsInspection */
|
314 |
+
if(isset($rich_snippet['Review'])) {
|
315 |
+
$rich_snippet['Review']['publisher'] = $publisher;
|
316 |
+
} else {
|
317 |
+
$rich_snippet['publisher'] = $publisher;
|
318 |
+
}
|
319 |
}
|
|
|
320 |
|
321 |
+
//Use this hook to add additional schema
|
322 |
+
//if doesn't exists a filter for yasr_filter_existing_schema, put $rich_snippet into $more_rich_snippet
|
323 |
+
$more_rich_snippet = apply_filters('yasr_filter_existing_schema', $rich_snippet);
|
324 |
|
325 |
+
if ($more_rich_snippet !== $rich_snippet && is_array($more_rich_snippet)) {
|
326 |
+
$rich_snippet = $more_rich_snippet;
|
327 |
+
}
|
328 |
|
|
|
329 |
return $content . $script_type . json_encode($rich_snippet) . $end_script_type;
|
330 |
}
|
331 |
|
public/yasr-public-init.php
CHANGED
@@ -56,4 +56,4 @@ spl_autoload_register('yasr_autoload_public_classes');
|
|
56 |
|
57 |
//filter yasr rich snippet
|
58 |
$yasr_additional_rich_fields = new YasrRichSnippetAdditionalFields;
|
59 |
-
$yasr_additional_rich_fields->
|
56 |
|
57 |
//filter yasr rich snippet
|
58 |
$yasr_additional_rich_fields = new YasrRichSnippetAdditionalFields;
|
59 |
+
$yasr_additional_rich_fields->addFilters();
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
|
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.
|
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
|
@@ -142,11 +142,19 @@ If doesn't, you should work on your seo reputation.
|
|
142 |
|
143 |
The full changelog can be found in the plugin's directory. Recent entries:
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
= 2.3.9 =
|
146 |
* FIXED: yasr_visitor_votes readonly didn't show up if load results with ajax is enabled
|
147 |
* FIXED: missing fragment error if gutenber used
|
148 |
* FIXED: empty tooltip on yasr_visitor_votes
|
149 |
|
|
|
150 |
= 2.3.8 =
|
151 |
* TWEAKED: Using GET instead of POST when getting rest response
|
152 |
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.4.0
|
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
|
142 |
|
143 |
The full changelog can be found in the plugin's directory. Recent entries:
|
144 |
|
145 |
+
= 2.4.0 =
|
146 |
+
* NEW FEATURE: is now possible to customize the itemType Name: if empty, post title will be used instead-
|
147 |
+
* TWEAKED: Custom text to show when an user has already voted now shows up even for logged in users
|
148 |
+
* TWEAKED: Added new hooks: yasr_filter_schema_title and yasr_below_panel (for gutenberg)
|
149 |
+
* TWEAKED: admin .js files are now bundled into a single one
|
150 |
+
* TWEAKED: support for IE11 (will be dropped in 12 months)
|
151 |
+
|
152 |
= 2.3.9 =
|
153 |
* FIXED: yasr_visitor_votes readonly didn't show up if load results with ajax is enabled
|
154 |
* FIXED: missing fragment error if gutenber used
|
155 |
* FIXED: empty tooltip on yasr_visitor_votes
|
156 |
|
157 |
+
|
158 |
= 2.3.8 =
|
159 |
* TWEAKED: Using GET instead of POST when getting rest response
|
160 |
|
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.
|
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.
|
80 |
//Plugin absolute path
|
81 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
82 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
+
* Version: 2.4.0
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
76 |
yasr_fs();
|
77 |
// Signal that SDK was initiated.
|
78 |
do_action( 'yasr_fs_loaded' );
|
79 |
+
define( 'YASR_VERSION_NUM', '2.4.0' );
|
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__ );
|