Version Description
- Now user can choose what kind of snippet use, if AggregateRating or Review
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 0.2.4 |
Comparing to | |
See all releases |
Code changes from version 0.1.3 to 0.2.4
- css/rateit.css +4 -0
- css/yasr.css +1 -1
- img/yasr_aggregate.jpg +0 -0
- img/yasr_review.png +0 -0
- lib/yasr-ajax-functions.php +13 -11
- lib/yasr-db-functions.php +57 -15
- lib/yasr-functions.php +242 -208
- lib/yasr-settings-functions.php +155 -0
- lib/yasr-shortcode-functions.php +93 -80
- readme.txt +21 -2
- yasr-metabox-multiple-rating.php +12 -11
- yasr-metabox-overall-rating.php +1 -1
- yasr-settings-page.php +87 -39
- yet-another-stars-rating.php +9 -6
css/rateit.css
CHANGED
@@ -96,3 +96,7 @@
|
|
96 |
{
|
97 |
background-position: 0 -16px;
|
98 |
}
|
|
|
|
|
|
|
|
96 |
{
|
97 |
background-position: 0 -16px;
|
98 |
}
|
99 |
+
|
100 |
+
.yasr_settings_fields_content {
|
101 |
+
background-color: #F7F7F7;
|
102 |
+
}
|
css/yasr.css
CHANGED
@@ -239,4 +239,4 @@
|
|
239 |
#yasr-log-page-navigation {
|
240 |
padding-top: 7px;
|
241 |
text-align: center;
|
242 |
-
}
|
239 |
#yasr-log-page-navigation {
|
240 |
padding-top: 7px;
|
241 |
text-align: center;
|
242 |
+
}
|
img/yasr_aggregate.jpg
ADDED
Binary file
|
img/yasr_review.png
ADDED
Binary file
|
lib/yasr-ajax-functions.php
CHANGED
@@ -80,6 +80,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
80 |
if(isset($_POST['set_id']) && isset($_POST['post_id'])) {
|
81 |
$set_type = $_POST['set_id'];
|
82 |
$post_id = $_POST['post_id'];
|
|
|
83 |
}
|
84 |
else {
|
85 |
exit();
|
@@ -89,6 +90,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
89 |
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
92 |
global $wpdb;
|
93 |
|
94 |
$set_values=yasr_get_multi_set_values_and_field ($post_id, $set_type);
|
@@ -137,7 +142,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
137 |
|
138 |
echo "<tr> <td>";
|
139 |
echo "$name->name </td>";
|
140 |
-
echo "<td> <div class=\"rateit bigstars\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td>";
|
141 |
echo "</tr>";
|
142 |
}
|
143 |
echo "</table>
|
@@ -174,7 +179,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
174 |
$set_content->vote = $integer_vote+1;
|
175 |
}
|
176 |
|
177 |
-
echo "<td width=\"50%\"> <div class=\"rateit bigstars\" id=\"$set_content->id\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td></tr>";
|
178 |
} //End foreach
|
179 |
echo "</table>";
|
180 |
|
@@ -475,7 +480,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
475 |
|
476 |
echo "
|
477 |
|
478 |
-
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" value=\"$i\">
|
479 |
|
480 |
</table>
|
481 |
|
@@ -510,14 +515,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
510 |
|
511 |
</form>
|
512 |
|
513 |
-
<script type="text/javascript">
|
514 |
-
|
515 |
-
var counter = <?php echo "$i"; ?>;
|
516 |
-
|
517 |
-
counter = counter+1;
|
518 |
-
|
519 |
-
</script>
|
520 |
-
|
521 |
<?php
|
522 |
|
523 |
die();
|
@@ -657,6 +654,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
657 |
|
658 |
|
659 |
|
|
|
660 |
/******
|
661 |
Display recent votes on dashboard, called from function yasr_display_dashboard_log_wiget,
|
662 |
declared on yasr-db-function ******/
|
@@ -676,6 +674,10 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
|
|
676 |
$page_num = 1;
|
677 |
}
|
678 |
|
|
|
|
|
|
|
|
|
679 |
$limit = 8; //max number of row to echo
|
680 |
|
681 |
$offset = ( $page_num - 1 ) * $limit;
|
80 |
if(isset($_POST['set_id']) && isset($_POST['post_id'])) {
|
81 |
$set_type = $_POST['set_id'];
|
82 |
$post_id = $_POST['post_id'];
|
83 |
+
$nonce_visitor = $_POST['nonce_visitor'];
|
84 |
}
|
85 |
else {
|
86 |
exit();
|
90 |
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
|
91 |
}
|
92 |
|
93 |
+
if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
|
94 |
+
die( 'Security check' );
|
95 |
+
}
|
96 |
+
|
97 |
global $wpdb;
|
98 |
|
99 |
$set_values=yasr_get_multi_set_values_and_field ($post_id, $set_type);
|
142 |
|
143 |
echo "<tr> <td>";
|
144 |
echo "$name->name </td>";
|
145 |
+
echo "<td> <div class=\"rateit bigstars multi\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td>";
|
146 |
echo "</tr>";
|
147 |
}
|
148 |
echo "</table>
|
179 |
$set_content->vote = $integer_vote+1;
|
180 |
}
|
181 |
|
182 |
+
echo "<td width=\"50%\"> <div class=\"rateit bigstars multi\" id=\"$set_content->id\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td></tr>";
|
183 |
} //End foreach
|
184 |
echo "</table>";
|
185 |
|
480 |
|
481 |
echo "
|
482 |
|
483 |
+
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
|
484 |
|
485 |
</table>
|
486 |
|
515 |
|
516 |
</form>
|
517 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
<?php
|
519 |
|
520 |
die();
|
654 |
|
655 |
|
656 |
|
657 |
+
|
658 |
/******
|
659 |
Display recent votes on dashboard, called from function yasr_display_dashboard_log_wiget,
|
660 |
declared on yasr-db-function ******/
|
674 |
$page_num = 1;
|
675 |
}
|
676 |
|
677 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
678 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
|
679 |
+
}
|
680 |
+
|
681 |
$limit = 8; //max number of row to echo
|
682 |
|
683 |
$offset = ( $page_num - 1 ) * $limit;
|
lib/yasr-db-functions.php
CHANGED
@@ -93,7 +93,7 @@ function yasr_search_gd_star_rating () {
|
|
93 |
}
|
94 |
|
95 |
else {
|
96 |
-
|
97 |
}
|
98 |
}
|
99 |
|
@@ -347,6 +347,31 @@ function yasr_get_overall_rating() {
|
|
347 |
}
|
348 |
}
|
349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
/****** Get multi set name ******/
|
351 |
function yasr_get_multi_set() {
|
352 |
global $wpdb;
|
@@ -406,7 +431,7 @@ function yasr_process_new_multi_set_form()
|
|
406 |
//IF thes fields are not empty go ahed
|
407 |
if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
|
408 |
|
409 |
-
$multi_set_name = $_POST['multi-set-name'];
|
410 |
|
411 |
$multi_set_name_element_=array();
|
412 |
|
@@ -579,12 +604,25 @@ function yasr_process_edit_multi_set_form() {
|
|
579 |
array ('%d')
|
580 |
);
|
581 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
582 |
if ($remove_set===FALSE) {
|
583 |
$error = TRUE;
|
584 |
$array_errors[] = __("Something goes wrong trying to delete a multi-set . Please report it", 'yasr');
|
585 |
}
|
586 |
|
587 |
if ($remove_set_values===FALSE) {
|
|
|
|
|
|
|
|
|
|
|
588 |
$error = TRUE;
|
589 |
$array_errors[] = __("Something goes wrong trying to delete data values for a set. Please report it", 'yasr');
|
590 |
}
|
@@ -594,7 +632,7 @@ function yasr_process_edit_multi_set_form() {
|
|
594 |
|
595 |
for ($i = 0; $i <= 9; $i++) {
|
596 |
|
597 |
-
//
|
598 |
if (isset($_POST["remove-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) ) {
|
599 |
|
600 |
$remove_field = $wpdb->delete (
|
@@ -634,11 +672,11 @@ function yasr_process_edit_multi_set_form() {
|
|
634 |
|
635 |
$field_name = $_POST["edit-multi-set-element-$i"];
|
636 |
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
|
643 |
else {
|
644 |
|
@@ -675,13 +713,16 @@ function yasr_process_edit_multi_set_form() {
|
|
675 |
|
676 |
$field_name = $_POST["edit-multi-set-element-$i"];
|
677 |
|
678 |
-
//if elements name is shorter than 3 chars
|
679 |
-
if
|
|
|
|
|
680 |
$array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
|
681 |
$error=TRUE;
|
682 |
}
|
683 |
|
684 |
-
|
|
|
685 |
|
686 |
$highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
|
687 |
|
@@ -753,6 +794,7 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
|
|
753 |
|
754 |
|
755 |
function yasr_display_dashboard_log_wiget () {
|
|
|
756 |
|
757 |
$limit = 8; //max number of row to echo
|
758 |
|
@@ -864,8 +906,6 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
|
|
864 |
|
865 |
?>
|
866 |
|
867 |
-
|
868 |
-
|
869 |
<script type="text/javascript">
|
870 |
|
871 |
//Log
|
@@ -873,7 +913,8 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
|
|
873 |
|
874 |
var data = {
|
875 |
action : 'yasr_change_log_page',
|
876 |
-
pagenum: jQuery(this).val()
|
|
|
877 |
};
|
878 |
|
879 |
jQuery.post(ajaxurl, data, function(response) {
|
@@ -888,7 +929,8 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
|
|
888 |
|
889 |
var data = {
|
890 |
action : 'yasr_change_log_page',
|
891 |
-
pagenum: jQuery(this).val()
|
|
|
892 |
};
|
893 |
|
894 |
jQuery.post(ajaxurl, data, function(response) {
|
93 |
}
|
94 |
|
95 |
else {
|
96 |
+
__( 'No previous Gd Star Ratings installation was found', 'yasr' );
|
97 |
}
|
98 |
}
|
99 |
|
347 |
}
|
348 |
}
|
349 |
|
350 |
+
|
351 |
+
/****** Get visitor rating ******/
|
352 |
+
function yasr_get_vistor_rating() {
|
353 |
+
global $wpdb;
|
354 |
+
|
355 |
+
$post_id=get_the_ID();
|
356 |
+
|
357 |
+
$result=$wpdb->get_results("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . " WHERE post_id=$post_id");
|
358 |
+
|
359 |
+
if ($result) {
|
360 |
+
|
361 |
+
$visitor_rating = array();
|
362 |
+
|
363 |
+
foreach ($result as $rating) {
|
364 |
+
$visitor_rating['votes_number']=$rating->number_of_votes;
|
365 |
+
$visitor_rating['sum']=$rating->sum_votes;
|
366 |
+
|
367 |
+
return $visitor_rating;
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
|
374 |
+
|
375 |
/****** Get multi set name ******/
|
376 |
function yasr_get_multi_set() {
|
377 |
global $wpdb;
|
431 |
//IF thes fields are not empty go ahed
|
432 |
if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
|
433 |
|
434 |
+
$multi_set_name = ucfirst(strtolower($_POST['multi-set-name']));
|
435 |
|
436 |
$multi_set_name_element_=array();
|
437 |
|
604 |
array ('%d')
|
605 |
);
|
606 |
|
607 |
+
$remove_set_votes = $wpdb->delete (
|
608 |
+
YASR_MULTI_SET_VALUES_TABLE,
|
609 |
+
array(
|
610 |
+
'set_type' => $set_id,
|
611 |
+
),
|
612 |
+
array ('%d')
|
613 |
+
);
|
614 |
+
|
615 |
if ($remove_set===FALSE) {
|
616 |
$error = TRUE;
|
617 |
$array_errors[] = __("Something goes wrong trying to delete a multi-set . Please report it", 'yasr');
|
618 |
}
|
619 |
|
620 |
if ($remove_set_values===FALSE) {
|
621 |
+
$error = TRUE;
|
622 |
+
$array_errors[] = __("Something goes wrong trying to delete data fields for a set. Please report it", 'yasr');
|
623 |
+
}
|
624 |
+
|
625 |
+
if ($remove_set_votes===FALSE) {
|
626 |
$error = TRUE;
|
627 |
$array_errors[] = __("Something goes wrong trying to delete data values for a set. Please report it", 'yasr');
|
628 |
}
|
632 |
|
633 |
for ($i = 0; $i <= 9; $i++) {
|
634 |
|
635 |
+
//Than, check if the user want to remove some field
|
636 |
if (isset($_POST["remove-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) ) {
|
637 |
|
638 |
$remove_field = $wpdb->delete (
|
672 |
|
673 |
$field_name = $_POST["edit-multi-set-element-$i"];
|
674 |
|
675 |
+
//if elements name is shorter than 3 chars
|
676 |
+
if (mb_strlen($field_name) <3 ) {
|
677 |
+
$array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
|
678 |
+
$error=TRUE;
|
679 |
+
}
|
680 |
|
681 |
else {
|
682 |
|
713 |
|
714 |
$field_name = $_POST["edit-multi-set-element-$i"];
|
715 |
|
716 |
+
//if elements name is shorter than 3 chars return error. I use mb_strlen($field_name) > 1
|
717 |
+
//because I don't wont return error if an user add an empty field. An empty field will be
|
718 |
+
//just ignored
|
719 |
+
if (mb_strlen($field_name) > 1 && mb_strlen($field_name) < 3) {
|
720 |
$array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
|
721 |
$error=TRUE;
|
722 |
}
|
723 |
|
724 |
+
//if field is not empty
|
725 |
+
elseif ($field_name != '') {
|
726 |
|
727 |
$highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
|
728 |
|
794 |
|
795 |
|
796 |
function yasr_display_dashboard_log_wiget () {
|
797 |
+
|
798 |
|
799 |
$limit = 8; //max number of row to echo
|
800 |
|
906 |
|
907 |
?>
|
908 |
|
|
|
|
|
909 |
<script type="text/javascript">
|
910 |
|
911 |
//Log
|
913 |
|
914 |
var data = {
|
915 |
action : 'yasr_change_log_page',
|
916 |
+
pagenum: jQuery(this).val(),
|
917 |
+
|
918 |
};
|
919 |
|
920 |
jQuery.post(ajaxurl, data, function(response) {
|
929 |
|
930 |
var data = {
|
931 |
action : 'yasr_change_log_page',
|
932 |
+
pagenum: jQuery(this).val(),
|
933 |
+
|
934 |
};
|
935 |
|
936 |
jQuery.post(ajaxurl, data, function(response) {
|
lib/yasr-functions.php
CHANGED
@@ -44,89 +44,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
44 |
);
|
45 |
}
|
46 |
|
47 |
-
add_action( 'admin_init', 'yasr_multi_form_init' );
|
48 |
-
|
49 |
-
function yasr_multi_form_init() {
|
50 |
-
register_setting(
|
51 |
-
'yasr_multi_form', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
|
52 |
-
'yasr_auto_insert_options' //The name of an option to sanitize and save.
|
53 |
-
);
|
54 |
-
|
55 |
-
$option = get_option( 'yasr_auto_insert_options' );
|
56 |
-
|
57 |
-
//To avoid undifined index, i put here the default value
|
58 |
-
if (!$option || !$option['enabled'] || !$option['what'] || !$option['where']) {
|
59 |
-
$option['enabled']=0;
|
60 |
-
$option['what']='overall_rating';
|
61 |
-
$option['where']='top';
|
62 |
-
}
|
63 |
-
|
64 |
-
add_settings_section( 'yasr_auto_insert_section_id', __('Auto insert Settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
|
65 |
-
add_settings_field( 'yasr_use_auto_insert_id', __('Use auto insert?', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option );
|
66 |
-
add_settings_field( 'yasr_what_auto_insert', __('What?', 'yasr'), 'yasr_what_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
|
67 |
-
add_settings_field( 'yasr_where_auto_insert', __('Where?', 'yasr'), 'yasr_where_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
|
68 |
-
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
function yasr_section_callback() {
|
73 |
-
//_e('Manage auto insert', 'yasr');
|
74 |
-
}
|
75 |
-
|
76 |
-
function yasr_auto_insert_callback($option) {
|
77 |
-
|
78 |
-
?>
|
79 |
-
|
80 |
-
<?php _e('Yes', 'yasr') ?>
|
81 |
-
<input type='radio' name='yasr_auto_insert_options[enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['enabled']==1) echo " checked=\"checked\" "; ?> />
|
82 |
-
|
83 |
-
|
84 |
-
<?php _e('No', 'yasr') ?>
|
85 |
-
<input type='radio' name='yasr_auto_insert_options[enabled]' value='0' id='yasr_auto_insert_radio_off'
|
86 |
-
<?php if ($option['enabled']==0) {
|
87 |
-
echo " checked=\"checked\" />";
|
88 |
-
echo ("<script>
|
89 |
-
jQuery( document ).ready(function() {
|
90 |
-
jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', true);
|
91 |
-
});
|
92 |
-
</script>") ;
|
93 |
-
}
|
94 |
-
?>
|
95 |
-
|
96 |
-
|
97 |
-
<?php
|
98 |
-
} //End yasr_auto_insert_callback
|
99 |
-
|
100 |
-
function yasr_what_auto_insert_callback($option) {
|
101 |
-
?>
|
102 |
-
|
103 |
-
<input type="radio" name="yasr_auto_insert_options[what]" value="overall_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='overall_rating') echo " checked=\"checked\" "; ?> >
|
104 |
-
<?php _e('Overall Rating / Author Rating', 'yasr') ?>
|
105 |
-
<br />
|
106 |
-
|
107 |
-
<input type="radio" name="yasr_auto_insert_options[what]" value="visitor_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='visitor_rating') echo " checked=\"checked\" "; ?> >
|
108 |
-
<?php _e('Visitor Votes', 'yasr')?>
|
109 |
-
<br />
|
110 |
-
|
111 |
-
<input type="radio" name="yasr_auto_insert_options[what]" value="both" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='both') echo " checked=\"checked\" "; ?> >
|
112 |
-
<?php _e('Both', 'yasr')?>
|
113 |
-
|
114 |
-
<?php
|
115 |
-
} //end function yasr_what_auto_insert_callback
|
116 |
-
|
117 |
-
function yasr_where_auto_insert_callback($option) {
|
118 |
-
?>
|
119 |
-
|
120 |
-
<input type="radio" name="yasr_auto_insert_options[where]" value="top" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='top' ) echo " checked=\"checked\" "; ?> >
|
121 |
-
<?php _e('Before the post', 'yasr')?>
|
122 |
-
<br />
|
123 |
-
|
124 |
-
<input type="radio" name="yasr_auto_insert_options[where]" value="bottom" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='bottom') echo " checked=\"checked\" "; ?> >
|
125 |
-
<?php _e('After the post', 'yasr')?>
|
126 |
-
<br />
|
127 |
-
|
128 |
-
<?php
|
129 |
-
} //End function yasr_where_auto_insert_callback
|
130 |
|
131 |
// Settings Page Content
|
132 |
function yasr_settings_page_callback () {
|
@@ -137,13 +54,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
137 |
|
138 |
<div class="wrap">
|
139 |
|
140 |
-
<h2>
|
141 |
|
142 |
<?php
|
143 |
|
144 |
-
$error_new_multi_set=yasr_process_new_multi_set_form();
|
145 |
|
146 |
-
$error_edit_multi_set=yasr_process_edit_multi_set_form();
|
147 |
|
148 |
if ($error_new_multi_set) {
|
149 |
echo "<div class=\"error\"> <p> <strong>";
|
@@ -168,15 +85,17 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
168 |
}
|
169 |
?>
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
180 |
|
181 |
<!--End div wrap is in yasr-settings-page-->
|
182 |
|
@@ -187,6 +106,173 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
187 |
} //End yasr_settings_page_content
|
188 |
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
|
192 |
/****** Create 2 metaboxes in post and pages ******/
|
@@ -236,27 +322,72 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
236 |
|
237 |
$schema=NULL; //To avoid undefined variable notice outside the loop
|
238 |
|
239 |
-
$
|
|
|
|
|
240 |
|
241 |
-
|
242 |
|
243 |
-
if(
|
244 |
-
global $post;
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
$author = __(' reviewed by ', 'yasr') . "<span itemprop=\"author\">" . get_the_author() . "</span>";
|
249 |
-
$date = __(' on ', 'yasr') . "<meta itemprop=\"datePublished\" content=\"" . get_the_date('c') . "\"> " . get_the_date();
|
250 |
-
$rating = __( ' rated ' , 'yasr' ) . "<span itemprop=\"reviewRating\">" . $overall_rating . "</span>" . __(' on 5.0' , 'yasr');
|
251 |
-
$end_div= "</div>";
|
252 |
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
-
}
|
256 |
|
257 |
-
|
258 |
|
259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
|
261 |
|
262 |
|
@@ -287,7 +418,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
287 |
return $content . $overall_rating_shortcode;
|
288 |
break;
|
289 |
} //End Switch
|
290 |
-
} //end ($option['what']
|
291 |
|
292 |
elseif ($option['what']=='visitor_rating') {
|
293 |
switch ($option['where']) {
|
@@ -358,101 +489,4 @@ function yasr_add_tinymce_button($buttons) {
|
|
358 |
//Add the button ID to the $button array
|
359 |
$buttons[] = "yasr_button";
|
360 |
return $buttons;
|
361 |
-
}
|
362 |
-
|
363 |
-
|
364 |
-
/****** Create a form for settings page to create new multi set ******/
|
365 |
-
function yasr_display_multi_set_form() {
|
366 |
-
?>
|
367 |
-
|
368 |
-
<h4 align="center">Add New Multiple Set</h4>
|
369 |
-
<em><?php _e('Field Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yasr') ?></em>
|
370 |
-
<p>
|
371 |
-
<form action="<?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_add_multi_set" method="post">
|
372 |
-
<strong><?php _e("Name", 'yasr')?></strong>
|
373 |
-
<input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
|
374 |
-
<input type="hidden" name="action" value="yasr_new_multi_set_form" />
|
375 |
-
|
376 |
-
<p></p>
|
377 |
-
<?php _e("You can insert up to nine element") ?>
|
378 |
-
<br />
|
379 |
-
|
380 |
-
<?php for($i=1; $i<=9; $i++) {
|
381 |
-
|
382 |
-
echo "<strong>" . __("Element ", 'yasr') . "#$i" . "</strong>";
|
383 |
-
?>
|
384 |
-
<input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>" class="input-text-multi-set">
|
385 |
-
<br />
|
386 |
-
|
387 |
-
<?php } //End foreach
|
388 |
-
|
389 |
-
wp_nonce_field( 'add-multi-set', 'add-nonce-new-multi-set' ) ?><!-- a little security to process on submission -->
|
390 |
-
|
391 |
-
<br />
|
392 |
-
<input type="submit" value="<?php _e("Create New Set", 'yasr') ?>" class="button-primary"/>
|
393 |
-
</form>
|
394 |
-
|
395 |
-
<?php
|
396 |
-
} //End function
|
397 |
-
|
398 |
-
|
399 |
-
/****** This function print the form to edit multi-set ******/
|
400 |
-
function yasr_edit_multi_form() {
|
401 |
-
|
402 |
-
$multi_set=yasr_get_multi_set();
|
403 |
-
|
404 |
-
global $wpdb;
|
405 |
-
|
406 |
-
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
407 |
-
|
408 |
-
if ($n_multi_set > 1) {
|
409 |
-
?>
|
410 |
-
|
411 |
-
<button href="#" class="button-delete" id="yasr-manage-multi-set"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
|
412 |
-
|
413 |
-
<div class="yasr-manage-multiset">
|
414 |
-
|
415 |
-
<?php _e('Wich set do you want to edit or remove?', 'yasr')?>
|
416 |
-
|
417 |
-
<select id ="yasr_select_edit_set">
|
418 |
-
<?php foreach ($multi_set as $name) { ?>
|
419 |
-
<option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
|
420 |
-
<?php } //End foreach ?>
|
421 |
-
</select>
|
422 |
-
|
423 |
-
</div>
|
424 |
-
|
425 |
-
<?php
|
426 |
-
} //End if n_multi_set >1
|
427 |
-
|
428 |
-
elseif ($n_multi_set == 1) {
|
429 |
-
?>
|
430 |
-
|
431 |
-
<button href="#" class="button-delete" id="yasr-manage-multi-set-single"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
|
432 |
-
|
433 |
-
<div class="yasr-manage-multiset-single">
|
434 |
-
|
435 |
-
<?php
|
436 |
-
|
437 |
-
$set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
|
438 |
-
FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
|
439 |
-
ORDER BY field_id ASC");
|
440 |
-
|
441 |
-
$i=1;
|
442 |
-
foreach ($set_name as $name) {
|
443 |
-
echo "Element #$i <input type=\"text\" value=\"$name->name\"> <br />";
|
444 |
-
$i++;
|
445 |
-
}
|
446 |
-
|
447 |
-
?>
|
448 |
-
|
449 |
-
</div>
|
450 |
-
|
451 |
-
<?php
|
452 |
-
}
|
453 |
-
|
454 |
-
else {
|
455 |
-
_e("No multiple set were found");
|
456 |
-
}
|
457 |
-
|
458 |
-
}//End function
|
44 |
);
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
// Settings Page Content
|
49 |
function yasr_settings_page_callback () {
|
54 |
|
55 |
<div class="wrap">
|
56 |
|
57 |
+
<h2>Yet Another Stars Rating: Settings</h2>
|
58 |
|
59 |
<?php
|
60 |
|
61 |
+
$error_new_multi_set=yasr_process_new_multi_set_form(); //defined in yasr-db-functions
|
62 |
|
63 |
+
$error_edit_multi_set=yasr_process_edit_multi_set_form(); //defined in yasr-db-functions
|
64 |
|
65 |
if ($error_new_multi_set) {
|
66 |
echo "<div class=\"error\"> <p> <strong>";
|
85 |
}
|
86 |
?>
|
87 |
|
88 |
+
|
89 |
+
<div class="yasr-settingsdiv">
|
90 |
+
<form action="options.php" method="post" id="yasr_settings_form">
|
91 |
+
<?php
|
92 |
+
settings_fields( 'yasr_auto_insert_options_group' );
|
93 |
+
settings_fields( 'yasr_choose_snippet_group' );
|
94 |
+
do_settings_sections('yasr_settings_page' );
|
95 |
+
submit_button( __('Save') );
|
96 |
+
?>
|
97 |
+
</form>
|
98 |
+
</div>
|
99 |
|
100 |
<!--End div wrap is in yasr-settings-page-->
|
101 |
|
106 |
} //End yasr_settings_page_content
|
107 |
|
108 |
|
109 |
+
/****** Create a form for settings page to create new multi set ******/
|
110 |
+
function yasr_display_multi_set_form() {
|
111 |
+
?>
|
112 |
+
|
113 |
+
<h4 align="center">Add New Multiple Set</h4>
|
114 |
+
<em><?php _e('Field Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yasr') ?></em>
|
115 |
+
<p>
|
116 |
+
<form action="<?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_add_multi_set" method="post">
|
117 |
+
<strong><?php _e("Name", 'yasr')?></strong>
|
118 |
+
<input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
|
119 |
+
<input type="hidden" name="action" value="yasr_new_multi_set_form" />
|
120 |
+
|
121 |
+
<p></p>
|
122 |
+
<?php _e("You can insert up to nine element") ?>
|
123 |
+
<br />
|
124 |
+
|
125 |
+
<?php for($i=1; $i<=9; $i++) {
|
126 |
+
|
127 |
+
echo "<strong>" . __("Element ", 'yasr') . "#$i" . "</strong>";
|
128 |
+
?>
|
129 |
+
<input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>" class="input-text-multi-set">
|
130 |
+
<br />
|
131 |
+
|
132 |
+
<?php } //End foreach
|
133 |
+
|
134 |
+
wp_nonce_field( 'add-multi-set', 'add-nonce-new-multi-set' ) ?><!-- a little security to process on submission -->
|
135 |
+
|
136 |
+
<br />
|
137 |
+
<input type="submit" value="<?php _e("Create New Set", 'yasr') ?>" class="button-primary"/>
|
138 |
+
</form>
|
139 |
+
|
140 |
+
<?php
|
141 |
+
} //End function
|
142 |
+
|
143 |
+
|
144 |
+
/****** This function print the form to edit multi-set ******/
|
145 |
+
function yasr_edit_multi_form() {
|
146 |
+
|
147 |
+
$multi_set=yasr_get_multi_set();
|
148 |
+
|
149 |
+
global $wpdb;
|
150 |
+
|
151 |
+
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
152 |
+
|
153 |
+
if ($n_multi_set > 1) {
|
154 |
+
?>
|
155 |
+
|
156 |
+
<button href="#" class="button-delete" id="yasr-manage-multi-set"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
|
157 |
+
|
158 |
+
<div class="yasr-manage-multiset">
|
159 |
+
|
160 |
+
<?php _e('Wich set do you want to edit or remove?', 'yasr')?>
|
161 |
+
|
162 |
+
<select id ="yasr_select_edit_set">
|
163 |
+
<?php foreach ($multi_set as $name) { ?>
|
164 |
+
<option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
|
165 |
+
<?php } //End foreach ?>
|
166 |
+
</select>
|
167 |
+
|
168 |
+
</div>
|
169 |
+
|
170 |
+
<?php
|
171 |
+
} //End if n_multi_set >1
|
172 |
+
|
173 |
+
elseif ($n_multi_set == 1) {
|
174 |
+
|
175 |
+
$set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id, parent_set_id AS set_id
|
176 |
+
FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
|
177 |
+
ORDER BY field_id ASC");
|
178 |
+
|
179 |
+
foreach ($multi_set as $find_set_id) {
|
180 |
+
$set_type = $find_set_id->set_id;
|
181 |
+
}
|
182 |
+
|
183 |
+
?>
|
184 |
+
|
185 |
+
<button href="#" class="button-delete" id="yasr-manage-multi-set-single"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
|
186 |
+
|
187 |
+
<div class="yasr-manage-multiset-single">
|
188 |
+
|
189 |
+
<form action=" <?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_edit_multi_set" method="post">
|
190 |
+
|
191 |
+
<input type="hidden" name="yasr_edit_multi_set_form" value="<?php echo $set_type ?>" />
|
192 |
+
|
193 |
+
<table id="yasr-table-form-edit-multi-set">
|
194 |
+
<tr>
|
195 |
+
|
196 |
+
<td id="yasr-table-form-edit-multi-set-header">
|
197 |
+
<?php _e('Field name', 'yasr') ?>
|
198 |
+
</td>
|
199 |
+
|
200 |
+
<td id="yasr-table-form-edit-multi-set-remove">
|
201 |
+
<?php _e('Remove', 'yasr') ?>
|
202 |
+
</td>
|
203 |
+
|
204 |
+
</tr>
|
205 |
+
|
206 |
+
<?php
|
207 |
+
|
208 |
+
$i=1;
|
209 |
+
foreach ($set_name as $name) {
|
210 |
+
echo "
|
211 |
+
<tr>
|
212 |
+
|
213 |
+
<td width=\"80%\">
|
214 |
+
Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$name->id\">
|
215 |
+
</td>
|
216 |
+
|
217 |
+
<td width=\"20%\" style=\"text-align:center\">
|
218 |
+
<input type=\"checkbox\" name=\"remove-element-$name->id\">
|
219 |
+
</td>
|
220 |
+
|
221 |
+
</tr>
|
222 |
+
";
|
223 |
+
$i++;
|
224 |
+
}
|
225 |
+
|
226 |
+
|
227 |
+
$i = $i-1; //This is the number of the fields
|
228 |
+
|
229 |
+
echo "
|
230 |
+
|
231 |
+
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" id=\"yasr-edit-form-number-elements\" value=\"$i\">
|
232 |
+
|
233 |
+
</table>
|
234 |
+
|
235 |
+
<table width=\"100%\" class=\"yasr-edit-form-remove-entire-set\">
|
236 |
+
<tr>
|
237 |
+
|
238 |
+
<td width=\"80%\">Remove whole set?</td>
|
239 |
+
|
240 |
+
<td width=\"20%\" style=\"text-align:center\">
|
241 |
+
<input type=\"checkbox\" name=\"yasr-remove-multi-set\" value=\"$set_type\">
|
242 |
+
</td>
|
243 |
+
|
244 |
+
</tr>
|
245 |
+
|
246 |
+
</table>
|
247 |
+
|
248 |
+
";
|
249 |
+
|
250 |
+
echo "<p>";
|
251 |
+
_e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , "yasr");
|
252 |
+
echo "</p>";
|
253 |
+
|
254 |
+
wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
|
255 |
+
|
256 |
+
?>
|
257 |
+
|
258 |
+
<div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , "yasr") ?></div>
|
259 |
+
|
260 |
+
<input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yasr'); ?>">
|
261 |
+
|
262 |
+
<input type="submit" value="<?php _e('Save changes', 'yasr') ?>" class="button-primary" >
|
263 |
+
|
264 |
+
</form>
|
265 |
+
|
266 |
+
</div>
|
267 |
+
|
268 |
+
<?php
|
269 |
+
}
|
270 |
+
|
271 |
+
else {
|
272 |
+
_e("No multiple set were found");
|
273 |
+
}
|
274 |
+
|
275 |
+
}//End function
|
276 |
|
277 |
|
278 |
/****** Create 2 metaboxes in post and pages ******/
|
322 |
|
323 |
$schema=NULL; //To avoid undefined variable notice outside the loop
|
324 |
|
325 |
+
$choosen_snippet = get_option( 'yasr_snippet_option' );
|
326 |
+
|
327 |
+
if ($choosen_snippet['what'] == 'overall_rating') {
|
328 |
|
329 |
+
$overall_rating=yasr_get_overall_rating();
|
330 |
|
331 |
+
if($overall_rating && $overall_rating != '-1') {
|
|
|
332 |
|
333 |
+
if(is_singular() && is_main_query() ) {
|
334 |
+
global $post;
|
|
|
|
|
|
|
|
|
335 |
|
336 |
+
$div = "<div itemprop=\"review\" itemscope itemtype=\"http://schema.org/Review\">";
|
337 |
+
$title = "<span itemprop=\"about\">". get_the_title() ."</span>";
|
338 |
+
$author = __(' reviewed by ', 'yasr') . "<span itemprop=\"author\">" . get_the_author() . "</span>";
|
339 |
+
$date = __(' on ', 'yasr') . "<meta itemprop=\"datePublished\" content=\"" . get_the_date('c') . "\"> " . get_the_date();
|
340 |
+
$rating = __( ' rated ' , 'yasr' ) . "<span itemprop=\"reviewRating\">" . $overall_rating . "</span>" . __(' on 5.0' , 'yasr');
|
341 |
+
$end_div= "</div>";
|
342 |
+
|
343 |
+
$schema = $div . $title . $author . $date . $rating . $end_div;
|
344 |
+
}
|
345 |
+
|
346 |
+
} //END id if $overall_rating != '-1'
|
347 |
+
|
348 |
+
if( is_singular() && is_main_query() ) {
|
349 |
+
return $content . $schema;
|
350 |
+
}
|
351 |
+
|
352 |
+
else {
|
353 |
+
return $content;
|
354 |
}
|
|
|
355 |
|
356 |
+
}
|
357 |
|
358 |
+
if ($choosen_snippet['what'] == 'visitor_rating') {
|
359 |
+
|
360 |
+
$visitor_rating = yasr_get_vistor_rating();
|
361 |
+
|
362 |
+
if ($visitor_rating['sum'] != 0) {
|
363 |
+
|
364 |
+
$average_rating = $visitor_rating['sum'] / $visitor_rating['votes_number'];
|
365 |
+
|
366 |
+
$average_rating=round($average_rating, 1);
|
367 |
+
|
368 |
+
$div_1 = "<div itemscope itemtype=\"http://schema.org/Product\">";
|
369 |
+
$title = "<span itemprop=\"name\">". get_the_title() ."</span>";
|
370 |
+
$span_1 = "<span itemprop=\"aggregateRating\" itemscope itemtype=\"http://schema.org/AggregateRating\">";
|
371 |
+
$rating = __( ' rated ' , 'yasr' ) . "<span itemprop=\"ratingValue\">" . $average_rating . "</span>" . __(' out of' ,'yasr') . "<span itemprop=\"bestRating\">5</span>";
|
372 |
+
$n_ratings = __(' based on ', 'yasr') . "<span itemprop=\"ratingCount\">" . $visitor_rating['votes_number'] . "</span>" . __(' user ratings', 'yasr');
|
373 |
+
$end_span_1 = "</span>";
|
374 |
+
$end_div_1 = "</div>";
|
375 |
+
|
376 |
+
$schema = $div_1 . $title . $span_1 . $rating . $n_ratings . $end_span_1 . $end_div_1;
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
if( is_singular() && is_main_query() ) {
|
381 |
+
return $content . $schema;
|
382 |
+
}
|
383 |
+
|
384 |
+
else {
|
385 |
+
return $content;
|
386 |
+
}
|
387 |
+
|
388 |
+
}
|
389 |
+
|
390 |
+
} //End function
|
391 |
|
392 |
|
393 |
|
418 |
return $content . $overall_rating_shortcode;
|
419 |
break;
|
420 |
} //End Switch
|
421 |
+
} //end ($option['what']=='overall_rating')
|
422 |
|
423 |
elseif ($option['what']=='visitor_rating') {
|
424 |
switch ($option['where']) {
|
489 |
//Add the button ID to the $button array
|
490 |
$buttons[] = "yasr_button";
|
491 |
return $buttons;
|
492 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/yasr-settings-functions.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/****** Add auto insert option ******/
|
5 |
+
|
6 |
+
add_action( 'admin_init', 'yasr_auto_insert_options_init' ); //This is for auto insert options
|
7 |
+
|
8 |
+
function yasr_auto_insert_options_init() {
|
9 |
+
register_setting(
|
10 |
+
'yasr_auto_insert_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
|
11 |
+
'yasr_auto_insert_options' //The name of an option to sanitize and save.
|
12 |
+
);
|
13 |
+
|
14 |
+
$option = get_option( 'yasr_auto_insert_options' );
|
15 |
+
|
16 |
+
//To avoid undifined index, i put here the default value
|
17 |
+
if (!$option || !$option['enabled'] || !$option['what'] || !$option['where']) {
|
18 |
+
$option['enabled']=0;
|
19 |
+
$option['what']='overall_rating';
|
20 |
+
$option['where']='top';
|
21 |
+
}
|
22 |
+
|
23 |
+
add_settings_section( 'yasr_auto_insert_section_id', __('Auto insert Settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
|
24 |
+
add_settings_field( 'yasr_use_auto_insert_id', __('Use auto insert?', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option );
|
25 |
+
add_settings_field( 'yasr_what_auto_insert', __('What?', 'yasr'), 'yasr_what_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
|
26 |
+
add_settings_field( 'yasr_where_auto_insert', __('Where?', 'yasr'), 'yasr_where_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
function yasr_section_callback() {
|
32 |
+
//_e('Manage auto insert', 'yasr');
|
33 |
+
}
|
34 |
+
|
35 |
+
function yasr_auto_insert_callback($option) {
|
36 |
+
|
37 |
+
?>
|
38 |
+
|
39 |
+
<?php _e('Yes', 'yasr') ?>
|
40 |
+
<input type='radio' name='yasr_auto_insert_options[enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['enabled']==1) echo " checked=\"checked\" "; ?> />
|
41 |
+
|
42 |
+
|
43 |
+
<?php _e('No', 'yasr') ?>
|
44 |
+
<input type='radio' name='yasr_auto_insert_options[enabled]' value='0' id='yasr_auto_insert_radio_off'
|
45 |
+
<?php if ($option['enabled']==0) {
|
46 |
+
echo " checked=\"checked\" />";
|
47 |
+
echo ("<script>
|
48 |
+
jQuery( document ).ready(function() {
|
49 |
+
jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', true);
|
50 |
+
});
|
51 |
+
</script>") ;
|
52 |
+
}
|
53 |
+
?>
|
54 |
+
|
55 |
+
|
56 |
+
<?php
|
57 |
+
} //End yasr_auto_insert_callback
|
58 |
+
|
59 |
+
function yasr_what_auto_insert_callback($option) {
|
60 |
+
?>
|
61 |
+
|
62 |
+
<input type="radio" name="yasr_auto_insert_options[what]" value="overall_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='overall_rating') echo " checked=\"checked\" "; ?> >
|
63 |
+
<?php _e('Overall Rating / Author Rating', 'yasr') ?>
|
64 |
+
<br />
|
65 |
+
|
66 |
+
<input type="radio" name="yasr_auto_insert_options[what]" value="visitor_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='visitor_rating') echo " checked=\"checked\" "; ?> >
|
67 |
+
<?php _e('Visitor Votes', 'yasr')?>
|
68 |
+
<br />
|
69 |
+
|
70 |
+
<input type="radio" name="yasr_auto_insert_options[what]" value="both" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='both') echo " checked=\"checked\" "; ?> >
|
71 |
+
<?php _e('Both', 'yasr')?>
|
72 |
+
|
73 |
+
<?php
|
74 |
+
} //end function yasr_what_auto_insert_callback
|
75 |
+
|
76 |
+
function yasr_where_auto_insert_callback($option) {
|
77 |
+
?>
|
78 |
+
|
79 |
+
<input type="radio" name="yasr_auto_insert_options[where]" value="top" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='top' ) echo " checked=\"checked\" "; ?> >
|
80 |
+
<?php _e('Before the post', 'yasr')?>
|
81 |
+
<br />
|
82 |
+
|
83 |
+
<input type="radio" name="yasr_auto_insert_options[where]" value="bottom" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='bottom') echo " checked=\"checked\" "; ?> >
|
84 |
+
<?php _e('After the post', 'yasr')?>
|
85 |
+
<br />
|
86 |
+
|
87 |
+
|
88 |
+
<p> </p>
|
89 |
+
|
90 |
+
|
91 |
+
<?php
|
92 |
+
} //End function yasr_where_auto_insert_callback
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
/****** Add choose snippet option ******/
|
97 |
+
|
98 |
+
add_action( 'admin_init', 'yasr_choose_snippet_init' );
|
99 |
+
|
100 |
+
function yasr_choose_snippet_init() {
|
101 |
+
|
102 |
+
register_setting(
|
103 |
+
'yasr_choose_snippet_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
|
104 |
+
'yasr_snippet_option' //The name of an option to sanitize and save.
|
105 |
+
);
|
106 |
+
|
107 |
+
$choosen_snippet = get_option( 'yasr_snippet_option' );
|
108 |
+
|
109 |
+
if (!$choosen_snippet || !$choosen_snippet['what']) {
|
110 |
+
$choosen_snippet['what']='overall_rating';
|
111 |
+
}
|
112 |
+
|
113 |
+
add_settings_section('yasr_choose_snippet_section_id', __('What rich snippets do you want to use?', 'yasr'), 'yasr_snippet_section_callback', 'yasr_settings_page');
|
114 |
+
add_settings_field( 'yasr_choose_snippet_id', __('Choose one', 'yasr'), 'yasr_choose_snippet_callback', 'yasr_settings_page', 'yasr_choose_snippet_section_id', $choosen_snippet );
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
function yasr_snippet_section_callback() {
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
function yasr_choose_snippet_callback($choosen_snippet) {
|
124 |
+
|
125 |
+
?>
|
126 |
+
|
127 |
+
<input type="radio" name="yasr_snippet_option[what]" value="overall_rating" class="yasr_choose_snippet" <?php if ($choosen_snippet['what']==='overall_rating') echo " checked=\"checked\" "; ?> >
|
128 |
+
<?php _e('Review Rating', 'yasr') ?>
|
129 |
+
<br />
|
130 |
+
|
131 |
+
<input type="radio" name="yasr_snippet_option[what]" value="visitor_rating" class="yasr_choose_snippet" <?php if ($choosen_snippet['what']==='visitor_rating') echo " checked=\"checked\" "; ?> >
|
132 |
+
<?php _e('Aggregate Rating', 'yasr')?>
|
133 |
+
<br />
|
134 |
+
|
135 |
+
<div class="yasr_snippet_explained">
|
136 |
+
<p> </p>
|
137 |
+
<?php
|
138 |
+
|
139 |
+
_e("If you select \"Review Rating\", your site will be indexed from search engines like this: ", "yasr");
|
140 |
+
echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr_review.png>";
|
141 |
+
|
142 |
+
echo "<br /> <br />";
|
143 |
+
|
144 |
+
_e("If, instead, you choose \"Aggregate Rating\", your site will be indexed like this", "yasr");
|
145 |
+
echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr_aggregate.jpg>";
|
146 |
+
?>
|
147 |
+
</div>
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
+
<?php
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
?>
|
lib/yasr-shortcode-functions.php
CHANGED
@@ -26,96 +26,109 @@ add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
|
|
26 |
|
27 |
function shortcode_visitor_votes_callback () {
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
?>
|
59 |
-
|
60 |
-
<script>
|
61 |
-
jQuery(document).ready(function() {
|
62 |
-
|
63 |
-
var tooltipvalues = ['bad', 'poor', 'ok', 'good', 'super'];
|
64 |
-
jQuery("#yasr_rateit_visitor_votes").bind('over', function (event, value) { jQuery(this).attr('title', tooltipvalues[value-1]); });
|
65 |
-
|
66 |
-
var postid = <?php the_ID(); ?>;
|
67 |
-
var cookiename = "yasr_visitor_vote_" + postid;
|
68 |
-
|
69 |
-
//If there is not cookie allow visitor to vote
|
70 |
-
if (!jQuery.cookie(cookiename)) {
|
71 |
-
|
72 |
-
jQuery('#yasr_rateit_visitor_votes').on('rated', function() {
|
73 |
-
var el = jQuery(this);
|
74 |
-
var value = el.rateit('value');
|
75 |
-
var value = value.toFixed(1); //
|
76 |
-
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
|
77 |
-
|
78 |
-
var data = {
|
79 |
-
action: 'yasr_send_visitor_rating',
|
80 |
-
rating: value,
|
81 |
-
post_id: postid
|
82 |
-
};
|
83 |
-
|
84 |
-
//Send value to the Server
|
85 |
-
jQuery.post(ajaxurl, data, function(response) {
|
86 |
-
jQuery('#yasr_visitor_votes').html(response);
|
87 |
-
jQuery('.rateit').rateit();
|
88 |
-
//Create a cookie to disable double vote
|
89 |
-
jQuery.cookie(cookiename, value, { expires : 360 });
|
90 |
-
}) ;
|
91 |
-
});
|
92 |
-
} //End if (!jQuery.cookie(cookiename))
|
93 |
-
|
94 |
-
//Else user cannot vote
|
95 |
-
else {
|
96 |
-
var cookievote=jQuery.cookie(cookiename);
|
97 |
-
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
|
98 |
-
|
99 |
-
var data = {
|
100 |
-
action: 'yasr_readonly_visitor_shortcode',
|
101 |
-
rating: cookievote,
|
102 |
-
votes: <?php echo $medium_rating ?>,
|
103 |
-
votes_number: <?php echo $votes_number ?>,
|
104 |
-
post_id: postid
|
105 |
}
|
106 |
|
107 |
-
jQuery.post(ajaxurl, data, function(response) {
|
108 |
-
jQuery('#yasr_visitor_votes').html(response);
|
109 |
-
jQuery('.rateit').rateit();
|
110 |
-
});
|
111 |
-
} //End else
|
112 |
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
<?php
|
118 |
-
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
|
26 |
|
27 |
function shortcode_visitor_votes_callback () {
|
28 |
|
29 |
+
$shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
|
30 |
|
31 |
+
if( is_singular() && is_main_query() ) {
|
32 |
|
33 |
+
$ajax_nonce_visitor = wp_create_nonce( "yasr_nonce_insert_visitor_rating" );
|
34 |
+
|
35 |
+
$votes=yasr_get_visitor_votes();
|
36 |
+
|
37 |
+
$medium_rating=0; //Avoid undefined variable
|
38 |
|
39 |
+
if (!$votes) {
|
40 |
+
$votes=0; //Avoid undefined variable if there is not overall rating
|
41 |
+
$votes_number=0; //Avoid undefined variable
|
42 |
+
}
|
43 |
+
|
44 |
+
else {
|
45 |
+
foreach ($votes as $user_votes) {
|
46 |
+
$votes_number = $user_votes->number_of_votes;
|
47 |
+
if ($votes_number !=0 ) {
|
48 |
+
$medium_rating = ($user_votes->sum_votes/$votes_number);
|
49 |
+
}
|
50 |
}
|
51 |
+
}
|
52 |
+
|
53 |
+
$medium_rating=round($medium_rating, 1);
|
54 |
+
|
55 |
+
if ($votes_number>0) {
|
56 |
+
$shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
|
57 |
+
</div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
|
58 |
+
}
|
59 |
+
|
60 |
+
else {
|
61 |
+
$shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
|
62 |
+
</div><br /> " . __("No rating yet" , "yasr") . "</div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
?>
|
67 |
+
|
68 |
+
<script>
|
69 |
+
jQuery(document).ready(function() {
|
70 |
+
|
71 |
+
var tooltipvalues = ['bad', 'poor', 'ok', 'good', 'super'];
|
72 |
+
jQuery("#yasr_rateit_visitor_votes").bind('over', function (event, value) { jQuery(this).attr('title', tooltipvalues[value-1]); });
|
73 |
+
|
74 |
+
var postid = <?php the_ID(); ?>;
|
75 |
+
var cookiename = "yasr_visitor_vote_" + postid;
|
76 |
|
77 |
+
//If there is not cookie allow visitor to vote
|
78 |
+
if (!jQuery.cookie(cookiename)) {
|
79 |
+
|
80 |
+
jQuery('#yasr_rateit_visitor_votes').on('rated', function() {
|
81 |
+
var el = jQuery(this);
|
82 |
+
var value = el.rateit('value');
|
83 |
+
var value = value.toFixed(1); //
|
84 |
+
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
|
85 |
+
|
86 |
+
var data = {
|
87 |
+
action: 'yasr_send_visitor_rating',
|
88 |
+
rating: value,
|
89 |
+
post_id: postid,
|
90 |
+
nonce_visitor: "<?php echo "$ajax_nonce_visitor"; ?>"
|
91 |
+
};
|
92 |
+
|
93 |
+
//Send value to the Server
|
94 |
+
jQuery.post(ajaxurl, data, function(response) {
|
95 |
+
jQuery('#yasr_visitor_votes').html(response);
|
96 |
+
jQuery('.rateit').rateit();
|
97 |
+
//Create a cookie to disable double vote
|
98 |
+
jQuery.cookie(cookiename, value, { expires : 360 });
|
99 |
+
}) ;
|
100 |
+
});
|
101 |
+
} //End if (!jQuery.cookie(cookiename))
|
102 |
+
|
103 |
+
//Else user cannot vote
|
104 |
+
else {
|
105 |
+
var cookievote=jQuery.cookie(cookiename);
|
106 |
+
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
|
107 |
+
|
108 |
+
var data = {
|
109 |
+
action: 'yasr_readonly_visitor_shortcode',
|
110 |
+
rating: cookievote,
|
111 |
+
votes: <?php echo $medium_rating ?>,
|
112 |
+
votes_number: <?php echo $votes_number ?>,
|
113 |
+
post_id: postid
|
114 |
+
}
|
115 |
+
|
116 |
+
jQuery.post(ajaxurl, data, function(response) {
|
117 |
+
jQuery('#yasr_visitor_votes').html(response);
|
118 |
+
jQuery('.rateit').rateit();
|
119 |
+
});
|
120 |
+
} //End else
|
121 |
+
|
122 |
+
});
|
123 |
+
|
124 |
+
</script>
|
125 |
|
126 |
<?php
|
127 |
+
|
128 |
+
} //End if is singular
|
129 |
+
|
130 |
+
return $shortcode_html;
|
131 |
+
|
132 |
}
|
133 |
|
134 |
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Yasr - Yet Another Stars Rating ===
|
2 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8S963KJ3UW5XG
|
3 |
-
Tags: Rating, Review, Star, Snippet
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 3.9.1
|
6 |
-
Stable tag: 0.
|
7 |
License: GPL2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -49,6 +49,25 @@ If with gd-star-rating you're using a different number of stars from the default
|
|
49 |
|
50 |
== Changelog ==
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
= 0.1.3 =
|
53 |
* Fixed some security issues. Please Update
|
54 |
|
1 |
=== Yasr - Yet Another Stars Rating ===
|
2 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8S963KJ3UW5XG
|
3 |
+
Tags: Rating, Review, Star, Snippet, Rich snippet, Schema, Schema.org, Serp
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 3.9.1
|
6 |
+
Stable tag: 0.2.4
|
7 |
License: GPL2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
49 |
|
50 |
== Changelog ==
|
51 |
|
52 |
+
= 0.2.4 =
|
53 |
+
* Now user can choose what kind of snippet use, if AggregateRating or Review
|
54 |
+
|
55 |
+
= 0.2.3 =
|
56 |
+
* [yasr_visitor_votes] it's now disabled outside a post or a page
|
57 |
+
* Security fixes on ajax functions
|
58 |
+
* Various fixes on multi-set settings
|
59 |
+
* Code cleanup
|
60 |
+
|
61 |
+
= 0.2.2 =
|
62 |
+
* Fixed doulbe ajax request on overall rating when used just 1 multiple set
|
63 |
+
* Many other minor bug fixes
|
64 |
+
|
65 |
+
= 0.2.1 =
|
66 |
+
* Fixed insert rating on multi set if only 1 is used
|
67 |
+
|
68 |
+
= 0.2.0 =
|
69 |
+
* Fixed Table installation
|
70 |
+
|
71 |
= 0.1.3 =
|
72 |
* Fixed some security issues. Please Update
|
73 |
|
yasr-metabox-multiple-rating.php
CHANGED
@@ -4,6 +4,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
4 |
|
5 |
$multi_set=yasr_get_multi_set();
|
6 |
|
|
|
|
|
7 |
global $wpdb;
|
8 |
|
9 |
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count number of rows of the last query
|
@@ -13,6 +15,7 @@ if ($n_multi_set>1) {
|
|
13 |
_e("Choose wich set you want to use");
|
14 |
|
15 |
?>
|
|
|
16 |
<br />
|
17 |
<select id ="select_set">
|
18 |
<?php foreach ($multi_set as $name) { ?>
|
@@ -21,10 +24,6 @@ if ($n_multi_set>1) {
|
|
21 |
</select>
|
22 |
|
23 |
|
24 |
-
<?php
|
25 |
-
$ajax_nonce_multi = wp_create_nonce( "yasr_nonce_insert_multi_rating" );
|
26 |
-
?>
|
27 |
-
|
28 |
<script>
|
29 |
// --------------IF multiple set are found -------------------
|
30 |
|
@@ -43,7 +42,7 @@ jQuery('#select_set').on("change", function() {
|
|
43 |
jQuery('#yasr_rateit_multi_rating').html(response);
|
44 |
jQuery('.rateit').rateit();
|
45 |
|
46 |
-
jQuery('.
|
47 |
var el = jQuery(this);
|
48 |
var value = el.rateit('value');
|
49 |
var value = value.toFixed(1);
|
@@ -64,7 +63,7 @@ jQuery('#select_set').on("change", function() {
|
|
64 |
});
|
65 |
|
66 |
|
67 |
-
jQuery('.
|
68 |
var el = jQuery(this);
|
69 |
var value = '0';
|
70 |
var idField = el.attr('id');
|
@@ -110,17 +109,17 @@ jQuery( document ).ready(function() {
|
|
110 |
set_id: <?php echo $set_id ?>,
|
111 |
post_id: postid
|
112 |
}
|
|
|
113 |
//Send value to the Server
|
114 |
jQuery.post(ajaxurl, data_id, function(response) {
|
115 |
jQuery('#yasr_rateit_multi_rating').html(response);
|
116 |
jQuery('.rateit').rateit();
|
117 |
|
118 |
-
jQuery('.
|
119 |
var el = jQuery(this);
|
120 |
var value = el.rateit('value');
|
121 |
var value = value.toFixed(1);
|
122 |
var idField = el.attr('id');
|
123 |
-
var setType = jQuery('#select_set').val();
|
124 |
|
125 |
var data = {
|
126 |
action: 'yasr_send_id_field_with_vote',
|
@@ -136,7 +135,7 @@ jQuery( document ).ready(function() {
|
|
136 |
|
137 |
});
|
138 |
|
139 |
-
jQuery('.
|
140 |
var el = jQuery(this);
|
141 |
var value = '0';
|
142 |
var idField = el.attr('id');
|
@@ -168,6 +167,8 @@ jQuery( document ).ready(function() {
|
|
168 |
|
169 |
<div>
|
170 |
<p>
|
171 |
-
<span id="yasr_rateit_multi_rating"
|
|
|
|
|
172 |
</p>
|
173 |
-
</div>
|
4 |
|
5 |
$multi_set=yasr_get_multi_set();
|
6 |
|
7 |
+
$ajax_nonce_multi = wp_create_nonce( "yasr_nonce_insert_multi_rating" );
|
8 |
+
|
9 |
global $wpdb;
|
10 |
|
11 |
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count number of rows of the last query
|
15 |
_e("Choose wich set you want to use");
|
16 |
|
17 |
?>
|
18 |
+
|
19 |
<br />
|
20 |
<select id ="select_set">
|
21 |
<?php foreach ($multi_set as $name) { ?>
|
24 |
</select>
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
27 |
<script>
|
28 |
// --------------IF multiple set are found -------------------
|
29 |
|
42 |
jQuery('#yasr_rateit_multi_rating').html(response);
|
43 |
jQuery('.rateit').rateit();
|
44 |
|
45 |
+
jQuery('.multi').on('rated', function() {
|
46 |
var el = jQuery(this);
|
47 |
var value = el.rateit('value');
|
48 |
var value = value.toFixed(1);
|
63 |
});
|
64 |
|
65 |
|
66 |
+
jQuery('.multi').on('reset', function() {
|
67 |
var el = jQuery(this);
|
68 |
var value = '0';
|
69 |
var idField = el.attr('id');
|
109 |
set_id: <?php echo $set_id ?>,
|
110 |
post_id: postid
|
111 |
}
|
112 |
+
|
113 |
//Send value to the Server
|
114 |
jQuery.post(ajaxurl, data_id, function(response) {
|
115 |
jQuery('#yasr_rateit_multi_rating').html(response);
|
116 |
jQuery('.rateit').rateit();
|
117 |
|
118 |
+
jQuery('.multi').on('rated', function() {
|
119 |
var el = jQuery(this);
|
120 |
var value = el.rateit('value');
|
121 |
var value = value.toFixed(1);
|
122 |
var idField = el.attr('id');
|
|
|
123 |
|
124 |
var data = {
|
125 |
action: 'yasr_send_id_field_with_vote',
|
135 |
|
136 |
});
|
137 |
|
138 |
+
jQuery('.multi').on('reset', function() {
|
139 |
var el = jQuery(this);
|
140 |
var value = '0';
|
141 |
var idField = el.attr('id');
|
167 |
|
168 |
<div>
|
169 |
<p>
|
170 |
+
<span id="yasr_rateit_multi_rating">
|
171 |
+
|
172 |
+
</span>
|
173 |
</p>
|
174 |
+
</div>
|
yasr-metabox-overall-rating.php
CHANGED
@@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
30 |
</div>
|
31 |
|
32 |
<?php
|
33 |
-
function yasr_overall_rating_javascript(
|
34 |
|
35 |
$ajax_nonce_overall = wp_create_nonce( "yasr_nonce_insert_overall_rating" );
|
36 |
|
30 |
</div>
|
31 |
|
32 |
<?php
|
33 |
+
function yasr_overall_rating_javascript() {
|
34 |
|
35 |
$ajax_nonce_overall = wp_create_nonce( "yasr_nonce_insert_overall_rating" );
|
36 |
|
yasr-settings-page.php
CHANGED
@@ -5,6 +5,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
|
|
5 |
if ( !current_user_can( 'manage_options' ) ) {
|
6 |
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ));
|
7 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
?>
|
9 |
|
10 |
|
@@ -44,6 +51,7 @@ if ( !current_user_can( 'manage_options' ) ) {
|
|
44 |
</div> <!--End yasr-multi-set-left-->
|
45 |
|
46 |
<div class="yasr-multi-set-right">
|
|
|
47 |
<?php yasr_edit_multi_form(); ?>
|
48 |
|
49 |
<div id="yasr-multi-set-response" style="display:none">
|
@@ -167,50 +175,90 @@ if ( !current_user_can( 'manage_options' ) ) {
|
|
167 |
jQuery('.yasr-manage-multiset').toggle();
|
168 |
});
|
169 |
|
|
|
170 |
|
171 |
-
jQuery('#yasr-manage-multi-set-single').on('click', function() {
|
172 |
-
jQuery('.yasr-manage-multiset-single').toggle();
|
173 |
-
});
|
174 |
|
|
|
175 |
|
176 |
-
|
177 |
-
jQuery('#yasr_select_edit_set').on("change", function() {
|
178 |
-
|
179 |
-
var data = {
|
180 |
-
action : 'yasr_get_multi_set',
|
181 |
-
set_id : jQuery(this).val()
|
182 |
-
}
|
183 |
-
|
184 |
-
jQuery.post(ajaxurl, data, function(response) {
|
185 |
-
jQuery('#yasr-multi-set-response').show();
|
186 |
-
jQuery('#yasr-multi-set-response').toggle;
|
187 |
-
jQuery('#yasr-multi-set-response').html(response);
|
188 |
-
});
|
189 |
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
|
216 |
//Terzo div code
|
5 |
if ( !current_user_can( 'manage_options' ) ) {
|
6 |
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ));
|
7 |
}
|
8 |
+
|
9 |
+
$multi_set=yasr_get_multi_set();
|
10 |
+
|
11 |
+
global $wpdb;
|
12 |
+
|
13 |
+
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
14 |
+
|
15 |
?>
|
16 |
|
17 |
|
51 |
</div> <!--End yasr-multi-set-left-->
|
52 |
|
53 |
<div class="yasr-multi-set-right">
|
54 |
+
|
55 |
<?php yasr_edit_multi_form(); ?>
|
56 |
|
57 |
<div id="yasr-multi-set-response" style="display:none">
|
175 |
jQuery('.yasr-manage-multiset').toggle();
|
176 |
});
|
177 |
|
178 |
+
<?php if ($n_multi_set == 1) { ?>
|
179 |
|
|
|
|
|
|
|
180 |
|
181 |
+
jQuery('#yasr-manage-multi-set-single').on('click', function() {
|
182 |
|
183 |
+
jQuery('.yasr-manage-multiset-single').toggle();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
+
var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
|
186 |
+
|
187 |
+
counter++;
|
188 |
+
|
189 |
+
jQuery("#yasr-add-field-edit-multiset").on('click', function() {
|
190 |
+
|
191 |
+
if(counter>9){
|
192 |
+
jQuery('#yasr-element-limit').show();
|
193 |
+
jQuery('#yasr-add-field-edit-multiset').hide();
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
var newTextBoxDiv = jQuery(document.createElement('tr'))
|
198 |
+
|
199 |
+
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
|
200 |
+
|
201 |
+
newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
|
202 |
+
|
203 |
+
counter++;
|
204 |
+
|
205 |
+
});
|
206 |
+
|
207 |
+
});
|
208 |
+
|
209 |
+
<?php
|
210 |
+
|
211 |
+
} //End if ($n_multi_set == 1)
|
212 |
+
|
213 |
+
if ($n_multi_set > 1) {
|
214 |
+
|
215 |
+
?>
|
216 |
+
|
217 |
+
|
218 |
+
//If more then 1 set is used...
|
219 |
+
jQuery('#yasr_select_edit_set').on("change", function() {
|
220 |
+
|
221 |
+
var data = {
|
222 |
+
action : 'yasr_get_multi_set',
|
223 |
+
set_id : jQuery(this).val()
|
224 |
+
}
|
225 |
+
|
226 |
+
jQuery.post(ajaxurl, data, function(response) {
|
227 |
+
jQuery('#yasr-multi-set-response').show();
|
228 |
+
jQuery('#yasr-multi-set-response').toggle;
|
229 |
+
jQuery('#yasr-multi-set-response').html(response);
|
230 |
+
});
|
231 |
+
|
232 |
+
});
|
233 |
|
234 |
+
|
235 |
+
jQuery(document).ajaxComplete(function(){
|
236 |
+
|
237 |
+
var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
|
238 |
+
|
239 |
+
counter++;
|
240 |
+
|
241 |
+
jQuery("#yasr-add-field-edit-multiset").on('click', function() {
|
242 |
+
|
243 |
+
if(counter>9){
|
244 |
+
jQuery('#yasr-element-limit').show();
|
245 |
+
jQuery('#yasr-add-field-edit-multiset').hide();
|
246 |
+
return false;
|
247 |
+
}
|
248 |
+
|
249 |
+
var newTextBoxDiv = jQuery(document.createElement('tr'))
|
250 |
+
|
251 |
+
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
|
252 |
+
|
253 |
+
newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
|
254 |
+
|
255 |
+
counter++;
|
256 |
+
|
257 |
+
});
|
258 |
+
|
259 |
+
});
|
260 |
+
|
261 |
+
<?php } //End if ($n_multi_set > 1) ?>
|
262 |
|
263 |
|
264 |
//Terzo div code
|
yet-another-stars-rating.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Yet Another Stars Rating
|
4 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
5 |
* Description: Rating system with rich snippets
|
6 |
-
* Version: 0.
|
7 |
* Author: Dario Curvino
|
8 |
* Author URI: http://profiles.wordpress.org/dudo/
|
9 |
* License: GPL2
|
@@ -28,9 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
28 |
*/
|
29 |
|
30 |
|
31 |
-
define('YASR_VERSION_NUM', '0.
|
32 |
-
|
33 |
-
update_option('yasr-version', YASR_VERSION_NUM);
|
34 |
|
35 |
//Plugin absolute path
|
36 |
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
|
@@ -52,8 +50,11 @@ define ("YASR_CSS_DIR", plugins_url(YASR_RELATIVE_PATH . '/css/' ));
|
|
52 |
define ("YASR_IMG_DIR", plugins_url( YASR_RELATIVE_PATH . '/img/'));
|
53 |
|
54 |
/* Include function file */
|
|
|
55 |
require (YASR_ABSOLUTE_PATH . '/lib/yasr-functions.php');
|
56 |
|
|
|
|
|
57 |
require (YASR_ABSOLUTE_PATH . '/lib/yasr-db-functions.php');
|
58 |
|
59 |
require (YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php');
|
@@ -62,14 +63,16 @@ require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
|
|
62 |
|
63 |
$version_installed = get_option('yasr-version') ;
|
64 |
|
65 |
-
//If this is a fresh new installation
|
66 |
|
67 |
-
if (!$version_installed) {
|
68 |
|
69 |
yasr_install();
|
70 |
|
71 |
}
|
72 |
|
|
|
|
|
73 |
global $wpdb;
|
74 |
|
75 |
define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
|
3 |
* Plugin Name: Yet Another Stars Rating
|
4 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
5 |
* Description: Rating system with rich snippets
|
6 |
+
* Version: 0.2.4
|
7 |
* Author: Dario Curvino
|
8 |
* Author URI: http://profiles.wordpress.org/dudo/
|
9 |
* License: GPL2
|
28 |
*/
|
29 |
|
30 |
|
31 |
+
define('YASR_VERSION_NUM', '0.2.4');
|
|
|
|
|
32 |
|
33 |
//Plugin absolute path
|
34 |
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
|
50 |
define ("YASR_IMG_DIR", plugins_url( YASR_RELATIVE_PATH . '/img/'));
|
51 |
|
52 |
/* Include function file */
|
53 |
+
|
54 |
require (YASR_ABSOLUTE_PATH . '/lib/yasr-functions.php');
|
55 |
|
56 |
+
require (YASR_ABSOLUTE_PATH . '/lib/yasr-settings-functions.php');
|
57 |
+
|
58 |
require (YASR_ABSOLUTE_PATH . '/lib/yasr-db-functions.php');
|
59 |
|
60 |
require (YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php');
|
63 |
|
64 |
$version_installed = get_option('yasr-version') ;
|
65 |
|
66 |
+
//If this is a fresh new installation or version < 0.2.0
|
67 |
|
68 |
+
if (!$version_installed || $version_installed < '0.2.0' ) {
|
69 |
|
70 |
yasr_install();
|
71 |
|
72 |
}
|
73 |
|
74 |
+
update_option('yasr-version', YASR_VERSION_NUM);
|
75 |
+
|
76 |
global $wpdb;
|
77 |
|
78 |
define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
|