Yasr – Yet Another Stars Rating - Version 1.1.4

Version Description

  • TWEAKED: added 2 new actions: yasr_action_on_overall_rating runs when the overall rating vote is insert or update, and yasr_action_on_visitor_vote runs when an user insert a vote and last yasr_action_on_update_visitor_vote that run when a logged in user update his vote
  • FIXED: changed to a lower priority on 2 actions
Download this release

Release Info

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

Code changes from version 1.1.3 to 1.1.4

lib/yasr-admin-actions.php CHANGED
@@ -29,8 +29,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
29
  }
30
 
31
 
32
- //Always return False
33
- add_filter( 'yasr_filter_schema_microdata', 'yasr_filter_schema_microdata_callback');
34
 
35
  function yasr_filter_schema_microdata_callback () {
36
 
@@ -39,7 +39,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
39
  }
40
 
41
  //Always return False
42
- add_filter( 'yasr_filter_schema_jsonld', 'yasr_filter_schema_jsonld_callback');
43
 
44
  function yasr_filter_schema_jsonld_callback () {
45
 
@@ -47,4 +47,18 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
47
 
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  ?>
29
  }
30
 
31
 
32
+ //Always return False, lower priority as possible
33
+ add_filter( 'yasr_filter_schema_microdata', 'yasr_filter_schema_microdata_callback', 999);
34
 
35
  function yasr_filter_schema_microdata_callback () {
36
 
39
  }
40
 
41
  //Always return False
42
+ add_filter( 'yasr_filter_schema_jsonld', 'yasr_filter_schema_jsonld_callback', 999);
43
 
44
  function yasr_filter_schema_jsonld_callback () {
45
 
47
 
48
  }
49
 
50
+
51
+ //DElete caches for wp_super_Cache and wp_rocket
52
+ add_action('yasr_action_on_visitor_vote', 'yasr_delete_cache' );
53
+ add_action('yasr_action_on_update_visitor_vote', 'yasr_delete_cache');
54
+
55
+
56
+ function yasr_delete_cache($post_id) {
57
+
58
+ yasr_wp_super_cache_support($post_id);
59
+
60
+ yasr_wp_rocket_support($post_id);
61
+
62
+ }
63
+
64
  ?>
lib/yasr-ajax-functions.php CHANGED
@@ -54,6 +54,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
54
 
55
  }
56
 
 
 
57
  global $wpdb;
58
 
59
  //If update works means that visitor already rated this post
@@ -1166,10 +1168,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1166
  exit();
1167
  }
1168
 
1169
- yasr_wp_super_cache_support($post_id);
1170
-
1171
- yasr_wp_rocket_support($post_id);
1172
-
1173
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1174
  die( 'Security check' );
1175
  }
@@ -1199,6 +1197,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1199
  $px_size = '32';
1200
  }
1201
 
 
 
 
 
1202
  global $wpdb;
1203
 
1204
  $row_exists = $wpdb->get_results($wpdb->prepare("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . "
@@ -1323,9 +1325,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1323
  exit();
1324
  }
1325
 
1326
- yasr_wp_super_cache_support($post_id);
1327
 
1328
- yasr_wp_rocket_support($post_id);
1329
 
1330
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1331
  die( 'Security check' );
@@ -1353,6 +1353,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1353
  $px_size = '32';
1354
  }
1355
 
 
1356
 
1357
  global $wpdb;
1358
 
@@ -1379,6 +1380,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1379
  $old_vote = $vote->vote;
1380
  }
1381
 
 
 
 
 
 
 
 
1382
  //Calculate the new sum: get the old sum and subtract the old vote
1383
  $new_sum = $old_votes_sum - $old_vote;
1384
 
54
 
55
  }
56
 
57
+ do_action('yasr_action_on_overall_rating', $post_id);
58
+
59
  global $wpdb;
60
 
61
  //If update works means that visitor already rated this post
1168
  exit();
1169
  }
1170
 
 
 
 
 
1171
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1172
  die( 'Security check' );
1173
  }
1197
  $px_size = '32';
1198
  }
1199
 
1200
+
1201
+ do_action('yasr_action_on_visitor_vote', $post_id);
1202
+
1203
+
1204
  global $wpdb;
1205
 
1206
  $row_exists = $wpdb->get_results($wpdb->prepare("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . "
1325
  exit();
1326
  }
1327
 
 
1328
 
 
1329
 
1330
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1331
  die( 'Security check' );
1353
  $px_size = '32';
1354
  }
1355
 
1356
+ do_action('yasr_action_on_update_visitor_vote', $post_id);
1357
 
1358
  global $wpdb;
1359
 
1380
  $old_vote = $vote->vote;
1381
  }
1382
 
