Yasr – Yet Another Stars Rating - Version 2.3.3

Version Description

  • FIXED: "Load results with AJAX" option works with all post types, not the "posts" one
  • FIXED: CSS fix in settings pages
  • FIXED: minor fix with multiSet
Download this release

Release Info

Developer Dudo
Plugin Icon 128x128 Yasr – Yet Another Stars Rating
Version 2.3.3
Comparing to
See all releases

Code changes from version 2.3.2 to 2.3.3

Files changed (39) hide show
  1. admin/classes/YasrEditCategory.php +69 -0
  2. admin/classes/YasrSettings.php +128 -0
  3. admin/css/yasr-admin.css +2 -1
  4. admin/editor/yasr-editor-functions.php +5 -7
  5. admin/editor/yasr-metabox-multiple-rating.php +10 -9
  6. admin/editor/yasr-metabox-schema.php +1 -1
  7. admin/js/src/guten/yasr-guten-blocks.js +683 -0
  8. admin/js/src/guten/yasr-guten-panel.js +289 -0
  9. admin/js/src/yasr-dashboard.js +99 -0
  10. admin/js/src/yasr-functions.js +22 -0
  11. admin/js/src/yasr-settings-page.js +237 -0
  12. admin/js/yasr-admin.js +1 -374
  13. admin/js/yasr-editor-screen.js +1 -2
  14. admin/js/yasr-guten-panel.js +1 -1
  15. admin/settings/multiset/yasr-settings-functions-multiset-page.php +4 -3
  16. admin/settings/multiset/yasr-settings-functions-multiset.php +10 -10
  17. admin/settings/yasr-settings-functions-misc.php +10 -4
  18. admin/settings/yasr-settings-functions.php +10 -30
  19. admin/settings/yasr-settings-page.php +64 -86
  20. admin/yasr-admin-actions.php +8 -0
  21. admin/yasr-admin-functions.php +146 -1
  22. admin/yasr-admin-init.php +1 -140
  23. changelog.txt +4 -16
  24. includes/classes/YasrCustomPostTypes.php +110 -0
  25. includes/js/yasr-front.js +3 -1
  26. includes/rest/classes/YasrCustomFields.php +4 -4
  27. includes/rest/classes/YasrPostMeta.php +4 -4
  28. includes/rest/yasr-rest.php +3 -0
  29. includes/shortcodes/classes/YasrNoStarsRankings.php +140 -0
  30. includes/shortcodes/classes/YasrOverallRating.php +5 -5
  31. includes/shortcodes/classes/YasrShortcode.php +4 -0
  32. includes/shortcodes/classes/YasrVisitorVotes.php +1 -0
  33. includes/shortcodes/yasr-shortcode-functions.php +7 -113
  34. includes/yasr-includes-db-functions.php +16 -9
  35. includes/yasr-includes-functions.php +18 -46
  36. includes/yasr-includes-init.php +5 -3
  37. public/yasr-public-filters.php +1 -1
  38. readme.txt +10 -12
  39. yet-another-stars-rating.php +2 -2
