Yasr – Yet Another Stars Rating - Version 0.4.5

Version Description

  • New feature: Added custom post type support!
  • Some fixes while editing / updating a multi-set
  • Minor changes
Download this release

Release Info

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

Code changes from version 0.4.4 to 0.4.5

lib/yasr-functions.php CHANGED
@@ -75,7 +75,20 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
75
  add_action( 'add_meta_boxes', 'yasr_add_metaboxes' );
76
 
77
  function yasr_add_metaboxes() {
78
- $post_type_where_display_metabox=array('post', 'page');
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  $multi_set=yasr_get_multi_set();
80
  //If multiset are used then add 2 metabox, 1 for overall rating and 1 for multiple rating
81
  if ($multi_set) {
@@ -845,7 +858,7 @@ function visitor_votes_auto_insert_code () {
845
  (Thanks to wordpress.stackexchange) ******/
846
 
847
  // init process for registering our button
848
- add_action('init', 'yasr_shortcode_button_init');
849
  function yasr_shortcode_button_init() {
850
 
851
  //Abort early if the user will never see TinyMCE
@@ -872,4 +885,30 @@ add_action('init', 'yasr_shortcode_button_init');
872
  //Add the button ID to the $button array
873
  $buttons[] = "yasr_button";
874
  return $buttons;
875
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  add_action( 'add_meta_boxes', 'yasr_add_metaboxes' );
76
 
77
  function yasr_add_metaboxes() {
78
+
79
+ //Default post type where display metabox
80
+ $post_type_where_display_metabox = array('post', 'page');
81
+
82
+ //get the custom post type
83
+ $custom_post_types = yasr_get_custom_post_type();
84
+
85
+ if ($custom_post_types) {
86
+
87
+ //First merge array then changes keys to int
88
+ $post_type_where_display_metabox = array_values(array_merge($post_type_where_display_metabox, $custom_post_types));
89
+
90
+ }
91
+
92
  $multi_set=yasr_get_multi_set();
93
  //If multiset are used then add 2 metabox, 1 for overall rating and 1 for multiple rating
94
  if ($multi_set) {
858
  (Thanks to wordpress.stackexchange) ******/
859
 
860
  // init process for registering our button
861
+ add_action('admin_init', 'yasr_shortcode_button_init');
862
  function yasr_shortcode_button_init() {
863
 
864
  //Abort early if the user will never see TinyMCE
885
  //Add the button ID to the $button array
886
  $buttons[] = "yasr_button";
887
  return $buttons;
888
+ }
889
+
890
+
891
+ /****** Return the custom post type if exists ******/
892
+
893
+ add_action( 'admin_init', 'yasr_get_custom_post_type');
894
+ function yasr_get_custom_post_type() {
895
+
896
+ $args = array(
897
+ 'public' => true,
898
+ '_builtin' => false
899
+ );
900
+
901
+ $output = 'names'; // names or objects, note names is the default
902
+ $operator = 'and'; // 'and' or 'or'
903
+
904
+ $post_types = get_post_types( $args, $output, $operator );
905
+
906
+ if ($post_types) {
907
+ return ($post_types);
908
+ }
909
+
910
+ else {
911
+ return FALSE;
912
+ }
913
+
914
+ }
lib/yasr-settings-functions.php CHANGED
@@ -629,8 +629,14 @@ function yasr_process_new_multi_set_form()
629
  $multi_set_name_element_[2]=$_POST['multi-set-name-element-2'];
630
 
631
  //If multi set name is shorter than 3 characher come back
632
- if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) <3 || mb_strlen($multi_set_name_element_[2]) <3 ) {
633
- $array_errors[] = "Content field must be longer then 3 chars";
 
 
 
 
 
 
634
  $error=TRUE;
635
  }
636
 
@@ -660,6 +666,11 @@ function yasr_process_new_multi_set_form()
660
  $error=TRUE;
661
  }
662
 
 
 
 
 
 
663
  $element_filled++;
664
  }
665
 
@@ -807,10 +818,13 @@ function yasr_process_edit_multi_set_form() {
807
  $array_errors[] .= __("Something goes wrong trying to delete a multi-set . Please report it", 'yasr');
808
  }
809
 
810
- if ($remove_set_values==FALSE) {
 
 
811
  $error = TRUE;
812
  $array_errors[] .= __("Something goes wrong trying to delete data fields for a set. Please report it", 'yasr');
813
  }
 
814
 
815
  //Comment this out, will echo error even if the value for that field it's just empty
816
  /*if ($remove_set_votes==FALSE) {
@@ -869,9 +883,14 @@ function yasr_process_edit_multi_set_form() {
869
  $field_id = $_POST["db-id-for-element-$i"];
870
 
871
  //if elements name is shorter than 3 chars
872
- if (mb_strlen($field_name) <3 ) {
873
- $array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
874
- $error=TRUE;
 
 
 
 
 
875
  }
876
 
877
  else {
@@ -929,6 +948,11 @@ function yasr_process_edit_multi_set_form() {
929
  $error=TRUE;
930
  }
931
 
 
 
 
 
 
932
  //if field is not empty
933
  elseif ($field_name != '') {
934
 
629
  $multi_set_name_element_[2]=$_POST['multi-set-name-element-2'];
630
 
631
  //If multi set name is shorter than 3 characher come back
632
+ if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) <3 || mb_strlen($multi_set_name_element_[2]) < 3 ) {
633
+ $array_errors[] = "Content field must be longer than 3 chars";
634
+ $error=TRUE;
635
+ }
636
+
637
+
638
+ if (mb_strlen($multi_set_name) > 23 || mb_strlen($multi_set_name_element_[1]) > 23 || mb_strlen($multi_set_name_element_[2]) > 23 ) {
639
+ $array_errors[] = "Content field must be shorter than 23 chars";
640
  $error=TRUE;
641
  }
642
 
666
  $error=TRUE;
667
  }
668
 
669
+ if (mb_strlen($multi_set_name_element_[$i]) > 23) {
670
+ $array_errors[] = "Field # $i must be shorter than 23 characters";
671
+ $error=TRUE;
672
+ }
673
+
674
  $element_filled++;
675
  }
676
 
818
  $array_errors[] .= __("Something goes wrong trying to delete a multi-set . Please report it", 'yasr');
819
  }
820
 
821
+
822
+ //Comment this out, if try to delete an empty set print error
823
+ /*if ($remove_set_values==FALSE) {
824
  $error = TRUE;
825
  $array_errors[] .= __("Something goes wrong trying to delete data fields for a set. Please report it", 'yasr');
826
  }
827
+ */
828
 
829
  //Comment this out, will echo error even if the value for that field it's just empty
830
  /*if ($remove_set_votes==FALSE) {
883
  $field_id = $_POST["db-id-for-element-$i"];
884
 
885
  //if elements name is shorter than 3 chars
886
+ if (mb_strlen($field_name) <3) {
887
+ $array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
888
+ $error=TRUE;
889
+ }
890
+
891
+ if(mb_strlen($field_name) > 23) {
892
+ $array_errors[] = __("Field # $i must be shorter than 23 characters", "yasr");
893
+ $error=TRUE;
894
  }
895
 
896
  else {
948
  $error=TRUE;
949
  }
950
 
951
+ if(mb_strlen($field_name) > 23) {
952
+ $array_errors[] = __("Field # $i must be shorter than 23 characters", "yasr");
953
+ $error=TRUE;
954
+ }
955
+
956
  //if field is not empty
957
  elseif ($field_name != '') {
958
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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, Schema.org, Serp
4
  Requires at least: 3.5
5
  Tested up to: 3.9.1
6
- Stable tag: 0.4.4
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -79,6 +79,11 @@ Of course not: you can easily add it on the visual editor just by clicking on th
79
 
80
  == Changelog ==
81
 
 
 
 
 
 
82
  = 0.4.4 =
83
  * Code cleanup on chart Top 10 by visitors: on first load load it should be about 30% faster
84
  * Showing a spinning image while chart Top 10 by visitors is loading
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, Schema.org, Serp
4
  Requires at least: 3.5
5
  Tested up to: 3.9.1
6
+ Stable tag: 0.4.5
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
79
 
80
  == Changelog ==
81
 
82
+ = 0.4.5 =
83
+ * New feature: Added custom post type support!
84
+ * Some fixes while editing / updating a multi-set
85
+ * Minor changes
86
+
87
  = 0.4.4 =
88
  * Code cleanup on chart Top 10 by visitors: on first load load it should be about 30% faster
89
  * Showing a spinning image while chart Top 10 by visitors is loading
yasr-metabox-overall-rating.php CHANGED
@@ -33,9 +33,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
33
 
34
  <?php
35
 
36
- if( YASR_AUTO_INSERT_ENABLED == 0 ) {
 
37
 
38
- echo "Remember to insert this shortcode <strong>[yasr_overall_rating]</strong> where you want to display this rating";
39
 
40
  }
41
 
33
 
34
  <?php
35
 
36
+ //Show this message if auto insert is off or if auto insert is not set to show overall rating (so if it is set to visitor rating)
37
+ if( YASR_AUTO_INSERT_ENABLED == 0 || (YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_WHAT === 'visitor_rating') ) {
38
 
39
+ _e ("Remember to insert this shortcode <strong>[yasr_overall_rating]</strong> where you want to display this rating", "yasr");
40
 
41
  }
42
 
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.4.4
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
28
  */
29
 
30
 
31
- define('YASR_VERSION_NUM', '0.4.4');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
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.4.5
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
28
  */
29
 
30
 
31
+ define('YASR_VERSION_NUM', '0.4.5');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );