Site Reviews - Version 5.13.0

Version Description

(2021-08-01) =

  • Added the $review->author() method on review objects which returns the author name as defined in the settings
  • Added the "site-reviews/avatar/attributes" hook which allows you to modify the attributes on the avatar tag
  • Internal changes to support the upcoming Review Themes add-on
  • Renamed the "site-reviews/review/response" hook to "site-reviews/review/responded" (see the related FAQ section)
  • Updated the "Common Problems and Solutions"
  • Updated the "FAQ"
Download this release

Release Info

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

Code changes from version 5.12.9 to 5.13.0

deprecated.php CHANGED
@@ -99,6 +99,18 @@ add_action('plugins_loaded', function () {
99
  }
100
  return $defaults;
101
  });
 
 
 
 
 
 
 
 
 
 
 
 
102
  });
103
 
104
  /**
99
  }
100
  return $defaults;
101
  });
102
+
103
+ /*
104
+ * Database\ReviewManager
105
+ * @since 5.11.0
106
+ */
107
+ add_action('site-reviews/review/responded', function ($review, $response) {
108
+ if (has_action('site-reviews/review/response')) {
109
+ $message = 'The "site-reviews/review/response" hook has been deprecated. Please use the "site-reviews/review/responded" hook instead which is documented on the FAQ page.';
110
+ glsr()->append('deprecated', $message);
111
+ do_action('site-reviews/review/response', $response, $review);
112
+ }
113
+ }, 9, 2);
114
  });
115
 
