Yasr – Yet Another Stars Rating - Version 1.0.5

Version Description

  • NEW FEATURE: In the Yasr code have been added a lot of hooks! This means that is much easier to develop Yasr. Further this, other developer can add their own extensions!
  • TWEAKED: Added the postid parameter on the yasr_multiset and yasr_visitor_multiset shortcodes
  • TWEAKED: Color scheme settings have been moved from "Multi Sets" tab on the "Styles" one.
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.0.5

js/yasr-admin.js CHANGED
@@ -321,7 +321,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
321
 
322
  /****** Yasr Settings Page ******/
323
 
324
- function YasrSettingsPage (activeTab, nMultiSet, autoInsertEnabled, nonceShortcodeOverall) {
325
 
326
  //-------------------General Settings Code---------------------
327
 
@@ -350,7 +350,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
350
  jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
351
  jQuery('#yasr-general-options-custom-text-before-visitor').val('Our Reader Score');
352
  jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
353
- jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted this article');
354
 
355
  });
356
 
@@ -502,12 +502,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
502
 
503
  } //End if ($n_multi_set > 1)
504
 
 
 
 
 
 
 
 
505
  jQuery('#yasr-color-scheme-preview-link').on('click', function () {
506
  jQuery('#yasr-color-scheme-preview').toggle('slow');
507
  return false; // prevent default click action from happening!
508
  });
509
 
510
- } //end if active_tab=='manage_multi'
511
 
512
 
513
  }
@@ -556,7 +563,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
556
  /****** Yasr Ajax Page ******/
557
 
558
 
559
- // When click on chart chart hide tab-main and show tab-charts
560
 
561
  function yasrShortcodeCreator(nMultiSet) {
562
 
321
 
322
  /****** Yasr Settings Page ******/
323
 
324
+ function YasrSettingsPage (activeTab, nMultiSet, autoInsertEnabled) {
325
 
326
  //-------------------General Settings Code---------------------
327
 
350
  jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
351
  jQuery('#yasr-general-options-custom-text-before-visitor').val('Our Reader Score');
352
  jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
353
+ jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article');
354
 
355
  });
356
 
502
 
503
  } //End if ($n_multi_set > 1)
504
 
505
+
506
+
507
+ } //end if active_tab=='manage_multi'
508
+
509
+
510
+ if (activeTab == 'style_options') {
511
+
512
  jQuery('#yasr-color-scheme-preview-link').on('click', function () {
513
  jQuery('#yasr-color-scheme-preview').toggle('slow');
514
  return false; // prevent default click action from happening!
515
  });
516
 
517
+ }
518
 
519
 
520
  }
563
  /****** Yasr Ajax Page ******/
564
 
565
 
566
+ // When click on chart hide tab-main and show tab-charts
567
 
