Version Description
- FIX: Author multiset didn't get saved
- TWEAKED: better error handling
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 3.0.4 |
Comparing to | |
See all releases |
Code changes from version 3.0.3 to 3.0.4
- admin/classes/YasrEditCategory.php +46 -22
- admin/classes/YasrOnInstall.php +19 -63
- admin/css/yasr-admin.css +4 -1
- admin/css/yasr-pricing-page.css +1 -2
- admin/editor/YasrEditorHooks.php +6 -4
- admin/editor/YasrOnSavePost.php +46 -7
- admin/editor/yasr-metabox-multiple-rating.php +1 -1
- admin/editor/yasr-metabox-schema.php +1 -1
- admin/js/guten/blocks/noStarsRankings.js +1 -1
- admin/js/guten/blocks/overallRating.js +1 -1
- admin/js/guten/blocks/rankings.js +1 -1
- admin/js/guten/blocks/visitorVotes.js +1 -1
- admin/js/guten/blocks/yasrGutenUtils.js +1 -1
- admin/js/guten/yasr-guten-misc.js +1 -1
- admin/js/src/guten/blocks/yasrGutenUtils.js +0 -2
- admin/js/src/yasr-editor-screen.js +19 -8
- admin/js/yasr-editor-screen.js +1 -1
- admin/js/yasr-settings.js +1 -1
- admin/settings/aspect_style/yasr-settings-style-actions.php +2 -1
- admin/settings/aspect_style/yasr-settings-style-functions.php +1 -7
- admin/settings/classes/YasrSettings.php +63 -79
- admin/settings/yasr-settings-functions-misc.php +0 -1
- admin/yasr-admin-actions.php +2 -1
- admin/yasr-admin-functions.php +27 -49
- admin/yasr-admin-init.php +14 -1
- admin/yasr-update-functions.php +1 -9
- includes/classes/YasrDatabaseRatings.php +9 -1
- includes/classes/YasrIncludesFilters.php +3 -1
- includes/classes/YasrLogDashboardWidget.php +4 -10
- includes/classes/YasrPhpFieldsHelper.php +2 -0
- includes/classes/YasrScriptsLoader.php +212 -0
- includes/classes/YasrSettingsValues.php +151 -0
- includes/js/catch-inifite-scroll.js +1 -1
- includes/js/rater-js.min.js +0 -1
- includes/js/readme +7 -3
- includes/js/shortcodes/overall-multiset.js +1 -1
- includes/js/shortcodes/rankings.js +1 -1
- includes/js/shortcodes/visitorVotes.js +1 -1
- includes/js/shortcodes/yasr-log-users-fronted.js +0 -1
- includes/js/shortcodes/yasr-log-users-frontend.js +1 -0
- includes/js/src/{rater-js-src.js → global_functions/rater-js-src.js} +3 -4
- includes/js/src/{modules → global_functions}/yasrSetRaterValue.js +1 -1
- includes/js/src/{modules → global_functions}/yasrTrueFalseStringConvertion.js +2 -2
- includes/js/src/global_functions/yasrValidJson.js +31 -0
- includes/js/src/shortcodes/overall-multiset.js +13 -11
- includes/js/src/shortcodes/ranking.js +5 -6
- includes/js/src/shortcodes/visitorVotes.js +134 -101
- includes/js/src/shortcodes/{yasr-log-users-fronted.js → yasr-log-users-frontend.js} +0 -0
- includes/js/yasr-globals.js +1 -0
- includes/rest/classes/YasrCustomEndpoint.php +3 -3
- includes/rest/classes/YasrCustomFields.php +2 -2
- includes/shortcodes/classes/YasrMultiSet.php +1 -1
- includes/shortcodes/classes/YasrNoStarsRankings.php +1 -1
- includes/shortcodes/classes/YasrOverallRating.php +1 -2
- includes/shortcodes/classes/YasrRankings.php +7 -7
- includes/shortcodes/classes/YasrShortcode.php +2 -47
- includes/shortcodes/classes/YasrShortcodesAjax.php +73 -65
- includes/shortcodes/classes/YasrVisitorMultiSet.php +2 -2
- includes/shortcodes/classes/YasrVisitorVotes.php +5 -68
- includes/yasr-includes-db-functions.php +1 -1
- includes/yasr-includes-functions.php +4 -40
- includes/yasr-includes-init.php +50 -130
- languages/yet-another-stars-rating.pot +3 -2
- public/classes/YasrPublicFilters.php +2 -8
- public/classes/YasrRichSnippets.php +9 -6
- readme.txt +6 -2
- yet-another-stars-rating.php +2 -2
admin/classes/YasrEditCategory.php
CHANGED
@@ -21,54 +21,78 @@ if (!defined('ABSPATH')) {
|
|
21 |
exit('You\'re not allowed to see this page');
|
22 |
} // Exit if accessed directly
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
class YasrEditCategory {
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
/**
|
|
|
33 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
*/
|
35 |
-
public
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
?>
|
37 |
<tr class="form-field term-name-wrap">
|
38 |
<th scope="row">
|
39 |
<label for="yasr-default-itemtype-category">
|
40 |
<?php esc_html_e( 'Select default itemType', 'yet-another-stars-rating' ) ?>
|
41 |
</label>
|
42 |
-
|
43 |
-
<?php
|
44 |
|
45 |
-
?>
|
46 |
<span class="description">
|
47 |
<?php
|
48 |
-
|
49 |
-
|
50 |
-
printf(
|
51 |
-
esc_html__('Upgrade to %s to unlock this feature', 'yet-another-stars-rating'),
|
52 |
-
sprintf(
|
53 |
-
'<a href="%s">%s</a>',
|
54 |
-
$url,
|
55 |
-
'YASR_PRO'
|
56 |
-
)
|
57 |
-
); ?>
|
58 |
</span>
|
59 |
</th>
|
60 |
<td>
|
61 |
-
<?php yasr_select_itemtype('yasr-pro-select-itemtype-category',
|
62 |
<p></p>
|
63 |
<label for="yasr-pro-checkbox-itemtype-category" class="yasr-indented-answer">
|
64 |
<input type="checkbox"
|
65 |
-
|
66 |
-
|
|
|
67 |
>
|
68 |
<span class="description">
|
69 |
<?php esc_html_e('Check to update YASR itemType', 'yet-another-stars-rating') ?>
|
70 |
</span>
|
71 |
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
</td>
|
73 |
</tr >
|
74 |
<?php
|
21 |
exit('You\'re not allowed to see this page');
|
22 |
} // Exit if accessed directly
|
23 |
|
24 |
+
/**
|
25 |
+
* Class to manage the category page in dashboard
|
26 |
+
*
|
27 |
+
* @author Dario Curvino <@dudo>
|
28 |
+
* @since 2.9.0
|
29 |
+
* Class YasrEditCategory
|
30 |
+
*/
|
31 |
class YasrEditCategory {
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Init YasrEditCategory class
|
35 |
+
*
|
36 |
+
* @author Dario Curvino <@dudo>
|
37 |
+
* @since 2.9.0
|
38 |
+
*/
|
39 |
+
public function init() {
|
40 |
+
add_action('category_edit_form_fields', array($this, 'categoryEditFormFields'), 10, 2 );
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* Callback for hook category_edit_form_fields
|
45 |
*
|
46 |
+
* This method adds a select when a category is edited, and, if PRO version is enabled,
|
47 |
+
* is possible to set the same itemType for the current category
|
48 |
+
*
|
49 |
+
* @author Dario Curvino <@dudo>
|
50 |
+
* @since 2.9.0
|
51 |
+
*
|
52 |
+
* @param $term
|
53 |
*/
|
54 |
+
public function categoryEditFormFields($term) {
|
55 |
+
$term_id = 1;
|
56 |
+
$disabled = true;
|
57 |
+
|
58 |
+
if (YASR_LOCKED_FEATURE_HTML_ATTRIBUTE !== 'disabled') {
|
59 |
+
$term_id = (int)$term->term_id;
|
60 |
+
$disabled = false;
|
61 |
+
}
|
62 |
+
|
63 |
?>
|
64 |
<tr class="form-field term-name-wrap">
|
65 |
<th scope="row">
|
66 |
<label for="yasr-default-itemtype-category">
|
67 |
<?php esc_html_e( 'Select default itemType', 'yet-another-stars-rating' ) ?>
|
68 |
</label>
|
69 |
+
<?php echo YASR_LOCKED_FEATURE ?>
|
|
|
70 |
|
|
|
71 |
<span class="description">
|
72 |
<?php
|
73 |
+
echo YASR_LOCKED_TEXT;
|
74 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
</span>
|
76 |
</th>
|
77 |
<td>
|
78 |
+
<?php yasr_select_itemtype('yasr-pro-select-itemtype-category', $term_id, $disabled ); ?>
|
79 |
<p></p>
|
80 |
<label for="yasr-pro-checkbox-itemtype-category" class="yasr-indented-answer">
|
81 |
<input type="checkbox"
|
82 |
+
name="yasr-pro-checkbox-itemtype-category"
|
83 |
+
id="yasr-pro-checkbox-itemtype-category"
|
84 |
+
<?php echo YASR_LOCKED_FEATURE_HTML_ATTRIBUTE; ?>
|
85 |
>
|
86 |
<span class="description">
|
87 |
<?php esc_html_e('Check to update YASR itemType', 'yet-another-stars-rating') ?>
|
88 |
</span>
|
89 |
</label>
|
90 |
+
<p class="description">
|
91 |
+
<?php esc_html_e(
|
92 |
+
'This will overwrite YASR itemType in all existing posts or pages for this category ',
|
93 |
+
'yasr-pro')
|
94 |
+
?>
|
95 |
+
</p>
|
96 |
</td>
|
97 |
</tr >
|
98 |
<?php
|
admin/classes/YasrOnInstall.php
CHANGED
@@ -28,7 +28,11 @@ if (!current_user_can('manage_options')) {
|
|
28 |
/**
|
29 |
* Class YasrOnInstall
|
30 |
*
|
31 |
-
* This class
|
|
|
|
|
|
|
|
|
32 |
*/
|
33 |
class YasrOnInstall {
|
34 |
|
@@ -58,6 +62,11 @@ class YasrOnInstall {
|
|
58 |
$this->defaultSettings();
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
61 |
public static function createTables () {
|
62 |
global $wpdb; //Database wordpress object
|
63 |
|
@@ -127,69 +136,16 @@ class YasrOnInstall {
|
|
127 |
dbDelta($sql_yasr_log_table);
|
128 |
}
|
129 |
|
130 |
-
|
|
|
|
|
|
|
|
|
131 |
private function defaultSettings() {
|
132 |
-
|
133 |
-
$
|
134 |
-
$
|
135 |
-
|
136 |
-
//Write default option settings
|
137 |
-
$option = get_option('yasr_general_options');
|
138 |
-
|
139 |
-
if (!$option) {
|
140 |
-
$option = array();
|
141 |
-
$option['auto_insert_enabled'] = 1;
|
142 |
-
$option['auto_insert_what'] = 'visitor_rating';
|
143 |
-
$option['auto_insert_where'] = 'bottom';
|
144 |
-
$option['auto_insert_size'] = 'large';
|
145 |
-
$option['auto_insert_align'] = 'center';
|
146 |
-
$option['auto_insert_exclude_pages'] = 'yes';
|
147 |
-
$option['auto_insert_custom_post_only'] = 'no';
|
148 |
-
$option['stars_title'] = 'no';
|
149 |
-
$option['stars_title_what'] = 'visitor_rating';
|
150 |
-
$option['stars_title_exclude_pages'] = 'yes';
|
151 |
-
$option['show_overall_in_loop'] = 'enabled';
|
152 |
-
$option['show_visitor_votes_in_loop'] = 'enabled';
|
153 |
-
$option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
|
154 |
-
$option['text_before_visitor_rating'] = __('Click to rate this post!', 'yet-another-stars-rating');
|
155 |
-
$option['text_after_visitor_rating'] = sprintf(
|
156 |
-
__('[Total: %s Average: %s]', 'yet-another-stars-rating'),
|
157 |
-
'%total_count%', '%average%'
|
158 |
-
);
|
159 |
-
$option['custom_text_user_voted'] = __('You have already voted for this article with rating ',
|
160 |
-
'yet-another-stars-rating') . '%rating%';
|
161 |
-
$option['custom_text_must_sign_in'] = __('You must sign in to vote', 'yet-another-stars-rating');
|
162 |
-
|
163 |
-
$option['enable_ip'] = 'no';
|
164 |
-
$option['snippet_itemtype'] = 'Product';
|
165 |
-
$option['publisher'] = 'Organization';
|
166 |
-
$option['publisher_name'] = get_bloginfo('name');
|
167 |
-
$option['publisher_logo'] = get_site_icon_url();
|
168 |
-
$option['allowed_user'] = 'allow_anonymous';
|
169 |
-
$option['visitors_stats'] = 'yes';
|
170 |
-
if($caching_plugin_found !== false) {
|
171 |
-
$option['enable_ajax'] = 'yes';
|
172 |
-
} else {
|
173 |
-
$option['enable_ajax'] = 'no';
|
174 |
-
}
|
175 |
-
|
176 |
-
add_option("yasr_general_options", $option); //Write here the default value if there is not option
|
177 |
-
|
178 |
-
//Style set options
|
179 |
-
$style_options = array();
|
180 |
-
$style_options['scheme_color_multiset'] = 'light';
|
181 |
-
$style_options['stars_set_free'] = 'flat';
|
182 |
-
|
183 |
-
add_option("yasr_style_options", $style_options);
|
184 |
-
|
185 |
-
//multi set options
|
186 |
-
$multi_set_options = array();
|
187 |
-
$multi_set_options['show_average'] = 'yes';
|
188 |
-
|
189 |
-
add_option("yasr_multiset_options", $multi_set_options);
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
}
|
194 |
|
195 |
}
|
28 |
/**
|
29 |
* Class YasrOnInstall
|
30 |
*
|
31 |
+
* This class is run on installation
|
32 |
+
*
|
33 |
+
* @since 2.3.1
|
34 |
+
* @author Dario Curvino <@dudo>
|
35 |
+
*
|
36 |
*/
|
37 |
class YasrOnInstall {
|
38 |
|
62 |
$this->defaultSettings();
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* Create YASR tables
|
67 |
+
*
|
68 |
+
* @author Dario Curvino <@dudo>
|
69 |
+
*/
|
70 |
public static function createTables () {
|
71 |
global $wpdb; //Database wordpress object
|
72 |
|
136 |
dbDelta($sql_yasr_log_table);
|
137 |
}
|
138 |
|
139 |
+
/**
|
140 |
+
* Save the default Settings
|
141 |
+
*
|
142 |
+
* @author Dario Curvino <@dudo>
|
143 |
+
*/
|
144 |
private function defaultSettings() {
|
145 |
+
$settings = new YasrSettingsValues();
|
146 |
+
add_option('yasr_general_options', $settings->getGeneralSettings());
|
147 |
+
add_option('yasr_style_options', $settings->getStyleSettings());
|
148 |
+
add_option('yasr_multiset_options', $settings->getMultiSettings());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
}
|
admin/css/yasr-admin.css
CHANGED
@@ -466,7 +466,6 @@
|
|
466 |
margin-bottom: 10px;
|
467 |
background-color: #FFF;
|
468 |
border: 1px solid #DDD;
|
469 |
-
border-radius: 9px;
|
470 |
padding: 20px;
|
471 |
font-size: 14px;
|
472 |
box-shadow: 0 0 5px 0 rgba(0,0,0,0.15);
|
@@ -790,6 +789,10 @@
|
|
790 |
|
791 |
/**** Yasr Aspect & Styles tab ***/
|
792 |
|
|
|
|
|
|
|
|
|
793 |
.yasr-select-img-container > div {
|
794 |
display: inline-block;
|
795 |
padding-left: 15px;
|
466 |
margin-bottom: 10px;
|
467 |
background-color: #FFF;
|
468 |
border: 1px solid #DDD;
|
|
|
469 |
padding: 20px;
|
470 |
font-size: 14px;
|
471 |
box-shadow: 0 0 5px 0 rgba(0,0,0,0.15);
|
789 |
|
790 |
/**** Yasr Aspect & Styles tab ***/
|
791 |
|
792 |
+
.yasr-select-img-container {
|
793 |
+
margin-bottom: 15px;
|
794 |
+
}
|
795 |
+
|
796 |
.yasr-select-img-container > div {
|
797 |
display: inline-block;
|
798 |
padding-left: 15px;
|
admin/css/yasr-pricing-page.css
CHANGED
@@ -35,7 +35,6 @@
|
|
35 |
background: white;
|
36 |
overflow: hidden;
|
37 |
flex-basis: calc( calc(100% - (var(--gap) * var(--nb-items)) )/var(--nb-items) );
|
38 |
-
min-height: 660px;
|
39 |
box-shadow: 0 18px 58px rgba(66, 11, 89, 0.07),
|
40 |
0 6.5703px 21.171px rgba(66, 11, 89, 0.0482987),
|
41 |
0 3.18976px 10.2781px rgba(66, 11, 89, 0.0389404),
|
@@ -90,7 +89,7 @@
|
|
90 |
|
91 |
.yasr-pricing-table-feature {
|
92 |
font-size: 15px;
|
93 |
-
padding:
|
94 |
list-style: none;
|
95 |
border-top: 1px solid #eee;
|
96 |
margin-bottom: 0;
|
35 |
background: white;
|
36 |
overflow: hidden;
|
37 |
flex-basis: calc( calc(100% - (var(--gap) * var(--nb-items)) )/var(--nb-items) );
|
|
|
38 |
box-shadow: 0 18px 58px rgba(66, 11, 89, 0.07),
|
39 |
0 6.5703px 21.171px rgba(66, 11, 89, 0.0482987),
|
40 |
0 3.18976px 10.2781px rgba(66, 11, 89, 0.0389404),
|
89 |
|
90 |
.yasr-pricing-table-feature {
|
91 |
font-size: 15px;
|
92 |
+
padding: 4px 0;
|
93 |
list-style: none;
|
94 |
border-top: 1px solid #eee;
|
95 |
margin-bottom: 0;
|
admin/editor/YasrEditorHooks.php
CHANGED
@@ -340,8 +340,8 @@ class YasrEditorHooks {
|
|
340 |
|
341 |
/**
|
342 |
* @author Dario Curvino <@dudo>
|
343 |
-
* @since
|
344 |
-
* @param
|
345 |
*/
|
346 |
public function addJsConstantInGutenberg($hook) {
|
347 |
if (($hook === 'post.php' || $hook === 'post-new.php' || $hook === 'appearance_page_gutenberg-edit-site')
|
@@ -752,8 +752,10 @@ class YasrEditorHooks {
|
|
752 |
} //End callback function
|
753 |
|
754 |
/**
|
|
|
|
|
755 |
* @author Dario Curvino <@dudo>
|
756 |
-
* @since 2.6.5
|
757 |
*
|
758 |
* @param $shortcode
|
759 |
* @param bool $value
|
@@ -791,7 +793,7 @@ class YasrEditorHooks {
|
|
791 |
|
792 |
/**
|
793 |
* @author Dario Curvino <@dudo>
|
794 |
-
* @since
|
795 |
*/
|
796 |
public function metaboxOutputMultisets() {
|
797 |
if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
|
340 |
|
341 |
/**
|
342 |
* @author Dario Curvino <@dudo>
|
343 |
+
* @since 2.8.4
|
344 |
+
* @param $hook
|
345 |
*/
|
346 |
public function addJsConstantInGutenberg($hook) {
|
347 |
if (($hook === 'post.php' || $hook === 'post-new.php' || $hook === 'appearance_page_gutenberg-edit-site')
|
752 |
} //End callback function
|
753 |
|
754 |
/**
|
755 |
+
* returns button to be used in tinymce
|
756 |
+
*
|
757 |
* @author Dario Curvino <@dudo>
|
758 |
+
* @since 2.6.5
|
759 |
*
|
760 |
* @param $shortcode
|
761 |
* @param bool $value
|
793 |
|
794 |
/**
|
795 |
* @author Dario Curvino <@dudo>
|
796 |
+
* @since 2.8.4
|
797 |
*/
|
798 |
public function metaboxOutputMultisets() {
|
799 |
if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
|
admin/editor/YasrOnSavePost.php
CHANGED
@@ -22,11 +22,22 @@ if (!defined('ABSPATH')) {
|
|
22 |
exit('You\'re not allowed to see this page');
|
23 |
} // Exit if accessed directly
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
class YasrOnSavePost {
|
27 |
|
28 |
private $post_id;
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
public function yasrSavePost($post_id) {
|
31 |
//if user can not publish posts
|
32 |
if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
|
@@ -45,8 +56,11 @@ class YasrOnSavePost {
|
|
45 |
do_action('yasr_on_save_post', $this->post_id);
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
private function saveOverallRating() {
|
51 |
//this mean there we're not in the classic editor
|
52 |
if (!isset($_POST['yasr_nonce_overall_rating'])) {
|
@@ -85,6 +99,11 @@ class YasrOnSavePost {
|
|
85 |
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
88 |
private function postIsReview() {
|
89 |
if(!isset($_POST['yasr_nonce_is_post_review'])) {
|
90 |
return;
|
@@ -104,6 +123,11 @@ class YasrOnSavePost {
|
|
104 |
}
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
107 |
private function saveItemType() {
|
108 |
//this mean there we're not in the classic editor
|
109 |
if(!isset($_POST['yasr_nonce_review_type'])) {
|
@@ -131,14 +155,19 @@ class YasrOnSavePost {
|
|
131 |
}
|
132 |
//save additional fields
|
133 |
$this->saveItemTypesFields($snippet_type);
|
134 |
-
|
135 |
}
|
136 |
}
|
137 |
}
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
private function saveItemTypesFields($snippet_type) {
|
140 |
$snippet_type = strtolower($snippet_type);
|
141 |
-
$array_item_type_info =
|
142 |
$array_to_save = array();
|
143 |
|
144 |
foreach ($array_item_type_info as $item_type_name) {
|
@@ -199,10 +228,15 @@ class YasrOnSavePost {
|
|
199 |
|
200 |
}
|
201 |
|
|
|
|
|
|
|
|
|
|
|
202 |
private function saveMultisetEditor() {
|
203 |
if (isset($_POST['yasr_multiset_author_votes']) && isset($_POST['yasr_multiset_id'])) {
|
204 |
$field_and_vote_array = json_decode(sanitize_text_field(stripslashes($_POST['yasr_multiset_author_votes'])));
|
205 |
-
$set_id = (int)
|
206 |
$nonce = $_POST['yasr_nonce_save_multi_values'];
|
207 |
|
208 |
if (!is_int($set_id) || $field_and_vote_array == '') {
|
@@ -220,7 +254,7 @@ class YasrOnSavePost {
|
|
220 |
$i = 0;
|
221 |
|
222 |
$data_to_save[$i] = array(
|
223 |
-
'set_id'
|
224 |
'fields_and_ratings' => $field_and_vote_array
|
225 |
);
|
226 |
|
@@ -250,6 +284,11 @@ class YasrOnSavePost {
|
|
250 |
|
251 |
} //End callback function
|
252 |
|
|
|
|
|
|
|
|
|
|
|
253 |
private function excludeAutoInsert() {
|
254 |
|
255 |
//this mean there we're not in the classic editor
|
22 |
exit('You\'re not allowed to see this page');
|
23 |
} // Exit if accessed directly
|
24 |
|
25 |
+
/**
|
26 |
+
* Class used when post is saved
|
27 |
+
*
|
28 |
+
* @author Dario Curvino <@dudo>
|
29 |
+
*/
|
30 |
class YasrOnSavePost {
|
31 |
|
32 |
private $post_id;
|
33 |
|
34 |
+
/**
|
35 |
+
* This method is the callback hooked into action save_post
|
36 |
+
*
|
37 |
+
* @author Dario Curvino <@dudo>
|
38 |
+
*
|
39 |
+
* @param $post_id
|
40 |
+
*/
|
41 |
public function yasrSavePost($post_id) {
|
42 |
//if user can not publish posts
|
43 |
if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
|
56 |
do_action('yasr_on_save_post', $this->post_id);
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* Save Overall Rating post_meta, is yasr_overall_rating isset
|
61 |
+
*
|
62 |
+
* @author Dario Curvino <@dudo>
|
63 |
+
*/
|
64 |
private function saveOverallRating() {
|
65 |
//this mean there we're not in the classic editor
|
66 |
if (!isset($_POST['yasr_nonce_overall_rating'])) {
|
99 |
|
100 |
}
|
101 |
|
102 |
+
/**
|
103 |
+
* Update / Delete the post meta key yasr_post_is_review
|
104 |
+
*
|
105 |
+
* @author Dario Curvino <@dudo>
|
106 |
+
*/
|
107 |
private function postIsReview() {
|
108 |
if(!isset($_POST['yasr_nonce_is_post_review'])) {
|
109 |
return;
|
123 |
}
|
124 |
}
|
125 |
|
126 |
+
/**
|
127 |
+
* Save itemType name and additional info
|
128 |
+
*
|
129 |
+
* @author Dario Curvino <@dudo>
|
130 |
+
*/
|
131 |
private function saveItemType() {
|
132 |
//this mean there we're not in the classic editor
|
133 |
if(!isset($_POST['yasr_nonce_review_type'])) {
|
155 |
}
|
156 |
//save additional fields
|
157 |
$this->saveItemTypesFields($snippet_type);
|
|
|
158 |
}
|
159 |
}
|
160 |
}
|
161 |
|
162 |
+
/**
|
163 |
+
* Helper method to save additional info for a itemType
|
164 |
+
*
|
165 |
+
* @author Dario Curvino <@dudo>
|
166 |
+
* @param $snippet_type
|
167 |
+
*/
|
168 |
private function saveItemTypesFields($snippet_type) {
|
169 |
$snippet_type = strtolower($snippet_type);
|
170 |
+
$array_item_type_info = YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS;
|
171 |
$array_to_save = array();
|
172 |
|
173 |
foreach ($array_item_type_info as $item_type_name) {
|
228 |
|
229 |
}
|
230 |
|
231 |
+
/**
|
232 |
+
* Save data for Author Multi Set
|
233 |
+
*
|
234 |
+
* @author Dario Curvino <@dudo>
|
235 |
+
*/
|
236 |
private function saveMultisetEditor() {
|
237 |
if (isset($_POST['yasr_multiset_author_votes']) && isset($_POST['yasr_multiset_id'])) {
|
238 |
$field_and_vote_array = json_decode(sanitize_text_field(stripslashes($_POST['yasr_multiset_author_votes'])));
|
239 |
+
$set_id = (int)$_POST['yasr_multiset_id'];
|
240 |
$nonce = $_POST['yasr_nonce_save_multi_values'];
|
241 |
|
242 |
if (!is_int($set_id) || $field_and_vote_array == '') {
|
254 |
$i = 0;
|
255 |
|
256 |
$data_to_save[$i] = array(
|
257 |
+
'set_id' => $set_id,
|
258 |
'fields_and_ratings' => $field_and_vote_array
|
259 |
);
|
260 |
|
284 |
|
285 |
} //End callback function
|
286 |
|
287 |
+
/**
|
288 |
+
* Update or delete post meta yasr_auto_insert_disabled
|
289 |
+
*
|
290 |
+
* @author Dario Curvino <@dudo>
|
291 |
+
*/
|
292 |
private function excludeAutoInsert() {
|
293 |
|
294 |
//this mean there we're not in the classic editor
|
admin/editor/yasr-metabox-multiple-rating.php
CHANGED
@@ -68,7 +68,7 @@ if ($n_multi_set > 1) {
|
|
68 |
data-postid="<?php echo esc_attr($post_id) ?>">
|
69 |
|
70 |
<input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
|
71 |
-
<input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="">
|
72 |
<input type="hidden" name="yasr_pro_review_setid" id="yasr-pro-review-setid"
|
73 |
value="<?php esc_attr_e($post->yasr_pro_review_setid) ?>">
|
74 |
|
68 |
data-postid="<?php echo esc_attr($post_id) ?>">
|
69 |
|
70 |
<input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
|
71 |
+
<input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="<?php echo esc_attr($set_id) ?>">
|
72 |
<input type="hidden" name="yasr_pro_review_setid" id="yasr-pro-review-setid"
|
73 |
value="<?php esc_attr_e($post->yasr_pro_review_setid) ?>">
|
74 |
|
admin/editor/yasr-metabox-schema.php
CHANGED
@@ -40,7 +40,7 @@ if(empty($saved_data)) {
|
|
40 |
$saved_data = array();
|
41 |
}
|
42 |
|
43 |
-
$array_item_type_info =
|
44 |
|
45 |
//foreach every supported element, create a nonce field
|
46 |
//and set single element to false if not present in db to avoid undefined
|
40 |
$saved_data = array();
|
41 |
}
|
42 |
|
43 |
+
$array_item_type_info = YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS;
|
44 |
|
45 |
//foreach every supported element, create a nonce field
|
46 |
//and set single element to false if not present in db to avoid undefined
|
admin/js/guten/blocks/noStarsRankings.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";var e,t,a,r,n,s,l,
|
1 |
+
(()=>{"use strict";var e,t,a,r,n,s,l,c={534:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>b,YasrDivRatingOverall:()=>S,YasrNoSettingsPanel:()=>h,YasrPrintInputId:()=>R,YasrPrintSelectSize:()=>d,YasrProText:()=>E,yasrLabelSelectSize:()=>o,yasrLeaveThisBlankText:()=>y,yasrOptionalText:()=>c,yasrOverallDescription:()=>v,yasrSelectSizeChoose:()=>i,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>g});var r=a(534),n=wp.i18n.__,s=wp.components.PanelBody,l=wp.blockEditor.InspectorControls,c=n("All these settings are optional","yet-another-stars-rating"),o=n("Choose Size","yet-another-stars-rating"),i=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),p=n("Large","yet-another-stars-rating"),y=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),v=n("Remember: only the post author can rate here.","yet-another-stars-rating"),g=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function d(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(a=t).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},r.yasrSelectSizeChoose),React.createElement("option",{value:"small"},r.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},r.yasrSelectSizeMedium),React.createElement("option",{value:"large"},r.yasrSelectSizeLarge)))}function R(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var a=t.target.value;!0!==/^\d+$/.test(a)&&""!==a||e({postId:a}),t.preventDefault()}}(e.setAttributes,t)}}))}function E(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function h(e){return React.createElement("div",null,React.createElement(E,null))}function b(e){var t;return"visitors"===e.block&&(t=g),"overall"===e.block&&(t=v),React.createElement(l,null,"overall"===e.block&&React.createElement(S,null),React.createElement(s,{title:"Settings"},React.createElement("h3",null,c),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,o),React.createElement("div",null,React.createElement(d,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(R,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},y)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function S(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return yasrSetRaterValue(32,"overall-rater",!1,.1,!1,a,r)}}))}}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var a=o[e]={exports:{}};return c[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var a in t)i.o(t,a)&&!i.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=i(534),t=wp.blocks.registerBlockType,a=wp.components.PanelBody,r=wp.element.Fragment,n=wp.blockEditor,s=n.useBlockProps,l=n.InspectorControls,t("yet-another-stars-rating/most-active-users",{edit:function(t){var n=s({className:"yasr-active-users-block"}),c=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function o(e){return React.createElement(l,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,c))))}return wp.hooks.doAction("yasr_top_visitor_setting",c),React.createElement(r,null,React.createElement(o,null),React.createElement("div",n,"[yasr_most_active_users]"))},save:function(e){var t=s.save({className:"yasr-active-users-block"});return React.createElement("div",t,"[yasr_most_active_users]")}}),t("yet-another-stars-rating/most-active-reviewers",{edit:function(t){var n=s({className:"yasr-reviewers-block"}),c=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function o(e){return React.createElement(l,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,c))))}return wp.hooks.doAction("yasr_top_reviewers_setting",c),React.createElement(r,null,React.createElement(o,null),React.createElement("div",n,"[yasr_top_reviewers]"))},save:function(e){var t=s.save({className:"yasr-reviewers-block"});return React.createElement("div",t,"[yasr_top_reviewers]")}})})();
|
admin/js/guten/blocks/overallRating.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";var e,t,a,r,n={
|
1 |
+
(()=>{"use strict";var e,t,a,r,n={534:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>E,YasrDivRatingOverall:()=>S,YasrNoSettingsPanel:()=>R,YasrPrintInputId:()=>b,YasrPrintSelectSize:()=>v,YasrProText:()=>h,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>y,yasrOptionalText:()=>o,yasrOverallDescription:()=>g,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>d});var r=a(534),n=wp.i18n.__,l=wp.components.PanelBody,s=wp.blockEditor.InspectorControls,o=n("All these settings are optional","yet-another-stars-rating"),i=n("Choose Size","yet-another-stars-rating"),c=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),p=n("Large","yet-another-stars-rating"),y=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),g=n("Remember: only the post author can rate here.","yet-another-stars-rating"),d=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function v(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(a=t).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},r.yasrSelectSizeChoose),React.createElement("option",{value:"small"},r.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},r.yasrSelectSizeMedium),React.createElement("option",{value:"large"},r.yasrSelectSizeLarge)))}function b(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var a=t.target.value;!0!==/^\d+$/.test(a)&&""!==a||e({postId:a}),t.preventDefault()}}(e.setAttributes,t)}}))}function h(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function R(e){return React.createElement("div",null,React.createElement(h,null))}function E(e){var t;return"visitors"===e.block&&(t=d),"overall"===e.block&&(t=g),React.createElement(s,null,"overall"===e.block&&React.createElement(S,null),React.createElement(l,{title:"Settings"},React.createElement("h3",null,o),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,i),React.createElement("div",null,React.createElement(v,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(b,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},y)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function S(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return yasrSetRaterValue(32,"overall-rater",!1,.1,!1,a,r)}}))}}},l={};function s(e){var t=l[e];if(void 0!==t)return t.exports;var a=l[e]={exports:{}};return n[e](a,a.exports,s),a.exports}s.d=(e,t)=>{for(var a in t)s.o(t,a)&&!s.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=s(534),wp.i18n.__,t=wp.blocks.registerBlockType,a=wp.element.Fragment,r=wp.blockEditor.useBlockProps,t("yet-another-stars-rating/overall-rating",{edit:function(t){var n=r({className:"yasr-overall-block"}),l=t.attributes,s=l.size,o=l.postId,i=t.setAttributes,c=t.isSelected,u=null,m=null;return"large"!==s&&(u=' size="'+s+'"'),!0===/^\d+$/.test(o)&&(m=' postid="'+o+'"'),React.createElement(a,null,c&&React.createElement(e.YasrBlocksPanel,{block:"overall",size:s,postId:o,setAttributes:i}),React.createElement("div",n,"[yasr_overall_rating",u,m,"]",c&&React.createElement(e.YasrPrintSelectSize,{size:s,setAttributes:i})))},save:function(e){var t=r.save({className:"yasr-overall-block"}),a=e.attributes,n=a.size,l=a.postId,s="";return n&&(s+='size="'+n+'"'),l&&(s+=' postid="'+l+'"'),React.createElement("div",t,"[yasr_overall_rating ",s,"]")}})})();
|
admin/js/guten/blocks/rankings.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";var e,t,a,r,n,l,s,o={
|
1 |
+
(()=>{"use strict";var e,t,a,r,n,l,s,o={534:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>b,YasrDivRatingOverall:()=>k,YasrNoSettingsPanel:()=>E,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>d,YasrProText:()=>R,yasrLabelSelectSize:()=>c,yasrLeaveThisBlankText:()=>y,yasrOptionalText:()=>o,yasrOverallDescription:()=>p,yasrSelectSizeChoose:()=>i,yasrSelectSizeLarge:()=>g,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>v});var r=a(534),n=wp.i18n.__,l=wp.components.PanelBody,s=wp.blockEditor.InspectorControls,o=n("All these settings are optional","yet-another-stars-rating"),c=n("Choose Size","yet-another-stars-rating"),i=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),g=n("Large","yet-another-stars-rating"),y=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),p=n("Remember: only the post author can rate here.","yet-another-stars-rating"),v=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function d(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(a=t).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},r.yasrSelectSizeChoose),React.createElement("option",{value:"small"},r.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},r.yasrSelectSizeMedium),React.createElement("option",{value:"large"},r.yasrSelectSizeLarge)))}function h(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var a=t.target.value;!0!==/^\d+$/.test(a)&&""!==a||e({postId:a}),t.preventDefault()}}(e.setAttributes,t)}}))}function R(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function E(e){return React.createElement("div",null,React.createElement(R,null))}function b(e){var t;return"visitors"===e.block&&(t=v),"overall"===e.block&&(t=p),React.createElement(s,null,"overall"===e.block&&React.createElement(k,null),React.createElement(l,{title:"Settings"},React.createElement("h3",null,o),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,c),React.createElement("div",null,React.createElement(d,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(h,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},y)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function k(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return yasrSetRaterValue(32,"overall-rater",!1,.1,!1,a,r)}}))}}},c={};function i(e){var t=c[e];if(void 0!==t)return t.exports;var a=c[e]={exports:{}};return o[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var a in t)i.o(t,a)&&!i.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=i(534),t=wp.blocks.registerBlockType,a=wp.components.PanelBody,r=wp.element.Fragment,n=wp.blockEditor,l=n.useBlockProps,s=n.InspectorControls,t("yet-another-stars-rating/overall-rating-ranking",{edit:function(t){var n=l({className:"yasr-ov-ranking-block"}),o=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function c(e){return React.createElement(s,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,o))))}return wp.hooks.doAction("yasr_overall_rating_rankings",o),React.createElement(r,null,React.createElement(c,null),React.createElement("div",n,"[yasr_ov_ranking]"))},save:function(e){var t=l.save({className:"yasr-ov-ranking-block"});return React.createElement("div",t,"[yasr_ov_ranking]")}}),t("yet-another-stars-rating/visitor-votes-ranking",{edit:function(t){var n=l({className:"yasr-vv-ranking-block"}),o=[React.createElement(e.YasrNoSettingsPanel,{key:0})];function c(e){return React.createElement(s,null,React.createElement(a,{title:"Settings"},React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("div",null,o))))}return wp.hooks.doAction("yasr_visitor_votes_rankings",o),React.createElement(r,null,React.createElement(c,null),React.createElement("div",n,"[yasr_most_or_highest_rated_posts]"))},save:function(e){var t=l.save({className:"yasr-vv-ranking-block"});return React.createElement("div",t,"[yasr_most_or_highest_rated_posts]")}})})();
|
admin/js/guten/blocks/visitorVotes.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";var e,t,a,r,n={
|
1 |
+
(()=>{"use strict";var e,t,a,r,n={534:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>E,YasrDivRatingOverall:()=>S,YasrNoSettingsPanel:()=>R,YasrPrintInputId:()=>b,YasrPrintSelectSize:()=>v,YasrProText:()=>h,yasrLabelSelectSize:()=>o,yasrLeaveThisBlankText:()=>y,yasrOptionalText:()=>i,yasrOverallDescription:()=>d,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>g});var r=a(534),n=wp.i18n.__,s=wp.components.PanelBody,l=wp.blockEditor.InspectorControls,i=n("All these settings are optional","yet-another-stars-rating"),o=n("Choose Size","yet-another-stars-rating"),c=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),p=n("Large","yet-another-stars-rating"),y=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),d=n("Remember: only the post author can rate here.","yet-another-stars-rating"),g=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function v(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(a=t).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},r.yasrSelectSizeChoose),React.createElement("option",{value:"small"},r.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},r.yasrSelectSizeMedium),React.createElement("option",{value:"large"},r.yasrSelectSizeLarge)))}function b(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var a=t.target.value;!0!==/^\d+$/.test(a)&&""!==a||e({postId:a}),t.preventDefault()}}(e.setAttributes,t)}}))}function h(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function R(e){return React.createElement("div",null,React.createElement(h,null))}function E(e){var t;return"visitors"===e.block&&(t=g),"overall"===e.block&&(t=d),React.createElement(l,null,"overall"===e.block&&React.createElement(S,null),React.createElement(s,{title:"Settings"},React.createElement("h3",null,i),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,o),React.createElement("div",null,React.createElement(v,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(b,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},y)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function S(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return yasrSetRaterValue(32,"overall-rater",!1,.1,!1,a,r)}}))}}},s={};function l(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={exports:{}};return n[e](a,a.exports,l),a.exports}l.d=(e,t)=>{for(var a in t)l.o(t,a)&&!l.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e=l(534),wp.i18n.__,t=wp.blocks.registerBlockType,a=wp.element.Fragment,r=wp.blockEditor.useBlockProps,t("yet-another-stars-rating/visitor-votes",{edit:function(t){var n=r({className:"yasr-vv-block"}),s=t.attributes,l=s.size,i=s.postId,o=t.setAttributes,c=t.isSelected,u=null,m=null;return"large"!==l&&(u=' size="'+l+'"'),!0===/^\d+$/.test(i)&&(m=' postid="'+i+'"'),React.createElement(a,null,React.createElement(e.YasrBlocksPanel,{block:"visitors",size:l,setAttributes:o,postId:i}),React.createElement("div",n,"[yasr_visitor_votes",u,m,"]",c&&React.createElement(e.YasrPrintSelectSize,{size:l,setAttributes:o})))},save:function(e){var t=r.save({className:"yasr-vv-block"}),a=e.attributes,n=a.size,s=a.postId,l="";return n&&(l+='size="'+n+'"'),s&&(l+=' postid="'+s+'"'),React.createElement("div",t,"[yasr_visitor_votes ",l,"]")}})})();
|
admin/js/guten/blocks/yasrGutenUtils.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";var e={
|
1 |
+
(()=>{"use strict";var e={534:(e,t,a)=>{a.r(t),a.d(t,{YasrBlocksPanel:()=>E,YasrDivRatingOverall:()=>S,YasrNoSettingsPanel:()=>R,YasrPrintInputId:()=>v,YasrPrintSelectSize:()=>h,YasrProText:()=>b,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>y,yasrOptionalText:()=>o,yasrOverallDescription:()=>g,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>m,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>d});var r=a(534),n=wp.i18n.__,l=wp.components.PanelBody,s=wp.blockEditor.InspectorControls,o=n("All these settings are optional","yet-another-stars-rating"),i=n("Choose Size","yet-another-stars-rating"),c=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),m=n("Medium","yet-another-stars-rating"),p=n("Large","yet-another-stars-rating"),y=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),g=n("Remember: only the post author can rate here.","yet-another-stars-rating"),d=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function h(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(a=t).target.querySelector("option:checked").value}),void a.preventDefault();var a}},React.createElement("option",{value:"--"},r.yasrSelectSizeChoose),React.createElement("option",{value:"small"},r.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},r.yasrSelectSizeMedium),React.createElement("option",{value:"large"},r.yasrSelectSizeLarge)))}function v(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var a=t.target.value;!0!==/^\d+$/.test(a)&&""!==a||e({postId:a}),t.preventDefault()}}(e.setAttributes,t)}}))}function b(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function R(e){return React.createElement("div",null,React.createElement(b,null))}function E(e){var t;return"visitors"===e.block&&(t=d),"overall"===e.block&&(t=g),React.createElement(s,null,"overall"===e.block&&React.createElement(S,null),React.createElement(l,{title:"Settings"},React.createElement("h3",null,o),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,i),React.createElement("div",null,React.createElement(h,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(v,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},y)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function S(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),a=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,r=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return yasrSetRaterValue(32,"overall-rater",!1,.1,!1,a,r)}}))}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var l=t[r]={exports:{}};return e[r](l,l.exports,a),l.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a(534)})();
|
admin/js/guten/yasr-guten-misc.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{var e={245:(e,t,r)=>{"use strict";r.r(t),r.d(t,{YasrBlocksPanel:()=>R,YasrDivRatingOverall:()=>E,YasrNoSettingsPanel:()=>b,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>g,YasrProText:()=>v,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>d,yasrOptionalText:()=>s,yasrOverallDescription:()=>m,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>y,yasrSelectSizeMedium:()=>p,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>f});var a=r(245),n=wp.i18n.__,o=wp.components.PanelBody,l=wp.blockEditor.InspectorControls,s=n("All these settings are optional","yet-another-stars-rating"),i=n("Choose Size","yet-another-stars-rating"),c=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),p=n("Medium","yet-another-stars-rating"),y=n("Large","yet-another-stars-rating"),d=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),m=n("Remember: only the post author can rate here.","yet-another-stars-rating"),f=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function g(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(r=t).target.querySelector("option:checked").value}),void r.preventDefault();var r}},React.createElement("option",{value:"--"},a.yasrSelectSizeChoose),React.createElement("option",{value:"small"},a.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},a.yasrSelectSizeMedium),React.createElement("option",{value:"large"},a.yasrSelectSizeLarge)))}function h(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var r=t.target.value;!0!==/^\d+$/.test(r)&&""!==r||e({postId:r}),t.preventDefault()}}(e.setAttributes,t)}}))}function v(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function b(e){return React.createElement("div",null,React.createElement(v,null))}function R(e){var t;return"visitors"===e.block&&(t=f),"overall"===e.block&&(t=m),React.createElement(l,null,"overall"===e.block&&React.createElement(E,null),React.createElement(o,{title:"Settings"},React.createElement("h3",null,s),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,i),React.createElement("div",null,React.createElement(g,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(h,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},d)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function E(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),r=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,a=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return function(e,t){var r,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:r,step:a,readOnly:n,rating:o,rateCallback:l})}(32,"overall-rater",!1,.1,!1,r,a)}}))}}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function r(e,t){return r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(e,t)}function a(t,r){if(r&&("object"===e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}var o=wp.i18n.__,l=wp.blocks.registerBlockType,s=wp.components,i=s.PanelBody,c=(s.PanelRow,wp.element.Fragment),u=wp.editor,p=(u.BlockControls,u.InspectorControls),y=o("All these settings are optional","yet-another-stars-rating"),d=o("Choose Size","yet-another-stars-rating"),m=o("Choose stars size","yet-another-stars-rating"),f=o("Small","yet-another-stars-rating"),g=o("Medium","yet-another-stars-rating"),h=o("Large","yet-another-stars-rating"),v=o("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),b=o("Remember: only the post author can rate here.","yet-another-stars-rating"),R=o("This is the star set where your users will be able to vote","yet-another-stars-rating"),E=o('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Overall Rating" again.',"yet-another-stars-rating"),w=o('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Visitors Votes" again.',"yet-another-stars-rating");l("yet-another-stars-rating/yasr-overall-rating",{title:o("[DEPRECATED]Yasr: Overall Rating","yet-another-stars-rating"),description:E,icon:"star-half",keywords:[o("rating","yet-another-stars-rating"),o("author","yet-another-stars-rating"),o("overall","yet-another-stars-rating")],attributes:{overallRatingMeta:{type:"number",source:"meta",meta:"yasr_overall_rating"},size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var l,s=e.attributes,u=s.overallRatingMeta,R=s.size,E=s.postId,w=e.setAttributes,k=e.isSelected,_=u,S=null,P=null;"--"!==R&&(S=' size="'+R+'"'),l=/^\d+$/.test(E),"--"!==E&&!0===l&&(P=' postid="'+E+'"');var O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)}(p,React.Component);var l,s,i,c,u=(i=p,c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=n(i);if(c){var r=n(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return a(this,e)});function p(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,p),(t=u.call(this,e)).yasrOverallRateThis=o("Rate this article / item","yet-another-stars-rating"),t}return l=p,(s=[{key:"render",value:function(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,React.createElement("div",{id:"overall-rater",ref:function(){return raterJs({starSize:32,step:.1,showToolTip:!1,rating:_,readOnly:!1,element:document.querySelector("#overall-rater"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),w({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&t(l.prototype,s),Object.defineProperty(l,"prototype",{writable:!1}),p}();function z(){return React.createElement("form",null,React.createElement("select",{value:R,onChange:I},React.createElement("option",{value:"--"},m),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},g),React.createElement("option",{value:"large"},h)))}function I(e){var t=e.target.querySelector("option:checked");w({size:t.value}),e.preventDefault()}function T(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:C}))}function C(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||w({postId:t}),e.preventDefault()}}function N(e){return React.createElement(p,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(O,null)),React.createElement(i,{title:"Settings"},React.createElement("h3",null,y),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,d),React.createElement("div",null,React.createElement(z,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(T,null),React.createElement("div",{className:"yasr-guten-block-explain"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},b)))}return React.createElement(c,null,React.createElement(N,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",S,P,"]",k&&React.createElement(z,null)))},save:function(e){var t=e.attributes,r=t.size,a=t.postId,n="",o=a;return r&&(n+='size="'+r+'"'),a&&("--"===a&&(o=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_overall_rating ",n,"]")}}),l("yet-another-stars-rating/yasr-visitor-votes",{title:o("[DEPRECATED]Yasr: Visitor Votes","yet-another-stars-rating"),description:w,icon:"star-half",keywords:[o("rating","yet-another-stars-rating"),o("visitor","yet-another-stars-rating"),o("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var t,r=e.attributes,a=r.size,n=r.postId,o=e.setAttributes,l=e.isSelected,s=null,u=null;function b(){return React.createElement("form",null,React.createElement("select",{value:a,onChange:E},React.createElement("option",{value:"--"},m),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},g),React.createElement("option",{value:"large"},h)))}function E(e){var t=e.target.querySelector("option:checked");o({size:t.value}),e.preventDefault()}function w(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:k}))}function k(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||o({postId:t}),e.preventDefault()}}function _(e){return React.createElement(p,null,React.createElement(i,{title:"Settings"},React.createElement("h3",null,y),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,d),React.createElement("div",null,React.createElement(b,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(w,null),React.createElement("div",{className:"yasr-guten-block-explain"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},R)))}return t=/^\d+$/.test(n),"--"!==a&&(s=' size="'+a+'"'),"--"!==n&&!0===t&&(u=' postid="'+n+'"'),React.createElement(c,null,React.createElement(_,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",s,u,"]",l&&React.createElement(b,null)))},save:function(e){var t=e.attributes,r=t.size,a=t.postId,n="",o=a;return r&&(n+='size="'+r+'"'),a&&("--"===a&&(o=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_visitor_votes ",n,"]")}}),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-overall-rating"),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-visitor-votes")})(),(()=>{"use strict";var e=r(245);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function i(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=p(e);if(t){var n=p(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return c(this,r)}}function c(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}var y=wp.i18n.__,d=wp.plugins.registerPlugin,m=wp.editPost,f=m.PluginSidebar,g=m.PluginSidebarMoreMenuItem,h=wp.components.PanelBody,v=wp.element.Fragment,b=function(){return React.createElement("div",null)},R=function(e){l(r,React.Component);var t=i(r);function r(e){var n;a(this,r),n=t.call(this,e);var o=!1;return"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(o=!0),n.state={postExcluded:o},n.yasrUpdatePostMetaAutoInsert=n.yasrUpdatePostMetaAutoInsert.bind(u(n)),n}return o(r,[{key:"yasrUpdatePostMetaAutoInsert",value:function(e){var t=e.target,r="checkbox"===t.type?t.checked:t.value;this.setState({postExcluded:r}),!0===r?wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"yes"}}):wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"no"}})}},{key:"render",value:function(){return React.createElement("div",{className:"yasr-guten-block-panel-center"},React.createElement("hr",null),React.createElement("label",null,React.createElement("span",null,y("Disable auto insert for this post or page?","yet-another-stars-rating"))),React.createElement("div",{className:"yasr-onoffswitch-big yasr-onoffswitch-big-center",id:"yasr-switcher-disable-auto-insert"},React.createElement("input",{type:"checkbox",name:"yasr_auto_insert_disabled",className:"yasr-onoffswitch-checkbox",value:"yes",id:"yasr-auto-insert-disabled-switch",defaultChecked:this.state.postExcluded,onChange:this.yasrUpdatePostMetaAutoInsert}),React.createElement("label",{className:"yasr-onoffswitch-label",htmlFor:"yasr-auto-insert-disabled-switch"},React.createElement("span",{className:"yasr-onoffswitch-inner"}),React.createElement("span",{className:"yasr-onoffswitch-switch"}))))}}]),r}(),E=function(t){l(n,React.Component);var r=i(n);function n(e){var t;a(this,n),t=r.call(this,e);var o=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(o=!0),t.state={yasrAutoInsertEnabled:o},t}return o(n,[{key:"render",value:function(){var t=[React.createElement(b,{key:0})];return wp.hooks.doAction("yasr_below_panel",t),React.createElement(v,null,React.createElement(g,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},y("YASR post settings","yet-another-stars-rating")),React.createElement(f,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(h,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(e.YasrDivRatingOverall,null),React.createElement("div",null,y('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating")),this.state.yasrAutoInsertEnabled&&React.createElement(R,null),t))))}}]),n}();d("yasr-sidebar",{icon:"star-half",title:y("Yasr: Settings","yet-another-stars-rating"),render:E})})()})();
|
1 |
+
(()=>{var e={534:(e,t,r)=>{"use strict";r.r(t),r.d(t,{YasrBlocksPanel:()=>R,YasrDivRatingOverall:()=>E,YasrNoSettingsPanel:()=>b,YasrPrintInputId:()=>h,YasrPrintSelectSize:()=>g,YasrProText:()=>v,yasrLabelSelectSize:()=>i,yasrLeaveThisBlankText:()=>m,yasrOptionalText:()=>s,yasrOverallDescription:()=>d,yasrSelectSizeChoose:()=>c,yasrSelectSizeLarge:()=>p,yasrSelectSizeMedium:()=>y,yasrSelectSizeSmall:()=>u,yasrVisitorVotesDescription:()=>f});var a=r(534),n=wp.i18n.__,o=wp.components.PanelBody,l=wp.blockEditor.InspectorControls,s=n("All these settings are optional","yet-another-stars-rating"),i=n("Choose Size","yet-another-stars-rating"),c=n("Choose stars size","yet-another-stars-rating"),u=n("Small","yet-another-stars-rating"),y=n("Medium","yet-another-stars-rating"),p=n("Large","yet-another-stars-rating"),m=n("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),d=n("Remember: only the post author can rate here.","yet-another-stars-rating"),f=n("This is the star set where your users will be able to vote","yet-another-stars-rating");function g(e){return React.createElement("form",null,React.createElement("select",{value:e.size,onChange:function(t){return(0,e.setAttributes)({size:(r=t).target.querySelector("option:checked").value}),void r.preventDefault();var r}},React.createElement("option",{value:"--"},a.yasrSelectSizeChoose),React.createElement("option",{value:"small"},a.yasrSelectSizeSmall),React.createElement("option",{value:"medium"},a.yasrSelectSizeMedium),React.createElement("option",{value:"large"},a.yasrSelectSizeLarge)))}function h(e){var t;return!1!==e.postId&&(t=e.postId),React.createElement("div",null,React.createElement("input",{type:"text",size:"4",defaultValue:t,onKeyPress:function(t){return function(e,t){if("Enter"===t.key){var r=t.target.value;!0!==/^\d+$/.test(r)&&""!==r||e({postId:r}),t.preventDefault()}}(e.setAttributes,t)}}))}function v(){var e=n("To be able to customize this ranking, you need","yet-another-stars-rating"),t=n("You can buy the plugin, including support, updates and upgrades, on","yet-another-stars-rating");return React.createElement("h3",null,e," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro"},"Yasr Pro."),React.createElement("br",null),t," ",React.createElement("a",{href:"https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings"},"yetanotherstarsrating.com"))}function b(e){return React.createElement("div",null,React.createElement(v,null))}function R(e){var t;return"visitors"===e.block&&(t=f),"overall"===e.block&&(t=d),React.createElement(l,null,"overall"===e.block&&React.createElement(E,null),React.createElement(o,{title:"Settings"},React.createElement("h3",null,s),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,i),React.createElement("div",null,React.createElement(g,{size:e.size,setAttributes:e.setAttributes}))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(h,{postId:e.postId,setAttributes:e.setAttributes}),React.createElement("div",{className:"yasr-guten-block-explain"},m)),React.createElement("div",{className:"yasr-guten-block-panel"},t)))}function E(e){if(!0===JSON.parse(yasrConstantGutenberg.isFseElement))return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement("div",null,n("This is a template file, you can't rate here. You need to insert the rating inside the single post or page","yet-another-stars-rating")),React.createElement("br",null));var t=n("Rate this article / item","yet-another-stars-rating"),r=wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,a=function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()};return React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},t,React.createElement("div",{id:"overall-rater",ref:function(){return yasrSetRaterValue(32,"overall-rater",!1,.1,!1,r,a)}}))}}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function r(e,t){return r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(e,t)}function a(t,r){if(r&&("object"===e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}var o=wp.i18n.__,l=wp.blocks.registerBlockType,s=wp.components,i=s.PanelBody,c=(s.PanelRow,wp.element.Fragment),u=wp.editor,y=(u.BlockControls,u.InspectorControls),p=o("All these settings are optional","yet-another-stars-rating"),m=o("Choose Size","yet-another-stars-rating"),d=o("Choose stars size","yet-another-stars-rating"),f=o("Small","yet-another-stars-rating"),g=o("Medium","yet-another-stars-rating"),h=o("Large","yet-another-stars-rating"),v=o("Leave this blank if you don't know what you're doing.","yet-another-stars-rating"),b=o("Remember: only the post author can rate here.","yet-another-stars-rating"),R=o("This is the star set where your users will be able to vote","yet-another-stars-rating"),E=o('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Overall Rating" again.',"yet-another-stars-rating"),w=o('This block is now deprecated. It will still work, but I suggest to replace it with the new one by simply removing it and adding "Yasr Visitors Votes" again.',"yet-another-stars-rating");l("yet-another-stars-rating/yasr-overall-rating",{title:o("[DEPRECATED]Yasr: Overall Rating","yet-another-stars-rating"),description:E,icon:"star-half",keywords:[o("rating","yet-another-stars-rating"),o("author","yet-another-stars-rating"),o("overall","yet-another-stars-rating")],attributes:{overallRatingMeta:{type:"number",source:"meta",meta:"yasr_overall_rating"},size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var l,s=e.attributes,u=s.overallRatingMeta,R=s.size,E=s.postId,w=e.setAttributes,k=e.isSelected,_=u,S=null,P=null;"--"!==R&&(S=' size="'+R+'"'),l=/^\d+$/.test(E),"--"!==E&&!0===l&&(P=' postid="'+E+'"');var O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)}(y,React.Component);var l,s,i,c,u=(i=y,c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=n(i);if(c){var r=n(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return a(this,e)});function y(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,y),(t=u.call(this,e)).yasrOverallRateThis=o("Rate this article / item","yet-another-stars-rating"),t}return l=y,(s=[{key:"render",value:function(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,React.createElement("div",{id:"overall-rater",ref:function(){return raterJs({starSize:32,step:.1,showToolTip:!1,rating:_,readOnly:!1,element:document.querySelector("#overall-rater"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),w({overallRatingMeta:e}),this.setRating(e),t()}})}})))}}])&&t(l.prototype,s),Object.defineProperty(l,"prototype",{writable:!1}),y}();function z(){return React.createElement("form",null,React.createElement("select",{value:R,onChange:I},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},g),React.createElement("option",{value:"large"},h)))}function I(e){var t=e.target.querySelector("option:checked");w({size:t.value}),e.preventDefault()}function C(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:T}))}function T(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||w({postId:t}),e.preventDefault()}}function N(e){return React.createElement(y,null,React.createElement("div",{class:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(O,null)),React.createElement(i,{title:"Settings"},React.createElement("h3",null,p),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,m),React.createElement("div",null,React.createElement(z,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(C,null),React.createElement("div",{className:"yasr-guten-block-explain"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},b)))}return React.createElement(c,null,React.createElement(N,null),React.createElement("div",{className:e.className},"[yasr_overall_rating",S,P,"]",k&&React.createElement(z,null)))},save:function(e){var t=e.attributes,r=t.size,a=t.postId,n="",o=a;return r&&(n+='size="'+r+'"'),a&&("--"===a&&(o=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_overall_rating ",n,"]")}}),l("yet-another-stars-rating/yasr-visitor-votes",{title:o("[DEPRECATED]Yasr: Visitor Votes","yet-another-stars-rating"),description:w,icon:"star-half",keywords:[o("rating","yet-another-stars-rating"),o("visitor","yet-another-stars-rating"),o("votes","yet-another-stars-rating")],attributes:{size:{type:"string",default:"--"},postId:{type:"string",default:"--"}},edit:function(e){var t,r=e.attributes,a=r.size,n=r.postId,o=e.setAttributes,l=e.isSelected,s=null,u=null;function b(){return React.createElement("form",null,React.createElement("select",{value:a,onChange:E},React.createElement("option",{value:"--"},d),React.createElement("option",{value:"small"},f),React.createElement("option",{value:"medium"},g),React.createElement("option",{value:"large"},h)))}function E(e){var t=e.target.querySelector("option:checked");o({size:t.value}),e.preventDefault()}function w(){return React.createElement("div",null,React.createElement("input",{type:"text",size:"4",onKeyPress:k}))}function k(e){if("Enter"===e.key){var t=e.target.value;!0!==/^\d+$/.test(t)&&""!==t||o({postId:t}),e.preventDefault()}}function _(e){return React.createElement(y,null,React.createElement(i,{title:"Settings"},React.createElement("h3",null,p),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,m),React.createElement("div",null,React.createElement(b,null))),React.createElement("div",{className:"yasr-guten-block-panel"},React.createElement("label",null,"Post ID"),React.createElement(w,null),React.createElement("div",{className:"yasr-guten-block-explain"},v)),React.createElement("div",{className:"yasr-guten-block-panel"},R)))}return t=/^\d+$/.test(n),"--"!==a&&(s=' size="'+a+'"'),"--"!==n&&!0===t&&(u=' postid="'+n+'"'),React.createElement(c,null,React.createElement(_,null),React.createElement("div",{className:e.className},"[yasr_visitor_votes",s,u,"]",l&&React.createElement(b,null)))},save:function(e){var t=e.attributes,r=t.size,a=t.postId,n="",o=a;return r&&(n+='size="'+r+'"'),a&&("--"===a&&(o=wp.data.select("core/editor").getCurrentPostId()),n+=' postid="'+o+'"'),React.createElement("div",null,"[yasr_visitor_votes ",n,"]")}}),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-overall-rating"),wp.data.dispatch("core/edit-post").hideBlockTypes("yet-another-stars-rating/yasr-visitor-votes")})(),(()=>{"use strict";var e=r(534);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function i(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=y(e);if(t){var n=y(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return c(this,r)}}function c(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}var p=wp.i18n.__,m=wp.plugins.registerPlugin,d=wp.editPost,f=d.PluginSidebar,g=d.PluginSidebarMoreMenuItem,h=wp.components.PanelBody,v=wp.element.Fragment,b=function(){return React.createElement("div",null)},R=function(e){l(r,React.Component);var t=i(r);function r(e){var n;a(this,r),n=t.call(this,e);var o=!1;return"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(o=!0),n.state={postExcluded:o},n.yasrUpdatePostMetaAutoInsert=n.yasrUpdatePostMetaAutoInsert.bind(u(n)),n}return o(r,[{key:"yasrUpdatePostMetaAutoInsert",value:function(e){var t=e.target,r="checkbox"===t.type?t.checked:t.value;this.setState({postExcluded:r}),!0===r?wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"yes"}}):wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"no"}})}},{key:"render",value:function(){return React.createElement("div",{className:"yasr-guten-block-panel-center"},React.createElement("hr",null),React.createElement("label",null,React.createElement("span",null,p("Disable auto insert for this post or page?","yet-another-stars-rating"))),React.createElement("div",{className:"yasr-onoffswitch-big yasr-onoffswitch-big-center",id:"yasr-switcher-disable-auto-insert"},React.createElement("input",{type:"checkbox",name:"yasr_auto_insert_disabled",className:"yasr-onoffswitch-checkbox",value:"yes",id:"yasr-auto-insert-disabled-switch",defaultChecked:this.state.postExcluded,onChange:this.yasrUpdatePostMetaAutoInsert}),React.createElement("label",{className:"yasr-onoffswitch-label",htmlFor:"yasr-auto-insert-disabled-switch"},React.createElement("span",{className:"yasr-onoffswitch-inner"}),React.createElement("span",{className:"yasr-onoffswitch-switch"}))))}}]),r}(),E=function(t){l(n,React.Component);var r=i(n);function n(e){var t;a(this,n),t=r.call(this,e);var o=!1;return"disabled"!==yasrConstantGutenberg.autoInsert&&(o=!0),t.state={yasrAutoInsertEnabled:o},t}return o(n,[{key:"render",value:function(){var t=[React.createElement(b,{key:0})];return wp.hooks.doAction("yasr_below_panel",t),React.createElement(v,null,React.createElement(g,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},p("YASR post settings","yet-another-stars-rating")),React.createElement(f,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(h,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(e.YasrDivRatingOverall,null),React.createElement("div",null,p('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating")),this.state.yasrAutoInsertEnabled&&React.createElement(R,null),t))))}}]),n}();m("yasr-sidebar",{icon:"star-half",title:p("Yasr: Settings","yet-another-stars-rating"),render:E})})()})();
|
admin/js/src/guten/blocks/yasrGutenUtils.js
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
//setting costants
|
2 |
-
import {yasrSetRaterValue} from "../../../../../includes/js/src/modules/yasrSetRaterValue";
|
3 |
-
|
4 |
const { __ } = wp.i18n; // Import __() from wp.i18n
|
5 |
const {PanelBody} = wp.components;
|
6 |
const {InspectorControls} = wp.blockEditor;
|
1 |
//setting costants
|
|
|
|
|
2 |
const { __ } = wp.i18n; // Import __() from wp.i18n
|
3 |
const {PanelBody} = wp.components;
|
4 |
const {InspectorControls} = wp.blockEditor;
|
admin/js/src/yasr-editor-screen.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import {copyToClipboard} from "./yasr-admin-functions";
|
2 |
-
import {yasrSetRaterValue} from "../../../includes/js/src/modules/yasrSetRaterValue";
|
3 |
import {v4 as uuidv4} from 'uuid';
|
4 |
|
5 |
|
@@ -223,7 +222,6 @@ function yasrAdminMultiSet() {
|
|
223 |
const reviewsEnabled = document.getElementById('yasr-pro-comments-enabled-yes');
|
224 |
const multiSetinReview = document.getElementById('yasr-pro-multiset-review-switcher');
|
225 |
|
226 |
-
|
227 |
yasrPrintAdminMultiSet(setId, postId, nMultiSet);
|
228 |
|
229 |
copyRoMultiset.onclick = function (event) {
|
@@ -266,7 +264,6 @@ function yasrAdminMultiSet() {
|
|
266 |
|
267 |
//when multiset switcher is enabled, enable also reviews in comment switcher
|
268 |
multiSetinReview.addEventListener('change', (event) => {
|
269 |
-
console.log(event.currentTarget);
|
270 |
if (event.currentTarget.checked === true) {
|
271 |
//if it is classic editor, check reviewsEnabled on true
|
272 |
if(reviewsEnabled !== null) {
|
@@ -344,7 +341,8 @@ function yasrPrintAdminMultiSet(setId, postid, nMultiSet) {
|
|
344 |
yasrReturnTableMultiset(yasrMultiSetValue, tableAuthorVisitor, false);
|
345 |
|
346 |
//Set rater for divs
|
347 |
-
yasrSetRaterAdminMulti(
|
|
|
348 |
|
349 |
let spanWithSetID = document.getElementsByClassName('yasr-editor-multiset-id');
|
350 |
|
@@ -367,6 +365,7 @@ function yasrPrintAdminMultiSet(setId, postid, nMultiSet) {
|
|
367 |
function yasrReturnTableMultiset (yasrMultiSetValue, table, authorMultiset=true) {
|
368 |
|
369 |
let content = '';
|
|
|
370 |
|
371 |
for (let i = 0; i < yasrMultiSetValue.length; i++) {
|
372 |
let valueName = yasrMultiSetValue[i]['name'];
|
@@ -376,13 +375,14 @@ function yasrReturnTableMultiset (yasrMultiSetValue, table, authorMultiset=true)
|
|
376 |
if(authorMultiset !== false) {
|
377 |
valueRating = yasrMultiSetValue[i]['average_rating'];
|
378 |
readonly = false;
|
|
|
379 |
}
|
380 |
|
381 |
let valueID = yasrMultiSetValue[i]['id'];
|
382 |
|
383 |
content += '<tr>';
|
384 |
content += '<td>' + valueName + '</td>';
|
385 |
-
content += '<td><div class=
|
386 |
+ valueRating + '" data-multi-idfield="' + valueID + '" data-readonly="'+ readonly +'"></div>';
|
387 |
content += '</td>';
|
388 |
content += '</tr>';
|
@@ -397,9 +397,20 @@ function yasrReturnTableMultiset (yasrMultiSetValue, table, authorMultiset=true)
|
|
397 |
|
398 |
}
|
399 |
|
400 |
-
|
401 |
-
|
402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
|
404 |
//an array with all the ratings objects
|
405 |
let ratingArray = [];
|
1 |
import {copyToClipboard} from "./yasr-admin-functions";
|
|
|
2 |
import {v4 as uuidv4} from 'uuid';
|
3 |
|
4 |
|
222 |
const reviewsEnabled = document.getElementById('yasr-pro-comments-enabled-yes');
|
223 |
const multiSetinReview = document.getElementById('yasr-pro-multiset-review-switcher');
|
224 |
|
|
|
225 |
yasrPrintAdminMultiSet(setId, postId, nMultiSet);
|
226 |
|
227 |
copyRoMultiset.onclick = function (event) {
|
264 |
|
265 |
//when multiset switcher is enabled, enable also reviews in comment switcher
|
266 |
multiSetinReview.addEventListener('change', (event) => {
|
|
|
267 |
if (event.currentTarget.checked === true) {
|
268 |
//if it is classic editor, check reviewsEnabled on true
|
269 |
if(reviewsEnabled !== null) {
|
341 |
yasrReturnTableMultiset(yasrMultiSetValue, tableAuthorVisitor, false);
|
342 |
|
343 |
//Set rater for divs
|
344 |
+
yasrSetRaterAdminMulti();
|
345 |
+
yasrSetRaterAdminMulti(false);
|
346 |
|
347 |
let spanWithSetID = document.getElementsByClassName('yasr-editor-multiset-id');
|
348 |
|
365 |
function yasrReturnTableMultiset (yasrMultiSetValue, table, authorMultiset=true) {
|
366 |
|
367 |
let content = '';
|
368 |
+
let divClass = 'yasr-multiset-admin'
|
369 |
|
370 |
for (let i = 0; i < yasrMultiSetValue.length; i++) {
|
371 |
let valueName = yasrMultiSetValue[i]['name'];
|
375 |
if(authorMultiset !== false) {
|
376 |
valueRating = yasrMultiSetValue[i]['average_rating'];
|
377 |
readonly = false;
|
378 |
+
divClass = 'yasr-multiset-admin-author'
|
379 |
}
|
380 |
|
381 |
let valueID = yasrMultiSetValue[i]['id'];
|
382 |
|
383 |
content += '<tr>';
|
384 |
content += '<td>' + valueName + '</td>';
|
385 |
+
content += '<td><div class='+divClass+' id="yasr-multiset-admin-' + uuidv4() + '" data-rating="'
|
386 |
+ valueRating + '" data-multi-idfield="' + valueID + '" data-readonly="'+ readonly +'"></div>';
|
387 |
content += '</td>';
|
388 |
content += '</tr>';
|
397 |
|
398 |
}
|
399 |
|
400 |
+
/**
|
401 |
+
*
|
402 |
+
* @param authorMultiset
|
403 |
+
*/
|
404 |
+
function yasrSetRaterAdminMulti(authorMultiset=true) {
|
405 |
+
|
406 |
+
let divClass;
|
407 |
+
if(authorMultiset !== false) {
|
408 |
+
divClass = 'yasr-multiset-admin-author';
|
409 |
+
} else {
|
410 |
+
divClass = 'yasr-multiset-admin';
|
411 |
+
}
|
412 |
+
|
413 |
+
const yasrMultiSetAdmin = document.getElementsByClassName(divClass);
|
414 |
|
415 |
//an array with all the ratings objects
|
416 |
let ratingArray = [];
|
admin/js/yasr-editor-screen.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";const e=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)};function t(e,t,n=!1,o=.1,a=!0,i=!1,s=!1){let r;r=n||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:r,step:o,readOnly:a,rating:i,rateCallback:s})}var n;tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var o=new Uint8Array(16);function a(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}const i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&i.test(e)};for(var r=[],l=0;l<256;++l)r.push((l+256).toString(16).substr(1));const d=function(e,t,n){var o=(e=e||{}).random||(e.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=o[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n}(o)};function y(e){"Product"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"LocalBusiness"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Recipe"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"SoftwareApplication"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Book"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Movie"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none"):document.getElementById("yasr-metabox-info-snippet-container").style.display="none"}function c(e,n,o){const a={action:"yasr_send_id_nameset",set_id:e,post_id:n};return jQuery.post(ajaxurl,a,(function(n){o>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");let a=JSON.parse(n),i=document.getElementById("yasr-table-multi-set-admin"),s=document.getElementById("yasr-table-multi-set-admin-visitor");m(a,i),m(a,s,!1),function(){let e=document.getElementsByClassName("yasr-multiset-admin"),n=[],o=!1;for(let a=0;a<e.length;a++)!function(a){let i=e.item(a).id,s=document.getElementById(i),r=parseInt(s.getAttribute("data-multi-idfield")),l=parseInt(s.getAttribute("data-rating")),d="true"===s.getAttribute("data-readonly"),y={field:r,rating:l};n.push(y),t(32,i,!1,.5,d,!1,(function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);for(let t=0;t<n.length;t++)n[t].field===r&&(n[t].rating=e);o=JSON.stringify(n),document.getElementById("yasr-multiset-author-votes").value=o,t()}))}(a)}();let r=document.getElementsByClassName("yasr-editor-multiset-id");for(let t=0;t<r.length;t++)r[t].innerText=e})),!1}function m(e,t,n=!0){let o="";for(let t=0;t<e.length;t++){let a=e[t].name,i=0,s=!0;!1!==n&&(i=e[t].average_rating,s=!1);let r=e[t].id;o+="<tr>",o+="<td>"+a+"</td>",o+='<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-'+d()+'" data-rating="'+i+'" data-multi-idfield="'+r+'" data-readonly="'+s+'"></div>',o+="</td>",o+="</tr>"}!1===n&&(o+='<tr><td colspan="2"><input type="submit" class="button button-primary" value="Submit!" disabled></td></tr>'),t.innerHTML=o}document.addEventListener("DOMContentLoaded",(function(t){var n;!0!==document.body.classList.contains("block-editor-page")&&(function(){let t=parseFloat(document.getElementById("yasr-overall-rating-value").value);const n=document.getElementById("yasr-editor-copy-overall");null!==n&&(n.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())}),raterJs({starSize:32,step:.1,showToolTip:!1,rating:t,readOnly:!1,element:document.getElementById("yasr-rater-overall"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),document.getElementById("yasr-overall-rating-value").value=e,this.setRating(e);document.getElementById("yasr_overall_text").textContent="You've rated "+e,t()}})}(),n={action:"yasr_create_shortcode"},jQuery.get(ajaxurl,n,(function(e){jQuery(e).appendTo("body").hide(),function(){let e=!1;null!==document.getElementById("yasr-editor-multiset-container")&&(e=!0);const t=document.getElementById("yasr-tinypopup-link-doc");jQuery("#yasr-link-tab-main").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-main").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-main").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-link-tab-charts").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-charts").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-charts").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-rankings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-overall").on("click",(function(){jQuery("#yasr-overall-choose-size").toggle("slow")})),jQuery("#yasr-visitor-votes").on("click",(function(){jQuery("#yasr-visitor-choose-size").toggle("slow")})),jQuery(".yasr-tinymce-shortcode-buttons").on("click",(function(){let e=this.getAttribute("data-shortcode");null==tinyMCE.activeEditor?jQuery("#content").append(e):tinyMCE.activeEditor.execCommand("mceInsertContent",0,e),tb_remove()})),!0===e&&jQuery("#yasr-insert-multiset-select").on("change",(function(){var e=jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();let t;t=jQuery("#yasr-allow-vote-multiset").is(":checked")?"[yasr_multiset setid=":"[yasr_visitor_multiset setid=",t+=e,jQuery("#yasr-hide-average-multiset").is(":checked")&&(t+=" show_average='no'"),t+="]",null==tinyMCE.activeEditor?jQuery("#content").append(t):tinyMCE.activeEditor.execCommand("mceInsertContent",0,t),tb_remove()}))}()}))),function(){jQuery("#yasr-metabox-below-editor-structured-data-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-structured-data-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-structured-data").show()})),jQuery("#yasr-metabox-below-editor-multiset-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-multiset-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-multiset").show()}));let t=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let t=document.getElementById("yasr-editor-multiset-container"),n=parseInt(t.getAttribute("data-nmultiset")),o=parseInt(t.getAttribute("data-setid")),a=parseInt(t.getAttribute("data-postid"));const i=document.getElementById("yasr-pro-review-setid"),s=document.getElementById("yasr-editor-copy-readonly-multiset"),r=document.getElementById("yasr-editor-copy-visitor-multiset"),l=document.getElementById("yasr-editor-copy-average-multiset"),d=document.getElementById("yasr-editor-copy-average-vvmultiset"),y=document.getElementById("yasr-editor-copy-comments-multiset"),m=document.getElementById("yasr-pro-comments-enabled-yes"),u=document.getElementById("yasr-pro-multiset-review-switcher");c(o,a,n),s.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},r.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},l.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},d.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},y.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},null!==u&&(null!==m&&m.addEventListener("change",(e=>{e.currentTarget.checked||(u.checked=!1)})),u.addEventListener("change",(e=>{console.log(e.currentTarget),!0===e.currentTarget.checked?(null!==m?m.checked=!0:document.getElementById("yasr-comment-reviews-disabled-switch").checked=!0,null!==i&&(i.value=o)):null!==i&&(i.value="")}))),n>1&&jQuery("#yasr_select_set").on("change",(function(){return o=jQuery("#yasr_select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),c(o,a,n),document.getElementById("yasr-multiset-id").value=o,null!==i&&""!==i&&(i.value===o?u.checked=!0:u.checked=!1),!1}))}(),y(t)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){y(this.value)}))})();
|
1 |
+
(()=>{"use strict";var e={607:(e,t,n)=>{n.d(t,{v:()=>o});const o=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)};tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"})}},t={};function n(o){var a=t[o];if(void 0!==a)return a.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e,t=n(607),o=new Uint8Array(16);function a(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}const i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&i.test(e)};for(var r=[],l=0;l<256;++l)r.push((l+256).toString(16).substr(1));const d=function(e,t,n){var o=(e=e||{}).random||(e.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=o[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n}(o)};function y(e){"Product"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"LocalBusiness"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Recipe"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"SoftwareApplication"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Book"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Movie"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none"):document.getElementById("yasr-metabox-info-snippet-container").style.display="none"}function c(e,t,n){const o={action:"yasr_send_id_nameset",set_id:e,post_id:t};return jQuery.post(ajaxurl,o,(function(t){n>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");let o=JSON.parse(t),a=document.getElementById("yasr-table-multi-set-admin"),i=document.getElementById("yasr-table-multi-set-admin-visitor");m(o,a),m(o,i,!1),u(),u(!1);let s=document.getElementsByClassName("yasr-editor-multiset-id");for(let t=0;t<s.length;t++)s[t].innerText=e})),!1}function m(e,t,n=!0){let o="",a="yasr-multiset-admin";for(let t=0;t<e.length;t++){let i=e[t].name,s=0,r=!0;!1!==n&&(s=e[t].average_rating,r=!1,a="yasr-multiset-admin-author");let l=e[t].id;o+="<tr>",o+="<td>"+i+"</td>",o+="<td><div class="+a+' id="yasr-multiset-admin-'+d()+'" data-rating="'+s+'" data-multi-idfield="'+l+'" data-readonly="'+r+'"></div>',o+="</td>",o+="</tr>"}!1===n&&(o+='<tr><td colspan="2"><input type="submit" class="button button-primary" value="Submit!" disabled></td></tr>'),t.innerHTML=o}function u(e=!0){let t;t=!1!==e?"yasr-multiset-admin-author":"yasr-multiset-admin";const n=document.getElementsByClassName(t);let o=[],a=!1;for(let e=0;e<n.length;e++)!function(e){let t=n.item(e).id,i=document.getElementById(t),s=parseInt(i.getAttribute("data-multi-idfield")),r=parseInt(i.getAttribute("data-rating")),l="true"===i.getAttribute("data-readonly"),d={field:s,rating:r};o.push(d),yasrSetRaterValue(32,t,!1,.5,l,!1,(function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);for(let t=0;t<o.length;t++)o[t].field===s&&(o[t].rating=e);a=JSON.stringify(o),document.getElementById("yasr-multiset-author-votes").value=a,t()}))}(e)}document.addEventListener("DOMContentLoaded",(function(e){var n;!0!==document.body.classList.contains("block-editor-page")&&(function(){let e=parseFloat(document.getElementById("yasr-overall-rating-value").value);const n=document.getElementById("yasr-editor-copy-overall");null!==n&&(n.onclick=function(e){let n=document.getElementById(e.target.id);(0,t.v)(n.textContent.trim())}),raterJs({starSize:32,step:.1,showToolTip:!1,rating:e,readOnly:!1,element:document.getElementById("yasr-rater-overall"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),document.getElementById("yasr-overall-rating-value").value=e,this.setRating(e);document.getElementById("yasr_overall_text").textContent="You've rated "+e,t()}})}(),n={action:"yasr_create_shortcode"},jQuery.get(ajaxurl,n,(function(e){jQuery(e).appendTo("body").hide(),function(){let e=!1;null!==document.getElementById("yasr-editor-multiset-container")&&(e=!0);const t=document.getElementById("yasr-tinypopup-link-doc");jQuery("#yasr-link-tab-main").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-main").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-main").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-link-tab-charts").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-charts").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-charts").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-rankings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-overall").on("click",(function(){jQuery("#yasr-overall-choose-size").toggle("slow")})),jQuery("#yasr-visitor-votes").on("click",(function(){jQuery("#yasr-visitor-choose-size").toggle("slow")})),jQuery(".yasr-tinymce-shortcode-buttons").on("click",(function(){let e=this.getAttribute("data-shortcode");null==tinyMCE.activeEditor?jQuery("#content").append(e):tinyMCE.activeEditor.execCommand("mceInsertContent",0,e),tb_remove()})),!0===e&&jQuery("#yasr-insert-multiset-select").on("change",(function(){var e=jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();let t;t=jQuery("#yasr-allow-vote-multiset").is(":checked")?"[yasr_multiset setid=":"[yasr_visitor_multiset setid=",t+=e,jQuery("#yasr-hide-average-multiset").is(":checked")&&(t+=" show_average='no'"),t+="]",null==tinyMCE.activeEditor?jQuery("#content").append(t):tinyMCE.activeEditor.execCommand("mceInsertContent",0,t),tb_remove()}))}()}))),function(){jQuery("#yasr-metabox-below-editor-structured-data-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-structured-data-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-structured-data").show()})),jQuery("#yasr-metabox-below-editor-multiset-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-multiset-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-multiset").show()}));let e=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let e=document.getElementById("yasr-editor-multiset-container"),n=parseInt(e.getAttribute("data-nmultiset")),o=parseInt(e.getAttribute("data-setid")),a=parseInt(e.getAttribute("data-postid"));const i=document.getElementById("yasr-pro-review-setid"),s=document.getElementById("yasr-editor-copy-readonly-multiset"),r=document.getElementById("yasr-editor-copy-visitor-multiset"),l=document.getElementById("yasr-editor-copy-average-multiset"),d=document.getElementById("yasr-editor-copy-average-vvmultiset"),y=document.getElementById("yasr-editor-copy-comments-multiset"),m=document.getElementById("yasr-pro-comments-enabled-yes"),u=document.getElementById("yasr-pro-multiset-review-switcher");c(o,a,n),s.onclick=function(e){let n=document.getElementById(e.target.id);(0,t.v)(n.textContent.trim())},r.onclick=function(e){let n=document.getElementById(e.target.id);(0,t.v)(n.textContent.trim())},l.onclick=function(e){let n=document.getElementById(e.target.id);(0,t.v)(n.textContent.trim())},d.onclick=function(e){let n=document.getElementById(e.target.id);(0,t.v)(n.textContent.trim())},y.onclick=function(e){let n=document.getElementById(e.target.id);(0,t.v)(n.textContent.trim())},null!==u&&(null!==m&&m.addEventListener("change",(e=>{e.currentTarget.checked||(u.checked=!1)})),u.addEventListener("change",(e=>{!0===e.currentTarget.checked?(null!==m?m.checked=!0:document.getElementById("yasr-comment-reviews-disabled-switch").checked=!0,null!==i&&(i.value=o)):null!==i&&(i.value="")}))),n>1&&jQuery("#yasr_select_set").on("change",(function(){return o=jQuery("#yasr_select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),c(o,a,n),document.getElementById("yasr-multiset-id").value=o,null!==i&&""!==i&&(i.value===o?u.checked=!0:u.checked=!1),!1}))}(),y(e)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){y(this.value)}))})()})();
|
admin/js/yasr-settings.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{var e;if(document.getElementsByClassName("nav-tab-active").length>0&&(e=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===e){var t=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===t&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-rating-saved").value="Rating saved!",document.getElementById("yasr-settings-custom-text-rating-updated").value="Rating updated!",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===e&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===e){var n=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===n){var r=jQuery("#yasr-edit-form-number-elements").attr("value");r++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(r>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+r+' <input type="text" name="edit-multi-set-element-'+r+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),r++}))}else n>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"migration_tools"===e&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===e&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";let e;var t,a=new Uint8Array(16);function n(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(a)}const r=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&r.test(e)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(e,t,a){var r=(e=e||{}).random||(e.rng||n)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){a=a||0;for(var i=0;i<16;++i)t[a+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function c(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function y(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}var p=wp.i18n.__,g=wp.element.render;function h(e){var t="yasr-ranking-element-"+l(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return function(e,t){var a,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:a,step:n,readOnly:r,rating:s,rateCallback:o})}(a,t,!1,.1,!0,e.rating)}})}function f(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",e.post.number_of_votes," ",p("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function v(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===e&&(e=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),e.innerHTML=t;const a=e.textContent;return e.innerHTML="",a}(t.post.title)))}function _(e){var t="after",a=p("Rating:","yet-another-stars-rating"),n=new URLSearchParams(e.rankingParams);return null!==n.get("text_position")&&(t=n.get("text_position")),null!==n.get("custom_txt")&&(a=n.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(f,{post:e.post,tableId:e.tableId,text:a}),React.createElement(h,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(h,{rating:e.post.rating,tableId:e.tableId}),React.createElement(f,{post:e.post,tableId:e.tableId,text:a}))}function b(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(v,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function E(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var n="yasr-rankings-td-colored";return"author_ranking"===e.source&&(n="yasr-rankings-td-white"),a%2==0&&(n="yasr-rankings-td-white","author_ranking"===e.source&&(n="yasr-rankings-td-colored")),React.createElement(b,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:n})})))}var k=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(o,React.Component);var t,a,n,r,s=(n=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=m(n);if(r){var a=m(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return y(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(p("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:t});else if(this.state.source){var n=this.returnRestUrl();Promise.all(n.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info(p("Ajax Call Failed. Getting data from source")),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(p(e))}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(p(t)),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:p("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,n="&nonce_rankings="+this.state.nonce,r="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);null!==s.get("order_by")&&(r+="order_by="+s.get("order_by")),null!==s.get("limit")&&(r+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(r+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(r+="&end_date="+s.get("end_date")),null!==s.get("ctg")?r+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(r+="&cpt="+s.get("cpt")),""!==r&&(r="&"+(r=r.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(r+="&setid="+s.get("setid"))}else r="";if("author_ranking"===a||"author_multi"===a)e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+r+n];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+r+o+n,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+r+i+n]}return e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:n},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:r},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.target.id,a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),t===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var e=this.state,t=e.data,a=e.source,n=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:n,show:"table-row-group",source:a});var r=t.most,s=t.highest,o="table-row-group",i="none",l="most",d=o,c=i,u=new URLSearchParams(n);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:r,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:n,show:d,source:a}),React.createElement(E,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:n,show:c,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}],a&&c(t.prototype,a),Object.defineProperty(t,"prototype",{writable:!1}),o}();function w(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,n=JSON.parse(e.item(t).dataset.rankingSource),r=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);g(React.createElement(k,{source:n,tableId:a,params:r,nonce:s}),o)}}w(),tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var I,B=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(I=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===I){var R,j=function(e){var t=D.value,a=document.getElementById("yasr-builder-shortcode").textContent,n=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];n=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",n),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+t+"&full_shortcode="+a).then((function(e){return!0===e.ok?e.json():(console.info(B("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(e){console.info(e)})).then((function(e){if("KO"!==e){var t=document.createElement("div");t.innerHTML=e,M.childNodes.length>0?M.replaceChild(t,M.childNodes[0]):M.appendChild(t)}})).then((function(e){n.forEach((function(e){t===e&&w()}))}))},x=function(e,t,a,n,r,s,o,i,l){e.style.display="",t.style.display="",s.style.display="",l.style.display="",a.style.display="none",n.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},C=function(e,t,a,n,r,s,o,i,l){a.style.display="",n.style.display="",t.style.display="",s.style.display="",l.style.display="",e.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},Q=function(e,t,a,n,r,s,o,i,l){r.style.display="",l.style.display="none",e.style.display="none",a.style.display="none",n.style.display="none",t.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},T=function(e,t,a,n,r,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(F.className="",F.classList.add("yasr-settings-row-24"),a.style.display="",n.style.display="",e.style.display="none"):(a.style.display="none",n.style.display="none",e.style.display=""),s.style.display="",t.style.display="",d.style.display="",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},L=".yasr-builder-elements-parents",S=".yasr-builder-elements-childs";jQuery(L).prop("disabled",!0),jQuery(S).prop("disabled",!0),jQuery(L).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",L,S);var P=[],O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};R=O.name,document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]");var N=document.getElementById("yasr-builder-button-preview"),H=document.getElementById("yasr-builder-copy-shortcode"),M=document.getElementById("yasr-builder-preview"),D=document.getElementById("yasr-ranking-source"),A=document.getElementById("yasr-ranking-multiset-select"),U=document.getElementById("yasr-builder-datepicker-start"),q=document.getElementById("yasr-builder-datepicker-end"),F=document.getElementById("yasr-builder-params-container"),z=document.getElementById("builder-vv-default-view"),J=document.getElementById("builder-vv-required-votes"),V=document.getElementById("builder-stars-size"),K=document.getElementById("builder-overall-text"),Y=document.getElementById("builder-username-options"),G=document.getElementById("builder-category"),$=document.getElementById("builder-cpt"),W=document.getElementById("yasr-ranking-multiset"),X=document.getElementById("yasr-builder-datepicker"),Z=D.value,ee=!1;U.value="",q.value="","yasr_ov_ranking"===Z?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===Z||"yasr_top_reviewers"===Z?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===Z?T(K,V,z,J,Y,G,$,W,!1,X):"yasr_visitor_multi_set_ranking"===Z?T(K,V,z,J,Y,G,$,W,!0,X):C(K,V,z,J,Y,G,$,W,X),document.addEventListener("change",(function(e){if("yasr-ranking-source"===e.target.id)F.className="",F.classList.add("yasr-settings-row-33"),M.innerHTML="",U.value="",q.value="",O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===e.target.value?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===e.target.value||"yasr_top_reviewers"===e.target.value?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===e.target.value?(T(K,V,z,J,Y,G,$,W,!1,X),O.setid=" setid="+A[0].value):"yasr_visitor_multi_set_ranking"===e.target.value?(T(K,V,z,J,Y,G,$,W,!0,X),O.setid=" setid="+A[0].value):C(K,V,z,J,Y,G,$,W,X),O.name=e.target.value,R=O.name+O.setid;else{"yasr-ranking-multiset-select"===e.target.id&&(O.setid=" setid="+e.target.value),P=wp.hooks.applyFilters("yasrBuilderFilterShortcode",O);for(var t=2;O.length;t++)P.hasOwnProperty(O[t])&&(O[t]=P[t]);R=O.name+O.setid+O.rows+O.view+O.minvotesmost+O.minvoteshg+O.size+O.txtPosition+O.txt+O.display+O.start_date+O.end_date+O.category+O.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]"),!0===ee&&"yasr-ranking-source"!==e.target.id&&"yasr-builder-category-radio"!==e.target.name&&j()})),H.onclick=function(e){var t,a;t=document.getElementById(e.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=t,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},N.onclick=function(e){j(),ee=!0}}})();
|
1 |
+
(()=>{var e;if(document.getElementsByClassName("nav-tab-active").length>0&&(e=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===e){var t=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===t&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-rating-saved").value="Rating saved!",document.getElementById("yasr-settings-custom-text-rating-updated").value="Rating updated!",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===e&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===e){var r=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===r){var n=jQuery("#yasr-edit-form-number-elements").attr("value");n++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(n>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+n+' <input type="text" name="edit-multi-set-element-'+n+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),n++}))}else r>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"migration_tools"===e&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===e&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";let e;var t,a=new Uint8Array(16);function r(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(a)}const n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&n.test(e)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(e,t,a){var n=(e=e||{}).random||(e.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){a=a||0;for(var i=0;i<16;++i)t[a+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(n)};function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function c(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function y(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}var p=wp.i18n.__,g=wp.element.render;function h(e){var t="yasr-ranking-element-"+l(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return yasrSetRaterValue(a,t,!1,.1,!0,e.rating)}})}function f(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",e.post.number_of_votes," ",p("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function v(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===e&&(e=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),e.innerHTML=t;const a=e.textContent;return e.innerHTML="",a}(t.post.title)))}function _(e){var t="after",a=p("Rating:","yet-another-stars-rating"),r=new URLSearchParams(e.rankingParams);return null!==r.get("text_position")&&(t=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(f,{post:e.post,tableId:e.tableId,text:a}),React.createElement(h,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(h,{rating:e.post.rating,tableId:e.tableId}),React.createElement(f,{post:e.post,tableId:e.tableId,text:a}))}function b(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(v,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function E(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var r="yasr-rankings-td-colored";return"author_ranking"===e.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===e.source&&(r="yasr-rankings-td-colored")),React.createElement(b,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:r})})))}var k=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(o,React.Component);var t,a,r,n,s=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=m(r);if(n){var a=m(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return y(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:t});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(e)}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(t),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:r},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:n},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),t===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var e=this.state,t=e.data,a=e.source,r=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=t.most,s=t.highest,o="table-row-group",i="none",l="most",d=o,c=i,u=new URLSearchParams(r);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:d,source:a}),React.createElement(E,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}],a&&c(t.prototype,a),Object.defineProperty(t,"prototype",{writable:!1}),o}();function w(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,r=JSON.parse(e.item(t).dataset.rankingSource),n=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);g(React.createElement(k,{source:r,tableId:a,params:n,nonce:s}),o)}}w(),tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var I,B=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(I=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===I){var R,j=function(e){var t=D.value,a=document.getElementById("yasr-builder-shortcode").textContent,r=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];r=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",r),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+t+"&full_shortcode="+a).then((function(e){return!0===e.ok?e.json():(console.info(B("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(e){console.info(e)})).then((function(e){if("KO"!==e){var t=document.createElement("div");t.innerHTML=e,M.childNodes.length>0?M.replaceChild(t,M.childNodes[0]):M.appendChild(t)}})).then((function(e){r.forEach((function(e){t===e&&w()}))}))},x=function(e,t,a,r,n,s,o,i,l){e.style.display="",t.style.display="",s.style.display="",l.style.display="",a.style.display="none",r.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},C=function(e,t,a,r,n,s,o,i,l){a.style.display="",r.style.display="",t.style.display="",s.style.display="",l.style.display="",e.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},Q=function(e,t,a,r,n,s,o,i,l){n.style.display="",l.style.display="none",e.style.display="none",a.style.display="none",r.style.display="none",t.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},L=function(e,t,a,r,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(F.className="",F.classList.add("yasr-settings-row-24"),a.style.display="",r.style.display="",e.style.display="none"):(a.style.display="none",r.style.display="none",e.style.display=""),s.style.display="",t.style.display="",d.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},T=".yasr-builder-elements-parents",S=".yasr-builder-elements-childs";jQuery(T).prop("disabled",!0),jQuery(S).prop("disabled",!0),jQuery(T).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",T,S);var P=[],O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};R=O.name,document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]");var N=document.getElementById("yasr-builder-button-preview"),H=document.getElementById("yasr-builder-copy-shortcode"),M=document.getElementById("yasr-builder-preview"),D=document.getElementById("yasr-ranking-source"),A=document.getElementById("yasr-ranking-multiset-select"),U=document.getElementById("yasr-builder-datepicker-start"),q=document.getElementById("yasr-builder-datepicker-end"),F=document.getElementById("yasr-builder-params-container"),z=document.getElementById("builder-vv-default-view"),V=document.getElementById("builder-vv-required-votes"),J=document.getElementById("builder-stars-size"),K=document.getElementById("builder-overall-text"),Y=document.getElementById("builder-username-options"),G=document.getElementById("builder-category"),$=document.getElementById("builder-cpt"),W=document.getElementById("yasr-ranking-multiset"),X=document.getElementById("yasr-builder-datepicker"),Z=D.value,ee=!1;U.value="",q.value="","yasr_ov_ranking"===Z?x(K,J,z,V,Y,G,$,W,X):"yasr_most_active_users"===Z||"yasr_top_reviewers"===Z?Q(K,J,z,V,Y,G,$,W,X):"yasr_multi_set_ranking"===Z?L(K,J,z,V,Y,G,$,W,!1,X):"yasr_visitor_multi_set_ranking"===Z?L(K,J,z,V,Y,G,$,W,!0,X):C(K,J,z,V,Y,G,$,W,X),document.addEventListener("change",(function(e){if("yasr-ranking-source"===e.target.id)F.className="",F.classList.add("yasr-settings-row-33"),M.innerHTML="",U.value="",q.value="",O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===e.target.value?x(K,J,z,V,Y,G,$,W,X):"yasr_most_active_users"===e.target.value||"yasr_top_reviewers"===e.target.value?Q(K,J,z,V,Y,G,$,W,X):"yasr_multi_set_ranking"===e.target.value?(L(K,J,z,V,Y,G,$,W,!1,X),O.setid=" setid="+A[0].value):"yasr_visitor_multi_set_ranking"===e.target.value?(L(K,J,z,V,Y,G,$,W,!0,X),O.setid=" setid="+A[0].value):C(K,J,z,V,Y,G,$,W,X),O.name=e.target.value,R=O.name+O.setid;else{"yasr-ranking-multiset-select"===e.target.id&&(O.setid=" setid="+e.target.value),P=wp.hooks.applyFilters("yasrBuilderFilterShortcode",O);for(var t=2;O.length;t++)P.hasOwnProperty(O[t])&&(O[t]=P[t]);R=O.name+O.setid+O.rows+O.view+O.minvotesmost+O.minvoteshg+O.size+O.txtPosition+O.txt+O.display+O.start_date+O.end_date+O.category+O.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]"),!0===ee&&"yasr-ranking-source"!==e.target.id&&"yasr-builder-category-radio"!==e.target.name&&j()})),H.onclick=function(e){var t,a;t=document.getElementById(e.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=t,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},N.onclick=function(e){j(),ee=!0}}})();
|
admin/settings/aspect_style/yasr-settings-style-actions.php
CHANGED
@@ -83,9 +83,10 @@ function yasr_style_options_choose_stars_lite_callback($style_options) {
|
|
83 |
</span>
|
84 |
</label>
|
85 |
</div>
|
86 |
-
|
87 |
</div>
|
88 |
|
|
|
|
|
89 |
<div id="yasr-settings-stylish-stars" style="margin-top: 30px">
|
90 |
<div id="yasr-settings-stylish-image-container">
|
91 |
<?php
|
83 |
</span>
|
84 |
</label>
|
85 |
</div>
|
|
|
86 |
</div>
|
87 |
|
88 |
+
<hr />
|
89 |
+
|
90 |
<div id="yasr-settings-stylish-stars" style="margin-top: 30px">
|
91 |
<div id="yasr-settings-stylish-image-container">
|
92 |
<?php
|
admin/settings/aspect_style/yasr-settings-style-functions.php
CHANGED
@@ -34,13 +34,7 @@ function yasr_style_options_init() {
|
|
34 |
'yasr_style_options_sanitize'
|
35 |
);
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
if (!$style_options || !isset($style_options['scheme_color_multiset']) || !isset($style_options['textarea'])) {
|
40 |
-
$style_options = array();
|
41 |
-
$style_options['scheme_color_multiset'] = 'light';
|
42 |
-
$style_options['textarea'] = null;
|
43 |
-
}
|
44 |
|
45 |
//filter $style_options
|
46 |
$style_options = apply_filters('yasr_filter_style_options', $style_options);
|
34 |
'yasr_style_options_sanitize'
|
35 |
);
|
36 |
|
37 |
+
$style_options = json_decode(YASR_STYLE_OPTIONS, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
//filter $style_options
|
40 |
$style_options = apply_filters('yasr_filter_style_options', $style_options);
|
admin/settings/classes/YasrSettings.php
CHANGED
@@ -54,77 +54,12 @@ class YasrSettings {
|
|
54 |
register_setting(
|
55 |
'yasr_general_options_group', // A settings group name. Must exist prior to the register_setting call.
|
56 |
// This must match the group name in settings_fields()
|
57 |
-
'yasr_general_options', //The name of an
|
58 |
array($this, 'sanitize')
|
59 |
);
|
60 |
|
61 |
-
$
|
62 |
-
$
|
63 |
-
|
64 |
-
//This is to avoid undefined offset
|
65 |
-
if ($option && $option['auto_insert_enabled'] === 0) {
|
66 |
-
$option['auto_insert_what'] = 'visitor_rating';
|
67 |
-
$option['auto_insert_where'] = 'bottom';
|
68 |
-
$option['auto_insert_align'] = 'center';
|
69 |
-
$option['auto_insert_exclude_pages'] = 'yes';
|
70 |
-
$option['auto_insert_size'] = 'large';
|
71 |
-
$option['auto_insert_custom_post_only'] = 'no';
|
72 |
-
}
|
73 |
-
|
74 |
-
if ($option && $option['stars_title'] === 'no') {
|
75 |
-
$option['stars_title_what'] = 'visitor_rating';
|
76 |
-
$option['stars_title_exclude_pages'] = 'yes';
|
77 |
-
$option['stars_title_where'] = 'archive';
|
78 |
-
}
|
79 |
-
|
80 |
-
//Default values
|
81 |
-
if(!isset($option['text_before_overall'])) {
|
82 |
-
$option['text_before_overall'] = __('Our Score', 'yet-another-stars-rating');
|
83 |
-
}
|
84 |
-
if(!isset($option['text_before_visitor_rating'])) {
|
85 |
-
$option['text_before_visitor_rating'] = __('Click to rate this post!', 'yet-another-stars-rating');
|
86 |
-
}
|
87 |
-
|
88 |
-
if(!isset($option['text_after_visitor_rating'])) {
|
89 |
-
$option['text_after_visitor_rating'] = sprintf(
|
90 |
-
__('[Total: %s Average: %s]', 'yet-another-stars-rating'),
|
91 |
-
'%total_count%', '%average%'
|
92 |
-
);
|
93 |
-
}
|
94 |
-
|
95 |
-
if(!isset($option['custom_text_rating_saved'])) {
|
96 |
-
$option['custom_text_rating_saved'] = __('Rating saved!', 'yet-another-stars-rating');
|
97 |
-
}
|
98 |
-
|
99 |
-
if(!isset($option['custom_text_rating_updated'])) {
|
100 |
-
$option['custom_text_rating_updated'] = __('Rating updated!', 'yet-another-stars-rating');
|
101 |
-
}
|
102 |
-
|
103 |
-
if(!isset($option['custom_text_user_voted'])) {
|
104 |
-
$option['custom_text_user_voted'] =
|
105 |
-
__('You have already voted for this article with rating ', 'yet-another-stars-rating') . '%rating%';
|
106 |
-
}
|
107 |
-
|
108 |
-
if(!isset($option['custom_text_must_sign_in'])) {
|
109 |
-
$option['custom_text_must_sign_in'] = __('You must sign in to vote', 'yet-another-stars-rating');
|
110 |
-
}
|
111 |
-
|
112 |
-
//Avoid undefined
|
113 |
-
if (!isset($option['publisher'])) {
|
114 |
-
$option['publisher'] = 'Organization';
|
115 |
-
}
|
116 |
-
|
117 |
-
if (!isset($option['publisher_name'])) {
|
118 |
-
$option['publisher_name'] = get_bloginfo('name');
|
119 |
-
}
|
120 |
-
|
121 |
-
if (!isset($option['publisher_logo'])) {
|
122 |
-
$option['publisher_logo'] = get_site_icon_url();
|
123 |
-
}
|
124 |
-
|
125 |
-
if(!isset($option['enable_ajax'])) {
|
126 |
-
$option['enable_ajax'] = 'no';
|
127 |
-
}
|
128 |
|
129 |
add_settings_section(
|
130 |
'yasr_general_options_section_id',
|
@@ -139,7 +74,7 @@ class YasrSettings {
|
|
139 |
array($this, 'autoInsert'),
|
140 |
'yasr_general_settings_tab',
|
141 |
'yasr_general_options_section_id',
|
142 |
-
$
|
143 |
);
|
144 |
|
145 |
add_settings_field(
|
@@ -148,7 +83,7 @@ class YasrSettings {
|
|
148 |
array($this, 'starsTitle'),
|
149 |
'yasr_general_settings_tab',
|
150 |
'yasr_general_options_section_id',
|
151 |
-
$
|
152 |
);
|
153 |
|
154 |
add_settings_field(
|
@@ -157,7 +92,7 @@ class YasrSettings {
|
|
157 |
array($this, 'archivePages'),
|
158 |
'yasr_general_settings_tab',
|
159 |
'yasr_general_options_section_id',
|
160 |
-
$
|
161 |
);
|
162 |
|
163 |
add_settings_field(
|
@@ -166,7 +101,7 @@ class YasrSettings {
|
|
166 |
array($this, 'vvStats'),
|
167 |
'yasr_general_settings_tab',
|
168 |
'yasr_general_options_section_id',
|
169 |
-
$
|
170 |
);
|
171 |
|
172 |
add_settings_field(
|
@@ -175,7 +110,7 @@ class YasrSettings {
|
|
175 |
array($this, 'loggedOnly'),
|
176 |
'yasr_general_settings_tab',
|
177 |
'yasr_general_options_section_id',
|
178 |
-
$
|
179 |
);
|
180 |
|
181 |
add_settings_field(
|
@@ -184,7 +119,7 @@ class YasrSettings {
|
|
184 |
array($this, 'customText'),
|
185 |
'yasr_general_settings_tab',
|
186 |
'yasr_general_options_section_id',
|
187 |
-
$
|
188 |
);
|
189 |
|
190 |
|
@@ -194,7 +129,7 @@ class YasrSettings {
|
|
194 |
array($this, 'snippets' ),
|
195 |
'yasr_general_settings_tab',
|
196 |
'yasr_general_options_section_id',
|
197 |
-
$
|
198 |
);
|
199 |
|
200 |
add_settings_field(
|
@@ -203,7 +138,7 @@ class YasrSettings {
|
|
203 |
array($this, 'advancedSettings'),
|
204 |
'yasr_general_settings_tab',
|
205 |
'yasr_general_options_section_id',
|
206 |
-
$
|
207 |
);
|
208 |
|
209 |
}
|
@@ -348,6 +283,7 @@ class YasrSettings {
|
|
348 |
/**
|
349 |
* Display options for stars near title
|
350 |
*
|
|
|
351 |
* @param $option
|
352 |
*/
|
353 |
public function starsTitle($option) {
|
@@ -417,6 +353,12 @@ class YasrSettings {
|
|
417 |
|
418 |
}
|
419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
public function archivePages($option) {
|
421 |
?>
|
422 |
<div class="yasr-settings-row-45">
|
@@ -463,6 +405,12 @@ class YasrSettings {
|
|
463 |
|
464 |
}
|
465 |
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
public function vvStats($option) {
|
467 |
?>
|
468 |
<div class="yasr-settings-row">
|
@@ -500,6 +448,12 @@ class YasrSettings {
|
|
500 |
|
501 |
}
|
502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
public function loggedOnly($option) {
|
504 |
?>
|
505 |
<div class="yasr-settings-padding-left">
|
@@ -527,6 +481,12 @@ class YasrSettings {
|
|
527 |
|
528 |
} //End function
|
529 |
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
public function customText($option) {
|
531 |
?>
|
532 |
<div>
|
@@ -621,6 +581,12 @@ class YasrSettings {
|
|
621 |
<?php
|
622 |
}
|
623 |
|
|
|
|
|
|
|
|
|
|
|
|
|
624 |
public function snippets($option) {
|
625 |
$publisher_name = $option['publisher_name'];
|
626 |
$publisher_logo = $option['publisher_logo'];
|
@@ -632,7 +598,7 @@ class YasrSettings {
|
|
632 |
</strong>
|
633 |
<div>
|
634 |
<?php
|
635 |
-
$review_types
|
636 |
sort($review_types);
|
637 |
?>
|
638 |
<label for="yasr-choose-reviews-types-list">
|
@@ -731,6 +697,12 @@ class YasrSettings {
|
|
731 |
|
732 |
} //End function yasr_choose_snippet_callback
|
733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
734 |
public function advancedSettings($option) {
|
735 |
?>
|
736 |
<div class="yasr-settings-row-45">
|
@@ -800,6 +772,16 @@ class YasrSettings {
|
|
800 |
<?php
|
801 |
} //End function
|
802 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
803 |
public function sanitize($option) {
|
804 |
//Array to return
|
805 |
$output = array();
|
@@ -927,8 +909,8 @@ class YasrSettings {
|
|
927 |
}
|
928 |
|
929 |
/**
|
930 |
-
* @author
|
931 |
-
* @since
|
932 |
* @param $elementsType_array
|
933 |
* @param $option
|
934 |
* @param string $option_prefix
|
@@ -970,4 +952,6 @@ class YasrSettings {
|
|
970 |
}
|
971 |
|
972 |
|
|
|
|
|
973 |
}
|
54 |
register_setting(
|
55 |
'yasr_general_options_group', // A settings group name. Must exist prior to the register_setting call.
|
56 |
// This must match the group name in settings_fields()
|
57 |
+
'yasr_general_options', //The name of an options to sanitize and save.
|
58 |
array($this, 'sanitize')
|
59 |
);
|
60 |
|
61 |
+
$settings = new YasrSettingsValues();
|
62 |
+
$options = $settings->getGeneralSettings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
add_settings_section(
|
65 |
'yasr_general_options_section_id',
|
74 |
array($this, 'autoInsert'),
|
75 |
'yasr_general_settings_tab',
|
76 |
'yasr_general_options_section_id',
|
77 |
+
$options
|
78 |
);
|
79 |
|
80 |
add_settings_field(
|
83 |
array($this, 'starsTitle'),
|
84 |
'yasr_general_settings_tab',
|
85 |
'yasr_general_options_section_id',
|
86 |
+
$options
|
87 |
);
|
88 |
|
89 |
add_settings_field(
|
92 |
array($this, 'archivePages'),
|
93 |
'yasr_general_settings_tab',
|
94 |
'yasr_general_options_section_id',
|
95 |
+
$options
|
96 |
);
|
97 |
|
98 |
add_settings_field(
|
101 |
array($this, 'vvStats'),
|
102 |
'yasr_general_settings_tab',
|
103 |
'yasr_general_options_section_id',
|
104 |
+
$options
|
105 |
);
|
106 |
|
107 |
add_settings_field(
|
110 |
array($this, 'loggedOnly'),
|
111 |
'yasr_general_settings_tab',
|
112 |
'yasr_general_options_section_id',
|
113 |
+
$options
|
114 |
);
|
115 |
|
116 |
add_settings_field(
|
119 |
array($this, 'customText'),
|
120 |
'yasr_general_settings_tab',
|
121 |
'yasr_general_options_section_id',
|
122 |
+
$options
|
123 |
);
|
124 |
|
125 |
|
129 |
array($this, 'snippets' ),
|
130 |
'yasr_general_settings_tab',
|
131 |
'yasr_general_options_section_id',
|
132 |
+
$options
|
133 |
);
|
134 |
|
135 |
add_settings_field(
|
138 |
array($this, 'advancedSettings'),
|
139 |
'yasr_general_settings_tab',
|
140 |
'yasr_general_options_section_id',
|
141 |
+
$options
|
142 |
);
|
143 |
|
144 |
}
|
283 |
/**
|
284 |
* Display options for stars near title
|
285 |
*
|
286 |
+
* @author Dario Curvino <@dudo>
|
287 |
* @param $option
|
288 |
*/
|
289 |
public function starsTitle($option) {
|
353 |
|
354 |
}
|
355 |
|
356 |
+
/**
|
357 |
+
* Display options for stars in archive pages
|
358 |
+
*
|
359 |
+
* @author Dario Curvino <@dudo>
|
360 |
+
* @param $option
|
361 |
+
*/
|
362 |
public function archivePages($option) {
|
363 |
?>
|
364 |
<div class="yasr-settings-row-45">
|
405 |
|
406 |
}
|
407 |
|
408 |
+
/**
|
409 |
+
* Display options for vvStats
|
410 |
+
*
|
411 |
+
* @author Dario Curvino <@dudo>
|
412 |
+
* @param $option
|
413 |
+
*/
|
414 |
public function vvStats($option) {
|
415 |
?>
|
416 |
<div class="yasr-settings-row">
|
448 |
|
449 |
}
|
450 |
|
451 |
+
/**
|
452 |
+
* Display options for choose who is allowed to votes
|
453 |
+
*
|
454 |
+
* @author Dario Curvino <@dudo>
|
455 |
+
* @param $option
|
456 |
+
*/
|
457 |
public function loggedOnly($option) {
|
458 |
?>
|
459 |
<div class="yasr-settings-padding-left">
|
481 |
|
482 |
} //End function
|
483 |
|
484 |
+
/**
|
485 |
+
* Display options for custom texts
|
486 |
+
*
|
487 |
+
* @author Dario Curvino <@dudo>
|
488 |
+
* @param $option
|
489 |
+
*/
|
490 |
public function customText($option) {
|
491 |
?>
|
492 |
<div>
|
581 |
<?php
|
582 |
}
|
583 |
|
584 |
+
/**
|
585 |
+
* Display options for rich snippets
|
586 |
+
*
|
587 |
+
* @author Dario Curvino <@dudo>
|
588 |
+
* @param $option
|
589 |
+
*/
|
590 |
public function snippets($option) {
|
591 |
$publisher_name = $option['publisher_name'];
|
592 |
$publisher_logo = $option['publisher_logo'];
|
598 |
</strong>
|
599 |
<div>
|
600 |
<?php
|
601 |
+
$review_types = YASR_SUPPORTED_SCHEMA_TYPES;
|
602 |
sort($review_types);
|
603 |
?>
|
604 |
<label for="yasr-choose-reviews-types-list">
|
697 |
|
698 |
} //End function yasr_choose_snippet_callback
|
699 |
|
700 |
+
/**
|
701 |
+
* Display options for advanced settings
|
702 |
+
*
|
703 |
+
* @author Dario Curvino <@dudo>
|
704 |
+
* @param $option
|
705 |
+
*/
|
706 |
public function advancedSettings($option) {
|
707 |
?>
|
708 |
<div class="yasr-settings-row-45">
|
772 |
<?php
|
773 |
} //End function
|
774 |
|
775 |
+
|
776 |
+
/**
|
777 |
+
* Action to do before save data into the db
|
778 |
+
*
|
779 |
+
* @author Dario Curvino <@dudo>
|
780 |
+
*
|
781 |
+
* @param $option
|
782 |
+
*
|
783 |
+
* @return array
|
784 |
+
*/
|
785 |
public function sanitize($option) {
|
786 |
//Array to return
|
787 |
$output = array();
|
909 |
}
|
910 |
|
911 |
/**
|
912 |
+
* @author Dario Curvino <@dudo>
|
913 |
+
* @since 2.4.7
|
914 |
* @param $elementsType_array
|
915 |
* @param $option
|
916 |
* @param string $option_prefix
|
952 |
}
|
953 |
|
954 |
|
955 |
+
|
956 |
+
|
957 |
}
|
admin/settings/yasr-settings-functions-misc.php
CHANGED
@@ -265,7 +265,6 @@ function yasr_upgrade_pro_box()
|
|
265 |
</button>
|
266 |
</a>
|
267 |
</div>
|
268 |
-
|
269 |
</div>
|
270 |
|
271 |
<?php
|
265 |
</button>
|
266 |
</a>
|
267 |
</div>
|
|
|
268 |
</div>
|
269 |
|
270 |
<?php
|
admin/yasr-admin-actions.php
CHANGED
@@ -8,7 +8,8 @@ add_action('plugins_loaded', 'yasr_edit_category_form');
|
|
8 |
|
9 |
function yasr_edit_category_form () {
|
10 |
if (current_user_can('manage_options')) {
|
11 |
-
YasrEditCategory
|
|
|
12 |
}
|
13 |
}
|
14 |
|
8 |
|
9 |
function yasr_edit_category_form () {
|
10 |
if (current_user_can('manage_options')) {
|
11 |
+
$edit_category = new YasrEditCategory();
|
12 |
+
$edit_category->init();
|
13 |
}
|
14 |
}
|
15 |
|
admin/yasr-admin-functions.php
CHANGED
@@ -61,13 +61,13 @@ function yasr_add_admin_scripts($hook) {
|
|
61 |
|
62 |
if(!isset($_GET['trial'])) {
|
63 |
wp_enqueue_style(
|
64 |
-
'yasrcss-pricing',
|
|
|
|
|
|
|
65 |
);
|
66 |
|
67 |
-
|
68 |
-
'yasrjs-pricing', YASR_JS_DIR_ADMIN . 'yasr-pricing-page.js', array('wp-element', 'yasradmin'),
|
69 |
-
YASR_VERSION_NUM, true
|
70 |
-
);
|
71 |
}
|
72 |
}
|
73 |
|
@@ -83,11 +83,13 @@ function yasr_add_admin_scripts($hook) {
|
|
83 |
|| $hook === 'yet-another-stars-rating_page_yasr_pricing_page'
|
84 |
|| $hook === 'yet-another-stars-rating_page_yasr_settings_page-pricing'
|
85 |
) {
|
86 |
-
|
87 |
-
yasr_enqueue_includes_js_scripts();
|
88 |
|
89 |
do_action('yasr_add_admin_scripts_begin', $hook);
|
90 |
|
|
|
|
|
|
|
91 |
wp_enqueue_style(
|
92 |
'yasrcss',
|
93 |
YASR_CSS_DIR_ADMIN . 'yasr-admin.css',
|
@@ -95,48 +97,17 @@ function yasr_add_admin_scripts($hook) {
|
|
95 |
YASR_VERSION_NUM
|
96 |
);
|
97 |
|
98 |
-
wp_enqueue_script(
|
99 |
-
'tippy',
|
100 |
-
YASR_JS_DIR_INCLUDES . 'tippy.all.min.js',
|
101 |
-
'',
|
102 |
-
'3.6.0',
|
103 |
-
true
|
104 |
-
);
|
105 |
-
|
106 |
-
wp_enqueue_script(
|
107 |
-
'yasradmin',
|
108 |
-
YASR_JS_DIR_ADMIN . 'yasr-admin.js',
|
109 |
-
array('jquery', 'tippy', 'rater'),
|
110 |
-
YASR_VERSION_NUM,
|
111 |
-
true
|
112 |
-
);
|
113 |
-
|
114 |
do_action('yasr_add_admin_scripts_end', $hook);
|
115 |
-
|
116 |
}
|
117 |
|
118 |
if ($hook === 'post.php' || $hook === 'post-new.php') {
|
119 |
-
|
120 |
-
'yasr_classic_editor_functions',
|
121 |
-
YASR_JS_DIR_ADMIN . 'yasr-editor-screen.js',
|
122 |
-
array('jquery', 'rater'),
|
123 |
-
YASR_VERSION_NUM,
|
124 |
-
true
|
125 |
-
);
|
126 |
}
|
127 |
|
128 |
//add this only in yasr setting page (admin.php?page=yasr_settings_page)
|
129 |
if ($hook === $yasr_settings_page) {
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
wp_enqueue_script(
|
134 |
-
'yasradmin-settings',
|
135 |
-
YASR_JS_DIR_ADMIN . 'yasr-settings.js',
|
136 |
-
array('jquery', 'yasradmin', 'wp-element'),
|
137 |
-
YASR_VERSION_NUM,
|
138 |
-
true
|
139 |
-
);
|
140 |
}
|
141 |
|
142 |
}
|
@@ -146,14 +117,22 @@ add_action('admin_menu', 'yasr_add_pages');
|
|
146 |
|
147 |
function yasr_add_pages() {
|
148 |
|
|
|
|
|
|
|
|
|
149 |
global $yasr_settings_page;
|
150 |
|
151 |
-
$
|
|
|
|
|
|
|
|
|
152 |
|
153 |
//Add Settings Page
|
154 |
$yasr_settings_page = add_menu_page(
|
155 |
-
|
156 |
-
|
157 |
'manage_options', //capability
|
158 |
'yasr_settings_page', //menu slug
|
159 |
'yasr_settings_page_callback', //The function to be called to output the content for this page.
|
@@ -163,7 +142,7 @@ function yasr_add_pages() {
|
|
163 |
add_submenu_page(
|
164 |
'yasr_settings_page',
|
165 |
'Yet Another Stars Rating: settings',
|
166 |
-
|
167 |
'manage_options',
|
168 |
'yasr_settings_page'
|
169 |
);
|
@@ -185,10 +164,9 @@ function yasr_add_pages() {
|
|
185 |
if (yasr_fs()->is_free_plan() && !yasr_fs()->is_trial()) {
|
186 |
global $submenu;
|
187 |
$permalink = '#';
|
188 |
-
$contact_us_string =
|
189 |
-
|
190 |
-
|
191 |
-
);
|
192 |
$submenu['yasr_settings_page'][] = array($contact_us_string, 'manage_options', $permalink);
|
193 |
}
|
194 |
|
61 |
|
62 |
if(!isset($_GET['trial'])) {
|
63 |
wp_enqueue_style(
|
64 |
+
'yasrcss-pricing',
|
65 |
+
YASR_CSS_DIR_ADMIN . 'yasr-pricing-page.css',
|
66 |
+
false,
|
67 |
+
YASR_VERSION_NUM
|
68 |
);
|
69 |
|
70 |
+
YasrScriptsLoader::loadPrincingPage();
|
|
|
|
|
|
|
71 |
}
|
72 |
}
|
73 |
|
83 |
|| $hook === 'yet-another-stars-rating_page_yasr_pricing_page'
|
84 |
|| $hook === 'yet-another-stars-rating_page_yasr_settings_page-pricing'
|
85 |
) {
|
86 |
+
YasrScriptsLoader::loadRequiredJs();
|
|
|
87 |
|
88 |
do_action('yasr_add_admin_scripts_begin', $hook);
|
89 |
|
90 |
+
YasrScriptsLoader::loadTippy();
|
91 |
+
YasrScriptsLoader::loadYasrAdmin();
|
92 |
+
|
93 |
wp_enqueue_style(
|
94 |
'yasrcss',
|
95 |
YASR_CSS_DIR_ADMIN . 'yasr-admin.css',
|
97 |
YASR_VERSION_NUM
|
98 |
);
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
do_action('yasr_add_admin_scripts_end', $hook);
|
|
|
101 |
}
|
102 |
|
103 |
if ($hook === 'post.php' || $hook === 'post-new.php') {
|
104 |
+
YasrScriptsLoader::loadClassicEditor();
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
|
107 |
//add this only in yasr setting page (admin.php?page=yasr_settings_page)
|
108 |
if ($hook === $yasr_settings_page) {
|
109 |
+
YasrScriptsLoader::loadCodeEditor();
|
110 |
+
YasrScriptsLoader::loadAdminSettings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
112 |
|
113 |
}
|
117 |
|
118 |
function yasr_add_pages() {
|
119 |
|
120 |
+
if (!current_user_can('manage_options')) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
global $yasr_settings_page;
|
125 |
|
126 |
+
$settings_menu_title = '<span class="dashicons dashicons-admin-settings"></span> ' .
|
127 |
+
esc_html__('Settings', 'yet-another-stars-rating');
|
128 |
+
|
129 |
+
$stats_menu_title = '<span class="dashicons dashicons-chart-line"></span> ' .
|
130 |
+
esc_html__('Manage Ratings', 'yet-another-stars-rating');
|
131 |
|
132 |
//Add Settings Page
|
133 |
$yasr_settings_page = add_menu_page(
|
134 |
+
'Yet Another Stars Rating: settings',
|
135 |
+
'Yet Another Stars Rating', //Menu Title
|
136 |
'manage_options', //capability
|
137 |
'yasr_settings_page', //menu slug
|
138 |
'yasr_settings_page_callback', //The function to be called to output the content for this page.
|
142 |
add_submenu_page(
|
143 |
'yasr_settings_page',
|
144 |
'Yet Another Stars Rating: settings',
|
145 |
+
$settings_menu_title,
|
146 |
'manage_options',
|
147 |
'yasr_settings_page'
|
148 |
);
|
164 |
if (yasr_fs()->is_free_plan() && !yasr_fs()->is_trial()) {
|
165 |
global $submenu;
|
166 |
$permalink = '#';
|
167 |
+
$contact_us_string = YASR_LOCKED_FEATURE . ' ' .
|
168 |
+
esc_html__('Contact Us', 'yet-another-stars-rating');
|
169 |
+
|
|
|
170 |
$submenu['yasr_settings_page'][] = array($contact_us_string, 'manage_options', $permalink);
|
171 |
}
|
172 |
|
admin/yasr-admin-init.php
CHANGED
@@ -42,7 +42,7 @@ add_action('init', function (){
|
|
42 |
$text = __('This feature is available only in the pro version', 'yet-another-stars-rating');
|
43 |
$lock_image =
|
44 |
apply_filters('yasr_feature_locked',
|
45 |
-
'<span class="dashicons dashicons-lock" title="'
|
46 |
10,
|
47 |
1);
|
48 |
|
@@ -50,6 +50,19 @@ add_action('init', function (){
|
|
50 |
|
51 |
define ('YASR_LOCKED_FEATURE', $lock_image);
|
52 |
define ('YASR_LOCKED_FEATURE_HTML_ATTRIBUTE', $html_disabled_attribute);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
});
|
54 |
|
55 |
|
42 |
$text = __('This feature is available only in the pro version', 'yet-another-stars-rating');
|
43 |
$lock_image =
|
44 |
apply_filters('yasr_feature_locked',
|
45 |
+
'<span class="dashicons dashicons-lock" title="'.esc_attr($text).'"></span>',
|
46 |
10,
|
47 |
1);
|
48 |
|
50 |
|
51 |
define ('YASR_LOCKED_FEATURE', $lock_image);
|
52 |
define ('YASR_LOCKED_FEATURE_HTML_ATTRIBUTE', $html_disabled_attribute);
|
53 |
+
|
54 |
+
$url = 'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=edit_category&utm_campaign=yasr_editor_category#yasr-pro';
|
55 |
+
$upgrade_text = sprintf(
|
56 |
+
esc_html__('Upgrade to %s to unlock this feature', 'yet-another-stars-rating'),
|
57 |
+
sprintf(
|
58 |
+
'<a href="%s">%s</a>',
|
59 |
+
esc_url($url),
|
60 |
+
'YASR PRO'
|
61 |
+
)
|
62 |
+
);
|
63 |
+
|
64 |
+
define ('YASR_LOCKED_TEXT', $upgrade_text);
|
65 |
+
|
66 |
});
|
67 |
|
68 |
|
admin/yasr-update-functions.php
CHANGED
@@ -12,17 +12,9 @@ function yasr_update_version() {
|
|
12 |
//do only in admin
|
13 |
if (is_admin()) {
|
14 |
global $wpdb;
|
15 |
-
|
16 |
|
17 |
if (YASR_VERSION_INSTALLED !== false) {
|
18 |
-
|
19 |
-
//In version 2.4.3 is added a setting to show stars near the post title
|
20 |
-
//remove August 2022
|
21 |
-
if (version_compare(YASR_VERSION_INSTALLED, '2.4.3') === -1) {
|
22 |
-
$yasr_stored_options['stars_title'] = 'no';
|
23 |
-
update_option('yasr_general_options', $yasr_stored_options);
|
24 |
-
}
|
25 |
-
|
26 |
//In version 2.6.6 %overall_rating% pattern is replaced with %rating%
|
27 |
//Remove March 2023
|
28 |
if (version_compare(YASR_VERSION_INSTALLED, '2.6.6') === -1) {
|
12 |
//do only in admin
|
13 |
if (is_admin()) {
|
14 |
global $wpdb;
|
15 |
+
$yasr_stored_options = get_option('yasr_general_options');
|
16 |
|
17 |
if (YASR_VERSION_INSTALLED !== false) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
//In version 2.6.6 %overall_rating% pattern is replaced with %rating%
|
19 |
//Remove March 2023
|
20 |
if (version_compare(YASR_VERSION_INSTALLED, '2.6.6') === -1) {
|
includes/classes/YasrDatabaseRatings.php
CHANGED
@@ -107,12 +107,20 @@ class YasrDatabaseRatings {
|
|
107 |
|
108 |
$array_to_return = array(
|
109 |
'number_of_votes' => 0,
|
110 |
-
'sum_votes' => 0
|
|
|
111 |
);
|
|
|
112 |
foreach ($result as $user_votes) {
|
113 |
$array_to_return['number_of_votes'] = (int)$user_votes->number_of_votes;
|
114 |
$array_to_return['sum_votes'] = (int)$user_votes->sum_votes;
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
|
|
116 |
return $array_to_return;
|
117 |
}
|
118 |
|
107 |
|
108 |
$array_to_return = array(
|
109 |
'number_of_votes' => 0,
|
110 |
+
'sum_votes' => 0,
|
111 |
+
'average' => 0
|
112 |
);
|
113 |
+
|
114 |
foreach ($result as $user_votes) {
|
115 |
$array_to_return['number_of_votes'] = (int)$user_votes->number_of_votes;
|
116 |
$array_to_return['sum_votes'] = (int)$user_votes->sum_votes;
|
117 |
+
|
118 |
+
if ($array_to_return['number_of_votes'] > 0) {
|
119 |
+
$array_to_return['average'] = ($array_to_return['sum_votes'] / $array_to_return['number_of_votes']);
|
120 |
+
$array_to_return['average'] = round($array_to_return['average'], 1);
|
121 |
+
}
|
122 |
}
|
123 |
+
|
124 |
return $array_to_return;
|
125 |
}
|
126 |
|
includes/classes/YasrIncludesFilters.php
CHANGED
@@ -24,7 +24,9 @@ class YasrIncludesFilters {
|
|
24 |
* @param $yasr_stored_options
|
25 |
*/
|
26 |
public function filterCustomTexts($yasr_stored_options) {
|
27 |
-
$
|
|
|
|
|
28 |
|
29 |
add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'), 10);
|
30 |
add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 10, 3);
|
24 |
* @param $yasr_stored_options
|
25 |
*/
|
26 |
public function filterCustomTexts($yasr_stored_options) {
|
27 |
+
if(is_array($yasr_stored_options)) {
|
28 |
+
$this->yasr_stored_options = $yasr_stored_options;
|
29 |
+
}
|
30 |
|
31 |
add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'), 10);
|
32 |
add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 10, 3);
|
includes/classes/YasrLogDashboardWidget.php
CHANGED
@@ -154,13 +154,7 @@ class YasrLogDashboardWidget {
|
|
154 |
* @return string|void
|
155 |
*/
|
156 |
public function userWidgetShortcode () {
|
157 |
-
|
158 |
-
'yasr-log-users-frontend',
|
159 |
-
YASR_JS_DIR_INCLUDES . 'shortcodes/yasr-log-users-fronted.js',
|
160 |
-
array('jquery'),
|
161 |
-
YASR_VERSION_NUM,
|
162 |
-
true
|
163 |
-
);
|
164 |
|
165 |
if($this->is_ajax === false) {
|
166 |
return $this->userWidget(true);
|
@@ -204,9 +198,9 @@ class YasrLogDashboardWidget {
|
|
204 |
$user->user_login = __('anonymous', 'yet-another-stars-rating');
|
205 |
}
|
206 |
|
207 |
-
$avatar
|
208 |
|
209 |
-
$post_title =
|
210 |
$link = get_permalink($column->post_id); //Get post link from post id
|
211 |
|
212 |
if ($this->user_widget !== true) {
|
@@ -242,7 +236,7 @@ class YasrLogDashboardWidget {
|
|
242 |
'</div>
|
243 |
<div class="yasr-log-child-head">
|
244 |
<span id="yasr-log-vote">'.$yasr_log_vote_text.'</span>
|
245 |
-
<span id="yasr-log-post"><a href="'. $link .'">'
|
246 |
</div>
|
247 |
<div class="yasr-log-ip-date">'
|
248 |
.$ip_span.
|
154 |
* @return string|void
|
155 |
*/
|
156 |
public function userWidgetShortcode () {
|
157 |
+
YasrScriptsLoader::loadLogUsersFrontend();
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
if($this->is_ajax === false) {
|
160 |
return $this->userWidget(true);
|
198 |
$user->user_login = __('anonymous', 'yet-another-stars-rating');
|
199 |
}
|
200 |
|
201 |
+
$avatar = get_avatar($column->user_id, '32'); //Get avatar from user id
|
202 |
|
203 |
+
$post_title = get_post_field( 'post_title', $column->post_id, 'raw' ); //Get post title from post id
|
204 |
$link = get_permalink($column->post_id); //Get post link from post id
|
205 |
|
206 |
if ($this->user_widget !== true) {
|
236 |
'</div>
|
237 |
<div class="yasr-log-child-head">
|
238 |
<span id="yasr-log-vote">'.$yasr_log_vote_text.'</span>
|
239 |
+
<span id="yasr-log-post"><a href="'. $link .'">'.esc_html($post_title).'</a></span>
|
240 |
</div>
|
241 |
<div class="yasr-log-ip-date">'
|
242 |
.$ip_span.
|
includes/classes/YasrPhpFieldsHelper.php
CHANGED
@@ -142,6 +142,8 @@ if (!class_exists('YasrPhpFieldsHelper') ) {
|
|
142 |
* @param bool|string|int $placeholder
|
143 |
* @param bool|string|int $default_value
|
144 |
* @param string $autocomplete
|
|
|
|
|
145 |
*
|
146 |
* @return string
|
147 |
*/
|
142 |
* @param bool|string|int $placeholder
|
143 |
* @param bool|string|int $default_value
|
144 |
* @param string $autocomplete
|
145 |
+
* @param bool|string $disabled
|
146 |
+
* @param bool|string $readonly
|
147 |
*
|
148 |
* @return string
|
149 |
*/
|
includes/classes/YasrScriptsLoader.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Dario Curvino <@dudo>
|
5 |
+
* @since 3.0.4
|
6 |
+
* Class YasrScriptsLoader
|
7 |
+
*/
|
8 |
+
class YasrScriptsLoader {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* This function enqueue the js scripts required on both admin and frontend
|
12 |
+
*
|
13 |
+
* @author Dario Curvino <@dudo>
|
14 |
+
* @since 2.8.5
|
15 |
+
*/
|
16 |
+
public static function loadRequiredJs() {
|
17 |
+
wp_enqueue_script('jquery');
|
18 |
+
|
19 |
+
wp_enqueue_script(
|
20 |
+
'yasr-global-functions',
|
21 |
+
YASR_JS_DIR_INCLUDES . 'yasr-globals.js',
|
22 |
+
'yasr-global-data',
|
23 |
+
YASR_VERSION_NUM,
|
24 |
+
true
|
25 |
+
);
|
26 |
+
|
27 |
+
if (defined('YASR_CATCH_INFINITE_SCROLL_INSTALLED') && YASR_CATCH_INFINITE_SCROLL_INSTALLED === true) {
|
28 |
+
$array_dep = array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-global-data', 'wp-element');
|
29 |
+
|
30 |
+
//laod tippy only if the shortcode has loaded it
|
31 |
+
$tippy_loaded = wp_script_is('tippy');
|
32 |
+
|
33 |
+
if ($tippy_loaded) {
|
34 |
+
$array_dep[] = 'tippy';
|
35 |
+
}
|
36 |
+
|
37 |
+
wp_enqueue_script(
|
38 |
+
'yasr_catch_infinite',
|
39 |
+
YASR_JS_DIR_INCLUDES . 'catch-inifite-scroll.js',
|
40 |
+
$array_dep,
|
41 |
+
YASR_VERSION_NUM,
|
42 |
+
true
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Enqueue visitorVotes.js file
|
50 |
+
*
|
51 |
+
* @author Dario Curvino <@dudo>
|
52 |
+
* @since 2.8.5
|
53 |
+
*/
|
54 |
+
public static function loadVVJs() {
|
55 |
+
$array_dep = array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-global-data');
|
56 |
+
$tippy_loaded = wp_script_is('tippy');
|
57 |
+
|
58 |
+
if ($tippy_loaded) {
|
59 |
+
$array_dep[] = 'tippy';
|
60 |
+
}
|
61 |
+
|
62 |
+
wp_enqueue_script(
|
63 |
+
'yasr-front-vv',
|
64 |
+
YASR_JS_DIR_INCLUDES . 'shortcodes/visitorVotes.js',
|
65 |
+
$array_dep,
|
66 |
+
YASR_VERSION_NUM,
|
67 |
+
true
|
68 |
+
);
|
69 |
+
}
|
70 |
+
|
71 |
+
/***
|
72 |
+
* Enqueue overall-multiset.js file
|
73 |
+
*
|
74 |
+
* @author Dario Curvino <@dudo>
|
75 |
+
* @since 2.8.8
|
76 |
+
*/
|
77 |
+
public static function loadOVMultiJs() {
|
78 |
+
wp_enqueue_script(
|
79 |
+
'yasr-ov-multi',
|
80 |
+
YASR_JS_DIR_INCLUDES . 'shortcodes/overall-multiset.js',
|
81 |
+
array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-global-data'),
|
82 |
+
YASR_VERSION_NUM,
|
83 |
+
true
|
84 |
+
);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Enqueue rankings.js file
|
89 |
+
*
|
90 |
+
* @author Dario Curvino <@dudo>
|
91 |
+
* @since 2.8.8
|
92 |
+
*/
|
93 |
+
public static function loadRankingsJs() {
|
94 |
+
wp_enqueue_script(
|
95 |
+
'yasr-rankings',
|
96 |
+
YASR_JS_DIR_INCLUDES . 'shortcodes/rankings.js',
|
97 |
+
array('jquery', 'yasr-global-functions', 'wp-i18n', 'wp-element', 'yasr-global-data'),
|
98 |
+
YASR_VERSION_NUM,
|
99 |
+
true
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Load file yasr-log-users-fronted.js
|
105 |
+
*
|
106 |
+
* @author Dario Curvino <@dudo>
|
107 |
+
* @since 3.0.4
|
108 |
+
*/
|
109 |
+
public static function loadLogUsersFrontend() {
|
110 |
+
wp_enqueue_script(
|
111 |
+
'yasr-log-users-frontend',
|
112 |
+
YASR_JS_DIR_INCLUDES . 'shortcodes/yasr-log-users-frontend.js',
|
113 |
+
array('jquery'),
|
114 |
+
YASR_VERSION_NUM,
|
115 |
+
true
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Load tippy if needed
|
121 |
+
*
|
122 |
+
* @author Dario Curvino <@dudo>
|
123 |
+
* @since 2.8.5
|
124 |
+
*/
|
125 |
+
public static function loadTippy() {
|
126 |
+
wp_enqueue_script(
|
127 |
+
'tippy',
|
128 |
+
YASR_JS_DIR_INCLUDES . 'tippy.all.min.js',
|
129 |
+
'',
|
130 |
+
'3.6.0',
|
131 |
+
true
|
132 |
+
);
|
133 |
+
}
|
134 |
+
|
135 |
+
/******************* Admin methods *******************/
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Load Yasr-admin.js
|
139 |
+
*
|
140 |
+
* @author Dario Curvino <@dudo>
|
141 |
+
* @since 3.0.4
|
142 |
+
*/
|
143 |
+
public static function loadYasrAdmin () {
|
144 |
+
wp_enqueue_script(
|
145 |
+
'yasradmin',
|
146 |
+
YASR_JS_DIR_ADMIN . 'yasr-admin.js',
|
147 |
+
array('jquery', 'tippy', 'yasr-global-functions'),
|
148 |
+
YASR_VERSION_NUM,
|
149 |
+
true
|
150 |
+
);
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Load yasr-editor-screen.js
|
155 |
+
*
|
156 |
+
* @author Dario Curvino <@dudo>
|
157 |
+
* @since 3.0.4
|
158 |
+
*/
|
159 |
+
public static function loadClassicEditor() {
|
160 |
+
wp_enqueue_script(
|
161 |
+
'yasr-classic-editor',
|
162 |
+
YASR_JS_DIR_ADMIN . 'yasr-editor-screen.js',
|
163 |
+
array('jquery', 'yasr-global-functions'),
|
164 |
+
YASR_VERSION_NUM,
|
165 |
+
true
|
166 |
+
);
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Enqueue the code editor
|
171 |
+
*
|
172 |
+
* @author Dario Curvino <@dudo>
|
173 |
+
* @since 3.0.4
|
174 |
+
*/
|
175 |
+
public static function loadCodeEditor() {
|
176 |
+
$cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/css'));
|
177 |
+
wp_localize_script('jquery', 'yasr_cm_settings', $cm_settings);
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Load yasr-settings.js
|
182 |
+
*
|
183 |
+
* @author Dario Curvino <@dudo>
|
184 |
+
* @since 3.0.4
|
185 |
+
*/
|
186 |
+
public static function loadAdminSettings () {
|
187 |
+
wp_enqueue_script(
|
188 |
+
'yasradmin-settings',
|
189 |
+
YASR_JS_DIR_ADMIN . 'yasr-settings.js',
|
190 |
+
array('jquery', 'yasradmin', 'wp-element'),
|
191 |
+
YASR_VERSION_NUM,
|
192 |
+
true
|
193 |
+
);
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Load yasr-pricing-page.js
|
198 |
+
*
|
199 |
+
* @author Dario Curvino <@dudo>
|
200 |
+
* @since 3.0.4
|
201 |
+
*/
|
202 |
+
public static function loadPrincingPage () {
|
203 |
+
wp_enqueue_script(
|
204 |
+
'yasrjs-pricing',
|
205 |
+
YASR_JS_DIR_ADMIN . 'yasr-pricing-page.js',
|
206 |
+
array('wp-element', 'yasradmin'),
|
207 |
+
YASR_VERSION_NUM,
|
208 |
+
true
|
209 |
+
);
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
includes/classes/YasrSettingsValues.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Collection of methods to manage YASR settings values
|
5 |
+
*
|
6 |
+
* @author Dario Curvino <@dudo>
|
7 |
+
* @since 3.0.4
|
8 |
+
* Class YasrSettingsValues
|
9 |
+
*/
|
10 |
+
class YasrSettingsValues {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Returns YASR General Settings
|
14 |
+
*
|
15 |
+
* @author Dario Curvino <@dudo>
|
16 |
+
* @since 3.0.4
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function getGeneralSettings () {
|
20 |
+
$saved_values = get_option('yasr_general_options');
|
21 |
+
$default_values = $this->defaultValuesGeneral();
|
22 |
+
|
23 |
+
return $this->returnSettingsArray($saved_values, $default_values);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Returns YASR General Settings
|
28 |
+
*
|
29 |
+
* @author Dario Curvino <@dudo>
|
30 |
+
* @since 3.0.4
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function getStyleSettings () {
|
34 |
+
$saved_values = get_option('yasr_style_options');
|
35 |
+
$default_values = $this->defaultValuesStyle();
|
36 |
+
|
37 |
+
return $this->returnSettingsArray($saved_values, $default_values);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Returns YASR Multiset Settings
|
42 |
+
*
|
43 |
+
* @author Dario Curvino <@dudo>
|
44 |
+
* @since 3.0.4
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function getMultiSettings () {
|
48 |
+
$saved_values = get_option('yasr_multiset_options');
|
49 |
+
$default_values = $this->defaultValuesMulti();
|
50 |
+
|
51 |
+
return $this->returnSettingsArray($saved_values, $default_values);
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Return an array with the default values for general settings
|
56 |
+
*
|
57 |
+
* @author Dario Curvino <@dudo>
|
58 |
+
* @since 3.0.4
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function defaultValuesGeneral() {
|
62 |
+
$caching_plugin = new YasrFindCachingPlugins();
|
63 |
+
$caching_plugin_found = $caching_plugin->cachingPluginFound();
|
64 |
+
|
65 |
+
$options['auto_insert_enabled'] = 1;
|
66 |
+
$options['auto_insert_what'] = 'visitor_rating';
|
67 |
+
$options['auto_insert_where'] = 'bottom';
|
68 |
+
$options['auto_insert_align'] = 'center';
|
69 |
+
$options['auto_insert_size'] = 'large';
|
70 |
+
$options['auto_insert_exclude_pages'] = 'yes';
|
71 |
+
$options['auto_insert_custom_post_only'] = 'no';
|
72 |
+
$options['stars_title'] = 'no';
|
73 |
+
$options['stars_title_what'] = 'visitor_rating';
|
74 |
+
$options['stars_title_exclude_pages'] = 'yes';
|
75 |
+
$options['stars_title_where'] = 'archive';
|
76 |
+
$options['show_overall_in_loop'] = 'disabled';
|
77 |
+
$options['show_visitor_votes_in_loop'] = 'disabled';
|
78 |
+
$options['visitors_stats'] = 'yes';
|
79 |
+
$options['allowed_user'] = 'allow_anonymous';
|
80 |
+
$options['text_before_overall'] = esc_html__('Our Score', 'yet-another-stars-rating');
|
81 |
+
$options['text_before_visitor_rating'] = esc_html__('Click to rate this post!', 'yet-another-stars-rating');
|
82 |
+
$options['text_after_visitor_rating'] = sprintf(
|
83 |
+
esc_html__('[Total: %s Average: %s]', 'yet-another-stars-rating'),
|
84 |
+
'%total_count%', '%average%'
|
85 |
+
);
|
86 |
+
$options['custom_text_rating_saved'] = esc_html__('Rating saved!', 'yet-another-stars-rating');
|
87 |
+
$options['custom_text_rating_updated'] = esc_html__('Rating updated!', 'yet-another-stars-rating');
|
88 |
+
$options['custom_text_user_voted'] =
|
89 |
+
esc_html__('You have already voted for this article with rating ', 'yet-another-stars-rating') . '%rating%';
|
90 |
+
$options['custom_text_must_sign_in'] = esc_html__('You must sign in to vote', 'yet-another-stars-rating');
|
91 |
+
$options['snippet_itemtype'] = 'Product';
|
92 |
+
$options['publisher'] = 'Organization';
|
93 |
+
$options['publisher_name'] = get_bloginfo('name');
|
94 |
+
$options['publisher_logo'] = get_site_icon_url();
|
95 |
+
$options['enable_ip'] = 'no';
|
96 |
+
|
97 |
+
if($caching_plugin_found !== false) {
|
98 |
+
$options['enable_ajax'] = 'yes';
|
99 |
+
} else {
|
100 |
+
$options['enable_ajax'] = 'no';
|
101 |
+
}
|
102 |
+
|
103 |
+
return $options;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Return an array with the default values for style settings
|
108 |
+
*
|
109 |
+
* @author Dario Curvino <@dudo>
|
110 |
+
* @since 3.0.4
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
public function defaultValuesStyle() {
|
114 |
+
$style_options['stars_set_free'] = 'rater-yasr';
|
115 |
+
$style_options['scheme_color_multiset'] = 'light';
|
116 |
+
$style_options['textarea'] = false;
|
117 |
+
|
118 |
+
return $style_options;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @author Dario Curvino <@dudo>
|
123 |
+
* @since 3.0.4
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public function defaultValuesMulti() {
|
127 |
+
$multi_set_options['show_average'] = 'yes';
|
128 |
+
return $multi_set_options;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Return a merged array, where the first array has precedence
|
133 |
+
*
|
134 |
+
* https://stackoverflow.com/a/866615/3472877
|
135 |
+
*
|
136 |
+
* @author Dario Curvino <@dudo>
|
137 |
+
* @since 3.0.4
|
138 |
+
* @param $saved_values
|
139 |
+
* @param $default_values
|
140 |
+
*
|
141 |
+
* @return array
|
142 |
+
*/
|
143 |
+
public function returnSettingsArray($saved_values, $default_values) {
|
144 |
+
if(is_array($saved_values) && is_array($default_values)) {
|
145 |
+
return $saved_values + $default_values;
|
146 |
+
}
|
147 |
+
|
148 |
+
return $default_values;
|
149 |
+
}
|
150 |
+
|
151 |
+
}
|
includes/js/catch-inifite-scroll.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";function t(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:s,rating:o,rateCallback:i})}function e(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}wp.i18n.__;for(var a=["yasr-rater-stars","yasr-multiset-visitors-rater"],r=0;r<a.length;r++)n(a[r]);function n(a){var r=document.getElementsByClassName(a);r.length>0&&("yasr-rater-stars"===a&&function(e){for(var a=0;a<e.length;a++)if(!1===e.item(a).classList.contains("yasr-star-rating")){var r=e.item(a),n=r.id;t(r.getAttribute("data-rater-starsize"),n,r)}}(r),"yasr-multiset-visitors-rater"===a&&function(a){for(var r="",n=[],s=document.getElementById("yasr-pro-multiset-review-rating"),o=0;o<a.length;o++)!function(o){if(!1===a.item(o).classList.contains("yasr-star-rating")){var i=a.item(o),l=i.id,c=i.getAttribute("data-rater-readonly"),u=i.getAttribute("data-rater-starsize");u||(u=16),c=e(c);t(u,l,i,1,c,!1,(function(t,e){var a=i.getAttribute("data-rater-postid"),o=i.getAttribute("data-rater-setid"),l=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var c=parseInt(t);this.setRating(c),r={postid:a,setid:o,field:l,rating:c},n.push(r),s&&(s.value=JSON.stringify(n)),e()}))}}(o);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var r={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:n,set_id:e};jQuery.post(yasrCommonData.ajaxurl,r,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(r))}var s=wp.i18n.__;function o(t){if(t.length>0&&(function(t){for(var a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var r=t.item(a),n=r.getAttribute("data-rating"),o=r.getAttribute("data-readonly-attribute"),l=r.getAttribute("data-rater-readonly");null===o&&(o=!1),o=e(o),l=e(l),!0===o&&(l=!0);var c=r.getAttribute("data-rater-postid"),u=r.id,d=u.replace("yasr-visitor-votes-rater-",""),m=parseInt(r.getAttribute("data-rater-starsize")),g=r.getAttribute("data-rater-nonce"),y=r.getAttribute("data-issingular"),v="yasr-vv-votes-number-container-"+d,f="yasr-vv-average-container-"+d,p="yasr-vv-bottom-container-"+d,h="yasr-vv-loader-"+d,_=document.getElementById(v),b=document.getElementById(f),E=document.getElementById(p),R=document.getElementById(h);if("yes"===yasrCommonData.ajaxEnabled){null!==R&&(R.innerHTML=yasrCommonData.loaderHtml);var k={action:"yasr_load_vv",post_id:c};jQuery.get(yasrCommonData.ajaxurl,k).done((function(t){var e,a=JSON.parse(t);e=!0===o||a.yasr_visitor_votes.stars_attributes.read_only,n=(n=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),n=parseFloat(n),i(m,n,c,e,u,0,g,y,_,b,R,E),!0!==o&&(null!==_&&(_.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=n),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,a,r){console.info(s("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),i(m,n,c,l,u,0,g,y,_,b,R,E),!0!==o&&(E.style.display="")}))}else i(m,n,c,l,u,0,g,y,_,b,R,E)}}(a)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(l(e))}))},onHidden:function(){r=s}})}(n)}(a)}}function i(a,r,n,s,o,i,l,c,u,d,m,g){r=parseFloat(r),s=e(s);var y=document.getElementById(o);null!==m&&(m.innerHTML=""),t(a,o,y,1,s,r,(function(t,e){null!==m&&(m.innerHTML=yasrCommonData.loaderHtml);var a={action:"yasr_send_visitor_rating",rating:t,post_id:n,nonce_visitor:l,is_singular:c};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){var e,a,r;"success"===(t=JSON.parse(t)).status?(e=t.number_of_votes,a=t.average_rating,r=t.rating_saved_text,null!==u&&(u.innerHTML=e),null!==d&&(d.innerHTML=a)):r=t.text,null!==g&&(g.innerHTML=r,g.style.display=""),null!==m&&(m.innerHTML="")})),e()}))}function l(t){var e=t.medium_rating;delete t.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||t[r].n_of_votes>a)&&(a=t[r].n_of_votes);var n=Math.log(a)*Math.LOG10E+1|0,o="5%";n<=3&&(o="5%"),n>3&&n<=5&&(o="10%"),n>5&&(o="15%");var i='<div class="yasr-visitors-stats-tooltip">';i+='<span id="yasr-medium-rating-tooltip">'+e+" "+s("out of 5 stars","yet-another-stars-rating")+"</span>",i+='<div class="yasr-progress-bars-container">';for(var l=s("stars","yet-another-stars-rating"),c=0,u=0,d=5;d>0;d--)1===d&&(l=s("star","yet-another-stars-rating")),void 0!==t[d]&&(c=t[d].progressbar,u=t[d].n_of_votes),i+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(d," ").concat(l,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(c,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(o,' ">').concat(u,"</div>\n </div>");return i+"</div></div>"}let c;var u;o(document.getElementsByClassName("yasr-rater-stars-vv"));var d=new Uint8Array(16);function m(){if(!u&&!(u="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return u(d)}const g=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,y=function(t){return"string"==typeof t&&g.test(t)};for(var v=[],f=0;f<256;++f)v.push((f+256).toString(16).substr(1));const p=function(t,e,a){var r=(t=t||{}).random||(t.rng||m)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(v[t[e+0]]+v[t[e+1]]+v[t[e+2]]+v[t[e+3]]+"-"+v[t[e+4]]+v[t[e+5]]+"-"+v[t[e+6]]+v[t[e+7]]+"-"+v[t[e+8]]+v[t[e+9]]+"-"+v[t[e+10]]+v[t[e+11]]+v[t[e+12]]+v[t[e+13]]+v[t[e+14]]+v[t[e+15]]).toLowerCase();if(!y(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function _(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function b(t,e){return b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},b(t,e)}function E(t,e){if(e&&("object"===h(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function R(t){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},R(t)}var k=wp.i18n.__,w=wp.element.render;function I(e){var a="yasr-ranking-element-"+p(),r=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:a,ref:function(){return t(r,a,!1,.1,!0,e.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",k("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",k("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function x(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===c&&(c=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),c.innerHTML=t;const e=c.textContent;return c.innerHTML="",e}(t.post.title)))}function L(t){var e="after",a=k("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:a}),React.createElement(I,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(I,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:a}))}function B(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(x,{colClass:e,post:t.post}),React.createElement(L,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function T(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(B,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}(o,React.Component);var e,a,r,n,s=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=R(r);if(n){var a=R(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return E(this,t)});function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=s.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(k("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(k("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(k(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(k(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:k("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},k("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},k("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},k("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},k("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,k("Post","yet-another-stars-rating")),React.createElement("th",null,k("Order By","yet-another-stars-rating"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(T,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="table-row-group",i="none",l="most",c=o,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(T,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(T,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,k("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&_(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),o}();function j(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);w(React.createElement(S,{source:r,tableId:a,params:n,nonce:s}),o)}}j(),jQuery(document).ajaxComplete((function(t,e,a){var r=yasrCommonData.siteUrl+"/page/";a.url.includes(r)&&(function(){for(var t=["yasr-rater-stars","yasr-multiset-visitors-rater"],e=0;e<t.length;e++)n(t[e])}(),o(document.getElementsByClassName("yasr-rater-stars-vv")),j())}))})();
|
1 |
+
(()=>{"use strict";var t={593:(t,e,a)=>{let r;var n;a.d(e,{N:()=>C});var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}const i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function y(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,e){return g=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},g(t,e)}function f(t,e){if(e&&("object"===m(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(t){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},v(t)}var p=wp.i18n.__,h=wp.element.render;function b(t){var e="yasr-ranking-element-"+d(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return yasrSetRaterValue(a,e,!1,.1,!0,t.rating)}})}function _(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",p("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function E(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;const e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=p("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(_,{post:t.post,tableId:t.tableId,text:a}),React.createElement(b,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(b,{rating:t.post.rating,tableId:t.tableId}),React.createElement(_,{post:t.post,tableId:t.tableId,text:a}))}function k(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function w(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(k,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var I=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}(o,React.Component);var e,a,r,n,s=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=v(r);if(n){var a=v(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return f(this,t)});function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=s.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(t)}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(e),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(w,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="table-row-group",i="none",l="most",c=o,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(w,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(w,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),o}();function C(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);h(React.createElement(I,{source:r,tableId:a,params:n,nonce:s}),o)}}C()}},e={};function a(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,a),s.exports}a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{for(var t=wp.i18n.__,e=["yasr-rater-stars","yasr-multiset-visitors-rater"],r=0;r<e.length;r++)n(e[r]);function n(e){var a=document.getElementsByClassName(e);a.length>0&&("yasr-rater-stars"===e&&function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id,n=a.getAttribute("data-rater-starsize");yasrSetRaterValue(n,r,a)}}(a),"yasr-multiset-visitors-rater"===e&&function(e){for(var a="",r=[],n=document.getElementById("yasr-pro-multiset-review-rating"),s=0;s<e.length;s++)!function(t){if(!1===e.item(t).classList.contains("yasr-star-rating")){var s=e.item(t),o=s.id,i=s.getAttribute("data-rater-readonly"),l=s.getAttribute("data-rater-starsize");l||(l=16),i=yasrTrueFalseStringConvertion(i);yasrSetRaterValue(l,o,s,1,i,!1,(function(t,e){var o=s.getAttribute("data-rater-postid"),i=s.getAttribute("data-rater-setid"),l=s.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var c=parseInt(t);this.setRating(c),a={postid:o,setid:i,field:l,rating:c},r.push(a),n&&(n.value=JSON.stringify(r)),e()}))}}(s);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var e=this.getAttribute("data-postid"),a=this.getAttribute("data-setid"),n=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+e+"-"+a).hide(),jQuery("#yasr-loader-multiset-visitor-"+e+"-"+a).show();var s={action:"yasr_visitor_multiset_field_vote",nonce:n,post_id:e,rating:r,set_id:a};jQuery.post(yasrCommonData.ajaxurl,s).done((function(t){var r;r=(t=JSON.parse(t)).text,jQuery("#yasr-loader-multiset-visitor-"+e+"-"+a).text(r)})).fail((function(e,a,r,n){console.error(t("YASR ajax call failed. Can't save data","yet-another-stars-rating")),console.log(e)}))}))}(a))}var s=wp.i18n.__;function o(t){if(t.length>0&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rater-postid"),n=a.id,s=n.replace("yasr-visitor-votes-rater-",""),o=document.getElementById("yasr_visitor_votes_"+s),u=parseInt(a.getAttribute("data-rater-starsize")),d=a.getAttribute("data-rater-nonce"),m=a.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+s,g="yasr-vv-average-container-"+s,f="yasr-vv-bottom-container-"+s,v="yasr-vv-loader-"+s,p=document.getElementById(y),h=document.getElementById(g),b=document.getElementById(f),_=document.getElementById(v),E=a.getAttribute("data-rating"),R=a.getAttribute("data-readonly-attribute"),k=a.getAttribute("data-rater-readonly");if(null===R&&(R=!1),R=yasrTrueFalseStringConvertion(R),k=yasrTrueFalseStringConvertion(k),!0===R&&(k=!0),"yes"===yasrCommonData.ajaxEnabled){c(_);var w={action:"yasr_load_vv",post_id:r};jQuery.get(yasrCommonData.ajaxurl,w).done((function(t){var e,a=yasrValidJson(t);if(!1===a){return c(_,!1),void l(o,"Not a valid Json Element")}if(e=!0===R||a.yasr_visitor_votes.stars_attributes.read_only,E=(E=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),E=parseFloat(E),i(u,E,r,e,n,0,d,m,p,h,_,b),!0!==R&&(l(p,a.yasr_visitor_votes.number_of_votes),l(h,E),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom)){var s=a.yasr_visitor_votes.stars_attributes.span_bottom;l(b,s)}})).fail((function(t,e,a,s){console.info("YASR ajax call failed. Showing ratings from html"),i(u,E,r,k,n,0,d,m,p,h,_,b),!0!==R&&(b.style.display="")}))}else i(u,E,r,k,n,0,d,m,p,h,_,b)}}(e)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){var e=document.getElementsByClassName("yasr-dashicons-visitor-stats");e&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};"function"==typeof tippy&&tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){if(!1!==(e=yasrValidJson(e)))return"error"===e.status?(console.error(e.text),void t.setContent(e.text)):void t.setContent(u(e));t.setContent("Error!")})).fail((function(e,a,r,n){console.log(e),t.setContent("YASR ajax call failed.")}))},onHidden:function(){r=s}})}(n)}(e)}}function i(t,e,a,r,n,s,o,i,u,d,m,y){e=parseFloat(e),r=yasrTrueFalseStringConvertion(r);var g=document.getElementById(n);c(m,!1),yasrSetRaterValue(t,n,g,1,r,e,(function(t,e){c(m,!0);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r).done((function(t){if(!1===(t=yasrValidJson(t)))return c(m,!1),void l(y,"<span>Not a valid Json Element, rating can't be saved.</span>");var a,r="yasr-vote-".concat(t.status);"success"===t.status&&(l(u,t.number_of_votes),l(d,t.average_rating)),a='<span class="yasr-small-block-bold" id="'.concat(r,'"> ').concat(t.text," </span>"),l(y,a),c(m,!1),e()})).fail((function(t,e,a,r){console.error("YASR ajax call failed. Can't save data"),console.log(t)}))}))}function l(t,e){null!==t&&(t.innerHTML=e,t.style.display="")}function c(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a="";!0===e&&(a=yasrCommonData.loaderHtml),l(t,a)}function u(t){var e=t.medium_rating;delete t.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||t[r].n_of_votes>a)&&(a=t[r].n_of_votes);var n=Math.log(a)*Math.LOG10E+1|0,o="5%";n<=3&&(o="5%"),n>3&&n<=5&&(o="10%"),n>5&&(o="15%");var i='<div class="yasr-visitors-stats-tooltip">';i+='<span id="yasr-medium-rating-tooltip">'+e+" "+s("out of 5 stars","yet-another-stars-rating")+"</span>",i+='<div class="yasr-progress-bars-container">';for(var l=s("stars","yet-another-stars-rating"),c=0,u=0,d=5;d>0;d--)1===d&&(l=s("star","yet-another-stars-rating")),void 0!==t[d]&&(c=t[d].progressbar,u=t[d].n_of_votes),i+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(d," ").concat(l,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(c,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(o,' ">').concat(u,"</div>\n </div>");return i+"</div></div>"}o(document.getElementsByClassName("yasr-rater-stars-vv"));var d=a(593);jQuery(document).ajaxComplete((function(t,e,a){var r=yasrCommonData.siteUrl+"/page/";a.url.includes(r)&&(function(){for(var t=["yasr-rater-stars","yasr-multiset-visitors-rater"],e=0;e<t.length;e++)n(t[e])}(),o(document.getElementsByClassName("yasr-rater-stars-vv")),(0,d.N)())}))})()})();
|
includes/js/rater-js.min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
function raterJs(e){let t=!0;if(void 0===e.element||null===e.element)return void console.info("missing rating element");if(null!==e.element&&e.element.classList.contains("yasr-star-rating"))return;if(void 0!==e.showToolTip&&(t=!!e.showToolTip),void 0!==e.step&&(e.step<=0||e.step>1))throw new Error("step must be a number between 0 and 1");let i,a,r=5,n=e.starSize||16,s=e.step||1,l=e.onHover,o=e.onLeave,d=wp.i18n.isRTL(),u=e.element;u.classList.add("yasr-star-rating");let v=document.createElement("div");v.classList.add("yasr-star-value"),v.style.backgroundSize=n+"px",u.appendChild(v),u.style.width=n*r+"px",u.style.height=n+"px",u.style.backgroundSize=n+"px";let c,f,m,g=e.rateCallback,y=!!e.readOnly,p=!1,b=e.isBusyText;if(c=void 0!==e.disableText?e.disableText:"{rating}/{maxRating}",y||(u.style.cursor="pointer"),m=void 0!==e.ratingText?e.ratingText:"{rating}/{maxRating}",e.rating)T(e.rating);else{var h=u.dataset.rating;h&&T(+h)}function w(e){if(!0===y||!0===p)return;let a;if(!0===d){let t=this.getBoundingClientRect(),i=e.pageX-t.left,r=u.offsetWidth;a=(r-i)/(r/100)}else{a=e.offsetX/u.offsetWidth*100}if(a<101){if(1===s)f=Math.ceil(a/100*r);else{let e=a/100*r;for(let t=0;;t+=s)if(t>=e){f=t;break}}if(f>5&&(f=5),u.querySelector(".yasr-star-value").style.width=f/r*100+"%",t){let e=m.replace("{rating}",f);e=e.replace("{maxRating}",r),u.setAttribute("data-title",e)}"function"==typeof l&&l(f,i)}}function x(e){void 0!==i?(u.querySelector(".yasr-star-value").style.width=i/r*100+"%",u.setAttribute("data-rating",i)):(u.querySelector(".yasr-star-value").style.width="0%",u.removeAttribute("data-rating")),"function"==typeof o&&o(f,i)}function L(e){!0!==y&&!0!==p&&(void 0===g&&!1===typeof g||(p=!0,a=f,void 0===b?u.removeAttribute("data-title"):u.setAttribute("data-title",b),g.call(this,a,function(){!1===y&&u.removeAttribute("data-title"),p=!1})))}function A(){if(y=!0,t&&c){let e=c.replace("{rating}",i);e=e.replace("{maxRating}",r),u.setAttribute("data-title",e)}else u.removeAttribute("data-title")}function T(e){if(-1===e&&(e=void 0),"number"!=typeof e&&void 0!==e)throw new Error("Value must be a number or undefined.");e<0&&(e=0),e>5&&(e=5),i=e,u.querySelector(".yasr-star-value").style.width=e/r*100+"%",u.setAttribute("data-rating",e)}void 0===i&&(u.querySelector(".yasr-star-value").style.width="0px"),y&&A(),u.addEventListener("mousemove",w),u.addEventListener("mouseleave",x);let E={setRating:T,getRating:function(){return i},disable:A,enable:function(){y=!1,u.removeAttribute("data-title")},dispose:function(){u.removeEventListener("mousemove",w),u.removeEventListener("mouseleave",x),u.removeEventListener("click",L)}};return u.addEventListener("click",L.bind(E)),E}
|
|
includes/js/readme
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
the files
|
2 |
-
|
3 |
-
|
|
|
|
|
4 |
|
5 |
-
|
|
|
|
1 |
the files
|
2 |
+
'./includes/js/src/global_functions/rater-js-src.js',
|
3 |
+
'./includes/js/src/global_functions/yasrSetRaterValue.js',
|
4 |
+
'./includes/js/src/global_functions/yasrTrueFalseStringConvertion.js',
|
5 |
+
'./includes/js/src/global_functions/yasrValidJson.js'
|
6 |
|
7 |
+
are just minified and compil
|
8 |
+
|
9 |
+
the files inside includes/js/src/global_functions are compiled with npm run concat-global
|
includes/js/shortcodes/overall-multiset.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";
|
1 |
+
(()=>{"use strict";const{__:t}=wp.i18n,e=["yasr-rater-stars","yasr-multiset-visitors-rater"];for(let t=0;t<e.length;t++)r(e[t]);function r(e){const r=document.getElementsByClassName(e);r.length>0&&("yasr-rater-stars"===e&&function(t){for(let e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){const r=t.item(e),s=r.id,a=r.getAttribute("data-rater-starsize");yasrSetRaterValue(a,s,r)}}(r),"yasr-multiset-visitors-rater"===e&&function(e){var r="",s=[];const a=document.getElementById("yasr-pro-multiset-review-rating");for(let t=0;t<e.length;t++)!function(t){if(!1!==e.item(t).classList.contains("yasr-star-rating"))return;let i=e.item(t),n=i.id,o=i.getAttribute("data-rater-readonly"),l=i.getAttribute("data-rater-starsize");l||(l=16),o=yasrTrueFalseStringConvertion(o);yasrSetRaterValue(l,n,i,1,o,!1,(function(t,e){const n=i.getAttribute("data-rater-postid"),o=i.getAttribute("data-rater-setid"),l=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);const u=parseInt(t);this.setRating(u),r={postid:n,setid:o,field:l,rating:u},s.push(r),a&&(a.value=JSON.stringify(s)),e()}))}(t);jQuery(".yasr-send-visitor-multiset").on("click",(function(){const e=this.getAttribute("data-postid"),r=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+e+"-"+r).hide(),jQuery("#yasr-loader-multiset-visitor-"+e+"-"+r).show();const i={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:e,rating:s,set_id:r};jQuery.post(yasrCommonData.ajaxurl,i).done((function(t){let s;s=(t=JSON.parse(t)).text,jQuery("#yasr-loader-multiset-visitor-"+e+"-"+r).text(s)})).fail((function(e,r,s,a){console.error(t("YASR ajax call failed. Can't save data","yet-another-stars-rating")),console.log(e)}))}))}(r))}})();
|
includes/js/shortcodes/rankings.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";let t;var e,a=new Uint8Array(16);function r(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(a)}const n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,o=function(t){return"string"==typeof t&&n.test(t)};for(var s=[],i=0;i<256;++i)s.push((i+256).toString(16).substr(1));const l=function(t,e,a){var n=(t=t||{}).random||(t.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var i=0;i<16;++i)e[a+i]=n[i];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase();if(!o(a))throw TypeError("Stringified UUID is invalid");return a}(n)};function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function u(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e){return d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},d(t,e)}function m(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}var h=wp.i18n.__,f=wp.element.render;function p(t){var e="yasr-ranking-element-"+l(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return function(t,e){var a,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:r,readOnly:n,rating:o,rateCallback:s})}(a,e,!1,.1,!0,t.rating)}})}function y(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",h("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",h("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function v(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===t&&(t=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),t.innerHTML=e;const a=t.textContent;return t.innerHTML="",a}(e.post.title)))}function b(t){var e="after",a=h("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(y,{post:t.post,tableId:t.tableId,text:a}),React.createElement(p,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(p,{rating:t.post.rating,tableId:t.tableId}),React.createElement(y,{post:t.post,tableId:t.tableId,text:a}))}function R(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(v,{colClass:e,post:t.post}),React.createElement(b,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function E(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(R,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var _=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(s,React.Component);var e,a,r,n,o=(r=s,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=g(r);if(n){var a=g(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return m(this,t)});function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=o.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(h("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(h("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(h(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(h(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:h("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("start_date")&&"0"!==o.get("start_date")&&(n+="&start_date="+o.get("start_date")),null!==o.get("end_date")&&"0"!==o.get("end_date")&&(n+="&end_date="+o.get("end_date")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+s+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:r},h("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},h("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},h("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},h("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,h("Post","yet-another-stars-rating")),React.createElement("th",null,h("Order By","yet-another-stars-rating"),": ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,o="most-rated-posts-"+a,s="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,o=e.highest,s="table-row-group",i="none",l="most",c=s,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=s),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(E,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,h("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&u(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),s}();!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=JSON.parse(t.item(e).dataset.rankingNonce),s=document.getElementById(a);f(React.createElement(_,{source:r,tableId:a,params:n,nonce:o}),s)}}()})();
|
1 |
+
(()=>{"use strict";let t;var e,a=new Uint8Array(16);function r(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(a)}const n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,o=function(t){return"string"==typeof t&&n.test(t)};for(var s=[],i=0;i<256;++i)s.push((i+256).toString(16).substr(1));const l=function(t,e,a){var n=(t=t||{}).random||(t.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var i=0;i<16;++i)e[a+i]=n[i];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase();if(!o(a))throw TypeError("Stringified UUID is invalid");return a}(n)};function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function u(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e){return d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},d(t,e)}function m(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}var f=wp.i18n.__,p=wp.element.render;function h(t){var e="yasr-ranking-element-"+l(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return yasrSetRaterValue(a,e,!1,.1,!0,t.rating)}})}function y(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",f("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",f("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function b(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===t&&(t=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),t.innerHTML=e;const a=t.textContent;return t.innerHTML="",a}(e.post.title)))}function v(t){var e="after",a=f("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(y,{post:t.post,tableId:t.tableId,text:a}),React.createElement(h,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(h,{rating:t.post.rating,tableId:t.tableId}),React.createElement(y,{post:t.post,tableId:t.tableId,text:a}))}function R(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(b,{colClass:e,post:t.post}),React.createElement(v,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function E(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(R,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var _=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(s,React.Component);var e,a,r,n,o=(r=s,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=g(r);if(n){var a=g(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return m(this,t)});function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=o.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(t)}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(e),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("start_date")&&"0"!==o.get("start_date")&&(n+="&start_date="+o.get("start_date")),null!==o.get("end_date")&&"0"!==o.get("end_date")&&(n+="&end_date="+o.get("end_date")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+s+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:r},f("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},f("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},f("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},f("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,f("Post","yet-another-stars-rating")),React.createElement("th",null,f("Order By","yet-another-stars-rating"),": ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,o="most-rated-posts-"+a,s="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,o=e.highest,s="table-row-group",i="none",l="most",c=s,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=s),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(E,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,f("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&u(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),s}();!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=JSON.parse(t.item(e).dataset.rankingNonce),s=document.getElementById(a);p(React.createElement(_,{source:r,tableId:a,params:n,nonce:o}),s)}}()})();
|
includes/js/shortcodes/visitorVotes.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(()=>{"use strict";
|
1 |
+
(()=>{"use strict";const{__:t}=wp.i18n;function e(t,e,r,o,n,i,l,d,u,y,v,c){e=parseFloat(e),o=yasrTrueFalseStringConvertion(o);const m=document.getElementById(n);s(v,!1),yasrSetRaterValue(t,n,m,1,o,e,(function(t,e){s(v,!0);const o={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:l,is_singular:d};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,o).done((function(t){if(!1===(t=yasrValidJson(t)))return s(v,!1),void a(c,"<span>Not a valid Json Element, rating can't be saved.</span>");let r,o=`yasr-vote-${t.status}`;"success"===t.status&&(a(u,t.number_of_votes),a(y,t.average_rating)),r=`<span class="yasr-small-block-bold" id="${o}"> ${t.text} </span>`,a(c,r),s(v,!1),e()})).fail((function(t,e,a,s){console.error("YASR ajax call failed. Can't save data"),console.log(t)}))}))}function a(t,e){null!==t&&(t.innerHTML=e,t.style.display="")}function s(t,e=!0){let s="";!0===e&&(s=yasrCommonData.loaderHtml),a(t,s)}function r(e){const a=e.medium_rating;delete e.medium_rating;let s=0;for(let t=1;t<=5;t++)(1===t||e[t].n_of_votes>s)&&(s=e[t].n_of_votes);let r=Math.log(s)*Math.LOG10E+1|0,o="5%";r<=3&&(o="5%"),r>3&&r<=5&&(o="10%"),r>5&&(o="15%");let n='<div class="yasr-visitors-stats-tooltip">';n+='<span id="yasr-medium-rating-tooltip">'+a+" "+t("out of 5 stars","yet-another-stars-rating")+"</span>",n+='<div class="yasr-progress-bars-container">';let i=t("stars","yet-another-stars-rating"),l=0,d=0;for(let a=5;a>0;a--)1===a&&(i=t("star","yet-another-stars-rating")),void 0!==e[a]&&(l=e[a].progressbar,d=e[a].n_of_votes),n+=`<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>${a} ${i}</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:${l}'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style="flex-basis:${o} ">${d}</div>\n </div>`;return n+="</div></div>",n}!function(t){if(t.length>0&&(function(t){for(let r=0;r<t.length;r++)!function(r){if(!1!==t.item(r).classList.contains("yasr-star-rating"))return;const o=t.item(r),n=o.getAttribute("data-rater-postid"),i=o.id,l=i.replace("yasr-visitor-votes-rater-",""),d=document.getElementById("yasr_visitor_votes_"+l),u=parseInt(o.getAttribute("data-rater-starsize")),y=o.getAttribute("data-rater-nonce"),v=o.getAttribute("data-issingular"),c="yasr-vv-votes-number-container-"+l,m="yasr-vv-average-container-"+l,g="yasr-vv-bottom-container-"+l,_="yasr-vv-loader-"+l,f=document.getElementById(c),p=document.getElementById(m),b=document.getElementById(g),h=document.getElementById(_);let C=o.getAttribute("data-rating"),E=o.getAttribute("data-readonly-attribute"),x=o.getAttribute("data-rater-readonly");if(null===E&&(E=!1),E=yasrTrueFalseStringConvertion(E),x=yasrTrueFalseStringConvertion(x),!0===E&&(x=!0),"yes"===yasrCommonData.ajaxEnabled){s(h);let t={action:"yasr_load_vv",post_id:n};jQuery.get(yasrCommonData.ajaxurl,t).done((function(t){let r,o=yasrValidJson(t);if(!1===o){let t="Not a valid Json Element";return s(h,!1),void a(d,t)}if(r=!0===E||o.yasr_visitor_votes.stars_attributes.read_only,C=o.yasr_visitor_votes.number_of_votes>0?o.yasr_visitor_votes.sum_votes/o.yasr_visitor_votes.number_of_votes:0,C=C.toFixed(1),C=parseFloat(C),e(u,C,n,r,i,0,y,v,f,p,h,b),!0!==E&&(a(f,o.yasr_visitor_votes.number_of_votes),a(p,C),!1!==o.yasr_visitor_votes.stars_attributes.span_bottom)){let t=o.yasr_visitor_votes.stars_attributes.span_bottom;a(b,t)}})).fail((function(t,a,s,r){console.info("YASR ajax call failed. Showing ratings from html"),e(u,C,n,x,i,0,y,v,f,p,h,b),!0!==E&&(b.style.display="")}))}else e(u,C,n,x,i,0,y,v,f,p,h,b)}(r)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){let t=document.getElementsByClassName("yasr-dashicons-visitor-stats");t&&function(t){let e,a,s=!1;for(let o=0;o<t.length;o++)!function(o){let n="#"+t.item(o).id,i=t.item(o).getAttribute("data-postid");0===o&&(e=document.getElementsByClassName("yasr-vv-text-container"),null!==e&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color"))),a&&(document.getElementById(t.item(o).id).style.fill=a);let l={action:"yasr_stats_visitors_votes",post_id:i};"function"==typeof tippy&&tippy(n,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){n!==s&&jQuery.post(yasrCommonData.ajaxurl,l,(function(e){if(!1!==(e=yasrValidJson(e)))return"error"===e.status?(console.error(e.text),void t.setContent(e.text)):void t.setContent(r(e));t.setContent("Error!")})).fail((function(e,a,s,r){console.log(e),t.setContent("YASR ajax call failed.")}))},onHidden:function(){s=n}})}(o)}(t)}}(document.getElementsByClassName("yasr-rater-stars-vv"))})();
|
includes/js/shortcodes/yasr-log-users-fronted.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function(){jQuery(".yasr-user-log-page-num").on("click",function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,function(a){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(a)})}),jQuery(document).ajaxComplete(function(a,e,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_user_log_page_front")&&jQuery(".yasr-user-log-page-num").on("click",function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,function(a){jQuery("#yasr-user-log-container").html(a)})})})});
|
|
includes/js/shortcodes/yasr-log-users-frontend.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,(function(a){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(a)}))})),jQuery(document).ajaxComplete((function(a,e,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_user_log_page_front")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,(function(a){jQuery("#yasr-user-log-container").html(a)}))}))}))}));
|
includes/js/src/{rater-js-src.js → global_functions/rater-js-src.js}
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
-
|
2 |
-
function
|
3 |
//private fields
|
4 |
let showToolTip = true;
|
5 |
|
@@ -28,8 +28,7 @@ function raterJs(options) {
|
|
28 |
let step = options.step || 1;
|
29 |
let onHover = options.onHover;
|
30 |
let onLeave = options.onLeave;
|
31 |
-
let isRtl =
|
32 |
-
|
33 |
let rating;
|
34 |
let myRating;
|
35 |
let elem = options.element;
|
1 |
+
/*Based on rater-js. [c] 2018 by Fredrik Olsson. MIT License */
|
2 |
+
window.raterJs = function(options) {
|
3 |
//private fields
|
4 |
let showToolTip = true;
|
5 |
|
28 |
let step = options.step || 1;
|
29 |
let onHover = options.onHover;
|
30 |
let onLeave = options.onLeave;
|
31 |
+
let isRtl = yasrTrueFalseStringConvertion(yasrCommonData.isRtl);
|
|
|
32 |
let rating;
|
33 |
let myRating;
|
34 |
let elem = options.element;
|
includes/js/src/{modules → global_functions}/yasrSetRaterValue.js
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
//this is the function that print the overall rating shortcode, get overall rating and starsize
|
2 |
-
|
3 |
htmlId,
|
4 |
element=false,
|
5 |
step=0.1,
|
1 |
//this is the function that print the overall rating shortcode, get overall rating and starsize
|
2 |
+
window.yasrSetRaterValue = function (starSize,
|
3 |
htmlId,
|
4 |
element=false,
|
5 |
step=0.1,
|
includes/js/src/{modules → global_functions}/yasrTrueFalseStringConvertion.js
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
-
|
2 |
|
3 |
if (typeof string === 'undefined' || string === null || string === '') {
|
4 |
-
string =
|
5 |
}
|
6 |
|
7 |
//Convert string to boolean
|
1 |
+
window.yasrTrueFalseStringConvertion = function (string) {
|
2 |
|
3 |
if (typeof string === 'undefined' || string === null || string === '') {
|
4 |
+
string = false;
|
5 |
}
|
6 |
|
7 |
//Convert string to boolean
|
includes/js/src/global_functions/yasrValidJson.js
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
//from https://stackoverflow.com/questions/3710204/how-to-check-if-a-string-is-a-valid-json-string
|
2 |
+
//This file doesn't use webpack, it is just minified for production
|
3 |
+
|
4 |
+
/**
|
5 |
+
* If you don't care about primitives and only objects then this function
|
6 |
+
* is for you, otherwise look elsewhere.
|
7 |
+
* This function will return `false` for any valid json primitive.
|
8 |
+
* EG, 'true' -> false
|
9 |
+
* '123' -> false
|
10 |
+
* 'null' -> false
|
11 |
+
* '"I'm a string"' -> false
|
12 |
+
*/
|
13 |
+
window.yasrValidJson = function(jsonString) {
|
14 |
+
try {
|
15 |
+
const o = JSON.parse(jsonString);
|
16 |
+
|
17 |
+
// Handle non-exception-throwing cases:
|
18 |
+
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
|
19 |
+
// but... JSON.parse(null) returns null, and typeof null === "object",
|
20 |
+
// so we must check for that, too. Thankfully, null is falsey, so this suffices:
|
21 |
+
if (o && typeof o === "object") {
|
22 |
+
return o;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
catch (e) {
|
26 |
+
console.error('Not a valid Json Element');
|
27 |
+
console.log(e)
|
28 |
+
}
|
29 |
+
|
30 |
+
return false;
|
31 |
+
}
|
includes/js/src/shortcodes/overall-multiset.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1 |
const { __ } = wp.i18n; // Import __() from wp.i181n
|
2 |
const arrayClasses = ['yasr-rater-stars', 'yasr-multiset-visitors-rater'];
|
3 |
|
4 |
-
import {yasrSetRaterValue} from "../modules/yasrSetRaterValue";
|
5 |
-
import {yasrTrueFalseStringConvertion} from "../modules/yasrTrueFalseStringConvertion";
|
6 |
-
|
7 |
/*** Constant used by yasr
|
8 |
yasrCommonData (ajaxurl, isrtl)
|
9 |
***/
|
@@ -120,7 +117,7 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
|
|
120 |
jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
|
121 |
jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
|
122 |
|
123 |
-
|
124 |
action: 'yasr_visitor_multiset_field_vote',
|
125 |
nonce: nonce,
|
126 |
post_id: multiSetPostId,
|
@@ -129,13 +126,18 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
|
|
129 |
};
|
130 |
|
131 |
//Send value to the Server
|
132 |
-
jQuery.post(yasrCommonData.ajaxurl, data
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
});
|
141 |
|
1 |
const { __ } = wp.i18n; // Import __() from wp.i181n
|
2 |
const arrayClasses = ['yasr-rater-stars', 'yasr-multiset-visitors-rater'];
|
3 |
|
|
|
|
|
|
|
4 |
/*** Constant used by yasr
|
5 |
yasrCommonData (ajaxurl, isrtl)
|
6 |
***/
|
117 |
jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
|
118 |
jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
|
119 |
|
120 |
+
const data = {
|
121 |
action: 'yasr_visitor_multiset_field_vote',
|
122 |
nonce: nonce,
|
123 |
post_id: multiSetPostId,
|
126 |
};
|
127 |
|
128 |
//Send value to the Server
|
129 |
+
jQuery.post(yasrCommonData.ajaxurl, data).done(
|
130 |
+
function(response) {
|
131 |
+
let responseText;
|
132 |
+
response = JSON.parse(response);
|
133 |
+
responseText = response.text
|
134 |
+
|
135 |
+
jQuery('#yasr-loader-multiset-visitor-' + multiSetPostId + '-' + multiSetId).text(responseText);
|
136 |
+
}).fail(
|
137 |
+
function(e, x, settings, exception) {
|
138 |
+
console.error(__('YASR ajax call failed. Can\'t save data', 'yet-another-stars-rating'));
|
139 |
+
console.log(e);
|
140 |
+
});
|
141 |
|
142 |
});
|
143 |
|
includes/js/src/shortcodes/ranking.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import {decodeEntities} from "@wordpress/html-entities";
|
2 |
import {v4 as uuidv4} from 'uuid';
|
3 |
-
import {yasrSetRaterValue} from '../modules/yasrSetRaterValue';
|
4 |
|
5 |
const { __ } = wp.i18n; // Import __() from wp.i18n
|
6 |
const {render} = wp.element;
|
@@ -226,7 +225,7 @@ class YasrRanking extends React.Component {
|
|
226 |
|
227 |
//If ajax is disabled, use global value
|
228 |
if(yasrCommonData.ajaxEnabled !== 'yes') {
|
229 |
-
console.info(
|
230 |
this.setState({
|
231 |
isLoaded: true,
|
232 |
data: rankingData
|
@@ -242,7 +241,7 @@ class YasrRanking extends React.Component {
|
|
242 |
if (response.ok === true) {
|
243 |
return response.json();
|
244 |
} else {
|
245 |
-
console.info(
|
246 |
return 'KO';
|
247 |
}
|
248 |
})
|
@@ -270,7 +269,7 @@ class YasrRanking extends React.Component {
|
|
270 |
})
|
271 |
.catch((error) => {
|
272 |
data = rankingData;
|
273 |
-
console.info(
|
274 |
})
|
275 |
))
|
276 |
//At the end of promise all, data can be from rest api or global var
|
@@ -281,7 +280,7 @@ class YasrRanking extends React.Component {
|
|
281 |
});
|
282 |
})
|
283 |
.catch((error) => {
|
284 |
-
console.info(
|
285 |
this.setState({
|
286 |
isLoaded: true,
|
287 |
data: data
|
@@ -290,7 +289,7 @@ class YasrRanking extends React.Component {
|
|
290 |
|
291 |
} else {
|
292 |
this.setState({
|
293 |
-
error:
|
294 |
});
|
295 |
}
|
296 |
}
|
1 |
import {decodeEntities} from "@wordpress/html-entities";
|
2 |
import {v4 as uuidv4} from 'uuid';
|
|
|
3 |
|
4 |
const { __ } = wp.i18n; // Import __() from wp.i18n
|
5 |
const {render} = wp.element;
|
225 |
|
226 |
//If ajax is disabled, use global value
|
227 |
if(yasrCommonData.ajaxEnabled !== 'yes') {
|
228 |
+
console.info('Ajax Disabled, getting data from source');
|
229 |
this.setState({
|
230 |
isLoaded: true,
|
231 |
data: rankingData
|
241 |
if (response.ok === true) {
|
242 |
return response.json();
|
243 |
} else {
|
244 |
+
console.info('Ajax Call Failed. Getting data from source')
|
245 |
return 'KO';
|
246 |
}
|
247 |
})
|
269 |
})
|
270 |
.catch((error) => {
|
271 |
data = rankingData;
|
272 |
+
console.info(error);
|
273 |
})
|
274 |
))
|
275 |
//At the end of promise all, data can be from rest api or global var
|
280 |
});
|
281 |
})
|
282 |
.catch((error) => {
|
283 |
+
console.info((error));
|
284 |
this.setState({
|
285 |
isLoaded: true,
|
286 |
data: data
|
289 |
|
290 |
} else {
|
291 |
this.setState({
|
292 |
+
error: ('Invalid Data Source')
|
293 |
});
|
294 |
}
|
295 |
}
|
includes/js/src/shortcodes/visitorVotes.js
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
const { __ } = wp.i18n; // Import __() from wp.i181n
|
2 |
-
import {yasrSetRaterValue} from "../modules/yasrSetRaterValue";
|
3 |
-
import {yasrTrueFalseStringConvertion} from "../modules/yasrTrueFalseStringConvertion";
|
4 |
|
5 |
const yasrRaterInDom = document.getElementsByClassName('yasr-rater-stars-vv');
|
6 |
|
@@ -32,10 +30,25 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
32 |
return;
|
33 |
}
|
34 |
|
35 |
-
const elem
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
if (readonlyShortcode === null) {
|
41 |
readonlyShortcode = false;
|
@@ -49,27 +62,8 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
49 |
readonly = true;
|
50 |
}
|
51 |
|
52 |
-
let postId = elem.getAttribute('data-rater-postid');
|
53 |
-
let htmlId = elem.id;
|
54 |
-
let uniqueId = htmlId.replace('yasr-visitor-votes-rater-', '');
|
55 |
-
let starSize = parseInt(elem.getAttribute('data-rater-starsize'));
|
56 |
-
let nonce = elem.getAttribute('data-rater-nonce');
|
57 |
-
let isSingular = elem.getAttribute('data-issingular');
|
58 |
-
|
59 |
-
let containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
|
60 |
-
let containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
|
61 |
-
let bottomContainerName = 'yasr-vv-bottom-container-' + uniqueId;
|
62 |
-
let loaderContainerName = 'yasr-vv-loader-' + uniqueId;
|
63 |
-
const containerVotesNumber = document.getElementById(containerVotesNumberName);
|
64 |
-
const containerAverageNumber = document.getElementById(containerAverageNumberName);
|
65 |
-
const bottomContainer = document.getElementById(bottomContainerName);
|
66 |
-
const loaderContainer = document.getElementById(loaderContainerName);
|
67 |
-
|
68 |
if(yasrCommonData.ajaxEnabled === 'yes') {
|
69 |
-
|
70 |
-
if(loaderContainer !== null) {
|
71 |
-
loaderContainer.innerHTML = yasrCommonData.loaderHtml;
|
72 |
-
}
|
73 |
|
74 |
let data = {
|
75 |
action: 'yasr_load_vv',
|
@@ -78,7 +72,15 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
78 |
|
79 |
jQuery.get(yasrCommonData.ajaxurl, data).done(
|
80 |
function (response) {
|
81 |
-
let data =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
let readonly;
|
83 |
//if has readonly attribute, it is always true
|
84 |
if(readonlyShortcode === true) {
|
@@ -100,24 +102,19 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
100 |
|
101 |
//do this only if yasr_visitor_votes has not the readonly attribute
|
102 |
if(readonlyShortcode !== true) {
|
103 |
-
|
104 |
-
|
105 |
-
}
|
106 |
-
if(containerAverageNumber !== null) {
|
107 |
-
containerAverageNumber.innerHTML = rating;
|
108 |
-
}
|
109 |
|
110 |
//insert span with text after the average
|
111 |
-
if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false
|
112 |
-
|
113 |
-
bottomContainer
|
114 |
-
bottomContainer.style.display = '';
|
115 |
}
|
116 |
}
|
117 |
|
118 |
}).fail(
|
119 |
function(e, x, settings, exception) {
|
120 |
-
console.info(
|
121 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
122 |
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer);
|
123 |
|
@@ -126,7 +123,10 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
126 |
bottomContainer.style.display = '';
|
127 |
}
|
128 |
});
|
129 |
-
}
|
|
|
|
|
|
|
130 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
131 |
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer);
|
132 |
}
|
@@ -163,18 +163,14 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
|
|
163 |
|
164 |
const elem = document.getElementById(htmlId);
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
loaderContainer.innerHTML = '';
|
169 |
-
}
|
170 |
let rateCallback = function (rating, done) {
|
171 |
//show the loader
|
172 |
-
|
173 |
-
loaderContainer.innerHTML = yasrCommonData.loaderHtml;
|
174 |
-
}
|
175 |
|
176 |
//Creating an object with data to send
|
177 |
-
|
178 |
action: 'yasr_send_visitor_rating',
|
179 |
rating: rating,
|
180 |
post_id: postId,
|
@@ -186,50 +182,68 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
|
|
186 |
this.disable();
|
187 |
|
188 |
//Send value to the Server
|
189 |
-
jQuery.post(yasrCommonData.ajaxurl, data
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
if(response.status === 'success') {
|
198 |
-
number_of_votes = response.number_of_votes;
|
199 |
-
average_rating = response.average_rating;
|
200 |
-
text = response.rating_saved_text;
|
201 |
-
|
202 |
-
//Update the ratings only if response is success
|
203 |
-
if (containerVotesNumber !== null) {
|
204 |
-
containerVotesNumber.innerHTML = number_of_votes;
|
205 |
}
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
}
|
209 |
-
} else {
|
210 |
-
//get response error
|
211 |
-
text = response.text;
|
212 |
-
}
|
213 |
|
214 |
-
|
215 |
-
bottomContainer.innerHTML = text;
|
216 |
-
//Be sure the bottom container is showed
|
217 |
-
bottomContainer.style.display = '';
|
218 |
-
}
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
loaderContainer
|
223 |
-
}
|
224 |
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
227 |
}
|
228 |
|
229 |
yasrSetRaterValue (starSize, htmlId, elem, 1, readonly, rating, rateCallback);
|
230 |
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
/****** Tooltip functions ******/
|
235 |
|
@@ -271,28 +285,47 @@ function yasrVvStats (yasrStatsInDom) {
|
|
271 |
|
272 |
let initialContent = '<span style="color: #0a0a0a">Loading...</span>';
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
290 |
-
},
|
291 |
-
onHidden: function onHidden() {
|
292 |
-
htmlIdChecked = htmlId;
|
293 |
-
}
|
294 |
|
295 |
-
|
|
|
296 |
|
297 |
})(i);
|
298 |
}
|
@@ -360,7 +393,7 @@ function yasrReturnToolbarStats (ratings) {
|
|
360 |
//Later, I need to get the number of digits of the highest number
|
361 |
let lengthHighestNumberOfVotes = Math.log(highestNumberOfVotes) * Math.LOG10E + 1 | 0;
|
362 |
|
363 |
-
//Later, I've to calculate the flexbasis based on the
|
364 |
//default flexbasis is 5%
|
365 |
let flexbasis = '5%'
|
366 |
|
1 |
const { __ } = wp.i18n; // Import __() from wp.i181n
|
|
|
|
|
2 |
|
3 |
const yasrRaterInDom = document.getElementsByClassName('yasr-rater-stars-vv');
|
4 |
|
30 |
return;
|
31 |
}
|
32 |
|
33 |
+
const elem = yasrRaterVVInDom.item(i);
|
34 |
+
const postId = elem.getAttribute('data-rater-postid');
|
35 |
+
const htmlId = elem.id;
|
36 |
+
const uniqueId = htmlId.replace('yasr-visitor-votes-rater-', '');
|
37 |
+
const mainContianer = document.getElementById('yasr_visitor_votes_' + uniqueId);
|
38 |
+
const starSize = parseInt(elem.getAttribute('data-rater-starsize'));
|
39 |
+
const nonce = elem.getAttribute('data-rater-nonce');
|
40 |
+
const isSingular = elem.getAttribute('data-issingular');
|
41 |
+
const containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
|
42 |
+
const containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
|
43 |
+
const bottomContainerName = 'yasr-vv-bottom-container-' + uniqueId;
|
44 |
+
const loaderContainerName = 'yasr-vv-loader-' + uniqueId;
|
45 |
+
const containerVotesNumber = document.getElementById(containerVotesNumberName);
|
46 |
+
const containerAverageNumber = document.getElementById(containerAverageNumberName);
|
47 |
+
const bottomContainer = document.getElementById(bottomContainerName);
|
48 |
+
const loaderContainer = document.getElementById(loaderContainerName);
|
49 |
+
let rating = elem.getAttribute('data-rating');
|
50 |
+
let readonlyShortcode = elem.getAttribute('data-readonly-attribute');
|
51 |
+
let readonly = elem.getAttribute('data-rater-readonly');
|
52 |
|
53 |
if (readonlyShortcode === null) {
|
54 |
readonlyShortcode = false;
|
62 |
readonly = true;
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
if(yasrCommonData.ajaxEnabled === 'yes') {
|
66 |
+
yasrLoader(loaderContainer);
|
|
|
|
|
|
|
67 |
|
68 |
let data = {
|
69 |
action: 'yasr_load_vv',
|
72 |
|
73 |
jQuery.get(yasrCommonData.ajaxurl, data).done(
|
74 |
function (response) {
|
75 |
+
let data = yasrValidJson(response);
|
76 |
+
|
77 |
+
if(data === false) {
|
78 |
+
let jsonError = 'Not a valid Json Element';
|
79 |
+
yasrLoader(loaderContainer, false)
|
80 |
+
yasrInnerHtml(mainContianer, jsonError);
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
let readonly;
|
85 |
//if has readonly attribute, it is always true
|
86 |
if(readonlyShortcode === true) {
|
102 |
|
103 |
//do this only if yasr_visitor_votes has not the readonly attribute
|
104 |
if(readonlyShortcode !== true) {
|
105 |
+
yasrInnerHtml(containerVotesNumber, data.yasr_visitor_votes.number_of_votes);
|
106 |
+
yasrInnerHtml(containerAverageNumber, rating);
|
|
|
|
|
|
|
|
|
107 |
|
108 |
//insert span with text after the average
|
109 |
+
if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false) {
|
110 |
+
let text = data.yasr_visitor_votes.stars_attributes.span_bottom;
|
111 |
+
yasrInnerHtml(bottomContainer, text);
|
|
|
112 |
}
|
113 |
}
|
114 |
|
115 |
}).fail(
|
116 |
function(e, x, settings, exception) {
|
117 |
+
console.info('YASR ajax call failed. Showing ratings from html');
|
118 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
119 |
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer);
|
120 |
|
123 |
bottomContainer.style.display = '';
|
124 |
}
|
125 |
});
|
126 |
+
}
|
127 |
+
|
128 |
+
//When ajax is not enabled, just set the star rating
|
129 |
+
else {
|
130 |
yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
|
131 |
containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer);
|
132 |
}
|
163 |
|
164 |
const elem = document.getElementById(htmlId);
|
165 |
|
166 |
+
yasrLoader(loaderContainer, false);
|
167 |
+
|
|
|
|
|
168 |
let rateCallback = function (rating, done) {
|
169 |
//show the loader
|
170 |
+
yasrLoader(loaderContainer, true);
|
|
|
|
|
171 |
|
172 |
//Creating an object with data to send
|
173 |
+
const data = {
|
174 |
action: 'yasr_send_visitor_rating',
|
175 |
rating: rating,
|
176 |
post_id: postId,
|
182 |
this.disable();
|
183 |
|
184 |
//Send value to the Server
|
185 |
+
jQuery.post(yasrCommonData.ajaxurl, data).done(
|
186 |
+
function (response) {
|
187 |
+
response = yasrValidJson(response);
|
188 |
+
|
189 |
+
if(response === false) {
|
190 |
+
yasrLoader(loaderContainer, false)
|
191 |
+
yasrInnerHtml(bottomContainer, "<span>Not a valid Json Element, rating can't be saved.</span>");
|
192 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
}
|
194 |
+
|
195 |
+
let text;
|
196 |
+
let responseSpanId = `yasr-vote-${response.status}`;
|
197 |
+
|
198 |
+
if (response.status === 'success') {
|
199 |
+
//Update the ratings only if response is success
|
200 |
+
yasrInnerHtml(containerVotesNumber, response.number_of_votes)
|
201 |
+
yasrInnerHtml(containerAverageNumber, response.average_rating)
|
202 |
}
|
|
|
|
|
|
|
|
|
203 |
|
204 |
+
text = `<span class="yasr-small-block-bold" id="${responseSpanId}"> ${response.text} </span>`;
|
|
|
|
|
|
|
|
|
205 |
|
206 |
+
yasrInnerHtml(bottomContainer, text);
|
207 |
+
|
208 |
+
yasrLoader(loaderContainer, false);
|
|
|
209 |
|
210 |
+
done();
|
211 |
+
|
212 |
+
}).fail(
|
213 |
+
function(e, x, settings, exception) {
|
214 |
+
console.error('YASR ajax call failed. Can\'t save data');
|
215 |
+
console.log(e);
|
216 |
+
});
|
217 |
}
|
218 |
|
219 |
yasrSetRaterValue (starSize, htmlId, elem, 1, readonly, rating, rateCallback);
|
220 |
|
221 |
}
|
222 |
|
223 |
+
function yasrInnerHtml(htmlContainer, htmlChild) {
|
224 |
+
if (htmlContainer !== null) {
|
225 |
+
htmlContainer.innerHTML = htmlChild;
|
226 |
+
//Be sure the bottom container is showed
|
227 |
+
htmlContainer.style.display = '';
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Show or hide the laoder
|
233 |
+
*
|
234 |
+
* since 3.0.4
|
235 |
+
* @param loaderContainer
|
236 |
+
* @param show
|
237 |
+
*/
|
238 |
+
function yasrLoader(loaderContainer, show=true) {
|
239 |
+
let loader = '';
|
240 |
+
|
241 |
+
if(show === true) {
|
242 |
+
loader = yasrCommonData.loaderHtml;
|
243 |
+
}
|
244 |
+
|
245 |
+
yasrInnerHtml(loaderContainer, loader);
|
246 |
+
}
|
247 |
|
248 |
/****** Tooltip functions ******/
|
249 |
|
285 |
|
286 |
let initialContent = '<span style="color: #0a0a0a">Loading...</span>';
|
287 |
|
288 |
+
if (typeof tippy === "function") {
|
289 |
+
tippy(htmlId, {
|
290 |
+
allowHTML: true,
|
291 |
+
content: initialContent,
|
292 |
+
theme: 'yasr',
|
293 |
+
arrow: true,
|
294 |
+
arrowType: 'round',
|
295 |
+
|
296 |
+
//When support for IE will be dropped out, this will become onShow(tip)
|
297 |
+
onShow: function onShow(tip) {
|
298 |
+
if (htmlId !== htmlIdChecked) {
|
299 |
+
//must be post or wont work
|
300 |
+
jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
|
301 |
+
response = yasrValidJson(response);
|
302 |
+
|
303 |
+
if(response === false) {
|
304 |
+
tip.setContent('Error!');
|
305 |
+
return;
|
306 |
+
}
|
307 |
+
|
308 |
+
if(response.status === 'error') {
|
309 |
+
console.error(response.text);
|
310 |
+
tip.setContent(response.text);
|
311 |
+
return;
|
312 |
+
}
|
313 |
+
|
314 |
+
tip.setContent(yasrReturnToolbarStats(response));
|
315 |
+
}).fail(
|
316 |
+
function(e, x, settings, exception) {
|
317 |
+
let errorText = 'YASR ajax call failed.'
|
318 |
+
console.log(e);
|
319 |
+
tip.setContent(errorText);
|
320 |
+
});
|
321 |
+
}
|
322 |
+
},
|
323 |
+
onHidden: function onHidden() {
|
324 |
+
htmlIdChecked = htmlId;
|
325 |
}
|
|
|
|
|
|
|
|
|
326 |
|
327 |
+
});
|
328 |
+
}
|
329 |
|
330 |
})(i);
|
331 |
}
|
393 |
//Later, I need to get the number of digits of the highest number
|
394 |
let lengthHighestNumberOfVotes = Math.log(highestNumberOfVotes) * Math.LOG10E + 1 | 0;
|
395 |
|
396 |
+
//Later, I've to calculate the flexbasis based on the length of the number
|
397 |
//default flexbasis is 5%
|
398 |
let flexbasis = '5%'
|
399 |
|
includes/js/src/shortcodes/{yasr-log-users-fronted.js → yasr-log-users-frontend.js}
RENAMED
File without changes
|
includes/js/yasr-globals.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
window.yasrTrueFalseStringConvertion=function(e){return null!=e&&""!==e||(e=!1),"true"!==e&&"1"!==e||(e=!0),"false"!==e&&"0"!==e||(e=!1),e},window.yasrValidJson=function(e){try{const t=JSON.parse(e);if(t&&"object"==typeof t)return t}catch(e){console.error("Not a valid Json Element"),console.log(e)}return!1},window.raterJs=function(e){let t=!0;if(void 0===e.element||null===e.element)return void console.info("missing rating element");if(null!==e.element&&e.element.classList.contains("yasr-star-rating"))return;if(void 0!==e.showToolTip&&(t=!!e.showToolTip),void 0!==e.step&&(e.step<=0||e.step>1))throw new Error("step must be a number between 0 and 1");let r,i,a=e.starSize||16,n=e.step||1,o=e.onHover,s=e.onLeave,l=yasrTrueFalseStringConvertion(yasrCommonData.isRtl),u=e.element;u.classList.add("yasr-star-rating");let d=document.createElement("div");d.classList.add("yasr-star-value"),d.style.backgroundSize=a+"px",u.appendChild(d),u.style.width=5*a+"px",u.style.height=a+"px",u.style.backgroundSize=a+"px";let c,f,v,m=e.rateCallback,y=!!e.readOnly,g=!1,p=e.isBusyText;if(c=void 0!==e.disableText?e.disableText:"{rating}/{maxRating}",y||(u.style.cursor="pointer"),v=void 0!==e.ratingText?e.ratingText:"{rating}/{maxRating}",e.rating)T(e.rating);else{var b=u.dataset.rating;b&&T(+b)}function w(e){if(!0===y||!0===g)return;let i;if(!0===l){let t=this.getBoundingClientRect(),r=e.pageX-t.left,a=u.offsetWidth;i=(a-r)/(a/100)}else i=e.offsetX/u.offsetWidth*100;if(i<101){if(1===n)f=Math.ceil(i/100*5);else{let e=i/100*5;for(let t=0;;t+=n)if(t>=e){f=t;break}}if(f>5&&(f=5),u.querySelector(".yasr-star-value").style.width=f/5*100+"%",t){let e=v.replace("{rating}",f);e=e.replace("{maxRating}",5),u.setAttribute("data-title",e)}"function"==typeof o&&o(f,r)}}function h(e){void 0!==r?(u.querySelector(".yasr-star-value").style.width=r/5*100+"%",u.setAttribute("data-rating",r)):(u.querySelector(".yasr-star-value").style.width="0%",u.removeAttribute("data-rating")),"function"==typeof s&&s(f,r)}function x(e){!0!==y&&!0!==g&&(void 0===m&&!1===typeof m||(g=!0,i=f,void 0===p?u.removeAttribute("data-title"):u.setAttribute("data-title",p),m.call(this,i,(function(){!1===y&&u.removeAttribute("data-title"),g=!1}))))}function S(){if(y=!0,t&&c){let e=c.replace("{rating}",r);e=e.replace("{maxRating}",5),u.setAttribute("data-title",e)}else u.removeAttribute("data-title")}function T(e){if(-1===e&&(e=void 0),"number"!=typeof e&&void 0!==e)throw new Error("Value must be a number or undefined.");e<0&&(e=0),e>5&&(e=5),r=e,u.querySelector(".yasr-star-value").style.width=e/5*100+"%",u.setAttribute("data-rating",e)}void 0===r&&(u.querySelector(".yasr-star-value").style.width="0px"),y&&S(),u.addEventListener("mousemove",w),u.addEventListener("mouseleave",h);let E={setRating:T,getRating:function(){return r},disable:S,enable:function(){y=!1,u.removeAttribute("data-title")},dispose:function(){u.removeEventListener("mousemove",w),u.removeEventListener("mouseleave",h),u.removeEventListener("click",x)}};return u.addEventListener("click",x.bind(E)),E},window.yasrSetRaterValue=function(e,t,r=!1,i=.1,a=!0,n=!1,o=!1){let s;s=r||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:s,step:i,readOnly:a,rating:n,rateCallback:o})};
|
includes/rest/classes/YasrCustomEndpoint.php
CHANGED
@@ -282,9 +282,9 @@ class YasrCustomEndpoint extends WP_REST_Controller {
|
|
282 |
|
283 |
/**
|
284 |
* @author Dario Curvino <@dudo>
|
285 |
-
* @since
|
286 |
-
* @param
|
287 |
-
* @param
|
288 |
*
|
289 |
* @return bool|\WP_Error|\WP_REST_Response
|
290 |
*/
|
282 |
|
283 |
/**
|
284 |
* @author Dario Curvino <@dudo>
|
285 |
+
* @since refactored 2.9.8
|
286 |
+
* @param $post_id
|
287 |
+
* @param $set_id
|
288 |
*
|
289 |
* @return bool|\WP_Error|\WP_REST_Response
|
290 |
*/
|
includes/rest/classes/YasrCustomFields.php
CHANGED
@@ -96,7 +96,7 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
96 |
'yasr_all_itemtypes',
|
97 |
array(
|
98 |
'get_callback' => static function() {
|
99 |
-
return
|
100 |
},
|
101 |
'update_callback' => null,
|
102 |
'schema' => $yasr_itemtype_schema,
|
@@ -123,7 +123,7 @@ class YasrCustomFields extends WP_REST_Controller {
|
|
123 |
$post_types,
|
124 |
'yasr_all_itemtypes_addition_info',
|
125 |
array(
|
126 |
-
'get_callback' => static function() {return
|
127 |
'update_callback' => null,
|
128 |
'schema' => $yasr_additional_itemtype_schema,
|
129 |
'auth_callback' => static function() {
|
96 |
'yasr_all_itemtypes',
|
97 |
array(
|
98 |
'get_callback' => static function() {
|
99 |
+
return YASR_SUPPORTED_SCHEMA_TYPES;
|
100 |
},
|
101 |
'update_callback' => null,
|
102 |
'schema' => $yasr_itemtype_schema,
|
123 |
$post_types,
|
124 |
'yasr_all_itemtypes_addition_info',
|
125 |
array(
|
126 |
+
'get_callback' => static function() {return YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS; },
|
127 |
'update_callback' => null,
|
128 |
'schema' => $yasr_additional_itemtype_schema,
|
129 |
'auth_callback' => static function() {
|
includes/shortcodes/classes/YasrMultiSet.php
CHANGED
@@ -69,7 +69,7 @@ class YasrMultiSet extends YasrShortcode {
|
|
69 |
$this->shortcode_html .= '</table>';
|
70 |
$this->shortcode_html .= '<!--End Yasr Multi Set Shortcode-->';
|
71 |
|
72 |
-
|
73 |
|
74 |
return $this->shortcode_html;
|
75 |
}
|
69 |
$this->shortcode_html .= '</table>';
|
70 |
$this->shortcode_html .= '<!--End Yasr Multi Set Shortcode-->';
|
71 |
|
72 |
+
YasrScriptsLoader::loadOVMultiJs();
|
73 |
|
74 |
return $this->shortcode_html;
|
75 |
}
|
includes/shortcodes/classes/YasrNoStarsRankings.php
CHANGED
@@ -45,7 +45,7 @@ class YasrNoStarsRankings extends YasrShortcode {
|
|
45 |
|
46 |
$this->shortcode_html .= '<!-- Yasr '.$this->shortcode_name.' Shortcode-->';
|
47 |
|
48 |
-
|
49 |
|
50 |
return $this->shortcode_html;
|
51 |
|
45 |
|
46 |
$this->shortcode_html .= '<!-- Yasr '.$this->shortcode_name.' Shortcode-->';
|
47 |
|
48 |
+
YasrScriptsLoader::loadRankingsJs();
|
49 |
|
50 |
return $this->shortcode_html;
|
51 |
|
includes/shortcodes/classes/YasrOverallRating.php
CHANGED
@@ -54,7 +54,7 @@ class YasrOverallRating extends YasrShortcode {
|
|
54 |
|
55 |
self::defineOvAttributes($overall_attributes['overall_rating']);
|
56 |
|
57 |
-
|
58 |
|
59 |
return $shortcode_html;
|
60 |
}
|
@@ -130,7 +130,6 @@ class YasrOverallRating extends YasrShortcode {
|
|
130 |
wp_kses_post(htmlspecialchars_decode($text_before_star)).
|
131 |
"</span>
|
132 |
</div>";
|
133 |
-
|
134 |
}
|
135 |
|
136 |
/**
|
54 |
|
55 |
self::defineOvAttributes($overall_attributes['overall_rating']);
|
56 |
|
57 |
+
YasrScriptsLoader::loadOVMultiJs();
|
58 |
|
59 |
return $shortcode_html;
|
60 |
}
|
130 |
wp_kses_post(htmlspecialchars_decode($text_before_star)).
|
131 |
"</span>
|
132 |
</div>";
|
|
|
133 |
}
|
134 |
|
135 |
/**
|
includes/shortcodes/classes/YasrRankings.php
CHANGED
@@ -27,8 +27,8 @@ if (!defined('ABSPATH')) {
|
|
27 |
class YasrRankings extends YasrShortcode {
|
28 |
|
29 |
protected $query_highest_rated_overall;
|
30 |
-
public
|
31 |
-
public
|
32 |
protected $ajax_nonce_rankings;
|
33 |
|
34 |
public function __construct($atts, $shortcode_name) {
|
@@ -56,7 +56,7 @@ class YasrRankings extends YasrShortcode {
|
|
56 |
$this->returnSingleTableRanking($this->urlencodeAtts($sql_atts));
|
57 |
$this->shortcode_html .= '<!--End Yasr Top 10 highest Rated Shortcode-->';
|
58 |
|
59 |
-
|
60 |
|
61 |
return $this->shortcode_html;
|
62 |
}
|
@@ -87,7 +87,7 @@ class YasrRankings extends YasrShortcode {
|
|
87 |
$this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), $source);
|
88 |
$this->shortcode_html .= '<!--End Yasr TMost Or Highest Rated Shortcode -->';
|
89 |
|
90 |
-
|
91 |
|
92 |
return $this->shortcode_html;
|
93 |
}
|
@@ -114,7 +114,7 @@ class YasrRankings extends YasrShortcode {
|
|
114 |
$this->returnSingleTableRanking($this->urlencodeAtts($sql_atts), 'author_multi');
|
115 |
$this->shortcode_html .= '<!-- Yasr Ranking by Multiset -->';
|
116 |
|
117 |
-
|
118 |
|
119 |
return $this->shortcode_html;
|
120 |
}
|
@@ -153,7 +153,7 @@ class YasrRankings extends YasrShortcode {
|
|
153 |
$this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), 'visitor_multi');
|
154 |
$this->shortcode_html .= '<!--End Yasr Ranking by Visitor Multiset -->';
|
155 |
|
156 |
-
|
157 |
|
158 |
return $this->shortcode_html;
|
159 |
}
|
@@ -261,7 +261,7 @@ class YasrRankings extends YasrShortcode {
|
|
261 |
if(isset($result->number_of_votes)) {
|
262 |
$data_array[$i]['number_of_votes'] = (int)$result->number_of_votes;
|
263 |
}
|
264 |
-
$data_array[$i]['title'] =
|
265 |
$data_array[$i]['link'] = get_permalink($result->post_id); //Get permalink from post id
|
266 |
$i++;
|
267 |
} //End foreach
|
27 |
class YasrRankings extends YasrShortcode {
|
28 |
|
29 |
protected $query_highest_rated_overall;
|
30 |
+
public $query_result_most_rated_visitor;
|
31 |
+
public $query_result_highest_rated_visitor;
|
32 |
protected $ajax_nonce_rankings;
|
33 |
|
34 |
public function __construct($atts, $shortcode_name) {
|
56 |
$this->returnSingleTableRanking($this->urlencodeAtts($sql_atts));
|
57 |
$this->shortcode_html .= '<!--End Yasr Top 10 highest Rated Shortcode-->';
|
58 |
|
59 |
+
YasrScriptsLoader::loadRankingsJs();
|
60 |
|
61 |
return $this->shortcode_html;
|
62 |
}
|
87 |
$this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), $source);
|
88 |
$this->shortcode_html .= '<!--End Yasr TMost Or Highest Rated Shortcode -->';
|
89 |
|
90 |
+
YasrScriptsLoader::loadRankingsJs();
|
91 |
|
92 |
return $this->shortcode_html;
|
93 |
}
|
114 |
$this->returnSingleTableRanking($this->urlencodeAtts($sql_atts), 'author_multi');
|
115 |
$this->shortcode_html .= '<!-- Yasr Ranking by Multiset -->';
|
116 |
|
117 |
+
YasrScriptsLoader::loadRankingsJs();
|
118 |
|
119 |
return $this->shortcode_html;
|
120 |
}
|
153 |
$this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), 'visitor_multi');
|
154 |
$this->shortcode_html .= '<!--End Yasr Ranking by Visitor Multiset -->';
|
155 |
|
156 |
+
YasrScriptsLoader::loadRankingsJs();
|
157 |
|
158 |
return $this->shortcode_html;
|
159 |
}
|
261 |
if(isset($result->number_of_votes)) {
|
262 |
$data_array[$i]['number_of_votes'] = (int)$result->number_of_votes;
|
263 |
}
|
264 |
+
$data_array[$i]['title'] = esc_html(get_post_field( 'post_title', $result->post_id, 'raw' ));
|
265 |
$data_array[$i]['link'] = get_permalink($result->post_id); //Get permalink from post id
|
266 |
$i++;
|
267 |
} //End foreach
|
includes/shortcodes/classes/YasrShortcode.php
CHANGED
@@ -139,54 +139,9 @@ abstract class YasrShortcode
|
|
139 |
*/
|
140 |
public static function enqueueScripts()
|
141 |
{
|
142 |
-
//scripts required for all
|
143 |
-
|
144 |
do_action( 'yasr_enqueue_assets_shortcode' );
|
145 |
}
|
146 |
-
|
147 |
-
/***
|
148 |
-
* This function is called by all the shortcodes that works in read only and in multiset
|
149 |
-
*
|
150 |
-
* @author Dario Curvino <@dudo>
|
151 |
-
* @since 2.8.8
|
152 |
-
*/
|
153 |
-
public static function enqueueReadonlyAndMultisetScript()
|
154 |
-
{
|
155 |
-
wp_enqueue_script(
|
156 |
-
'yasr-ov-multi',
|
157 |
-
YASR_JS_DIR_INCLUDES . 'shortcodes/overall-multiset.js',
|
158 |
-
array(
|
159 |
-
'jquery',
|
160 |
-
'rater',
|
161 |
-
'wp-i18n',
|
162 |
-
'yasr-global-data'
|
163 |
-
),
|
164 |
-
YASR_VERSION_NUM,
|
165 |
-
true
|
166 |
-
);
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Enqueue scripts for rankings
|
171 |
-
*
|
172 |
-
* @author Dario Curvino <@dudo>
|
173 |
-
* @since 2.8.8
|
174 |
-
*/
|
175 |
-
public static function enqueueRankingScript()
|
176 |
-
{
|
177 |
-
wp_enqueue_script(
|
178 |
-
'yasr-rankings',
|
179 |
-
YASR_JS_DIR_INCLUDES . 'shortcodes/rankings.js',
|
180 |
-
array(
|
181 |
-
'jquery',
|
182 |
-
'rater',
|
183 |
-
'wp-i18n',
|
184 |
-
'wp-element',
|
185 |
-
'yasr-global-data'
|
186 |
-
),
|
187 |
-
YASR_VERSION_NUM,
|
188 |
-
true
|
189 |
-
);
|
190 |
-
}
|
191 |
|
192 |
}
|
139 |
*/
|
140 |
public static function enqueueScripts()
|
141 |
{
|
142 |
+
//scripts required for all shortcodes
|
143 |
+
YasrScriptsLoader::loadRequiredJs();
|
144 |
do_action( 'yasr_enqueue_assets_shortcode' );
|
145 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
}
|
includes/shortcodes/classes/YasrShortcodesAjax.php
CHANGED
@@ -41,16 +41,16 @@ class YasrShortcodesAjax {
|
|
41 |
}
|
42 |
|
43 |
//VV save rating
|
44 |
-
add_action('wp_ajax_yasr_send_visitor_rating',
|
45 |
add_action('wp_ajax_nopriv_yasr_send_visitor_rating', array($this, 'saveVV'));
|
46 |
|
47 |
//MV save rating
|
48 |
-
add_action('wp_ajax_yasr_visitor_multiset_field_vote',
|
49 |
add_action('wp_ajax_nopriv_yasr_visitor_multiset_field_vote', array($this, 'saveMV'));
|
50 |
|
51 |
//VV load stats
|
52 |
if(YASR_VISITORS_STATS === 'yes') {
|
53 |
-
add_action('wp_ajax_yasr_stats_visitors_votes',
|
54 |
add_action('wp_ajax_nopriv_yasr_stats_visitors_votes', array($this, 'returnVVStats'));
|
55 |
}
|
56 |
|
@@ -96,8 +96,8 @@ class YasrShortcodesAjax {
|
|
96 |
$current_user_id = get_current_user_id();
|
97 |
$ip_address = yasr_get_ip();
|
98 |
|
99 |
-
$result_update_log =
|
100 |
-
$result_insert_log =
|
101 |
|
102 |
if (is_user_logged_in()) {
|
103 |
//try to update first, if fails the do the insert
|
@@ -115,7 +115,12 @@ class YasrShortcodesAjax {
|
|
115 |
}
|
116 |
|
117 |
if ($result_update_log || $result_insert_log) {
|
118 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
die(); // this is required to return a proper result
|
@@ -167,10 +172,13 @@ class YasrShortcodesAjax {
|
|
167 |
'vote' => $rating,
|
168 |
'date' => date('Y-m-d H:i:s'),
|
169 |
'ip' => $ip_address
|
170 |
-
),
|
|
|
171 |
'post_id' => $post_id,
|
172 |
'user_id' => $user_id
|
173 |
-
),
|
|
|
|
|
174 |
);
|
175 |
}
|
176 |
|
@@ -182,13 +190,13 @@ class YasrShortcodesAjax {
|
|
182 |
* @param $rating
|
183 |
* @param $result_update_log
|
184 |
*
|
185 |
-
* @return
|
186 |
*/
|
187 |
public function vvReturnResponse($post_id, $rating, $result_update_log) {
|
188 |
$row_exists = YasrDatabaseRatings::getVisitorVotes($post_id);
|
189 |
|
190 |
-
$user_votes_sum = $row_exists['sum_votes'];
|
191 |
$number_of_votes = $row_exists['number_of_votes'];
|
|
|
192 |
|
193 |
//customize visitor_votes cookie name
|
194 |
$cookiename = apply_filters('yasr_vv_cookie', 'yasr_visitor_vote_cookie');
|
@@ -200,9 +208,6 @@ class YasrShortcodesAjax {
|
|
200 |
|
201 |
yasr_setcookie($cookiename, $data_to_save);
|
202 |
|
203 |
-
$total_rating = ($user_votes_sum / $number_of_votes);
|
204 |
-
$medium_rating = round($total_rating, 1);
|
205 |
-
|
206 |
$rating_saved_text = '';
|
207 |
|
208 |
//Default text when rating is saved
|
@@ -213,16 +218,32 @@ class YasrShortcodesAjax {
|
|
213 |
$rating_saved_text = apply_filters('yasr_vv_saved_text', $rating_saved_text);
|
214 |
}
|
215 |
|
216 |
-
|
217 |
-
. wp_kses_post(htmlspecialchars_decode($rating_saved_text)) .
|
218 |
-
'</span>';
|
219 |
-
|
220 |
-
return array(
|
221 |
'status' => 'success',
|
222 |
'number_of_votes' => $number_of_votes,
|
223 |
'average_rating' => $medium_rating,
|
224 |
-
'
|
225 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
}
|
227 |
|
228 |
/**
|
@@ -289,14 +310,14 @@ class YasrShortcodesAjax {
|
|
289 |
$nonce = $_POST['nonce'];
|
290 |
|
291 |
if (!is_int($post_id) || !is_int($set_id)) {
|
292 |
-
|
293 |
}
|
294 |
|
295 |
if (!is_array($rating)) {
|
296 |
-
|
297 |
}
|
298 |
} else {
|
299 |
-
|
300 |
}
|
301 |
|
302 |
$nonce_response = self::validNonce($nonce, 'yasr_nonce_insert_visitor_rating_multiset');
|
@@ -312,6 +333,7 @@ class YasrShortcodesAjax {
|
|
312 |
do_action('yasr_action_on_visitor_multiset_vote', $array_action_visitor_multiset_vote);
|
313 |
|
314 |
$array_error = array();
|
|
|
315 |
|
316 |
//clean array, so if an user rate same field twice, take only the last rating
|
317 |
$cleaned_array = yasr_unique_multidim_array($rating, 'field');
|
@@ -337,7 +359,7 @@ class YasrShortcodesAjax {
|
|
337 |
//first try to update the vote
|
338 |
$update_query_success = $this->mvUpdateRating ($id_field, $set_id, $post_id, $rating, $current_user_id, $ip_address);
|
339 |
|
340 |
-
//
|
341 |
if (!$update_query_success) {
|
342 |
//insert as new rating
|
343 |
$insert_query_success = $this->mvSaveRating ($id_field, $set_id, $post_id, $rating, $current_user_id, $ip_address);
|
@@ -363,18 +385,18 @@ class YasrShortcodesAjax {
|
|
363 |
$array_error[] = 1;
|
364 |
}
|
365 |
|
366 |
-
$error_found = false;
|
367 |
-
|
368 |
foreach ($array_error as $error) {
|
369 |
if ($error === 1) {
|
370 |
$error_found = true;
|
371 |
}
|
372 |
}
|
373 |
|
374 |
-
|
375 |
-
|
|
|
376 |
|
377 |
-
|
|
|
378 |
|
379 |
} //End callback function
|
380 |
|
@@ -455,37 +477,27 @@ class YasrShortcodesAjax {
|
|
455 |
* @author Dario Curvino <@dudo>
|
456 |
* @since 2.7.2
|
457 |
*
|
458 |
-
* @param $error_found
|
459 |
* @param $post_id
|
460 |
* @param $set_id
|
461 |
*
|
462 |
-
* @return
|
463 |
*/
|
464 |
-
public function mvReturnResponse ($
|
465 |
-
|
466 |
-
$cookiename = apply_filters('yasr_mv_cookie', 'yasr_multi_visitor_cookie');
|
467 |
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
yasr_setcookie($cookiename, $data_to_save);
|
474 |
-
|
475 |
-
$rating_saved_text = __('Rating Saved', 'yet-another-stars-rating');
|
476 |
-
$rating_saved_text = wp_kses_post(apply_filters('yasr_mv_saved_text', $rating_saved_text));
|
477 |
|
478 |
-
|
479 |
-
'status' => 'success',
|
480 |
-
'text' => $rating_saved_text
|
481 |
-
);
|
482 |
-
}
|
483 |
|
484 |
-
|
485 |
-
'status' => 'error',
|
486 |
-
'error' => __('Rating not saved. Please Try again', 'yet-another-stars-rating')
|
487 |
-
);
|
488 |
|
|
|
|
|
|
|
|
|
489 |
}
|
490 |
|
491 |
/**
|
@@ -497,20 +509,16 @@ class YasrShortcodesAjax {
|
|
497 |
$post_id = (int)$_POST['post_id'];
|
498 |
}
|
499 |
else {
|
500 |
-
|
|
|
|
|
|
|
|
|
501 |
}
|
502 |
|
503 |
$votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
|
504 |
-
$
|
505 |
|
506 |
-
if ($votes_number !== 0) {
|
507 |
-
$medium_rating = ($votes_array['sum_votes'] / $votes_number);
|
508 |
-
}
|
509 |
-
else {
|
510 |
-
$medium_rating = 0;
|
511 |
-
}
|
512 |
-
|
513 |
-
$medium_rating = round($medium_rating, 1);
|
514 |
$missing_vote = null; //avoid undefined variable
|
515 |
|
516 |
global $wpdb;
|
@@ -578,7 +586,8 @@ class YasrShortcodesAjax {
|
|
578 |
$i = 5;
|
579 |
|
580 |
$array_to_return = array(
|
581 |
-
'
|
|
|
582 |
);
|
583 |
|
584 |
foreach ($stats as $logged_votes) {
|
@@ -720,8 +729,7 @@ class YasrShortcodesAjax {
|
|
720 |
|
721 |
//if this is coming from an ajax request
|
722 |
if($is_ajax === true) {
|
723 |
-
|
724 |
-
die();
|
725 |
}
|
726 |
|
727 |
return $data_to_return;
|
41 |
}
|
42 |
|
43 |
//VV save rating
|
44 |
+
add_action('wp_ajax_yasr_send_visitor_rating', array($this, 'saveVV'));
|
45 |
add_action('wp_ajax_nopriv_yasr_send_visitor_rating', array($this, 'saveVV'));
|
46 |
|
47 |
//MV save rating
|
48 |
+
add_action('wp_ajax_yasr_visitor_multiset_field_vote', array($this, 'saveMV'));
|
49 |
add_action('wp_ajax_nopriv_yasr_visitor_multiset_field_vote', array($this, 'saveMV'));
|
50 |
|
51 |
//VV load stats
|
52 |
if(YASR_VISITORS_STATS === 'yes') {
|
53 |
+
add_action('wp_ajax_yasr_stats_visitors_votes', array($this, 'returnVVStats'));
|
54 |
add_action('wp_ajax_nopriv_yasr_stats_visitors_votes', array($this, 'returnVVStats'));
|
55 |
}
|
56 |
|
96 |
$current_user_id = get_current_user_id();
|
97 |
$ip_address = yasr_get_ip();
|
98 |
|
99 |
+
$result_update_log = false; //avoid undefined
|
100 |
+
$result_insert_log = false; //avoid undefined
|
101 |
|
102 |
if (is_user_logged_in()) {
|
103 |
//try to update first, if fails the do the insert
|
115 |
}
|
116 |
|
117 |
if ($result_update_log || $result_insert_log) {
|
118 |
+
echo ($this->vvReturnResponse($post_id, $rating, $result_update_log));
|
119 |
+
}
|
120 |
+
|
121 |
+
//use === false here
|
122 |
+
if($result_insert_log === false && $result_update_log === false) {
|
123 |
+
echo ($this->returnErrorResponse(__('Error in Ajax Call, rating can\'t be saved', 'yet-another-stars-rating')));
|
124 |
}
|
125 |
|
126 |
die(); // this is required to return a proper result
|
172 |
'vote' => $rating,
|
173 |
'date' => date('Y-m-d H:i:s'),
|
174 |
'ip' => $ip_address
|
175 |
+
),
|
176 |
+
array(
|
177 |
'post_id' => $post_id,
|
178 |
'user_id' => $user_id
|
179 |
+
),
|
180 |
+
array('%d', '%d', '%d', '%s', '%s', '%s'),
|
181 |
+
array('%d', '%d')
|
182 |
);
|
183 |
}
|
184 |
|
190 |
* @param $rating
|
191 |
* @param $result_update_log
|
192 |
*
|
193 |
+
* @return string
|
194 |
*/
|
195 |
public function vvReturnResponse($post_id, $rating, $result_update_log) {
|
196 |
$row_exists = YasrDatabaseRatings::getVisitorVotes($post_id);
|
197 |
|
|
|
198 |
$number_of_votes = $row_exists['number_of_votes'];
|
199 |
+
$medium_rating = $row_exists['average'];
|
200 |
|
201 |
//customize visitor_votes cookie name
|
202 |
$cookiename = apply_filters('yasr_vv_cookie', 'yasr_visitor_vote_cookie');
|
208 |
|
209 |
yasr_setcookie($cookiename, $data_to_save);
|
210 |
|
|
|
|
|
|
|
211 |
$rating_saved_text = '';
|
212 |
|
213 |
//Default text when rating is saved
|
218 |
$rating_saved_text = apply_filters('yasr_vv_saved_text', $rating_saved_text);
|
219 |
}
|
220 |
|
221 |
+
return json_encode(array(
|
|
|
|
|
|
|
|
|
222 |
'status' => 'success',
|
223 |
'number_of_votes' => $number_of_votes,
|
224 |
'average_rating' => $medium_rating,
|
225 |
+
'text' => wp_kses_post($rating_saved_text)
|
226 |
+
));
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @author Dario Curvino <@dudo>
|
231 |
+
* @since 3.0.4
|
232 |
+
* @param string|bool $error_text
|
233 |
+
*
|
234 |
+
* @return string
|
235 |
+
*/
|
236 |
+
public function returnErrorResponse ($error_text) {
|
237 |
+
if(!$error_text) {
|
238 |
+
$error_text = esc_html__('Error in Ajax Call, rating can\'t be saved.', 'yet-another-stars-rating');
|
239 |
+
}
|
240 |
+
|
241 |
+
$error_text = apply_filters('yasr_vv_rating_error_text', $error_text);
|
242 |
+
|
243 |
+
return json_encode(array(
|
244 |
+
'status' => 'error',
|
245 |
+
'text' => wp_kses_post($error_text)
|
246 |
+
));
|
247 |
}
|
248 |
|
249 |
/**
|
310 |
$nonce = $_POST['nonce'];
|
311 |
|
312 |
if (!is_int($post_id) || !is_int($set_id)) {
|
313 |
+
die($this->returnErrorResponse(__('Missing post id or set id', 'yet-another-stars-rating')));
|
314 |
}
|
315 |
|
316 |
if (!is_array($rating)) {
|
317 |
+
die($this->returnErrorResponse(__('Error with rating', 'yet-another-stars-rating')));
|
318 |
}
|
319 |
} else {
|
320 |
+
die($this->returnErrorResponse(__('Missing required param', 'yet-another-stars-rating')));
|
321 |
}
|
322 |
|
323 |
$nonce_response = self::validNonce($nonce, 'yasr_nonce_insert_visitor_rating_multiset');
|
333 |
do_action('yasr_action_on_visitor_multiset_vote', $array_action_visitor_multiset_vote);
|
334 |
|
335 |
$array_error = array();
|
336 |
+
$error_found = false;
|
337 |
|
338 |
//clean array, so if an user rate same field twice, take only the last rating
|
339 |
$cleaned_array = yasr_unique_multidim_array($rating, 'field');
|
359 |
//first try to update the vote
|
360 |
$update_query_success = $this->mvUpdateRating ($id_field, $set_id, $post_id, $rating, $current_user_id, $ip_address);
|
361 |
|
362 |
+
//use ! instead of === FALSE
|
363 |
if (!$update_query_success) {
|
364 |
//insert as new rating
|
365 |
$insert_query_success = $this->mvSaveRating ($id_field, $set_id, $post_id, $rating, $current_user_id, $ip_address);
|
385 |
$array_error[] = 1;
|
386 |
}
|
387 |
|
|
|
|
|
388 |
foreach ($array_error as $error) {
|
389 |
if ($error === 1) {
|
390 |
$error_found = true;
|
391 |
}
|
392 |
}
|
393 |
|
394 |
+
if($error_found === true) {
|
395 |
+
die($this->returnErrorResponse(__('Error in Ajax Call, rating can\'t be saved.', 'yet-another-stars-rating')));
|
396 |
+
}
|
397 |
|
398 |
+
//echo response
|
399 |
+
die($this->mvReturnResponse($post_id, $set_id));
|
400 |
|
401 |
} //End callback function
|
402 |
|
477 |
* @author Dario Curvino <@dudo>
|
478 |
* @since 2.7.2
|
479 |
*
|
|
|
480 |
* @param $post_id
|
481 |
* @param $set_id
|
482 |
*
|
483 |
+
* @return string
|
484 |
*/
|
485 |
+
public function mvReturnResponse ($post_id, $set_id) {
|
486 |
+
$cookiename = apply_filters('yasr_mv_cookie', 'yasr_multi_visitor_cookie');
|
|
|
487 |
|
488 |
+
$data_to_save = array(
|
489 |
+
'post_id' => $post_id,
|
490 |
+
'set_id' => $set_id
|
491 |
+
);
|
|
|
|
|
|
|
|
|
|
|
492 |
|
493 |
+
yasr_setcookie($cookiename, $data_to_save);
|
|
|
|
|
|
|
|
|
494 |
|
495 |
+
$rating_saved_text = apply_filters('yasr_mv_saved_text', __('Rating Saved', 'yet-another-stars-rating'));
|
|
|
|
|
|
|
496 |
|
497 |
+
return json_encode(array(
|
498 |
+
'status' => 'success',
|
499 |
+
'text' => wp_kses_post($rating_saved_text)
|
500 |
+
));
|
501 |
}
|
502 |
|
503 |
/**
|
509 |
$post_id = (int)$_POST['post_id'];
|
510 |
}
|
511 |
else {
|
512 |
+
echo json_encode(array(
|
513 |
+
'status' => 'error',
|
514 |
+
'text' => 'Missing Post ID'
|
515 |
+
));
|
516 |
+
die();
|
517 |
}
|
518 |
|
519 |
$votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
|
520 |
+
$average_rating = $votes_array['average'];
|
521 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
$missing_vote = null; //avoid undefined variable
|
523 |
|
524 |
global $wpdb;
|
586 |
$i = 5;
|
587 |
|
588 |
$array_to_return = array(
|
589 |
+
'status' => 'success',
|
590 |
+
'medium_rating' => $average_rating
|
591 |
);
|
592 |
|
593 |
foreach ($stats as $logged_votes) {
|
729 |
|
730 |
//if this is coming from an ajax request
|
731 |
if($is_ajax === true) {
|
732 |
+
wp_send_json($data_to_return);
|
|
|
733 |
}
|
734 |
|
735 |
return $data_to_return;
|
includes/shortcodes/classes/YasrVisitorMultiSet.php
CHANGED
@@ -99,7 +99,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
|
|
99 |
$this->shortcode_html .= "</table>";
|
100 |
$this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
|
101 |
|
102 |
-
|
103 |
|
104 |
return $this->shortcode_html;
|
105 |
}
|
@@ -107,7 +107,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
|
|
107 |
|
108 |
/**
|
109 |
* @author Dario Curvino <@dudo>
|
110 |
-
* @since
|
111 |
* @return bool
|
112 |
*/
|
113 |
public function checkCookie() {
|
99 |
$this->shortcode_html .= "</table>";
|
100 |
$this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
|
101 |
|
102 |
+
YasrScriptsLoader::loadOVMultiJs();
|
103 |
|
104 |
return $this->shortcode_html;
|
105 |
}
|
107 |
|
108 |
/**
|
109 |
* @author Dario Curvino <@dudo>
|
110 |
+
* @since 2.3.0
|
111 |
* @return bool
|
112 |
*/
|
113 |
public function checkCookie() {
|
includes/shortcodes/classes/YasrVisitorVotes.php
CHANGED
@@ -30,7 +30,6 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
30 |
protected $is_singular;
|
31 |
protected $unique_id;
|
32 |
protected $ajax_nonce_visitor;
|
33 |
-
protected static $tippy_loaded;
|
34 |
|
35 |
public function __construct($atts, $shortcode_name) {
|
36 |
parent::__construct($atts, $shortcode_name);
|
@@ -44,7 +43,6 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
44 |
$this->unique_id = str_shuffle(uniqid());
|
45 |
$this->ajax_nonce_visitor = wp_create_nonce('yasr_nonce_vv');
|
46 |
|
47 |
-
self::$tippy_loaded = false;
|
48 |
}
|
49 |
|
50 |
/**
|
@@ -55,14 +53,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
55 |
public function returnShortcode() {
|
56 |
$stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
|
57 |
$number_of_votes = $stored_votes['number_of_votes'];
|
58 |
-
|
59 |
-
if ($number_of_votes > 0) {
|
60 |
-
$average_rating = $stored_votes['sum_votes']/$number_of_votes;
|
61 |
-
} else {
|
62 |
-
$average_rating = 0;
|
63 |
-
}
|
64 |
-
|
65 |
-
$average_rating=round($average_rating, 1);
|
66 |
|
67 |
self::defineVvAttributes($stored_votes);
|
68 |
|
@@ -84,46 +75,6 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
84 |
|
85 |
} //end function
|
86 |
|
87 |
-
/**
|
88 |
-
* Load visitorVotes.js if needed
|
89 |
-
*
|
90 |
-
* @author Dario Curvino <@dudo>
|
91 |
-
* @since 2.8.5
|
92 |
-
*/
|
93 |
-
public function loadVVScripts() {
|
94 |
-
$array_dep = array('jquery', 'rater', 'wp-i18n', 'yasr-global-data');
|
95 |
-
|
96 |
-
if(self::$tippy_loaded === true) {
|
97 |
-
$array_dep[] = 'tippy';
|
98 |
-
}
|
99 |
-
|
100 |
-
wp_enqueue_script(
|
101 |
-
'yasr-front-vv',
|
102 |
-
YASR_JS_DIR_INCLUDES . 'shortcodes/visitorVotes.js',
|
103 |
-
$array_dep,
|
104 |
-
YASR_VERSION_NUM,
|
105 |
-
true
|
106 |
-
);
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Load tippy if needed
|
111 |
-
*
|
112 |
-
* @author Dario Curvino <@dudo>
|
113 |
-
* @since 2.8.5
|
114 |
-
*/
|
115 |
-
public function loadTippy() {
|
116 |
-
wp_enqueue_script(
|
117 |
-
'tippy',
|
118 |
-
YASR_JS_DIR_INCLUDES . 'tippy.all.min.js',
|
119 |
-
'',
|
120 |
-
'3.6.0',
|
121 |
-
true
|
122 |
-
);
|
123 |
-
|
124 |
-
self::$tippy_loaded = true;
|
125 |
-
}
|
126 |
-
|
127 |
/**
|
128 |
* Return YASR VV in read only
|
129 |
*
|
@@ -153,7 +104,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
153 |
|
154 |
$shortcode_html = $container . $stars . $end_container;
|
155 |
|
156 |
-
|
157 |
|
158 |
//Use this filter to customize yasr_visitor_votes readonly
|
159 |
return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes, $this->post_id);
|
@@ -345,7 +296,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
345 |
id="yasr-stats-dashicon-'.$this->unique_id.'">
|
346 |
<path d="M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z"></path>
|
347 |
</svg>';
|
348 |
-
|
349 |
}
|
350 |
|
351 |
return $stat_icon;
|
@@ -401,7 +352,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
401 |
$stars_htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
|
402 |
|
403 |
$shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
|
404 |
-
$shortcode_html .= "<div id='yasr_visitor_votes_$this->
|
405 |
|
406 |
$shortcode_html .= $this->textBeforeStars($number_of_votes, $average_rating);
|
407 |
$shortcode_html .= "<div id='yasr-vv-second-row-container-$this->unique_id'
|
@@ -432,7 +383,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
432 |
$shortcode_html .= '</div>'; //close all
|
433 |
$shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
|
434 |
|
435 |
-
|
436 |
|
437 |
return $shortcode_html;
|
438 |
}
|
@@ -470,18 +421,4 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
470 |
define('YASR_VV_ATTRIBUTES', json_encode($yasr_vv_attributes));
|
471 |
}
|
472 |
}
|
473 |
-
|
474 |
-
/**
|
475 |
-
* Returns tippy status
|
476 |
-
*
|
477 |
-
* @author Dario Curvino <@dudo>
|
478 |
-
* @since 2.9.3
|
479 |
-
* @return bool
|
480 |
-
*/
|
481 |
-
public static function tippyLoaded() {
|
482 |
-
if(self::$tippy_loaded === true) {
|
483 |
-
return true;
|
484 |
-
}
|
485 |
-
return false;
|
486 |
-
}
|
487 |
}
|
30 |
protected $is_singular;
|
31 |
protected $unique_id;
|
32 |
protected $ajax_nonce_visitor;
|
|
|
33 |
|
34 |
public function __construct($atts, $shortcode_name) {
|
35 |
parent::__construct($atts, $shortcode_name);
|
43 |
$this->unique_id = str_shuffle(uniqid());
|
44 |
$this->ajax_nonce_visitor = wp_create_nonce('yasr_nonce_vv');
|
45 |
|
|
|
46 |
}
|
47 |
|
48 |
/**
|
53 |
public function returnShortcode() {
|
54 |
$stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
|
55 |
$number_of_votes = $stored_votes['number_of_votes'];
|
56 |
+
$average_rating = $stored_votes['average'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
self::defineVvAttributes($stored_votes);
|
59 |
|
75 |
|
76 |
} //end function
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
/**
|
79 |
* Return YASR VV in read only
|
80 |
*
|
104 |
|
105 |
$shortcode_html = $container . $stars . $end_container;
|
106 |
|
107 |
+
YasrScriptsLoader::loadOVMultiJs();
|
108 |
|
109 |
//Use this filter to customize yasr_visitor_votes readonly
|
110 |
return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes, $this->post_id);
|
296 |
id="yasr-stats-dashicon-'.$this->unique_id.'">
|
297 |
<path d="M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z"></path>
|
298 |
</svg>';
|
299 |
+
YasrScriptsLoader::loadTippy();
|
300 |
}
|
301 |
|
302 |
return $stat_icon;
|
352 |
$stars_htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
|
353 |
|
354 |
$shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
|
355 |
+
$shortcode_html .= "<div id='yasr_visitor_votes_$this->unique_id' class='yasr-visitor-votes'>";
|
356 |
|
357 |
$shortcode_html .= $this->textBeforeStars($number_of_votes, $average_rating);
|
358 |
$shortcode_html .= "<div id='yasr-vv-second-row-container-$this->unique_id'
|
383 |
$shortcode_html .= '</div>'; //close all
|
384 |
$shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
|
385 |
|
386 |
+
YasrScriptsLoader::loadVVJs();
|
387 |
|
388 |
return $shortcode_html;
|
389 |
}
|
421 |
define('YASR_VV_ATTRIBUTES', json_encode($yasr_vv_attributes));
|
422 |
}
|
423 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
}
|
includes/yasr-includes-db-functions.php
CHANGED
@@ -29,7 +29,7 @@ if (!defined('ABSPATH')) {
|
|
29 |
* @return bool|string
|
30 |
*/
|
31 |
function yasr_get_itemType($term_id=false) {
|
32 |
-
$review_types =
|
33 |
|
34 |
//if term_id is not an int, use get_post_meta
|
35 |
if(!is_int($term_id)) {
|
29 |
* @return bool|string
|
30 |
*/
|
31 |
function yasr_get_itemType($term_id=false) {
|
32 |
+
$review_types = YASR_SUPPORTED_SCHEMA_TYPES;
|
33 |
|
34 |
//if term_id is not an int, use get_post_meta
|
35 |
if(!is_int($term_id)) {
|
includes/yasr-includes-functions.php
CHANGED
@@ -46,7 +46,8 @@ function yasr_add_scripts_includes() {
|
|
46 |
'visitorStatsEnabled' => YASR_VISITORS_STATS,
|
47 |
'ajaxEnabled' => YASR_ENABLE_AJAX,
|
48 |
'loaderHtml' => $yasr_visitor_votes_loader,
|
49 |
-
'loaderUrl' => esc_url(YASR_IMG_DIR . 'loader.gif')
|
|
|
50 |
);
|
51 |
|
52 |
//check if wp_localize_script has already run before
|
@@ -138,43 +139,6 @@ function yasr_rtl_support() {
|
|
138 |
}
|
139 |
}
|
140 |
|
141 |
-
/**
|
142 |
-
* This function enqueue the js scripts required on both admin and frontend
|
143 |
-
*
|
144 |
-
* @author Dario Curvino <@dudo>
|
145 |
-
* @since 2.8.5
|
146 |
-
*/
|
147 |
-
|
148 |
-
function yasr_enqueue_includes_js_scripts() {
|
149 |
-
wp_enqueue_script('jquery');
|
150 |
-
|
151 |
-
wp_enqueue_script(
|
152 |
-
'rater',
|
153 |
-
YASR_JS_DIR_INCLUDES .
|
154 |
-
'rater-js.min.js',
|
155 |
-
'',
|
156 |
-
YASR_VERSION_NUM,
|
157 |
-
true
|
158 |
-
);
|
159 |
-
|
160 |
-
if(defined('YASR_CATCH_INFINITE_SCROLL_INSTALLED') && YASR_CATCH_INFINITE_SCROLL_INSTALLED === true) {
|
161 |
-
$array_dep = array('jquery', 'rater', 'wp-i18n', 'yasr-global-data', 'wp-element');
|
162 |
-
//laod tippy only if the shortcode has loaded it
|
163 |
-
if(YasrVisitorVotes::tippyLoaded() === true) {
|
164 |
-
$array_dep[] = 'tippy';
|
165 |
-
}
|
166 |
-
wp_enqueue_script(
|
167 |
-
'yasr_catch_infinite',
|
168 |
-
YASR_JS_DIR_INCLUDES .
|
169 |
-
'catch-inifite-scroll.js',
|
170 |
-
$array_dep,
|
171 |
-
YASR_VERSION_NUM,
|
172 |
-
true
|
173 |
-
);
|
174 |
-
}
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
/****** Translating YASR ******/
|
179 |
add_action('init', 'yasr_translate');
|
180 |
|
@@ -194,7 +158,7 @@ function yasr_select_itemtype($html_id=false, $term_id=false, $disabled=false) {
|
|
194 |
if($html_id === false) {
|
195 |
$html_id = 'yasr-choose-reviews-types-list';
|
196 |
}
|
197 |
-
$itemtypes_array
|
198 |
|
199 |
sort($itemtypes_array);
|
200 |
|
@@ -412,7 +376,7 @@ function yasr_check_valid_url($url) {
|
|
412 |
*/
|
413 |
|
414 |
function yasr_is_supported_schema ($item_type) {
|
415 |
-
$supported_schema_array =
|
416 |
|
417 |
if (in_array($item_type, $supported_schema_array)) {
|
418 |
return true;
|
46 |
'visitorStatsEnabled' => YASR_VISITORS_STATS,
|
47 |
'ajaxEnabled' => YASR_ENABLE_AJAX,
|
48 |
'loaderHtml' => $yasr_visitor_votes_loader,
|
49 |
+
'loaderUrl' => esc_url(YASR_IMG_DIR . 'loader.gif'),
|
50 |
+
'isRtl' => json_encode(is_rtl())
|
51 |
);
|
52 |
|
53 |
//check if wp_localize_script has already run before
|
139 |
}
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
/****** Translating YASR ******/
|
143 |
add_action('init', 'yasr_translate');
|
144 |
|
158 |
if($html_id === false) {
|
159 |
$html_id = 'yasr-choose-reviews-types-list';
|
160 |
}
|
161 |
+
$itemtypes_array = YASR_SUPPORTED_SCHEMA_TYPES;
|
162 |
|
163 |
sort($itemtypes_array);
|
164 |
|
376 |
*/
|
377 |
|
378 |
function yasr_is_supported_schema ($item_type) {
|
379 |
+
$supported_schema_array = YASR_SUPPORTED_SCHEMA_TYPES;
|
380 |
|
381 |
if (in_array($item_type, $supported_schema_array)) {
|
382 |
return true;
|
includes/yasr-includes-init.php
CHANGED
@@ -68,23 +68,23 @@ require YASR_ABSOLUTE_PATH_INCLUDES . '/shortcodes/yasr-shortcode-functions.php'
|
|
68 |
|
69 |
/****** Getting options ******/
|
70 |
//Get general options
|
71 |
-
$yasr_stored_options = get_option('yasr_general_options');
|
72 |
|
73 |
-
|
|
|
74 |
|
75 |
-
if(isset($
|
76 |
-
define('YASR_AUTO_INSERT_ENABLED', (int)$
|
77 |
} else {
|
78 |
-
define('YASR_AUTO_INSERT_ENABLED',
|
79 |
}
|
80 |
|
81 |
if (YASR_AUTO_INSERT_ENABLED === 1) {
|
82 |
-
define('YASR_AUTO_INSERT_WHAT',
|
83 |
-
define('YASR_AUTO_INSERT_WHERE', $
|
84 |
-
define('YASR_AUTO_INSERT_ALIGN', $
|
85 |
-
define('YASR_AUTO_INSERT_SIZE',
|
86 |
-
define('YASR_AUTO_INSERT_EXCLUDE_PAGES', $
|
87 |
-
define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', $
|
88 |
} else {
|
89 |
define('YASR_AUTO_INSERT_WHAT', null);
|
90 |
define('YASR_AUTO_INSERT_WHERE', null);
|
@@ -94,131 +94,53 @@ if (YASR_AUTO_INSERT_ENABLED === 1) {
|
|
94 |
define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', null);
|
95 |
}
|
96 |
|
97 |
-
|
98 |
-
define('YASR_STARS_TITLE', $yasr_stored_options['stars_title']);
|
99 |
-
} else {
|
100 |
-
define('YASR_STARS_TITLE', null);
|
101 |
-
}
|
102 |
|
103 |
if (YASR_STARS_TITLE === 'yes') {
|
104 |
-
define('YASR_STARS_TITLE_WHAT',
|
105 |
-
define('YASR_STARS_TITLE_EXCLUDE_PAGES', $
|
106 |
-
define('YASR_STARS_TITLE_WHERE',
|
107 |
} else {
|
108 |
define('YASR_STARS_TITLE_WHAT', null);
|
109 |
define('YASR_STARS_TITLE_EXCLUDE_PAGES', null);
|
110 |
define('YASR_STARS_TITLE_WHERE', null);
|
111 |
}
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
118 |
|
119 |
-
if(isset($
|
120 |
-
|
121 |
-
|
122 |
-
define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', null);
|
123 |
-
}
|
124 |
-
|
125 |
-
if(isset($yasr_stored_options['visitors_stats'])) {
|
126 |
-
define('YASR_VISITORS_STATS', $yasr_stored_options['visitors_stats']);
|
127 |
-
} else {
|
128 |
-
define('YASR_VISITORS_STATS', false);
|
129 |
-
}
|
130 |
-
|
131 |
-
if(isset($yasr_stored_options['allowed_user'])) {
|
132 |
-
define('YASR_ALLOWED_USER', $yasr_stored_options['allowed_user']);
|
133 |
-
} else {
|
134 |
-
define('YASR_ALLOWED_USER', false);
|
135 |
-
}
|
136 |
-
|
137 |
-
if(isset($yasr_stored_options['enable_ip'])) {
|
138 |
-
define('YASR_ENABLE_IP', $yasr_stored_options['enable_ip']);
|
139 |
-
} else {
|
140 |
-
define('YASR_ENABLE_IP', false);
|
141 |
-
}
|
142 |
-
|
143 |
-
if(isset($yasr_stored_options['snippet_itemtype'])) {
|
144 |
-
define('YASR_ITEMTYPE', $yasr_stored_options['snippet_itemtype']);
|
145 |
-
} else {
|
146 |
-
define('YASR_ITEMTYPE', false);
|
147 |
-
}
|
148 |
-
|
149 |
-
if (isset($yasr_stored_options['publisher'])) {
|
150 |
-
define('YASR_PUBLISHER_TYPE', $yasr_stored_options['publisher']);
|
151 |
-
} else {
|
152 |
-
define('YASR_PUBLISHER_TYPE', 'Organization'); //default value
|
153 |
-
}
|
154 |
-
|
155 |
-
if (isset($yasr_stored_options['publisher_name'])) {
|
156 |
-
define('YASR_PUBLISHER_NAME', $yasr_stored_options['publisher_name']);
|
157 |
-
} else {
|
158 |
-
define('YASR_PUBLISHER_NAME', get_bloginfo('name'));
|
159 |
-
}
|
160 |
-
|
161 |
-
if (isset($yasr_stored_options['publisher_logo'])
|
162 |
-
&& (filter_var($yasr_stored_options['publisher_logo'], FILTER_VALIDATE_URL) !== false)) {
|
163 |
-
define('YASR_PUBLISHER_LOGO', $yasr_stored_options['publisher_logo']);
|
164 |
} else {
|
165 |
define('YASR_PUBLISHER_LOGO', get_site_icon_url());
|
166 |
}
|
167 |
|
168 |
-
|
169 |
-
define('YASR_ENABLE_AJAX', $yasr_stored_options['enable_ajax']);
|
170 |
-
} else {
|
171 |
-
define('YASR_ENABLE_AJAX', 'no'); //default value
|
172 |
-
}
|
173 |
-
|
174 |
-
//Get stored style options
|
175 |
-
$style_options = get_option('yasr_style_options');
|
176 |
|
177 |
-
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
}
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
define('YASR_SCHEME_COLOR', null);
|
190 |
-
}
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
} else {
|
195 |
-
define('YASR_STARS_SET', null);
|
196 |
-
}
|
197 |
|
198 |
-
|
199 |
-
define('YASR_CUSTOM_CSS_RULES', null);
|
200 |
-
define('YASR_SCHEME_COLOR', null);
|
201 |
-
define('YASR_STARS_SET', null);
|
202 |
-
}
|
203 |
|
204 |
-
//Multi set options
|
205 |
-
$multi_set_options = get_option('yasr_multiset_options');
|
206 |
-
if ($multi_set_options) {
|
207 |
-
//Multi set options
|
208 |
-
$first_multiset = YasrMultiSetData::returnFirstSetId();
|
209 |
-
define('YASR_FIRST_SETID', $first_multiset);
|
210 |
-
|
211 |
-
if(YASR_FIRST_SETID !== false) {
|
212 |
-
if (isset($multi_set_options['show_average'])) {
|
213 |
-
define('YASR_MULTI_SHOW_AVERAGE', $multi_set_options['show_average']);
|
214 |
-
}
|
215 |
-
else {
|
216 |
-
define('YASR_MULTI_SHOW_AVERAGE', 'yes');
|
217 |
-
}
|
218 |
-
}
|
219 |
-
} else {
|
220 |
-
define('YASR_FIRST_SETID', 1);
|
221 |
-
}
|
222 |
/****** End Getting options ******/
|
223 |
|
224 |
define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
|
@@ -227,9 +149,11 @@ define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
|
|
227 |
$save_settings_text = __('Save All Settings', 'yet-another-stars-rating');
|
228 |
define('YASR_SAVE_All_SETTINGS_TEXT', $save_settings_text);
|
229 |
|
230 |
-
//
|
231 |
-
//
|
232 |
-
|
|
|
|
|
233 |
array (
|
234 |
'BlogPosting',
|
235 |
'Book',
|
@@ -248,12 +172,11 @@ $supported_schema_types = json_encode(
|
|
248 |
'Product',
|
249 |
'Recipe',
|
250 |
'SoftwareApplication'
|
251 |
-
)
|
252 |
-
);
|
253 |
|
254 |
//here the array member must contain main itemtype name
|
255 |
//e.g. yasr_softwareapplication contain 'SoftwareApplication'
|
256 |
-
|
257 |
array(
|
258 |
'yasr_schema_title',
|
259 |
'yasr_book_author',
|
@@ -294,15 +217,11 @@ $array_item_type_info = json_encode(
|
|
294 |
'yasr_softwareapplication_price_currency',
|
295 |
'yasr_softwareapplication_price_url',
|
296 |
'yasr_softwareapplication_price_valid_until',
|
297 |
-
)
|
298 |
-
);
|
299 |
-
|
300 |
-
define('YASR_SUPPORTED_SCHEMA_TYPES', $supported_schema_types);
|
301 |
-
define('YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS', $array_item_type_info);
|
302 |
|
303 |
//run includes filters
|
304 |
$yasr_includes_filter = new YasrIncludesFilters();
|
305 |
-
$yasr_includes_filter->filterCustomTexts($
|
306 |
|
307 |
//support for caching plugins
|
308 |
$yasr_includes_filter->cachingPluginSupport();
|
@@ -311,7 +230,8 @@ $init_ajax = new YasrShortcodesAjax();
|
|
311 |
$init_ajax->init();
|
312 |
|
313 |
add_action('plugins_loaded', static function () {
|
314 |
-
|
|
|
315 |
});
|
316 |
|
317 |
//Load rest API
|
68 |
|
69 |
/****** Getting options ******/
|
70 |
//Get general options
|
|
|
71 |
|
72 |
+
$settings = new YasrSettingsValues();
|
73 |
+
$yasr_general_settings = $settings->getGeneralSettings();
|
74 |
|
75 |
+
if(isset($yasr_general_settings['auto_insert_enabled'])) {
|
76 |
+
define('YASR_AUTO_INSERT_ENABLED', (int)$yasr_general_settings['auto_insert_enabled']);
|
77 |
} else {
|
78 |
+
define('YASR_AUTO_INSERT_ENABLED', 0);
|
79 |
}
|
80 |
|
81 |
if (YASR_AUTO_INSERT_ENABLED === 1) {
|
82 |
+
define('YASR_AUTO_INSERT_WHAT', $yasr_general_settings['auto_insert_what']);
|
83 |
+
define('YASR_AUTO_INSERT_WHERE', $yasr_general_settings['auto_insert_where']);
|
84 |
+
define('YASR_AUTO_INSERT_ALIGN', $yasr_general_settings['auto_insert_align']);
|
85 |
+
define('YASR_AUTO_INSERT_SIZE', $yasr_general_settings['auto_insert_size']);
|
86 |
+
define('YASR_AUTO_INSERT_EXCLUDE_PAGES', $yasr_general_settings['auto_insert_exclude_pages']);
|
87 |
+
define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', $yasr_general_settings['auto_insert_custom_post_only']);
|
88 |
} else {
|
89 |
define('YASR_AUTO_INSERT_WHAT', null);
|
90 |
define('YASR_AUTO_INSERT_WHERE', null);
|
94 |
define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', null);
|
95 |
}
|
96 |
|
97 |
+
define('YASR_STARS_TITLE', $yasr_general_settings['stars_title']);
|
|
|
|
|
|
|
|
|
98 |
|
99 |
if (YASR_STARS_TITLE === 'yes') {
|
100 |
+
define('YASR_STARS_TITLE_WHAT', $yasr_general_settings['stars_title_what']);
|
101 |
+
define('YASR_STARS_TITLE_EXCLUDE_PAGES', $yasr_general_settings['stars_title_exclude_pages']);
|
102 |
+
define('YASR_STARS_TITLE_WHERE', $yasr_general_settings['stars_title_where']);
|
103 |
} else {
|
104 |
define('YASR_STARS_TITLE_WHAT', null);
|
105 |
define('YASR_STARS_TITLE_EXCLUDE_PAGES', null);
|
106 |
define('YASR_STARS_TITLE_WHERE', null);
|
107 |
}
|
108 |
|
109 |
+
define('YASR_SHOW_OVERALL_IN_LOOP', $yasr_general_settings['show_overall_in_loop']);
|
110 |
+
define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', $yasr_general_settings['show_visitor_votes_in_loop']);
|
111 |
+
define('YASR_VISITORS_STATS', $yasr_general_settings['visitors_stats']);
|
112 |
+
define('YASR_ALLOWED_USER', $yasr_general_settings['allowed_user']);
|
113 |
+
define('YASR_ENABLE_IP', $yasr_general_settings['enable_ip']);
|
114 |
+
define('YASR_ITEMTYPE', $yasr_general_settings['snippet_itemtype']);
|
115 |
+
define('YASR_PUBLISHER_TYPE', $yasr_general_settings['publisher']);
|
116 |
+
define('YASR_PUBLISHER_NAME', $yasr_general_settings['publisher_name']);
|
117 |
|
118 |
+
if (isset($yasr_general_settings['publisher_logo'])
|
119 |
+
&& (filter_var($yasr_general_settings['publisher_logo'], FILTER_VALIDATE_URL) !== false)) {
|
120 |
+
define('YASR_PUBLISHER_LOGO', $yasr_general_settings['publisher_logo']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
} else {
|
122 |
define('YASR_PUBLISHER_LOGO', get_site_icon_url());
|
123 |
}
|
124 |
|
125 |
+
define('YASR_ENABLE_AJAX', $yasr_general_settings['enable_ajax']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
+
$style_options = $settings->getStyleSettings();
|
128 |
|
129 |
+
//Get stored style options
|
130 |
+
//To better support php version < 7, I can't use an array into define
|
131 |
+
//Also, I can't use const here, because it only works with primitive values
|
132 |
+
//https://stackoverflow.com/questions/2447791/php-define-vs-const
|
133 |
+
define('YASR_STYLE_OPTIONS', json_encode($style_options));
|
|
|
134 |
|
135 |
+
define('YASR_STARS_SET', $style_options['stars_set_free']);
|
136 |
+
define('YASR_SCHEME_COLOR', $style_options['scheme_color_multiset']);
|
137 |
+
define('YASR_CUSTOM_CSS_RULES', $style_options['textarea']);
|
|
|
|
|
138 |
|
139 |
+
//Multi set options
|
140 |
+
$multi_set_options = $settings->getMultiSettings();
|
|
|
|
|
|
|
141 |
|
142 |
+
define('YASR_MULTI_SHOW_AVERAGE', $multi_set_options['show_average']);
|
|
|
|
|
|
|
|
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
/****** End Getting options ******/
|
145 |
|
146 |
define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
|
149 |
$save_settings_text = __('Save All Settings', 'yet-another-stars-rating');
|
150 |
define('YASR_SAVE_All_SETTINGS_TEXT', $save_settings_text);
|
151 |
|
152 |
+
//To better support php version < 7, I can't use an array into define
|
153 |
+
//I can use const here, because it is a primitive value
|
154 |
+
//https://stackoverflow.com/questions/1290318/php-constants-containing-arrays
|
155 |
+
//https://stackoverflow.com/questions/2447791/php-define-vs-const
|
156 |
+
const YASR_SUPPORTED_SCHEMA_TYPES =
|
157 |
array (
|
158 |
'BlogPosting',
|
159 |
'Book',
|
172 |
'Product',
|
173 |
'Recipe',
|
174 |
'SoftwareApplication'
|
175 |
+
);
|
|
|
176 |
|
177 |
//here the array member must contain main itemtype name
|
178 |
//e.g. yasr_softwareapplication contain 'SoftwareApplication'
|
179 |
+
const YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS =
|
180 |
array(
|
181 |
'yasr_schema_title',
|
182 |
'yasr_book_author',
|
217 |
'yasr_softwareapplication_price_currency',
|
218 |
'yasr_softwareapplication_price_url',
|
219 |
'yasr_softwareapplication_price_valid_until',
|
220 |
+
);
|
|
|
|
|
|
|
|
|
221 |
|
222 |
//run includes filters
|
223 |
$yasr_includes_filter = new YasrIncludesFilters();
|
224 |
+
$yasr_includes_filter->filterCustomTexts($yasr_general_settings);
|
225 |
|
226 |
//support for caching plugins
|
227 |
$yasr_includes_filter->cachingPluginSupport();
|
230 |
$init_ajax->init();
|
231 |
|
232 |
add_action('plugins_loaded', static function () {
|
233 |
+
define('YASR_FIRST_SETID', YasrMultiSetData::returnFirstSetId());
|
234 |
+
define ('YASR_CATCH_INFINITE_SCROLL_INSTALLED', yasr_is_catch_infinite_sroll_installed());
|
235 |
});
|
236 |
|
237 |
//Load rest API
|
languages/yet-another-stars-rating.pot
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: YASR lenguages\n"
|
5 |
-
"POT-Creation-Date:
|
6 |
"PO-Revision-Date: 2016-07-04 10:26+0100\n"
|
7 |
"Last-Translator: Dario <thedudoworld@gmail.com>\n"
|
8 |
"Language-Team: \n"
|
@@ -11,7 +11,8 @@ msgstr ""
|
|
11 |
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"X-Generator: Poedit 2.3\n"
|
14 |
-
"X-Poedit-KeywordsList: __;_e
|
|
|
15 |
"X-Poedit-Basepath: ..\n"
|
16 |
"X-Poedit-SearchPath-0: .\n"
|
17 |
"X-Poedit-SearchPathExcluded-0: yasr_pro\n"
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: YASR lenguages\n"
|
5 |
+
"POT-Creation-Date: 2022-03-24 14:02+0100\n"
|
6 |
"PO-Revision-Date: 2016-07-04 10:26+0100\n"
|
7 |
"Last-Translator: Dario <thedudoworld@gmail.com>\n"
|
8 |
"Language-Team: \n"
|
11 |
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"X-Generator: Poedit 2.3\n"
|
14 |
+
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_html_e;esc_html_x;esc_attr__;"
|
15 |
+
"esc_attr_e;esc_attr_x\n"
|
16 |
"X-Poedit-Basepath: ..\n"
|
17 |
"X-Poedit-SearchPath-0: .\n"
|
18 |
"X-Poedit-SearchPathExcluded-0: yasr_pro\n"
|
public/classes/YasrPublicFilters.php
CHANGED
@@ -23,7 +23,7 @@ class YasrPublicFilters {
|
|
23 |
add_filter('the_title', array($this, 'filterTitle'));
|
24 |
add_action('wp_enqueue_scripts', static function() {
|
25 |
YasrShortcode::enqueueScripts();
|
26 |
-
|
27 |
});
|
28 |
}
|
29 |
|
@@ -229,14 +229,8 @@ class YasrPublicFilters {
|
|
229 |
$stored_votes = YasrDatabaseRatings::getVisitorVotes();
|
230 |
|
231 |
$number_of_votes = $stored_votes['number_of_votes'];
|
232 |
-
|
233 |
-
$average_rating = $stored_votes['sum_votes'] / $number_of_votes;
|
234 |
-
}
|
235 |
-
else {
|
236 |
-
$average_rating = 0;
|
237 |
-
}
|
238 |
|
239 |
-
$average_rating = round($average_rating, 1);
|
240 |
$htmlid = 'yasr-visitor-votes-readonly-rater-' . str_shuffle(uniqid());
|
241 |
|
242 |
$vv_widget = "<div class='yasr-stars-title yasr-rater-stars'
|
23 |
add_filter('the_title', array($this, 'filterTitle'));
|
24 |
add_action('wp_enqueue_scripts', static function() {
|
25 |
YasrShortcode::enqueueScripts();
|
26 |
+
YasrScriptsLoader::loadOVMultiJs();
|
27 |
});
|
28 |
}
|
29 |
|
229 |
$stored_votes = YasrDatabaseRatings::getVisitorVotes();
|
230 |
|
231 |
$number_of_votes = $stored_votes['number_of_votes'];
|
232 |
+
$average_rating = $stored_votes['average'];
|
|
|
|
|
|
|
|
|
|
|
233 |
|
|
|
234 |
$htmlid = 'yasr-visitor-votes-readonly-rater-' . str_shuffle(uniqid());
|
235 |
|
236 |
$vv_widget = "<div class='yasr-stars-title yasr-rater-stars'
|
public/classes/YasrRichSnippets.php
CHANGED
@@ -5,11 +5,14 @@ if (!defined('ABSPATH')) {
|
|
5 |
} // Exit if accessed directly
|
6 |
|
7 |
/**
|
|
|
|
|
8 |
* This class hook to yasr_filter_existing_schema, get the post meta
|
9 |
* yasr_schema_additional_fields, and depending of the itemType selected
|
10 |
* returns the schema info
|
11 |
*
|
12 |
-
*
|
|
|
13 |
*/
|
14 |
class YasrRichSnippets {
|
15 |
|
@@ -289,7 +292,7 @@ class YasrRichSnippets {
|
|
289 |
|
290 |
/**
|
291 |
* @author Dario Curvino <@dudo>
|
292 |
-
* @since
|
293 |
* @return array
|
294 |
*/
|
295 |
private function richSnippetsCommon ($review_choosen, $rich_snippet_data, $cleaned_content) {
|
@@ -433,8 +436,8 @@ class YasrRichSnippets {
|
|
433 |
|
434 |
/**
|
435 |
* @author Dario Curvino <@dudo>
|
436 |
-
* @since
|
437 |
-
* @param
|
438 |
*
|
439 |
* @return array
|
440 |
*/
|
@@ -576,14 +579,14 @@ class YasrRichSnippets {
|
|
576 |
* @author Dario Curvino <@dudo>
|
577 |
* @return array|mixed
|
578 |
*/
|
579 |
-
|
580 |
$post_meta = get_post_meta(get_the_ID(), 'yasr_schema_additional_fields', true);
|
581 |
//avoid undefined
|
582 |
if(!is_array($post_meta)) {
|
583 |
$post_meta = array();
|
584 |
}
|
585 |
|
586 |
-
$array_item_type_info =
|
587 |
|
588 |
foreach ($array_item_type_info as $item_type) {
|
589 |
//avoid undefined
|
5 |
} // Exit if accessed directly
|
6 |
|
7 |
/**
|
8 |
+
* Manage Rich Snippets
|
9 |
+
*
|
10 |
* This class hook to yasr_filter_existing_schema, get the post meta
|
11 |
* yasr_schema_additional_fields, and depending of the itemType selected
|
12 |
* returns the schema info
|
13 |
*
|
14 |
+
* @author Dario Curvino <dudo>
|
15 |
+
*
|
16 |
*/
|
17 |
class YasrRichSnippets {
|
18 |
|
292 |
|
293 |
/**
|
294 |
* @author Dario Curvino <@dudo>
|
295 |
+
* @since 2.9.7
|
296 |
* @return array
|
297 |
*/
|
298 |
private function richSnippetsCommon ($review_choosen, $rich_snippet_data, $cleaned_content) {
|
436 |
|
437 |
/**
|
438 |
* @author Dario Curvino <@dudo>
|
439 |
+
* @since 2.9.1
|
440 |
+
* @param $post_meta
|
441 |
*
|
442 |
* @return array
|
443 |
*/
|
579 |
* @author Dario Curvino <@dudo>
|
580 |
* @return array|mixed
|
581 |
*/
|
582 |
+
public function post_meta() {
|
583 |
$post_meta = get_post_meta(get_the_ID(), 'yasr_schema_additional_fields', true);
|
584 |
//avoid undefined
|
585 |
if(!is_array($post_meta)) {
|
586 |
$post_meta = array();
|
587 |
}
|
588 |
|
589 |
+
$array_item_type_info = YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS;
|
590 |
|
591 |
foreach ($array_item_type_info as $item_type) {
|
592 |
//avoid undefined
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
3 |
Tags: rating, rate post, rate page, star rating, google rating, votes
|
4 |
Requires at least: 5.0
|
5 |
Contributors: Dudo
|
6 |
-
Tested up to: 5.9.
|
7 |
-
Stable tag: 3.0.
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
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
|
@@ -203,6 +203,10 @@ Yes, YASR is 100% fully compatible with PHP 8
|
|
203 |
|
204 |
The full changelog can be found in the plugin's directory. Recent entries:
|
205 |
|
|
|
|
|
|
|
|
|
206 |
= 3.0.3 =
|
207 |
* FIX: if parameter 'show_average' is enabled on a multi set, a duplicate query was run.
|
208 |
* TWEAKED: loader image has height and width attributes set.
|
3 |
Tags: rating, rate post, rate page, star rating, google rating, votes
|
4 |
Requires at least: 5.0
|
5 |
Contributors: Dudo
|
6 |
+
Tested up to: 5.9.3
|
7 |
+
Stable tag: 3.0.4
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
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
|
203 |
|
204 |
The full changelog can be found in the plugin's directory. Recent entries:
|
205 |
|
206 |
+
= 3.0.4 =
|
207 |
+
* FIX: Author multiset didn't get saved
|
208 |
+
* TWEAKED: better error handling
|
209 |
+
|
210 |
= 3.0.3 =
|
211 |
* FIX: if parameter 'show_average' is enabled on a multi set, a duplicate query was run.
|
212 |
* TWEAKED: loader image has height and width attributes set.
|
yet-another-stars-rating.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
-
* Version: 3.0.
|
8 |
* Requires at least: 5.6
|
9 |
* Requires PHP: 5.4
|
10 |
* Author: Dario Curvino
|
@@ -78,7 +78,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
78 |
yasr_fs();
|
79 |
// Signal that SDK was initiated.
|
80 |
do_action( 'yasr_fs_loaded' );
|
81 |
-
define( 'YASR_VERSION_NUM', '3.0.
|
82 |
//Plugin absolute path
|
83 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
84 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
+
* Version: 3.0.4
|
8 |
* Requires at least: 5.6
|
9 |
* Requires PHP: 5.4
|
10 |
* Author: Dario Curvino
|
78 |
yasr_fs();
|
79 |
// Signal that SDK was initiated.
|
80 |
do_action( 'yasr_fs_loaded' );
|
81 |
+
define( 'YASR_VERSION_NUM', '3.0.4' );
|
82 |
//Plugin absolute path
|
83 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
84 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|