Site Reviews - Version 5.10.3

Version Description

(2021-04-28) =

  • Fixed the assigned_posts meta keys which store the average rating, ranking, and review count
Download this release

Release Info

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

Code changes from version 5.10.2 to 5.10.3

languages/site-reviews-en_US.po CHANGED
@@ -1563,12 +1563,12 @@ msgctxt "admin-text"
1563
  msgid "Terms Accepted"
1564
  msgstr "Terms Accepted"
1565
 
1566
- #: plugin/Addons/Controller.php:70, plugin/Controllers/AdminController.php:48, plugin/Controllers/MenuController.php:51, views/pages/tools/sync.php:23
1567
  msgctxt "admin-text"
1568
  msgid "Settings"
1569
  msgstr "Settings"
1570
 
1571
- #: plugin/Addons/Controller.php:76, plugin/Controllers/AdminController.php:54, plugin/Controllers/MenuController.php:54
1572
  msgctxt "admin-text"
1573
  msgid "Help"
1574
  msgstr "Help"
@@ -1668,29 +1668,29 @@ msgctxt "admin-text"
1668
  msgid "Edit"
1669
  msgstr "Edit"
1670
 
1671
- #: plugin/Controllers/AdminController.php:85
1672
  msgctxt "admin-text"
1673
  msgid "%s Review"
1674
  msgid_plural "%s Reviews"
1675
  msgstr[0] "%s Review"
1676
  msgstr[1] "%s Reviews"
1677
 
1678
- #: plugin/Controllers/AdminController.php:165, plugin/Widgets/SiteReviewsWidget.php:113
1679
  msgctxt "admin-text"
1680
  msgid "Recent Reviews"
1681
  msgstr "Recent Reviews"
1682
 
1683
- #: plugin/Controllers/AdminController.php:166, plugin/Widgets/SiteReviewsFormWidget.php:78
1684
  msgctxt "admin-text"
1685
  msgid "Submit a Review"
1686
  msgstr "Submit a Review"
1687
 
1688
- #: plugin/Controllers/AdminController.php:167, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1689
  msgctxt "admin-text"
1690
  msgid "Summary of Reviews"
1691
  msgstr "Summary of Reviews"
1692
 
1693
- #: plugin/Controllers/AdminController.php:202, plugin/Controllers/AdminController.php:222, plugin/Controllers/AdminController.php:235
1694
  msgctxt "admin-text"
1695
  msgid "Nothing found."
1696
  msgstr "Nothing found."
1563
  msgid "Terms Accepted"
1564
  msgstr "Terms Accepted"
1565
 
1566
+ #: plugin/Addons/Controller.php:70, plugin/Controllers/AdminController.php:49, plugin/Controllers/MenuController.php:51, views/pages/tools/sync.php:23
1567
  msgctxt "admin-text"
1568
  msgid "Settings"
1569
  msgstr "Settings"
1570
 
1571
+ #: plugin/Addons/Controller.php:76, plugin/Controllers/AdminController.php:55, plugin/Controllers/MenuController.php:54
1572
  msgctxt "admin-text"
1573
  msgid "Help"
1574
  msgstr "Help"
1668
  msgid "Edit"
1669
  msgstr "Edit"
1670
 
1671
+ #: plugin/Controllers/AdminController.php:86
1672
  msgctxt "admin-text"
1673
  msgid "%s Review"
1674
  msgid_plural "%s Reviews"
1675
  msgstr[0] "%s Review"
1676
  msgstr[1] "%s Reviews"
1677
 
1678
+ #: plugin/Controllers/AdminController.php:167, plugin/Widgets/SiteReviewsWidget.php:113
1679
  msgctxt "admin-text"
1680
  msgid "Recent Reviews"
1681
  msgstr "Recent Reviews"
1682
 
1683
+ #: plugin/Controllers/AdminController.php:168, plugin/Widgets/SiteReviewsFormWidget.php:78
1684
  msgctxt "admin-text"
1685
  msgid "Submit a Review"
1686
  msgstr "Submit a Review"
1687
 
1688
+ #: plugin/Controllers/AdminController.php:169, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1689
  msgctxt "admin-text"
1690
  msgid "Summary of Reviews"
1691
  msgstr "Summary of Reviews"
1692
 
1693
+ #: plugin/Controllers/AdminController.php:204, plugin/Controllers/AdminController.php:224, plugin/Controllers/AdminController.php:237
1694
  msgctxt "admin-text"
1695
  msgid "Nothing found."