568
  function yasrShortcodeCreator(nMultiSet) {
569
 
js/yasr-front.js CHANGED
@@ -117,7 +117,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
117
  //an array with all the ratingonjects
118
  var ratingArray = new Array();
119
 
120
- jQuery('.yasr-visitor-multi-'+yasrCommonData.postid+'-'+yasrMultiSetData.setType).on('rated', function() {
121
  var el = jQuery(this);
122
  var value = el.rateit('value');
123
  var value = value.toFixed(1);
@@ -135,18 +135,18 @@ document.addEventListener('DOMContentLoaded', function(event) {
135
 
136
  });
137
 
138
- jQuery('#yasr-send-visitor-multiset-'+yasrCommonData.postid+'-'+yasrMultiSetData.setType).on('click', function() {
139
 
140
- jQuery('#yasr-send-visitor-multiset-'+yasrCommonData.postid+'-'+yasrMultiSetData.setType).hide();
141
 
142
 
143
- jQuery('#yasr-loader-multiset-visitor-'+yasrCommonData.postid+'-'+yasrMultiSetData.setType).show();
144
 
145
  var data = {
146
 
147
  action: 'yasr_visitor_multiset_field_vote',
148
  nonce: yasrMultiSetData.nonce,
149
- post_id: yasrCommonData.postid,
150
  rating: ratingArray,
151
  set_type: yasrMultiSetData.setType
152
 
@@ -154,7 +154,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
154
 
155
  //Send value to the Server
156
  jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
157
- jQuery('#yasr-loader-multiset-visitor-'+yasrCommonData.postid+'-'+yasrMultiSetData.setType).text(response);
158
  });
159
 
160
  });
117
  //an array with all the ratingonjects
118
  var ratingArray = new Array();
119
 
120
+ jQuery('.yasr-visitor-multi-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).on('rated', function() {
121
  var el = jQuery(this);
122
  var value = el.rateit('value');
123
  var value = value.toFixed(1);
135
 
136
  });
137
 
138
+ jQuery('#yasr-send-visitor-multiset-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).on('click', function() {
139
 
140
+ jQuery('#yasr-send-visitor-multiset-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).hide();
141
 
142
 
143
+ jQuery('#yasr-loader-multiset-visitor-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).show();
144
 
145
  var data = {
146
 
147
  action: 'yasr_visitor_multiset_field_vote',
148
  nonce: yasrMultiSetData.nonce,
149
+ post_id: yasrMultiSetData.postid,
150
  rating: ratingArray,
151
  set_type: yasrMultiSetData.setType
152
 
154
 
155
  //Send value to the Server
156
  jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
157
+ jQuery('#yasr-loader-multiset-visitor-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).text(response);
158
  });
159
 
160
  });
lib/yasr-admin-actions.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+ //css
6
+ add_action('yasr_add_front_script_css', 'yasr_pro_front_script_css' );
7
+
8
+ function yasr_pro_front_script_css () {
9
+
10
+ //if visitors stats are enabled
11
+ if (YASR_VISITORS_STATS === 'yes') {
12
+ wp_enqueue_style( 'jquery-ui','//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css', FALSE, NULL, 'all' );
13
+ wp_enqueue_style( 'dashicons' ); //dashicons
14
+ }
15
+
16
+ }
17
+
18
+ //js
19
+ add_action('yasr_add_front_script_js', 'yasr_pro_front_script_js' );
20
+
21
+ function yasr_pro_front_script_js () {
22
+
23
+ //if visitors stats are enabled
24
+ if (YASR_VISITORS_STATS === 'yes') {
25
+ wp_enqueue_script( 'jquery-ui-progressbar' ); //script
26
+ wp_enqueue_script( 'jquery-ui-tooltip' ); //script
27
+ }
28
+
29
+ }
30
+
31
+ //add tab on settings page
32
+ add_action( 'yasr_add_settings_tab', 'yasr_free_settings_tab');
33
+
34
+ function yasr_free_settings_tab ($active_tab) {
35
+
36
+ ?>
37
+
38
+ <a href="?page=yasr_settings_page&tab=go_pro" class="nav-tab <?php if ($active_tab == 'go_pro') echo 'nav-tab-active'; ?>" > <?php _e("Pro Features!", 'yet-another-stars-rating'); ?> </a>
39
+
40
+ <?php
41
+ }
42
+
43
+
44
+ //content of the tab above
45
+ add_action( 'yasr_settings_check_active_tab', 'yasr_free_check_active_tab' );
46
+
47
+ function yasr_free_check_active_tab ($active_tab) {
48
+
49
+ if ($active_tab == 'go_pro') {
50
+
51
+ yasr_go_pro();
52
+
53
+ yasr_fb_box ();
54
+
55
+ yasr_ask_rating ();
56
+
57
+ }
58
+
59
+ }
60
+
61
+ ?>
lib/yasr-ajax-functions.php CHANGED
@@ -131,6 +131,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
131
  exit();
132
  }
133
 
 
 
 
 
134
  if ($reviewtype === "1") {
135
 
136
  $reviewtype = 'Product';
@@ -474,6 +478,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
474
  <h2 class="nav-tab-wrapper yasr-underline">
475
  <a href="#" id="yasr-link-tab-main" class="nav-tab nav-tab-active"><?php _e("Main", 'yet-another-stars-rating'); ?></a>
476
  <a href="#" id="yasr-link-tab-charts" class="nav-tab"><?php _e("Charts" , 'yet-another-stars-rating'); ?></a>
 
477
 
478
  <a href="https://yetanotherstarsrating.com/f-a-q/" target="_blank" id="yasr-tinypopup-link-doc"><?php _e("Read the doc", 'yet-another-stars-rating'); ?></a>
479
 
@@ -590,6 +595,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
590
 
591
  </div>
592
 
 
 
593
  </div>
594
 
595
  <script type="text/javascript">
@@ -772,6 +779,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
772
 
773
  function yasr_change_log_page_callback () {
774
 
 
 
 
 
775
  if (isset($_POST['pagenum'])) {
776
 
777
  $page_num = $_POST['pagenum'];
@@ -782,10 +793,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
782
  $page_num = 1;
783
  }
784
 
785
- if ( ! current_user_can( 'manage_options' ) ) {
786
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
787
- }
788
-
789
  $limit = 8; //max number of row to echo
790
 
791
  $offset = ( $page_num - 1 ) * $limit;
@@ -934,6 +941,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
934
 
935
  function yasr_hide_ask_rating_metabox () {
936
 
 
 
 
 
937
  if (isset($_POST['nonce']) && isset($_POST['choose']) ) {
938
 
939
  $choose = $_POST['choose'];
131
  exit();
132
  }
133
 
134
+ if ( ! current_user_can( 'publish_posts' ) ) {
135
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
136
+ }
137
+
138
  if ($reviewtype === "1") {
139
 
140
  $reviewtype = 'Product';
478
  <h2 class="nav-tab-wrapper yasr-underline">
479
  <a href="#" id="yasr-link-tab-main" class="nav-tab nav-tab-active"><?php _e("Main", 'yet-another-stars-rating'); ?></a>
480
  <a href="#" id="yasr-link-tab-charts" class="nav-tab"><?php _e("Charts" , 'yet-another-stars-rating'); ?></a>
481
+ <?php do_action( 'yasr_add_tabs_on_tinypopupform'); ?>
482
 
483
  <a href="https://yetanotherstarsrating.com/f-a-q/" target="_blank" id="yasr-tinypopup-link-doc"><?php _e("Read the doc", 'yet-another-stars-rating'); ?></a>
484
 
595
 
596
  </div>
597
 
598
+ <?php do_action( 'yasr_add_content_on_tinypopupform'); ?>
599
+
600
  </div>
601
 
602
  <script type="text/javascript">
779
 
780
  function yasr_change_log_page_callback () {
781
 
782
+ if ( ! current_user_can( 'manage_options' ) ) {
783
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
784
+ }
785
+
786
  if (isset($_POST['pagenum'])) {
787
 
788
  $page_num = $_POST['pagenum'];
793
  $page_num = 1;
794
  }
795
 
 
 
 
 
796
  $limit = 8; //max number of row to echo
797
 
798
  $offset = ( $page_num - 1 ) * $limit;
941
 
942
  function yasr_hide_ask_rating_metabox () {
943
 
944
+ if ( ! current_user_can( 'manage_options' ) ) {
945
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
946
+ }
947
+
948
  if (isset($_POST['nonce']) && isset($_POST['choose']) ) {
949
 
950
  $choose = $_POST['choose'];
lib/yasr-db-functions.php CHANGED
@@ -82,6 +82,7 @@ function yasr_install() {
82
  PRIMARY KEY (id),
83
  UNIQUE KEY id (id)
84
  );";
 
85
 
86
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
87
 
@@ -116,12 +117,15 @@ function yasr_install() {
116
 
117
  add_option("yasr_general_options", $option); //Write here the default value if there is not option
118
 
119
- //Multi set options
120
- $multiset_options = array();
121
- $multiset_option['scheme_color'] = 'light';
 
 
122
 
123
- update_option("yasr_multiset_options", $multiset_option);
124
 
 
 
125
 
126
  }
127
 
82
  PRIMARY KEY (id),
83
  UNIQUE KEY id (id)
84
  );";
85
+
86
 
87
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
88
 
117
 
118
  add_option("yasr_general_options", $option); //Write here the default value if there is not option
119
 
120
+ //Style set options
121
+ $style_options = array();
122
+ $style_options['scheme_color_multiset'] = 'light';
123
+
124
+ update_option("yasr_style_options", $style_options);
125
 
 
126
 
127
+ do_action( 'yasr_scripts_on_install');
128
+
129
 
130
  }
131
 
lib/yasr-functions.php CHANGED
@@ -28,11 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
28
 
29
  function yasr_add_scripts () {
30
 
31
- //if visitors stats are enabled
32
- if (YASR_VISITORS_STATS === 'yes') {
33
- wp_enqueue_style( 'jquery-ui','//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css', FALSE, NULL, 'all' );
34
- wp_enqueue_style( 'dashicons' ); //dashicons
35
- }
36
 
37
 
38
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', FALSE, NULL, 'all' );
@@ -50,15 +46,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
50
  wp_add_inline_style( 'yasrcss', YASR_CUSTOM_CSS_RULES );
51
  }
52
 
 
53
 
54
  wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.22', TRUE );
55
 
56
- //if visitors stats are enabled
57
- if (YASR_VISITORS_STATS === 'yes') {
58
- wp_enqueue_script( 'jquery-ui-progressbar' ); //script
59
- wp_enqueue_script( 'jquery-ui-tooltip' ); //script
60
- }
61
-
62
  wp_enqueue_script( 'yasrfront', YASR_JS_DIR . 'yasr-front.js' , array('jquery', 'rateit'), '1.0.0', TRUE );
63
 
64
  $yasr_visitor_votes_loader = '<div id="loader-visitor-rating" >&nbsp; ' . __("Loading, please wait",'yet-another-stars-rating') . ' <img src=' . YASR_IMG_DIR . '/loader.gif title="yasr-loader" alt="yasr-loader"></div>';
@@ -83,6 +74,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
83
 
84
  function yasr_add_admin_scripts () {
85
 
 
 
86
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr-admin.css', FALSE, NULL, 'all' );
87
  wp_enqueue_style( 'wp-jquery-ui-dialog' ); //style
88
 
28
 
29
  function yasr_add_scripts () {
30
 
31
+ do_action( 'yasr_add_front_script_css' );
 
 
 
 
32
 
33
 
34
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', FALSE, NULL, 'all' );
46
  wp_add_inline_style( 'yasrcss', YASR_CUSTOM_CSS_RULES );
47
  }
48
 
49
+ do_action('yasr_add_front_script_js');
50
 
51
  wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.22', TRUE );
52
 
 
 
 
 
 
 
53
  wp_enqueue_script( 'yasrfront', YASR_JS_DIR . 'yasr-front.js' , array('jquery', 'rateit'), '1.0.0', TRUE );
54
 
55
  $yasr_visitor_votes_loader = '<div id="loader-visitor-rating" >&nbsp; ' . __("Loading, please wait",'yet-another-stars-rating') . ' <img src=' . YASR_IMG_DIR . '/loader.gif title="yasr-loader" alt="yasr-loader"></div>';
74
 
75
  function yasr_add_admin_scripts () {
76
 
77
+ do_action('yasr_add_admin_scripts_begin');
78
+
79
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr-admin.css', FALSE, NULL, 'all' );
80
  wp_enqueue_style( 'wp-jquery-ui-dialog' ); //style
81
 
lib/yasr-settings-functions.php CHANGED
@@ -537,7 +537,6 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
537
  $option_multiset = get_option( 'yasr_multiset_options' );
538
 
539
  add_settings_section( 'yasr_multiset_options_section_id', '', 'yasr_multiset_section_callback', 'yasr_multiset_tab' );
540
- add_settings_field( 'yasr_color_scheme', __('Which color scheme do you want to use?', 'yet-another-stars-rating') , 'yasr_color_scheme_callback', 'yasr_multiset_tab', 'yasr_multiset_options_section_id', $option_multiset);
541
 
542
  }
543
 
@@ -547,49 +546,10 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
547
 
548
  }
549
 
550
- function yasr_color_scheme_callback($option_multiset) {
551
-
552
- if (!$option_multiset['scheme_color']) {
553
-
554
- $option_multiset['scheme_color'] = 'light';
555
-
556
- }
557
-
558
- ?>
559
-
560
- <input type='radio' name='yasr_multiset_options[scheme_color]' value='light' class='yasr-general-options-scheme-color' <?php if ($option_multiset['scheme_color']==='light') echo " checked=\"checked\" "; ?> />
561
- <?php _e('Light', 'yet-another-stars-rating')?>
562
-
563
- &nbsp;&nbsp;&nbsp;
564
-
565
- <input type='radio' name='yasr_multiset_options[scheme_color]' value='dark' class='yasr-general-options-scheme-color' <?php if ($option_multiset['scheme_color']==='dark') echo " checked=\"checked\" "; ?> />
566
- <?php _e('Dark', 'yet-another-stars-rating')?>
567
- <br />
568
-
569
- <br />
570
-
571
- <a href="#" id="yasr-color-scheme-preview-link"><?php _e("Preview", 'yet-another-stars-rating') ?></a>
572
-
573
- <div id="yasr-color-scheme-preview" style="display:none">
574
- <?php
575
-
576
- _e("Light theme", 'yet-another-stars-rating');
577
- echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr-multi-set.png>";
578
-
579
- echo "<br /> <br />";
580
-
581
- _e("Dark theme", 'yet-another-stars-rating');
582
- echo "<br /><br /><img src=" . YASR_IMG_DIR . "dark-multi-set.png>";
583
- ?>
584
- </div>
585
-
586
- <p>
587
-
588
- <?php
589
- }
590
 
591
 
592
- /****** Create a form for settings page to create new multi set ******/
593
  function yasr_display_multi_set_form() {
594
  ?>
595
 
@@ -768,7 +728,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
768
 
769
 
770
 
771
- /****** Get and output multiple set in a form and table, used in settings page ******/
772
 
773
  add_action( 'wp_ajax_yasr_get_multi_set', 'yasr_get_multi_set_callback' );
774
 
@@ -882,7 +842,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
882
 
883
 
884
 
885
- /****** Validate new multi set form ******/
886
  function yasr_process_new_multi_set_form() {
887
 
888
  if ( isset( $_POST['multi-set-name'])) {
@@ -1334,26 +1294,67 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1334
 
1335
  $style_options = get_option( 'yasr_style_options' );
1336
 
1337
- if (!$style_options) {
1338
 
1339
  $style_options = array();
 
1340
  $style_options['textarea'] = NULL;
1341
 
1342
  }
1343
 
1344
  add_settings_section( 'yasr_style_options_section_id', __('Style Options', 'yet-another-stars-rating'), 'yasr_style_section_callback', 'yasr_style_tab' );
 
1345
  add_settings_field( 'yasr_style_options_textarea', __('Custom CSS Styles', 'yet-another-stars-rating'), 'yasr_style_options_textarea_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
1346
 
1347
  }
1348
 
1349
  function yasr_style_section_callback () {
1350
- _e("Please use text area below to write your own CSS styles to override the default ones.", 'yet-another-stars-rating');
1351
- echo "<strong>";
1352
- _e("Leave it blank if you don't know what you're doing", 'yet-another-stars-rating');
1353
- echo "</strong>";
1354
  }
1355
 
1356
- function yasr_style_options_textarea_callback ($style_options) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1357
 
1358
  echo ("
1359
  <textarea rows=\"20\" cols=\"50\" name=\"yasr_style_options[textarea]\" id=\"yasr_style_options_textarea\">$style_options[textarea]</textarea>
@@ -1361,7 +1362,7 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1361
 
1362
  }
1363
 
1364
-
1365
  function yasr_style_options_sanitize ($style_options) {
1366
 
1367
  foreach ($style_options as $key => $value) {
537
  $option_multiset = get_option( 'yasr_multiset_options' );
538
 
539
  add_settings_section( 'yasr_multiset_options_section_id', '', 'yasr_multiset_section_callback', 'yasr_multiset_tab' );
 
540
 
541
  }
542
 
546
 
547
  }
548
 
549
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
550
 
551
 
552
+ /****** Create a form for settings page to create new multi set ******/
553
  function yasr_display_multi_set_form() {
554
  ?>
555
 
728
 
729
 
730
 
731
+ /****** Get and output multiple set in a form and table, used in settings page ******/
732
 
733
  add_action( 'wp_ajax_yasr_get_multi_set', 'yasr_get_multi_set_callback' );
734
 
842
 
843
 
844
 
845
+ /****** Validate new multi set form ******/
846
  function yasr_process_new_multi_set_form() {
847
 
848
  if ( isset( $_POST['multi-set-name'])) {
1294
 
1295
  $style_options = get_option( 'yasr_style_options' );
1296
 
1297
+ if (!$style_options || !isset($style_options['scheme_color_multiset']) || !isset($style_options['textarea'])) {
1298
 
1299
  $style_options = array();
1300
+ $style_options['scheme_color_multiset'] = 'light';
1301
  $style_options['textarea'] = NULL;
1302
 
1303
  }
1304
 
1305
  add_settings_section( 'yasr_style_options_section_id', __('Style Options', 'yet-another-stars-rating'), 'yasr_style_section_callback', 'yasr_style_tab' );
1306
+ add_settings_field( 'yasr_color_scheme_multiset', __('Which color scheme do you want to use?', 'yet-another-stars-rating') , 'yasr_color_scheme_multiset_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options);
1307
  add_settings_field( 'yasr_style_options_textarea', __('Custom CSS Styles', 'yet-another-stars-rating'), 'yasr_style_options_textarea_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
1308
 
1309
  }
1310
 
1311
  function yasr_style_section_callback () {
1312
+
 
 
 
1313
  }
1314
 
1315
+
1316
+
1317
+ function yasr_color_scheme_multiset_callback($style_options) {
1318
+
1319
+ ?>
1320
+
1321
+ <input type='radio' name='yasr_style_options[scheme_color_multiset]' value='light' class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset']==='light') echo " checked=\"checked\" "; ?> />
1322
+ <?php _e('Light', 'yet-another-stars-rating')?>
1323
+
1324
+ &nbsp;&nbsp;&nbsp;
1325
+
1326
+ <input type='radio' name='yasr_style_options[scheme_color_multiset]' value='dark' class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset']==='dark') echo " checked=\"checked\" "; ?> />
1327
+ <?php _e('Dark', 'yet-another-stars-rating')?>
1328
+ <br />
1329
+
1330
+ <br />
1331
+
1332
+ <a href="#" id="yasr-color-scheme-preview-link"><?php _e("Preview", 'yet-another-stars-rating') ?></a>
1333
+
1334
+ <div id="yasr-color-scheme-preview" style="display:none">
1335
+ <?php
1336
+
1337
+ _e("Light theme", 'yet-another-stars-rating');
1338
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr-multi-set.png>";
1339
+
1340
+ echo "<br /> <br />";
1341
+
1342
+ _e("Dark theme", 'yet-another-stars-rating');
1343
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "dark-multi-set.png>";
1344
+ ?>
1345
+ </div>
1346
+
1347
+ <p>
1348
+
1349
+ <?php
1350
+ }
1351
+
1352
+ function yasr_style_options_textarea_callback ($style_options) {
1353
+
1354
+ _e("Please use text area below to write your own CSS styles to override the default ones.", 'yet-another-stars-rating');
1355
+ echo "<strong> &nbsp;";
1356
+ _e("Leave it blank if you don't know what you're doing.", 'yet-another-stars-rating');
1357
+ echo "</strong><p>";
1358
 
1359
  echo ("
1360
  <textarea rows=\"20\" cols=\"50\" name=\"yasr_style_options[textarea]\" id=\"yasr_style_options_textarea\">$style_options[textarea]</textarea>
1362
 
1363
  }
1364
 
1365
+ //sanitize
1366
  function yasr_style_options_sanitize ($style_options) {
1367
 
1368
  foreach ($style_options as $key => $value) {
lib/yasr-shortcode-functions.php CHANGED
@@ -255,7 +255,7 @@ function shortcode_visitor_votes_callback ($atts) {
255
 
256
  $readonly = 'true'; //readonly is true if user isn't logged
257
 
258
- $span_after_rate_it = __("You must sign to vote", 'yet-another-stars-rating');
259
 
260
  }
261
 
@@ -429,17 +429,29 @@ add_shortcode ('yasr_multiset', 'shortcode_multi_set_callback');
429
 
430
  function shortcode_multi_set_callback( $atts ) {
431
 
432
- $post_id=get_the_id();
433
-
434
  global $wpdb;
435
 
436
  // Attributes
437
  extract( shortcode_atts(
438
  array(
439
- 'setid' => '1',
 
440
  ), $atts )
441
  );
442
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  $shortcode_html = ""; //Avoid undefined variable if used a missing setid
444
 
445
  $set_name_content=yasr_get_multi_set_values_and_field ($post_id, $setid);
@@ -481,8 +493,6 @@ add_shortcode ('yasr_visitor_multiset', 'yasr_visitor_multiset_callback');
481
 
482
  function yasr_visitor_multiset_callback ( $atts ) {
483
 
484
- $post_id=get_the_id();
485
-
486
  $ajax_nonce_visitor_multiset = wp_create_nonce( "yasr_nonce_insert_visitor_rating_multiset" );
487
 
488
  global $wpdb;
@@ -491,9 +501,23 @@ function yasr_visitor_multiset_callback ( $atts ) {
491
  extract( shortcode_atts(
492
  array(
493
  'setid' => '0',
 
494
  ), $atts )
495
  );
496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  $cookiename = 'yasr_multi_visitor_cookie_' . $post_id . '_' . $setid;
498
 
499
  $image = YASR_IMG_DIR . "/loader.gif";
@@ -526,7 +550,7 @@ function yasr_visitor_multiset_callback ( $atts ) {
526
 
527
  $button = "<input type=\"submit\" name=\"submit\" id=\"yasr-send-visitor-multiset-$post_id-$setid\" class=\"button button-primary\" value=\"". __('Submit!', 'yet-another-stars-rating') . " \" />";
528
  $star_readonly = 'true';
529
- $span_message_content = __("You must sign to vote", 'yet-another-stars-rating');;
530
 
531
  }
532
 
@@ -657,7 +681,8 @@ function yasr_visitor_multiset_callback ( $atts ) {
657
 
658
  wp_localize_script( 'yasrfront', 'yasrMultiSetData', array(
659
  'setType' => $setid,
660
- 'nonce' => $ajax_nonce_visitor_multiset
 
661
  )
662
  );
663
 
255
 
256
  $readonly = 'true'; //readonly is true if user isn't logged
257
 
258
+ $span_after_rate_it = __("You must sign in to vote", 'yet-another-stars-rating');
259
 
260
  }
261
 
429
 
430
  function shortcode_multi_set_callback( $atts ) {
431
 
 
 
432
  global $wpdb;
433
 
434
  // Attributes
435
  extract( shortcode_atts(
436
  array(
437
+ 'setid' => '0',
438
+ 'postid' => FALSE
439
  ), $atts )
440
  );
441
 
442
+ //If it's not specified use get_the_id
443
+ if (!$postid) {
444
+
445
+ $post_id = get_the_ID();
446
+
447
+ }
448
+
449
+ else {
450
+
451
+ $post_id = $postid;
452
+
453
+ }
454
+
455
  $shortcode_html = ""; //Avoid undefined variable if used a missing setid
456
 
457
  $set_name_content=yasr_get_multi_set_values_and_field ($post_id, $setid);
493
 
494
  function yasr_visitor_multiset_callback ( $atts ) {
495
 
 
 
496
  $ajax_nonce_visitor_multiset = wp_create_nonce( "yasr_nonce_insert_visitor_rating_multiset" );
497
 
498
  global $wpdb;
501
  extract( shortcode_atts(
502
  array(
503
  'setid' => '0',
504
+ 'postid' => FALSE
505
  ), $atts )
506
  );
507
 
508
+ //If it's not specified use get_the_id
509
+ if (!$postid) {
510
+
511
+ $post_id = get_the_ID();
512
+
513
+ }
514
+
515
+ else {
516
+
517
+ $post_id = $postid;
518
+
519
+ }
520
+
521
  $cookiename = 'yasr_multi_visitor_cookie_' . $post_id . '_' . $setid;
522
 
523
  $image = YASR_IMG_DIR . "/loader.gif";
550
 
551
  $button = "<input type=\"submit\" name=\"submit\" id=\"yasr-send-visitor-multiset-$post_id-$setid\" class=\"button button-primary\" value=\"". __('Submit!', 'yet-another-stars-rating') . " \" />";
552
  $star_readonly = 'true';
553
+ $span_message_content = __("You must sign in to vote", 'yet-another-stars-rating');;
554
 
555
  }
556
 
681
 
682
  wp_localize_script( 'yasrfront', 'yasrMultiSetData', array(
683
  'setType' => $setid,
684
+ 'nonce' => $ajax_nonce_visitor_multiset,
685
+ 'postid' => $post_id
686
  )
687
  );
688
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
  Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post rating, posts, rate, rating, rating platform, rating system, ratings, review, reviews, rich snippets, seo, star, star rating, stars, vote, Votes, voting, voting contest, schema, serp
4
  Requires at least: 3.5
5
  Contributors: Dudo
6
- Tested up to: 4.3.1
7
- Stable tag: 1.0.4
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
@@ -121,6 +121,11 @@ Of course not: you can easily add it on the visual editor just by clicking on th
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
124
  = 1.0.4 =
125
  * FIXED: yasr_visitor_votes didn't work if used the postid attribute
126
  * Code cleanup
3
  Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post rating, posts, rate, rating, rating platform, rating system, ratings, review, reviews, rich snippets, seo, star, star rating, stars, vote, Votes, voting, voting contest, schema, serp
4
  Requires at least: 3.5
5
  Contributors: Dudo
6
+ Tested up to: 4.4
7
+ Stable tag: 1.0.5
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
121
 
122
  == Changelog ==
123
 
124
+ = 1.0.5 =
125
+ * NEW FEATURE: In the Yasr code have been added a lot of hooks! This means that is much easier to develop Yasr. Further this, other developer can add their own extensions!
126
+ * TWEAKED: Added the postid parameter on the yasr_multiset and yasr_visitor_multiset shortcodes
127
+ * TWEAKED: Color scheme settings have been moved from "Multi Sets" tab on the "Styles" one.
128
+
129
  = 1.0.4 =
130
  * FIXED: yasr_visitor_votes didn't work if used the postid attribute
131
  * Code cleanup
yasr-metabox-top-right.php CHANGED
@@ -205,6 +205,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
205
 
206
  </div>
207
 
 
 
 
 
 
 
208
  </div>
209
 
210
  <script type="text/javascript">
205
 
206
  </div>
207
 
208
+ <?php
209
+
210
+ do_action( 'yasr_add_content_bottom_topright_metabox', $post_id );
211
+
212
+ ?>
213
+
214
  </div>
215
 
216
  <script type="text/javascript">
yasr-settings-page.php CHANGED
@@ -24,12 +24,13 @@ if ( !current_user_can( 'manage_options' ) ) {
24
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ));
25
  }
26
 
27
- $n_multi_set = NULL; //Evoid undefined variable when printed outside multiset tab
28
-
29
  $ajax_nonce_hide_ask_rating = wp_create_nonce( "yasr_nonce_hide_ask_rating" );
30
 
31
  yasr_include_fb_sdk ();
32
 
 
 
 
33
  ?>
34
 
35
  <div class="wrap">
@@ -77,256 +78,246 @@ yasr_include_fb_sdk ();
77
  ?>
78
 
79
  <h2 class="nav-tab-wrapper yasr-no-underline">
80
- <a href="?page=yasr_settings_page&tab=general_settings" class="nav-tab <?php if ($active_tab == 'general_settings' || ($active_tab != 'manage_multi' && $active_tab != 'style_options' && $active_tab != 'go_pro')) echo 'nav-tab-active'; ?>" > <?php _e("General Settings", 'yet-another-stars-rating'); ?> </a>
 
81
  <a href="?page=yasr_settings_page&tab=manage_multi" class="nav-tab <?php if ($active_tab == 'manage_multi') echo 'nav-tab-active'; ?>" > <?php _e("Multi Sets", 'yet-another-stars-rating'); ?> </a>
82
  <a href="?page=yasr_settings_page&tab=style_options" class="nav-tab <?php if ($active_tab == 'style_options') echo 'nav-tab-active'; ?>" > <?php _e("Styles", 'yet-another-stars-rating'); ?> </a>
83
- <a href="?page=yasr_settings_page&tab=go_pro" class="nav-tab <?php if ($active_tab == 'go_pro') echo 'nav-tab-active'; ?>" > <?php _e("Pro Features!", 'yet-another-stars-rating'); ?> </a>
84
 
85
  </h2>
86
 
87
 
88
 
89
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
- if ($active_tab == 'general_settings' || $active_tab != 'manage_multi' && $active_tab != 'style_options' && $active_tab != 'go_pro') {
92
 
93
- ?>
 
94
 
95
- <div class="yasr-settingsdiv">
96
- <form action="options.php" method="post" id="yasr_settings_form">
97
- <?php
98
- settings_fields( 'yasr_general_options_group' );
99
- do_settings_sections('yasr_general_settings_tab' );
100
- submit_button( __('Save') );
101
- ?>
102
- </form>
103
- </div>
104
 
105
- <?php
106
 
107
- yasr_fb_box ();
108
- yasr_ask_rating ();
109
 
110
- ?>
 
 
 
 
 
 
 
111
 
112
- <div class="yasr-space-settings-div">
113
- </div>
 
 
 
 
114
 
115
- <?php
 
 
116
 
117
- $gd_star_rating_found = yasr_search_gd_star_rating();
 
 
 
 
 
 
118
 
119
- $gd_star_imported = get_option('yasr-gdstar-imported');
120
 
121
- //If gdstar rating has been found but data haven't been imported yet
122
- if ($gd_star_rating_found && !$gd_star_imported) {
123
- ?>
124
- <div class="yasr-settingsdiv">
125
- <h3><?php _e("Import Gd Star Rating", 'yet-another-stars-rating'); ?></h3>
126
- <?php _e("I've found a previous installation of Gd Star Rating.", 'yet-another-stars-rating'); ?> <br /><?php _e("Do you want proceed to import data?", 'yet-another-stars-rating'); ?>
127
- <br />
128
- <button href="#" class="button-delete" id="import-gdstar"><?php _e('Yes, Begin Import', 'yet-another-stars-rating'); ?></button>
129
 
130
- <div id="yasr-import-gdstar-div" style="display:none;">
 
 
 
 
 
 
 
 
 
 
131
  <strong>
132
- <?php _e("Click on Proceed to import Gd Star Rating data."); ?>
133
  </strong>
134
  <br />
135
  <button href="#" class="button-primary" id="import-button"> <?php _e('Proceed', 'yet-another-stars-rating'); ?></button>
136
 
137
  <span id="yasr-loader-importer" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "loader.gif" ?>">
138
  </span>
 
139
  <br />
140
 
141
  <div id="result-import">
142
  </div>
143
- </div>
144
- </div>
145
-
146
- <div class="yasr-space-settings-div">
147
- </div>
148
-
149
- <?php
150
 
151
- } //End If $gd_star_rating_found && !$gd_star_imported
 
152
 
153
- else if ($gd_star_rating_found && $gd_star_imported==1) {
154
- ?>
155
 
156
- <div class="yasr-settingsdiv">
157
- <h3><?php _e("Manage GD Star Data", 'yet-another-stars-rating'); ?></h3>
158
- <?php _e("Gd Star Rating has been already imported.", 'yet-another-stars-rating'); ?> <br />
159
- <?php _e("If you wish you can import it again, but", 'yet-another-stars-rating'); ?><strong> <?php _e("you will lose all data you've collect since the import!", 'yet-another-stars-rating'); ?> </strong>
160
- <br />
161
- <button href="#" class="button-delete" id="import-gdstar"><?php _e('Ok, Import Again'); ?></button>
162
 
163
- <div id="yasr-import-gdstar-div" style="display:none;">
164
- <strong>
165
- <?php _e("Click on Proceed to import again Gd Star Rating data. This may take a while!"); ?>
166
- </strong>
167
- <br />
168
- <button href="#" class="button-primary" id="import-button"> <?php _e('Proceed', 'yet-another-stars-rating'); ?></button>
169
 
170
- <span id="yasr-loader-importer" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "loader.gif" ?>">
171
- </span>
172
-
173
- <br />
174
 
175
- <div id="result-import">
176
- </div>
177
 
178
- </div>
179
- </div>
180
 
181
- <div class="yasr-space-settings-div">
182
- </div>
183
 
184
- <?php
185
- } //$gd_star_rating_found && $gd_star_imported==1$gd_star_rating_found = yasr_search_gd_star_rating();
186
 
187
- } //End if tab 'general_settings'
188
 
 
 
 
189
 
190
- if ($active_tab == 'manage_multi') {
191
 
192
- $multi_set=yasr_get_multi_set();
193
 
194
- global $wpdb;
195
 
196
- $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
 
197
 
198
- ?>
199
 
200
- <div class="yasr-settingsdiv">
201
-
202
- <h3> <?php _e("Manage Multi Set", 'yet-another-stars-rating'); ?></h3>
203
 
204
- <p>
205
 
206
- <a href="#" id="yasr-multi-set-doc-link"><?php _e("What is a Multi Set?", 'yet-another-stars-rating') ?></a>
207
 
208
- </p>
209
 
210
- <div id="yasr-multi-set-doc-box" style="display:none">
211
- <?php _e("Multi Set allows you to insert a rate for each aspect about the product / local business / whetever you're reviewing, example in the image below.", 'yet-another-stars-rating');
212
 
213
- echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr-multi-set.png> <br /> <br />";
214
 
215
- _e("You can create up to 99 different Multi Set and each one can contain up to 9 different fields. Once you've saved it, you can insert the rates while typing your article in the box below the editor, as you can see in this image (click to see it larger)", 'yet-another-stars-rating');
216
 
217
- 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 />";
218
 
219
- _e("In order to insert your Multi Sets into a post or page, you can either past the short code that will appear at the bottom of the box or just click on the star in the graphic editor and select \"Insert Multi Set\".", 'yet-another-stars-rating');
220
 
221
- ?>
222
 
223
- <br /> <br />
224
 
225
- <a href="#" id="yasr-multi-set-doc-link-hide"><?php _e("Close this message", 'yet-another-stars-rating') ?></a>
226
 
227
- </div>
228
 
229
- <div class="yasr-multi-set-left">
230
 
231
- <div class="yasr-new-multi-set" >
232
 
233
- <?php yasr_display_multi_set_form(); ?>
234
 
235
- </div> <!--yasr-new-multi-set-->
236
 
237
- </div> <!--End yasr-multi-set-left-->
 
238
 
239
- <div class="yasr-multi-set-right">
240
 
241
- <?php yasr_edit_multi_form(); ?>
242
 
243
- <div id="yasr-multi-set-response" style="display:none">
 
 
 
 
 
 
 
244
 
245
  </div>
246
 
247
- </div> <!--End yasr-multi-set-right-->
248
 
249
- <div class="yasr-space-settings-div">
250
  </div>
251
 
 
 
 
 
252
 
253
- <div class="yasr-multi-set-choose-theme">
254
-
255
- <!--This allow to choose color for multiset-->
256
- <form action="options.php" method="post" id="yasr_multiset_form">
257
- <?php
258
- settings_fields( 'yasr_multiset_options_group' );
259
- do_settings_sections('yasr_multiset_tab' );
260
- submit_button( __('Save') );
261
- ?>
262
- </form>
263
-
264
  </div>
265
 
 
266
 
267
- </div>
268
-
269
- <?php
270
- yasr_fb_box ();
271
- yasr_ask_rating ();
272
- ?>
273
-
274
- <div class="yasr-space-settings-div">
275
- </div>
276
-
277
- <?php
278
-
279
- } //End if ($active_tab=='manage_multi')
280
-
281
-
282
- if ($active_tab == 'style_options') {
283
-
284
- ?>
285
-
286
- <div class="yasr-settingsdiv">
287
- <form action="options.php" method="post" id="yasr_settings_form">
288
- <?php
289
- settings_fields( 'yasr_style_options_group' );
290
- do_settings_sections('yasr_style_tab' );
291
- submit_button( __('Save') );
292
- ?>
293
- </form>
294
- </div>
295
-
296
- <?php
297
- yasr_fb_box ();
298
- yasr_ask_rating ();
299
- ?>
300
-
301
- <div class="yasr-space-settings-div">
302
- </div>
303
-
304
 
305
- <?php
306
 
307
- } //End tab style
308
 
 
309
 
310
- if ($active_tab == 'go_pro') {
 
 
 
 
 
 
 
 
311
 
312
- yasr_go_pro();
 
 
 
313
 
314
- yasr_fb_box ();
 
315
 
316
- yasr_ask_rating ();
317
 
 
318
 
319
- }
320
 
321
- ?>
322
 
323
- <?php
324
 
325
- yasr_fb_box("bottom");
326
 
327
- yasr_ask_rating("bottom");
328
 
329
- ?>
 
 
 
330
 
331
  <!--End div wrap-->
332
  </div>
@@ -342,8 +333,12 @@ yasr_include_fb_sdk ();
342
 
343
  var autoInsertEnabled = <?php echo (json_encode(YASR_AUTO_INSERT_ENABLED)); ?>;
344
 
 
 
345
  YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled);
346
 
 
 
347
  }); //End jquery document ready
348
 
349
  </script>
24
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ));
25
  }
26
 
 
 
27
  $ajax_nonce_hide_ask_rating = wp_create_nonce( "yasr_nonce_hide_ask_rating" );
28
 
29
  yasr_include_fb_sdk ();
30
 
31
+ $n_multi_set = NULL; //Evoid undefined variable when printed outside multiset tab
32
+
33
+
34
  ?>
35
 
36
  <div class="wrap">
78
  ?>
79
 
80
  <h2 class="nav-tab-wrapper yasr-no-underline">
81
+
82
+ <a href="?page=yasr_settings_page&tab=general_settings" class="nav-tab <?php if ($active_tab == 'general_settings' || ($active_tab != 'manage_multi' && $active_tab != 'style_options' && $active_tab != 'go_pro' && $active_tab != 'pro_general_options' && $active_tab != 'charts_options' && $active_tab != 'activate_license')) echo 'nav-tab-active'; ?>" > <?php _e("General Settings", 'yet-another-stars-rating'); ?> </a>
83
  <a href="?page=yasr_settings_page&tab=manage_multi" class="nav-tab <?php if ($active_tab == 'manage_multi') echo 'nav-tab-active'; ?>" > <?php _e("Multi Sets", 'yet-another-stars-rating'); ?> </a>
84
  <a href="?page=yasr_settings_page&tab=style_options" class="nav-tab <?php if ($active_tab == 'style_options') echo 'nav-tab-active'; ?>" > <?php _e("Styles", 'yet-another-stars-rating'); ?> </a>
85
+ <?php do_action( 'yasr_add_settings_tab', $active_tab ); ?>
86
 
87
  </h2>
88
 
89
 
90
 
91
+ <?php
92
+
93
+ if ($active_tab == 'general_settings' || ($active_tab != 'manage_multi' && $active_tab != 'style_options' && $active_tab != 'pro_general_options' && $active_tab != 'charts_options' && $active_tab != 'activate_license' && $active_tab != 'go_pro' )) {
94
+
95
+ ?>
96
+
97
+ <div class="yasr-settingsdiv">
98
+ <form action="options.php" method="post" id="yasr_settings_form">
99
+ <?php
100
+ settings_fields( 'yasr_general_options_group' );
101
+ do_settings_sections('yasr_general_settings_tab' );
102
+ submit_button( __('Save') );
103
+ ?>
104
+ </form>
105
+ </div>
106
+
107
+ <?php
108
+
109
+ yasr_fb_box ();
110
+ yasr_ask_rating ();
111
 
112
+ ?>
113
 
114
+ <div class="yasr-space-settings-div">
115
+ </div>
116
 
117
+ <?php
 
 
 
 
 
 
 
 
118
 
119
+ $gd_star_rating_found = yasr_search_gd_star_rating();
120
 
121
+ $gd_star_imported = get_option('yasr-gdstar-imported');
 
122
 
123
+ //If gdstar rating has been found but data haven't been imported yet
124
+ if ($gd_star_rating_found && !$gd_star_imported) {
125
+ ?>
126
+ <div class="yasr-settingsdiv">
127
+ <h3><?php _e("Import Gd Star Rating", 'yet-another-stars-rating'); ?></h3>
128
+ <?php _e("I've found a previous installation of Gd Star Rating.", 'yet-another-stars-rating'); ?> <br /><?php _e("Do you want proceed to import data?", 'yet-another-stars-rating'); ?>
129
+ <br />
130
+ <button href="#" class="button-delete" id="import-gdstar"><?php _e('Yes, Begin Import', 'yet-another-stars-rating'); ?></button>
131
 
132
+ <div id="yasr-import-gdstar-div" style="display:none;">
133
+ <strong>
134
+ <?php _e("Click on Proceed to import Gd Star Rating data."); ?>
135
+ </strong>
136
+ <br />
137
+ <button href="#" class="button-primary" id="import-button"> <?php _e('Proceed', 'yet-another-stars-rating'); ?></button>
138
 
139
+ <span id="yasr-loader-importer" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "loader.gif" ?>">
140
+ </span>
141
+ <br />
142
 
143
+ <div id="result-import">
144
+ </div>
145
+ </div>
146
+ </div>
147
+
148
+ <div class="yasr-space-settings-div">
149
+ </div>
150
 
151
+ <?php
152
 
153
+ } //End If $gd_star_rating_found && !$gd_star_imported
 
 
 
 
 
 
 
154
 
155
+ else if ($gd_star_rating_found && $gd_star_imported==1) {
156
+ ?>
157
+
158
+ <div class="yasr-settingsdiv">
159
+ <h3><?php _e("Manage GD Star Data", 'yet-another-stars-rating'); ?></h3>
160
+ <?php _e("Gd Star Rating has been already imported.", 'yet-another-stars-rating'); ?> <br />
161
+ <?php _e("If you wish you can import it again, but", 'yet-another-stars-rating'); ?><strong> <?php _e("you will lose all data you've collect since the import!", 'yet-another-stars-rating'); ?> </strong>
162
+ <br />
163
+ <button href="#" class="button-delete" id="import-gdstar"><?php _e('Ok, Import Again'); ?></button>
164
+
165
+ <div id="yasr-import-gdstar-div" style="display:none;">
166
  <strong>
167
+ <?php _e("Click on Proceed to import again Gd Star Rating data. This may take a while!"); ?>
168
  </strong>
169
  <br />
170
  <button href="#" class="button-primary" id="import-button"> <?php _e('Proceed', 'yet-another-stars-rating'); ?></button>
171
 
172
  <span id="yasr-loader-importer" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "loader.gif" ?>">
173
  </span>
174
+
175
  <br />
176
 
177
  <div id="result-import">
178
  </div>
 
 
 
 
 
 
 
179
 
180
+ </div>
181
+ </div>
182
 
183
+ <div class="yasr-space-settings-div">
184
+ </div>
185
 
186
+ <?php
187
+ } //$gd_star_rating_found && $gd_star_imported==1$gd_star_rating_found = yasr_search_gd_star_rating();
 
 
 
 
188
 
189
+ } //End if tab 'general_settings'
 
 
 
 
 
190
 
 
 
 
 
191
 
192
+ if ($active_tab == 'manage_multi') {
 
193
 
194
+ $multi_set=yasr_get_multi_set();
 
195
 
196
+ global $wpdb;
 
197
 
198
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
 
199
 
200
+ ?>
201
 
202
+ <div class="yasr-settingsdiv">
203
+
204
+ <h3> <?php _e("Manage Multi Set", 'yet-another-stars-rating'); ?></h3>
205
 
206
+ <p>
207
 
208
+ <a href="#" id="yasr-multi-set-doc-link"><?php _e("What is a Multi Set?", 'yet-another-stars-rating') ?></a>
209
 
210
+ </p>
211
 
212
+ <div id="yasr-multi-set-doc-box" style="display:none">
213
+ <?php _e("Multi Set allows you to insert a rate for each aspect about the product / local business / whetever you're reviewing, example in the image below.", 'yet-another-stars-rating');
214
 
215
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr-multi-set.png> <br /> <br />";
216
 
217
+ _e("You can create up to 99 different Multi Set and each one can contain up to 9 different fields. Once you've saved it, you can insert the rates while typing your article in the box below the editor, as you can see in this image (click to see it larger)", 'yet-another-stars-rating');
 
 
218
 
219
+ 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 />";
220
 
221
+ _e("In order to insert your Multi Sets into a post or page, you can either past the short code that will appear at the bottom of the box or just click on the star in the graphic editor and select \"Insert Multi Set\".", 'yet-another-stars-rating');
222
 
223
+ ?>
224
 
225
+ <br /> <br />
 
226
 
227
+ <a href="#" id="yasr-multi-set-doc-link-hide"><?php _e("Close this message", 'yet-another-stars-rating') ?></a>
228
 
229
+ </div>
230
 
231
+ <div class="yasr-multi-set-left">
232
 
233
+ <div class="yasr-new-multi-set" >
234
 
235
+ <?php yasr_display_multi_set_form(); ?>
236
 
237
+ </div> <!--yasr-new-multi-set-->
238
 
239
+ </div> <!--End yasr-multi-set-left-->
240
 
241
+ <div class="yasr-multi-set-right">
242
 
243
+ <?php yasr_edit_multi_form(); ?>
244
 
245
+ <div id="yasr-multi-set-response" style="display:none">
246
 
247
+ </div>
248
 
249
+ </div> <!--End yasr-multi-set-right-->
250
 
251
+ <div class="yasr-space-settings-div">
252
+ </div>
253
 
 
254
 
255
+ <div class="yasr-multi-set-choose-theme">
256
 
257
+ <!--This allow to choose color for multiset-->
258
+ <form action="options.php" method="post" id="yasr_multiset_form">
259
+ <?php
260
+ settings_fields( 'yasr_multiset_options_group' );
261
+ do_settings_sections('yasr_multiset_tab' );
262
+ submit_button( __('Save') );
263
+ ?>
264
+ </form>
265
 
266
  </div>
267
 
 
268
 
 
269
  </div>
270
 
271
+ <?php
272
+ yasr_fb_box ();
273
+ yasr_ask_rating ();
274
+ ?>
275
 
276
+ <div class="yasr-space-settings-div">
 
 
 
 
 
 
 
 
 
 
277
  </div>
278
 
279
+ <?php
280
 
281
+ } //End if ($active_tab=='manage_multi')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
 
283
 
284
+ if ($active_tab == 'style_options') {
285
 
286
+ ?>
287
 
288
+ <div class="yasr-settingsdiv">
289
+ <form action="options.php" method="post" id="yasr_settings_form">
290
+ <?php
291
+ settings_fields( 'yasr_style_options_group' );
292
+ do_settings_sections('yasr_style_tab' );
293
+ submit_button( __('Save') );
294
+ ?>
295
+ </form>
296
+ </div>
297
 
298
+ <?php
299
+ yasr_fb_box ();
300
+ yasr_ask_rating ();
301
+ ?>
302
 
303
+ <div class="yasr-space-settings-div">
304
+ </div>
305
 
 
306
 
307
+ <?php
308
 
309
+ } //End tab style
310
 
 
311
 
312
+ do_action( 'yasr_settings_check_active_tab', $active_tab );
313
 
 
314
 
315
+
316
 
317
+ yasr_fb_box("bottom");
318
+ yasr_ask_rating ("bottom");
319
+
320
+ ?>
321
 
322
  <!--End div wrap-->
323
  </div>
333
 
334
  var autoInsertEnabled = <?php echo (json_encode(YASR_AUTO_INSERT_ENABLED)); ?>;
335
 
336
+ var nonceHideAskRating = <?php echo (json_encode("$ajax_nonce_hide_ask_rating")); ?>
337
+
338
  YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled);
339
 
340
+ YasrAsk5Stars(nonceHideAskRating);
341
+
342
  }); //End jquery document ready
343
 
344
  </script>
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: 1.0.4
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
@@ -29,8 +29,10 @@ You should have received a copy of the GNU General Public License
29
  along with this program. If not, see <http://www.gnu.org/licenses/>
30
  */
31
 
 
 
32
 
33
- define('YASR_VERSION_NUM', '1.0.4');
34
 
35
  //Plugin relative path
36
  define( "YASR_RELATIVE_PATH", dirname(__FILE__) );
@@ -100,21 +102,13 @@ define ("YASR_SCHEMA_FORMAT", $stored_options['snippet_format']);
100
  define ("YASR_METABOX_OVERALL_RATING", $stored_options['metabox_overall_rating']);
101
 
102
 
103
- //Get multi-set options
104
- $multiset_options = get_option('yasr_multiset_options');
105
-
106
- if($multiset_options && $multiset_options['scheme_color'] != '') {
107
-
108
- define("YASR_SCHEME_COLOR", $multiset_options['scheme_color']);
109
-
110
- }
111
-
112
  //Get stored style options
113
- $custom_style = get_option ('yasr_style_options');
114
 
115
- if ($custom_style && $custom_style['textarea'] != '') {
116
 
117
- define ("YASR_CUSTOM_CSS_RULES", $custom_style['textarea']);
 
118
 
119
  }
120
 
@@ -131,6 +125,8 @@ else {
131
  // Include function file
132
  require (YASR_RELATIVE_PATH . '/lib/yasr-functions.php');
133
 
 
 
134
  require (YASR_RELATIVE_PATH . '/lib/yasr-settings-functions.php');
135
 
136
  require (YASR_RELATIVE_PATH . '/lib/yasr-db-functions.php');
@@ -166,8 +162,29 @@ define ("YASR_LOADER_IMAGE", YASR_IMG_DIR . "/loader.gif");
166
 
167
  /****** backward compatibility functions ******/
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  //remove end may 2016
170
- if ($version_installed < '1.0.2') {
171
 
172
  $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name VARCHAR( 40 )
173
  CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;");
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: 1.0.5
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
29
  along with this program. If not, see <http://www.gnu.org/licenses/>
30
  */
31
 
32
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
+
34
 
35
+ define('YASR_VERSION_NUM', '1.0.5');
36
 
37
  //Plugin relative path
38
  define( "YASR_RELATIVE_PATH", dirname(__FILE__) );
102
  define ("YASR_METABOX_OVERALL_RATING", $stored_options['metabox_overall_rating']);
103
 
104
 
 
 
 
 
 
 
 
 
 
105
  //Get stored style options
106
+ $style_options = get_option ('yasr_style_options');
107
 
108
+ if ($style_options && isset($style_options['textarea'])) {
109
 
110
+ define ("YASR_CUSTOM_CSS_RULES", $style_options['textarea']);
111
+ define ("YASR_SCHEME_COLOR", $style_options['scheme_color_multiset']);
112
 
113
  }
114
 
125
  // Include function file
126
  require (YASR_RELATIVE_PATH . '/lib/yasr-functions.php');
127
 
128
+ require (YASR_RELATIVE_PATH . '/lib/yasr-admin-actions.php');
129
+
130
  require (YASR_RELATIVE_PATH . '/lib/yasr-settings-functions.php');
131
 
132
  require (YASR_RELATIVE_PATH . '/lib/yasr-db-functions.php');
162
 
163
  /****** backward compatibility functions ******/
164
 
165
+ //Remove july 2016
166
+ if ($version_installed && $version_installed < '1.0.5') {
167
+
168
+ $multiset_options = get_option('yasr_multiset_options');
169
+
170
+ if($multiset_options && $multiset_options['scheme_color'] != '') {
171
+
172
+ $style_options['scheme_color_multiset'] = $multiset_options['scheme_color'];
173
+
174
+ }
175
+
176
+ else {
177
+
178
+ $style_options['scheme_color_multiset'] = 'light';
179
+
180
+ }
181
+
182
+ update_option("yasr_style_options", $style_options);
183
+
184
+ }
185
+
186
  //remove end may 2016
187
+ if ($version_installed && $version_installed < '1.0.2') {
188
 
189
  $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name VARCHAR( 40 )
190
  CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;");