Version Description
- FIXED: links in Recent Ratings dashboard widget (thanks to Fernando Tellado)
- Enhancement: Added REST responses. More info in the official site
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 2.2.2 |
Comparing to | |
See all releases |
Code changes from version 2.2.1 to 2.2.2
- js/src/yasr-guten-blocks.js +8 -2
- js/yasr-guten-blocks.js +2 -3
- lib/admin/editor/yasr-editor-functions.php +1 -1
- lib/admin/editor/yasr-metabox-multiple-rating.php +19 -2
- lib/admin/settings/yasr-settings-functions-misc.php +5 -5
- lib/admin/settings/yasr-settings-functions-multiset-page.php +1 -1
- lib/admin/settings/yasr-settings-functions-multiset.php +1 -1
- lib/admin/yasr-admin-classes.php +1 -1
- lib/admin/yasr-update-functions.php +13 -4
- lib/rest/YasrCustomEndpoint.php +151 -0
- lib/rest/YasrCustomFields.php +62 -0
- lib/rest/YasrPostMeta.php +76 -0
- lib/rest/yasr-rest.php +14 -0
- lib/yasr-ajax-functions.php +25 -167
- lib/yasr-db-classes.php +124 -59
- lib/yasr-db-functions.php +2 -70
- lib/yasr-deprecated.php +9 -0
- lib/yasr-functions.php +20 -34
- lib/yasr-shortcode-classes.php +67 -54
- readme.txt +7 -2
- yet-another-stars-rating.php +9 -4
js/src/yasr-guten-blocks.js
CHANGED
@@ -38,9 +38,15 @@ function YasrProText () {
|
|
38 |
return (
|
39 |
<h3>
|
40 |
{YasrProText1}
|
41 |
-
 
|
|
|
|
|
|
|
42 |
{YasrProText2}
|
43 |
-
 
|
|
|
|
|
|
|
44 |
</h3>
|
45 |
)
|
46 |
|
38 |
return (
|
39 |
<h3>
|
40 |
{YasrProText1}
|
41 |
+
|
42 |
+
<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro">
|
43 |
+
Yasr Pro.
|
44 |
+
</a><br />
|
45 |
{YasrProText2}
|
46 |
+
|
47 |
+
<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings">
|
48 |
+
yetanotherstarsrating.com
|
49 |
+
</a>
|
50 |
</h3>
|
51 |
)
|
52 |
|
js/yasr-guten-blocks.js
CHANGED
@@ -55,7 +55,7 @@ function YasrProText() {
|
|
55 |
'\xA0',
|
56 |
React.createElement(
|
57 |
'a',
|
58 |
-
{ href: 'https://yetanotherstarsrating.com
|
59 |
'Yasr Pro.'
|
60 |
),
|
61 |
React.createElement('br', null),
|
@@ -63,7 +63,7 @@ function YasrProText() {
|
|
63 |
'\xA0',
|
64 |
React.createElement(
|
65 |
'a',
|
66 |
-
{ href: 'https://yetanotherstarsrating.com
|
67 |
'yetanotherstarsrating.com'
|
68 |
)
|
69 |
);
|
@@ -621,7 +621,6 @@ registerBlockType('yet-another-stars-rating/overall-rating-ranking', {
|
|
621 |
keywords: [__('ranking', 'yet-another-stars-rating'), __('highest', 'yet-another-stars-rating'), __('chart', 'yet-another-stars-rating')],
|
622 |
|
623 |
edit: function edit(props) {
|
624 |
-
|
625 |
return React.createElement(
|
626 |
Fragment,
|
627 |
null,
|
55 |
'\xA0',
|
56 |
React.createElement(
|
57 |
'a',
|
58 |
+
{ href: 'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro' },
|
59 |
'Yasr Pro.'
|
60 |
),
|
61 |
React.createElement('br', null),
|
63 |
'\xA0',
|
64 |
React.createElement(
|
65 |
'a',
|
66 |
+
{ href: 'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings' },
|
67 |
'yetanotherstarsrating.com'
|
68 |
)
|
69 |
);
|
621 |
keywords: [__('ranking', 'yet-another-stars-rating'), __('highest', 'yet-another-stars-rating'), __('chart', 'yet-another-stars-rating')],
|
622 |
|
623 |
edit: function edit(props) {
|
|
|
624 |
return React.createElement(
|
625 |
Fragment,
|
626 |
null,
|
lib/admin/editor/yasr-editor-functions.php
CHANGED
@@ -127,7 +127,7 @@ function yasr_add_metaboxes() {
|
|
127 |
);
|
128 |
}
|
129 |
|
130 |
-
$multi_set =
|
131 |
//If multiset are used then add the second metabox
|
132 |
if ($multi_set) {
|
133 |
foreach ($post_type_where_display_metabox as $post_type) {
|
127 |
);
|
128 |
}
|
129 |
|
130 |
+
$multi_set = YasrMultiSetData::returnMultiSetNames();
|
131 |
//If multiset are used then add the second metabox
|
132 |
if ($multi_set) {
|
133 |
foreach ($post_type_where_display_metabox as $post_type) {
|
lib/admin/editor/yasr-metabox-multiple-rating.php
CHANGED
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
20 |
|
21 |
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
|
22 |
|
23 |
-
$multi_set =
|
24 |
|
25 |
$post_id = get_the_ID();
|
26 |
|
@@ -85,7 +85,24 @@ elseif ($n_multi_set === 1) {
|
|
85 |
|
86 |
<?php _e( "If, instead, you want allow your visitor to vote on this multiset, use this shortcode", 'yet-another-stars-rating' ); ?>
|
87 |
<span id='yasr-multi-set-admin-explain-with-id-visitor'></span>.
|
88 |
-
<?php _e('In this case, you don\'t need to vote here', 'yet-another-stars-rating');?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
</div>
|
91 |
|
20 |
|
21 |
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
|
22 |
|
23 |
+
$multi_set = YasrMultiSetData::returnMultiSetNames();
|
24 |
|
25 |
$post_id = get_the_ID();
|
26 |
|
85 |
|
86 |
<?php _e( "If, instead, you want allow your visitor to vote on this multiset, use this shortcode", 'yet-another-stars-rating' ); ?>
|
87 |
<span id='yasr-multi-set-admin-explain-with-id-visitor'></span>.
|
88 |
+
<?php _e('In this case, you don\'t need to vote here', 'yet-another-stars-rating');?>
|
89 |
+
|
90 |
+
<br />
|
91 |
+
<br />
|
92 |
+
|
93 |
+
<?php
|
94 |
+
$yasr_pro_string = sprintf(
|
95 |
+
__( "With %sYasr Pro%s you can use %s yasr_pro_average_multiset %s and
|
96 |
+
%s yasr_pro_average_visitor_multiset %s to print a separate average of the Multi Set.",
|
97 |
+
'yet-another-stars-rating' ),
|
98 |
+
'<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=metabox_multiple_rating&utm_campaign=yasr_editor_screen&utm_content=yasr-pro#yasr-pro">',
|
99 |
+
'</a>',
|
100 |
+
'<strong>', '</strong>',
|
101 |
+
'<strong>', '</strong>');
|
102 |
+
|
103 |
+
echo $yasr_pro_string;
|
104 |
+
?>
|
105 |
+
<span id='yasr-multi-set-admin-explain-with-id-visitor'></span>
|
106 |
|
107 |
</div>
|
108 |
|
lib/admin/settings/yasr-settings-functions-misc.php
CHANGED
@@ -140,15 +140,15 @@ function yasr_resources_box( $position = false )
|
|
140 |
$text = '<div class="yasr-donate-title">Resources</div>';
|
141 |
$text .= '<div class="yasr-donate-single-resource">
|
142 |
<span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
|
143 |
-
<a target="blank" href="https://yetanotherstarsrating.com
|
144 |
</div>';
|
145 |
$text .= '<div class="yasr-donate-single-resource">
|
146 |
<span class="dashicons dashicons-edit" style="color: #ccc"></span>
|
147 |
-
<a target="blank" href="https://yetanotherstarsrating.com/docs
|
148 |
</div>';
|
149 |
$text .= '<div class="yasr-donate-single-resource">
|
150 |
<span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
|
151 |
-
<a target="blank" href="https://yetanotherstarsrating.com/docs/faq
|
152 |
</div>';
|
153 |
$text .= '<div class="yasr-donate-single-resource">
|
154 |
<span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
|
@@ -156,7 +156,7 @@ function yasr_resources_box( $position = false )
|
|
156 |
</div>';
|
157 |
$text .= '<div class="yasr-donate-single-resource">
|
158 |
<span class="dashicons dashicons-smiley" style="color: #ccc"></span>
|
159 |
-
<a target="blank" href="https://yetanotherstarsrating.com/#yasr-pro">
|
160 |
Yasr Pro
|
161 |
</a>
|
162 |
</div>';
|
@@ -222,7 +222,7 @@ function yasr_custom_admin_footer( $text )
|
|
222 |
$custom_text .= sprintf(
|
223 |
__( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
|
224 |
Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>', 'yet-another-stars-rating' ),
|
225 |
-
'https://yetanotherstarsrating.com',
|
226 |
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
|
227 |
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
|
228 |
);
|
140 |
$text = '<div class="yasr-donate-title">Resources</div>';
|
141 |
$text .= '<div class="yasr-donate-single-resource">
|
142 |
<span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
|
143 |
+
<a target="blank" href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_official">' . __( 'YASR official website', 'yet-another-stars-rating' ) . '</a>
|
144 |
</div>';
|
145 |
$text .= '<div class="yasr-donate-single-resource">
|
146 |
<span class="dashicons dashicons-edit" style="color: #ccc"></span>
|
147 |
+
<a target="blank" href="https://yetanotherstarsrating.com/docs/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=documentation">' . __( 'Documentation', 'yet-another-stars-rating' ) . '</a>
|
148 |
</div>';
|
149 |
$text .= '<div class="yasr-donate-single-resource">
|
150 |
<span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
|
151 |
+
<a target="blank" href="https://yetanotherstarsrating.com/docs/faq/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=faq">' . __( 'F.A.Q.', 'yet-another-stars-rating' ) . '</a>
|
152 |
</div>';
|
153 |
$text .= '<div class="yasr-donate-single-resource">
|
154 |
<span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
|
156 |
</div>';
|
157 |
$text .= '<div class="yasr-donate-single-resource">
|
158 |
<span class="dashicons dashicons-smiley" style="color: #ccc"></span>
|
159 |
+
<a target="blank" href="https://yetanotherstarsrating.com/#yasr-pro?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr-pro">
|
160 |
Yasr Pro
|
161 |
</a>
|
162 |
</div>';
|
222 |
$custom_text .= sprintf(
|
223 |
__( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
|
224 |
Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>', 'yet-another-stars-rating' ),
|
225 |
+
'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=footer&utm_campaign=yasr_settings',
|
226 |
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
|
227 |
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
|
228 |
);
|
lib/admin/settings/yasr-settings-functions-multiset-page.php
CHANGED
@@ -58,7 +58,7 @@ OR option_name LIKE '_transient_timeout_yasr_visitor_multi_set_%'
|
|
58 |
|
59 |
$wpdb->query($sql_delete_transient);
|
60 |
|
61 |
-
$multi_set =
|
62 |
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
63 |
|
64 |
?>
|
58 |
|
59 |
$wpdb->query($sql_delete_transient);
|
60 |
|
61 |
+
$multi_set = YasrMultiSetData::returnMultiSetNames();
|
62 |
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
63 |
|
64 |
?>
|
lib/admin/settings/yasr-settings-functions-multiset.php
CHANGED
@@ -145,7 +145,7 @@ function yasr_edit_multi_form() {
|
|
145 |
|
146 |
global $wpdb;
|
147 |
|
148 |
-
$multi_set =
|
149 |
|
150 |
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
151 |
|
145 |
|
146 |
global $wpdb;
|
147 |
|
148 |
+
$multi_set = YasrMultiSetData::returnMultiSetNames();
|
149 |
|
150 |
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
151 |
|
lib/admin/yasr-admin-classes.php
CHANGED
@@ -208,7 +208,7 @@ class YasrLogDashboardWidget {
|
|
208 |
'</div>
|
209 |
<div class="yasr-log-child-head">
|
210 |
<span id="yasr-log-vote">'.$yasr_log_vote_text.'</span>
|
211 |
-
<span id="yasr-log-post"><a href
|
212 |
</div>
|
213 |
<div class="yasr-log-ip-date">'
|
214 |
.$ip_span.
|
208 |
'</div>
|
209 |
<div class="yasr-log-child-head">
|
210 |
<span id="yasr-log-vote">'.$yasr_log_vote_text.'</span>
|
211 |
+
<span id="yasr-log-post"><a href="'. $link .'">'.$post_title.'</a></span>
|
212 |
</div>
|
213 |
<div class="yasr-log-ip-date">'
|
214 |
.$ip_span.
|
lib/admin/yasr-update-functions.php
CHANGED
@@ -140,10 +140,9 @@ function yasr_update_version() {
|
|
140 |
|
141 |
//delete all transient that use multiset
|
142 |
$sql_delete_transient = "
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
";
|
147 |
|
148 |
$wpdb->query($sql_delete_transient);
|
149 |
|
@@ -279,6 +278,16 @@ function yasr_update_version() {
|
|
279 |
$wpdb->query($sql_delete_transient_multiset);
|
280 |
}
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
/****** End backward compatibility functions ******/
|
283 |
if ($yasr_version_installed != YASR_VERSION_NUM) {
|
284 |
update_option('yasr-version', YASR_VERSION_NUM);
|
140 |
|
141 |
//delete all transient that use multiset
|
142 |
$sql_delete_transient = "
|
143 |
+
DELETE FROM {$wpdb->options}
|
144 |
+
WHERE option_name LIKE '_transient_yasr_visitor_multi_set_%'
|
145 |
+
OR option_name LIKE '_transient_timeout_yasr_visitor_multi_set_%' ";
|
|
|
146 |
|
147 |
$wpdb->query($sql_delete_transient);
|
148 |
|
278 |
$wpdb->query($sql_delete_transient_multiset);
|
279 |
}
|
280 |
|
281 |
+
if (version_compare($yasr_version_installed, '2.2.2') === -1) {
|
282 |
+
//delete all transient that uses multiset
|
283 |
+
$sql_delete_transient_visitor_votes = "
|
284 |
+
DELETE FROM {$wpdb->options}
|
285 |
+
WHERE option_name LIKE '_transient_yasr_visitor_votes_%'
|
286 |
+
OR option_name LIKE '_transient_timeout_yasr_visitor_votes_%'
|
287 |
+
";
|
288 |
+
$wpdb->query($sql_delete_transient_visitor_votes);
|
289 |
+
}
|
290 |
+
|
291 |
/****** End backward compatibility functions ******/
|
292 |
if ($yasr_version_installed != YASR_VERSION_NUM) {
|
293 |
update_option('yasr-version', YASR_VERSION_NUM);
|
lib/rest/YasrCustomEndpoint.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH')) {
|
4 |
+
exit('You\'re not allowed to see this page');
|
5 |
+
} // Exit if accessed directly
|
6 |
+
|
7 |
+
class YasrCustomEndpoint extends WP_REST_Controller {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Constructor
|
11 |
+
*/
|
12 |
+
public function __construct() {
|
13 |
+
add_action('rest_api_init', array( $this, 'customEndpoint'));
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* All the functions that need parameters
|
19 |
+
*/
|
20 |
+
public function customEndpoint () {
|
21 |
+
/*
|
22 |
+
* Param for this route must be
|
23 |
+
* YOURSITE/wp-json/yet-another-stars-rating/v1/yasr-multiset/<ID>?post_id=<ID>
|
24 |
+
* OPTIONAL &visitor=1
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
$namespace = 'yet-another-stars-rating/';
|
28 |
+
$version = 'v1/';
|
29 |
+
$base = 'yasr-multiset';
|
30 |
+
|
31 |
+
register_rest_route(
|
32 |
+
$namespace . $version . $base . '/',
|
33 |
+
'(?P<set_id>\d+)',
|
34 |
+
array(
|
35 |
+
'methods' => WP_REST_Server::READABLE,
|
36 |
+
'callback' => array($this, 'authorMultiSet'),
|
37 |
+
'args' => array(
|
38 |
+
'set_id' => array(
|
39 |
+
'required' => true,
|
40 |
+
'sanitize_callback' => array($this, 'sanitizeInput')
|
41 |
+
),
|
42 |
+
'post_id' => array(
|
43 |
+
'required' => true,
|
44 |
+
'sanitize_callback' => array($this, 'sanitizeInput')
|
45 |
+
),
|
46 |
+
'visitor' => array(
|
47 |
+
'default' => 0,
|
48 |
+
'required' => false,
|
49 |
+
'sanitize_callback' => array($this, 'sanitizeInput')
|
50 |
+
),
|
51 |
+
),
|
52 |
+
)
|
53 |
+
);
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
*
|
59 |
+
* Return Author Multi Set
|
60 |
+
*
|
61 |
+
* @param WP_REST_Request $request
|
62 |
+
*
|
63 |
+
* @return WP_Error|WP_REST_Response
|
64 |
+
*/
|
65 |
+
public function authorMultiSet ($request) {
|
66 |
+
/*
|
67 |
+
* Get cleaned params
|
68 |
+
*/
|
69 |
+
|
70 |
+
$set_id = $request['set_id'];
|
71 |
+
$post_id = $request['post_id'];
|
72 |
+
$visitor = $request['visitor'];
|
73 |
+
|
74 |
+
$data_to_return = array(
|
75 |
+
'set_id' => $set_id
|
76 |
+
);
|
77 |
+
|
78 |
+
$invalid_set = false;
|
79 |
+
|
80 |
+
//if $visitor === 1 then get data from yasr_visitor_multiset
|
81 |
+
if($visitor === 1) {
|
82 |
+
$data_to_return['yasr_visitor_multiset'] = YasrMultiSetData::returnVisitorMultiSetContent($post_id, $set_id);
|
83 |
+
if ($data_to_return['yasr_visitor_multiset'] === false) {
|
84 |
+
$invalid_set = true;
|
85 |
+
}
|
86 |
+
} else {
|
87 |
+
$data_to_return['yasr_multiset'] = YasrMultiSetData::returnMultisetContent($post_id, $set_id);
|
88 |
+
if ($data_to_return['yasr_multiset'] === false) {
|
89 |
+
$invalid_set = true;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($invalid_set === true) {
|
94 |
+
return new WP_Error(
|
95 |
+
'invalid_multiset',
|
96 |
+
__('This Multi Set doesn\'t exists', 'yet-another-stars-rating'),
|
97 |
+
400
|
98 |
+
);
|
99 |
+
}
|
100 |
+
|
101 |
+
$response = new WP_REST_Response($data_to_return);
|
102 |
+
$response->set_status(200);
|
103 |
+
|
104 |
+
return $response;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param $param
|
109 |
+
* @param $request
|
110 |
+
* @param $key
|
111 |
+
*
|
112 |
+
* @return int|void|WP_Error
|
113 |
+
*/
|
114 |
+
public function sanitizeInput ($param, $request, $key) {
|
115 |
+
if($key === 'set_id') {
|
116 |
+
return (int)$param;
|
117 |
+
}
|
118 |
+
|
119 |
+
if($key === 'post_id') {
|
120 |
+
$post_id = (int)$param;
|
121 |
+
|
122 |
+
/*if post_id is null means that is not set in the request.
|
123 |
+
* (int) will convert it to 0.
|
124 |
+
* When WordPress is installed, the first post has ID = 1
|
125 |
+
*/
|
126 |
+
if ($post_id === 0) {
|
127 |
+
return new WP_Error (
|
128 |
+
'wrong_post_id',
|
129 |
+
__('Invalid Post ID', 'yet-another-stars-rating'),
|
130 |
+
400
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
//Check if exists a post with this ID
|
135 |
+
if (get_post($post_id) === null) {
|
136 |
+
return new WP_Error (
|
137 |
+
'wrong_post_id',
|
138 |
+
__('Post ID doesn\'t exists', 'yet-another-stars-rating'),
|
139 |
+
404
|
140 |
+
);
|
141 |
+
}
|
142 |
+
return $post_id;
|
143 |
+
}
|
144 |
+
|
145 |
+
if($key === 'visitor') {
|
146 |
+
return (int)$param;
|
147 |
+
}
|
148 |
+
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
}
|
lib/rest/YasrCustomFields.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH')) {
|
4 |
+
exit('You\'re not allowed to see this page');
|
5 |
+
} // Exit if accessed directly
|
6 |
+
|
7 |
+
class YasrCustomFields extends WP_REST_Controller {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Constructor
|
11 |
+
*/
|
12 |
+
public function __construct() {
|
13 |
+
add_action('rest_api_init', array( $this, 'customFields'));
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Add a new response in
|
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
|
26 |
+
*/
|
27 |
+
$this->visitorVotes();
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Helper function to return visitorVotes
|
32 |
+
*/
|
33 |
+
private function visitorVotes() {
|
34 |
+
$post_types = yasr_return_all_post_types();
|
35 |
+
$yasr_vv_schema = array(
|
36 |
+
'description' => 'Yasr Visitor Votes Data',
|
37 |
+
'type' => 'object',
|
38 |
+
'context' => array('view', 'edit'),
|
39 |
+
// In JSON Schema you can specify object properties in the properties attribute.
|
40 |
+
'properties' => array(
|
41 |
+
'sum_votes' => array(
|
42 |
+
'type' => 'integer',
|
43 |
+
),
|
44 |
+
'number_of_votes' => array(
|
45 |
+
'type' => 'integer',
|
46 |
+
),
|
47 |
+
),
|
48 |
+
);
|
49 |
+
|
50 |
+
//Register Visitor Votes
|
51 |
+
register_rest_field(
|
52 |
+
$post_types,
|
53 |
+
'yasr-visitor-votes',
|
54 |
+
array(
|
55 |
+
'get_callback' => function() {return YasrDatabaseRatings::getVisitorVotes(); },
|
56 |
+
'update_callback' => null,
|
57 |
+
'schema' => $yasr_vv_schema
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
+
}
|
62 |
+
}
|
lib/rest/YasrPostMeta.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH')) {
|
4 |
+
exit('You\'re not allowed to see this page');
|
5 |
+
} // Exit if accessed directly
|
6 |
+
|
7 |
+
class YasrPostMeta {
|
8 |
+
/**
|
9 |
+
* Constructor
|
10 |
+
*/
|
11 |
+
public function __construct() {
|
12 |
+
add_action('init', array( $this, 'postMeta' ));
|
13 |
+
}
|
14 |
+
|
15 |
+
/*
|
16 |
+
* Get Yasr Post Meta Values and insert in the rest response
|
17 |
+
* YOURSITE.COM/wp-json/wp/v2/posts?_field=meta
|
18 |
+
* or
|
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',
|
27 |
+
array(
|
28 |
+
'show_in_rest' => true,
|
29 |
+
'single' => true,
|
30 |
+
'type' => 'number',
|
31 |
+
'auth_callback' => function() {
|
32 |
+
return current_user_can('edit_posts');
|
33 |
+
}
|
34 |
+
)
|
35 |
+
);
|
36 |
+
|
37 |
+
register_meta(
|
38 |
+
'post',
|
39 |
+
'yasr_post_is_review',
|
40 |
+
array(
|
41 |
+
'show_in_rest' => true,
|
42 |
+
'single' => true,
|
43 |
+
'type' => 'string',
|
44 |
+
'auth_callback' => function() {
|
45 |
+
return current_user_can('edit_posts');
|
46 |
+
}
|
47 |
+
)
|
48 |
+
);
|
49 |
+
|
50 |
+
register_meta(
|
51 |
+
'post',
|
52 |
+
'yasr_auto_insert_disabled',
|
53 |
+
array(
|
54 |
+
'show_in_rest' => true,
|
55 |
+
'single' => true,
|
56 |
+
'type' => 'string',
|
57 |
+
'auth_callback' => function() {
|
58 |
+
return current_user_can('edit_posts');
|
59 |
+
}
|
60 |
+
)
|
61 |
+
);
|
62 |
+
|
63 |
+
register_meta(
|
64 |
+
'post',
|
65 |
+
'yasr_review_type',
|
66 |
+
array(
|
67 |
+
'show_in_rest' => true,
|
68 |
+
'single' => true,
|
69 |
+
'type' => 'string',
|
70 |
+
'auth_callback' => function() {
|
71 |
+
return current_user_can('edit_posts');
|
72 |
+
}
|
73 |
+
)
|
74 |
+
);
|
75 |
+
}
|
76 |
+
}
|
lib/rest/yasr-rest.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH')) {
|
4 |
+
exit('You\'re not allowed to see this page');
|
5 |
+
} // Exit if accessed directly
|
6 |
+
|
7 |
+
//get all post meta and return it in the meta[] response
|
8 |
+
$yasr_post_meta = new YasrPostMeta();
|
9 |
+
|
10 |
+
//add a custom response
|
11 |
+
$yasr_custom_fields = new YasrCustomFields();
|
12 |
+
|
13 |
+
//register new route
|
14 |
+
$yasr_custom_endpoint = new YasrCustomEndpoint();
|
lib/yasr-ajax-functions.php
CHANGED
@@ -66,7 +66,7 @@ function wp_ajax_yasr_create_shortcode_callback() {
|
|
66 |
|
67 |
global $wpdb;
|
68 |
|
69 |
-
$multi_set =
|
70 |
$n_multi_set = $wpdb->num_rows;
|
71 |
|
72 |
?>
|
@@ -80,8 +80,11 @@ function wp_ajax_yasr_create_shortcode_callback() {
|
|
80 |
class="nav-tab yasr-nav-tab"><?php _e("Charts", 'yet-another-stars-rating'); ?></a>
|
81 |
<?php do_action('yasr_add_tabs_on_tinypopupform'); ?>
|
82 |
|
83 |
-
<a href="https://yetanotherstarsrating.com/yasr-basics-shortcode
|
84 |
-
|
|
|
|
|
|
|
85 |
|
86 |
</h2>
|
87 |
|
@@ -288,144 +291,6 @@ function wp_ajax_yasr_create_shortcode_callback() {
|
|
288 |
|
289 |
/********** END Functions used while wirting a new post or page ********/
|
290 |
|
291 |
-
//add_action('wp_ajax_yasr_change_user_log_page', 'yasr_change_user_log_page_callback');
|
292 |
-
|
293 |
-
function yasr_change_user_log_page_callback() {
|
294 |
-
|
295 |
-
if (isset($_POST['pagenum'])) {
|
296 |
-
$page_num = (int)$_POST['pagenum'];
|
297 |
-
$num_of_pages = (int)$_POST['totalpages'];
|
298 |
-
} else {
|
299 |
-
$page_num = 1;
|
300 |
-
}
|
301 |
-
|
302 |
-
$limit = 8; //max number of row to echo
|
303 |
-
|
304 |
-
$offset = ($page_num - 1) * $limit;
|
305 |
-
|
306 |
-
$user_id = get_current_user_id();
|
307 |
-
|
308 |
-
global $wpdb;
|
309 |
-
|
310 |
-
$log_result = $wpdb->get_results(
|
311 |
-
$wpdb->prepare(
|
312 |
-
"SELECT * FROM "
|
313 |
-
. YASR_LOG_TABLE .
|
314 |
-
" WHERE user_id = %d
|
315 |
-
ORDER BY date DESC
|
316 |
-
LIMIT %d, %d ",
|
317 |
-
$user_id, $offset, $limit
|
318 |
-
)
|
319 |
-
);
|
320 |
-
|
321 |
-
if (!$log_result) {
|
322 |
-
_e("No Recenet votes yet", 'yet-another-stars-rating');
|
323 |
-
} else {
|
324 |
-
|
325 |
-
foreach ($log_result as $column) {
|
326 |
-
|
327 |
-
$avatar = get_avatar($user_id, '32'); //Get avatar from user id
|
328 |
-
|
329 |
-
$title_post = wp_strip_all_tags(get_the_title($column->post_id)); //Get post title from post id
|
330 |
-
$link = get_permalink($column->post_id); //Get post link from post id
|
331 |
-
|
332 |
-
$yasr_log_vote_text = sprintf(__('You rated %s on ', 'yet-another-stars-rating'), '<strong style="color: blue">' . $column->vote . '</strong>');
|
333 |
-
|
334 |
-
echo "
|
335 |
-
|
336 |
-
<div class='yasr-log-div-child'>
|
337 |
-
|
338 |
-
<div class='yasr-log-image'>
|
339 |
-
$avatar
|
340 |
-
</div>
|
341 |
-
|
342 |
-
<div class='yasr-log-child-head'>
|
343 |
-
<span id='yasr-log-vote'>$yasr_log_vote_text</span><span class='yasr-log-post'><a href='$link'>$title_post</a></span>
|
344 |
-
</div>
|
345 |
-
|
346 |
-
<div class='yasr-log-ip-date'>
|
347 |
-
<span class='yasr-log-ip'>" . __("Ip address", 'yet-another-stars-rating') . ": <span style='color:blue'>$column->ip</span></span>
|
348 |
-
<span class='yasr-log-date'>$column->date</span>
|
349 |
-
</div>
|
350 |
-
|
351 |
-
</div>
|
352 |
-
|
353 |
-
";
|
354 |
-
|
355 |
-
} //End foreach
|
356 |
-
|
357 |
-
echo "<div id='yasr-log-page-navigation'>";
|
358 |
-
|
359 |
-
//use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
|
360 |
-
//the "last" button could not exists
|
361 |
-
//This is required on ajax, not here, but still doing it here to take it simple
|
362 |
-
echo "<span id='yasr-user-log-total-pages' data-yasr-user-log-total-pages='$num_of_pages'>";
|
363 |
-
|
364 |
-
_e("Pages", 'yet-another-stars-rating');
|
365 |
-
echo ": ($num_of_pages) ";
|
366 |
-
|
367 |
-
echo "</span>";
|
368 |
-
|
369 |
-
if ($num_of_pages <= 3) {
|
370 |
-
|
371 |
-
for ($i = 1; $i <= $num_of_pages; $i ++) {
|
372 |
-
if ($i == $page_num) {
|
373 |
-
echo "<button class='button-primary' value='$i'>$i</button> ";
|
374 |
-
} else {
|
375 |
-
echo "<button class='yasr-user-log-page-num' value='$i'>$i</button> ";
|
376 |
-
|
377 |
-
}
|
378 |
-
}
|
379 |
-
echo "<span id='yasr-loader-user-log-metabox' style='display:none;'> <img src='" . YASR_IMG_DIR . "/loader.gif' ></span>";
|
380 |
-
} else {
|
381 |
-
$start_for = $page_num - 1;
|
382 |
-
|
383 |
-
if ($start_for <= 0) {
|
384 |
-
$start_for = 1;
|
385 |
-
}
|
386 |
-
|
387 |
-
$end_for = $page_num + 1;
|
388 |
-
|
389 |
-
if ($end_for >= $num_of_pages) {
|
390 |
-
$end_for = $num_of_pages;
|
391 |
-
}
|
392 |
-
|
393 |
-
if ($page_num >= 3) {
|
394 |
-
echo "<button class='yasr-user-log-page-num' value='1'>« First </button> ... ";
|
395 |
-
}
|
396 |
-
|
397 |
-
for ($i = $start_for; $i <= $end_for; $i ++) {
|
398 |
-
|
399 |
-
if ($i == $page_num) {
|
400 |
-
echo "<button class='button-primary' value='$i'>$i</button> ";
|
401 |
-
} else {
|
402 |
-
echo "<button class='yasr-user-log-page-num' value='$i'>$i</button> ";
|
403 |
-
}
|
404 |
-
|
405 |
-
}
|
406 |
-
|
407 |
-
$num_of_page_less_one = $num_of_pages - 1;
|
408 |
-
|
409 |
-
if ($page_num != $num_of_pages && $page_num != $num_of_page_less_one) {
|
410 |
-
echo "... <button class='yasr-user-log-page-num' value='$num_of_pages'>Last »</button> ";
|
411 |
-
}
|
412 |
-
|
413 |
-
echo "<span id='yasr-user-log-container' style='display:none;' > <img src='" . YASR_IMG_DIR . "/loader.gif' ></span>";
|
414 |
-
|
415 |
-
}
|
416 |
-
|
417 |
-
echo "
|
418 |
-
|
419 |
-
</div>
|
420 |
-
|
421 |
-
</div>";
|
422 |
-
|
423 |
-
} // End else if !$log result
|
424 |
-
|
425 |
-
die();
|
426 |
-
|
427 |
-
}
|
428 |
-
|
429 |
/********************* END Admin ajax functions ****************/
|
430 |
|
431 |
|
@@ -538,17 +403,10 @@ function yasr_insert_visitor_votes_callback() {
|
|
538 |
}
|
539 |
|
540 |
if ($result_update_log || $result_insert_log) {
|
|
|
541 |
|
542 |
-
$
|
543 |
-
$
|
544 |
-
|
545 |
-
foreach ($row_exists as $results) {
|
546 |
-
$stored_user_votes_sum = $results->sum_votes;
|
547 |
-
$stored_number_of_votes = $results->number_of_votes;
|
548 |
-
}
|
549 |
-
|
550 |
-
$user_votes_sum = $stored_user_votes_sum;
|
551 |
-
$number_of_votes = $stored_number_of_votes;
|
552 |
|
553 |
$cookiename = 'yasr_visitor_vote_cookie';
|
554 |
|
@@ -562,8 +420,15 @@ function yasr_insert_visitor_votes_callback() {
|
|
562 |
$total_rating = ($user_votes_sum / $number_of_votes);
|
563 |
$medium_rating = round($total_rating, 1);
|
564 |
|
565 |
-
$html_to_return = '<span class="yasr-total-average-text"> ['
|
566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
|
568 |
echo json_encode($html_to_return);
|
569 |
|
@@ -697,25 +562,18 @@ add_action('wp_ajax_nopriv_yasr_stats_visitors_votes', 'yasr_stats_visitors_vote
|
|
697 |
function yasr_stats_visitors_votes_callback() {
|
698 |
|
699 |
if (isset($_POST['post_id']) && $_POST['post_id'] !== '') {
|
700 |
-
$post_id = $_POST['post_id'];
|
701 |
} else {
|
702 |
return;
|
703 |
}
|
704 |
|
705 |
-
$
|
706 |
-
$
|
707 |
-
|
708 |
-
$medium_rating = 0; //Avoid undefined variable
|
709 |
|
710 |
-
if (
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
$medium_rating = ($user_votes->sum_votes / $votes_number);
|
715 |
-
} else {
|
716 |
-
$medium_rating = 0;
|
717 |
-
}
|
718 |
-
}
|
719 |
}
|
720 |
|
721 |
$medium_rating = round($medium_rating, 1);
|
66 |
|
67 |
global $wpdb;
|
68 |
|
69 |
+
$multi_set = YasrMultiSetData::returnMultiSetNames();
|
70 |
$n_multi_set = $wpdb->num_rows;
|
71 |
|
72 |
?>
|
80 |
class="nav-tab yasr-nav-tab"><?php _e("Charts", 'yet-another-stars-rating'); ?></a>
|
81 |
<?php do_action('yasr_add_tabs_on_tinypopupform'); ?>
|
82 |
|
83 |
+
<a href="https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen"
|
84 |
+
target="_blank"
|
85 |
+
id="yasr-tinypopup-link-doc">
|
86 |
+
<?php _e("Read the doc", 'yet-another-stars-rating'); ?>
|
87 |
+
</a>
|
88 |
|
89 |
</h2>
|
90 |
|
291 |
|
292 |
/********** END Functions used while wirting a new post or page ********/
|
293 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
/********************* END Admin ajax functions ****************/
|
295 |
|
296 |
|
403 |
}
|
404 |
|
405 |
if ($result_update_log || $result_insert_log) {
|
406 |
+
$row_exists = YasrDatabaseRatings::getVisitorVotes($post_id, false);
|
407 |
|
408 |
+
$user_votes_sum = $row_exists['sum_votes'];
|
409 |
+
$number_of_votes = $row_exists['number_of_votes'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
|
411 |
$cookiename = 'yasr_visitor_vote_cookie';
|
412 |
|
420 |
$total_rating = ($user_votes_sum / $number_of_votes);
|
421 |
$medium_rating = round($total_rating, 1);
|
422 |
|
423 |
+
$html_to_return = '<span class="yasr-total-average-text"> ['
|
424 |
+
. __('Total:', 'yet-another-stars-rating') .
|
425 |
+
" $number_of_votes "
|
426 |
+
. __('Average:', 'yet-another-stars-rating') .
|
427 |
+
" $medium_rating/5 ]
|
428 |
+
</span>";
|
429 |
+
$html_to_return .= '<span class="yasr-small-block-bold" id="yasr-vote-saved">'
|
430 |
+
. __('Vote Saved', 'yet-another-stars-rating') .
|
431 |
+
'</span>';
|
432 |
|
433 |
echo json_encode($html_to_return);
|
434 |
|
562 |
function yasr_stats_visitors_votes_callback() {
|
563 |
|
564 |
if (isset($_POST['post_id']) && $_POST['post_id'] !== '') {
|
565 |
+
$post_id = (int)$_POST['post_id'];
|
566 |
} else {
|
567 |
return;
|
568 |
}
|
569 |
|
570 |
+
$votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
|
571 |
+
$votes_number = $votes_array['number_of_votes'];
|
|
|
|
|
572 |
|
573 |
+
if ($votes_number != 0) {
|
574 |
+
$medium_rating = ($votes_array['sum_votes'] / $votes_number);
|
575 |
+
} else {
|
576 |
+
$medium_rating = 0;
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
|
579 |
$medium_rating = round($medium_rating, 1);
|
lib/yasr-db-classes.php
CHANGED
@@ -29,7 +29,7 @@ class YasrDatabaseRatings {
|
|
29 |
*
|
30 |
* @return mixed|null
|
31 |
*/
|
32 |
-
public function getOverallRating ($post_id=false) {
|
33 |
//if values it's not passed get the post id, since version 1.6.9 this is just for yasr_add_schema function
|
34 |
//and for a further check
|
35 |
if (!is_int($post_id)) {
|
@@ -53,7 +53,7 @@ class YasrDatabaseRatings {
|
|
53 |
*
|
54 |
* @return array|bool|mixed|object|null
|
55 |
*/
|
56 |
-
public function getVisitorVotes ($post_id = false, $create_transient = true) {
|
57 |
global $wpdb;
|
58 |
|
59 |
//if values it's not passed get the post id, most of cases and default one
|
@@ -73,16 +73,24 @@ class YasrDatabaseRatings {
|
|
73 |
} else {
|
74 |
$result = $wpdb->get_results(
|
75 |
$wpdb->prepare(
|
76 |
-
"SELECT SUM(vote)
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
80 |
)
|
81 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
if ($create_transient === true) {
|
83 |
-
set_transient($transient_name, $
|
84 |
}
|
85 |
-
return $
|
86 |
}
|
87 |
|
88 |
}
|
@@ -94,7 +102,7 @@ class YasrDatabaseRatings {
|
|
94 |
*
|
95 |
* @return bool|string
|
96 |
*/
|
97 |
-
public function visitorVotesHasUserVoted($post_id = false) {
|
98 |
global $wpdb;
|
99 |
|
100 |
$current_user = wp_get_current_user();
|
@@ -132,7 +140,17 @@ class YasrMultiSetData {
|
|
132 |
/**
|
133 |
* @var array $array_to_return
|
134 |
*/
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
/**
|
138 |
* This function returns an multidimensional array of multiset ID and Fields
|
@@ -148,30 +166,55 @@ class YasrMultiSetData {
|
|
148 |
* )
|
149 |
*
|
150 |
* @param int $set_id
|
151 |
-
* @return array|bool
|
152 |
*/
|
153 |
|
154 |
-
public function multisetFieldsAndID($set_id) {
|
155 |
-
|
156 |
-
return false;
|
157 |
-
}
|
158 |
|
159 |
global $wpdb;
|
160 |
|
161 |
$result = $wpdb->get_results($wpdb->prepare(
|
162 |
-
"SELECT f.field_id AS id,
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
168 |
|
169 |
if (empty($result)) {
|
170 |
return false;
|
171 |
}
|
172 |
-
|
173 |
return $result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
|
177 |
/** This functions returns an array with all the value to print the multiset
|
@@ -190,24 +233,32 @@ class YasrMultiSetData {
|
|
190 |
*
|
191 |
* @param integer $set_id the set id
|
192 |
* @param array $set_fields an array with fields names and id
|
193 |
-
* @param
|
194 |
*
|
195 |
* @return bool | array
|
196 |
*/
|
197 |
|
198 |
-
public function returnArrayFieldsRatings($set_id, $set_fields, $
|
|
|
199 |
|
200 |
-
if (
|
201 |
return false;
|
202 |
}
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
//index
|
205 |
$i = 0;
|
206 |
//always returns field id and name
|
207 |
foreach ($set_fields as $fields_ids_and_names) {
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
|
212 |
//if there is post meta
|
213 |
if ($set_post_meta_values) {
|
@@ -218,9 +269,9 @@ class YasrMultiSetData {
|
|
218 |
//loop the saved arrays
|
219 |
foreach ($saved_set_id['fields_and_ratings'] as $single_value) {
|
220 |
//if field id is the same, add the rating
|
221 |
-
if (
|
222 |
//save the rating
|
223 |
-
|
224 |
}
|
225 |
}
|
226 |
}
|
@@ -229,43 +280,20 @@ class YasrMultiSetData {
|
|
229 |
//this is for list the set names
|
230 |
$i ++;
|
231 |
}
|
232 |
-
return
|
233 |
}
|
234 |
|
235 |
/**
|
236 |
-
*
|
237 |
-
*
|
238 |
-
* This get the multiset content, and returns the average
|
239 |
*
|
240 |
-
* @return int|false|float
|
241 |
-
*/
|
242 |
-
public function returnMultiSetAverage($multiset_content) {
|
243 |
-
if (!is_array($multiset_content)) {
|
244 |
-
return 0;
|
245 |
-
}
|
246 |
-
//default value
|
247 |
-
$multiset_vote_sum = 0;
|
248 |
-
$multiset_rows_number = 0;
|
249 |
-
|
250 |
-
foreach ($multiset_content as $set_content) {
|
251 |
-
$multiset_vote_sum = $multiset_vote_sum + $set_content['average_rating'];
|
252 |
-
$multiset_rows_number = $multiset_rows_number+1;
|
253 |
-
}
|
254 |
-
$multiset_average = round($multiset_vote_sum/$multiset_rows_number, 1);
|
255 |
-
|
256 |
-
return $multiset_average;
|
257 |
-
}
|
258 |
-
|
259 |
-
|
260 |
-
/**
|
261 |
* @param $post_id
|
262 |
* @param $set_type
|
263 |
*
|
264 |
* @return array|mixed|object|null
|
265 |
*/
|
266 |
-
public function
|
267 |
$post_id = (int)$post_id;
|
268 |
-
$set_type = (int)
|
269 |
|
270 |
$result = get_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type);
|
271 |
|
@@ -277,7 +305,7 @@ class YasrMultiSetData {
|
|
277 |
|
278 |
$result = $wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name,
|
279 |
f.field_id AS id,
|
280 |
-
(SUM(l.vote)/COUNT(l.vote)) AS average_rating,
|
281 |
COUNT(l.vote) AS number_of_votes
|
282 |
FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f LEFT JOIN " . YASR_LOG_MULTI_SET . " AS l
|
283 |
ON l.post_id = %d
|
@@ -288,10 +316,47 @@ class YasrMultiSetData {
|
|
288 |
|
289 |
if (!empty($result)) {
|
290 |
set_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type, $result, WEEK_IN_SECONDS);
|
|
|
|
|
|
|
291 |
}
|
292 |
|
293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
}
|
296 |
|
297 |
}
|
29 |
*
|
30 |
* @return mixed|null
|
31 |
*/
|
32 |
+
public static function getOverallRating ($post_id=false) {
|
33 |
//if values it's not passed get the post id, since version 1.6.9 this is just for yasr_add_schema function
|
34 |
//and for a further check
|
35 |
if (!is_int($post_id)) {
|
53 |
*
|
54 |
* @return array|bool|mixed|object|null
|
55 |
*/
|
56 |
+
public static function getVisitorVotes ($post_id = false, $create_transient = true) {
|
57 |
global $wpdb;
|
58 |
|
59 |
//if values it's not passed get the post id, most of cases and default one
|
73 |
} else {
|
74 |
$result = $wpdb->get_results(
|
75 |
$wpdb->prepare(
|
76 |
+
"SELECT SUM(vote) as sum_votes,
|
77 |
+
COUNT(vote) as number_of_votes FROM "
|
78 |
+
. YASR_LOG_TABLE .
|
79 |
+
" WHERE post_id=%d",
|
80 |
+
$post_id
|
81 |
)
|
82 |
);
|
83 |
+
|
84 |
+
$array_to_return = array();
|
85 |
+
foreach ($result as $user_votes) {
|
86 |
+
$array_to_return['number_of_votes'] = (int)$user_votes->number_of_votes;
|
87 |
+
$array_to_return['sum_votes'] = (int)$user_votes->sum_votes;
|
88 |
+
}
|
89 |
+
|
90 |
if ($create_transient === true) {
|
91 |
+
set_transient($transient_name, $array_to_return, WEEK_IN_SECONDS);
|
92 |
}
|
93 |
+
return $array_to_return;
|
94 |
}
|
95 |
|
96 |
}
|
102 |
*
|
103 |
* @return bool|string
|
104 |
*/
|
105 |
+
public static function visitorVotesHasUserVoted($post_id = false) {
|
106 |
global $wpdb;
|
107 |
|
108 |
$current_user = wp_get_current_user();
|
140 |
/**
|
141 |
* @var array $array_to_return
|
142 |
*/
|
143 |
+
static $array_to_return = array();
|
144 |
+
|
145 |
+
|
146 |
+
/****** Get multi set name ******/
|
147 |
+
public static function returnMultiSetNames() {
|
148 |
+
global $wpdb;
|
149 |
+
|
150 |
+
$result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id");
|
151 |
+
|
152 |
+
return $result;
|
153 |
+
}
|
154 |
|
155 |
/**
|
156 |
* This function returns an multidimensional array of multiset ID and Fields
|
166 |
* )
|
167 |
*
|
168 |
* @param int $set_id
|
169 |
+
* @return array|bool
|
170 |
*/
|
171 |
|
172 |
+
public static function multisetFieldsAndID($set_id) {
|
173 |
+
$set_id = (int)$set_id;
|
|
|
|
|
174 |
|
175 |
global $wpdb;
|
176 |
|
177 |
$result = $wpdb->get_results($wpdb->prepare(
|
178 |
+
"SELECT f.field_id AS id,
|
179 |
+
f.field_name AS name
|
180 |
+
FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f
|
181 |
+
WHERE f.parent_set_id=%d
|
182 |
+
ORDER BY f.field_id
|
183 |
+
", $set_id),
|
184 |
+
ARRAY_A);
|
185 |
|
186 |
if (empty($result)) {
|
187 |
return false;
|
188 |
}
|
|
|
189 |
return $result;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Get from the db all the values for VisitorMultiSet
|
194 |
+
*
|
195 |
+
* @param $post_id
|
196 |
+
* @param $set_id
|
197 |
+
*
|
198 |
+
* @return array|bool
|
199 |
+
*/
|
200 |
+
public static function returnMultisetContent($post_id, $set_id) {
|
201 |
+
$set_id = (int)$set_id;
|
202 |
+
$post_id = (int)$post_id;
|
203 |
+
|
204 |
+
if ($post_id === 0) {
|
205 |
+
return false;
|
206 |
+
}
|
207 |
+
|
208 |
+
//set fields name and ids
|
209 |
+
$set_fields = self::multisetFieldsAndID($set_id);
|
210 |
|
211 |
+
if($set_fields === false) {
|
212 |
+
return false;
|
213 |
+
}
|
214 |
+
|
215 |
+
$multiset_content = YasrMultiSetData::returnArrayFieldsRatings($set_id, $set_fields, $post_id);
|
216 |
+
|
217 |
+
return $multiset_content;
|
218 |
}
|
219 |
|
220 |
/** This functions returns an array with all the value to print the multiset
|
233 |
*
|
234 |
* @param integer $set_id the set id
|
235 |
* @param array $set_fields an array with fields names and id
|
236 |
+
* @param integer|bool $post_id the post_id
|
237 |
*
|
238 |
* @return bool | array
|
239 |
*/
|
240 |
|
241 |
+
public static function returnArrayFieldsRatings($set_id, $set_fields, $post_id=false) {
|
242 |
+
$set_id = (int)$set_id;
|
243 |
|
244 |
+
if (!$set_fields) {
|
245 |
return false;
|
246 |
}
|
247 |
|
248 |
+
if(!is_int($post_id)) {
|
249 |
+
$post_id = get_the_ID();
|
250 |
+
}
|
251 |
+
|
252 |
+
//get meta values (field id and rating)
|
253 |
+
$set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes', true);
|
254 |
+
|
255 |
//index
|
256 |
$i = 0;
|
257 |
//always returns field id and name
|
258 |
foreach ($set_fields as $fields_ids_and_names) {
|
259 |
+
self::$array_to_return[$i]['id'] = (int) $fields_ids_and_names['id'];
|
260 |
+
self::$array_to_return[$i]['name'] = $fields_ids_and_names['name'];
|
261 |
+
self::$array_to_return[$i]['average_rating'] = 0;
|
262 |
|
263 |
//if there is post meta
|
264 |
if ($set_post_meta_values) {
|
269 |
//loop the saved arrays
|
270 |
foreach ($saved_set_id['fields_and_ratings'] as $single_value) {
|
271 |
//if field id is the same, add the rating
|
272 |
+
if (self::$array_to_return[$i]['id'] === $single_value->field) {
|
273 |
//save the rating
|
274 |
+
self::$array_to_return[$i]['average_rating'] = $single_value->rating;
|
275 |
}
|
276 |
}
|
277 |
}
|
280 |
//this is for list the set names
|
281 |
$i ++;
|
282 |
}
|
283 |
+
return self::$array_to_return;
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
+
* Get from the db all the values for VisitorMultiSet
|
|
|
|
|
288 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
* @param $post_id
|
290 |
* @param $set_type
|
291 |
*
|
292 |
* @return array|mixed|object|null
|
293 |
*/
|
294 |
+
public static function returnVisitorMultiSetContent($post_id, $set_type) {
|
295 |
$post_id = (int)$post_id;
|
296 |
+
$set_type = (int)$set_type;
|
297 |
|
298 |
$result = get_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type);
|
299 |
|
305 |
|
306 |
$result = $wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name,
|
307 |
f.field_id AS id,
|
308 |
+
CAST((SUM(l.vote)/COUNT(l.vote)) AS DECIMAL(2,1)) AS average_rating,
|
309 |
COUNT(l.vote) AS number_of_votes
|
310 |
FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f LEFT JOIN " . YASR_LOG_MULTI_SET . " AS l
|
311 |
ON l.post_id = %d
|
316 |
|
317 |
if (!empty($result)) {
|
318 |
set_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type, $result, WEEK_IN_SECONDS);
|
319 |
+
return $result;
|
320 |
+
} else {
|
321 |
+
return false;
|
322 |
}
|
323 |
|
324 |
+
}
|
325 |
+
|
326 |
+
|
327 |
+
/**
|
328 |
+
* @param int $post_id
|
329 |
+
* @param int $set_id
|
330 |
+
* @param bool $visitor_multiset
|
331 |
+
*
|
332 |
+
* Get the post_id and the set id, return the average (float)
|
333 |
+
*
|
334 |
+
* @return float|int|false|
|
335 |
+
*/
|
336 |
+
public static function returnMultiSetAverage($post_id, $set_id, $visitor_multiset) {
|
337 |
+
$post_id = (int)$post_id;
|
338 |
+
$set_id = (int)$set_id;
|
339 |
|
340 |
+
if ($visitor_multiset === true) {
|
341 |
+
$multiset_content = self::returnVisitorMultiSetContent($post_id, $set_id);
|
342 |
+
} else {
|
343 |
+
$multiset_content = self::returnMultisetContent($post_id, $set_id);
|
344 |
+
}
|
345 |
+
|
346 |
+
if (!is_array($multiset_content)) {
|
347 |
+
return 0;
|
348 |
+
}
|
349 |
+
//default value
|
350 |
+
$multiset_vote_sum = 0;
|
351 |
+
$multiset_rows_number = 0;
|
352 |
+
|
353 |
+
foreach ($multiset_content as $set_content) {
|
354 |
+
$multiset_vote_sum = $multiset_vote_sum + $set_content['average_rating'];
|
355 |
+
$multiset_rows_number = $multiset_rows_number+1;
|
356 |
+
}
|
357 |
+
$multiset_average = round($multiset_vote_sum/$multiset_rows_number, 1);
|
358 |
+
|
359 |
+
return $multiset_average;
|
360 |
}
|
361 |
|
362 |
}
|
lib/yasr-db-functions.php
CHANGED
@@ -216,16 +216,6 @@ function yasr_get_snippet_type() {
|
|
216 |
|
217 |
}
|
218 |
|
219 |
-
/****** Get multi set name ******/
|
220 |
-
function yasr_get_multi_set() {
|
221 |
-
global $wpdb;
|
222 |
-
|
223 |
-
$result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id");
|
224 |
-
|
225 |
-
return $result;
|
226 |
-
}
|
227 |
-
|
228 |
-
|
229 |
/** Output the multi set while editing the page, used in
|
230 |
* yasr-metabox-multiple-rating and yasr-ajax-function
|
231 |
*/
|
@@ -236,14 +226,12 @@ function yasr_return_multi_set_values_admin($post_id, $set_id) {
|
|
236 |
exit(__('Missing post or set id', 'yet-another-stars-rating'));
|
237 |
}
|
238 |
|
239 |
-
$multiset_obj = new YasrMultiSetData();
|
240 |
-
|
241 |
//set fields name and ids
|
242 |
-
$set_fields =
|
243 |
|
244 |
//set meta values
|
245 |
$set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes', true);
|
246 |
-
$array_to_return =
|
247 |
|
248 |
echo json_encode($array_to_return);
|
249 |
|
@@ -537,7 +525,6 @@ function yasr_save_multiset_editor($post_id) {
|
|
537 |
//if the saved set is different from the one that we're trying to save,
|
538 |
//append data to save to the post meta
|
539 |
if ($saved_set_id['set_id'] !== $set_id) {
|
540 |
-
|
541 |
$data_to_save[$i]['set_id'] = $saved_set_id['set_id'];
|
542 |
$data_to_save[$i]['fields_and_ratings'] = $saved_set_id['fields_and_ratings'];
|
543 |
|
@@ -581,58 +568,3 @@ if (YASR_AUTO_INSERT_ENABLED == 1) {
|
|
581 |
}
|
582 |
|
583 |
}
|
584 |
-
|
585 |
-
|
586 |
-
//This will add to the REST yasr data
|
587 |
-
//must be public and not in the admin files
|
588 |
-
add_action('init', 'yasr_gutenberg_show_in_rest_overall_meta');
|
589 |
-
|
590 |
-
function yasr_gutenberg_show_in_rest_overall_meta() {
|
591 |
-
register_meta('post', 'yasr_overall_rating',
|
592 |
-
array(
|
593 |
-
'show_in_rest' => true,
|
594 |
-
'single' => true,
|
595 |
-
'type' => 'number',
|
596 |
-
'auth_callback' => function() {
|
597 |
-
return current_user_can('edit_posts');
|
598 |
-
}
|
599 |
-
)
|
600 |
-
);
|
601 |
-
|
602 |
-
register_meta('post', 'yasr_post_is_review',
|
603 |
-
array(
|
604 |
-
'show_in_rest' => true,
|
605 |
-
'single' => true,
|
606 |
-
'type' => 'string',
|
607 |
-
'auth_callback' => function() {
|
608 |
-
return current_user_can('edit_posts');
|
609 |
-
}
|
610 |
-
)
|
611 |
-
);
|
612 |
-
|
613 |
-
register_meta('post', 'yasr_auto_insert_disabled',
|
614 |
-
array(
|
615 |
-
'show_in_rest' => true,
|
616 |
-
'single' => true,
|
617 |
-
'type' => 'string',
|
618 |
-
'auth_callback' => function() {
|
619 |
-
return current_user_can('edit_posts');
|
620 |
-
}
|
621 |
-
)
|
622 |
-
);
|
623 |
-
|
624 |
-
register_meta('post', 'yasr_review_type',
|
625 |
-
array(
|
626 |
-
'show_in_rest' => true,
|
627 |
-
'single' => true,
|
628 |
-
'type' => 'string',
|
629 |
-
'auth_callback' => function() {
|
630 |
-
return current_user_can('edit_posts');
|
631 |
-
}
|
632 |
-
)
|
633 |
-
);
|
634 |
-
|
635 |
-
}
|
636 |
-
|
637 |
-
|
638 |
-
?>
|
216 |
|
217 |
}
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
/** Output the multi set while editing the page, used in
|
220 |
* yasr-metabox-multiple-rating and yasr-ajax-function
|
221 |
*/
|
226 |
exit(__('Missing post or set id', 'yet-another-stars-rating'));
|
227 |
}
|
228 |
|
|
|
|
|
229 |
//set fields name and ids
|
230 |
+
$set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
|
231 |
|
232 |
//set meta values
|
233 |
$set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes', true);
|
234 |
+
$array_to_return = YasrMultiSetData::returnArrayFieldsRatings($set_id, $set_fields, $set_post_meta_values);
|
235 |
|
236 |
echo json_encode($array_to_return);
|
237 |
|
525 |
//if the saved set is different from the one that we're trying to save,
|
526 |
//append data to save to the post meta
|
527 |
if ($saved_set_id['set_id'] !== $set_id) {
|
|
|
528 |
$data_to_save[$i]['set_id'] = $saved_set_id['set_id'];
|
529 |
$data_to_save[$i]['fields_and_ratings'] = $saved_set_id['fields_and_ratings'];
|
530 |
|
568 |
}
|
569 |
|
570 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/yasr-deprecated.php
CHANGED
@@ -171,3 +171,12 @@ function yasr_check_if_user_already_voted($post_id = false) {
|
|
171 |
return $rating;
|
172 |
|
173 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
return $rating;
|
172 |
|
173 |
}
|
174 |
+
|
175 |
+
/****** Get multi set name ******/
|
176 |
+
function yasr_get_multi_set() {
|
177 |
+
global $wpdb;
|
178 |
+
|
179 |
+
$result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id");
|
180 |
+
|
181 |
+
return $result;
|
182 |
+
}
|
lib/yasr-functions.php
CHANGED
@@ -386,25 +386,12 @@ function yasr_add_schema($content) {
|
|
386 |
return $content;
|
387 |
}
|
388 |
|
389 |
-
$
|
390 |
-
$
|
391 |
-
$visitor_votes = $database_ratings_obj->getVisitorVotes(false, false);
|
392 |
|
393 |
$is_post_a_review = get_post_meta(get_the_ID(), 'yasr_post_is_review', true);
|
394 |
|
395 |
-
|
396 |
-
|
397 |
-
if($visitor_votes != false && is_array($visitor_votes)) {
|
398 |
-
foreach ($visitor_votes as $rating) {
|
399 |
-
$visitor_rating['votes_number'] = $rating->number_of_votes;
|
400 |
-
$visitor_rating['sum'] = $rating->sum_votes;
|
401 |
-
}
|
402 |
-
} else {
|
403 |
-
$visitor_rating['votes_number'] = false;
|
404 |
-
$visitor_rating['sum'] = false;
|
405 |
-
}
|
406 |
-
|
407 |
-
if (!$overall_rating && !$visitor_rating['votes_number'] && !$visitor_rating['sum']) {
|
408 |
return $content;
|
409 |
}
|
410 |
|
@@ -538,14 +525,14 @@ function yasr_add_schema($content) {
|
|
538 |
//So, is post is selected as review, exclude AggregateRating
|
539 |
if($is_post_a_review !== 'yes') {
|
540 |
if ($visitor_votes) {
|
541 |
-
if ($
|
542 |
-
$average_rating = $
|
543 |
$average_rating = round($average_rating, 1);
|
544 |
|
545 |
$rich_snippet["aggregateRating"] = array(
|
546 |
"@type" => "AggregateRating",
|
547 |
"ratingValue" => "$average_rating",
|
548 |
-
"ratingCount" => $
|
549 |
);
|
550 |
}
|
551 |
}
|
@@ -636,18 +623,6 @@ function yasr_shortcode_button_media() {
|
|
636 |
|
637 |
add_action('admin_init', 'yasr_get_custom_post_type');
|
638 |
|
639 |
-
//Creating a rest response
|
640 |
-
add_action('rest_api_init', function () {
|
641 |
-
register_rest_route(
|
642 |
-
'yet-another-stars-rating/v1/',
|
643 |
-
'/list-posts-types',
|
644 |
-
array(
|
645 |
-
'methods' => 'GET',
|
646 |
-
'callback' => 'yasr_get_custom_post_type',
|
647 |
-
)
|
648 |
-
);
|
649 |
-
});
|
650 |
-
|
651 |
function yasr_get_custom_post_type($return_value = 'array') {
|
652 |
|
653 |
//if this is a rest request $return_value is an object called WP_REST_Request
|
@@ -681,6 +656,19 @@ function yasr_get_custom_post_type($return_value = 'array') {
|
|
681 |
|
682 |
}
|
683 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
684 |
|
685 |
/*** Add support for wp super cache ***/
|
686 |
function yasr_wp_super_cache_support($post_id) {
|
@@ -959,6 +947,4 @@ function yasr_is_supported_schema ($item_type) {
|
|
959 |
}
|
960 |
|
961 |
return false;
|
962 |
-
}
|
963 |
-
|
964 |
-
?>
|
386 |
return $content;
|
387 |
}
|
388 |
|
389 |
+
$overall_rating = YasrDatabaseRatings::getOverallRating();
|
390 |
+
$visitor_votes = YasrDatabaseRatings::getVisitorVotes(false, false);
|
|
|
391 |
|
392 |
$is_post_a_review = get_post_meta(get_the_ID(), 'yasr_post_is_review', true);
|
393 |
|
394 |
+
if (!$overall_rating && !$visitor_votes['number_of_votes'] && !$visitor_votes['sum_votes']) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
return $content;
|
396 |
}
|
397 |
|
525 |
//So, is post is selected as review, exclude AggregateRating
|
526 |
if($is_post_a_review !== 'yes') {
|
527 |
if ($visitor_votes) {
|
528 |
+
if ($visitor_votes['sum_votes'] != 0 && $visitor_votes['number_of_votes'] != 0) {
|
529 |
+
$average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
|
530 |
$average_rating = round($average_rating, 1);
|
531 |
|
532 |
$rich_snippet["aggregateRating"] = array(
|
533 |
"@type" => "AggregateRating",
|
534 |
"ratingValue" => "$average_rating",
|
535 |
+
"ratingCount" => $visitor_votes['number_of_votes'],
|
536 |
);
|
537 |
}
|
538 |
}
|
623 |
|
624 |
add_action('admin_init', 'yasr_get_custom_post_type');
|
625 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
function yasr_get_custom_post_type($return_value = 'array') {
|
627 |
|
628 |
//if this is a rest request $return_value is an object called WP_REST_Request
|
656 |
|
657 |
}
|
658 |
|
659 |
+
function yasr_return_all_post_types () {
|
660 |
+
$args = array(
|
661 |
+
'public' => true,
|
662 |
+
);
|
663 |
+
|
664 |
+
$output = 'names';
|
665 |
+
$operator = 'and';
|
666 |
+
|
667 |
+
$post_types = get_post_types($args, $output, $operator);
|
668 |
+
|
669 |
+
return $post_types;
|
670 |
+
}
|
671 |
+
|
672 |
|
673 |
/*** Add support for wp super cache ***/
|
674 |
function yasr_wp_super_cache_support($post_id) {
|
947 |
}
|
948 |
|
949 |
return false;
|
950 |
+
}
|
|
|
|
lib/yasr-shortcode-classes.php
CHANGED
@@ -112,15 +112,14 @@ class YasrOverallRating extends YasrShortcode {
|
|
112 |
return false;
|
113 |
}
|
114 |
|
115 |
-
$stars_size
|
116 |
-
$
|
117 |
-
$this->overall_rating = $overall_rating_obj->getOverallRating($this->post_id);
|
118 |
|
119 |
-
$this->shortcode_html
|
120 |
|
121 |
//generate an unique id to be sure that every element has a different ID
|
122 |
-
$unique_id
|
123 |
-
$overall_rating_html_id
|
124 |
|
125 |
$this->html_stars = "<div class='yasr-overall-rating'>
|
126 |
<div class='yasr-rater-stars'
|
@@ -157,9 +156,9 @@ class YasrOverallRating extends YasrShortcode {
|
|
157 |
if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
|
158 |
$text_before_star = str_replace('%overall_rating%', $this->overall_rating, YASR_TEXT_BEFORE_OVERALL);
|
159 |
$this->shortcode_html = "<div class='yasr-container-custom-text-and-overall'>
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
} else {
|
164 |
$this->shortcode_html .= $this->html_stars;
|
165 |
}
|
@@ -173,14 +172,12 @@ class YasrOverallRating extends YasrShortcode {
|
|
173 |
*/
|
174 |
class YasrVisitorVotes extends YasrShortcode {
|
175 |
|
176 |
-
protected $votes = null;
|
177 |
protected $votes_number = 0;
|
178 |
protected $medium_rating = 0;
|
179 |
protected $cookie_value = false; //avoid undefined
|
180 |
protected $span_bottom_line;
|
181 |
protected $span_text_after_stars;
|
182 |
|
183 |
-
|
184 |
/**
|
185 |
* Print the visitor votes shortcode
|
186 |
*
|
@@ -199,17 +196,13 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
199 |
$htmlid = 'yasr-visitor-votes-rater-' . $unique_id ;
|
200 |
$span_container_after_stars = "<span id='yasr-visitor-votes-container-after-stars-$unique_id'
|
201 |
class='yasr-visitor-votes-after-stars-class'>";
|
|
|
202 |
|
203 |
-
$
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
$this->
|
208 |
-
if ($this->votes_number != 0) {
|
209 |
-
$this->medium_rating = ($user_votes->sum_votes/$this->votes_number);
|
210 |
-
} else {
|
211 |
-
$this->medium_rating = 0;
|
212 |
-
}
|
213 |
}
|
214 |
|
215 |
$this->medium_rating=round($this->medium_rating, 1);
|
@@ -226,9 +219,13 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
226 |
if ($this->readonly === true || $this->readonly === "yes") {
|
227 |
$htmlid = 'yasr-visitor-votes-readonly-rater-'.$unique_id;
|
228 |
|
229 |
-
$this->shortcode_html = "<div class
|
230 |
-
|
231 |
-
|
|
|
|
|
|
|
|
|
232 |
|
233 |
return $this->shortcode_html;
|
234 |
}
|
@@ -313,14 +310,12 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
313 |
* @return void
|
314 |
*/
|
315 |
protected function allowedUser () {
|
316 |
-
$visitor_votes = new YasrDatabaseRatings();
|
317 |
-
|
318 |
//I've to check a logged in user that has already rated
|
319 |
if (is_user_logged_in()) {
|
320 |
$this->readonly = 'false'; //Always false if user is logged in
|
321 |
|
322 |
//Check if a logged in user has already rated for this post
|
323 |
-
$vote_if_user_already_rated =
|
324 |
|
325 |
//If user has already rated
|
326 |
if ($vote_if_user_already_rated) {
|
@@ -474,23 +469,14 @@ class YasrMultiSet extends YasrShortcode {
|
|
474 |
|
475 |
$this->shortcode_html = '<!-- Yasr Multi Set Shortcode-->';
|
476 |
|
477 |
-
$
|
478 |
-
|
479 |
-
//set fields name and ids
|
480 |
-
$set_fields = $multiset_obj->multisetFieldsAndID($this->set_id);
|
481 |
|
482 |
-
|
483 |
-
if (!$set_fields) {
|
484 |
$string = __('No Set Found with this ID', 'yet-another-stars-rating');
|
485 |
return $this->shortcode_html . $string;
|
486 |
}
|
487 |
|
488 |
-
|
489 |
-
$set_post_meta_values = get_post_meta($this->post_id, 'yasr_multiset_author_votes', true);
|
490 |
-
|
491 |
-
$multiset_content = $multiset_obj->returnArrayFieldsRatings($this->set_id, $set_fields, $set_post_meta_values);
|
492 |
-
|
493 |
-
$this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
|
494 |
$this->shortcode_html .= '<table class="yasr_table_multi_set_shortcode">';
|
495 |
$this->star_readonly = 'true';
|
496 |
|
@@ -503,9 +489,19 @@ class YasrMultiSet extends YasrShortcode {
|
|
503 |
}
|
504 |
|
505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
protected function printMultisetRows($multiset_content, $visitor_multiset=false) {
|
507 |
|
508 |
-
$multiset_string
|
509 |
if ($visitor_multiset === true) {
|
510 |
$multiset_string = 'yasr-visitor-multi-set-average-';
|
511 |
}
|
@@ -527,45 +523,48 @@ class YasrMultiSet extends YasrShortcode {
|
|
527 |
$span_container_number_of_votes = '';
|
528 |
if ($visitor_multiset === true) {
|
529 |
$span_container_number_of_votes = '<span class="yasr-visitor-multiset-vote-count">'
|
530 |
-
|
531 |
'</span>';
|
532 |
}
|
533 |
|
534 |
-
$this->shortcode_html .='<tr>
|
535 |
<td>
|
536 |
<span class="yasr-multi-set-name-field">' . $set_content['name'] . '</span>
|
537 |
</td>
|
538 |
<td>'
|
539 |
-
|
540 |
-
|
541 |
</tr>';
|
542 |
|
543 |
} //End foreach
|
544 |
|
545 |
-
|
546 |
-
|
547 |
-
|
|
|
548 |
|
549 |
-
|
550 |
-
|
|
|
551 |
|
552 |
}
|
553 |
|
554 |
/**
|
|
|
|
|
555 |
* @since 2.1.0
|
556 |
*
|
557 |
-
* @param $show_average
|
558 |
* @param $multiset_average
|
559 |
* @param $multiset_string
|
560 |
*
|
561 |
* @return string
|
562 |
*/
|
563 |
-
protected function printAverageRowMultiSet($
|
564 |
$average_txt = __("Average", "yet-another-stars-rating");
|
565 |
$html_average = null;
|
566 |
|
567 |
//Show average row
|
568 |
-
if ($
|
569 |
$unique_id_identifier = $multiset_string . str_shuffle(uniqid());
|
570 |
|
571 |
$html_average = "<tr>
|
@@ -583,6 +582,21 @@ class YasrMultiSet extends YasrShortcode {
|
|
583 |
return $html_average;
|
584 |
}
|
585 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
}
|
587 |
|
588 |
/**
|
@@ -611,7 +625,6 @@ class YasrVisitorMultiSet extends YasrMultiSet {
|
|
611 |
return false;
|
612 |
}
|
613 |
|
614 |
-
$multiset_obj = new YasrMultiSetData();
|
615 |
$ajax_nonce_visitor_multiset = wp_create_nonce("yasr_nonce_insert_visitor_rating_multiset");
|
616 |
|
617 |
$this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
|
@@ -642,7 +655,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
|
|
642 |
//check cookie and assign default values
|
643 |
$this->multisetAttributes();
|
644 |
|
645 |
-
$set_name_content =
|
646 |
|
647 |
if (!$set_name_content) {
|
648 |
$this->shortcode_html .= __('No MultiSet found with this ID', 'yet-another-stars-rating');
|
112 |
return false;
|
113 |
}
|
114 |
|
115 |
+
$stars_size = $this->starSize();
|
116 |
+
$this->overall_rating = YasrDatabaseRatings::getOverallRating($this->post_id);
|
|
|
117 |
|
118 |
+
$this->shortcode_html = '<!--Yasr Overall Rating Shortcode-->';
|
119 |
|
120 |
//generate an unique id to be sure that every element has a different ID
|
121 |
+
$unique_id = str_shuffle(uniqid());
|
122 |
+
$overall_rating_html_id = 'yasr-overall-rating-rater-' . $unique_id;
|
123 |
|
124 |
$this->html_stars = "<div class='yasr-overall-rating'>
|
125 |
<div class='yasr-rater-stars'
|
156 |
if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
|
157 |
$text_before_star = str_replace('%overall_rating%', $this->overall_rating, YASR_TEXT_BEFORE_OVERALL);
|
158 |
$this->shortcode_html = "<div class='yasr-container-custom-text-and-overall'>
|
159 |
+
<span id='yasr-custom-text-before-overall'>" . $text_before_star . "</span>
|
160 |
+
$this->html_stars
|
161 |
+
</div>";
|
162 |
} else {
|
163 |
$this->shortcode_html .= $this->html_stars;
|
164 |
}
|
172 |
*/
|
173 |
class YasrVisitorVotes extends YasrShortcode {
|
174 |
|
|
|
175 |
protected $votes_number = 0;
|
176 |
protected $medium_rating = 0;
|
177 |
protected $cookie_value = false; //avoid undefined
|
178 |
protected $span_bottom_line;
|
179 |
protected $span_text_after_stars;
|
180 |
|
|
|
181 |
/**
|
182 |
* Print the visitor votes shortcode
|
183 |
*
|
196 |
$htmlid = 'yasr-visitor-votes-rater-' . $unique_id ;
|
197 |
$span_container_after_stars = "<span id='yasr-visitor-votes-container-after-stars-$unique_id'
|
198 |
class='yasr-visitor-votes-after-stars-class'>";
|
199 |
+
$stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id); //always reference it
|
200 |
|
201 |
+
$this->votes_number = $stored_votes['number_of_votes'];
|
202 |
+
if ($this->votes_number != 0) {
|
203 |
+
$this->medium_rating = ($stored_votes['sum_votes']/$this->votes_number);
|
204 |
+
} else {
|
205 |
+
$this->medium_rating = 0;
|
|
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
|
208 |
$this->medium_rating=round($this->medium_rating, 1);
|
219 |
if ($this->readonly === true || $this->readonly === "yes") {
|
220 |
$htmlid = 'yasr-visitor-votes-readonly-rater-'.$unique_id;
|
221 |
|
222 |
+
$this->shortcode_html = "<div class='yasr-rater-stars-visitor-votes\'
|
223 |
+
id='$htmlid'
|
224 |
+
data-rating='$this->medium_rating'
|
225 |
+
data-rater-starsize='$stars_size'
|
226 |
+
data-rater-postid='$this->post_id'
|
227 |
+
data-rater-readonly='true'>
|
228 |
+
</div>";
|
229 |
|
230 |
return $this->shortcode_html;
|
231 |
}
|
310 |
* @return void
|
311 |
*/
|
312 |
protected function allowedUser () {
|
|
|
|
|
313 |
//I've to check a logged in user that has already rated
|
314 |
if (is_user_logged_in()) {
|
315 |
$this->readonly = 'false'; //Always false if user is logged in
|
316 |
|
317 |
//Check if a logged in user has already rated for this post
|
318 |
+
$vote_if_user_already_rated = YasrDatabaseRatings::visitorVotesHasUserVoted($this->post_id);
|
319 |
|
320 |
//If user has already rated
|
321 |
if ($vote_if_user_already_rated) {
|
469 |
|
470 |
$this->shortcode_html = '<!-- Yasr Multi Set Shortcode-->';
|
471 |
|
472 |
+
$multiset_content = YasrMultiSetData::returnMultisetContent($this->post_id, $this->set_id);
|
|
|
|
|
|
|
473 |
|
474 |
+
if ($multiset_content === false) {
|
|
|
475 |
$string = __('No Set Found with this ID', 'yet-another-stars-rating');
|
476 |
return $this->shortcode_html . $string;
|
477 |
}
|
478 |
|
479 |
+
$this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
|
|
|
|
|
|
|
|
|
|
|
480 |
$this->shortcode_html .= '<table class="yasr_table_multi_set_shortcode">';
|
481 |
$this->star_readonly = 'true';
|
482 |
|
489 |
}
|
490 |
|
491 |
|
492 |
+
/**
|
493 |
+
*
|
494 |
+
* This function insert into $this->shortcode_html the rows of both multisets (average included)
|
495 |
+
*
|
496 |
+
* @param $multiset_content
|
497 |
+
* @param bool $visitor_multiset
|
498 |
+
*
|
499 |
+
* @return void
|
500 |
+
*
|
501 |
+
*/
|
502 |
protected function printMultisetRows($multiset_content, $visitor_multiset=false) {
|
503 |
|
504 |
+
$multiset_string = 'yasr-average-multiset-';
|
505 |
if ($visitor_multiset === true) {
|
506 |
$multiset_string = 'yasr-visitor-multi-set-average-';
|
507 |
}
|
523 |
$span_container_number_of_votes = '';
|
524 |
if ($visitor_multiset === true) {
|
525 |
$span_container_number_of_votes = '<span class="yasr-visitor-multiset-vote-count">'
|
526 |
+
. $set_content['number_of_votes'] .
|
527 |
'</span>';
|
528 |
}
|
529 |
|
530 |
+
$this->shortcode_html .= '<tr>
|
531 |
<td>
|
532 |
<span class="yasr-multi-set-name-field">' . $set_content['name'] . '</span>
|
533 |
</td>
|
534 |
<td>'
|
535 |
+
. $html_stars . $span_container_number_of_votes .
|
536 |
+
'</td>
|
537 |
</tr>';
|
538 |
|
539 |
} //End foreach
|
540 |
|
541 |
+
//If average row should be showed
|
542 |
+
if ($this->show_average_multiset() === true) {
|
543 |
+
//get the average of the multiset
|
544 |
+
$multiset_average = YasrMultiSetData::returnMultiSetAverage($this->post_id, $this->set_id, $visitor_multiset);
|
545 |
|
546 |
+
//print it
|
547 |
+
$this->shortcode_html .= $this->printAverageRowMultiSet($multiset_average, $multiset_string);
|
548 |
+
}
|
549 |
|
550 |
}
|
551 |
|
552 |
/**
|
553 |
+
* This function return the html code of the average multiset
|
554 |
+
*
|
555 |
* @since 2.1.0
|
556 |
*
|
|
|
557 |
* @param $multiset_average
|
558 |
* @param $multiset_string
|
559 |
*
|
560 |
* @return string
|
561 |
*/
|
562 |
+
protected function printAverageRowMultiSet($multiset_average, $multiset_string) {
|
563 |
$average_txt = __("Average", "yet-another-stars-rating");
|
564 |
$html_average = null;
|
565 |
|
566 |
//Show average row
|
567 |
+
if ($this->show_average_multiset() === true) {
|
568 |
$unique_id_identifier = $multiset_string . str_shuffle(uniqid());
|
569 |
|
570 |
$html_average = "<tr>
|
582 |
return $html_average;
|
583 |
}
|
584 |
|
585 |
+
/**
|
586 |
+
* Return true or false if average should be displayed
|
587 |
+
*
|
588 |
+
* @return bool
|
589 |
+
*/
|
590 |
+
public function show_average_multiset() {
|
591 |
+
if ($this->show_average === '' && YASR_MULTI_SHOW_AVERAGE !== 'no' ||
|
592 |
+
$this->show_average !== '' && $this->show_average !== 'no') {
|
593 |
+
return true;
|
594 |
+
}
|
595 |
+
else {
|
596 |
+
return false;
|
597 |
+
}
|
598 |
+
}
|
599 |
+
|
600 |
}
|
601 |
|
602 |
/**
|
625 |
return false;
|
626 |
}
|
627 |
|
|
|
628 |
$ajax_nonce_visitor_multiset = wp_create_nonce("yasr_nonce_insert_visitor_rating_multiset");
|
629 |
|
630 |
$this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
|
655 |
//check cookie and assign default values
|
656 |
$this->multisetAttributes();
|
657 |
|
658 |
+
$set_name_content = YasrMultiSetData::returnVisitorMultiSetContent($this->post_id, $this->set_id);
|
659 |
|
660 |
if (!$set_name_content) {
|
661 |
$this->shortcode_html .= __('No MultiSet found with this ID', 'yet-another-stars-rating');
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== Yasr - Yet Another Stars Rating ===
|
2 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
|
3 |
Tags: rating, rate post, rate page, star rating, google rating, votes
|
4 |
-
Requires at least: 4.
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.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
|
@@ -125,6 +125,11 @@ If doesn't, it's suggested to ask in a SEO oriented forum.
|
|
125 |
|
126 |
The full changelog can be found in the plugin's directory. Recent entries:
|
127 |
|
|
|
|
|
|
|
|
|
|
|
128 |
= 2.2.1 =
|
129 |
* FIXED: MultiSet returns "undefined" in editor screen
|
130 |
* FIXED: MultiSet average always shows
|
1 |
=== Yasr - Yet Another Stars Rating ===
|
2 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
|
3 |
Tags: rating, rate post, rate page, star rating, google rating, votes
|
4 |
+
Requires at least: 4.9.0
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.2.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
|
125 |
|
126 |
The full changelog can be found in the plugin's directory. Recent entries:
|
127 |
|
128 |
+
= 2.2.2 =
|
129 |
+
* FIXED: links in Recent Ratings dashboard widget (thanks to Fernando Tellado)
|
130 |
+
* Enhancement: Added REST responses. More info in the official site
|
131 |
+
|
132 |
+
|
133 |
= 2.2.1 =
|
134 |
* FIXED: MultiSet returns "undefined" in editor screen
|
135 |
* FIXED: MultiSet average always shows
|
yet-another-stars-rating.php
CHANGED
@@ -3,8 +3,9 @@
|
|
3 |
/**
|
4 |
* Plugin Name: Yet Another Stars Rating
|
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 |
-
*
|
|
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
@@ -76,7 +77,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.2.
|
80 |
//Plugin relative path
|
81 |
define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
|
82 |
//Plugin RELATIVE PATH without slashes (just the directory's name)
|
@@ -190,6 +191,10 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
190 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-db-classes.php';
|
191 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php';
|
192 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php';
|
|
|
|
|
|
|
|
|
193 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-widgets.php';
|
194 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-deprecated.php';
|
195 |
|
@@ -274,7 +279,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
274 |
if ( yasr_fs()->is_free_plan() ) {
|
275 |
// create link
|
276 |
if ( $file == $plugin ) {
|
277 |
-
$links[] = '<a href="https://yetanotherstarsrating.com
|
278 |
}
|
279 |
} else {
|
280 |
// create link
|
3 |
/**
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
+
* Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
|
7 |
+
* testimonials to your website posts, pages and CPT, without affecting its speed.
|
8 |
+
* Version: 2.2.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.2.2' );
|
81 |
//Plugin relative path
|
82 |
define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
|
83 |
//Plugin RELATIVE PATH without slashes (just the directory's name)
|
191 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-db-classes.php';
|
192 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php';
|
193 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php';
|
194 |
+
require YASR_ABSOLUTE_PATH . '/lib/rest/YasrPostMeta.php';
|
195 |
+
require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomFields.php';
|
196 |
+
require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomEndpoint.php';
|
197 |
+
require YASR_ABSOLUTE_PATH . '/lib/rest/yasr-rest.php';
|
198 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-widgets.php';
|
199 |
require YASR_ABSOLUTE_PATH . '/lib/yasr-deprecated.php';
|
200 |
|
279 |
if ( yasr_fs()->is_free_plan() ) {
|
280 |
// create link
|
281 |
if ( $file == $plugin ) {
|
282 |
+
$links[] = '<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=above_description&utm_campaign=yasr_plugin_list">' . __( 'Buy Yasr Pro', 'yet-another-stars-rating' ) . '</a>';
|
283 |
}
|
284 |
} else {
|
285 |
// create link
|