1696
  msgstr "Nothing found."
languages/site-reviews.pot CHANGED
@@ -1186,12 +1186,12 @@ msgstr ""
1186
  msgid "This review is based on my own experience and is my genuine opinion."
1187
  msgstr ""
1188
 
1189
- #: plugin/Addons/Controller.php:70, plugin/Controllers/AdminController.php:48, plugin/Controllers/MenuController.php:51, views/pages/tools/sync.php:23
1190
  msgctxt "admin-text"
1191
  msgid "Settings"
1192
  msgstr ""
1193
 
1194
- #: plugin/Addons/Controller.php:76, plugin/Controllers/AdminController.php:54, plugin/Controllers/MenuController.php:54
1195
  msgctxt "admin-text"
1196
  msgid "Help"
1197
  msgstr ""
@@ -1297,29 +1297,29 @@ msgctxt "admin-text"
1297
  msgid "Edit"
1298
  msgstr ""
1299
 
1300
- #: plugin/Controllers/AdminController.php:85
1301
  msgctxt "admin-text"
1302
  msgid "%s Review"
1303
  msgid_plural "%s Reviews"
1304
  msgstr[0] ""
1305
  msgstr[1] ""
1306
 
1307
- #: plugin/Controllers/AdminController.php:165, plugin/Widgets/SiteReviewsWidget.php:113
1308
  msgctxt "admin-text"
1309
  msgid "Recent Reviews"
1310
  msgstr ""
1311
 
1312
- #: plugin/Controllers/AdminController.php:166, plugin/Widgets/SiteReviewsFormWidget.php:78
1313
  msgctxt "admin-text"
1314
  msgid "Submit a Review"
1315
  msgstr ""
1316
 
1317
- #: plugin/Controllers/AdminController.php:167, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1318
  msgctxt "admin-text"
1319
  msgid "Summary of Reviews"
1320
  msgstr ""
1321
 
1322
- #: plugin/Controllers/AdminController.php:202, plugin/Controllers/AdminController.php:222, plugin/Controllers/AdminController.php:235
1323
  msgctxt "admin-text"
1324
  msgid "Nothing found."
1325
  msgstr ""
1186
  msgid "This review is based on my own experience and is my genuine opinion."
1187
  msgstr ""
1188
 
1189
+ #: plugin/Addons/Controller.php:70, plugin/Controllers/AdminController.php:49, plugin/Controllers/MenuController.php:51, views/pages/tools/sync.php:23
1190
  msgctxt "admin-text"
1191
  msgid "Settings"
1192
  msgstr ""
1193
 
1194
+ #: plugin/Addons/Controller.php:76, plugin/Controllers/AdminController.php:55, plugin/Controllers/MenuController.php:54
1195
  msgctxt "admin-text"
1196
  msgid "Help"
1197
  msgstr ""
1297
  msgid "Edit"
1298
  msgstr ""
1299
 
1300
+ #: plugin/Controllers/AdminController.php:86
1301
  msgctxt "admin-text"
1302
  msgid "%s Review"
1303
  msgid_plural "%s Reviews"
1304
  msgstr[0] ""
1305
  msgstr[1] ""
1306
 
1307
+ #: plugin/Controllers/AdminController.php:167, plugin/Widgets/SiteReviewsWidget.php:113
1308
  msgctxt "admin-text"
1309
  msgid "Recent Reviews"
1310
  msgstr ""
1311
 
1312
+ #: plugin/Controllers/AdminController.php:168, plugin/Widgets/SiteReviewsFormWidget.php:78
1313
  msgctxt "admin-text"
1314
  msgid "Submit a Review"
1315
  msgstr ""
1316
 
1317
+ #: plugin/Controllers/AdminController.php:169, plugin/Widgets/SiteReviewsSummaryWidget.php:81
1318
  msgctxt "admin-text"
1319
  msgid "Summary of Reviews"
1320
  msgstr ""
1321
 
1322
+ #: plugin/Controllers/AdminController.php:204, plugin/Controllers/AdminController.php:224, plugin/Controllers/AdminController.php:237
1323
  msgctxt "admin-text"
1324
  msgid "Nothing found."
1325
  msgstr ""
plugin/Controllers/AdminController.php CHANGED
@@ -12,6 +12,7 @@ use GeminiLabs\SiteReviews\Database;
12
  use GeminiLabs\SiteReviews\Helpers\Arr;
13
  use GeminiLabs\SiteReviews\Install;
14
  use GeminiLabs\SiteReviews\Modules\Html\Builder;
 
15
  use GeminiLabs\SiteReviews\Modules\Notice;
16
  use GeminiLabs\SiteReviews\Modules\Translation;
17
  use GeminiLabs\SiteReviews\Request;
@@ -133,6 +134,7 @@ class AdminController extends Controller
133
  {
134
  if (empty(get_option(glsr()->prefix.'activated'))) {
135
  glsr(Install::class)->run();
 
136
  update_option(glsr()->prefix.'activated', true);
137
  }
138
  }
12
  use GeminiLabs\SiteReviews\Helpers\Arr;
13
  use GeminiLabs\SiteReviews\Install;
14
  use GeminiLabs\SiteReviews\Modules\Html\Builder;
15
+ use GeminiLabs\SiteReviews\Modules\Migrate;
16
  use GeminiLabs\SiteReviews\Modules\Notice;
17
  use GeminiLabs\SiteReviews\Modules\Translation;
18
  use GeminiLabs\SiteReviews\Request;
134
  {
135
  if (empty(get_option(glsr()->prefix.'activated'))) {
136
  glsr(Install::class)->run();
137
+ glsr(Migrate::class)->run();
138
  update_option(glsr()->prefix.'activated', true);
139
  }
140
  }
plugin/Database/Sql.php CHANGED
@@ -149,8 +149,7 @@ trait Sql
149
  */
150
  protected function clauseAndAssignedPosts()
151
  {
152
- $postIds = implode(',', $this->args['assigned_posts']);
153
- return sprintf('(apt.post_id IN (%s) AND apt.is_published = 1)', $postIds);
154
  }
155
 
156
  /**
@@ -158,8 +157,7 @@ trait Sql
158
  */
159
  protected function clauseAndAssignedTerms()
160
  {
161
- $termIds = implode(',', $this->args['assigned_terms']);
162
- return sprintf('(att.term_id IN (%s))', $termIds);
163
  }
164
 
165
  /**
@@ -167,8 +165,7 @@ trait Sql
167
  */
168
  protected function clauseAndAssignedUsers()
169
  {
170
- $userIds = implode(',', $this->args['assigned_users']);
171
- return sprintf('(aut.user_id IN (%s))', $userIds);
172
  }
173
 
174
  /**
@@ -200,7 +197,7 @@ trait Sql
200
  */
201
  protected function clauseAndEmail()
202
  {
203
- return $this->db->prepare('AND r.email = %s', $this->args['email']);
204
  }
205
 
206
  /**
@@ -208,7 +205,7 @@ trait Sql
208
  */
209
  protected function clauseAndIpAddress()
210
  {
211
- return $this->db->prepare('AND r.ip_address = %s', $this->args['ip_address']);
212
  }
213
 
214
  /**
@@ -216,7 +213,7 @@ trait Sql
216
  */
217
  protected function clauseAndPostIn()
218
  {
219
- return $this->db->prepare('AND r.review_id IN (%s)', implode(',', $this->args['post__in']));
220
  }
221
 
222
  /**
@@ -224,7 +221,7 @@ trait Sql
224
  */
225
  protected function clauseAndPostNotIn()
226
  {
227
- return $this->db->prepare('AND r.review_id NOT IN (%s)', implode(',', $this->args['post__not_in']));
228
  }
229
 
230
  /**
@@ -242,7 +239,7 @@ trait Sql
242
  */
243
  protected function clauseAndStatus()
244
  {
245
- return $this->db->prepare('AND r.is_approved = %d', $this->args['status']);
246
  }
247
 
248
  /**
@@ -250,7 +247,11 @@ trait Sql
250
  */
251
  protected function clauseAndTerms()
252
  {
253
- return $this->db->prepare('AND r.terms = %d', Cast::toBool($this->args['terms']));
 
 
 
 
254
  }
255
 
256
  /**
@@ -258,7 +259,7 @@ trait Sql
258
  */
259
  protected function clauseAndType()
260
  {
261
- return $this->db->prepare('AND r.type = %s', $this->args['type']);
262
  }
263
 
264
  /**
@@ -266,7 +267,7 @@ trait Sql
266
  */
267
  protected function clauseAndUserIn()
268
  {
269
- return $this->db->prepare('AND p.post_author IN (%s)', implode(',', $this->args['user__in']));
270
  }
271
 
272
  /**
@@ -274,7 +275,27 @@ trait Sql
274
  */
275
  protected function clauseAndUserNotIn()
