Yasr – Yet Another Stars Rating - Version 3.0.7

Version Description

  • FIXED: when the value 0 is entered for the Price the Offers field is not displayed in the Schema markup.
  • TWEAKED: minor changes
Download this release

Release Info

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

Code changes from version 3.0.6 to 3.0.7

admin/editor/blocks/yasrOverallRating.block.json → includes/blocks/overall-rating/block.json RENAMED
File without changes
admin/editor/blocks/rankingOverallRating.block.json → includes/blocks/ranking-overall-rating/block.json RENAMED
File without changes
admin/editor/blocks/rankingMostActiveReviewers.block.json → includes/blocks/ranking-reviewers/block.json RENAMED
File without changes
admin/editor/blocks/rankingMostActiveUsers.block.json → includes/blocks/ranking-users/block.json RENAMED
File without changes
admin/editor/blocks/rankingVisitorVotes.block.json → includes/blocks/ranking-visitor-votes/block.json RENAMED
File without changes
admin/editor/blocks/yasrUserRateHistory.block.json → includes/blocks/user-rate-history/block.json RENAMED
File without changes
admin/editor/blocks/yasrVisitorVotes.block.json → includes/blocks/visitor-votes/block.json RENAMED
File without changes
includes/classes/YasrScriptsLoader.php CHANGED
@@ -409,6 +409,18 @@ class YasrScriptsLoader {
409
  * @since 2.8.4
410
  */
411
  public function initGutenBlocks() {
 
 
 
 
 
 
 
 
 
 
 
 
412
  wp_register_script(
413
  'yasr-shortcodes-blocks',
414
  YASR_JS_GUTEN_BLOCKS . 'shortcodes.js',
@@ -422,111 +434,40 @@ class YasrScriptsLoader {
422
  1
423
  );
424
 
425
- global $wp_version;
426
-
427
- $use_register_block_type_from_metadata = true;
428
  if(version_compare($wp_version, '5.8.0') >= 0) {
429
- $use_register_block_type_from_metadata = false;
430
  }
431
 
432
- $this->register_overall_block($use_register_block_type_from_metadata);
433
- $this->register_vv_block($use_register_block_type_from_metadata);
434
- $this->register_ranking_block($use_register_block_type_from_metadata);
435
- $this->register_nostars_rankings($use_register_block_type_from_metadata);
436
- $this->register_user_rate_history($use_register_block_type_from_metadata);
437
  }
438
 
439
- /**
440
- * @author Dario Curvino <@dudo>
441
- * @since 2.8.4
442
- * @param bool $use_register_block_type_from_metadata
443
- */
444
- private function register_overall_block($use_register_block_type_from_metadata = true) {
445
- if($use_register_block_type_from_metadata === false) {
446
- register_block_type(YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/yasrOverallRating.block.json');
447
- }
448
- else {
449
- register_block_type_from_metadata(YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/yasrOverallRating.block.json');
450
- }
451
- }
452
 
453
  /**
454
  * @author Dario Curvino <@dudo>
455
- * @since 2.8.4
456
- * @param bool $use_register_block_type_from_metadata
457
- */
458
- private function register_vv_block($use_register_block_type_from_metadata = true) {
459
- if($use_register_block_type_from_metadata === false) {
460
- register_block_type(YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/yasrVisitorVotes.block.json');
461
- }
462
- else {
463
- register_block_type_from_metadata(YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/yasrVisitorVotes.block.json');
464
- }
465
- }
466
-
467
- /**
468
- * @author Dario Curvino <@dudo>
469
- * @since 2.8.4
470
- * @param bool $use_register_block_type_from_metadata
471
- */
472
- private function register_ranking_block($use_register_block_type_from_metadata = true) {
473
- if($use_register_block_type_from_metadata === false) {
474
- register_block_type(
475
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingOverallRating.block.json'
476
- );
477
- register_block_type(
478
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingVisitorVotes.block.json'
479
- );
480
- }
481
- else {
482
- register_block_type_from_metadata(
483
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingOverallRating.block.json'
484
- );
485
- register_block_type_from_metadata(
486
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingVisitorVotes.block.json'
487
- );
488
- }
489
- }
490
-
491
- /**
492
- * @author Dario Curvino <@dudo>
493
- * @since 2.8.4
494
- * @param bool $use_register_block_type_from_metadata
495
  */
496
- private function register_nostars_rankings($use_register_block_type_from_metadata = true) {
497
- if($use_register_block_type_from_metadata === false) {
498
- register_block_type(
499
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingMostActiveUsers.block.json'
500
- );
501
- register_block_type(
502
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingMostActiveReviewers.block.json'
503
- );
504
- }
505
- else {
506
- register_block_type_from_metadata(
507
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingMostActiveUsers.block.json'
508
- );
509
- register_block_type_from_metadata(
510
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/rankingMostActiveReviewers.block.json'
511
- );
512
- }
513
- }
514
 
515
- /**
516
- * @author Dario Curvino <@dudo>
517
- * @since 2.8.4
518
- * @param bool $use_register_block_type_from_metadata
519
- */
520
- private function register_user_rate_history($use_register_block_type_from_metadata = true) {
521
- if($use_register_block_type_from_metadata === false) {
522
- register_block_type(
523
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/yasrUserRateHistory.block.json'
524
- );
525
- }
526
- else {
527
- register_block_type_from_metadata(
528
- YASR_ABSOLUTE_PATH_ADMIN . '/editor/blocks/yasrUserRateHistory.block.json'
529
- );
530
  }
531
  }
532
 
409
  * @since 2.8.4
410
  */
411
  public function initGutenBlocks() {
412
+ global $wp_version;
413
+ //this function exists since version 5.5.0
414
+ if (!function_exists('register_block_type_from_metadata')) {
415
+ return;
416
+ }
417
+
418
+ //Yasr blocks use apiVersion 2, that works since WP 5.6
419
+ //so, if wp version is < 5.6.0, return
420
+ if(version_compare($wp_version, '5.6.0') < 0) {
421
+ return;
422
+ }
423
+
424
  wp_register_script(
425
  'yasr-shortcodes-blocks',
426
  YASR_JS_GUTEN_BLOCKS . 'shortcodes.js',
434
  1
435
  );
436
 
437
+ $use_register_post_type = false;
438
+ //use register_post_type if version is > 5.8.0
 
439
  if(version_compare($wp_version, '5.8.0') >= 0) {
440
+ $use_register_post_type = true;
441
  }
442
 
443
+ $this->register_blocks($use_register_post_type);
 
 
 
 
444
  }
445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
 
447
  /**
448
  * @author Dario Curvino <@dudo>
449
+ * @since 3.0.4
450
+ *
451
+ * @param bool $use_register_post_type
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  */
453
+ private function register_blocks($use_register_post_type = false) {
454
+
455
+ //get all content in the dir
456
+ $scan = scandir(YASR_ABSOLUTE_BLOCKS_PATH);
457
+
458
+ foreach($scan as $dir) {
459
+ //be sure it is a dir and it is not . and ..
460
+ if ($dir !== '.' && $dir !== '..' && is_dir(YASR_ABSOLUTE_BLOCKS_PATH . '/' . $dir)) {
461
+ //use regist_block_type if wp version > 5.8
462
+ if ($use_register_post_type === true) {
463
+ register_block_type(YASR_ABSOLUTE_BLOCKS_PATH .'/'.$dir.'/block.json');
464
+ }
465
+ //register_block_type_from_metadata if less
466
+ else {
467
+ register_block_type_from_metadata(YASR_ABSOLUTE_BLOCKS_PATH .'/'.$dir . '/block.json');
468
+ }
469
+ }
 
470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  }
472
  }
473
 
public/classes/YasrRichSnippets.php CHANGED
@@ -406,7 +406,8 @@ class YasrRichSnippets {
406
  $rich_snippet['sku'] = $post_meta['yasr_product_sku'];
407
  $rich_snippet[$global_identifer_name] = $post_meta['yasr_product_global_identifier_value'];
408
 
409
- if(!empty($post_meta['yasr_product_price'])) {
 
410
  $rich_snippet['offers'] = array(
411
  '@type' => 'Offer',
412
  'price' => $post_meta['yasr_product_price'],
@@ -495,7 +496,8 @@ class YasrRichSnippets {
495
  $rich_snippet['applicationCategory'] = $post_meta['yasr_softwareapplication_category'];
496
  $rich_snippet['operatingSystem'] = $post_meta['yasr_softwareapplication_os'];
497
 
498
- if(!empty($post_meta['yasr_softwareapplication_price'])) {
 
499
  $rich_snippet['offers'] = array(
500
  '@type' => 'Offer',
501
  'price' => $post_meta['yasr_softwareapplication_price'],
406
  $rich_snippet['sku'] = $post_meta['yasr_product_sku'];
407
  $rich_snippet[$global_identifer_name] = $post_meta['yasr_product_global_identifier_value'];
408
 
409
+ //Can't use !empty here, because emprty return true with 0, and 0 is a valid price
410
+ if($post_meta['yasr_product_price'] !== '') {
411
  $rich_snippet['offers'] = array(
412
  '@type' => 'Offer',
413
  'price' => $post_meta['yasr_product_price'],
496
  $rich_snippet['applicationCategory'] = $post_meta['yasr_softwareapplication_category'];
497
  $rich_snippet['operatingSystem'] = $post_meta['yasr_softwareapplication_os'];
498
 
499
+ //Can't use !empty here, because emprty return true with 0, and 0 is a valid price
500
+ if($post_meta['yasr_softwareapplication_price'] !== '') {
501
  $rich_snippet['offers'] = array(
502
  '@type' => 'Offer',
503
  'price' => $post_meta['yasr_softwareapplication_price'],
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Yasr - Yet Another Stars Rating ===
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
3
  Tags: rating, rate post, star rating, google rating, block
4
- Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 6.0
7
- Stable tag: 3.0.6
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -203,6 +203,10 @@ Yes, YASR is 100% fully compatible with PHP 8
203
 
204
  The full changelog can be found in the plugin's directory. Recent entries:
205
 
 
 
 
 
206
  = 3.0.6 =
207
  * FIX: translation for rankings shortcodes
208
  * FIX: in the classic editor, if Multi Set is used, a duplicate query were run
1
  === Yasr - Yet Another Stars Rating ===
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
3
  Tags: rating, rate post, star rating, google rating, block
4
+ Requires at least: 4.7
5
  Contributors: Dudo
6
  Tested up to: 6.0
7
+ Stable tag: 3.0.7
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
203
 
204
  The full changelog can be found in the plugin's directory. Recent entries:
205
 
206
+ = 3.0.7 =
207
+ * FIXED: when the value 0 is entered for the Price the ‘Offers’ field is not displayed in the Schema markup.
208
+ * TWEAKED: minor changes
209
+
210
  = 3.0.6 =
211
  * FIX: translation for rankings shortcodes
212
  * FIX: in the classic editor, if Multi Set is used, a duplicate query were run
yet-another-stars-rating.php CHANGED
@@ -4,8 +4,8 @@
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
- * Version: 3.0.6
8
- * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
11
  * Author URI: https://dariocurvino.it/
@@ -78,7 +78,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
- define( 'YASR_VERSION_NUM', '3.0.6' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
@@ -99,6 +99,8 @@ if ( !function_exists( 'yasr_fs' ) ) {
99
  define( 'YASR_RELATIVE_PATH_INCLUDES', YASR_RELATIVE_PATH . '/includes' );
100
  //public relative path
101
  define( 'YASR_RELATIVE_PATH_PUBLIC', YASR_RELATIVE_PATH . '/public' );
 
 
102
  //IMG directory absolute URL
103
  define( 'YASR_IMG_DIR', plugins_url() . '/' . YASR_RELATIVE_PATH_INCLUDES . '/img/' );
104
  //Plugin language directory: here I've to use relative path
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
+ * Version: 3.0.7
8
+ * Requires at least: 4.7
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
11
  * Author URI: https://dariocurvino.it/
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
+ define( 'YASR_VERSION_NUM', '3.0.7' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
99
  define( 'YASR_RELATIVE_PATH_INCLUDES', YASR_RELATIVE_PATH . '/includes' );
100
  //public relative path
101
  define( 'YASR_RELATIVE_PATH_PUBLIC', YASR_RELATIVE_PATH . '/public' );
102
+ //blocks path
103
+ define( 'YASR_ABSOLUTE_BLOCKS_PATH', YASR_ABSOLUTE_PATH_INCLUDES . '/blocks' );
104
  //IMG directory absolute URL
105
  define( 'YASR_IMG_DIR', plugins_url() . '/' . YASR_RELATIVE_PATH_INCLUDES . '/img/' );
106
  //Plugin language directory: here I've to use relative path