Site Reviews - Version 5.12.1

Version Description

(2021-06-12) =

  • Fixed the "respond_to_*" capabilities, users can now respond to reviews if they are the author of one of the assigned posts
Download this release

Release Info

Developer geminilabs
Plugin Icon 128x128 Site Reviews
Version 5.12.1
Comparing to
See all releases

Code changes from version 5.12.0 to 5.12.1

languages/site-reviews-en_US.po CHANGED
@@ -1683,29 +1683,29 @@ msgctxt "admin-text"
1683
  msgid "Edit"
1684
  msgstr "Edit"
1685
 
1686
- #: plugin/Controllers/AdminController.php:100
1687
  msgctxt "admin-text"
1688
  msgid "%s Review"
1689
  msgid_plural "%s Reviews"
1690
  msgstr[0] "%s Review"
1691
  msgstr[1] "%s Reviews"
1692
 
1693
- #: plugin/Controllers/AdminController.php:181, plugin/Widgets/SiteReviewsWidget.php:113
1694
  msgctxt "admin-text"
1695
  msgid "Recent Reviews"
1696
  msgstr "Recent Reviews"
1697
 
1698
- #: plugin/Controllers/AdminController.php:182, plugin/Widgets/SiteReviewsFormWidget.php:78, plugin/Integrations/Elementor/ElementorFormWidget.php:21
1699
  msgctxt "admin-text"
1700
  msgid "Submit a Review"
1701
  msgstr "Submit a Review"
1702
 
1703
- #: plugin/Controllers/AdminController.php:183, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1704
  msgctxt "admin-text"
1705
  msgid "Summary of Reviews"
1706
  msgstr "Summary of Reviews"
1707
 
1708
- #: plugin/Controllers/AdminController.php:218, plugin/Controllers/AdminController.php:238, plugin/Controllers/AdminController.php:251
1709
  msgctxt "admin-text"
1710
  msgid "Nothing found."
1711
  msgstr "Nothing found."
1683
  msgid "Edit"
1684
  msgstr "Edit"
1685
 
1686
+ #: plugin/Controllers/AdminController.php:107
1687
  msgctxt "admin-text"
1688
  msgid "%s Review"
1689
  msgid_plural "%s Reviews"
1690
  msgstr[0] "%s Review"
1691
  msgstr[1] "%s Reviews"
1692
 
1693
+ #: plugin/Controllers/AdminController.php:188, plugin/Widgets/SiteReviewsWidget.php:113
1694
  msgctxt "admin-text"
1695
  msgid "Recent Reviews"
1696
  msgstr "Recent Reviews"
1697
 
1698
+ #: plugin/Controllers/AdminController.php:189, plugin/Widgets/SiteReviewsFormWidget.php:78, plugin/Integrations/Elementor/ElementorFormWidget.php:21
1699
  msgctxt "admin-text"
1700
  msgid "Submit a Review"
1701
  msgstr "Submit a Review"
1702
 
1703
+ #: plugin/Controllers/AdminController.php:190, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1704
  msgctxt "admin-text"
1705
  msgid "Summary of Reviews"
1706
  msgstr "Summary of Reviews"
1707
 
1708
+ #: plugin/Controllers/AdminController.php:225, plugin/Controllers/AdminController.php:245, plugin/Controllers/AdminController.php:258
1709
  msgctxt "admin-text"
1710
  msgid "Nothing found."
1711
  msgstr "Nothing found."
languages/site-reviews.pot CHANGED
@@ -1312,29 +1312,29 @@ msgctxt "admin-text"
1312
  msgid "Edit"
1313
  msgstr ""
1314
 
1315
- #: plugin/Controllers/AdminController.php:100
1316
  msgctxt "admin-text"
1317
  msgid "%s Review"
1318
  msgid_plural "%s Reviews"
1319
  msgstr[0] ""
1320
  msgstr[1] ""
1321
 
1322
- #: plugin/Controllers/AdminController.php:181, plugin/Widgets/SiteReviewsWidget.php:113
1323
  msgctxt "admin-text"
1324
  msgid "Recent Reviews"
1325
  msgstr ""
1326
 
1327
- #: plugin/Controllers/AdminController.php:182, plugin/Widgets/SiteReviewsFormWidget.php:78, plugin/Integrations/Elementor/ElementorFormWidget.php:21
1328
  msgctxt "admin-text"
1329
  msgid "Submit a Review"
1330
  msgstr ""
1331
 
1332
- #: plugin/Controllers/AdminController.php:183, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1333
  msgctxt "admin-text"
1334
  msgid "Summary of Reviews"
1335
  msgstr ""
1336
 
1337
- #: plugin/Controllers/AdminController.php:218, plugin/Controllers/AdminController.php:238, plugin/Controllers/AdminController.php:251
1338
  msgctxt "admin-text"
1339
  msgid "Nothing found."
1340
  msgstr ""
1312
  msgid "Edit"
1313
  msgstr ""
1314
 
1315
+ #: plugin/Controllers/AdminController.php:107
1316
  msgctxt "admin-text"
1317
  msgid "%s Review"
1318
  msgid_plural "%s Reviews"
1319
  msgstr[0] ""
1320
  msgstr[1] ""
1321
 
1322
+ #: plugin/Controllers/AdminController.php:188, plugin/Widgets/SiteReviewsWidget.php:113
1323
  msgctxt "admin-text"