276
  {
277
- return $this->db->prepare('AND p.post_author NOT IN (%s)', implode(',', $this->args['user__not_in']));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  }
279
 
280
  /**
@@ -282,7 +303,11 @@ trait Sql
282
  */
283
  protected function clauseJoinAssignedPosts()
284
  {
285
- return "INNER JOIN {$this->table('assigned_posts')} AS apt ON r.ID = apt.rating_id";
 
 
 
 
286
  }
287
 
288
  /**
@@ -290,7 +315,11 @@ trait Sql
290
  */
291
  protected function clauseJoinAssignedTerms()
292
  {
293
- return "INNER JOIN {$this->table('assigned_terms')} AS att ON r.ID = att.rating_id";
 
 
 
 
294
  }
295
 
296
  /**
@@ -298,7 +327,11 @@ trait Sql
298
  */
299
  protected function clauseJoinAssignedUsers()
300
  {
301
- return "INNER JOIN {$this->table('assigned_users')} AS aut ON r.ID = aut.rating_id";
 
 
 
 
302
  }
303
 
304
  /**
@@ -306,8 +339,10 @@ trait Sql
306
  */
307
  protected function clauseJoinDate()
308
  {
309
- return Helper::ifTrue(!empty(array_filter($this->args['date'])),
310
- "INNER JOIN {$this->db->posts} AS p ON r.review_id = p.ID"
 
 
311
  );
312
  }
313
 
@@ -316,7 +351,11 @@ trait Sql
316
  */
317
  protected function clauseJoinUserIn()
318
  {
319
- return "INNER JOIN {$this->db->posts} AS p ON r.review_id = p.ID";
 
 
 
 
320
  }
321
 
322
  /**
@@ -324,7 +363,11 @@ trait Sql
324
  */
325
  protected function clauseJoinUserNotIn()
326
  {
327
- return "INNER JOIN {$this->db->posts} AS p ON r.review_id = p.ID";
 
 
 
 
328
  }
329
 
330
  /**
149
  */
150
  protected function clauseAndAssignedPosts()
151
  {
152
+ return $this->clauseIfValueNotEmpty('(apt.post_id IN (%s) AND apt.is_published = 1)', $this->args['assigned_posts']);
 
153
  }
154
 
155
  /**
157
  */
158
  protected function clauseAndAssignedTerms()
159
  {
160
+ return $this->clauseIfValueNotEmpty('(att.term_id IN (%s))', $this->args['assigned_terms']);
 
161
  }
162
 
163
  /**
165
  */
166
  protected function clauseAndAssignedUsers()
167
  {
168
+ return $this->clauseIfValueNotEmpty('(aut.user_id IN (%s))', $this->args['assigned_users']);
 
169
  }
170
 
171
  /**
197
  */
198
  protected function clauseAndEmail()
199
  {
200
+ return $this->clauseIfValueNotEmpty('AND r.email = %s', $this->args['email']);
201
  }
202
 
203
  /**
205
  */
206
  protected function clauseAndIpAddress()
207
  {
208
+ return $this->clauseIfValueNotEmpty('AND r.ip_address = %s', $this->args['ip_address']);
209
  }
210
 
211
  /**
213
  */
214
  protected function clauseAndPostIn()
215
  {
216
+ return $this->clauseIfValueNotEmpty('AND r.review_id IN (%s)', $this->args['post__in']);
217
  }
218
 
219
  /**
221
  */
222
  protected function clauseAndPostNotIn()
223
  {
224
+ return $this->clauseIfValueNotEmpty('AND r.review_id NOT IN (%s)', $this->args['post__not_in']);
225
  }
226
 
227
  /**
239
  */
240
  protected function clauseAndStatus()
241
  {
242
+ return $this->clauseIfValueNotEmpty('AND r.is_approved = %d', $this->args['status']);
243
  }
244
 
245
  /**
247
  */
248
  protected function clauseAndTerms()
249
  {
250
+ if (Helper::isEmpty($this->args['terms'])) {
251
+ return '';
252
+ }
253
+ $value = Cast::toInt(Cast::toBool($this->args['terms']));
254
+ return $this->clauseIfValueNotEmpty('AND r.terms = %d', $value);
255
  }
256
 
257
  /**
259
  */
260
  protected function clauseAndType()
261
  {
262
+ return $this->clauseIfValueNotEmpty('AND r.type = %s', $this->args['type']);
263
  }
264
 
265
  /**
267
  */
268
  protected function clauseAndUserIn()
