Yasr – Yet Another Stars Rating - Version 2.0.0

Version Description

  • NEW FEATURE: is now possible to import date from:
  • Wp Post Ratings
  • KK Star Ratings
  • Rate My Post
  • FIXED: in editor screen, multi set didn't shows up if more than 1 was used
  • TWEAKED: minor changes
Download this release

Release Info

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

Code changes from version 1.9.9 to 2.0.0

changelog.txt CHANGED
@@ -1,3 +1,17 @@
1
= 1.9.0 =
2
* NEW FEATURE: yasr_visitor_votes is now a Gutenberg block
3
* FIXED: In Gutenberg, when using yasr_overall_rating block, if post is rated and size or post_id is changed, stars got full filled
@@ -7,10 +21,6 @@
7
* TWEAKED: added a div with class "yasr-overall-rating" in the front end shortcode to allow customization
8
* TWEAKED: dropped out support for extensions
9
* TWEAKED: minor changes
10
- [//]: # fs_premium_only_begin
11
- * TWEAKED: if enabled, use curl instead of file_get_contents
12
- * FIXED: missing text in the image upload sections
13
- [//]: # fs_premium_only_end
14
15
= 1.8.9 =
16
* FIXED: updated freemius sdk to version 2.2.4
@@ -40,10 +50,6 @@
40
41
= 1.8.3 =
42
* FIXED: multiset doesn't show up in the edit screen if only 1 is used
43
- [//]: # fs_premium_only_begin
44
- * FIXED: Missing stars in Yasr Custom Rankings
45
- * TWEAKED: oxygen icon
46
- [//]: # fs_premium_only_end
47
48
= 1.8.2 =
49
* FIXED: widgets didn't load in front end
@@ -54,11 +60,6 @@
54
= 1.8.0 =
55
* This is a very important release. A lot of code has been cleaned up/rewritten. Images are not png anymore, but svg.
56
Everthing is now fresher and even more lightweight then before. If you customized your stars set, check it again in the settings.
57
- [//]: # fs_premium_only_begin
58
- * FIXED: string when the rating of a review is updated
59
- * FIXED: Javascript error when the current user has not left a review for a post or page
60
- * FIXED: undefined constant
61
- [//]: # fs_premium_only_end
62
63
= 1.7.4 =
64
* Css fixes
@@ -68,10 +69,6 @@ Everthing is now fresher and even more lightweight then before. If you customize
68
* TWEAKED: progress bars doesn't use jquery anymore, it's css only
69
* TWEAKED: tooltip for yasr_visitor_votes doesn't use jquery anymore, but uses [tippy](https://atomiks.github.io/tippyjs/) instead
70
* TWEAKED: A lot of under the hood changes
71
- [//]: # fs_premium_only_begin
72
- * FIXED: Cookie check wasn't working
73
- * TWEAKED: Review in comments now can work without Jquery
74
- [//]: # fs_premium_only_end
75
76
= 1.7.2 =
77
* FIXED: yasr_visitor_multiset didn't work
1
+ = 1.9.4 =
2
+ * NEW: In the settings, is now possible to customize the "you must sign in" text; two html tags are supported: < strong > and < p >
3
+ * FIXED: Update transient to show the new average when a rating get deleted from the panel
4
+ * TWEAKED: Code cleanup
5
+
6
+ = 1.9.3 =
7
+ * Minor changes and code cleanup.
8
+
9
+ = 1.9.2 =
10
+ * FIXED: Javascript error on some mobile device
11
+
12
+ = 1.9.1 =
13
+ * FIXED: In some (rare) case, overall rating get empty with Gutenberg
14
+
15
= 1.9.0 =
16
* NEW FEATURE: yasr_visitor_votes is now a Gutenberg block
17
* FIXED: In Gutenberg, when using yasr_overall_rating block, if post is rated and size or post_id is changed, stars got full filled
21
* TWEAKED: added a div with class "yasr-overall-rating" in the front end shortcode to allow customization
22
* TWEAKED: dropped out support for extensions
23
* TWEAKED: minor changes
24
25
= 1.8.9 =
26
* FIXED: updated freemius sdk to version 2.2.4
50
51
= 1.8.3 =
52
* FIXED: multiset doesn't show up in the edit screen if only 1 is used
53
54
= 1.8.2 =
55
* FIXED: widgets didn't load in front end
60
= 1.8.0 =
61
* This is a very important release. A lot of code has been cleaned up/rewritten. Images are not png anymore, but svg.
62
Everthing is now fresher and even more lightweight then before. If you customized your stars set, check it again in the settings.
63
64
= 1.7.4 =
65
* Css fixes
69
* TWEAKED: progress bars doesn't use jquery anymore, it's css only
70
* TWEAKED: tooltip for yasr_visitor_votes doesn't use jquery anymore, but uses [tippy](https://atomiks.github.io/tippyjs/) instead
71
* TWEAKED: A lot of under the hood changes
72
73
= 1.7.2 =
74
* FIXED: yasr_visitor_multiset didn't work
css/yasr-admin.css CHANGED
@@ -580,6 +580,28 @@
580
581
/**** End Yasr Aspect & Styles tab ***/
582
583
584
/*** Popup in tinymce ***/
585
580
581
/**** End Yasr Aspect & Styles tab ***/
582
583
+ /**** Migration Tools Page ****/
584
+
585
+ .title-plugin-found{
586
+ font-size: 18px;
587
+ font-weight: bold;
588
+ color: #2ca02c;
589
+ }
590
+
591
+ .yasr-alert-box {
592
+ margin-top: 15px;
593
+ margin-bottom: 15px;
594
+ margin-left: 10px;
595
+ padding: 10px;
596
+ padding-left: 30px;
597
+ border: #ff806e 2px dashed;
598
+ width: 70%;
599
+ }
600
+
601
+ /**** End Migration Tools Page ****/
602
+
603
+
604
+
605
606
/*** Popup in tinymce ***/
607
js/src/yasr-guten-panel.js CHANGED
@@ -132,4 +132,4 @@ registerPlugin( 'yasr-sidebar', {
132
icon: 'star-half',
133
title: __( 'Yasr: Page Settings', 'yet-another-stars-rating' ),
134
render: yasrSidebar
135
- } );
132
icon: 'star-half',
133
title: __( 'Yasr: Page Settings', 'yet-another-stars-rating' ),
134
render: yasrSidebar
135
+ } );
js/yasr-admin.js CHANGED
@@ -81,6 +81,8 @@ function yasrAdminMultiSet(nMultiSet, postid, setId, nonceMulti) {
81
82
yasrPrintAdminMultiSet(setId, postid, nonceMulti);
83
84
});
85
86
}
@@ -330,7 +332,7 @@ function YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled, textBeforeSta
330
return false;
331
}
332
333
- var newTextBoxDiv = jQuery(document.createElement('tr'))
334
335
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
336
@@ -406,43 +408,71 @@ function YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled, textBeforeSta
406
407
}
408
409
- function YasrAsk5Stars(nonceHideAskRating) {
410
411
- //This will call an ajax action that set a site transite to hide
412
- //for a week the metabok
413
- jQuery('#yasr-ask-five-star-later').on("click", function () {
414
415
- jQuery('#yasr-ask-five-stars').hide();
416
417
- var data = {
418
- action: 'yasr_hide_ask_rating_metabox',
419
- choose: 'hide',
420
- nonce: nonceHideAskRating
421
422
};
423
424
- jQuery.post(ajaxurl, data);
425
426
});
427
428
429
- //This will close the ask rating metabox forever
430
- jQuery('#yasr-ask-five-close').on("click", function () {
431
432
- jQuery('#yasr-ask-five-stars').hide();
433
434
var data = {
435
- action: 'yasr_hide_ask_rating_metabox',
436
- choose: 'close',
437
- nonce: nonceHideAskRating
438
};
439
440
- jQuery.post(ajaxurl, data);
441
442
});
443
444
445
- }
446
447
/****** End Yasr Settings Page ******/
448
81
82
yasrPrintAdminMultiSet(setId, postid, nonceMulti);
83
84
+ return false; // prevent default click action from happening!
85
+
86
});
87
88
}
332
return false;
333
}
334
335
+ var newTextBoxDiv = jQuery(document.createElement('tr'));
336
337
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
338
408
409
}
410
411
412
+ /****** Migration tools page ******/
413
+ document.addEventListener('DOMContentLoaded', function(event) {
414
415
+ jQuery('#yasr-import-ratemypost-submit').on('click', function() {
416
417
+ //show loader on click
418
+ document.getElementById('yasr-import-ratemypost-answer').innerHTML = '<img src="'
419
+ +yasrCommonDataAdmin.loaderHtml+'"</img>';
420
421
+ var nonce = document.getElementById('yasr-import-rmp-nonce').value;
422
+
423
+ var data = {
424
+ action: 'yasr_import_ratemypost',
425
+ nonce: nonce
426
};
427
428
+ jQuery.post(ajaxurl, data, function (response) {
429
+ response = JSON.parse(response);
430
+ document.getElementById('yasr-import-ratemypost-answer').innerHTML = response;
431
+ });
432
433
});
434
435
+ jQuery('#yasr-import-wppr-submit').on('click', function() {
436
437
+ //show loader on click
438
+ document.getElementById('yasr-import-wppr-answer').innerHTML = '<img src="'
439
+ +yasrCommonDataAdmin.loaderHtml+'"</img>';
440
441
+ var nonce = document.getElementById('yasr-import-wppr-nonce').value;
442
443
var data = {
444
+ action: 'yasr_import_wppr',
445
+ nonce: nonce
446
};
447
448
+ jQuery.post(ajaxurl, data, function (response) {
449
+ //response = JSON.parse(response);
450
+ document.getElementById('yasr-import-wppr-answer').innerHTML = response;
451
+ });
452
453
});
454
455
+ jQuery('#yasr-import-kksr-submit').on('click', function() {
456
457
+ //show loader on click
458
+ document.getElementById('yasr-import-kksr-answer').innerHTML = '<img src="'
459
+ +yasrCommonDataAdmin.loaderHtml+'"</img>';
460
+
461
+ var nonce = document.getElementById('yasr-import-kksr-nonce').value;
462
+
463
+ var data = {
464
+ action: 'yasr_import_kksr',
465
+ nonce: nonce
466
+ };
467
+
468
+ jQuery.post(ajaxurl, data, function (response) {
469
+ //response = JSON.parse(response);
470
+ document.getElementById('yasr-import-kksr-answer').innerHTML = response;
471
+ });
472
+
473
+ });
474
+
475
+ });
476
477
/****** End Yasr Settings Page ******/
478
lib/admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -1,41 +1,123 @@
1
<?php
2
3
- function yasr_upgrade_pro_box($position = false) {
4
5
- if (yasr_fs()->is_free_plan()) {
6
7
- if ($position && $position == "bottom") {
8
$yasr_upgrade_class = "yasr-donatedivbottom";
9
} else {
10
$yasr_upgrade_class = "yasr-donatedivdx";
11
}
12
-
13
?>
14
15
- <div class="<?php echo $yasr_upgrade_class ?>" style="display: none">
16
17
<h2 class="yasr-donate-title" style="color: #34A7C1">
18
- <?php _e('Upgrade to YASR Pro', 'yet-another-stars-rating'); ?>
19
</h2>
20
21
<div class="yasr-upgrade-to-pro">
22
<ul>
23
- <li><strong><?php _e(' User Reviews', 'yet-another-stars-rating'); ?></strong></li>
24
- <li><strong><?php _e(' Custom Rankings', 'yet-another-stars-rating'); ?></strong></li>
25
- <li><strong><?php _e(' 20 + ready to use themes', 'yet-another-stars-rating'); ?></strong></li>
26
- <li><strong><?php _e(' Upload your own theme', 'yet-another-stars-rating'); ?></strong></li>
27
- <li><strong><?php _e(' Dedicate support', 'yet-another-stars-rating'); ?></strong></li>
28
- <li><strong><?php _e(' ...And much more!!', 'yet-another-stars-rating'); ?></strong></li>
29
</ul>
30
- <a href="<?php echo yasr_fs()->get_upgrade_url(); ?>">
31
<button class="button button-primary">Upgrade Now</button>
32
</a>
33
</div>
34
35
</div>
36
37
- <?php
38
-
39
}
40
41
}
@@ -45,41 +127,32 @@ function yasr_upgrade_pro_box($position = false) {
45
* Since version 1.9.5
46
*
47
*/
48
-
49
- function yasr_resources_box($position = false) {
50
-
51
- if ($position && $position == "bottom") {
52
$yasr_metabox_class = "yasr-donatedivbottom";
53
- } else {
54
$yasr_metabox_class = "yasr-donatedivdx";
55
}
56
-
57
- $div = "<div class='$yasr_metabox_class' id='yasr-resources-box' style='display:none;'>";
58
-
59
$text = '<div class="yasr-donate-title">Resources</div>';
60
$text .= '<div class="yasr-donate-single-resource">
61
<span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
62
- <a target="blank" href="http://yetanotherstarsrating.com/">'
63
- . __('YASR official website', 'yet-another-stars-rating') .
64
- '</a>
65
</div>';
66
$text .= '<div class="yasr-donate-single-resource">
67
<span class="dashicons dashicons-edit" style="color: #ccc"></span>
68
- <a target="blank" href="https://yetanotherstarsrating.com/yasr-basics-shortcode/">'
69
- . __('Documentation', 'yet-another-stars-rating') .
70
- '</a>
71
</div>';
72
$text .= '<div class="yasr-donate-single-resource">
73
<span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
74
- <a target="blank" href="https://yetanotherstarsrating.com/f-a-q/">'
75
- . __('F.A.Q.', 'yet-another-stars-rating') .
76
- '</a>
77
</div>';
78
$text .= '<div class="yasr-donate-single-resource">
79
<span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
80
- <a target="blank" href="https://www.youtube.com/channel/UCU5jbO1PJsUUsCNbME9S-Zw">'
81
- . __('Youtube channel', 'yet-another-stars-rating') .
82
- '</a>
83
</div>';
84
$text .= '<div class="yasr-donate-single-resource">
85
<span class="dashicons dashicons-smiley" style="color: #ccc"></span>
@@ -87,29 +160,24 @@ function yasr_resources_box($position = false) {
87
Yasr Pro
88
</a>
89
</div>';
90
-
91
-
92
$div_and_text = $div . $text . '</div>';
93
-
94
- echo $div_and_text;
95
-
96
}
97
98
/** Add a box on the right for asking to rate 5 stars on Wordpress.org
99
* Since version 0.9.0
100
*/
101
-
102
- function yasr_ask_rating($position = false) {
103
-
104
- if ($position && $position == "bottom") {
105
$yasr_metabox_class = "yasr-donatedivbottom";
106
- } else {
107
$yasr_metabox_class = "yasr-donatedivdx";
108
}
109
-
110
- $div = "<div class='$yasr_metabox_class' id='yasr-ask-five-stars' style='display:none;'>";
111
-
112
- $text = '<div class="yasr-donate-title">' . __('Can I ask your help?', 'yet-another-stars-rating') .'</div>';
113
$text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
114
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
115
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
@@ -117,67 +185,55 @@ function yasr_ask_rating($position = false) {
117
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
118
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
119
</div>';
120
- $text .= __('Please rate YASR 5 stars on', 'yet-another-stars-rating');
121
$text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
122
WordPress.org.</a><br />';
123
- $text .= __(' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating');
124
$text .= "<br /><br />";
125
$text .= "<em>> Dario Curvino</em>";
126
-
127
$div_and_text = $div . $text . '</div>';
128
-
129
- echo $div_and_text;
130
-
131
}
132
133
-
134
/****
135
Yasr Right settings panel, since version 1.9.5
136
****/
137
-
138
- function yasr_right_settings_panel($position = false) {
139
- do_action('yasr_right_settings_panel_box', $position);
140
- yasr_upgrade_pro_box($position);
141
- yasr_resources_box($position);
142
- yasr_ask_rating($position);
143
}
144
145
-
146
/** Change default admin footer on yasr settings pages
147
* $text is the default wordpress text
148
* Since 0.8.9
149
*/
150
-
151
- add_filter('admin_footer_text', 'yasr_custom_admin_footer');
152
-
153
- function yasr_custom_admin_footer($text) {
154
-
155
- if (isset($_GET['page'])) {
156
$yasr_page = $_GET['page'];
157
-
158
- if ($yasr_page == 'yasr_settings_page') {
159
$custom_text = ' | <i>';
160
$custom_text .= sprintf(
161
- __('Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
162
- Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>',
163
- 'yet-another-stars-rating'
164
- ),
165
'https://yetanotherstarsrating.com',
166
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
167
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
168
);
169
$custom_text .= '</i>';
170
-
171
return $text . $custom_text;
172
-
173
} else {
174
return $text;
175
}
176
-
177
} else {
178
return $text;
179
}
180
181
}
182
-
183
- ?>
1
<?php
2
3
+ /**Drow settings tab*/
4
+ function yasr_settings_tabs( $active_tab )
5
+ {
6
+ ?>
7
8
+ <h2 class="nav-tab-wrapper yasr-no-underline">
9
10
+ <a href="?page=yasr_settings_page&tab=general_settings"
11
+ class="nav-tab <?php
12
+ if ( $active_tab === 'general_settings' ) {
13
+ echo 'nav-tab-active' ;
14
+ }
15
+ ?>">
16
+ <?php
17
+ _e( "General Settings", 'yet-another-stars-rating' );
18
+ ?>
19
+ </a>
20
+
21
+ <a href="?page=yasr_settings_page&tab=manage_multi" class="nav-tab <?php
22
+ if ( $active_tab === 'manage_multi' ) {
23
+ echo 'nav-tab-active' ;
24
+ }
25
+ ?>">
26
+ <?php
27
+ _e( "Multi Sets", 'yet-another-stars-rating' );
28
+ ?>
29
+ </a>
30
+
31
+ <a href="?page=yasr_settings_page&tab=style_options"
32
+ class="nav-tab <?php
33
+ if ( $active_tab === 'style_options' ) {
34
+ echo 'nav-tab-active' ;
35
+ }
36
+ ?>">
37
+ <?php
38
+ _e( "Aspect & Styles", 'yet-another-stars-rating' );
39
+ ?>
40
+ </a>
41
+
42
+ <?php
43
+ do_action( 'yasr_add_settings_tab', $active_tab );
44
+ $rating_plugin_exists = new yasrSearchExistingRatingPlugin();
45
+
46
+ if ( $rating_plugin_exists->yasr_search_wppr() || $rating_plugin_exists->yasr_search_rmp() || $rating_plugin_exists->yasr_search_kksr() ) {
47
+ ?>
48
+ <a href="?page=yasr_settings_page&tab=migration_tools" class="nav-tab <?php
49
+ if ( $active_tab === 'migration_tools' ) {
50
+ echo 'nav-tab-active' ;
51
+ }
52
+ ?>">
53
+ <?php
54
+ _e( "Migration Tools", 'yet-another-stars-rating' );
55
+ ?>
56
+ </a>
57
+ <?php
58
+ }
59
+
60
+ ?>
61
+
62
+ </h2>
63
+
64
+ <?php
65
+ }
66
+
67
+ function yasr_upgrade_pro_box( $position = false )
68
+ {
69
+
70
+ if ( yasr_fs()->is_free_plan() ) {
71
+
72
+ if ( $position && $position == "bottom" ) {
73
$yasr_upgrade_class = "yasr-donatedivbottom";
74
} else {
75
$yasr_upgrade_class = "yasr-donatedivdx";
76
}
77
+
78
?>
79
80
+ <div class="<?php
81
+ echo $yasr_upgrade_class ;
82
+ ?>" style="display: none">
83
84
<h2 class="yasr-donate-title" style="color: #34A7C1">
85
+ <?php
86
+ _e( 'Upgrade to YASR Pro', 'yet-another-stars-rating' );
87
+ ?>
88
</h2>
89
90
<div class="yasr-upgrade-to-pro">
91
<ul>
92
+ <li><strong><?php
93
+ _e( ' User Reviews', 'yet-another-stars-rating' );
94
+ ?></strong></li>
95
+ <li><strong><?php
96
+ _e( ' Custom Rankings', 'yet-another-stars-rating' );
97
+ ?></strong></li>
98
+ <li><strong><?php
99
+ _e( ' 20 + ready to use themes', 'yet-another-stars-rating' );
100
+ ?></strong></li>
101
+ <li><strong><?php
102
+ _e( ' Upload your own theme', 'yet-another-stars-rating' );
103
+ ?></strong></li>
104
+ <li><strong><?php
105
+ _e( ' Dedicate support', 'yet-another-stars-rating' );
106
+ ?></strong></li>
107
+ <li><strong><?php
108
+ _e( ' ...And much more!!', 'yet-another-stars-rating' );
109
+ ?></strong></li>
110
</ul>
111
+ <a href="<?php
112
+ echo yasr_fs()->get_upgrade_url() ;
113
+ ?>">
114
<button class="button button-primary">Upgrade Now</button>
115
</a>
116
</div>
117
118
</div>
119
120
+ <?php
121
}
122
123
}
127
* Since version 1.9.5
128
*
129
*/
130
+ function yasr_resources_box( $position = false )
131
+ {
132
+
133
+ if ( $position && $position == "bottom" ) {
134
$yasr_metabox_class = "yasr-donatedivbottom";
135
+ } else {
136
$yasr_metabox_class = "yasr-donatedivdx";
137
}
138
+
139
+ $div = "<div class='{$yasr_metabox_class}' id='yasr-resources-box' style='display:none;'>";
140
$text = '<div class="yasr-donate-title">Resources</div>';
141
$text .= '<div class="yasr-donate-single-resource">
142
<span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
143
+ <a target="blank" href="http://yetanotherstarsrating.com/">' . __( 'YASR official website', 'yet-another-stars-rating' ) . '</a>
144
</div>';
145
$text .= '<div class="yasr-donate-single-resource">
146
<span class="dashicons dashicons-edit" style="color: #ccc"></span>
147
+ <a target="blank" href="https://yetanotherstarsrating.com/yasr-basics-shortcode/">' . __( 'Documentation', 'yet-another-stars-rating' ) . '</a>
148
</div>';
149
$text .= '<div class="yasr-donate-single-resource">
150
<span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
151
+ <a target="blank" href="https://yetanotherstarsrating.com/f-a-q/">' . __( 'F.A.Q.', 'yet-another-stars-rating' ) . '</a>
152
</div>';
153
$text .= '<div class="yasr-donate-single-resource">
154
<span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
155
+ <a target="blank" href="https://www.youtube.com/channel/UCU5jbO1PJsUUsCNbME9S-Zw">' . __( 'Youtube channel', 'yet-another-stars-rating' ) . '</a>
156
</div>';
157
$text .= '<div class="yasr-donate-single-resource">
158
<span class="dashicons dashicons-smiley" style="color: #ccc"></span>
160
Yasr Pro
161
</a>
162
</div>';
163
$div_and_text = $div . $text . '</div>';
164
+ echo $div_and_text ;
165
}
166
167
/** Add a box on the right for asking to rate 5 stars on Wordpress.org
168
* Since version 0.9.0
169
*/
170
+ function yasr_ask_rating( $position = false )
171
+ {
172
+
173
+ if ( $position && $position == "bottom" ) {
174
$yasr_metabox_class = "yasr-donatedivbottom";
175
+ } else {
176
$yasr_metabox_class = "yasr-donatedivdx";
177
}
178
+
179
+ $div = "<div class='{$yasr_metabox_class}' id='yasr-ask-five-stars' style='display:none;'>";
180
+ $text = '<div class="yasr-donate-title">' . __( 'Can I ask your help?', 'yet-another-stars-rating' ) . '</div>';
181
$text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
182
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
183
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
185
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
186
<span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
187
</div>';
188
+ $text .= __( 'Please rate YASR 5 stars on', 'yet-another-stars-rating' );
189
$text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
190
WordPress.org.</a><br />';
191
+ $text .= __( ' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating' );
192
$text .= "<br /><br />";
193
$text .= "<em>> Dario Curvino</em>";
194
$div_and_text = $div . $text . '</div>';
195
+ echo $div_and_text ;
196
}
197
198
/****
199
Yasr Right settings panel, since version 1.9.5
200
****/
201
+ function yasr_right_settings_panel( $position = false )
202
+ {
203
+ do_action( 'yasr_right_settings_panel_box', $position );
204
+ yasr_upgrade_pro_box( $position );
205
+ yasr_resources_box( $position );
206
+ yasr_ask_rating( $position );
207
}
208
209
/** Change default admin footer on yasr settings pages
210
* $text is the default wordpress text
211
* Since 0.8.9
212
*/
213
+ add_filter( 'admin_footer_text', 'yasr_custom_admin_footer' );
214
+ function yasr_custom_admin_footer( $text )
215
+ {
216
+
217
+ if ( isset( $_GET['page'] ) ) {
218
$yasr_page = $_GET['page'];
219
+
220
+ if ( $yasr_page == 'yasr_settings_page' ) {
221
$custom_text = ' | <i>';
222
$custom_text .= sprintf(
223
+ __( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
224
+ Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>', 'yet-another-stars-rating' ),
225
'https://yetanotherstarsrating.com',
226
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
227
'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
228
);
229
$custom_text .= '</i>';
230
return $text . $custom_text;
231
} else {
232
return $text;
233
}
234
+
235
} else {
236
return $text;
237
}
238
239
}
lib/admin/settings/yasr-settings-functions-multiset-page.php ADDED
@@ -0,0 +1,135 @@
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
+ $error_new_multi_set = yasr_process_new_multi_set_form(); //defined in yasr-settings-functions
26
+ $error_edit_multi_set = yasr_process_edit_multi_set_form(); //defined in yasr-settings-functions
27
+
28
+ if ($error_new_multi_set) {
29
+ echo "<div class=\"error\"> <p> <strong>";
30
+
31
+ foreach ($error_new_multi_set as $error) {
32
+ _e($error, 'yet-another-stars-rating');
33
+ echo "<br />";
34
+ }
35
+
36
+ echo "</strong></p></div>";
37
+ }
38
+
39
+ if ($error_edit_multi_set) {
40
+ echo "<div class=\"error\"> <p> <strong>";
41
+
42
+ foreach ($error_edit_multi_set as $error) {
43
+ _e($error, 'yet-another-stars-rating');
44
+ echo "<br />";
45
+ }
46
+
47
+ echo "</strong></p></div>";
48
+ }
49
+
50
+ global $wpdb;
51
+
52
+ //delete all transient that use multiset
53
+ $sql_delete_transient = "
54
+ DELETE FROM {$wpdb->options}
55
+ WHERE option_name LIKE '_transient_yasr_get_multi_set_values_and_field_%'
56
+ OR option_name LIKE '_transient_yasr_visitor_multi_set_%'
57
+ OR option_name LIKE '_transient_timeout_yasr_get_multi_set_values_and_field_%'
58
+ OR option_name LIKE '_transient_timeout_yasr_visitor_multi_set_%'
59
+ ";
60
+
61
+ $wpdb->query($sql_delete_transient);
62
+
63
+ $multi_set = yasr_get_multi_set();
64
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
65
+
66
+ ?>
67
+
68
+ <div class="yasr-settingsdiv">
69
+ <h3> <?php _e("Manage Multi Set", 'yet-another-stars-rating'); ?></h3>
70
+
71
+ <p>
72
+ <a href="#"
73
+ id="yasr-multi-set-doc-link"><?php _e("What is a Multi Set?", 'yet-another-stars-rating') ?></a>
74
+ </p>
75
+
76
+ <div id="yasr-multi-set-doc-box" style="display:none">
77
+ <?php _e(
78
+ "Multi Set allows you to insert a rate for each aspect about the product / local business /
79
+ whetever you're reviewing, example in the image below.",
80
+ 'yet-another-stars-rating'
81
+ );
82
+
83
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr-multi-set.png> <br /> <br />";
84
+
85
+ _e(
86
+ "You can create up to 99 different Multi Set and each one can contain up to 9 different fields.
87
+ Once you've saved it, you can insert the rates while typing your article in the box below the editor,
88
+ as you can see in this image (click to see it larger)",
89
+ 'yet-another-stars-rating'
90
+ );
91
+
92
+ echo "<br /><br /><a href=\"" . YASR_IMG_DIR . "yasr-multi-set-insert-rate.jpg\"><img src=" . YASR_IMG_DIR . "/yasr-multi-set-insert-rate-small.jpg></a> <br /> <br />";
93
+
94
+ _e(
95
+ 'In order to insert your Multi Sets into a post or page, you can either past the short code that will
96
+ appear at the bottom of the box or just click on the star in the graphic editor and select "Insert Multi Set".',
97
+ 'yet-another-stars-rating'
98
+ );
99
+
100
+ ?>
101
+ <br/> <br/>
102
+ <a href="#"
103
+ id="yasr-multi-set-doc-link-hide"><?php _e("Close this message", 'yet-another-stars-rating') ?></a>
104
+ </div>
105
+
106
+ <div class="yasr-multi-set-left">
107
+ <div class="yasr-new-multi-set">
108
+ <?php yasr_display_multi_set_form(); ?>
109
+ </div>
110
+ </div>
111
+
112
+ <div class="yasr-multi-set-right">
113
+ <?php yasr_edit_multi_form(); ?>
114
+ <div id="yasr-multi-set-response" style="display:none">
115
+ </div>
116
+ </div>
117
+
118
+ <div class="yasr-space-settings-div">
119
+ </div>
120
+
121
+
122
+ <div class="yasr-multi-set-choose-theme">
123
+ <!--This allow to choose if show average or no-->
124
+ <form action="options.php" method="post" id="yasr_multiset_form">
125
+ <?php
126
+ settings_fields('yasr_multiset_options_group');
127
+ do_settings_sections('yasr_multiset_tab');
128
+ submit_button(__('Save'));
129
+ ?>
130
+ </form>
131
+ </div>
132
+
133
+
134
+ </div>
135
+
lib/admin/settings/yasr-settings-functions-multiset.php CHANGED
@@ -18,194 +18,202 @@ 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' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
22
23
/**************** Add yasr multiset options and settings ************/
24
25
- add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general options
26
27
function yasr_multiset_options_init() {
28
- register_setting(
29
- 'yasr_multiset_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
30
- 'yasr_multiset_options', //The name of an option to sanitize and save.
31
- 'yasr_sanitize_multiset_options'
32
- );
33
34
- $option_multiset = get_option( 'yasr_multiset_options' );
35
36
- if ($option_multiset === FALSE) {
37
38
- $option_multiset = array();
39
40
- }
41
-
42
- if (!isset($option_multiset['show_average'])) {
43
-
44
- $option_multiset['show_average'] = 'yes';
45
-
46
- }
47
-
48
- add_settings_section( 'yasr_multiset_options_section_id', '', 'yasr_multiset_section_callback', 'yasr_multiset_tab' );
49
- add_settings_field( 'yasr_multiset_hide_average_id', __('Show average?', 'yet-another-stars-rating'), 'yasr_multiset_hide_average_callback', 'yasr_multiset_tab', 'yasr_multiset_options_section_id', $option_multiset );
50
51
}
52
53
- function yasr_multiset_section_callback () {
54
55
- //Silence
56
57
}
58
59
- function yasr_multiset_hide_average_callback ($option_multiset) {
60
61
- ?>
62
63
- <div class="yasr-onoffswitch-big">
64
- <input type="checkbox" name="yasr_multiset_options[show_average]" class="yasr-onoffswitch-checkbox" id="yasr-multiset-options-show-average-switch" <?php if ($option_multiset['show_average']==='yes') echo " checked='checked' "; ?> >
65
- <label class="yasr-onoffswitch-label" for="yasr-multiset-options-show-average-switch">
66
- <span class="yasr-onoffswitch-inner"></span>
67
- <span class="yasr-onoffswitch-switch"></span>
68
- </label>
69
- </div>
70
71
- <br />
72
73
- <br />
74
75
- <?php
76
77
- _e("If you select no, the \"Average\" row will not be displayed. You can override this in the single multi set by using the parameter \"show_average\"", "yasr");
78
79
}
80
81
82
- function yasr_sanitize_multiset_options ($option_multiset) {
83
-
84
- if (!array_key_exists('show_average', $option_multiset)) {
85
-
86
- $option_multiset['show_average'] = 'no';
87
88
- }
89
90
- else {
91
-
92
- $option_multiset['show_average'] = 'yes';
93
-
94
- }
95
-
96
- return $option_multiset;
97
98
}
99
100
101
/****** Create a form for settings page to create new multi set ******/
102
function yasr_display_multi_set_form() {
103
104
- ?>
105
106
- <h4 class="yasr-multi-set-form-headers"><?php _e("Add New Multiple Set", 'yet-another-stars-rating'); ?></h4>
107
- <em><?php _e('Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yet-another-stars-rating') ?></em>
108
- <p>
109
- <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>" id="form_add_multi_set" method="post">
110
- <strong><?php _e("Name", 'yet-another-stars-rating')?></strong>
111
- <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
112
- <!--input type="hidden" name="action" value="yasr_new_multi_set_form" />-->
113
114
- <p></p>
115
- <?php _e("You can insert up to nine elements", 'yet-another-stars-rating') ?>
116
- <br />
117
118
- <?php for($i=1; $i<=9; $i++) {
119
120
- echo "<strong>" . __("Element ", 'yet-another-stars-rating') . "#$i" . "</strong>";
121
- ?>
122
- <input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>" class="input-text-multi-set">
123
- <br />
124
125
- <?php } //End foreach
126
127
- wp_nonce_field( 'add-multi-set', 'add-nonce-new-multi-set' ) ?><!-- a little security to process on submission -->
128
129
- <br />
130
- <input type="submit" value="<?php _e("Create New Set", 'yet-another-stars-rating') ?>" class="button-primary"/>
131
- </form>
132
133
- <?php
134
} //End function
135
136
137
function yasr_edit_multi_form() {
138
139
- global $wpdb;
140
141
- $multi_set=yasr_get_multi_set();
142
143
- $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
144
145
- if ($n_multi_set > 1) {
146
- ?>
147
148
- <div class="yasr-manage-multiset">
149
150
- <h4 class="yasr-multi-set-form-headers"><?php _e("Manage Multiple Set" , 'yet-another-stars-rating'); ?></h4>
151
152
- <?php _e('Wich set do you want to edit or remove?', 'yet-another-stars-rating')?>
153
154
- <select id ="yasr_select_edit_set">
155
- <?php foreach ($multi_set as $name) { ?>
156
- <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
157
- <?php } //End foreach ?>
158
- </select>
159
160
- <button href="#" class="button-delete" id="yasr-button-select-set-edit-form"><?php _e("Select"); ?></button>
161
162
163
- </div>
164
165
- <?php
166
167
- } //End if n_multi_set >1
168
169
- elseif ($n_multi_set == 1) {
170
171
- $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id, parent_set_id AS set_id
172
FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
173
ORDER BY field_id ASC");
174
175
- foreach ($multi_set as $find_set_id) {
176
- $set_type = $find_set_id->set_id;
177
- }
178
179
- ?>
180
181
- <div class="yasr-manage-multiset-single">
182
183
- <h4 class="yasr-multi-set-form-headers"><?php _e("Manage Multiple Set", 'yet-another-stars-rating'); ?></h4>
184
185
- <form action=" <?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>" id="form_edit_multi_set" method="post">
186
187
- <input type="hidden" name="yasr_edit_multi_set_form" value="<?php echo $set_type ?>" />
188
189
- <table id="yasr-table-form-edit-multi-set">
190
- <tr>
191
192
- <td id="yasr-table-form-edit-multi-set-header">
193
- <?php _e('Field name', 'yet-another-stars-rating') ?>
194
- </td>
195
196
- <td id="yasr-table-form-edit-multi-set-remove">
197
- <?php _e('Remove', 'yet-another-stars-rating') ?>
198
- </td>
199
200
- </tr>
201
202
- <?php
203
204
- $i=1;
205
206
- foreach ($set_name as $name) {
207
208
- echo "
209
<tr>
210
211
<td width=\"80%\">
@@ -220,14 +228,14 @@ function yasr_edit_multi_form() {
220
</tr>
221
";
222
223
- $i++;
224
225
- }
226
227
228
- $i = $i-1; //This is the number of the fields
229
230
- echo "
231
232
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
233
@@ -248,81 +256,81 @@ function yasr_edit_multi_form() {
248
249
";
250
251
- echo "<p>";
252
- _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , 'yet-another-stars-rating');
253
- echo "</p>";
254
-
255
- wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
256
257
- ?>
258
259
- <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , 'yet-another-stars-rating') ?></div>
260
261
- <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
262
263
- <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>" class="button-primary" >
264
265
- </form>
266
267
- </div>
268
269
- <?php
270
- }
271
272
- else {
273
- _e("No Multiple Set were found", 'yet-another-stars-rating');
274
- }
275
276
}//End function
277
278
279
/****** Get and output multiple set in a form and table, used in settings page ******/
280
281
- add_action( 'wp_ajax_yasr_get_multi_set', 'yasr_get_multi_set_callback' );
282
283
function yasr_get_multi_set_callback() {
284
- if (isset($_POST['set_id']) && $_POST['set_id'] != '' ) {
285
- $set_type = $_POST['set_id'];
286
- }
287
- else {
288
- exit ();
289
- }
290
291
- global $wpdb;
292
293
- $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
294
FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
295
WHERE parent_set_id=%d
296
ORDER BY field_id ASC", $set_type));
297
298
299
300
- ?>
301
-
302
- <form action=" <?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>" id="form_edit_multi_set" method="post">
303
- <input type="hidden" name="yasr_edit_multi_set_form" value="<?php echo $set_type ?>" />
304
305
306
- <table id="yasr-table-form-edit-multi-set">
307
- <tr>
308
309
- <td id="yasr-table-form-edit-multi-set-header">
310
- <?php _e('Field name', 'yet-another-stars-rating') ?>
311
- </td>
312
313
- <td id="yasr-table-form-edit-multi-set-remove">
314
- <?php _e('Remove', 'yet-another-stars-rating') ?>
315
- </td>
316
317
- </tr>
318
319
- <?php
320
321
- $i=1;
322
323
- foreach ($set_name as $name) {
324
325
- echo "
326
<tr>
327
328
<td width=\"80%\">
@@ -337,14 +345,14 @@ function yasr_get_multi_set_callback() {
337
</tr>
338
";
339
340
- $i++;
341
342
- }
343
344
345
- $i = $i-1; //This is the number of the fields
346
347
- echo "
348
349
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
350
@@ -365,25 +373,27 @@ function yasr_get_multi_set_callback() {
365
366
";
367
368
- echo "<p>";
369
- _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , 'yet-another-stars-rating');
370
- echo "</p>";
371
372
- wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
373
374
- ?>
375
376
- <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , 'yet-another-stars-rating') ?></div>
377
378
- <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
379
380
- <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>" class="button-primary" >
381
382
- </form>
383
384
- <?php
385
386
- die();
387
388
} //End function
389
@@ -391,435 +401,428 @@ function yasr_get_multi_set_callback() {
391
/****** Validate new multi set form ******/
392
function yasr_process_new_multi_set_form() {
393
394
- if ( isset( $_POST['multi-set-name'])) {
395
-
396
- global $wpdb;
397
398
- if ( !current_user_can( 'manage_options' ) ) {
399
- wp_die( 'You are not allowed to be on this page.' );
400
- }
401
402
- // Check nonce field
403
- check_admin_referer( 'add-multi-set', 'add-nonce-new-multi-set' );
404
405
- $array_errors = array();
406
- $error = FALSE;
407
408
- //IF thes fields are not empty go ahed
409
- if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
410
411
- $multi_set_name = ucfirst(strtolower($_POST['multi-set-name']));
412
413
- $multi_set_name_element_=array();
414
415
- $multi_set_name_element_[1]=$_POST['multi-set-name-element-1'];
416
- $multi_set_name_element_[2]=$_POST['multi-set-name-element-2'];
417
418
- //If multi set name is shorter than 3 characher come back
419
- if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) <3 || mb_strlen($multi_set_name_element_[2]) < 3 ) {
420
- $array_errors[] = "Content field must be longer than 3 chars";
421
- $error=TRUE;
422
- }
423
424
425
- if (mb_strlen($multi_set_name) > 40 || mb_strlen($multi_set_name_element_[1]) > 40 || mb_strlen($multi_set_name_element_[2]) > 40 ) {
426
- $array_errors[] = "Content field must be shorter than 40 chars";
427
- $error=TRUE;
428
- }
429
430
- //Check if a set with that name already exists
431
- $check_name_exists=$wpdb->get_results("SELECT set_name FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
432
433
- foreach ($check_name_exists as $set_name) {
434
435
- if ($multi_set_name==$set_name->set_name) {
436
- $array_errors[] = "You already have a set with this name";
437
- $error=TRUE;
438
- }
439
440
- }
441
442
- $element_filled=2;
443
444
- //If filled get the element from 3 to 9
445
- for($i=3; $i<=9; $i++) {
446
447
- if (isset($_POST["multi-set-name-element-$i"]) && $_POST["multi-set-name-element-$i"]!='') {
448
449
- $multi_set_name_element_[$i]=$_POST["multi-set-name-element-$i"];
450
451
- if (mb_strlen($multi_set_name_element_[$i]) < 3) {
452
- $array_errors[] = "Field # $i must be at least 3 characters";
453
- $error=TRUE;
454
- }
455
456
- if (mb_strlen($multi_set_name_element_[$i]) > 40) {
457
- $array_errors[] = "Field # $i must be shorter than 40 characters";
458
- $error=TRUE;
459
- }
460
461
- $element_filled++;
462
- }
463
464
- }
465
466
- //If there isnt any error write in the table
467
- if (!$error) {
468
469
- //get the highest id in table
470
- $highest_id=$wpdb->get_results("SELECT set_id FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id DESC LIMIT 1 ");
471
472
- if (!$highest_id) {
473
- $name_table_new_id=0;
474
- }
475
476
- foreach ($highest_id as $id) {
477
- $name_table_new_id=$id->set_id + 1;
478
- }
479
480
- $insert_multi_name_success = $wpdb->replace(
481
- YASR_MULTI_SET_NAME_TABLE,
482
- array(
483
- 'set_id' =>$name_table_new_id,
484
- 'set_name' =>$multi_set_name
485
- ),
486
- array ('%d', '%s')
487
- );
488
489
- //If multi set name hase been inserted, now we're going to insert elements
490
- if ($insert_multi_name_success) {
491
492
- //get the highest id in table
493
- $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
494
495
- if (!$highest_id) {
496
- $field_table_new_id=0;
497
- }
498
499
- foreach ($highest_id as $id) {
500
- $field_table_new_id=$id->id + 1;
501
- }
502
503
- for ($i=1; $i<=$element_filled; $i++) {
504
- $insert_set_value=$wpdb->replace(
505
- YASR_MULTI_SET_FIELDS_TABLE,
506
- array(
507
- 'id' => $field_table_new_id,
508
- 'parent_set_id' =>$name_table_new_id,
509
- 'field_name' =>$multi_set_name_element_[$i],
510
- 'field_id' =>$i
511
- ),
512
- array ('%d', '%d', '%s', '%d')
513
- );
514
- $field_table_new_id++; //Avoid overwrite
515
- } //End for
516
517
- if ($insert_set_value) {
518
- echo "<div class=\"updated\"><p><strong>";
519
- _e("Settings Saved", 'yet-another-stars-rating');
520
- echo "</strong></p></div> ";
521
- }
522
523
- else {
524
- _e("Something goes wrong trying insert set field name. Please report it", 'yet-another-stars-rating');
525
- }
526
527
- } //End if $insert_multi_name_success
528
529
- else {
530
- _e("Something goes wrong trying insert Multi Set name. Please report it", 'yet-another-stars-rating');
531
- }
532
533
- } //End if !$error
534
535
- } //End if $_POST['multi-set-name']!=''
536
537
- //Else multi set's name and first 2 elements are empty
538
- else {
539
- $array_errors[] = "Multi Set's name and first 2 elements can't be empty";
540
- $error=TRUE;
541
- }
542
543
- if ($error) {
544
- return $array_errors;
545
- }
546
547
- } //End if ( isset( $_POST['multi-set-name']) ) {
548
549
} //End yasr_process_new_multi_set_form() function
550
551
function yasr_process_edit_multi_set_form() {
552
553
- $error = FALSE;
554
-
555
- if ( isset( $_POST['yasr_edit_multi_set_form']) ) {
556
-
557
- $set_id = $_POST['yasr_edit_multi_set_form'];
558
559
- $number_of_stored_elements = $_POST['yasr-edit-form-number-elements'];
560
561
- global $wpdb;
562
563
- $array_errors = array();
564
565
- if ( !current_user_can( 'manage_options' ) ) {
566
- wp_die( 'You are not allowed to be on this page.' );
567
- }
568
569
- // Check nonce field
570
- check_admin_referer( 'edit-multi-set', 'add-nonce-edit-multi-set' );
571
572
573
- //Check if user want to delete entire set
574
575
- if (isset($_POST["yasr-remove-multi-set"])) {
576
577
- $remove_set = $wpdb->delete (
578
- YASR_MULTI_SET_NAME_TABLE,
579
- array(
580
- 'set_id' => $set_id,
581
- ),
582
- array ('%d')
583
- );
584
585
- $remove_set_values = $wpdb->delete (
586
- YASR_MULTI_SET_FIELDS_TABLE,
587
- array(
588
- 'parent_set_id' => $set_id,
589
- ),
590
- array ('%d')
591
- );
592
593
- $remove_set_votes = $wpdb->delete (
594
- YASR_MULTI_SET_VALUES_TABLE,
595
- array(
596
- 'set_type' => $set_id,
597
- ),
598
- array ('%d')
599
- );
600
601
- if ($remove_set==FALSE) {
602
- $error = TRUE;
603
- $array_errors[] .= __("Something goes wrong trying to delete a Multi Set . Please report it", 'yet-another-stars-rating');
604
- }
605
606
607
- //Comment this out, if try to delete an empty set print error
608
- /*if ($remove_set_values==FALSE) {
609
- $error = TRUE;
610
- $array_errors[] .= __("Something goes wrong trying to delete data fields for a set. Please report it", 'yet-another-stars-rating');
611
- }
612
- */
613
614
- //Comment this out, will echo error even if the value for that field it's just empty
615
- /*if ($remove_set_votes==FALSE) {
616
- $error = TRUE;
617
- $array_errors[] .= __("Something goes wrong trying to delete data values for a set. Please report it", 'yet-another-stars-rating');
618
- }*/
619
620
- }
621
622
- for ($i = 0; $i <= 9; $i++) {
623
624
- //Than, check if the user want to remove some field
625
- if (isset($_POST["remove-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) ) {
626
627
- $field_to_remove = $_POST["remove-element-$i"];
628
629
- $remove_field = $wpdb->delete (
630
- YASR_MULTI_SET_FIELDS_TABLE,
631
- array(
632
- 'parent_set_id' => $set_id,
633
- 'field_id' =>$field_to_remove
634
- ),
635
- array ('%d', '%d')
636
- );
637
638
- $remove_values = $wpdb->delete (
639
- YASR_MULTI_SET_VALUES_TABLE,
640
- array(
641
- 'set_type' => $set_id,
642
- 'field_id' =>$field_to_remove
643
- ),
644
- array ('%d', '%d')
645
- );
646
647
- if ($remove_field == FALSE) {
648
- $error = TRUE;
649
- $array_errors[] = __("Something goes wrong trying to delete a Multi Set's element. Please report it", 'yet-another-stars-rating');
650
- }
651
652
653
- //Comment this out, will echo error even if the value for that field it's just empty
654
- /*if ($remove_values == FALSE) {
655
- $error = TRUE;
656
- $array_errors[] = __("Something goes wrong trying to delete data value for an element. Please report it", 'yet-another-stars-rating');
657
- }*/
658
659
660
- } //End if isset $_POST['remove-element-$i']
661
662
663
- //update the stored elements with the new ones
664
- if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i <= $number_of_stored_elements ) {
665
666
- $field_name = $_POST["edit-multi-set-element-$i"];
667
668
- $field_id = $_POST["db-id-for-element-$i"];
669
670
- //if elements name is shorter than 3 chars
671
- if (mb_strlen($field_name) <3) {
672
- $array_errors[] = __("Field # $i must be at least 3 characters", 'yet-another-stars-rating');
673
- $error=TRUE;
674
- }
675
676
- if(mb_strlen($field_name) > 40) {
677
- $array_errors[] = __("Field # $i must be shorter than 40 characters", 'yet-another-stars-rating');
678
- $error=TRUE;
679
- }
680
681
- else {
682
683
- //Check if field name is changed
684
- $field_name_in_db = $wpdb->get_results($wpdb->prepare("SELECT field_name FROM " . YASR_MULTI_SET_FIELDS_TABLE . " WHERE field_id=%d AND parent_set_id=%d", $field_id, $set_id ) );
685
686
- foreach ($field_name_in_db as $field_in_db) {
687
- $field_name_in_database = $field_in_db->field_name;
688
- }
689
690
- //if field name in db is different from field name in form update it
691
- if ($field_name_in_database != $field_name) {
692
693
- $insert_field_name=$wpdb->update(
694
- YASR_MULTI_SET_FIELDS_TABLE,
695
696
- array(
697
- 'field_name' =>$field_name,
698
- ),
699
700
- array(
701
- 'parent_set_id' =>$set_id,
702
- 'field_id' =>$field_id
703
- ),
704
705
- array ('%s'),
706
707
- array ('%d', '%d')
708
709
- );
710
711
- if ($insert_field_name == FALSE) {
712
- $error = TRUE;
713
- $array_errors[] = __("Something goes wrong trying to update a Multi Set's element. Please report it", 'yet-another-stars-rating');
714
- }
715
716
- } //End if ($field_name_in_database != $field_name) {
717
718
- }
719
720
- } //End if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i<=$number_of_stored_elements )
721
722
723
- //If $i > number of stored elements, user is adding new elements, so we're going to insert the new ones
724
- if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i > $number_of_stored_elements ) {
725
726
- $field_name = $_POST["edit-multi-set-element-$i"];
727
728
- //if elements name is shorter than 3 chars return error. I use mb_strlen($field_name) > 1
729
- //because I don't wont return error if an user add an empty field. An empty field will be
730
- //just ignored
731
- if (mb_strlen($field_name) > 1 && mb_strlen($field_name) < 3) {
732
- $array_errors[] = __("Field # $i must be at least 3 characters", 'yet-another-stars-rating');
733
- $error=TRUE;
734
- }
735
736
- if(mb_strlen($field_name) > 40) {
737
- $array_errors[] = __("Field # $i must be shorter than 40 characters", 'yet-another-stars-rating');
738
- $error=TRUE;
739
- }
740
741
- //if field is not empty
742
- elseif ($field_name != '') {
743
744
- $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
745
746
- $highest_field_id = $wpdb->get_results("SELECT field_id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY field_id DESC LIMIT 1 ");
747
748
- foreach ($highest_id as $id) {
749
- $field_table_new_id=$id->id + 1;
750
- }
751
752
- foreach ($highest_field_id as $id) {
753
- $new_field_id = $id->field_id+1;
754
- }
755
756
- $insert_set_value=$wpdb->replace(
757
- YASR_MULTI_SET_FIELDS_TABLE,
758
- array(
759
- 'id' => $field_table_new_id,
760
- 'parent_set_id' =>$set_id,
761
- 'field_name' =>$field_name,
762
- 'field_id' =>$new_field_id
763
- ),
764
- array ('%d', '%d', '%s', '%d')
765
- );
766
767
- //now, I've to find which post is using the edited multi set and add the new field with value 0
768
769
- //get the highest id
770
- $highest_id_value_table = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
771
772
- foreach ($highest_id_value_table as $id) {
773
- $field_value_table_new_id=$id->id + 1;
774
- }
775
776
- //get all the post id that are using this multiset
777
- $array_post_id = $wpdb->get_results($wpdb->prepare("SELECT post_id
778
FROM " . YASR_MULTI_SET_VALUES_TABLE .
779
- " WHERE set_type=%d
780
GROUP BY post_id", $set_id));
781
782
- //Insert the new fields
783
- foreach ($array_post_id as $postid) {
784
785
- $insert_new_field_values_table = $wpdb->insert(
786
- YASR_MULTI_SET_VALUES_TABLE,
787
- array(
788
- 'id' => $field_value_table_new_id,
789
- 'set_type' => $set_id,
790
- 'field_id' => $new_field_id,
791
- 'post_id' => $postid->post_id
792
- ),
793
- array ('%d', '%d', '%d', '%d')
794
- );
795
796
- $field_value_table_new_id++;
797
798
- }
799
800
- if ($insert_set_value == FALSE) {
801
- $error = TRUE;
802
- $array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yet-another-stars-rating');
803
- }
804
805
- } //end else
806
- }
807
808
809
- } //End for
810
811
812
- if ($error) {
813
- return $array_errors;
814
- }
815
- else {
816
- echo "<div class=\"updated\"><p><strong>";
817
- _e("Settings Saved", 'yet-another-stars-rating');
818
- echo "</strong></p></div> ";
819
- }
820
821
822
- } //End if isset( $_POST['yasr_edit_multi_set_form']
823
824
825
} //End yasr_process_edit_multi_set_form() function
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
/**************** Add yasr multiset options and settings ************/
26
27
+ add_action('admin_init', 'yasr_multiset_options_init'); //This is for general options
28
29
function yasr_multiset_options_init() {
30
+ register_setting(
31
+ 'yasr_multiset_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
32
+ 'yasr_multiset_options', //The name of an option to sanitize and save.
33
+ 'yasr_sanitize_multiset_options'
34
+ );
35
36
+ $option_multiset = get_option('yasr_multiset_options');
37
38
+ if ($option_multiset === false) {
39
+ $option_multiset = array();
40
+ }
41
42
+ if (!isset($option_multiset['show_average'])) {
43
+ $option_multiset['show_average'] = 'yes';
44
+ }
45
46
+ add_settings_section('yasr_multiset_options_section_id', '', 'yasr_multiset_section_callback', 'yasr_multiset_tab');
47
+ add_settings_field('yasr_multiset_hide_average_id', __('Show average?', 'yet-another-stars-rating'), 'yasr_multiset_hide_average_callback', 'yasr_multiset_tab', 'yasr_multiset_options_section_id', $option_multiset);
48
49
}
50
51
+ function yasr_multiset_section_callback() {
52
53
+ //Silence
54
55
}
56
57
+ function yasr_multiset_hide_average_callback($option_multiset) {
58
59
+ ?>
60
61
+ <div class="yasr-onoffswitch-big">
62
+ <input type="checkbox" name="yasr_multiset_options[show_average]" class="yasr-onoffswitch-checkbox"
63
+ id="yasr-multiset-options-show-average-switch" <?php if ($option_multiset['show_average'] === 'yes') {
64
+ echo " checked='checked' ";
65
+ } ?> >
66
+ <label class="yasr-onoffswitch-label" for="yasr-multiset-options-show-average-switch">
67
+ <span class="yasr-onoffswitch-inner"></span>
68
+ <span class="yasr-onoffswitch-switch"></span>
69
+ </label>
70
+ </div>
71
72
+ <br/>
73
74
+ <br/>
75
76
+ <?php
77
78
+ _e("If you select no, the \"Average\" row will not be displayed. You can override this in the single multi set by using the parameter \"show_average\"", "yasr");
79
80
}
81
82
83
+ function yasr_sanitize_multiset_options($option_multiset) {
84
85
+ if (!array_key_exists('show_average', $option_multiset)) {
86
+ $option_multiset['show_average'] = 'no';
87
+ } else {
88
+ $option_multiset['show_average'] = 'yes';
89
+ }
90
91
+ return $option_multiset;
92
93
}
94
95
96
/****** Create a form for settings page to create new multi set ******/
97
function yasr_display_multi_set_form() {
98
+ ?>
99
+
100
+ <h4 class="yasr-multi-set-form-headers">
101
+ <?php _e("Add New Multiple Set", 'yet-another-stars-rating'); ?>
102
+ </h4>
103
+
104
+ <p>
105
+ <em>
106
+ <?php _e('Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters',
107
+ 'yet-another-stars-rating') ?>
108
+ </em>
109
+ </p>
110
111
+ <div>
112
+ <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>"
113
+ id="form_add_multi_set" method="post">
114
115
+ <?php wp_nonce_field('add-multi-set', 'add-nonce-new-multi-set') //Must be inside the form ?>
116
117
+ <strong><?php _e("Name", 'yet-another-stars-rating') ?></strong>
118
119
+ <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
120
+ <br />
121
122
+ <?php _e("You can insert up to nine elements", 'yet-another-stars-rating') ?>
123
+ <br/>
124
125
+ <?php for ($i = 1; $i <= 9; $i ++) {
126
127
+ echo "<strong>" . __('Element ', 'yet-another-stars-rating') . "#$i" . "</strong>";
128
+ ?>
129
+ <input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>"
130
+ class="input-text-multi-set">
131
+ <br/>
132
133
+ <?php } //End foreach ?>
134
135
+ <br/>
136
+ <input type="submit" value="<?php _e("Create New Set", 'yet-another-stars-rating') ?>" class="button-primary"/>
137
+ </form>
138
+ </div>
139
+
140
+ <?php
141
} //End function
142
143
144
function yasr_edit_multi_form() {
145
146
+ global $wpdb;
147
148
+ $multi_set = yasr_get_multi_set();
149
150
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
151
152
+ if ($n_multi_set > 1) {
153
+ ?>
154
155
+ <div class="yasr-manage-multiset">
156
157
+ <h4 class="yasr-multi-set-form-headers"><?php _e("Manage Multiple Set", 'yet-another-stars-rating'); ?></h4>
158
159
+ <?php _e('Wich set do you want to edit or remove?', 'yet-another-stars-rating') ?>
160
161
+ <select id="yasr_select_edit_set">
162
+ <?php foreach ($multi_set as $name) { ?>
163
+ <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
164
+ <?php } //End foreach ?>
165
+ </select>
166
167
+ <button href="#" class="button-delete" id="yasr-button-select-set-edit-form"><?php _e("Select"); ?></button>
168
169
170
+ </div>
171
172
+ <?php
173
174
+ } //End if n_multi_set >1
175
176
+ elseif ($n_multi_set == 1) {
177
178
+ $set_name = $wpdb->get_results("SELECT field_name AS name, field_id AS id, parent_set_id AS set_id
179
FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
180
ORDER BY field_id ASC");
181
182
+ foreach ($multi_set as $find_set_id) {
183
+ $set_type = $find_set_id->set_id;
184
+ }
185
186
+ ?>
187
188
+ <div class="yasr-manage-multiset-single">
189
190
+ <h4 class="yasr-multi-set-form-headers"><?php _e("Manage Multiple Set", 'yet-another-stars-rating'); ?></h4>
191
192
+ <form action=" <?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>"
193
+ id="form_edit_multi_set" method="post">
194
195
+ <input type="hidden" name="yasr_edit_multi_set_form" value="<?php echo $set_type ?>"/>
196
197
+ <table id="yasr-table-form-edit-multi-set">
198
+ <tr>
199
200
+ <td id="yasr-table-form-edit-multi-set-header">
201
+ <?php _e('Field name', 'yet-another-stars-rating') ?>
202
+ </td>
203
204
+ <td id="yasr-table-form-edit-multi-set-remove">
205
+ <?php _e('Remove', 'yet-another-stars-rating') ?>
206
+ </td>
207
208
+ </tr>
209
210
+ <?php
211
212
+ $i = 1;
213
214
+ foreach ($set_name as $name) {
215
216
+ echo "
217
<tr>
218
219
<td width=\"80%\">
228
</tr>
229
";
230
231
+ $i ++;
232
233
+ }
234
235
236
+ $i = $i - 1; //This is the number of the fields
237
238
+ echo "
239
240
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
241
256
257
";
258
259
+ echo "<p>";
260
+ _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone.", 'yet-another-stars-rating');
261
+ echo "</p>";
262
263
+ wp_nonce_field('edit-multi-set', 'add-nonce-edit-multi-set')
264
265
+ ?>
266
267
+ <div id="yasr-element-limit"
268
+ style="display:none; color:red"><?php _e("You can use up to 9 elements", 'yet-another-stars-rating') ?></div>
269
270
+ <input type="button" class="button-delete" id="yasr-add-field-edit-multiset"
271
+ value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
272
273
+ <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>"
274
+ class="button-primary">
275
276
+ </form>
277
278
+ </div>
279
280
+ <?php
281
+ } else {
282
+ _e("No Multiple Set were found", 'yet-another-stars-rating');
283
+ }
284
285
}//End function
286
287
288
/****** Get and output multiple set in a form and table, used in settings page ******/
289
290
+ add_action('wp_ajax_yasr_get_multi_set', 'yasr_get_multi_set_callback');
291
292
function yasr_get_multi_set_callback() {
293
+ if (isset($_POST['set_id']) && $_POST['set_id'] != '') {
294
+ $set_type = $_POST['set_id'];
295
+ } else {
296
+ exit ();
297
+ }
298
299
+ global $wpdb;
300
301
+ $set_name = $wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
302
FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
303
WHERE parent_set_id=%d
304
ORDER BY field_id ASC", $set_type));
305
306
307
+ ?>
308
309
+ <form action=" <?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>"
310
+ id="form_edit_multi_set" method="post">
311
+ <input type="hidden" name="yasr_edit_multi_set_form" value="<?php echo $set_type ?>"/>
312
313
314
+ <table id="yasr-table-form-edit-multi-set">
315
+ <tr>
316
317
+ <td id="yasr-table-form-edit-multi-set-header">
318
+ <?php _e('Field name', 'yet-another-stars-rating') ?>
319
+ </td>
320
321
+ <td id="yasr-table-form-edit-multi-set-remove">
322
+ <?php _e('Remove', 'yet-another-stars-rating') ?>
323
+ </td>
324
325
+ </tr>
326
327
+ <?php
328
329
+ $i = 1;
330
331
+ foreach ($set_name as $name) {
332
333
+ echo "
334
<tr>
335
336
<td width=\"80%\">
345
</tr>
346
";
347
348
+ $i ++;
349
350
+ }
351
352
353
+ $i = $i - 1; //This is the number of the fields
354
355
+ echo "
356
357
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
358
373
374
";
375
376
+ echo "<p>";
377
+ _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone.", 'yet-another-stars-rating');
378
+ echo "</p>";
379
380
+ wp_nonce_field('edit-multi-set', 'add-nonce-edit-multi-set')
381
382
+ ?>
383
384
+ <div id="yasr-element-limit"
385
+ style="display:none; color:red"><?php _e("You can use up to 9 elements", 'yet-another-stars-rating') ?></div>
386
387
+ <input type="button" class="button-delete" id="yasr-add-field-edit-multiset"
388
+ value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
389
390
+ <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>" class="button-primary">
391
392
+ </form>
393
394
+ <?php
395
396
+ die();
397
398
} //End function
399
401
/****** Validate new multi set form ******/
402
function yasr_process_new_multi_set_form() {
403
404
+ if (isset($_POST['multi-set-name'])) {
405
406
+ global $wpdb;
407
408
+ if (!current_user_can('manage_options')) {
409
+ wp_die('You are not allowed to be on this page.');
410
+ }
411
412
+ // Check nonce field
413
+ check_admin_referer('add-multi-set', 'add-nonce-new-multi-set');
414
415
+ $array_errors = array();
416
+ $error = false;
417
418
+ //IF thes fields are not empty go ahed
419
+ if ($_POST['multi-set-name'] != '' && $_POST['multi-set-name-element-1'] != '' && $_POST['multi-set-name-element-2'] != '') {
420
421
+ $multi_set_name = ucfirst(strtolower($_POST['multi-set-name']));
422
423
+ $multi_set_name_element_ = array();
424
425
+ $multi_set_name_element_[1] = $_POST['multi-set-name-element-1'];
426
+ $multi_set_name_element_[2] = $_POST['multi-set-name-element-2'];
427
428
+ //If multi set name is shorter than 3 characher come back
429
+ if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) < 3 || mb_strlen($multi_set_name_element_[2]) < 3) {
430
+ $array_errors[] = "Content field must be longer than 3 chars";
431
+ $error = true;
432
+ }
433
434
435
+ if (mb_strlen($multi_set_name) > 40 || mb_strlen($multi_set_name_element_[1]) > 40 || mb_strlen($multi_set_name_element_[2]) > 40) {
436
+ $array_errors[] = "Content field must be shorter than 40 chars";
437
+ $error = true;
438
+ }
439
440
+ //Check if a set with that name already exists
441
+ $check_name_exists = $wpdb->get_results("SELECT set_name FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
442
443
+ foreach ($check_name_exists as $set_name) {
444
445
+ if ($multi_set_name == $set_name->set_name) {
446
+ $array_errors[] = "You already have a set with this name";
447
+ $error = true;
448
+ }
449
450
+ }
451
452
+ $element_filled = 2;
453
454
+ //If filled get the element from 3 to 9
455
+ for ($i = 3; $i <= 9; $i ++) {
456
457
+ if (isset($_POST["multi-set-name-element-$i"]) && $_POST["multi-set-name-element-$i"] != '') {
458
459
+ $multi_set_name_element_[$i] = $_POST["multi-set-name-element-$i"];
460
461
+ if (mb_strlen($multi_set_name_element_[$i]) < 3) {
462
+ $array_errors[] = "Field # $i must be at least 3 characters";
463
+ $error = true;
464
+ }
465
466
+ if (mb_strlen($multi_set_name_element_[$i]) > 40) {
467
+ $array_errors[] = "Field # $i must be shorter than 40 characters";
468
+ $error = true;
469
+ }
470
471
+ $element_filled ++;
472
+ }
473
474
+ }
475
476
+ //If there isnt any error write in the table
477
+ if (!$error) {
478
479
+ //get the highest id in table
480
+ $highest_id = $wpdb->get_results("SELECT set_id FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id DESC LIMIT 1 ");
481
482
+ if (!$highest_id) {
483
+ $name_table_new_id = 0;
484
+ }
485
486
+ foreach ($highest_id as $id) {
487
+ $name_table_new_id = $id->set_id + 1;
488
+ }
489
490
+ $insert_multi_name_success = $wpdb->replace(
491
+ YASR_MULTI_SET_NAME_TABLE,
492
+ array(
493
+ 'set_id' => $name_table_new_id,
494
+ 'set_name' => $multi_set_name
495
+ ),
496
+ array('%d', '%s')
497
+ );
498
499
+ //If multi set name hase been inserted, now we're going to insert elements
500
+ if ($insert_multi_name_success) {
501
502
+ //get the highest id in table
503
+ $highest_id = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
504
505
+ if (!$highest_id) {
506
+ $field_table_new_id = 0;
507
+ }
508
509
+ foreach ($highest_id as $id) {
510
+ $field_table_new_id = $id->id + 1;
511
+ }
512
513
+ for ($i = 1; $i <= $element_filled; $i ++) {
514
+ $insert_set_value = $wpdb->replace(
515
+ YASR_MULTI_SET_FIELDS_TABLE,
516
+ array(
517
+ 'id' => $field_table_new_id,
518
+ 'parent_set_id' => $name_table_new_id,
519
+ 'field_name' => $multi_set_name_element_[$i],
520
+ 'field_id' => $i
521
+ ),
522
+ array('%d', '%d', '%s', '%d')
523
+ );
524
+ $field_table_new_id ++; //Avoid overwrite
525
+ } //End for
526
527
+ if ($insert_set_value) {
528
+ echo "<div class=\"updated\"><p><strong>";
529
+ _e("Settings Saved", 'yet-another-stars-rating');
530
+ echo "</strong></p></div> ";
531
+ } else {
532
+ _e("Something goes wrong trying insert set field name. Please report it", 'yet-another-stars-rating');
533
+ }
534
535
+ } //End if $insert_multi_name_success
536
537
+ else {
538
+ _e("Something goes wrong trying insert Multi Set name. Please report it", 'yet-another-stars-rating');
539
+ }
540
541
+ } //End if !$error
542
543
+ } //End if $_POST['multi-set-name']!=''
544
545
+ //Else multi set's name and first 2 elements are empty
546
+ else {
547
+ $array_errors[] = "Multi Set's name and first 2 elements can't be empty";
548
+ $error = true;
549
+ }
550
551
+ if ($error) {
552
+ return $array_errors;
553
+ }
554
555
+ } //End if ( isset( $_POST['multi-set-name']) ) {
556
557
} //End yasr_process_new_multi_set_form() function
558
559
function yasr_process_edit_multi_set_form() {
560
561
+ $error = false;
562
563
+ if (isset($_POST['yasr_edit_multi_set_form'])) {
564
565
+ $set_id = $_POST['yasr_edit_multi_set_form'];
566
567
+ $number_of_stored_elements = $_POST['yasr-edit-form-number-elements'];
568
569
+ global $wpdb;
570
571
+ $array_errors = array();
572
573
+ if (!current_user_can('manage_options')) {
574
+ wp_die('You are not allowed to be on this page.');
575
+ }
576
577
+ // Check nonce field
578
+ check_admin_referer('edit-multi-set', 'add-nonce-edit-multi-set');
579
580
581
+ //Check if user want to delete entire set
582
583
+ if (isset($_POST["yasr-remove-multi-set"])) {
584
585
+ $remove_set = $wpdb->delete(
586
+ YASR_MULTI_SET_NAME_TABLE,
587
+ array(
588
+ 'set_id' => $set_id,
589
+ ),
590
+ array('%d')
591
+ );
592
593
+ $remove_set_values = $wpdb->delete(
594
+ YASR_MULTI_SET_FIELDS_TABLE,
595
+ array(
596
+ 'parent_set_id' => $set_id,
597
+ ),
598
+ array('%d')
599
+ );
600
601
+ $remove_set_votes = $wpdb->delete(
602
+ YASR_MULTI_SET_VALUES_TABLE,
603
+ array(
604
+ 'set_type' => $set_id,
605
+ ),
606
+ array('%d')
607
+ );
608
609
+ if ($remove_set == false) {
610
+ $error = true;
611
+ $array_errors[] .= __("Something goes wrong trying to delete a Multi Set . Please report it", 'yet-another-stars-rating');
612
+ }
613
614
615
+ //Comment this out, if try to delete an empty set print error
616
+ /*if ($remove_set_values==FALSE) {
617
+ $error = TRUE;
618
+ $array_errors[] .= __("Something goes wrong trying to delete data fields for a set. Please report it", 'yet-another-stars-rating');
619
+ }
620
+ */
621
622
+ //Comment this out, will echo error even if the value for that field it's just empty
623
+ /*if ($remove_set_votes==FALSE) {
624
+ $error = TRUE;
625
+ $array_errors[] .= __("Something goes wrong trying to delete data values for a set. Please report it", 'yet-another-stars-rating');
626
+ }*/
627
628
+ }
629
630
+ for ($i = 0; $i <= 9; $i ++) {
631
632
+ //Than, check if the user want to remove some field
633
+ if (isset($_POST["remove-element-$i"]) && !isset($_POST["yasr-remove-multi-set"])) {
634
635
+ $field_to_remove = $_POST["remove-element-$i"];
636
637
+ $remove_field = $wpdb->delete(
638
+ YASR_MULTI_SET_FIELDS_TABLE,
639
+ array(
640
+ 'parent_set_id' => $set_id,
641
+ 'field_id' => $field_to_remove
642
+ ),
643
+ array('%d', '%d')
644
+ );
645
646
+ $remove_values = $wpdb->delete(
647
+ YASR_MULTI_SET_VALUES_TABLE,
648
+ array(
649
+ 'set_type' => $set_id,
650
+ 'field_id' => $field_to_remove
651
+ ),
652
+ array('%d', '%d')
653
+ );
654
655
+ if ($remove_field == false) {
656
+ $error = true;
657
+ $array_errors[] = __("Something goes wrong trying to delete a Multi Set's element. Please report it", 'yet-another-stars-rating');
658
+ }
659
660
661
+ //Comment this out, will echo error even if the value for that field it's just empty
662
+ /*if ($remove_values == FALSE) {
663
+ $error = TRUE;
664
+ $array_errors[] = __("Something goes wrong trying to delete data value for an element. Please report it", 'yet-another-stars-rating');
665
+ }*/
666
667
668
+ } //End if isset $_POST['remove-element-$i']
669
670
671
+ //update the stored elements with the new ones
672
+ if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i <= $number_of_stored_elements) {
673
674
+ $field_name = $_POST["edit-multi-set-element-$i"];
675
676
+ $field_id = $_POST["db-id-for-element-$i"];
677
678
+ //if elements name is shorter than 3 chars
679
+ if (mb_strlen($field_name) < 3) {
680
+ $array_errors[] = __("Field # $i must be at least 3 characters", 'yet-another-stars-rating');
681
+ $error = true;
682
+ }
683
684
+ if (mb_strlen($field_name) > 40) {
685
+ $array_errors[] = __("Field # $i must be shorter than 40 characters", 'yet-another-stars-rating');
686
+ $error = true;
687
+ } else {
688
689
+ //Check if field name is changed
690
+ $field_name_in_db = $wpdb->get_results($wpdb->prepare("SELECT field_name FROM " . YASR_MULTI_SET_FIELDS_TABLE . " WHERE field_id=%d AND parent_set_id=%d", $field_id, $set_id));
691
692
+ foreach ($field_name_in_db as $field_in_db) {
693
+ $field_name_in_database = $field_in_db->field_name;
694
+ }
695
696
+ //if field name in db is different from field name in form update it
697
+ if ($field_name_in_database != $field_name) {
698
699
+ $insert_field_name = $wpdb->update(
700
+ YASR_MULTI_SET_FIELDS_TABLE,
701
702
+ array(
703
+ 'field_name' => $field_name,
704
+ ),
705
706
+ array(
707
+ 'parent_set_id' => $set_id,
708
+ 'field_id' => $field_id
709
+ ),
710
711
+ array('%s'),
712
713
+ array('%d', '%d')
714
715
+ );
716
717
+ if ($insert_field_name == false) {
718
+ $error = true;
719
+ $array_errors[] = __("Something goes wrong trying to update a Multi Set's element. Please report it", 'yet-another-stars-rating');
720
+ }
721
722
+ } //End if ($field_name_in_database != $field_name) {
723
724
+ }
725
726
+ } //End if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i<=$number_of_stored_elements )
727
728
729
+ //If $i > number of stored elements, user is adding new elements, so we're going to insert the new ones
730
+ if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i > $number_of_stored_elements) {
731
732
+ $field_name = $_POST["edit-multi-set-element-$i"];
733
734
+ //if elements name is shorter than 3 chars return error. I use mb_strlen($field_name) > 1
735
+ //because I don't wont return error if an user add an empty field. An empty field will be
736
+ //just ignored
737
+ if (mb_strlen($field_name) > 1 && mb_strlen($field_name) < 3) {
738
+ $array_errors[] = __("Field # $i must be at least 3 characters", 'yet-another-stars-rating');
739
+ $error = true;
740
+ }
741
742
+ if (mb_strlen($field_name) > 40) {
743
+ $array_errors[] = __("Field # $i must be shorter than 40 characters", 'yet-another-stars-rating');
744
+ $error = true;
745
+ } //if field is not empty
746
+ elseif ($field_name != '') {
747
748
+ $highest_id = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
749
750
+ $highest_field_id = $wpdb->get_results("SELECT field_id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY field_id DESC LIMIT 1 ");
751
752
+ foreach ($highest_id as $id) {
753
+ $field_table_new_id = $id->id + 1;
754
+ }
755
756
+ foreach ($highest_field_id as $id) {
757
+ $new_field_id = $id->field_id + 1;
758
+ }
759
760
+ $insert_set_value = $wpdb->replace(
761
+ YASR_MULTI_SET_FIELDS_TABLE,
762
+ array(
763
+ 'id' => $field_table_new_id,
764
+ 'parent_set_id' => $set_id,
765
+ 'field_name' => $field_name,
766
+ 'field_id' => $new_field_id
767
+ ),
768
+ array('%d', '%d', '%s', '%d')
769
+ );
770
771
+ //now, I've to find which post is using the edited multi set and add the new field with value 0
772
773
+ //get the highest id
774
+ $highest_id_value_table = $wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
775
776
+ foreach ($highest_id_value_table as $id) {
777
+ $field_value_table_new_id = $id->id + 1;
778
+ }
779
780
+ //get all the post id that are using this multiset
781
+ $array_post_id = $wpdb->get_results($wpdb->prepare("SELECT post_id
782
FROM " . YASR_MULTI_SET_VALUES_TABLE .
783
+ " WHERE set_type=%d
784
GROUP BY post_id", $set_id));
785
786
+ //Insert the new fields
787
+ foreach ($array_post_id as $postid) {
788
789
+ $insert_new_field_values_table = $wpdb->insert(
790
+ YASR_MULTI_SET_VALUES_TABLE,
791
+ array(
792
+ 'id' => $field_value_table_new_id,
793
+ 'set_type' => $set_id,
794
+ 'field_id' => $new_field_id,
795
+ 'post_id' => $postid->post_id
796
+ ),
797
+ array('%d', '%d', '%d', '%d')
798
+ );
799
800
+ $field_value_table_new_id ++;
801
802
+ }
803
804
+ if ($insert_set_value == false) {
805
+ $error = true;
806
+ $array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yet-another-stars-rating');
807
+ }
808
809
+ } //end else
810
+ }
811
812
813
+ } //End for
814
815
816
+ if ($error) {
817
+ return $array_errors;
818
+ } else {
819
+ echo "<div class=\"updated\"><p><strong>";
820
+ _e("Settings Saved", 'yet-another-stars-rating');
821
+ echo "</strong></p></div> ";
822
+ }
823
824
825
+ } //End if isset( $_POST['yasr_edit_multi_set_form']
826
827
828
} //End yasr_process_edit_multi_set_form() function
lib/admin/settings/yasr-settings-functions.php CHANGED
@@ -17,190 +17,78 @@ GNU General Public License for more details.
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
- if ( !defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
- }
23
- // Exit if accessed directly
24
- function yasr_settings_tabs( $active_tab )
25
- {
26
- ?>
27
-
28
- <h2 class="nav-tab-wrapper yasr-no-underline">
29
-
30
- <a href="?page=yasr_settings_page&tab=general_settings"
31
- class="nav-tab <?php
32
- if ( $active_tab === 'general_settings' ) {
33
- echo 'nav-tab-active' ;
34
- }
35
- ?>">
36
- <?php
37
- _e( "General Settings", 'yet-another-stars-rating' );
38
- ?>
39
- </a>
40
-
41
- <a href="?page=yasr_settings_page&tab=manage_multi" class="nav-tab <?php
42
- if ( $active_tab === 'manage_multi' ) {
43
- echo 'nav-tab-active' ;
44
- }
45
- ?>">
46
- <?php
47
- _e( "Multi Sets", 'yet-another-stars-rating' );
48
- ?>
49
- </a>
50
-
51
- <a href="?page=yasr_settings_page&tab=style_options"
52
- class="nav-tab <?php
53
- if ( $active_tab === 'style_options' ) {
54
- echo 'nav-tab-active' ;
55
- }
56
- ?>">
57
- <?php
58
- _e( "Aspect & Styles", 'yet-another-stars-rating' );
59
- ?>
60
- </a>
61
62
63
- <?php
64
- do_action( 'yasr_add_settings_tab', $active_tab );
65
- ?>
66
67
- </h2>
68
69
- <?php
70
- }
71
72
- /************ Add yasr general options ***********/
73
- add_action( 'admin_init', 'yasr_general_options_init' );
74
- //This is for general options
75
- function yasr_general_options_init()
76
- {
77
register_setting(
78
- 'yasr_general_options_group',
79
- // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
80
- 'yasr_general_options',
81
- //The name of an option to sanitize and save.
82
'yasr_general_options_sanitize'
83
);
84
- $option = get_option( 'yasr_general_options' );
85
//This is to avoid undefined offset
86
-
87
- if ( $option && $option['auto_insert_enabled'] == 0 ) {
88
- $option['auto_insert_what'] = 'overall_rating';
89
- $option['auto_insert_where'] = 'top';
90
- $option['auto_insert_exclude_pages'] = 'yes';
91
- $option['auto_insert_size'] = 'large';
92
$option['auto_insert_custom_post_only'] = 'no';
93
}
94
-
95
//This is to avoid undefined offset
96
-
97
- if ( $option && $option['text_before_stars'] == 0 ) {
98
- $option['text_before_overall'] = '';
99
$option['text_before_visitor_rating'] = '';
100
- $option['text_after_visitor_rating'] = '';
101
- $option['custom_text_user_voted'] = '';
102
- $option['custom_text_must_sign_in'] = '';
103
}
104
-
105
//if it's not blogposting avoid undefined variable
106
- if ( !isset( $option['blogposting_organization_name'] ) ) {
107
- $option['blogposting_organization_name'] = get_bloginfo( 'name' );
108
}
109
- if ( !isset( $option['blogposting_organization_logo'] ) ) {
110
$option['blogposting_organization_logo'] = get_site_icon_url();
111
}
112
- add_settings_section(
113
- 'yasr_general_options_section_id',
114
- __( 'General settings', 'yet-another-stars-rating' ),
115
- 'yasr_section_callback',
116
- 'yasr_general_settings_tab'
117
- );
118
- add_settings_field(
119
- 'yasr_use_auto_insert_id',
120
- __( 'Auto insert options', 'yet-another-stars-rating' ),
121
- 'yasr_auto_insert_callback',
122
- 'yasr_general_settings_tab',
123
- 'yasr_general_options_section_id',
124
- $option
125
- );
126
- add_settings_field(
127
- 'yasr_custom_text',
128
- __( 'Insert custom text to show before / after stars', 'yet-another-stars-rating' ),
129
- 'yasr_custom_text_callback',
130
- 'yasr_general_settings_tab',
131
- 'yasr_general_options_section_id',
132
- $option
133
- );
134
- add_settings_field(
135
- 'yasr_show_overall_in_loop',
136
- __( 'Show "Overall Rating" in Archive Page?', 'yet-another-stars-rating' ),
137
- 'yasr_show_overall_in_loop_callback',
138
- 'yasr_general_settings_tab',
139
- 'yasr_general_options_section_id',
140
- $option
141
- );
142
- add_settings_field(
143
- 'yasr_show_visitor_votes_in_loop',
144
- __( 'Show "Visitor Votes" in Archive Page?', 'yet-another-stars-rating' ),
145
- 'yasr_show_visitor_votes_in_loop_callback',
146
- 'yasr_general_settings_tab',
147
- 'yasr_general_options_section_id',
148
- $option
149
- );
150
- add_settings_field(
151
- 'yasr_visitors_stats',
152
- __( 'Do you want show stats for visitors votes?', 'yet-another-stars-rating' ),
153
- 'yasr_visitors_stats_callback',
154
- 'yasr_general_settings_tab',
155
- 'yasr_general_options_section_id',
156
- $option
157
- );
158
- add_settings_field(
159
- 'yasr_allow_only_logged_in_id',
160
- __( 'Allow only logged in user to vote?', 'yet-another-stars-rating' ),
161
- 'yasr_allow_only_logged_in_callback',
162
- 'yasr_general_settings_tab',
163
- 'yasr_general_options_section_id',
164
- $option
165
- );
166
- add_settings_field(
167
- 'yasr_enable_ip',
168
- __( 'Do you want to save ip address?', 'yet-another-stars-rating' ),
169
- 'yasr_enable_ip_callback',
170
- 'yasr_general_settings_tab',
171
- 'yasr_general_options_section_id',
172
- $option
173
- );
174
- add_settings_field(
175
- 'yasr_choose_snippet_id',
176
- __( 'Rich snippet options', 'yet-another-stars-rating' ),
177
- 'yasr_choose_snippet_callback',
178
- 'yasr_general_settings_tab',
179
- 'yasr_general_options_section_id',
180
- $option
181
- );
182
}
183
184
- function yasr_section_callback()
185
- {
186
//_e('Manage auto insert', 'yet-another-stars-rating');
187
}
188
189
- function yasr_auto_insert_callback( $option )
190
- {
191
?>
192
193
<div>
194
- <strong><?php
195
- _e( 'Use Auto Insert?', 'yet-another-stars-rating' );
196
- ?></strong>
197
<div class="yasr-onoffswitch-big">
198
<input type="checkbox" name="yasr_general_options[auto_insert_enabled]" class="yasr-onoffswitch-checkbox"
199
- value="1" id="yasr_auto_insert_switch" <?php
200
- if ( $option['auto_insert_enabled'] == 1 ) {
201
- echo " checked='checked' " ;
202
- }
203
- ?> >
204
<label class="yasr-onoffswitch-label" for="yasr_auto_insert_switch">
205
<span class="yasr-onoffswitch-inner"></span>
206
<span class="yasr-onoffswitch-switch"></span>
@@ -209,249 +97,184 @@ function yasr_auto_insert_callback( $option )
209
210
<p>&nbsp;</p>
211
212
- <strong><?php
213
- _e( 'What?', 'yet-another-stars-rating' );
214
- ?></strong>
215
216
<div class="yasr-indented-answer">
217
218
<input type="radio" name="yasr_general_options[auto_insert_what]" value="overall_rating"
219
- class="yasr-auto-insert-options-class" <?php
220
- if ( $option['auto_insert_what'] === 'overall_rating' ) {
221
- echo " checked=\"checked\" " ;
222
- }
223
- ?> >
224
- <?php
225
- _e( 'Overall Rating / Author Rating', 'yet-another-stars-rating' );
226
- ?>
227
<br/>
228
229
<input type="radio" name="yasr_general_options[auto_insert_what]" value="visitor_rating"
230
- class="yasr-auto-insert-options-class" <?php
231
- if ( $option['auto_insert_what'] === 'visitor_rating' ) {
232
- echo " checked=\"checked\" " ;
233
- }
234
- ?> >
235
- <?php
236
- _e( 'Visitor Votes', 'yet-another-stars-rating' );
237
- ?>
238
<br/>
239
240
<input type="radio" name="yasr_general_options[auto_insert_what]" value="both"
241
- class="yasr-auto-insert-options-class" <?php
242
- if ( $option['auto_insert_what'] === 'both' ) {
243
- echo " checked=\"checked\" " ;
244
- }
245
- ?> >
246
- <?php
247
- _e( 'Both', 'yet-another-stars-rating' );
248
- ?>
249
250
<p>&nbsp;</p>
251
252
</div>
253
254
- <strong><?php
255
- _e( 'Where?', 'yet-another-stars-rating' );
256
- ?></strong>
257
258
<div class="yasr-indented-answer">
259
260
<input type="radio" name="yasr_general_options[auto_insert_where]" value="top"
261
- class="yasr-auto-insert-options-class" <?php
262
- if ( $option['auto_insert_where'] === 'top' ) {
263
- echo " checked=\"checked\" " ;
264
- }
265
- ?> >
266
- <?php
267
- _e( 'Before the post', 'yet-another-stars-rating' );
268
- ?>
269
<br/>
270
271
<input type="radio" name="yasr_general_options[auto_insert_where]" value="bottom"
272
- class="yasr-auto-insert-options-class" <?php
273
- if ( $option['auto_insert_where'] === 'bottom' ) {
274
- echo " checked=\"checked\" " ;
275
- }
276
- ?> >
277
- <?php
278
- _e( 'After the post', 'yet-another-stars-rating' );
279
- ?>
280
<br/>
281
282
<p>&nbsp;</p>
283
284
</div>
285
286
- <strong><?php
287
- _e( 'Size', 'yet-another-stars-rating' );
288
- ?></strong>
289
290
<div class="yasr-indented-answer">
291
292
<div class="yasr-option-size">
293
<input type="radio" name="yasr_general_options[auto_insert_size]" value="small"
294
- class="yasr-auto-insert-options-class" <?php
295
- if ( $option['auto_insert_size'] === 'small' ) {
296
- echo " checked=\"checked\" " ;
297
- }
298
- ?> >
299
- <img src="<?php
300
- echo YASR_IMG_DIR . "yasr-stars-small.png" ;
301
- ?>" class="yasr-img-option-size"><span
302
- class="yasr-text-options-size"><?php
303
- _e( 'Small', 'yet-another-stars-rating' );
304
- ?></span>
305
</div>
306
307
<div class="yasr-option-size">
308
<input type="radio" name="yasr_general_options[auto_insert_size]" value="medium"
309
- class="yasr-auto-insert-options-class" <?php
310
- if ( $option['auto_insert_size'] === 'medium' ) {
311
- echo " checked=\"checked\" " ;
312
- }
313
- ?> >
314
- <img src="<?php
315
- echo YASR_IMG_DIR . "yasr-stars-medium.png" ;
316
- ?>" class="yasr-img-option-size"><span
317
- class="yasr-text-options-size"><?php
318
- _e( 'Medium', 'yet-another-stars-rating' );
319
- ?></span>
320
</div>
321
322
<div class="yasr-option-size">
323
<input type="radio" name="yasr_general_options[auto_insert_size]" value="large"
324
- class="yasr-auto-insert-options-class" <?php
325
- if ( $option['auto_insert_size'] === 'large' ) {
326
- echo " checked=\"checked\" " ;
327
- }
328
- ?> >
329
- <img src="<?php
330
- echo YASR_IMG_DIR . "yasr-stars-large.png" ;
331
- ?>" class="yasr-img-option-size"><span
332
- class="yasr-text-options-size"><?php
333
- _e( 'Large', 'yet-another-stars-rating' );
334
- ?></span>
335
</div>
336
337
<p>&nbsp;</p>
338
339
</div>
340
341
- <strong><?php
342
- _e( 'Exclude Pages?', 'yet-another-stars-rating' );
343
- ?></strong>
344