1383
+ //just to be sure it's not negative
1384
+ if ($old_vote < 0) {
1385
+
1386
+ $old_vote = 0;
1387
+
1388
+ }
1389
+
1390
  //Calculate the new sum: get the old sum and subtract the old vote
1391
  $new_sum = $old_votes_sum - $old_vote;
1392
 
lib/yasr-functions.php CHANGED
@@ -285,7 +285,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
285
 
286
  /****** Add review schema data at the end of the post *******/
287
 
288
- add_filter('the_content', 'yasr_add_schema');
 
 
289
 
290
  function yasr_add_schema($content) {
291
 
@@ -306,13 +308,14 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
306
  //if is not jsonld (default case)
307
  if(YASR_SCHEMA_FORMAT != 'jsonld'){
308
 
309
-
310
  $schema=NULL; //To avoid undefined variable notice outside the loop
311
 
312
  $review_choosen = yasr_get_snippet_type();
313
 
314
  $schema = apply_filters( 'yasr_filter_schema_microdata', $review_choosen );
315
 
 
 
316
  if ($schema) {
317
 
318
  return $content . $schema;
@@ -851,6 +854,4 @@ function yasr_get_ip() {
851
 
852
  }
853
 
854
-
855
-
856
  ?>
285
 
286
  /****** Add review schema data at the end of the post *******/
287
 
288
+
289
+ add_filter('the_content', 'yasr_add_schema');
290
+
291
 
292
  function yasr_add_schema($content) {
293
 
308
  //if is not jsonld (default case)
309
  if(YASR_SCHEMA_FORMAT != 'jsonld'){
310
 
 
311
  $schema=NULL; //To avoid undefined variable notice outside the loop
312
 
313
  $review_choosen = yasr_get_snippet_type();
314
 
315
  $schema = apply_filters( 'yasr_filter_schema_microdata', $review_choosen );
316
 
317
+ //$schema = yasr_pro_microdata_reviews($review_choosen);
318
+
319
  if ($schema) {
320
 
321
  return $content . $schema;
854
 
855
  }
856
 
 
 
857
  ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post r
4
  Requires at least: 3.5
5
  Contributors: Dudo
6
  Tested up to: 4.4
7
- Stable tag: 1.1.3
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
@@ -110,6 +110,10 @@ Of course not: you can easily add it on the visual editor just by clicking on th
110
 
111
  == Changelog ==
112
 
 
 
 
 
113
  = 1.1.3 =
114
  * NEW FEATURE: New widget in the dashboard: all the logged in user can now see the logs of their votes
115
  * FIXED: Insert new vote instead of update the old one if a logged in user try to vote an already rated post on archive pages
4
  Requires at least: 3.5
5
  Contributors: Dudo
6
  Tested up to: 4.4
7
+ Stable tag: 1.1.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
110
 
111
  == Changelog ==
112
 
113
+ = 1.1.4 =
114
+ * TWEAKED: added 2 new actions: yasr_action_on_overall_rating runs when the overall rating vote is insert or update, and yasr_action_on_visitor_vote runs when an user insert a vote and last yasr_action_on_update_visitor_vote that run when a logged in user update his vote
115
+ * FIXED: changed to a lower priority on 2 actions
116
+
117
  = 1.1.3 =
118
  * NEW FEATURE: New widget in the dashboard: all the logged in user can now see the logs of their votes
119
  * FIXED: Insert new vote instead of update the old one if a logged in user try to vote an already rated post on archive pages
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: Yet Another Stars Rating turn your WordPress into a complete review website.
6
- * Version: 1.1.3
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
@@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
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.1.3');
36
 
37
  //Plugin relative path
38
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -273,27 +273,6 @@ if ($version_installed && $version_installed < '0.9.7') {
273
 
274
  }
275
 
276
- //remove end dec 2015
277
- if ($version_installed && $version_installed < '0.8.6') {
278
-
279
- $new_fields=$wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_VALUES_TABLE . " LIMIT 1");
280
-
281
- foreach ($new_fields as $fields) {
282
- if(!isset($fields->number_of_votes)) {
283
- $new_fields = FALSE;
284
- }
285
- }
286
-
287
-
288
-
289
- if(!$new_fields) {
290
-
291
- $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_VALUES_TABLE . " ADD number_of_votes BIGINT( 20 ) NOT NULL ,
292
- ADD sum_votes DECIMAL( 11, 1 ) NOT NULL ;");
293
- }
294
-
295
- }
296
-
297
 
298
  /****** End backward compatibility functions ******/
299
 
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Yet Another Stars Rating turn your WordPress into a complete review website.
6
+ * Version: 1.1.4
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
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.1.4');
36
 
37
  //Plugin relative path
38
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
273
 
274
  }
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
 
277
  /****** End backward compatibility functions ******/
278