116
  /**
languages/site-reviews-en_US.mo CHANGED
Binary file
languages/site-reviews-en_US.po CHANGED
@@ -18,7 +18,7 @@ msgstr ""
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
  "Language: en_US\n"
20
 
21
- #: deprecated.php:111
22
  msgid ""
23
  "%s is <strong>deprecated</strong> since version %s with no alternative "
24
  "available."
@@ -26,7 +26,7 @@ msgstr ""
26
  "%s is <strong>deprecated</strong> since version %s with no alternative "
27
  "available."
28
 
29
- #: deprecated.php:124
30
  msgid "%s is <strong>deprecated</strong> since version %s! Use %s instead."
31
  msgstr "%s is <strong>deprecated</strong> since version %s! Use %s instead."
32
 
@@ -34,7 +34,7 @@ msgstr "%s is <strong>deprecated</strong> since version %s! Use %s instead."
34
  msgid "There are no reviews yet. Be the first one to write one."
35
  msgstr "There are no reviews yet. Be the first one to write one."
36
 
37
- #: plugin/Router.php:156, views/pages/documentation/support/common-problems-and-solutions.php:45
38
  msgid "The form could not be submitted. Please notify the site administrator."
39
  msgstr "The form could not be submitted. Please notify the site administrator."
40
 
@@ -86,7 +86,7 @@ msgstr "Show more"
86
  msgid "Your review has been submitted!"
87
  msgstr "Your review has been submitted!"
88
 
89
- #: plugin/Commands/CreateReview.php:166, views/pages/documentation/support/common-problems-and-solutions.php:65
90
  msgid ""
91
  "Your review could not be submitted and the error has been logged. Please "
92
  "notify the site administrator."
@@ -166,6 +166,10 @@ msgstr ""
166
  msgid "and"
167
  msgstr "and"
168
 
 
 
 
 
169
  #: plugin/Modules/Date.php:84
170
  msgid "A moment ago"
171
  msgstr "A moment ago"
@@ -216,23 +220,23 @@ msgstr[1] "%s years ago"
216
  msgid "Anonymous"
217
  msgstr "Anonymous"
218
 
219
- #: plugin/Shortcodes/Shortcode.php:207
220
  msgid "Excellent"
221
  msgstr "Excellent"
222
 
223
- #: plugin/Shortcodes/Shortcode.php:208
224
  msgid "Very good"
225
  msgstr "Very good"
226
 
227
- #: plugin/Shortcodes/Shortcode.php:209
228
  msgid "Average"
229
  msgstr "Average"
230
 
231
- #: plugin/Shortcodes/Shortcode.php:210
232
  msgid "Poor"
233
  msgstr "Poor"
234
 
235
- #: plugin/Shortcodes/Shortcode.php:211
236
  msgid "Terrible"
237
  msgstr "Terrible"
238
 
@@ -256,15 +260,15 @@ msgstr "You may also %s for an account."
256
  msgid "Close modal"
257
  msgstr "Close modal"
258
 
259
- #: plugin/Modules/Validator/AkismetValidator.php:49, plugin/Modules/Validator/HoneypotValidator.php:26, views/pages/documentation/support/common-problems-and-solutions.php:61
260
  msgid "This review has been flagged as possible spam and cannot be submitted."
261
  msgstr "This review has been flagged as possible spam and cannot be submitted."
262
 
263
- #: plugin/Modules/Validator/BlacklistValidator.php:37, views/pages/documentation/support/common-problems-and-solutions.php:57
264
  msgid "Your review cannot be submitted at this time."
265
  msgstr "Your review cannot be submitted at this time."
266
 
267
- #: plugin/Modules/Validator/CustomValidator.php:27, views/pages/documentation/support/common-problems-and-solutions.php:70
268
  msgid "The review submission failed. Please notify the site administrator."
269
  msgstr "The review submission failed. Please notify the site administrator."
270
 
@@ -1504,7 +1508,7 @@ msgstr ""
1504
  "The [%s] method has been deprecated and will be soon be removed, please use "
1505
  "the [%s] method instead."
1506
 
1507
- #: plugin/Review.php:323, plugin/Controllers/ListTableColumns/ColumnValueAuthorName.php:20
1508
  msgctxt "admin-text"
1509
  msgid "Unknown"
1510
  msgstr "Unknown"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
  "Language: en_US\n"
20
 
21
+ #: deprecated.php:123
22
  msgid ""
23
  "%s is <strong>deprecated</strong> since version %s with no alternative "
24
  "available."
26
  "%s is <strong>deprecated</strong> since version %s with no alternative "
27
  "available."
28
 
29
+ #: deprecated.php:136
30
  msgid "%s is <strong>deprecated</strong> since version %s! Use %s instead."
31
  msgstr "%s is <strong>deprecated</strong> since version %s! Use %s instead."
32
 
34
  msgid "There are no reviews yet. Be the first one to write one."
35
  msgstr "There are no reviews yet. Be the first one to write one."
36
 
37
+ #: plugin/Router.php:156, views/pages/documentation/support/common-problems-and-solutions.php:48
38
  msgid "The form could not be submitted. Please notify the site administrator."
39
  msgstr "The form could not be submitted. Please notify the site administrator."
40
 
86
  msgid "Your review has been submitted!"
87
  msgstr "Your review has been submitted!"
88
 
89
+ #: plugin/Commands/CreateReview.php:166, views/pages/documentation/support/common-problems-and-solutions.php:68
90
  msgid ""
91
  "Your review could not be submitted and the error has been logged. Please "
92
  "notify the site administrator."
166
  msgid "and"
167
  msgstr "and"
168
 
169
+ #: plugin/Modules/Avatar.php:48
170
+ msgid "Avatar for %s"
171
+ msgstr "Avatar for %s"
172
+
173
  #: plugin/Modules/Date.php:84
174
  msgid "A moment ago"
175
  msgstr "A moment ago"
220
  msgid "Anonymous"
221
  msgstr "Anonymous"
222
 
223
+ #: plugin/Shortcodes/Shortcode.php:208
224
  msgid "Excellent"
225
  msgstr "Excellent"
226
 
227
+ #: plugin/Shortcodes/Shortcode.php:209
228
  msgid "Very good"
229
  msgstr "Very good"
230
 
231
+ #: plugin/Shortcodes/Shortcode.php:210
232
  msgid "Average"
233
  msgstr "Average"
234
 
235
+ #: plugin/Shortcodes/Shortcode.php:211
236
  msgid "Poor"
237
  msgstr "Poor"
238
 
239
+ #: plugin/Shortcodes/Shortcode.php:212
240
  msgid "Terrible"
241
  msgstr "Terrible"
242
 
260
  msgid "Close modal"
261
  msgstr "Close modal"
262
 
263
+ #: plugin/Modules/Validator/AkismetValidator.php:49, plugin/Modules/Validator/HoneypotValidator.php:26, views/pages/documentation/support/common-problems-and-solutions.php:64
264
  msgid "This review has been flagged as possible spam and cannot be submitted."
265
  msgstr "This review has been flagged as possible spam and cannot be submitted."
266
 
267
+ #: plugin/Modules/Validator/BlacklistValidator.php:37, views/pages/documentation/support/common-problems-and-solutions.php:60
268
  msgid "Your review cannot be submitted at this time."
269
  msgstr "Your review cannot be submitted at this time."
270
 
271
+ #: plugin/Modules/Validator/CustomValidator.php:27, views/pages/documentation/support/common-problems-and-solutions.php:73
272
  msgid "The review submission failed. Please notify the site administrator."
273
  msgstr "The review submission failed. Please notify the site administrator."
274
 
1508
  "The [%s] method has been deprecated and will be soon be removed, please use "
1509
  "the [%s] method instead."
1510
 
1511
+ #: plugin/Review.php:334, plugin/Controllers/ListTableColumns/ColumnValueAuthorName.php:20
1512
  msgctxt "admin-text"
1513
  msgid "Unknown"
1514
  msgstr "Unknown"
languages/site-reviews.pot CHANGED
@@ -115,11 +115,11 @@ msgctxt "admin-text"
115
  msgid "Respond To Others' Reviews"
116
  msgstr ""
117
 
118
- #: deprecated.php:111
119
  msgid "%s is <strong>deprecated</strong> since version %s with no alternative available."
120
  msgstr ""
121
 
122
- #: deprecated.php:124
123
  msgid "%s is <strong>deprecated</strong> since version %s! Use %s instead."
124
  msgstr ""
125
 
@@ -1077,7 +1077,7 @@ msgctxt "admin-text"
1077
  msgid "The [%s] method has been deprecated and will be soon be removed, please use the [%s] method instead."
1078
  msgstr ""
1079
 
1080
- #: plugin/Review.php:323, plugin/Controllers/ListTableColumns/ColumnValueAuthorName.php:20
1081
  msgctxt "admin-text"
1082
  msgid "Unknown"
1083
  msgstr ""
@@ -1087,7 +1087,7 @@ msgctxt "admin-text"
1087
  msgid "There was an error (try reloading the page)."
1088
  msgstr ""
1089
 
1090
- #: plugin/Router.php:156, views/pages/documentation/support/common-problems-and-solutions.php:45
1091
  msgid "The form could not be submitted. Please notify the site administrator."
1092
  msgstr ""
1093
 
@@ -1234,7 +1234,7 @@ msgstr ""
1234
  msgid "Your review has been submitted!"
1235
  msgstr ""
1236
 
1237
- #: plugin/Commands/CreateReview.php:166, views/pages/documentation/support/common-problems-and-solutions.php:65
1238
  msgid "Your review could not be submitted and the error has been logged. Please notify the site administrator."
1239
  msgstr ""
1240
 
@@ -2007,6 +2007,10 @@ msgstr ""
2007
  msgid "and"
2008
  msgstr ""
2009
 
 
 
 
 
2010
  #: plugin/Modules/Console.php:79
2011
  msgctxt "admin-text"
2012
  msgid "Console is empty"
@@ -2084,23 +2088,23 @@ msgctxt "admin-text"
2084
  msgid "No Change"
2085
  msgstr ""
2086
 
2087
- #: plugin/Shortcodes/Shortcode.php:207
2088
  msgid "Excellent"
2089
  msgstr ""
2090
 
2091
- #: plugin/Shortcodes/Shortcode.php:208
2092
  msgid "Very good"
2093
  msgstr ""
2094
 
2095
- #: plugin/Shortcodes/Shortcode.php:209
2096
  msgid "Average"
2097
  msgstr ""
2098
 
2099
- #: plugin/Shortcodes/Shortcode.php:210
2100
  msgid "Poor"
2101
  msgstr ""
2102
 
2103
- #: plugin/Shortcodes/Shortcode.php:211
2104
  msgid "Terrible"
2105
  msgstr ""
2106
 
@@ -2716,15 +2720,15 @@ msgctxt "admin-text"
2716
  msgid "Additional CSS classes"
2717
  msgstr ""
2718
 
2719
- #: plugin/Modules/Validator/AkismetValidator.php:49, plugin/Modules/Validator/HoneypotValidator.php:26, views/pages/documentation/support/common-problems-and-solutions.php:61
2720
  msgid "This review has been flagged as possible spam and cannot be submitted."
2721
  msgstr ""
2722
 
2723
- #: plugin/Modules/Validator/BlacklistValidator.php:37, views/pages/documentation/support/common-problems-and-solutions.php:57
2724
  msgid "Your review cannot be submitted at this time."
2725
  msgstr ""
2726
 
2727
- #: plugin/Modules/Validator/CustomValidator.php:27, views/pages/documentation/support/common-problems-and-solutions.php:70
2728
  msgid "The review submission failed. Please notify the site administrator."
2729
  msgstr ""
2730
 
115
  msgid "Respond To Others' Reviews"
116
  msgstr ""
117
 
118
+ #: deprecated.php:123
119
  msgid "%s is <strong>deprecated</strong> since version %s with no alternative available."
120
  msgstr ""
121
 
122
+ #: deprecated.php:136
123
  msgid "%s is <strong>deprecated</strong> since version %s! Use %s instead."
124
  msgstr ""
125
 
1077
  msgid "The [%s] method has been deprecated and will be soon be removed, please use the [%s] method instead."
1078
  msgstr ""
1079
 
1080
+ #: plugin/Review.php:334, plugin/Controllers/ListTableColumns/ColumnValueAuthorName.php:20
1081
  msgctxt "admin-text"
1082
  msgid "Unknown"
1083
  msgstr ""
1087
  msgid "There was an error (try reloading the page)."
1088
  msgstr ""
1089
 
1090
+ #: plugin/Router.php:156, views/pages/documentation/support/common-problems-and-solutions.php:48
1091
  msgid "The form could not be submitted. Please notify the site administrator."
1092
  msgstr ""
1093
 
1234
  msgid "Your review has been submitted!"
1235
  msgstr ""
1236
 
1237
+ #: plugin/Commands/CreateReview.php:166, views/pages/documentation/support/common-problems-and-solutions.php:68
1238
  msgid "Your review could not be submitted and the error has been logged. Please notify the site administrator."
1239
  msgstr ""
1240
 
2007
  msgid "and"
2008
  msgstr ""
2009
 
2010
+ #: plugin/Modules/Avatar.php:48
2011
+ msgid "Avatar for %s"
2012
+ msgstr ""
2013
+
2014
  #: plugin/Modules/Console.php:79
2015
  msgctxt "admin-text"
2016
  msgid "Console is empty"
2088
  msgid "No Change"
2089
  msgstr ""
2090
 
2091
+ #: plugin/Shortcodes/Shortcode.php:208
2092
  msgid "Excellent"
2093
  msgstr ""
2094
 
2095
+ #: plugin/Shortcodes/Shortcode.php:209
2096
  msgid "Very good"
2097
  msgstr ""
2098
 
2099
+ #: plugin/Shortcodes/Shortcode.php:210
2100
  msgid "Average"
2101
  msgstr ""
2102
 
2103
+ #: plugin/Shortcodes/Shortcode.php:211
2104
  msgid "Poor"
2105
  msgstr ""
2106
 
2107
+ #: plugin/Shortcodes/Shortcode.php:212
2108
  msgid "Terrible"
2109
  msgstr ""
2110
 
2720
  msgid "Additional CSS classes"
2721
  msgstr ""
2722
 
2723
+ #: plugin/Modules/Validator/AkismetValidator.php:49, plugin/Modules/Validator/HoneypotValidator.php:26, views/pages/documentation/support/common-problems-and-solutions.php:64
2724
  msgid "This review has been flagged as possible spam and cannot be submitted."
2725
  msgstr ""
2726
 
2727
+ #: plugin/Modules/Validator/BlacklistValidator.php:37, views/pages/documentation/support/common-problems-and-solutions.php:60
2728
  msgid "Your review cannot be submitted at this time."
2729
  msgstr ""
2730
 
2731
+ #: plugin/Modules/Validator/CustomValidator.php:27, views/pages/documentation/support/common-problems-and-solutions.php:73
2732
  msgid "The review submission failed. Please notify the site administrator."
2733
  msgstr ""
2734
 
plugin/Database/ReviewManager.php CHANGED
@@ -314,8 +314,10 @@ class ReviewManager
314
  $response = Cast::toString($response);
315
  $response = glsr(Sanitizer::class)->sanitizeTextHtml($response);
316
  $userId = Helper::ifTrue(empty($response), 0, get_current_user_id());
317
- glsr(Database::class)->metaSet($reviewId, 'response_by', $userId);
318
- return glsr(Database::class)->metaSet($reviewId, 'response', $response);
 
 
319
  }
320
 
321
  /**
314
  $response = Cast::toString($response);
315
  $response = glsr(Sanitizer::class)->sanitizeTextHtml($response);
316
  $userId = Helper::ifTrue(empty($response), 0, get_current_user_id());
317
+ $review = glsr_get_review($reviewId);
318
+ glsr()->action('review/responded', $review, $response, $userId);
319
+ glsr(Database::class)->metaSet($reviewId, 'response_by', $userId); // prefixed metakey
320
+ return glsr(Database::class)->metaSet($reviewId, 'response', $response); // prefixed metakey
321
  }
322
 
323
  /**
plugin/Helpers/Str.php CHANGED
@@ -133,7 +133,7 @@ class Str
133
  */
