Version Description
- FIXED: Uncaught TypeError randomly shows up in the browser console
- TWEAKED: removed deprecated multisite function
- TWEAKED: in tht settings page, the "custom css" textarea is now a text editor
- TWEAKED: CSS improvment in settings page
- TWEAKED: minor code cleanup
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 2.3.2 |
Comparing to | |
See all releases |
Code changes from version 2.3.1 to 2.3.2
- admin/css/yasr-admin.css +2 -2
- admin/js/src/yasr-guten-panel.js +4 -4
- admin/js/yasr-admin.js +15 -6
- admin/js/yasr-guten-panel.js +2 -2
- admin/settings/aspect_style/yasr-settings-functions-style.php +28 -8
- admin/settings/yasr-settings-functions-misc.php +7 -9
- admin/settings/yasr-settings-page.php +1 -1
- admin/yasr-admin-functions.php +2 -2
- admin/yasr-admin-init.php +6 -0
- includes/rest/classes/YasrCustomEndpoint.php +5 -4
- includes/rest/classes/YasrCustomFields.php +19 -9
- includes/rest/classes/YasrPostMeta.php +4 -5
- includes/rest/yasr-rest.php +4 -0
- includes/yasr-includes-functions.php +1 -1
- includes/yasr-includes-init.php +3 -2
- readme.txt +14 -6
- yet-another-stars-rating.php +3 -3
admin/css/yasr-admin.css
CHANGED
@@ -289,7 +289,7 @@
|
|
289 |
.yasr-settingsdiv {
|
290 |
float: left;
|
291 |
display: block;
|
292 |
-
width:
|
293 |
background-color: #FFF;
|
294 |
border: 1px solid #DDD;
|
295 |
padding-left: 25px;
|
@@ -301,7 +301,7 @@
|
|
301 |
.yasr-donatedivdx {
|
302 |
float: right;
|
303 |
display: block !important;
|
304 |
-
min-width:
|
305 |
width: 15%;
|
306 |
margin-bottom: 10px;
|
307 |
background-color: #FFF;
|
289 |
.yasr-settingsdiv {
|
290 |
float: left;
|
291 |
display: block;
|
292 |
+
width: 65%;
|
293 |
background-color: #FFF;
|
294 |
border: 1px solid #DDD;
|
295 |
padding-left: 25px;
|
301 |
.yasr-donatedivdx {
|
302 |
float: right;
|
303 |
display: block !important;
|
304 |
+
min-width: 250px;
|
305 |
width: 15%;
|
306 |
margin-bottom: 10px;
|
307 |
background-color: #FFF;
|
admin/js/src/yasr-guten-panel.js
CHANGED
@@ -9,7 +9,7 @@ const yasrPostExcluded = __('Is this a review?', 'yet-another-stars-rating');
|
|
9 |
const yasrSelectSnippetTitle = __('Select ItemType ', 'yet-another-stars-rating');
|
10 |
|
11 |
const ContentBelowSidebar = () => {
|
12 |
-
return <div
|
13 |
};
|
14 |
|
15 |
|
@@ -56,7 +56,6 @@ class YasrDivRatingOverall extends React.Component {
|
|
56 |
/>
|
57 |
<br />
|
58 |
{this.yasrOverallMoreInfo}
|
59 |
-
<hr />
|
60 |
</div>
|
61 |
)
|
62 |
}
|
@@ -112,6 +111,7 @@ class YasrSideBarAutoInsert extends React.Component {
|
|
112 |
render () {
|
113 |
return (
|
114 |
<div className="yasr-guten-block-panel-center">
|
|
|
115 |
<label><span>{yasrDisableAutoInsert}</span></label>
|
116 |
<div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
|
117 |
<input type="checkbox"
|
@@ -123,8 +123,8 @@ class YasrSideBarAutoInsert extends React.Component {
|
|
123 |
onChange={this.yasrUpdatePostMetaAutoInsert}
|
124 |
/>
|
125 |
<label className="yasr-onoffswitch-label" htmlFor="yasr-auto-insert-disabled-switch">
|
126 |
-
<span className="yasr-onoffswitch-inner"
|
127 |
-
<span className="yasr-onoffswitch-switch"
|
128 |
</label>
|
129 |
</div>
|
130 |
</div>
|
9 |
const yasrSelectSnippetTitle = __('Select ItemType ', 'yet-another-stars-rating');
|
10 |
|
11 |
const ContentBelowSidebar = () => {
|
12 |
+
return <div/>;
|
13 |
};
|
14 |
|
15 |
|
56 |
/>
|
57 |
<br />
|
58 |
{this.yasrOverallMoreInfo}
|
|
|
59 |
</div>
|
60 |
)
|
61 |
}
|
111 |
render () {
|
112 |
return (
|
113 |
<div className="yasr-guten-block-panel-center">
|
114 |
+
<hr />
|
115 |
<label><span>{yasrDisableAutoInsert}</span></label>
|
116 |
<div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
|
117 |
<input type="checkbox"
|
123 |
onChange={this.yasrUpdatePostMetaAutoInsert}
|
124 |
/>
|
125 |
<label className="yasr-onoffswitch-label" htmlFor="yasr-auto-insert-disabled-switch">
|
126 |
+
<span className="yasr-onoffswitch-inner"/>
|
127 |
+
<span className="yasr-onoffswitch-switch"/>
|
128 |
</label>
|
129 |
</div>
|
130 |
</div>
|
admin/js/yasr-admin.js
CHANGED
@@ -168,6 +168,10 @@ function YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled, textBeforeSta
|
|
168 |
|
169 |
|
170 |
if (activeTab === 'style_options') {
|
|
|
|
|
|
|
|
|
171 |
|
172 |
jQuery('#yasr-color-scheme-preview-link').on('click', function () {
|
173 |
jQuery('#yasr-color-scheme-preview').toggle('slow');
|
@@ -293,11 +297,14 @@ jQuery(document).ready(function () {
|
|
293 |
});
|
294 |
|
295 |
jQuery(document).ajaxComplete(function (event, xhr, settings) {
|
|
|
296 |
|
297 |
-
|
298 |
-
|
299 |
-
|
|
|
300 |
|
|
|
301 |
jQuery('.yasr-log-pagenum').on('click', function () {
|
302 |
jQuery('#yasr-loader-log-metabox').show();
|
303 |
|
@@ -337,11 +344,13 @@ jQuery(document).ready(function () {
|
|
337 |
});
|
338 |
|
339 |
jQuery(document).ajaxComplete(function (event, xhr, settings) {
|
|
|
340 |
|
341 |
-
|
342 |
-
|
|
|
|
|
343 |
if (isYasrAjaxCall !== -1) {
|
344 |
-
|
345 |
jQuery('.yasr-user-log-page-num').on('click', function () {
|
346 |
jQuery('#yasr-loader-user-log-metabox').show();
|
347 |
|
168 |
|
169 |
|
170 |
if (activeTab === 'style_options') {
|
171 |
+
wp.codeEditor.initialize(
|
172 |
+
document.getElementById('yasr_style_options_textarea'),
|
173 |
+
yasr_cm_settings
|
174 |
+
);
|
175 |
|
176 |
jQuery('#yasr-color-scheme-preview-link').on('click', function () {
|
177 |
jQuery('#yasr-color-scheme-preview').toggle('slow');
|
297 |
});
|
298 |
|
299 |
jQuery(document).ajaxComplete(function (event, xhr, settings) {
|
300 |
+
var isYasrAjaxCall = true;
|
301 |
|
302 |
+
if(settings.data !== 'undefined') {
|
303 |
+
//check if the ajax call is done by yasr with action yasr_change_log_page
|
304 |
+
isYasrAjaxCall = settings.data.search("action=yasr_change_log_page");
|
305 |
+
}
|
306 |
|
307 |
+
if (isYasrAjaxCall !== -1) {
|
308 |
jQuery('.yasr-log-pagenum').on('click', function () {
|
309 |
jQuery('#yasr-loader-log-metabox').show();
|
310 |
|
344 |
});
|
345 |
|
346 |
jQuery(document).ajaxComplete(function (event, xhr, settings) {
|
347 |
+
var isYasrAjaxCall = true;
|
348 |
|
349 |
+
if(settings.data !== 'undefined') {
|
350 |
+
//check if the ajax call is done by yasr with action yasr_change_log_page
|
351 |
+
isYasrAjaxCall = settings.data.search("action=yasr_change_log_page");
|
352 |
+
}
|
353 |
if (isYasrAjaxCall !== -1) {
|
|
|
354 |
jQuery('.yasr-user-log-page-num').on('click', function () {
|
355 |
jQuery('#yasr-loader-user-log-metabox').show();
|
356 |
|
admin/js/yasr-guten-panel.js
CHANGED
@@ -77,8 +77,7 @@ var YasrDivRatingOverall = function (_React$Component) {
|
|
77 |
}
|
78 |
}),
|
79 |
React.createElement('br', null),
|
80 |
-
this.yasrOverallMoreInfo
|
81 |
-
React.createElement('hr', null)
|
82 |
);
|
83 |
}
|
84 |
}, {
|
@@ -141,6 +140,7 @@ var YasrSideBarAutoInsert = function (_React$Component2) {
|
|
141 |
return React.createElement(
|
142 |
'div',
|
143 |
{ className: 'yasr-guten-block-panel-center' },
|
|
|
144 |
React.createElement(
|
145 |
'label',
|
146 |
null,
|
77 |
}
|
78 |
}),
|
79 |
React.createElement('br', null),
|
80 |
+
this.yasrOverallMoreInfo
|
|
|
81 |
);
|
82 |
}
|
83 |
}, {
|
140 |
return React.createElement(
|
141 |
'div',
|
142 |
{ className: 'yasr-guten-block-panel-center' },
|
143 |
+
React.createElement('hr', null),
|
144 |
React.createElement(
|
145 |
'label',
|
146 |
null,
|
admin/settings/aspect_style/yasr-settings-functions-style.php
CHANGED
@@ -43,21 +43,42 @@ function yasr_style_options_init() {
|
|
43 |
//filter $style_options
|
44 |
$style_options = apply_filters('yasr_filter_style_options', $style_options);
|
45 |
|
46 |
-
add_settings_section(
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
do_action('yasr_style_options_add_settings_field', $style_options);
|
48 |
-
|
49 |
-
add_settings_field(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
|
52 |
}
|
53 |
|
54 |
function yasr_style_section_callback() {
|
55 |
-
|
56 |
}
|
57 |
|
58 |
|
59 |
function yasr_color_scheme_multiset_callback($style_options) {
|
60 |
-
|
61 |
?>
|
62 |
|
63 |
<input type='radio' name='yasr_style_options[scheme_color_multiset]' value='light'
|
@@ -66,7 +87,6 @@ function yasr_color_scheme_multiset_callback($style_options) {
|
|
66 |
} ?> />
|
67 |
<?php _e('Light', 'yet-another-stars-rating') ?>
|
68 |
|
69 |
-
|
70 |
|
71 |
<input type='radio' name='yasr_style_options[scheme_color_multiset]' value='dark'
|
72 |
class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset'] === 'dark') {
|
@@ -110,7 +130,7 @@ function yasr_style_options_textarea_callback($style_options) {
|
|
110 |
rows='17'
|
111 |
cols='40'
|
112 |
name='yasr_style_options[textarea]'
|
113 |
-
id='yasr_style_options_textarea'><?php echo $style_options['textarea']?></textarea>
|
114 |
|
115 |
<?php
|
116 |
|
@@ -122,7 +142,7 @@ function yasr_style_options_sanitize($style_options) {
|
|
122 |
$output = array();
|
123 |
|
124 |
foreach ($style_options as $key => $value) {
|
125 |
-
$output[$key] =
|
126 |
}
|
127 |
|
128 |
return $output;
|
43 |
//filter $style_options
|
44 |
$style_options = apply_filters('yasr_filter_style_options', $style_options);
|
45 |
|
46 |
+
add_settings_section(
|
47 |
+
'yasr_style_options_section_id',
|
48 |
+
__('Style Options', 'yet-another-stars-rating'),
|
49 |
+
'yasr_style_section_callback',
|
50 |
+
'yasr_style_tab'
|
51 |
+
);
|
52 |
+
|
53 |
do_action('yasr_style_options_add_settings_field', $style_options);
|
54 |
+
|
55 |
+
add_settings_field(
|
56 |
+
'yasr_color_scheme_multiset',
|
57 |
+
__('Which color scheme do you want to use?', 'yet-another-stars-rating'),
|
58 |
+
'yasr_color_scheme_multiset_callback',
|
59 |
+
'yasr_style_tab',
|
60 |
+
'yasr_style_options_section_id',
|
61 |
+
$style_options
|
62 |
+
);
|
63 |
+
|
64 |
+
add_settings_field(
|
65 |
+
'yasr_style_options_textarea',
|
66 |
+
__('Custom CSS Styles', 'yet-another-stars-rating'),
|
67 |
+
'yasr_style_options_textarea_callback',
|
68 |
+
'yasr_style_tab',
|
69 |
+
'yasr_style_options_section_id',
|
70 |
+
$style_options
|
71 |
+
);
|
72 |
|
73 |
|
74 |
}
|
75 |
|
76 |
function yasr_style_section_callback() {
|
77 |
+
return;
|
78 |
}
|
79 |
|
80 |
|
81 |
function yasr_color_scheme_multiset_callback($style_options) {
|
|
|
82 |
?>
|
83 |
|
84 |
<input type='radio' name='yasr_style_options[scheme_color_multiset]' value='light'
|
87 |
} ?> />
|
88 |
<?php _e('Light', 'yet-another-stars-rating') ?>
|
89 |
|
|
|
90 |
|
91 |
<input type='radio' name='yasr_style_options[scheme_color_multiset]' value='dark'
|
92 |
class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset'] === 'dark') {
|
130 |
rows='17'
|
131 |
cols='40'
|
132 |
name='yasr_style_options[textarea]'
|
133 |
+
id='yasr_style_options_textarea'><?php echo esc_textarea($style_options['textarea']); ?></textarea>
|
134 |
|
135 |
<?php
|
136 |
|
142 |
$output = array();
|
143 |
|
144 |
foreach ($style_options as $key => $value) {
|
145 |
+
$output[$key] = sanitize_textarea_field($style_options[$key]);
|
146 |
}
|
147 |
|
148 |
return $output;
|
admin/settings/yasr-settings-functions-misc.php
CHANGED
@@ -14,7 +14,7 @@ function yasr_settings_tabs( $active_tab )
|
|
14 |
}
|
15 |
?>">
|
16 |
<?php
|
17 |
-
_e(
|
18 |
?>
|
19 |
</a>
|
20 |
|
@@ -24,7 +24,7 @@ function yasr_settings_tabs( $active_tab )
|
|
24 |
}
|
25 |
?>">
|
26 |
<?php
|
27 |
-
_e(
|
28 |
?>
|
29 |
</a>
|
30 |
|
@@ -35,7 +35,7 @@ function yasr_settings_tabs( $active_tab )
|
|
35 |
}
|
36 |
?>">
|
37 |
<?php
|
38 |
-
_e(
|
39 |
?>
|
40 |
</a>
|
41 |
|
@@ -217,7 +217,7 @@ function yasr_custom_admin_footer( $text )
|
|
217 |
if ( isset( $_GET['page'] ) ) {
|
218 |
$yasr_page = $_GET['page'];
|
219 |
|
220 |
-
if ( $yasr_page
|
221 |
$custom_text = ' | <i>';
|
222 |
$custom_text .= sprintf(
|
223 |
__( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
|
@@ -228,12 +228,10 @@ function yasr_custom_admin_footer( $text )
|
|
228 |
);
|
229 |
$custom_text .= '</i>';
|
230 |
return $text . $custom_text;
|
231 |
-
} else {
|
232 |
-
return $text;
|
233 |
}
|
234 |
-
|
235 |
-
} else {
|
236 |
return $text;
|
237 |
}
|
238 |
-
|
|
|
239 |
}
|
14 |
}
|
15 |
?>">
|
16 |
<?php
|
17 |
+
_e( 'General Settings', 'yet-another-stars-rating' );
|
18 |
?>
|
19 |
</a>
|
20 |
|
24 |
}
|
25 |
?>">
|
26 |
<?php
|
27 |
+
_e( 'Multi Sets', 'yet-another-stars-rating' );
|
28 |
?>
|
29 |
</a>
|
30 |
|
35 |
}
|
36 |
?>">
|
37 |
<?php
|
38 |
+
_e( 'Aspect & Styles', 'yet-another-stars-rating' );
|
39 |
?>
|
40 |
</a>
|
41 |
|
217 |
if ( isset( $_GET['page'] ) ) {
|
218 |
$yasr_page = $_GET['page'];
|
219 |
|
220 |
+
if ( $yasr_page === 'yasr_settings_page' ) {
|
221 |
$custom_text = ' | <i>';
|
222 |
$custom_text .= sprintf(
|
223 |
__( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
|
228 |
);
|
229 |
$custom_text .= '</i>';
|
230 |
return $text . $custom_text;
|
|
|
|
|
231 |
}
|
232 |
+
|
|
|
233 |
return $text;
|
234 |
}
|
235 |
+
|
236 |
+
return $text;
|
237 |
}
|
admin/settings/yasr-settings-page.php
CHANGED
@@ -134,7 +134,7 @@ $n_multi_set = null; //Avoid undefined variable when printed outside multiset ta
|
|
134 |
|
135 |
|
136 |
<script type="text/javascript">
|
137 |
-
|
138 |
var activeTab = <?php echo(json_encode("$active_tab")); ?>;
|
139 |
var nMultiSet = <?php echo(json_encode("$n_multi_set")); ?> ;//Null in php is different from javascript NULL
|
140 |
var autoInsertEnabled = <?php echo(json_encode(YASR_AUTO_INSERT_ENABLED)); ?>;
|
134 |
|
135 |
|
136 |
<script type="text/javascript">
|
137 |
+
document.addEventListener("DOMContentLoaded", function() {
|
138 |
var activeTab = <?php echo(json_encode("$active_tab")); ?>;
|
139 |
var nMultiSet = <?php echo(json_encode("$n_multi_set")); ?> ;//Null in php is different from javascript NULL
|
140 |
var autoInsertEnabled = <?php echo(json_encode(YASR_AUTO_INSERT_ENABLED)); ?>;
|
admin/yasr-admin-functions.php
CHANGED
@@ -23,9 +23,9 @@ if (!defined('ABSPATH')) {
|
|
23 |
} // Exit if accessed directly
|
24 |
|
25 |
//action is in the main file
|
26 |
-
function yasr_on_create_blog( $
|
27 |
if (is_plugin_active_for_network( 'yet-another-stars-rating/yet-another-stars-rating.php' )) {
|
28 |
-
switch_to_blog($blog_id);
|
29 |
YasrOnInstall::createTables();
|
30 |
restore_current_blog();
|
31 |
}
|
23 |
} // Exit if accessed directly
|
24 |
|
25 |
//action is in the main file
|
26 |
+
function yasr_on_create_blog(WP_Site $new_site) {
|
27 |
if (is_plugin_active_for_network( 'yet-another-stars-rating/yet-another-stars-rating.php' )) {
|
28 |
+
switch_to_blog($new_site->blog_id);
|
29 |
YasrOnInstall::createTables();
|
30 |
restore_current_blog();
|
31 |
}
|
admin/yasr-admin-init.php
CHANGED
@@ -83,6 +83,12 @@ function yasr_add_admin_scripts($hook) {
|
|
83 |
);
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
if ($hook === 'index.php' || $hook === 'edit.php' || $hook === 'post.php' || $hook === 'post-new.php' ||
|
87 |
$hook === 'edit-comments.php' || $hook === $yasr_settings_page ||
|
88 |
$hook === 'yet-another-stars-rating_page_yasr_stats_page'
|
83 |
);
|
84 |
}
|
85 |
|
86 |
+
//add this only in yasr setting page (admin.php?page=yasr_settings_page)
|
87 |
+
if ($hook === $yasr_settings_page) {
|
88 |
+
$cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/css'));
|
89 |
+
wp_localize_script('jquery', 'yasr_cm_settings', $cm_settings);
|
90 |
+
}
|
91 |
+
|
92 |
if ($hook === 'index.php' || $hook === 'edit.php' || $hook === 'post.php' || $hook === 'post-new.php' ||
|
93 |
$hook === 'edit-comments.php' || $hook === $yasr_settings_page ||
|
94 |
$hook === 'yet-another-stars-rating_page_yasr_stats_page'
|
includes/rest/classes/YasrCustomEndpoint.php
CHANGED
@@ -9,7 +9,7 @@ class YasrCustomEndpoint extends WP_REST_Controller {
|
|
9 |
/**
|
10 |
* Constructor
|
11 |
*/
|
12 |
-
public function
|
13 |
add_action('rest_api_init', array( $this, 'customEndpoint'));
|
14 |
}
|
15 |
|
@@ -55,7 +55,8 @@ class YasrCustomEndpoint extends WP_REST_Controller {
|
|
55 |
|
56 |
/**
|
57 |
*
|
58 |
-
*
|
|
|
59 |
*
|
60 |
* @param WP_REST_Request $request
|
61 |
*
|
@@ -65,7 +66,6 @@ class YasrCustomEndpoint extends WP_REST_Controller {
|
|
65 |
/*
|
66 |
* Get cleaned params
|
67 |
*/
|
68 |
-
|
69 |
$set_id = $request['set_id'];
|
70 |
$post_id = $request['post_id'];
|
71 |
$visitor = $request['visitor'];
|
@@ -104,6 +104,8 @@ class YasrCustomEndpoint extends WP_REST_Controller {
|
|
104 |
}
|
105 |
|
106 |
/**
|
|
|
|
|
107 |
* @param $param
|
108 |
* @param $request
|
109 |
* @param $key
|
@@ -144,7 +146,6 @@ class YasrCustomEndpoint extends WP_REST_Controller {
|
|
144 |
if($key === 'visitor') {
|
145 |
return (int)$param;
|
146 |
}
|
147 |
-
|
148 |
return;
|
149 |
}
|
150 |
}
|
9 |
/**
|
10 |
* Constructor
|
11 |
*/
|
12 |
+
public function restApiInit() {
|
13 |
add_action('rest_api_init', array( $this, 'customEndpoint'));
|
14 |
}
|
15 |
|
55 |
|
56 |
/**
|
57 |
*
|
58 |
+
* Returns Author Multi Set
|
59 |
+
* must be public
|
60 |
*
|
61 |
* @param WP_REST_Request $request
|
62 |
*
|
66 |
/*
|
67 |
* Get cleaned params
|
68 |
*/
|
|
|
69 |
$set_id = $request['set_id'];
|
70 |
$post_id = $request['post_id'];
|
71 |
$visitor = $request['visitor'];
|
104 |
}
|
105 |
|
106 |
/**
|
107 |
+
* Sanitizie input, must be public
|
108 |
+
*
|
109 |
* @param $param
|
110 |
* @param $request
|
111 |
* @param $key
|
146 |
if($key === 'visitor') {
|
147 |
return (int)$param;
|
148 |
}
|
|
|
149 |
return;
|
150 |
}
|
151 |
}
|
includes/rest/classes/YasrCustomFields.php
CHANGED
@@ -7,9 +7,9 @@ if (!defined('ABSPATH')) {
|
|
7 |
class YasrCustomFields extends WP_REST_Controller {
|
8 |
|
9 |
/**
|
10 |
-
*
|
11 |
*/
|
12 |
-
public function
|
13 |
add_action('rest_api_init', array( $this, 'customFields'));
|
14 |
}
|
15 |
|
@@ -19,7 +19,6 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
19 |
* YOURSITE.COM/wp-json/wp/v2/posts
|
20 |
*/
|
21 |
public function customFields () {
|
22 |
-
|
23 |
/**
|
24 |
* Add <yasr-visitor-votes> in
|
25 |
* YOURSITE.COM/wp-json/wp/v2/posts
|
@@ -30,7 +29,15 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
*/
|
35 |
private function visitorVotes() {
|
36 |
$post_types = yasr_return_all_post_types();
|
@@ -99,7 +106,9 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
-
*
|
|
|
|
|
103 |
*/
|
104 |
private function allItemTypes() {
|
105 |
$post_types = yasr_return_all_post_types();
|
@@ -114,7 +123,7 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
114 |
$post_types,
|
115 |
'yasr_all_itemtypes',
|
116 |
array(
|
117 |
-
'get_callback' => function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES); },
|
118 |
'update_callback' => null,
|
119 |
'schema' => $yasr_itemtype_schema
|
120 |
)
|
@@ -122,7 +131,8 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
-
*
|
|
|
126 |
*/
|
127 |
private function itemTypesAdditionalFields() {
|
128 |
$post_types = yasr_return_all_post_types();
|
@@ -135,9 +145,9 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
135 |
//Register Visitor Votes
|
136 |
register_rest_field(
|
137 |
$post_types,
|
138 |
-
'
|
139 |
array(
|
140 |
-
'get_callback' => function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS); },
|
141 |
'update_callback' => null,
|
142 |
'schema' => $yasr_additional_itemtype_schema
|
143 |
)
|
7 |
class YasrCustomFields extends WP_REST_Controller {
|
8 |
|
9 |
/**
|
10 |
+
* Add in rest_api_init
|
11 |
*/
|
12 |
+
public function restApiInit() {
|
13 |
add_action('rest_api_init', array( $this, 'customFields'));
|
14 |
}
|
15 |
|
19 |
* YOURSITE.COM/wp-json/wp/v2/posts
|
20 |
*/
|
21 |
public function customFields () {
|
|
|
22 |
/**
|
23 |
* Add <yasr-visitor-votes> in
|
24 |
* YOURSITE.COM/wp-json/wp/v2/posts
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
+
* Returns a multidimensionalarray like this:
|
33 |
+
* "yasr_visitor_votes": {
|
34 |
+
* "number_of_votes": int,
|
35 |
+
* "sum_votes": int,
|
36 |
+
* "stars_attributes": {
|
37 |
+
* "read_only": bool,
|
38 |
+
* "span_bottom": string
|
39 |
+
* }
|
40 |
+
* }
|
41 |
*/
|
42 |
private function visitorVotes() {
|
43 |
$post_types = yasr_return_all_post_types();
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
+
* Function to returns all supported itemtype
|
110 |
+
* (YASR_SUPPORTED_SCHEMA_TYPES)
|
111 |
+
* only in the editor screen
|
112 |
*/
|
113 |
private function allItemTypes() {
|
114 |
$post_types = yasr_return_all_post_types();
|
123 |
$post_types,
|
124 |
'yasr_all_itemtypes',
|
125 |
array(
|
126 |
+
'get_callback' => function() {return json_decode( YASR_SUPPORTED_SCHEMA_TYPES, true ); },
|
127 |
'update_callback' => null,
|
128 |
'schema' => $yasr_itemtype_schema
|
129 |
)
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
+
* Function that returns YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS
|
135 |
+
* only in the edit screen (for guteberg editor)
|
136 |
*/
|
137 |
private function itemTypesAdditionalFields() {
|
138 |
$post_types = yasr_return_all_post_types();
|
145 |
//Register Visitor Votes
|
146 |
register_rest_field(
|
147 |
$post_types,
|
148 |
+
'yasr_all_itemtypes_addition_info',
|
149 |
array(
|
150 |
+
'get_callback' => static function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true); },
|
151 |
'update_callback' => null,
|
152 |
'schema' => $yasr_additional_itemtype_schema
|
153 |
)
|
includes/rest/classes/YasrPostMeta.php
CHANGED
@@ -6,10 +6,10 @@ if (!defined('ABSPATH')) {
|
|
6 |
|
7 |
class YasrPostMeta {
|
8 |
/**
|
9 |
-
*
|
10 |
*/
|
11 |
-
public function
|
12 |
-
add_action('init', array( $this, '
|
13 |
}
|
14 |
|
15 |
/*
|
@@ -19,8 +19,7 @@ class YasrPostMeta {
|
|
19 |
* YOURSITE.COM/wp-json/wp/v2/posts/<POSTID>?_field=meta
|
20 |
*
|
21 |
*/
|
22 |
-
|
23 |
-
public function postMeta () {
|
24 |
register_meta(
|
25 |
'post',
|
26 |
'yasr_overall_rating',
|
6 |
|
7 |
class YasrPostMeta {
|
8 |
/**
|
9 |
+
* Load in init
|
10 |
*/
|
11 |
+
public function init() {
|
12 |
+
add_action('init', array( $this, 'registerPostMeta' ));
|
13 |
}
|
14 |
|
15 |
/*
|
19 |
* YOURSITE.COM/wp-json/wp/v2/posts/<POSTID>?_field=meta
|
20 |
*
|
21 |
*/
|
22 |
+
public function registerPostMeta () {
|
|
|
23 |
register_meta(
|
24 |
'post',
|
25 |
'yasr_overall_rating',
|
includes/rest/yasr-rest.php
CHANGED
@@ -36,3 +36,7 @@ $yasr_custom_fields = new YasrCustomFields();
|
|
36 |
|
37 |
//register new route
|
38 |
$yasr_custom_endpoint = new YasrCustomEndpoint();
|
|
|
|
|
|
|
|
36 |
|
37 |
//register new route
|
38 |
$yasr_custom_endpoint = new YasrCustomEndpoint();
|
39 |
+
|
40 |
+
$yasr_post_meta->init();
|
41 |
+
$yasr_custom_fields->restApiInit();
|
42 |
+
$yasr_custom_endpoint->restApiInit();
|
includes/yasr-includes-functions.php
CHANGED
@@ -81,7 +81,7 @@ function yasr_rtl_support() {
|
|
81 |
|
82 |
|
83 |
/****** Translating YASR ******/
|
84 |
-
add_action('init', 'yasr_translate_option'
|
85 |
|
86 |
function yasr_translate_option() {
|
87 |
load_plugin_textdomain('yet-another-stars-rating', false, YASR_LANG_DIR);
|
81 |
|
82 |
|
83 |
/****** Translating YASR ******/
|
84 |
+
add_action('init', 'yasr_translate_option');
|
85 |
|
86 |
function yasr_translate_option() {
|
87 |
load_plugin_textdomain('yet-another-stars-rating', false, YASR_LANG_DIR);
|
includes/yasr-includes-init.php
CHANGED
@@ -175,10 +175,11 @@ if ($multi_set_options) {
|
|
175 |
|
176 |
global $wpdb;
|
177 |
|
|
|
|
|
178 |
define('YASR_MULTI_SET_NAME_TABLE', $wpdb->prefix . 'yasr_multi_set');
|
179 |
define('YASR_MULTI_SET_FIELDS_TABLE', $wpdb->prefix . 'yasr_multi_set_fields');
|
180 |
-
|
181 |
-
define('YASR_LOG_TABLE', $wpdb->prefix . 'yasr_log');
|
182 |
define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
|
183 |
|
184 |
//Text for button in settings pages
|
175 |
|
176 |
global $wpdb;
|
177 |
|
178 |
+
define('YASR_LOG_TABLE', $wpdb->prefix . 'yasr_log');
|
179 |
+
define('YASR_LOG_MULTI_SET', $wpdb->prefix . 'yasr_log_multi_set');
|
180 |
define('YASR_MULTI_SET_NAME_TABLE', $wpdb->prefix . 'yasr_multi_set');
|
181 |
define('YASR_MULTI_SET_FIELDS_TABLE', $wpdb->prefix . 'yasr_multi_set_fields');
|
182 |
+
|
|
|
183 |
define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
|
184 |
|
185 |
//Text for button in settings pages
|
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.3.
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
@@ -111,12 +111,13 @@ YASR has been tested with:
|
|
111 |
* Wp Rocket
|
112 |
|
113 |
= Why I don't see stars in google? =
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
118 |
If you set up everythings fine, in 99% of cases your stars will appear in a week.
|
119 |
-
If doesn't,
|
120 |
|
121 |
|
122 |
== Screenshots ==
|
@@ -130,6 +131,13 @@ If doesn't, it's suggested to ask in a SEO oriented forum.
|
|
130 |
|
131 |
The full changelog can be found in the plugin's directory. Recent entries:
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
= 2.3.1 =
|
134 |
* Code refactor, according to boilerplate standards
|
135 |
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.3.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
|
111 |
* Wp Rocket
|
112 |
|
113 |
= Why I don't see stars in google? =
|
114 |
+
[Read here](https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/) and find out how to
|
115 |
+
set up rich snippets.
|
116 |
+
You can use the [Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool/u/0/) to validate
|
117 |
+
your pages.
|
118 |
+
Also [read this](https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html) google announcement.
|
119 |
If you set up everythings fine, in 99% of cases your stars will appear in a week.
|
120 |
+
If doesn't, you should work on your seo reputation.
|
121 |
|
122 |
|
123 |
== Screenshots ==
|
131 |
|
132 |
The full changelog can be found in the plugin's directory. Recent entries:
|
133 |
|
134 |
+
= 2.3.2 =
|
135 |
+
* FIXED: Uncaught TypeError randomly shows up in the browser console
|
136 |
+
* TWEAKED: removed deprecated multisite function
|
137 |
+
* TWEAKED: in tht settings page, the "custom css" textarea is now a text editor
|
138 |
+
* TWEAKED: CSS improvment in settings page
|
139 |
+
* TWEAKED: minor code cleanup
|
140 |
+
|
141 |
= 2.3.1 =
|
142 |
* Code refactor, according to boilerplate standards
|
143 |
|
yet-another-stars-rating.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
|
7 |
* testimonials to your website posts, pages and CPT, without affecting its speed.
|
8 |
-
* Version: 2.3.
|
9 |
* Author: Dario Curvino
|
10 |
* Author URI: https://dariocurvino.it/
|
11 |
* Text Domain: yet-another-stars-rating
|
@@ -77,7 +77,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
77 |
yasr_fs();
|
78 |
// Signal that SDK was initiated.
|
79 |
do_action( 'yasr_fs_loaded' );
|
80 |
-
define( 'YASR_VERSION_NUM', '2.3.
|
81 |
//Plugin absolute path
|
82 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
83 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|
@@ -132,7 +132,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
132 |
|
133 |
//this is called when in multisite a new blog is added
|
134 |
add_action(
|
135 |
-
'
|
136 |
'yasr_on_create_blog',
|
137 |
10,
|
138 |
6
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
|
7 |
* testimonials to your website posts, pages and CPT, without affecting its speed.
|
8 |
+
* Version: 2.3.2
|
9 |
* Author: Dario Curvino
|
10 |
* Author URI: https://dariocurvino.it/
|
11 |
* Text Domain: yet-another-stars-rating
|
77 |
yasr_fs();
|
78 |
// Signal that SDK was initiated.
|
79 |
do_action( 'yasr_fs_loaded' );
|
80 |
+
define( 'YASR_VERSION_NUM', '2.3.2' );
|
81 |
//Plugin absolute path
|
82 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
83 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|
132 |
|
133 |
//this is called when in multisite a new blog is added
|
134 |
add_action(
|
135 |
+
'wp_insert_site',
|
136 |
'yasr_on_create_blog',
|
137 |
10,
|
138 |
6
|