269
  {
270
+ return $this->clauseIfValueNotEmpty('AND p.post_author IN (%s)', $this->args['user__in']);
271
  }
272
 
273
  /**
275
  */
276
  protected function clauseAndUserNotIn()
277
  {
278
+ return $this->clauseIfValueNotEmpty('AND p.post_author NOT IN (%s)', $this->args['user__not_in']);
279
+ }
280
+
281
+ /**
282
+ * @param string $clause
283
+ * @param array|int|string $value
284
+ * @param bool $prepare
285
+ * @return string
286
+ */
287
+ protected function clauseIfValueNotEmpty($clause, $value, $prepare = true)
288
+ {
289
+ if (Helper::isEmpty($value)) {
290
+ return '';
291
+ }
292
+ if (!$prepare) {
293
+ return $clause;
294
+ }
295
+ if (is_array($value)) {
296
+ $value = implode(',', $value);
297
+ }
298
+ return $this->db->prepare($clause, $value);
299
  }
300
 
301
  /**
303
  */
304
  protected function clauseJoinAssignedPosts()
305
  {
306
+ return $this->clauseIfValueNotEmpty(
307
+ "INNER JOIN {$this->table('assigned_posts')} AS apt ON r.ID = apt.rating_id",
308
+ $this->args['assigned_posts'],
309
+ $prepare = false
310
+ );
311
  }
312
 
313
  /**
315
  */
316
  protected function clauseJoinAssignedTerms()
317
  {
318
+ return $this->clauseIfValueNotEmpty(
319
+ "INNER JOIN {$this->table('assigned_terms')} AS att ON r.ID = att.rating_id",
320
+ $this->args['assigned_terms'],
321
+ $prepare = false
322
+ );
323
  }
324
 
325
  /**
327
  */
328
  protected function clauseJoinAssignedUsers()
329
  {
330
+ return $this->clauseIfValueNotEmpty(
331
+ "INNER JOIN {$this->table('assigned_users')} AS aut ON r.ID = aut.rating_id",
332
+ $this->args['assigned_users'],
333
+ $prepare = false
334
+ );
335
  }
336
 
337
  /**
339
  */
340
  protected function clauseJoinDate()
341
  {
342
+ return $this->clauseIfValueNotEmpty(
343
+ "INNER JOIN {$this->db->posts} AS p ON r.review_id = p.ID",
344
+ array_filter($this->args['date']),
345
+ $prepare = false
346
  );
347
  }
348
 
351
  */
352
  protected function clauseJoinUserIn()
353
  {
354
+ return $this->clauseIfValueNotEmpty(
355
+ "INNER JOIN {$this->db->posts} AS p ON r.review_id = p.ID",
356
+ $this->args['user__in'],
357
+ $prepare = false
358
+ );
359
  }
360
 
361
  /**
363
  */
364
  protected function clauseJoinUserNotIn()
365
  {
366
+ return $this->clauseIfValueNotEmpty(
367
+ "INNER JOIN {$this->db->posts} AS p ON r.review_id = p.ID",
368
+ $this->args['user__not_in'],
369
+ $prepare = false
370
+ );
371
  }
372
 
373
  /**
plugin/Modules/Migrations/Migrate_5_10_3.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GeminiLabs\SiteReviews\Modules\Migrations;
4
+
5
+ use GeminiLabs\SiteReviews\Database\CountManager;
6
+
7
+ class Migrate_5_10_3
8
+ {
9
+ /**
10
+ * @return bool
11
+ */
12
+ public function run()
13
+ {
14
+ glsr(CountManager::class)->recalculate();
15
+ return true;
16
+ }
17
+ }
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.10.2
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -135,6 +135,10 @@ All documentation can be found in the "Help" page of the plugin. If your questio
135
 
136
  ## Changelog
137
 
 
 
 
 
138
  = 5.10.2 (2021-04-27) =
139
 
140
  - Fixed the missing "terms" database column error for users who have not run the plugin migration from previous versions
5
  Tested up to: 5.7
6
  Requires at least: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 5.10.3
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
135
 
136
  ## Changelog
137
 
138
+ = 5.10.3 (2021-04-28) =
139
+
140
+ - Fixed the assigned_posts meta keys which store the average rating, ranking, and review count
141
+
142
  = 5.10.2 (2021-04-27) =
143
 
144
  - Fixed the missing "terms" database column error for users who have not run the plugin migration from previous versions
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.10.2
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.10.3
11
  * Author: Paul Ryley
12
  * Author URI: https://geminilabs.io
13
  * License: GPL2