1324
  msgid "Recent Reviews"
1325
  msgstr ""
1326
 
1327
+ #: plugin/Controllers/AdminController.php:189, plugin/Widgets/SiteReviewsFormWidget.php:78, plugin/Integrations/Elementor/ElementorFormWidget.php:21
1328
  msgctxt "admin-text"
1329
  msgid "Submit a Review"
1330
  msgstr ""
1331
 
1332
+ #: plugin/Controllers/AdminController.php:190, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1333
  msgctxt "admin-text"
1334
  msgid "Summary of Reviews"
1335
  msgstr ""
1336
 
1337
+ #: plugin/Controllers/AdminController.php:225, plugin/Controllers/AdminController.php:245, plugin/Controllers/AdminController.php:258
1338
  msgctxt "admin-text"
1339
  msgid "Nothing found."
1340
  msgstr ""
plugin/Controllers/AdminController.php CHANGED
@@ -69,21 +69,28 @@ class AdminController extends Controller
69
  */
70
  public function filterCapabilities($capabilities, $capability, $userId, $args)
71
  {
72
- if (is_multisite() && is_super_admin()) {
73
  return $capabilities;
74
  }
75
- if ('respond_to_post' === $capability) {
76
- $capabilities = [];
77
- $post = get_post((int) Arr::get($args, 0));
78
- if (is_null($post)) {
79
- $capabilities[] = 'do_not_allow';
80
- } elseif ($userId == $post->post_author) {
81
- $capabilities[] = glsr(Role::class)->capability('respond_to_posts');
82
- } else {
83
- $capabilities[] = glsr(Role::class)->capability('respond_to_others_posts');
 
 
 
 
84
  }
85
  }
86
- return $capabilities;
 
 
 
87
  }
88
 
89
  /**
69
  */
70
  public function filterCapabilities($capabilities, $capability, $userId, $args)
71
  {
72
+ if ('respond_to_'.glsr()->post_type !== $capability) {
73
  return $capabilities;
74
  }
75
+ $review = glsr_get_review(Arr::get($args, 0));
76
+ if (!$review->isValid()) {
77
+ return ['do_not_allow'];
78
+ }
79
+ $capabilities = [];
80
+ $respondToReviews = glsr(Role::class)->capability('respond_to_posts');
81
+ if ($userId == $review->author_id) {
82
+ $capabilities[] = $respondToReviews; // they are the author of the review
83
+ }
84
+ foreach ($review->assignedPosts() as $assignedPost) {
85
+ if ($userId == $assignedPost->post_author) {
86
+ $capabilities[] = $respondToReviews; // they are the author of the post that the review is assigned to
87
+ break;
88
  }
89
  }
90
+ if (!in_array($respondToReviews, $capabilities)) {
91
+ $capabilities[] = glsr(Role::class)->capability('respond_to_others_posts');
92
+ }
93
+ return array_unique($capabilities);
94
  }
95
 
96
  /**
plugin/Role.php CHANGED
@@ -52,7 +52,9 @@ class Role
52
  'publish_posts',
53
  'read_post',
54
  'read_private_posts',
 
55
  'respond_to_others_posts',
 
56
  'respond_to_posts',
57
  ];
58
  }
52
  'publish_posts',
53
  'read_post',
54
  'read_private_posts',
55
+ 'respond_to_others_post',
56
  'respond_to_others_posts',
57
+ 'respond_to_post',
58
  'respond_to_posts',
59
  ];
60
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: reviews, ratings, testimonials, woocommerce, product reviews
5
  Tested up to: 5.7
6
  Requires at least: 5.5
7
  Requires PHP: 5.6
8
- Stable tag: 5.12.0
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -137,7 +137,11 @@ All documentation can be found in the "Help" page of the plugin. If your questio
137
 
138
  ## Changelog
139
 
140
- = 5.12.0-beta2 (2021-06-05) =
 
 
 
 
141
 
142
  - Added the "rating_field" shortcode option which allows you to use a custom rating field with the summary
143
  - Added the "Repair Review Relations" tool
5
  Tested up to: 5.7
6
  Requires at least: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 5.12.1
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
137
 
138
  ## Changelog
139
 
140
+ = 5.12.1 (2021-06-12) =
141
+
142
+ - Fixed the "respond_to_*" capabilities, users can now respond to reviews if they are the author of one of the assigned posts
143
+
144
+ = 5.12.0 (2021-06-07) =
145
 
146
  - Added the "rating_field" shortcode option which allows you to use a custom rating field with the summary
147
  - Added the "Repair Review Relations" tool
site-reviews.php CHANGED
@@ -7,7 +7,7 @@
7
  * Plugin Name: Site Reviews
8
  * Plugin URI: https://wordpress.org/plugins/site-reviews
9
  * Description: Receive and display reviews on your website
10
- * Version: 5.12.0
11
  * Author: Paul Ryley
12
  * Author URI: https://geminilabs.io
13
  * License: GPL2
7
  * Plugin Name: Site Reviews
8
  * Plugin URI: https://wordpress.org/plugins/site-reviews
9
  * Description: Receive and display reviews on your website
10
+ * Version: 5.12.1
11
  * Author: Paul Ryley
12
  * Author URI: https://geminilabs.io
13
  * License: GPL2