admin/classes/YasrEditCategory.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ /*
3
+
4
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 2 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>
18
+ */
19
+
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
+ } // Exit if accessed directly
23
+
24
+
25
+ class YasrEditCategory {
26
+ public static function init() {
27
+ if (yasr_fs()->is_free_plan() && !yasr_fs()->is_trial()) {
28
+ add_action( 'category_edit_form_fields', array('YasrEditCategory', 'categoryEditFormFieldsLock' ) );
29
+ }
30
+ }
31
+
32
+ /**
33
+ *
34
+ */
35
+ public static function categoryEditFormFieldsLock() {
36
+ ?>
37
+ <tr class="form-field term-name-wrap">
38
+ <th scope="row">
39
+ <label for="yasr-default-itemtype-category">
40
+ <?php _e( 'Select default itemType', 'yet-another-stars-rating' ) ?>
41
+ </label>
42
+ <span class="dashicons dashicons-lock"></span>
43
+ <?php
44
+ $string = sprintf(
45
+ __('Upgrade to %s to unlock this feature', 'yet-another-stars-rating'),
46
+ '<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=edit_category&utm_campaign=yasr_editor_category#yasr-pro">YASR PRO</a>'
47
+ );
48
+ ?>
49
+ <span class="description">
50
+ <?php echo $string ?>
51
+ </span>
52
+ </th>
53
+ <td>
54
+ <?php yasr_select_itemtype('yasr-pro-select-itemtype-category', 1, true ); ?>
55
+ <p></p>
56
+ <label for="yasr-pro-checkbox-itemtype-category" class="yasr-indented-answer">
57
+ <input type="checkbox"
58
+ id="yasr-pro-checkbox-itemtype-category"
59
+ disabled
60
+ >
61
+ <span class="description">
62
+ <?php _e('Check to update YASR itemType', 'yet-another-stars-rating') ?>
63
+ </span>
64
+ </label>
65
+ </td>
66
+ </tr >
67
+ <?php
68
+ }
69
+ }
admin/classes/YasrSettings.php ADDED
@@ -0,0 +1,128 @@
1
+ <?php
2
+
3
+ /*
4
+
5
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>
19
+ */
20
+
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
+
25
+ class YasrSettings {
26
+
27
+ /**
28
+ * @since 2.3.3
29
+ *
30
+ * @param $name
31
+ * @param $class
32
+ * @param $db_value
33
+ * @param $id
34
+ *
35
+ * return void
36
+ */
37
+ public static function radioSelectSize($name, $class, $db_value=false, $id=false) {
38
+ $array_size = array('small', 'medium', 'large');
39
+
40
+ foreach($array_size as $size) {
41
+ $id_string = $id . $size;
42
+
43
+ //must be inside for each, or when loop arrive to last element
44
+ //checked is defined
45
+ $checked = '';
46
+
47
+ //If db_value === false, there is no need to check for db value
48
+ //so checked is the medium star (i.e. ranking page)
49
+ if($db_value === false) {
50
+ if($size === 'medium') {
51
+ $checked = 'checked';
52
+ }
53
+ } else if ($db_value === $size) {
54
+ $checked = 'checked';
55
+ }
56
+
57
+ echo sprintf( '<div class="yasr-option-div">
58
+ <label for="%s">
59
+ <input type="radio"
60
+ name="%s"
61
+ value="%s"
62
+ class="%s"
63
+ id="%s"
64
+ %s
65
+ >
66
+ <img src="%syasr-stars-%s.png"
67
+ class="yasr-img-option-size" alt=%s>
68
+ <span class="yasr-text-options-size">
69
+ %s
70
+ </span>
71
+ </label>
72
+ </div>',
73
+ $id_string, $name, $size, $class, $id_string, $checked, YASR_IMG_DIR, $size, $size,
74
+ __( ucwords( $size ), 'yet-another-stars-rating' ) );
75
+
76
+ } //end foreach
77
+ }
78
+
79
+ /**
80
+ * @param string $option_title
81
+ * @param array $array_options
82
+ * @param string $name
83
+ * @param string $class
84
+ * @param bool | string | int $default_value
85
+ * @param bool | string $id
86
+ */
87
+ public static function printRadioType($option_title, $array_options, $name, $class, $default_value=false, $id=false) {
88
+
89
+ echo '<strong>' . $option_title . '</strong><br />';
90
+
91
+ if(is_array($array_options)) {
92
+ foreach ($array_options as $value => $label) {
93
+ $id_string = $id . '-' . strtolower(trim(str_replace(' ', '', $value)));
94
+ //must be inside foreach, or when loop arrive to last element
95
+ //checked is defined
96
+ $checked = '';
97
+
98
+ //If db_value === false, there is no need to check for db value
99
+ //so checked is the medium star (i.e. ranking page)
100
+ if($default_value === $value) {
101
+ $checked = 'checked';
102
+ }
103
+
104
+ //string value must be empty
105
+ if($value === 0) {
106
+ $value = '';
107
+ }
108
+
109
+ echo sprintf('<div>
110
+ <label for="%s">
111
+ <input type="radio"
112
+ name="%s"
113
+ value="%s"
114
+ class="%s"
115
+ id="%s"
116
+ %s
117
+ >
118
+ %s
119
+ </label>
120
+ </div>',
121
+ $id_string, $name, $value, $class, $id_string, $checked,
122
+ __(ucwords($label), 'yet-another-stars-rating'));
123
+
124
+ } //end foreach
125
+ }
126
+ }
127
+
128
+ }
admin/css/yasr-admin.css CHANGED
@@ -300,6 +300,7 @@
300
301
.yasr-donatedivdx {
302
float: right;
303
display: block !important;
304
min-width: 250px;
305
width: 15%;
@@ -382,7 +383,7 @@
382
content: "+";
383
}
384
385
- .yasr-option-size {
386
vertical-align: bottom;
387
display: block;
388
margin-bottom: 15px;
300
301
.yasr-donatedivdx {
302
float: right;
303
+ clear: right;
304
display: block !important;
305
min-width: 250px;
306
width: 15%;
383
content: "+";
384
}
385
386
+ .yasr-option-div {
387
vertical-align: bottom;
388
display: block;
389
margin-bottom: 15px;
admin/editor/yasr-editor-functions.php CHANGED
@@ -99,7 +99,7 @@ function yasr_add_metaboxes() {
99
$post_type_where_display_metabox = array('post', 'page');
100
101
//get the custom post type
102
- $custom_post_types = yasr_get_custom_post_type();
103
104
if ($custom_post_types) {
105
//First merge array then changes keys to int
@@ -411,12 +411,10 @@ function yasr_output_multiple_set_callback() {
411
wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
412
}
413
414
- if (!empty($_POST['set_id']) && !empty($_POST['post_id'])) {
415
- $set_id = (int) $_POST['set_id'];
416
- $post_id = (int) $_POST['post_id'];
417
- } else {
418
- die();
419
- }
420
421
//set fields name and ids
422
$set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
99
$post_type_where_display_metabox = array('post', 'page');
100
101
//get the custom post type
102
+ $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
103
104
if ($custom_post_types) {
105
//First merge array then changes keys to int
411
wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
412
}
413
414
+ //in version < 2.1.0 set id could be 0
415
+ $set_id = (int) $_POST['set_id'];
416
+ $post_id = (int) $_POST['post_id'];
417
+
418
419
//set fields name and ids
420
$set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
admin/editor/yasr-metabox-multiple-rating.php CHANGED
@@ -33,17 +33,20 @@ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count numb
33
if ($n_multi_set > 1) {
34
?>
35
<div>
36
- <?php _e("Choose wich set you want to use", 'yet-another-stars-rating'); ?>
37
<br />
38
- <select id="select_set">
39
- <?php foreach ($multi_set as $name) { ?>
40
- <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
41
- <?php } //End foreach ?>
42
- </select>
43
44
<button href="#" class="button-delete" id="yasr-button-select-set"><?php _e("Select"); ?></button>
45
46
- <span id="yasr-loader-select-multi-set" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
47
</span>
48
</div>
49
@@ -52,12 +55,10 @@ if ($n_multi_set > 1) {
52
} //End if if ($n_multi_set>1)
53
54
elseif ($n_multi_set === 1) {
55
-
56
//If multiset is only 1, array index will be always 0
57
////get the set_id
58
$set_id = $multi_set[0]->set_id;
59
$set_id = (int)$set_id;
60
-
61
}
62
63
33
if ($n_multi_set > 1) {
34
?>
35
<div>
36
+ <?php _e("Choose which set you want to use", 'yet-another-stars-rating'); ?>
37
<br />
38
+ <label for="select_set">
39
+ <select id="select_set">
40
+ <?php foreach ($multi_set as $name) { ?>
41
+ <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
42
+ <?php } //End foreach ?>
43
+ </select>
44
+ </label>
45
46
<button href="#" class="button-delete" id="yasr-button-select-set"><?php _e("Select"); ?></button>
47
48
+ <span id="yasr-loader-select-multi-set" style="display:none;" >&nbsp;
49
+ <img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>" alt="yasr-loader">
50
</span>
51
</div>
52
55
} //End if if ($n_multi_set>1)
56
57
elseif ($n_multi_set === 1) {
58
//If multiset is only 1, array index will be always 0
59
////get the set_id
60
$set_id = $multi_set[0]->set_id;
61
$set_id = (int)$set_id;
62
}
63
64
admin/editor/yasr-metabox-schema.php CHANGED
@@ -28,7 +28,7 @@ global $post;
28
wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
29
30
//itemType select
31
- wp_nonce_field('yasr_nonce_review_type_action', 'yasr_nonce_review_type');
32
33
//get all additional post meta
34
$saved_data = get_post_meta($post->ID, 'yasr_schema_additional_fields', true);
28
wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
29
30
//itemType select
31
+ wp_nonce_field('yasr_nonce_review_type_action', 'yasr_nonce_review_type');
32
33
//get all additional post meta
34
$saved_data = get_post_meta($post->ID, 'yasr_schema_additional_fields', true);
admin/js/src/guten/yasr-guten-blocks.js ADDED
@@ -0,0 +1,683 @@
1
+ //setting costants
2
+ const { __ } = wp.i18n; // Import __() from wp.i18n
3
+ const {registerBlockType} = wp.blocks; // Import from wp.blocks
4
+ const {PanelBody, PanelRow} = wp.components;
5
+ const {Fragment} = wp.element;
6
+ const {BlockControls,InspectorControls} = wp.editor;
7
+
8
+
9
+ const yasrOptionalText = __('All these settings are optional', 'yet-another-stars-rating');
10
+
11
+ const yasrLabelSelectSize = __('Choose Size', 'yet-another-stars-rating');
12
+
13
+ const yasrSelectSizeChoose = __('Choose stars size', 'yet-another-stars-rating');
14
+ const yasrSelectSizeSmall = __('Small', 'yet-another-stars-rating');
15
+ const yasrSelectSizeMedium = __('Medium', 'yet-another-stars-rating');
16
+ const yasrSelectSizeLarge = __('Large', 'yet-another-stars-rating');
17
+
18
+ const yasrLeaveThisBlankText = __('Leave this blank if you don\'t know what you\'re doing.', 'yet-another-stars-rating');
19
+
20
+ const yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
21
+ const yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
22
+
23
+ /******* function to check ajax response *****/
24
+ /*function checkResponse(res) {
25
+ if (res.status >= 400 && res.status < 600) {
26
+ throw new Error(`Failed with status ${res.status}`);
27
+ }
28
+
29
+ return res;
30
+ }*/
31
+
32
+ function YasrProText () {
33
+
34
+ const YasrProText1 = __('To be able to customize this ranking, you need', 'yet-another-stars-rating');
35
+ const YasrProText2 = __('You can buy the plugin, including one year of support, updates and upgrades, on',
36
+ 'yet-another-stars-rating');
37
+
38
+ return (
39
+ <h3>
40
+ {YasrProText1}
41
+ &nbsp;
42
+ <a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings#yasr-pro">
43
+ Yasr Pro.
44
+ </a><br />
45
+ {YasrProText2}
46
+ &nbsp;
47
+ <a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=gutenberg_panel&utm_campaign=yasr_editor_screen&utm_content=rankings">
48
+ yetanotherstarsrating.com
49
+ </a>
50
+ </h3>
51
+ )
52
+
53
+ }
54
+
55
+ function YasrNoSettingsPanel (props) {
56
+
57
+ return (
58
+ <InspectorControls>
59
+ <PanelBody title='Settings'>
60
+ <YasrProText/>
61
+ </PanelBody>
62
+ </InspectorControls>
63
+ );
64
+
65
+ }
66
+
67
+ /*function YasrPrintSelectRows () {
68
+
69
+ let optionValueRows = [];
70
+
71
+ for (let i=2; i<=30; i++) {
72
+ if (i === 9) {
73
+ optionValueRows.push(<option value={i} selected disabled>{i}</option>);
74
+ } else {
75
+ optionValueRows.push(<option value={i} disabled>{i}</option>);
76
+ }
77
+
78
+ }
79
+
80
+ return(
81
+ <form>
82
+ <select>
83
+ {optionValueRows}
84
+ </select>
85
+ <span className="dashicons dashicons-lock"></span>
86
+ </form>
87
+ )
88
+
89
+ }
90
+
91
+
92
+ function YasrPrintSelectSize () {
93
+ return (
94
+ <form>
95
+ <select>
96
+ <option value="--">{yasrSelectSizeChoose}</option>
97
+ <option value="small" disabled>{yasrSelectSizeSmall}</option>
98
+ <option value="medium" disabled>{yasrSelectSizeMedium}</option>
99
+ <option value="large" disabled>{yasrSelectSizeLarge}</option>
100
+ </select>
101
+ <span className="dashicons dashicons-lock"></span>
102
+ </form>
103
+ );
104
+ }
105
+
106
+ function YasrPrintTextPosition () {
107
+ return (
108
+ <form>
109
+ <select>
110
+ <option value="before" selected disabled>Before</option>
111
+ <option value="after" disabled>After</option>
112
+ </select>
113
+ <span className="dashicons dashicons-lock"></span>
114
+ </form>
115
+ );
116
+ }
117
+ */
118
+ /**
119
+ * Register: a Gutenberg Block.
120
+ *
121
+ * Registers a new block provided a unique name and an object defining its
122
+ * behavior. Once registered, the block is made editor as an option to any
123
+ * editor interface where blocks are implemented.
124
+ *
125
+ * @link https://wordpress.org/gutenberg/handbook/block-api/
126
+ * @param {string} name Block name.
127
+ * @param {Object} settings Block settings.
128
+ * @return {?WPBlock} The block, if it has been successfully
129
+ * registered; otherwise `undefined`.
130
+ */
131
+
132
+ registerBlockType(
133
+ 'yet-another-stars-rating/yasr-overall-rating', {
134
+ title: __( 'Yasr: Overall Rating', 'yet-another-stars-rating' ),
135
+ description: __('Insert the author rating', ''),
136
+ icon: 'star-half',
137
+ category: 'yet-another-stars-rating',
138
+ keywords: [
139
+ __('rating', 'yet-another-stars-rating'),
140
+ __('author', 'yet-another-stars-rating'),
141
+ __('overall', 'yet-another-stars-rating')
142
+ ],
143
+ attributes: {
144
+ overallRatingMeta: {
145
+ type: 'number',
146
+ source: 'meta',
147
+ meta: 'yasr_overall_rating'
148
+ },
149
+ size: {
150
+ type: 'string',
151
+ default: '--'
152
+ },
153
+ postId: {
154
+ type: 'number',
155
+ default: ''
156
+ },
157
+ },
158
+
159
+ edit:
160
+
161
+ function(props) {
162
+
163
+ const { attributes: {overallRatingMeta, size, postId}, setAttributes, isSelected } = props;
164
+
165
+ let overallRating = overallRatingMeta;
166
+
167
+ let sizeAttribute = null;
168
+ let postIdAttribute = null;
169
+ let isNum = false;
170
+
171
+ if (size !== '--') {
172
+ sizeAttribute = ' size="' + size + '"';
173
+ }
174
+
175
+ isNum = /^\d+#x2F;.test(postId);
176
+
177
+ if (postId && isNum === true) {
178
+ postIdAttribute = ' postid="' +postId + '"';
179
+ }
180
+
181
+ class YasrDivRatingOverall extends React.Component {
182
+
183
+ constructor(props) {
184
+ super(props);
185
+ this.yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
186
+ }
187
+
188
+ render () {
189
+ return (
190
+ <div>
191
+ {this.yasrOverallRateThis}
192
+ <div>
193
+ <div id="overall-rater" ref={()=>
194
+ raterJs({
195
+ starSize: 32,
196
+ step: 0.1,
197
+ showToolTip: false,
198
+ rating: overallRating,
199
+ readOnly: false,
200
+ element: document.querySelector("#overall-rater"),
201
+ rateCallback: function rateCallback(rating, done) {
202
+
203
+ rating = rating.toFixed(1);
204
+ rating = parseFloat(rating);
205
+
206
+ setAttributes( { overallRatingMeta: rating } );
207
+
208
+ this.setRating(rating);
209
+
210
+ done();
211
+
212
+ }
213
+ })
214
+ }
215
+ />
216
+ </div>
217
+ </div>
218
+
219
+ );
220
+ }
221
+
222
+ }
223
+
224
+ function YasrPrintSelectSize () {
225
+ return (
226
+ <form>
227
+ <select value={size} onChange={ yasrSetStarsSize }>
228
+ <option value="--">{yasrSelectSizeChoose}</option>
229
+ <option value="small">{yasrSelectSizeSmall}</option>
230
+ <option value="medium">{yasrSelectSizeMedium}</option>
231
+ <option value="large">{yasrSelectSizeLarge}</option>
232
+ </select>
233
+ </form>
234
+ );
235
+ }
236
+
237
+ function yasrSetStarsSize(event) {
238
+ const selected = event.target.querySelector( 'option:checked' );
239
+ setAttributes( { size: selected.value } );
240
+ event.preventDefault();
241
+ }
242
+
243
+ function YasrPrintInputId() {
244
+ return (
245
+ <div>
246
+ <input type="text" size="4" onKeyPress={yasrSetPostId} />
247
+ </div>
248
+ );
249
+ }
250
+
251
+ function yasrSetPostId (event) {
252
+ if (event.key === 'Enter') {
253
+ const postIdValue = event.target.value;
254
+
255
+ //postID is always a string, here I check if this string is made only by digits
256
+ var isNum = /^\d+#x2F;.test(postIdValue);
257
+
258
+ if (isNum === true) {
259
+ setAttributes({postId: postIdValue})
260
+ }
261
+ event.preventDefault();
262
+ }
263
+ }
264
+
265
+ function YasrOverallPanel (props) {
266
+
267
+ return (
268
+ <InspectorControls>
269
+ <div class="yasr-guten-block-panel yasr-guten-block-panel-center">
270
+ <YasrDivRatingOverall />
271
+ </div>
272
+
273
+ <PanelBody title='Settings'>
274
+ <h3>{yasrOptionalText}</h3>
275
+
276
+ <div className="yasr-guten-block-panel">
277
+ <label>{yasrLabelSelectSize}</label>
278
+ <div>
279
+ <YasrPrintSelectSize />
280
+ </div>
281
+ </div>
282
+
283
+ <div className="yasr-guten-block-panel">
284
+ <label>Post ID</label>
285
+ <YasrPrintInputId/>
286
+ <div className="yasr-guten-block-explain">
287
+ {yasrLeaveThisBlankText}
288
+ </div>
289
+ </div>
290
+
291
+ <div className="yasr-guten-block-panel">
292
+ {yasrOverallDescription}
293
+ </div>
294
+ </PanelBody>
295
+ </InspectorControls>
296
+ );
297
+
298
+ }
299
+
300
+ return (
301
+ <Fragment>
302
+ <YasrOverallPanel />
303
+ <div className={ props.className }>
304
+ [yasr_overall_rating{sizeAttribute}{postIdAttribute}]
305
+ {isSelected && <YasrPrintSelectSize />}
306
+ </div>
307
+ </Fragment>
308
+ );
309
+ },
310
+
311
+ /**
312
+ * The save function defines the way in which the different attributes should be combined
313
+ * into the final markup, which is then serialized by Gutenberg into post_content.
314
+ *
315
+ * The "save" property must be specified and must be a valid function.
316
+ *
317
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
318
+ */
319
+ save:
320
+ function( props ) {
321
+ const {attributes: {size, postId}} = props;
322
+
323
+ let yasrOverallAttributes = null;
324
+
325
+ if (size) {
326
+ yasrOverallAttributes += ' size="' +size+ '"';
327
+ }
328
+ if (postId) {
329
+ yasrOverallAttributes += ' postid="'+postId+'"';
330
+ }
331
+
332
+ return (
333
+ <div>[yasr_overall_rating {yasrOverallAttributes}]</div>
334
+ );
335
+ },
336
+
337
+ });
338
+
339
+ registerBlockType(
340
+ 'yet-another-stars-rating/yasr-visitor-votes', {
341
+
342
+ title: __( 'Yasr: Visitor Votes', 'yet-another-stars-rating' ),
343
+ description: __('Insert the ability for your visitors to vote', 'yet-another-stars-rating'),
344
+ icon: 'star-half',
345
+ category: 'yet-another-stars-rating',
346
+ keywords: [
347
+ __('rating', 'yet-another-stars-rating'),
348
+ __('visitor', 'yet-another-stars-rating'),
349
+ __('votes', 'yet-another-stars-rating')
350
+ ],
351
+ attributes: {
352
+ //name of the attribute
353
+ size: {
354
+ type: 'string',
355
+ default: '--'
356
+ },
357
+ postId: {
358
+ type: 'number',
359
+ default: ''
360
+ },
361
+ },
362
+
363
+ edit:
364
+
365
+ function( props ) {
366
+
367
+ const { attributes: { size, postId }, setAttributes, isSelected } = props;
368
+
369
+ let sizeAttribute = null;
370
+ let postIdAttribute = null;
371
+ let isNum = false;
372
+
373
+ isNum = /^\d+#x2F;.test(postId);
374
+
375
+ if (size !== '--') {
376
+ sizeAttribute = ' size="' + size + '"';
377
+ }
378
+
379
+ if (postId && isNum === true) {
380
+ postIdAttribute = ' postid="' +postId + '"';
381
+ }
382
+
383
+
384
+ function YasrPrintSelectSize () {
385
+ return (
386
+ <form>
387
+ <select value={size} onChange={ yasrSetStarsSize }>
388
+ <option value="--">{yasrSelectSizeChoose}</option>
389
+ <option value="small">{yasrSelectSizeSmall}</option>
390
+ <option value="medium">{yasrSelectSizeMedium}</option>
391
+ <option value="large">{yasrSelectSizeLarge}</option>
392
+ </select>
393
+ </form>
394
+ );
395
+ }
396
+
397
+ function yasrSetStarsSize(event) {
398
+ const selected = event.target.querySelector( 'option:checked' );
399
+ setAttributes( { size: selected.value } );
400
+ event.preventDefault();
401
+ }
402
+
403
+ function YasrPrintInputId() {
404
+ return (
405
+ <div>
406
+ <input type="text" size="4" onKeyPress={yasrSetPostId} />
407
+ </div>
408
+ );
409
+ }
410
+
411
+ function yasrSetPostId (event) {
412
+ if (event.key === 'Enter') {
413
+ const postIdValue = event.target.value;
414
+
415
+ //postID is always a string, here I check if this string is made only by digits
416
+ var isNum = /^\d+#x2F;.test(postIdValue);
417
+
418
+ if (isNum === true) {
419
+ setAttributes({postId: postIdValue})
420
+ }
421
+ event.preventDefault();
422
+ }
423
+ }
424
+
425
+ function YasrVVPanel (props) {
426
+
427
+ return (
428
+ <InspectorControls>
429
+ <PanelBody title='Settings'>
430
+ <h3>{yasrOptionalText}</h3>
431
+
432
+ <div className="yasr-guten-block-panel">
433
+ <label>{yasrLabelSelectSize}</label>
434
+ <div>
435
+ <YasrPrintSelectSize />
436
+ </div>
437
+ </div>
438
+
439
+ <div className="yasr-guten-block-panel">
440
+ <label>Post ID</label>
441
+ <YasrPrintInputId/>
442
+ <div className="yasr-guten-block-explain">
443
+ {yasrLeaveThisBlankText}
444
+ </div>
445
+ </div>
446
+
447
+ <div className="yasr-guten-block-panel">
448
+ {yasrVisitorVotesDescription}
449
+ </div>
450
+ </PanelBody>
451
+ </InspectorControls>
452
+ );
453
+
454
+ }
455
+
456
+ return (
457
+ <Fragment>
458
+ <YasrVVPanel />
459
+ <div className={props.className}>
460
+ [yasr_visitor_votes{sizeAttribute}{postIdAttribute}]
461
+ {isSelected && <YasrPrintSelectSize />}
462
+ </div>
463
+ </Fragment>
464
+ );
465
+ },
466
+
467
+ /**
468
+ * The save function defines the way in which the different attributes should be combined
469
+ * into the final markup, which is then serialized by Gutenberg into post_content.
470
+ *
471
+ * The "save" property must be specified and must be a valid function.
472
+ *
473
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
474
+ */
475
+ save:
476
+ function( props ) {
477
+ const { attributes: {size, postId} } = props;
478
+
479
+ let yasrVVAttributes = null;
480
+
481
+ if (size) {
482
+ yasrVVAttributes += ' size="' +size+ '"';
483
+ }
484
+ if (postId) {
485
+ yasrVVAttributes += ' postid="'+postId+'"';
486
+ }
487
+
488
+ return (
489
+ <div>[yasr_visitor_votes {yasrVVAttributes}]</div>
490
+ );
491
+ },
492
+
493
+ });
494
+
495
+ registerBlockType(
496
+ 'yet-another-stars-rating/overall-rating-ranking', {
497
+
498
+ title: __('Yasr: Top 10 Reviews', 'yet-another-stars-rating'),
499
+ description: __(
500
+ 'This ranking shows the highest rated posts rated through the overall_rating shortcode.',
501
+ 'yet-another-stars-rating'
502
+ ),
503
+ icon: 'star-half',
504
+ category: 'yet-another-stars-rating',
505
+ keywords: [
506
+ __('ranking', 'yet-another-stars-rating'),
507
+ __('highest', 'yet-another-stars-rating'),
508
+ __('chart', 'yet-another-stars-rating')
509
+ ],
510
+
511
+ edit:
512
+ function(props) {
513
+ return (
514
+ <Fragment>
515
+ <YasrNoSettingsPanel />
516
+ <div className={props.className}>
517
+ [yasr_top_ten_highest_rated]
518
+ </div>
519
+ </Fragment>
520
+ );
521
+ },
522
+
523
+
524
+ /**
525
+ * The save function defines the way in which the different attributes should be combined
526
+ * into the final markup, which is then serialized by Gutenberg into post_content.
527
+ *
528
+ * The "save" property must be specified and must be a valid function.
529
+ *
530
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
531
+ */
532
+ save:
533
+ function(props) {
534
+ return (
535
+ <div>[yasr_top_ten_highest_rated]</div>
536
+ );
537
+ },
538
+
539
+ });
540
+
541
+ registerBlockType(
542
+ 'yet-another-stars-rating/visitor-votes-ranking', {
543
+
544
+ title: __('Yasr: Top 10 By Visitors Votes', 'yet-another-stars-rating'),
545
+ description: __(
546
+ 'This ranking shows both the highest and most rated posts rated through the yasr_visitor_votes shortcode. For an item to appear in this chart, it has to be rated at least twice. ',
547
+ 'yet-another-stars-rating'
548
+ ),
549
+ icon: 'star-half',
550
+ category: 'yet-another-stars-rating',
551
+ keywords: [
552
+ __('ranking', 'yet-another-stars-rating'),
553
+ __('highest', 'yet-another-stars-rating'),
554
+ __('most', 'yet-another-stars-rating'),
555
+ __('chart', 'yet-another-stars-rating')
556
+ ],
557
+
558
+ edit:
559
+
560
+ function(props) {
561
+
562
+ return (
563
+ <Fragment>
564
+ <YasrNoSettingsPanel />
565
+ <div className={props.className}>
566
+ [yasr_most_or_highest_rated_posts]
567
+ </div>
568
+ </Fragment>
569
+ );
570
+ },
571
+
572
+ /**
573
+ * The save function defines the way in which the different attributes should be combined
574
+ * into the final markup, which is then serialized by Gutenberg into post_content.
575
+ *
576
+ * The "save" property must be specified and must be a valid function.
577
+ *
578
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
579
+ */
580
+ save:
581
+ function(props) {
582
+ return (
583
+ <div>[yasr_most_or_highest_rated_posts]</div>
584
+ );
585
+ },
586
+
587
+ });
588
+
589
+ registerBlockType(
590
+ 'yet-another-stars-rating/most-active-reviewers', {
591
+
592
+ title: __('Yasr: Most Active Authors', 'yet-another-stars-rating'),
593
+ description: __('This ranking shows the 5 most active reviewers on your site.',
594
+ 'yet-another-stars-rating'
595
+ ),
596
+ icon: 'star-half',
597
+ category: 'yet-another-stars-rating',
598
+ keywords: [
599
+ __('ranking', 'yet-another-stars-rating'),
600
+ __('highest', 'yet-another-stars-rating'),
601
+ __('most', 'yet-another-stars-rating'),
602
+ __('chart', 'yet-another-stars-rating'),
603
+ __('authors', 'yet-another-stars-rating')
604
+ ],
605
+
606
+ edit:
607
+
608
+ function(props) {
609
+
610
+ return (
611
+ <Fragment>
612
+ <YasrNoSettingsPanel />
613
+ <div className={props.className}>
614
+ [yasr_top_5_reviewers]
615
+ </div>
616
+ </Fragment>
617
+ );
618
+ },
619
+
620
+ /**
621
+ * The save function defines the way in which the different attributes should be combined
622
+ * into the final markup, which is then serialized by Gutenberg into post_content.
623
+ *
624
+ * The "save" property must be specified and must be a valid function.
625
+ *
626
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
627
+ */
628
+ save:
629
+ function(props) {
630
+ return (
631
+ <div>[yasr_top_5_reviewers]</div>
632
+ );
633
+ },
634
+
635
+ });
636
+
637
+ registerBlockType(
638
+ 'yet-another-stars-rating/most-active-users', {
639
+
640
+ title: __('Yasr: Most Active Visitors', 'yet-another-stars-rating'),
641
+ description: __('This ranking shows the 10 most active users, displaying the login name if logged in or “Anonymous” if not.',
642
+ 'yet-another-stars-rating'
643
+ ),
644
+ icon: 'star-half',
645
+ category: 'yet-another-stars-rating',
646
+ keywords: [
647
+ __('ranking', 'yet-another-stars-rating'),
648
+ __('highest', 'yet-another-stars-rating'),
649
+ __('most', 'yet-another-stars-rating'),
650
+ __('chart', 'yet-another-stars-rating'),
651
+ __('visitors', 'yet-another-stars-rating')
652
+ ],
653
+
654
+ edit:
655
+
656
+ function(props) {
657
+
658
+ return (
659
+ <Fragment>
660
+ <YasrNoSettingsPanel />
661
+ <div className={props.className}>
662
+ [yasr_top_ten_active_users]
663
+ </div>
664
+ </Fragment>
665
+ );
666
+ },
667
+
668
+ /**
669
+ * The save function defines the way in which the different attributes should be combined
670
+ * into the final markup, which is then serialized by Gutenberg into post_content.
671
+ *
672
+ * The "save" property must be specified and must be a valid function.
673
+ *
674
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
675
+ */
676
+ save:
677
+ function(props) {
678
+ return (
679
+ <div>[yasr_top_ten_active_users]</div>
680
+ );
681
+ },
682
+
683
+ });
admin/js/src/guten/yasr-guten-panel.js ADDED
@@ -0,0 +1,289 @@
1
+ const {registerPlugin} = wp.plugins;
2
+ const {PluginSidebar, PluginSidebarMoreMenuItem} = wp.editPost;
3
+ const {TextControl, PanelBody, PanelRow} = wp.components;
4
+ const {BlockControls,InspectorControls} = wp.editor;
5
+
6
+ const yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
7
+ const yasrRichSnippetOptions = __('Rich snippet options', 'yet-another-stars-rating');
8
+ const yasrPostExcluded = __('Is this a review?', 'yet-another-stars-rating');
9
+ const yasrSelectSnippetTitle = __('Select ItemType ', 'yet-another-stars-rating');
10
+
11
+ const ContentBelowSidebar = () => {
12
+ return <div/>;
13
+ };
14
+
15
+
16
+ class YasrDivRatingOverall extends React.Component {
17
+
18
+ shouldComponentUpdate(nextProps, nextState) {
19
+ return false;
20
+ }
21
+
22
+ constructor(props) {
23
+ super(props);
24
+ this.yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
25
+ this.yasrOverallMoreInfo =
26
+ __("This is the same value that you find the \"Yasr: Overall Rating\" block.",
27
+ 'yet-another-stars-rating');
28
+ }
29
+
30
+ printDivOverallRater() {
31
+ return(
32
+ <div>
33
+ <div id="overall-rater-panel" ref={()=>
34
+ raterJs({
35
+ starSize: 32,
36
+ step: 0.1,
37
+ showToolTip: false,
38
+ rating: wp.data.select('core/editor').getCurrentPost().meta.yasr_overall_rating,
39
+ readOnly: false,
40
+ element: document.querySelector("#overall-rater-panel"),
41
+ rateCallback: function(rating, done){
42
+
43
+ rating = rating.toFixed(1);
44
+ rating = parseFloat(rating);
45
+
46
+ wp.data.dispatch('core/editor').editPost(
47
+ { meta: { yasr_overall_rating: rating } }
48
+ );
49
+
50
+ this.setRating(rating);
51
+
52
+ done();
53
+ }
54
+ })
55
+ }
56
+ />
57
+ <br />
58
+ {this.yasrOverallMoreInfo}
59
+ </div>
60
+ )
61
+ }
62
+
63
+ render () {
64
+ return (
65
+ <div>
66
+ {this.yasrOverallRateThis}
67
+ <div>
68
+ {this.printDivOverallRater()}
69
+ </div>
70
+ </div>
71
+
72
+ );
73
+ }
74
+
75
+ }
76
+
77
+ class YasrSideBarAutoInsert extends React.Component {
78
+
79
+ constructor(props) {
80
+ super(props);
81
+
82
+ let isThisPostExluded = wp.data.select('core/editor').getCurrentPost().meta.yasr_auto_insert_disabled;
83
+ let isThisPostExludedCheckbox = false;
84
+
85
+ if (isThisPostExluded === 'yes') {
86
+ isThisPostExludedCheckbox = true;
87
+ }
88
+
89
+ this.state = {postExcluded: isThisPostExludedCheckbox};
90
+
91
+ this.yasrUpdatePostMetaAutoInsert = this.yasrUpdatePostMetaAutoInsert.bind(this);
92
+ }
93
+
94
+ yasrUpdatePostMetaAutoInsert(event) {
95
+ const target = event.target;
96
+ const postExcluded = target.type === 'checkbox' ? target.checked : target.value;
97
+
98
+ this.setState({postExcluded: postExcluded});
99
+
100
+ if (postExcluded === true) {
101
+ wp.data.dispatch('core/editor').editPost(
102
+ { meta: { yasr_auto_insert_disabled: 'yes' } }
103
+ );
104
+ } else {
105
+ wp.data.dispatch('core/editor').editPost(
106
+ { meta: { yasr_auto_insert_disabled: 'no' } }
107
+ );
108
+ }
109
+ }
110
+
111
+ render () {
112
+ return (
113
+ <div className="yasr-guten-block-panel-center">
114
+ <hr />
115
+ <label><span>{yasrDisableAutoInsert}</span></label>
116
+ <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
117
+ <input type="checkbox"
118
+ name="yasr_auto_insert_disabled"
119
+ className="yasr-onoffswitch-checkbox"
120
+ value="yes"
121
+ id="yasr-auto-insert-disabled-switch"
122
+ defaultChecked={this.state.postExcluded}
123
+ onChange={this.yasrUpdatePostMetaAutoInsert}
124
+ />
125
+ <label className="yasr-onoffswitch-label" htmlFor="yasr-auto-insert-disabled-switch">
126
+ <span className="yasr-onoffswitch-inner"/>
127
+ <span className="yasr-onoffswitch-switch"/>
128
+ </label>
129
+ </div>
130
+ </div>
131
+ );
132
+ }
133
+
134
+ }
135
+
136
+ /*class YasrDivIsReview extends React.Component {
137
+
138
+ constructor(props) {
139
+ super(props);
140
+
141
+ let isThisPostReview = wp.data.select('core/editor').getCurrentPost().meta.yasr_post_is_review;
142
+ let isThisPostReviewCheckbox = false;
143
+
144
+ if (isThisPostReview === 'yes') {
145
+ isThisPostReviewCheckbox = true;
146
+ }
147
+
148
+ this.state = {postIsReview: isThisPostReviewCheckbox};
149
+
150
+ this.yasrUpdatePostMetaIsReview = this.yasrUpdatePostMetaIsReview.bind(this);
151
+ }
152
+
153
+ yasrUpdatePostMetaIsReview(event) {
154
+
155
+ const target = event.target;
156
+ const postIsReview = target.type === 'checkbox' ? target.checked : target.value;
157
+
158
+ this.setState({postIsReview: postIsReview});
159
+
160
+ if (postIsReview === true) {
161
+ wp.data.dispatch('core/editor').editPost(
162
+ { meta: { yasr_post_is_review: 'yes' } }
163
+ );
164
+ } else {
165
+ wp.data.dispatch('core/editor').editPost(
166
+ { meta: { yasr_post_is_review: 'no' } }
167
+ );
168
+ }
169
+
170
+ }
171
+
172
+ render () {
173
+ return (
174
+ <div className="yasr-guten-block-panel-center">
175
+ <div className="rich-snippet-title">{yasrRichSnippetOptions}</div>
176
+ <label><span>{yasrPostExcluded}</span></label>
177
+ <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-post-is-review">
178
+ <input type="checkbox"
179
+ name="yasr_post_is_review"
180
+ className="yasr-onoffswitch-checkbox"
181
+ value="yes"
182
+ id="yasr-post-is-review-switch"
183
+ defaultChecked={this.state.postIsReview}
184
+ onChange={this.yasrUpdatePostMetaIsReview}
185
+ />
186
+ <label className="yasr-onoffswitch-label" htmlFor="yasr-post-is-review-switch">
187
+ <span className="yasr-onoffswitch-inner"></span>
188
+ <span className="yasr-onoffswitch-switch"></span>
189
+ </label>
190
+ </div>
191
+ <p></p>
192
+ </div>
193
+ );
194
+ }
195
+
196
+ }
197
+
198
+ class YasrSideBarSelectSnippets extends React.Component {
199
+
200
+ supportedItemtype;
201
+
202
+ constructor(props) {
203
+ super(props);
204
+
205
+ //at the begin, get the default type
206
+ let snippetType = yasrConstantGutenberg.defaultItemType;
207
+
208
+ //get array with all supported itemtypes
209
+ this.supportedItemtype = wp.data.select('core/editor').getCurrentPost().yasr_all_itemtypes;
210
+
211
+ //get postmeta itemtype
212
+ let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
213
+
214
+ //if the postmeta is in the array of all item, set in the select the postmeta_itemtype
215
+ if(this.supportedItemtype.includes(postMetaItemType)) {
216
+ snippetType = postMetaItemType;
217
+ }
218
+
219
+ this.state = {snippet: snippetType};
220
+
221
+ this.yasrSetItemType = this.yasrSetItemType.bind(this);
222
+ }
223
+
224
+ yasrSetItemType(event) {
225
+ this.setState({snippet: event.target.value});
226
+
227
+ wp.data.dispatch( 'core/editor' ).editPost(
228
+ { meta: { yasr_review_type: event.target.value } }
229
+ );
230
+ }
231
+
232
+ render() {
233
+ return (
234
+ <div className="yasr-guten-block-panel-center">
235
+ <label><span>{yasrSelectSnippetTitle}</span></label>
236
+ <select value={this.state.snippet} onChange={this.yasrSetItemType}>
237
+ {this.supportedItemtype.map((snippet) => {
238
+ return <option value={snippet}>{snippet}</option>;
239
+ })}
240
+ </select>
241
+ </div>
242
+ );
243
+ }
244
+ }*/
245
+
246
+ class yasrSidebar extends React.Component {
247
+
248
+ constructor(props) {
249
+ super(props);
250
+
251
+ let yasrAutoInsertEnabled = false;
252
+
253
+ //this is not for the post, but from settings
254
+ if (yasrConstantGutenberg.autoInsert !== 'disabled') {
255
+ yasrAutoInsertEnabled = true;
256
+ }
257
+
258
+ this.state = {yasrAutoInsertEnabled: yasrAutoInsertEnabled};
259
+
260
+ }
261
+
262
+ render() {
263
+ return (
264
+ <Fragment>
265
+ <PluginSidebarMoreMenuItem name="yasr-sidebar" type="sidebar" target="yasr-guten-sidebar" >
266
+ { __( 'YASR post settings', 'yet-another-stars-rating' ) }
267
+ </PluginSidebarMoreMenuItem>
268
+ <PluginSidebar name="yasr-guten-sidebar" title="YASR Settings">
269
+ <PanelBody>
270
+ <div className="yasr-guten-block-panel yasr-guten-block-panel-center">
271
+ <YasrDivRatingOverall />
272
+ {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
273
+ {<ContentBelowSidebar />}
274
+ </div>
275
+ </PanelBody>
276
+ </PluginSidebar>
277
+ </Fragment>
278
+ );
279
+ }
280
+ }
281
+
282
+
283
+
284
+ //Custom sidebar
285
+ registerPlugin( 'yasr-sidebar', {
286
+ icon: 'star-half',
287
+ title: __( 'Yasr: Page Settings', 'yet-another-stars-rating' ),
288
+ render: yasrSidebar
289
+ } );
admin/js/src/yasr-dashboard.js ADDED
@@ -0,0 +1,99 @@
1
+ //Vote log
2
+ jQuery(document).ready(function () {
3
+
4
+ //Log
5
+ jQuery('.yasr-log-pagenum').on('click', function () {
6
+
7
+ jQuery('#yasr-loader-log-metabox').show();
8
+
9
+ var data = {
10
+ action: 'yasr_change_log_page',
11
+ pagenum: jQuery(this).val(),
12
+ totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
13
+
14
+ };
15
+
16
+ jQuery.post(ajaxurl, data, function (response) {
17
+ jQuery('#yasr-loader-log-metabox').hide();
18
+ jQuery('#yasr-log-container').html(response);
19
+ });
20
+
21
+ });
22
+
23
+ jQuery(document).ajaxComplete(function (event, xhr, settings) {
24
+ var isYasrAjaxCall = true;
25
+
26
+ if(settings.data !== 'undefined') {
27
+ //check if the ajax call is done by yasr with action yasr_change_log_page
28
+ isYasrAjaxCall = settings.data.search("action=yasr_change_log_page");
29
+ }
30
+
31
+ if (isYasrAjaxCall !== -1) {
32
+ jQuery('.yasr-log-pagenum').on('click', function () {
33
+ jQuery('#yasr-loader-log-metabox').show();
34
+
35
+ var data = {
36
+ action: 'yasr_change_log_page',
37
+ pagenum: jQuery(this).val(),
38
+ totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
39
+ };
40
+
41
+ jQuery.post(ajaxurl, data, function (response) {
42
+ jQuery('#yasr-log-container').html(response); //This will hide the loader gif too
43
+ });
44
+ });
45
+ }
46
+
47
+ });
48
+
49
+ });
50
+
51
+
52
+ //Vote user log
53
+ jQuery(document).ready(function () {
54
+
55
+ //Log
56
+ jQuery('.yasr-user-log-page-num').on('click', function () {
57
+ jQuery('#yasr-loader-user-log-metabox').show();
58
+ var data = {
59
+ action: 'yasr_change_user_log_page',
60
+ pagenum: jQuery(this).val(),
61
+ totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
62
+
63
+ };
64
+ jQuery.post(ajaxurl, data, function (response) {
65
+ jQuery('#yasr-loader-log-metabox').hide();
66
+ jQuery('#yasr-user-log-container').html(response);
67
+ });
68
+ });
69
+
70
+ jQuery(document).ajaxComplete(function (event, xhr, settings) {
71
+ var isYasrAjaxCall = true;
72
+
73
+ if (typeof settings.data === 'undefined') {
74
+ return;
75
+ }
76
+
77
+ //check if the ajax call is done by yasr with action yasr_change_log_page
78
+ isYasrAjaxCall = settings.data.search("action=yasr_change_log_page");
79
+
80
+ if (isYasrAjaxCall !== -1) {
81
+ jQuery('.yasr-user-log-page-num').on('click', function () {
82
+ jQuery('#yasr-loader-user-log-metabox').show();
83
+
84
+ var data = {
85
+ action: 'yasr_change_user_log_page',
86
+ pagenum: jQuery(this).val(),
87
+ totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
88
+ };
89
+
90
+ jQuery.post(ajaxurl, data, function (response) {
91
+ jQuery('#yasr-user-log-container').html(response); //This will hide the loader gif too
92
+ });
93
+ });
94
+
95
+ }
96
+
97
+ });
98
+
99
+ });
admin/js/src/yasr-functions.js ADDED
@@ -0,0 +1,22 @@
1
+ copyToClipboard = string => {
2
+ const el = document.createElement('textarea');
3
+ el.value = string;
4
+ el.setAttribute('readonly', '');
5
+ el.style.position = 'absolute';
6
+ el.style.left = '-9999px';
7
+ document.body.appendChild(el);
8
+ el.select();
9
+ document.execCommand('copy');
10
+ document.body.removeChild(el);
11
+ };
12
+
13
+ tippy(
14
+ document.querySelectorAll('.yasr-copy-shortcode'),
15
+ {
16
+ content: 'Copied! Insert into your post!',
17
+ theme: 'yasr',
18
+ arrow: 'true',
19
+ arrowType: 'round',
20
+ trigger: 'click'
21
+ }
22
+ );
admin/js/src/yasr-settings-page.js ADDED
@@ -0,0 +1,237 @@
1
+ /****** Yasr Settings Page ******/
2
+
3
+ document.addEventListener('DOMContentLoaded', function(event) {
4
+
5
+ if (typeof document.getElementsByClassName('nav-tab-active')[0] === 'undefined') {
6
+ return;
7
+ }
8
+
9
+ //get active Tab
10
+ let activeTab = document.getElementsByClassName('nav-tab-active')[0].id;
11
+
12
+ //-------------------General Settings Code---------------------
13
+ if (activeTab === 'general_settings') {
14
+
15
+ let autoInsertEnabled = document.getElementById('yasr_auto_insert_switch').checked;
16
+ let textBeforeStars = document.getElementById('yasr-general-options-text-before-stars-switch').checked;
17
+
18
+ if (autoInsertEnabled === false) {
19
+ jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
20
+ }
21
+
22
+ //First Div, for auto insert
23
+ jQuery('#yasr_auto_insert_switch').change(function () {
24
+ if (jQuery(this).is(':checked')) {
25
+ jQuery('.yasr-auto-insert-options-class').prop('disabled', false);
26
+ } else {
27
+ jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
28
+ }
29
+ });
30
+
31
+ //for text before stars
32
+ if (textBeforeStars === false) {
33
+ jQuery('.yasr-general-options-text-before').prop('disabled', true);
34
+ }
35
+
36
+ jQuery('#yasr-general-options-text-before-stars-switch').change(function () {
37
+ if (jQuery(this).is(':checked')) {
38
+
39
+ jQuery('.yasr-general-options-text-before').prop('disabled', false);
40
+ jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
41
+ jQuery('#yasr-general-options-custom-text-before-visitor').val('Click to rate this post!');
42
+ jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
43
+ jQuery('#yasr-general-options-custom-text-must-sign-in').val('You must sign in to vote');
44
+ jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article');
45
+
46
+ } else {
47
+ jQuery('.yasr-general-options-text-before').prop('disabled', true);
48
+ }
49
+
50
+ });
51
+
52
+ jQuery('#yasr-doc-custom-text-link').on('click', function () {
53
+ jQuery('#yasr-doc-custom-text-div').toggle('slow');
54
+ return false;
55
+ });
56
+
57
+ jQuery('#yasr-stats-explained-link').on('click', function () {
58
+ jQuery('#yasr-stats-explained').toggle('slow');
59
+ return false;
60
+ });
61
+
62
+ } //End if general settings
63
+
64
+
65
+ //--------------Multi Sets Page ------------------
66
+ if (activeTab === 'manage_multi') {
67
+
68
+ let nMultiSet = document.getElementById('n-multiset').value;
69
+
70
+ jQuery('#yasr-multi-set-doc-link').on('click', function () {
71
+ jQuery('#yasr-multi-set-doc-box').toggle("slow");
72
+ });
73
+
74
+ jQuery('#yasr-multi-set-doc-link-hide').on('click', function () {
75
+ jQuery('#yasr-multi-set-doc-box').toggle("slow");
76
+ });
77
+
78
+ if (nMultiSet === 1) {
79
+ var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
80
+
81
+ counter++;
82
+
83
+ jQuery("#yasr-add-field-edit-multiset").on('click', function () {
84
+ if (counter > 9) {
85
+ jQuery('#yasr-element-limit').show();
86
+ jQuery('#yasr-add-field-edit-multiset').hide();
87
+ return false;
88
+ }
89
+
90
+ var newTextBoxDiv = jQuery(document.createElement('tr'));
91
+ newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
92
+ newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
93
+ counter++;
94
+ });
95
+
96
+
97
+ } //End if ($n_multi_set == 1)
98
+
99
+ if (nMultiSet > 1) {
100
+
101
+ //If more then 1 set is used...
102
+ jQuery('#yasr-button-select-set-edit-form').on("click", function () {
103
+
104
+ var data = {
105
+ action: 'yasr_get_multi_set',
106
+ set_id: jQuery('#yasr_select_edit_set').val()
107
+ };
108
+
109
+ jQuery.post(ajaxurl, data, function (response) {
110
+ jQuery('#yasr-multi-set-response').show();
111
+ jQuery('#yasr-multi-set-response').html(response);
112
+ });
113
+
114
+ return false; // prevent default click action from happening!
115
+
116
+ });
117
+
118
+ jQuery(document).ajaxComplete(function () {
119
+ var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
120
+ counter++;
121
+
122
+ jQuery("#yasr-add-field-edit-multiset").on('click', function () {
123
+ if (counter > 9) {
124
+ jQuery('#yasr-element-limit').show();
125
+ jQuery('#yasr-add-field-edit-multiset').hide();
126
+ return false;
127
+ }
128
+ var newTextBoxDiv = jQuery(document.createElement('tr'));
129
+ newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
130
+ newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
131
+ counter++;
132
+ });
133
+
134
+ });
135
+
136
+ } //End if ($n_multi_set > 1)
137
+
138
+ } //end if active_tab=='manage_multi'
139
+
140
+ if (activeTab === 'style_options') {
141
+ wp.codeEditor.initialize(
142
+ document.getElementById('yasr_style_options_textarea'),
143
+ yasr_cm_settings
144
+ );
145
+
146
+ jQuery('#yasr-color-scheme-preview-link').on('click', function () {
147
+ jQuery('#yasr-color-scheme-preview').toggle('slow');
148
+ return false; // prevent default click action from happening!
149
+ });
150
+
151
+ }
152
+
153
+ if (activeTab === 'migration_tools') {
154
+ jQuery('#yasr-import-ratemypost-submit').on('click', function () {
155
+
156
+ //show loader on click
157
+ document.getElementById('yasr-import-ratemypost-answer').innerHTML = '<img src="'
158
+ + yasrCommonDataAdmin.loaderHtml + '"</img>';
159
+
160
+ var nonce = document.getElementById('yasr-import-rmp-nonce').value;
161
+
162
+ var data = {
163
+ action: 'yasr_import_ratemypost',
164
+ nonce: nonce
165
+ };
166
+
167
+ jQuery.post(ajaxurl, data, function (response) {
168
+ response = JSON.parse(response);
169
+ document.getElementById('yasr-import-ratemypost-answer').innerHTML = response;
170
+ });
171
+
172
+ });
173
+
174
+ jQuery('#yasr-import-wppr-submit').on('click', function () {
175
+
176
+ //show loader on click
177
+ document.getElementById('yasr-import-wppr-answer').innerHTML = '<img src="'
178
+ + yasrCommonDataAdmin.loaderHtml + '"</img>';
179
+
180
+ var nonce = document.getElementById('yasr-import-wppr-nonce').value;
181
+
182
+ var data = {
183
+ action: 'yasr_import_wppr',
184
+ nonce: nonce
185
+ };
186
+
187
+ jQuery.post(ajaxurl, data, function (response) {
188
+ //response = JSON.parse(response);
189
+ document.getElementById('yasr-import-wppr-answer').innerHTML = response;
190
+ });
191
+
192
+ });
193
+
194
+ jQuery('#yasr-import-kksr-submit').on('click', function () {
195
+
196
+ //show loader on click
197
+ document.getElementById('yasr-import-kksr-answer').innerHTML = '<img src="'
198
+ + yasrCommonDataAdmin.loaderHtml + '"</img>';
199
+
200
+ var nonce = document.getElementById('yasr-import-kksr-nonce').value;
201
+
202
+ var data = {
203
+ action: 'yasr_import_kksr',
204
+ nonce: nonce
205
+ };
206
+
207
+ jQuery.post(ajaxurl, data, function (response) {
208
+ //response = JSON.parse(response);
209
+ document.getElementById('yasr-import-kksr-answer').innerHTML = response;
210
+ });
211
+
212
+ });
213
+
214
+ //import multi rating
215
+ jQuery('#yasr-import-mr-submit').on('click', function () {
216
+
217
+ //show loader on click
218
+ document.getElementById('yasr-import-mr-answer').innerHTML = '<img src="'
219
+ + yasrCommonDataAdmin.loaderHtml + '"</img>';
220
+
221
+ var nonce = document.getElementById('yasr-import-mr-nonce').value;
222
+
223
+ var data = {
224
+ action: 'yasr_import_mr',
225
+ nonce: nonce
226
+ };
227
+
228
+ jQuery.post(ajaxurl, data, function (response) {
229
+ //response = JSON.parse(response);
230
+ document.getElementById('yasr-import-mr-answer').innerHTML = response;
231
+ });
232
+
233
+ });
234
+ }
235
+ });
236
+
237
+ /****** End Yasr Settings Page ******/
admin/js/yasr-admin.js CHANGED
@@ -1,374 +1 @@
1
- /*
2
-
3
- Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
4
-
5
- This program is free software: you can redistribute it and/or modify
6
- it under the terms of the GNU General Public License as published by
7
- the Free Software Foundation, either version 2 of the License, or
8
- (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License
16
- along with this program. If not, see <http://www.gnu.org/licenses/>
17
- */
18
-
19
-
20
- /*** Constant used by yasr
21
-
22
- yasrCommonDataAdmin (loaderHtml)
23
-
24
- ***/
25
-
26
- /****** Yasr Settings Page ******/
27
-
28
- function YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled, textBeforeStars) {
29
-
30
- //-------------------General Settings Code---------------------
31
-
32
- if (activeTab === 'general_settings') {
33
-
34
- if (autoInsertEnabled == 0) {
35
- jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
36
- }
37
-
38
- //First Div, for auto insert
39
- jQuery('#yasr_auto_insert_switch').change(function () {
40
- if (jQuery(this).is(':checked')) {
41
- jQuery('.yasr-auto-insert-options-class').prop('disabled', false);
42
- } else {
43
- jQuery('.yasr-auto-insert-options-class').prop('disabled', true);
44
- }
45
- });
46
-
47
- //for text before stars
48
- if (textBeforeStars == 0) {
49
- jQuery('.yasr-general-options-text-before').prop('disabled', true);
50
- }
51
-
52
- jQuery('#yasr-general-options-text-before-stars-switch').change(function () {
53
- if (jQuery(this).is(':checked')) {
54
-
55
- jQuery('.yasr-general-options-text-before').prop('disabled', false);
56
- jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
57
- jQuery('#yasr-general-options-custom-text-before-visitor').val('Click to rate this post!');
58
- jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
59
- jQuery('#yasr-general-options-custom-text-must-sign-in').val('You must sign in to vote');
60
- jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article');
61
-
62
- } else {
63
- jQuery('.yasr-general-options-text-before').prop('disabled', true);
64
- }
65
-
66
- });
67
-
68
- jQuery('#yasr-doc-custom-text-link').on('click', function () {
69
- jQuery('#yasr-doc-custom-text-div').toggle('slow');
70
- return false;
71
- });
72
-
73
- jQuery('#yasr-stats-explained-link').on('click', function () {
74
- jQuery('#yasr-stats-explained').toggle('slow');
75
- return false;
76
- });
77
-
78
- } //End if general settings
79
-
80
- //--------------Multi Sets Page ------------------
81
-
82
- if (activeTab === 'manage_multi') {
83
-
84
- jQuery('#yasr-multi-set-doc-link').on('click', function () {
85
- jQuery('#yasr-multi-set-doc-box').toggle("slow");
86
- });
87
-
88
- jQuery('#yasr-multi-set-doc-link-hide').on('click', function () {
89
- jQuery('#yasr-multi-set-doc-box').toggle("slow");
90
- });
91
-
92
- if (nMultiSet == 1) {
93
-
94
- var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
95
-
96
- counter++;
97
-
98
- jQuery("#yasr-add-field-edit-multiset").on('click', function () {
99
-
100
- if (counter > 9) {
101
- jQuery('#yasr-element-limit').show();
102
- jQuery('#yasr-add-field-edit-multiset').hide();
103
- return false;
104
- }
105
-
106
- var newTextBoxDiv = jQuery(document.createElement('tr'));
107
-
108
- newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
109
-
110
- newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
111
-
112
- counter++;
113
-
114
- });
115
-
116
-
117
- } //End if ($n_multi_set == 1)
118
-
119
- if (nMultiSet > 1) {
120
-
121
- //If more then 1 set is used...
122
- jQuery('#yasr-button-select-set-edit-form').on("click", function () {
123
-
124
- var data = {
125
- action: 'yasr_get_multi_set',
126
- set_id: jQuery('#yasr_select_edit_set').val()
127
- };
128
-
129
- jQuery.post(ajaxurl, data, function (response) {
130
- jQuery('#yasr-multi-set-response').show();
131
- jQuery('#yasr-multi-set-response').html(response);
132
- });
133
-
134
- return false; // prevent default click action from happening!
135
-
136
- });
137
-
138
- jQuery(document).ajaxComplete(function () {
139
-
140
- var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
141
-
142
- counter++;
143
-
144
- jQuery("#yasr-add-field-edit-multiset").on('click', function () {
145
-
146
- if (counter > 9) {
147
- jQuery('#yasr-element-limit').show();
148
- jQuery('#yasr-add-field-edit-multiset').hide();
149
- return false;
150
- }
151
-
152
- var newTextBoxDiv = jQuery(document.createElement('tr'));
153
-
154
- newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
155
-
156
- newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
157
-
158
- counter++;
159
-
160
- });
161
-
162
- });
163
-
164
- } //End if ($n_multi_set > 1)
165
-
166
-
167
- } //end if active_tab=='manage_multi'
168
-
169
-
170
- if (activeTab === 'style_options') {
171
- wp.codeEditor.initialize(
172
- document.getElementById('yasr_style_options_textarea'),
173
- yasr_cm_settings
174
- );
175
-
176
- jQuery('#yasr-color-scheme-preview-link').on('click', function () {
177
- jQuery('#yasr-color-scheme-preview').toggle('slow');
178
- return false; // prevent default click action from happening!
179
- });
180
-
181
- }
182
-
183
-
184
- }
185
-
186
-
187
- /****** Migration tools page ******/
188
- document.addEventListener('DOMContentLoaded', function(event) {
189
-
190
- jQuery('#yasr-import-ratemypost-submit').on('click', function() {
191
-
192
- //show loader on click
193
- document.getElementById('yasr-import-ratemypost-answer').innerHTML = '<img src="'
194
- +yasrCommonDataAdmin.loaderHtml+'"</img>';
195
-
196
- var nonce = document.getElementById('yasr-import-rmp-nonce').value;
197
-
198
- var data = {
199
- action: 'yasr_import_ratemypost',
200
- nonce: nonce
201
- };
202
-
203
- jQuery.post(ajaxurl, data, function (response) {
204
- response = JSON.parse(response);
205
- document.getElementById('yasr-import-ratemypost-answer').innerHTML = response;
206
- });
207
-
208
- });
209
-
210
- jQuery('#yasr-import-wppr-submit').on('click', function() {
211
-
212
- //show loader on click
213
- document.getElementById('yasr-import-wppr-answer').innerHTML = '<img src="'
214
- +yasrCommonDataAdmin.loaderHtml+'"</img>';
215
-
216
- var nonce = document.getElementById('yasr-import-wppr-nonce').value;
217
-
218
- var data = {
219
- action: 'yasr_import_wppr',
220
- nonce: nonce
221
- };
222
-
223
- jQuery.post(ajaxurl, data, function (response) {
224
- //response = JSON.parse(response);
225
- document.getElementById('yasr-import-wppr-answer').innerHTML = response;
226
- });
227
-
228
- });
229
-
230
- jQuery('#yasr-import-kksr-submit').on('click', function() {
231
-
232
- //show loader on click
233
- document.getElementById('yasr-import-kksr-answer').innerHTML = '<img src="'
234
- +yasrCommonDataAdmin.loaderHtml+'"</img>';
235
-
236
- var nonce = document.getElementById('yasr-import-kksr-nonce').value;
237
-
238
- var data = {
239
- action: 'yasr_import_kksr',
240
- nonce: nonce
241
- };
242
-
243
- jQuery.post(ajaxurl, data, function (response) {
244
- //response = JSON.parse(response);
245
- document.getElementById('yasr-import-kksr-answer').innerHTML = response;
246
- });
247
-
248
- });
249
-
250
- //import multi rating
251
- jQuery('#yasr-import-mr-submit').on('click', function() {
252
-
253
- //show loader on click
254
- document.getElementById('yasr-import-mr-answer').innerHTML = '<img src="'
255
- +yasrCommonDataAdmin.loaderHtml+'"</img>';
256
-
257
- var nonce = document.getElementById('yasr-import-mr-nonce').value;
258
-
259
- var data = {
260
- action: 'yasr_import_mr',
261
- nonce: nonce
262
- };
263
-
264
- jQuery.post(ajaxurl, data, function (response) {
265
- //response = JSON.parse(response);
266
- document.getElementById('yasr-import-mr-answer').innerHTML = response;
267
- });
268
-
269
- });
270
-
271
- });
272
-
273
- /****** End Yasr Settings Page ******/
274
-
275
- /****** Yasr db functions ******/
276
-
277
- //Vote log
278
- jQuery(document).ready(function () {
279
-
280
- //Log
281
- jQuery('.yasr-log-pagenum').on('click', function () {
282
-
283
- jQuery('#yasr-loader-log-metabox').show();
284
-
285
- var data = {
286
- action: 'yasr_change_log_page',
287
- pagenum: jQuery(this).val(),
288
- totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
289
-
290
- };
291
-
292
- jQuery.post(ajaxurl, data, function (response) {
293
- jQuery('#yasr-loader-log-metabox').hide();
294
- jQuery('#yasr-log-container').html(response);
295
- });
296
-
297
- });
298
-
299
- jQuery(document).ajaxComplete(function (event, xhr, settings) {
300
- var isYasrAjaxCall = true;
301
-
302
- if(settings.data !== 'undefined') {
303
- //check if the ajax call is done by yasr with action yasr_change_log_page
304
- isYasrAjaxCall = settings.data.search("action=yasr_change_log_page");
305
- }
306
-
307
- if (isYasrAjaxCall !== -1) {
308
- jQuery('.yasr-log-pagenum').on('click', function () {
309
- jQuery('#yasr-loader-log-metabox').show();
310
-
311
- var data = {
312
- action: 'yasr_change_log_page',
313
- pagenum: jQuery(this).val(),
314
- totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
315
- };
316
-
317
- jQuery.post(ajaxurl, data, function (response) {
318
- jQuery('#yasr-log-container').html(response); //This will hide the loader gif too
319
- });
320
- });
321
- }
322
-
323
- });
324
-
325
- });
326
-
327
-
328
- //Vote user log
329
- jQuery(document).ready(function () {
330
-
331
- //Log
332
- jQuery('.yasr-user-log-page-num').on('click', function () {
333
- jQuery('#yasr-loader-user-log-metabox').show();
334
- var data = {
335
- action: 'yasr_change_user_log_page',
336
- pagenum: jQuery(this).val(),
337
- totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
338
-
339
- };
340
- jQuery.post(ajaxurl, data, function (response) {
341
- jQuery('#yasr-loader-log-metabox').hide();
342
- jQuery('#yasr-user-log-container').html(response);
343
- });
344
- });
345
-
346
- jQuery(document).ajaxComplete(function (event, xhr, settings) {
347
- var isYasrAjaxCall = true;
348
-
349
- if(settings.data !== 'undefined') {
350
- //check if the ajax call is done by yasr with action yasr_change_log_page
351
- isYasrAjaxCall = settings.data.search("action=yasr_change_log_page");
352
- }
353
- if (isYasrAjaxCall !== -1) {
354
- jQuery('.yasr-user-log-page-num').on('click', function () {
355
- jQuery('#yasr-loader-user-log-metabox').show();
356
-
357
- var data = {
358
- action: 'yasr_change_user_log_page',
359
- pagenum: jQuery(this).val(),
360
- totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
361
- };
362
-
363
- jQuery.post(ajaxurl, data, function (response) {
364
- jQuery('#yasr-user-log-container').html(response); //This will hide the loader gif too
365
- });
366
- });
367
-
368
- }
369
-
370
- });
371
-
372
- });
373
-
374
- /****** End yasr db functions ******/
1
+ !function(e){var t={};function r(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(o,a,function(t){return e[t]}.bind(null,a));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),r(2),e.exports=r(3)},function(e,t){copyToClipboard=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"})},function(e,t){jQuery(document).ready((function(){jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){var o=!0;"undefined"!==r.data&&(o=r.data.search("action=yasr_change_log_page")),-1!==o&&jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-log-container").html(e)}))}))}))})),jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_log_page")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-user-log-container").html(e)}))}))}))}))},function(e,t){document.addEventListener("DOMContentLoaded",(function(e){if(void 0===document.getElementsByClassName("nav-tab-active")[0])return;let t=document.getElementsByClassName("nav-tab-active")[0].id;if("general_settings"===t){let e=document.getElementById("yasr_auto_insert_switch").checked,t=document.getElementById("yasr-general-options-text-before-stars-switch").checked;!1===e&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),jQuery("#yasr_auto_insert_switch").change((function(){jQuery(this).is(":checked")?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),!1===t&&jQuery(".yasr-general-options-text-before").prop("disabled",!0),jQuery("#yasr-general-options-text-before-stars-switch").change((function(){jQuery(this).is(":checked")?(jQuery(".yasr-general-options-text-before").prop("disabled",!1),jQuery("#yasr-general-options-custom-text-before-overall").val("Our Score"),jQuery("#yasr-general-options-custom-text-before-visitor").val("Click to rate this post!"),jQuery("#yasr-general-options-custom-text-after-visitor").val("[Total: %total_count% Average: %average%]"),jQuery("#yasr-general-options-custom-text-must-sign-in").val("You must sign in to vote"),jQuery("#yasr-general-options-custom-text-already-rated").val("You have already voted for this article")):jQuery(".yasr-general-options-text-before").prop("disabled",!0)})),jQuery("#yasr-doc-custom-text-link").on("click",(function(){return jQuery("#yasr-doc-custom-text-div").toggle("slow"),!1})),jQuery("#yasr-stats-explained-link").on("click",(function(){return jQuery("#yasr-stats-explained").toggle("slow"),!1}))}if("manage_multi"===t){let e=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===e){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++}))}e>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++}))})))}"style_options"===t&&(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}))),"migration_tools"===t&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';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="'+yasrCommonDataAdmin.loaderHtml+'"</img>';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="'+yasrCommonDataAdmin.loaderHtml+'"</img>';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="'+yasrCommonDataAdmin.loaderHtml+'"</img>';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}))})))}))}]);