134
  public static function fallback($value, $fallback)
135
  {
136
- return is_scalar($value) && !empty(trim($value))
137
  ? Cast::toString($value)
138
  : Cast::toString($fallback);
139
  }
@@ -156,7 +156,7 @@ class Str
156
  */
157
  public static function prefix($string, $prefix, $trim = null)
158
  {
159
- if (empty($string)) {
160
  return $string;
161
  }
162
  if (null === $trim) {
@@ -214,7 +214,7 @@ class Str
214
  public static function replaceLast($search, $replace, $subject)
215
  {
216
  $position = strrpos($subject, $search);
217
- if (!empty($search) && $position !== false) {
218
  return substr_replace($subject, $replace, $position, strlen($search));
219
  }
220
  return $subject;
133
  */
134
  public static function fallback($value, $fallback)
135
  {
136
+ return is_scalar($value) && '' !== trim($value)
137
  ? Cast::toString($value)
138
  : Cast::toString($fallback);
139
  }
156
  */
157
  public static function prefix($string, $prefix, $trim = null)
158
  {
159
+ if ('' === $string) {
160
  return $string;
161
  }
162
  if (null === $trim) {
214
  public static function replaceLast($search, $replace, $subject)
215
  {
216
  $position = strrpos($subject, $search);
217
+ if ('' !== $search && false !== $position) {
218
  return substr_replace($subject, $replace, $position, strlen($search));
219
  }
220
  return $subject;
plugin/Modules/Avatar.php CHANGED
@@ -5,6 +5,7 @@ namespace GeminiLabs\SiteReviews\Modules;
5
  use GeminiLabs\SiteReviews\Helper;
6
  use GeminiLabs\SiteReviews\Helpers\Cast;
7
  use GeminiLabs\SiteReviews\Modules\Html\Builder;
 
8
 
9
  class Avatar
10
  {
@@ -36,14 +37,15 @@ class Avatar
36
  }
37
 
38
  /**
39
- * @param string $src
40
  * @param int $size
41
  * @return string
42
  */
43
- public function img($src, $size = null)
44
  {
45
  $size = $this->size($size);
 
46
  $attributes = [
 
47
  'height' => $size * 2,
48
  'loading' => 'lazy',
49
  'src' => $this->url($src, $size * 2),
@@ -53,6 +55,7 @@ class Avatar
53
  if (glsr()->isAdmin()) {
54
  $attributes['data-fallback'] = $this->fallback($size);
55
  }
 
56
  return glsr(Builder::class)->img($attributes);
57
  }
58
 
5
  use GeminiLabs\SiteReviews\Helper;
6
  use GeminiLabs\SiteReviews\Helpers\Cast;
7
  use GeminiLabs\SiteReviews\Modules\Html\Builder;
8
+ use GeminiLabs\SiteReviews\Review;
9
 
10
  class Avatar
11
  {
37
  }
38
 
39
  /**
 
40
  * @param int $size
41
  * @return string
42
  */
43
+ public function img(Review $review, $size = null)
44
  {
45
  $size = $this->size($size);
46
+ $src = $review->get('avatar');
47
  $attributes = [
48
+ 'alt' => sprintf(__('Avatar for %s', 'site-reviews'), $review->author()),
49
  'height' => $size * 2,
50
  'loading' => 'lazy',
51
  'src' => $this->url($src, $size * 2),
55
  if (glsr()->isAdmin()) {
56
  $attributes['data-fallback'] = $this->fallback($size);
57
  }
58
+ $attributes = glsr()->filterArray('avatar/attributes', $attributes, $review);
59
  return glsr(Builder::class)->img($attributes);
60
  }
61
 
plugin/Modules/Html/Attributes.php CHANGED
@@ -62,9 +62,9 @@ class Attributes
62
  'webkitdirectory',
63
  ];
64
 
65
- const GLOBAL_ATTRIBUTES = [
66
  'accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone',
67
- 'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title',
68
  ];
69
 
70
  const GLOBAL_WILDCARD_ATTRIBUTES = [
62
  'webkitdirectory',
63
  ];
64
 
65
+ const GLOBAL_ATTRIBUTES = [ // ie-style is used by https://github.com/nuxodin/ie11CustomProperties
66
  'accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone',
67
+ 'hidden', 'id', 'ie-style', 'lang', 'spellcheck', 'style', 'tabindex', 'title',
68
  ];
69
 
70
  const GLOBAL_WILDCARD_ATTRIBUTES = [
plugin/Modules/Html/Field.php CHANGED
@@ -322,9 +322,10 @@ class Field
322
  */
323
  protected function normalizeFieldName()
324
  {
325
- $this->field['name'] = Str::convertPathToName(
326
- $this->field['path'],
327
- $this->getFieldPrefix()
328
- );
 
329
  }
330
  }
322
  */
323
  protected function normalizeFieldName()
324
  {
325
+ $name = Str::convertPathToName($this->field['path'], $this->getFieldPrefix());
326
+ if ($this->field['is_multi'] && 'checkbox' === $this->field['type']) {
327
+ $name = Str::suffix($name, '[]'); // @todo is it necessary to do this both here and in the defaults?
328
+ }
329
+ $this->field['name'] = $name;
330
  }
331
  }
plugin/Modules/Html/ReviewsHtml.php CHANGED
@@ -112,7 +112,7 @@ class ReviewsHtml extends \ArrayObject
112
  }
113
  return property_exists($this, $key)
114
  ? $this->$key
115
- : null;
116
  }
117
 
118
  /**
112
  }
113
  return property_exists($this, $key)
114
  ? $this->$key
115
+ : glsr()->filter('reviews/html/'.$key, null, $this);
116
  }
117
 
118
  /**
plugin/Modules/Html/Tags/ReviewAuthorTag.php CHANGED
@@ -12,11 +12,7 @@ class ReviewAuthorTag extends ReviewTag
12
  protected function handle($value = null)
13
  {
14
  if (!$this->isHidden()) {
15
- $tagValue = Str::convertName($value,
16
- glsr_get_option('reviews.name.format'),
17
- glsr_get_option('reviews.name.initial')
18
- );
19
- return $this->wrap($tagValue, 'span');
20
  }
21
  }
22
  }
12
  protected function handle($value = null)
13
  {
14
  if (!$this->isHidden()) {
15
+ return $this->wrap($this->review->author(), 'span');
 
 
 
 
16
  }
17
  }
18
  }
plugin/Modules/Html/Tags/ReviewAvatarTag.php CHANGED
@@ -33,8 +33,9 @@ class ReviewAvatarTag extends ReviewTag
33
  protected function handle($value = null)
34
  {
35
  if (!$this->isHidden('reviews.avatars')) {
 
36
  return $this->wrap(
37
- glsr(Avatar::class)->img($this->regenerateAvatar($value))
38
  );
39
  }
40
  }
33
  protected function handle($value = null)
34
  {
35
  if (!$this->isHidden('reviews.avatars')) {
36
+ $this->review->set('avatar', $this->regenerateAvatar($value));
37
  return $this->wrap(
38
+ glsr(Avatar::class)->img($this->review)
39
  );
40
  }
41
  }
plugin/Provider.php CHANGED
@@ -3,8 +3,25 @@
3
  namespace GeminiLabs\SiteReviews;
4
 
5
  use GeminiLabs\SiteReviews\Contracts\ProviderContract;
 
 
 
 
 
 
6
  use GeminiLabs\SiteReviews\Controllers\MainController;
7
- use GeminiLabs\SiteReviews\Database\OptionManager;
 
 
 
 
 
 
 
 
 
 
 
8
  use GeminiLabs\SiteReviews\Modules\Style;
9
  use GeminiLabs\SiteReviews\Modules\Translation;
10
  use GeminiLabs\SiteReviews\Modules\Translator;
@@ -23,6 +40,26 @@ class Provider implements ProviderContract
23
  $app->singleton(Style::class);
24
  $app->singleton(Translator::class);
25
  $app->singleton(Translation::class);
26
- $app->singleton(MainController::class); // this goes last
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
  }
3
  namespace GeminiLabs\SiteReviews;
4
 
5
  use GeminiLabs\SiteReviews\Contracts\ProviderContract;
6
+ use GeminiLabs\SiteReviews\Controllers\AdminController;
7
+ use GeminiLabs\SiteReviews\Controllers\Api\Version1\RestController;
8
+ use GeminiLabs\SiteReviews\Controllers\BlocksController;
9
+ use GeminiLabs\SiteReviews\Controllers\EditorController;
10
+ use GeminiLabs\SiteReviews\Controllers\IntegrationController;
11
+ use GeminiLabs\SiteReviews\Controllers\ListTableController;
12
  use GeminiLabs\SiteReviews\Controllers\MainController;
13
+ use GeminiLabs\SiteReviews\Controllers\MenuController;
14
+ use GeminiLabs\SiteReviews\Controllers\MetaboxController;
15
+ use GeminiLabs\SiteReviews\Controllers\NoticeController;
16
+ use GeminiLabs\SiteReviews\Controllers\PrivacyController;
17
+ use GeminiLabs\SiteReviews\Controllers\PublicController;
18
+ use GeminiLabs\SiteReviews\Controllers\ReviewController;
19
+ use GeminiLabs\SiteReviews\Controllers\RevisionController;
20
+ use GeminiLabs\SiteReviews\Controllers\SettingsController;
21
+ use GeminiLabs\SiteReviews\Controllers\TaxonomyController;
22
+ use GeminiLabs\SiteReviews\Controllers\ToolsController;
23
+ use GeminiLabs\SiteReviews\Controllers\TranslationController;
24
+ use GeminiLabs\SiteReviews\Controllers\WelcomeController;
25
  use GeminiLabs\SiteReviews\Modules\Style;
26
  use GeminiLabs\SiteReviews\Modules\Translation;
27
  use GeminiLabs\SiteReviews\Modules\Translator;
40
  $app->singleton(Style::class);
41
  $app->singleton(Translator::class);
42
  $app->singleton(Translation::class);
43
+ // Using controllers as singletons allow people to remove hooks!
44
+ $app->singleton(AdminController::class);
45
+ $app->singleton(BlocksController::class);
46
+ $app->singleton(EditorController::class);
47
+ $app->singleton(IntegrationController::class);
48
+ $app->singleton(ListTableController::class);
49
+ $app->singleton(MainController::class);
50
+ $app->singleton(MenuController::class);
51
+ $app->singleton(MetaboxController::class);
52
+ $app->singleton(NoticeController::class);
53
+ $app->singleton(PrivacyController::class);
54
+ $app->singleton(PublicController::class);
55
+ $app->singleton(RestController::class);
56
+ $app->singleton(ReviewController::class);
57
+ $app->singleton(RevisionController::class);
58
+ $app->singleton(Router::class);
59
+ $app->singleton(SettingsController::class);
60
+ $app->singleton(TaxonomyController::class);
61
+ $app->singleton(ToolsController::class);
62
+ $app->singleton(TranslationController::class);
63
+ $app->singleton(WelcomeController::class);
64
  }
65
  }
plugin/Review.php CHANGED
@@ -143,13 +143,24 @@ class Review extends Arguments
143
  ]);
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
146
  /**
147
  * @param int $size
148
  * @return string
149
  */
150
  public function avatar($size = null)
151
  {
152
- return glsr(Avatar::class)->img($this->get('avatar'), $size);
153
  }
154
 
155
  /**
143
  ]);
144
  }
145
 
146
+ /**
147
+ * @return string
148
+ */
149
+ public function author()
150
+ {
151
+ return Str::convertName($this->get('author'),
152
+ glsr_get_option('reviews.name.format'),
153
+ glsr_get_option('reviews.name.initial')
154
+ );
155
+ }
156
+
157
  /**
158
  * @param int $size
159
  * @return string
160
  */
161
  public function avatar($size = null)
162
  {
163
+ return glsr(Avatar::class)->img($this, $size);
164
  }
165
 
166
  /**
plugin/Shortcodes/Shortcode.php CHANGED
@@ -61,6 +61,7 @@ abstract class Shortcode implements ShortcodeContract
61
  'id' => $atts->id,
62
  'text' => $template,
63
  ]);
 
64
  $html = glsr(Builder::class)->div($attributes);
65
  return $args->before_widget.$atts->title.$html.$args->after_widget;
66
  }
61
  'id' => $atts->id,
62
  'text' => $template,
63
  ]);
64
+ $attributes = glsr()->filterArray('shortcode/'.$this->shortcode.'/attributes', $attributes, $this);
65
  $html = glsr(Builder::class)->div($attributes);
66
  return $args->before_widget.$atts->title.$html.$args->after_widget;
67
  }
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: geminilabs, pryley
3
  Donate link: https://www.paypal.me/pryley
4
  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.9
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -137,6 +137,15 @@ All documentation can be found in the "Help" page of the plugin. If your questio
137
 
138
  ## Changelog
139
 
 
 
 
 
 
 
 
 
 
140
  = 5.12.9 (2021-07-21) =
141
 
142
  - Fixed relative dates to use the GMT date of the review
2
  Contributors: geminilabs, pryley
3
  Donate link: https://www.paypal.me/pryley
4
  Tags: reviews, ratings, testimonials, woocommerce, product reviews
5
+ Tested up to: 5.8
6
  Requires at least: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 5.13.0
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
137
 
138
  ## Changelog
139
 
140
+ = 5.13.0 (2021-08-01) =
141
+
142
+ - Added the $review->author() method on review objects which returns the author name as defined in the settings
143
+ - Added the "site-reviews/avatar/attributes" hook which allows you to modify the attributes on the avatar <img> tag
144
+ - Internal changes to support the upcoming Review Themes add-on
145
+ - Renamed the "site-reviews/review/response" hook to "site-reviews/review/responded" (see the related FAQ section)
146
+ - Updated the "Common Problems and Solutions"
147
+ - Updated the "FAQ"
148
+
149
  = 5.12.9 (2021-07-21) =
150
 
151
  - Fixed relative dates to use the GMT date of the review
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.9
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.13.0
11
  * Author: Paul Ryley
12
  * Author URI: https://geminilabs.io
13
  * License: GPL2
views/pages/documentation/faq/notify-author-when-responding.php CHANGED
@@ -10,12 +10,14 @@
10
  * Send an email notification to the review author after responding to a review
11
  * This snippet assumes that your review form includes the email field
12
  * Paste this code in your theme's functions.php file.
13
- * @param string $response
14
  * @param \GeminiLabs\SiteReviews\Review $review
 
15
  * @return void
16
  */
17
- add_action('site-reviews/review/respond', function ($response, $review) {
18
- if (empty($response) || !empty($review->response)) {
 
 
19
  return; // only send an email if the response is not empty and there is no previous response
20
  }
21
  $email = glsr('Modules\Email')->compose([
10
  * Send an email notification to the review author after responding to a review
11
  * This snippet assumes that your review form includes the email field
12
  * Paste this code in your theme's functions.php file.
 
13
  * @param \GeminiLabs\SiteReviews\Review $review
14
+ * @param string $response
15
  * @return void
16
  */
17
+ add_action('site-reviews/review/responded', function ($review, $response) {
18
+ $hasResponse = !empty($review->response);
19
+ $hasResponseUserId = !empty(get_post_meta($review->ID, '_response_by', true));
20
+ if (empty($response) || $hasResponse || $hasResponseUserId) {
21
  return; // only send an email if the response is not empty and there is no previous response
22
  }
23
  $email = glsr('Modules\Email')->compose([
views/pages/documentation/support/common-problems-and-solutions.php CHANGED
@@ -20,7 +20,10 @@
20
  <p>You may be using a caching plugin which is caching the database and preventing Site Reviews from storing the migration status. To fix this, you will need to flush your database cache and/or object cache and then try again.</p>
21
  </li>
22
  <li>
23
- <p>You may have 3rd-party reviews that were not imported correctly. You can verify this by looking for reviews on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type); ?>">All Reviews</a></code> page that do not have any stars. Clicking on these reviews will show a read-only editor and a notice alerting you that the review is an, "Unsupported Review Type". To fix this, please delete the invalid reviews and use the provided <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-general'); ?>" data-expand="#tools-import-reviews">Import Third Party Reviews</a></code> tool to re-import them.</p>
 
 
 
24
  </li>
25
  </ol>
26
  <h3>The review form is not working, the submit button just spins.</h3>
@@ -50,7 +53,7 @@
50
  <li>The Form Request is missing a required action</li>
51
  <li>The Form Request is invalid</li>
52
  </ul>
53
- <p>To fix the nonce errors, make sure that you are not caching the review page for logged in users because Site Reviews adds a <a href="https://www.bynicolas.com/code/wordpress-nonce/" target="_blank">WordPress Nonce</a> token to the form if the user is logged in. Nonces are a standard WordPress security feature that r malicious form submissions, but they will not work if your web pages are being cached because the nonce tokens are time-sensitive and their validity expires after 12 hours.</p>
54
  <p>Alternatively, you may remove the Nonce check as shown in the FAQ page: <code><a data-expand="#faq-remove-nonce-check" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">How do I remove the WordPress Nonce check for logged in users?</a></code>.</p>
55
  </li>
56
  <li>
20
  <p>You may be using a caching plugin which is caching the database and preventing Site Reviews from storing the migration status. To fix this, you will need to flush your database cache and/or object cache and then try again.</p>
21
  </li>
22
  <li>
23
+ <p>You may have 3rd-party reviews that were not imported correctly. You can verify this by looking for reviews on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type); ?>">All Reviews</a></code> page that do not have any stars. To fix this, please delete the invalid reviews, empty the trash, and then try again. Afterwards, use the provided <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-general'); ?>" data-expand="#tools-import-reviews">Import Third Party Reviews</a></code> tool to re-import the reviews.</p>
24
+ </li>
25
+ <li>
26
+ <p>You may have reviews that were duplicated with a plugin (i.e. "Duplicate Page" plugin). Duplication plugins will not work correctly with Site Reviews because the review details are stored in a custom database table and then linked to the review; this allows Site Reviews to perform much faster database queries. To fix this, please delete the duplicated reviews, empty the trash, then try again.</p>
27
  </li>
28
  </ol>
29
  <h3>The review form is not working, the submit button just spins.</h3>
53
  <li>The Form Request is missing a required action</li>
54
  <li>The Form Request is invalid</li>
55
  </ul>
56
+ <p>To fix the nonce errors, make sure that you are not caching the review page for logged in users because Site Reviews adds a <a href="https://www.bynicolas.com/code/wordpress-nonce/" target="_blank">WordPress Nonce</a> token to the form if the user is logged in. Nonces are a standard WordPress security feature that help to prevent malicious form submissions, but they will not work if your web pages are being cached because the nonce tokens are time-sensitive and their validity expires after 12 hours.</p>
57
  <p>Alternatively, you may remove the Nonce check as shown in the FAQ page: <code><a data-expand="#faq-remove-nonce-check" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">How do I remove the WordPress Nonce check for logged in users?</a></code>.</p>
58
  </li>
59
  <li>
views/pages/welcome/whatsnew.php CHANGED
@@ -4,6 +4,7 @@
4
  <div class="is-fullwidth">
5
  <div class="glsr-flex-row">
6
  <div class="glsr-column">
 
7
  <?php include trailingslashit(__DIR__).'whatsnew/v512.php'; ?>
8
  <?php include trailingslashit(__DIR__).'whatsnew/v511.php'; ?>
9
  <?php include trailingslashit(__DIR__).'whatsnew/v510.php'; ?>
4
  <div class="is-fullwidth">
5
  <div class="glsr-flex-row">
6
  <div class="glsr-column">
7
+ <?php include trailingslashit(__DIR__).'whatsnew/v513.php'; ?>
8
  <?php include trailingslashit(__DIR__).'whatsnew/v512.php'; ?>
9
  <?php include trailingslashit(__DIR__).'whatsnew/v511.php'; ?>
10
  <?php include trailingslashit(__DIR__).'whatsnew/v510.php'; ?>
views/pages/welcome/whatsnew/v512.php CHANGED
@@ -1,6 +1,6 @@
1
- <div class="glsr-card postbox is-fullwidth open">
2
  <h3 class="glsr-card-heading">
3
- <button type="button" class="glsr-accordion-trigger" aria-expanded="true" aria-controls="welcome-v5_12_0">
4
  <span class="title">Version 5.12</span>
5
  <span class="icon"></span>
6
  </button>
1
+ <div class="glsr-card postbox is-fullwidth">
2
  <h3 class="glsr-card-heading">
3
+ <button type="button" class="glsr-accordion-trigger" aria-expanded="false" aria-controls="welcome-v5_12_0">
4
  <span class="title">Version 5.12</span>
5
  <span class="icon"></span>
6
  </button>
views/pages/welcome/whatsnew/v513.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="glsr-card postbox is-fullwidth open">
2
+ <h3 class="glsr-card-heading">
3
+ <button type="button" class="glsr-accordion-trigger" aria-expanded="true" aria-controls="welcome-v5_13_0">
4
+ <span class="title">Version 5.13</span>
5
+ <span class="icon"></span>
6
+ </button>
7
+ </h3>
8
+ <div id="welcome-v5_13_0" class="inside">
9
+ <p><em>Initial Release Date &mdash; August 1st, 2021</em></p>
10
+ <h4>✨ New Features</h4>
11
+ <ul>
12
+ <li>Added a <code>data-rating</code> attribute to the review ratings</li>
13
+ <li>Added the <code>site-reviews/avatar/attributes</code> hook which allows you to modify the attributes on the avatar &lt;img&gt; tag</li>
14
+ <li>Added the <code>$review->author()</code> method on review objects which returns the author name as defined in the settings</li>
15
+ </ul>
16
+ <h4>📢 Changes</h4>
17
+ <ul>
18
+ <li>Internal changes to support the upcoming Review Themes add-on</li>
19
+ <li>Renamed the <code>site-reviews/review/response</code> hook to <code>site-reviews/review/responded</code> (see the related FAQ section)</li>
20
+ </ul>
21
+ <h4>🛠 Tweaks</h4>
22
+ <ul>
23
+ <li>Improved the error message when saving add-on licenses to make it more descriptive and helpful.</li>
24
+ <li>Removed the "Discover Premium" button for licensed add-on users</li>
25
+ <li>Updated the "Common Problems and Solutions"</li>
26
+ <li>Updated the "FAQ"</li>
27
+ </ul>
28
+ <h4>🐞 Bugs Fixed</h4>
29
+ <ul>
30
+ <li>Fixed invalid schema output on the <code>[site_reviews]</code> shortcode when there are no reviews</li>
31
+ <li>Fixed PHP warning introduced in v5.12.7</li>
32
+ <li>Fixed relative dates to use the GMT date of the review</li>
33
+ <li>Fixed the <code>respond_to_*</code> capabilities, users can now respond to reviews if they are the author of one of the assigned posts</li>
34
+ <li>Fixed the Assigned Posts filter on the All Reviews page</li>
35
+ <li>Fixed the Bulk Edit actions</li>
36
+ <li>Fixed the filters on the "All Reviews" admin page</li>
37
+ <li>Fixed the plugin migration which sets the custom role capabilities in cases where the default WordPress roles have been renamed or removed</li>
38
+ </ul>
39
+ </div>
40
+ </div>