Version Description
(2021-10-06) =
- Fixed Initials Avatars
- Fixed Pixel Avatars
Download this release
Release Info
Developer | geminilabs |
Plugin | Site Reviews |
Version | 5.16.2 |
Comparing to | |
See all releases |
Code changes from version 5.16.1 to 5.16.2
- languages/site-reviews-en_US.po +1 -1
- languages/site-reviews.pot +1 -1
- plugin/Modules/Avatar.php +10 -16
- plugin/Modules/Avatars/InitialsAvatar.php +49 -0
- plugin/Modules/{PixelAvatar.php → Avatars/PixelAvatar.php} +16 -5
- plugin/Modules/Avatars/SvgAvatar.php +59 -0
- readme.txt +6 -1
- site-reviews.php +1 -1
languages/site-reviews-en_US.po
CHANGED
@@ -170,7 +170,7 @@ msgstr "and"
|
|
170 |
msgid "Show less"
|
171 |
msgstr "Show less"
|
172 |
|
173 |
-
#: plugin/Modules/Avatar.php:
|
174 |
msgid "Avatar for %s"
|
175 |
msgstr "Avatar for %s"
|
176 |
|
170 |
msgid "Show less"
|
171 |
msgstr "Show less"
|
172 |
|
173 |
+
#: plugin/Modules/Avatar.php:115
|
174 |
msgid "Avatar for %s"
|
175 |
msgstr "Avatar for %s"
|
176 |
|
languages/site-reviews.pot
CHANGED
@@ -2066,7 +2066,7 @@ msgstr ""
|
|
2066 |
msgid "Show less"
|
2067 |
msgstr ""
|
2068 |
|
2069 |
-
#: plugin/Modules/Avatar.php:
|
2070 |
msgid "Avatar for %s"
|
2071 |
msgstr ""
|
2072 |
|
2066 |
msgid "Show less"
|
2067 |
msgstr ""
|
2068 |
|
2069 |
+
#: plugin/Modules/Avatar.php:115
|
2070 |
msgid "Avatar for %s"
|
2071 |
msgstr ""
|
2072 |
|
plugin/Modules/Avatar.php
CHANGED
@@ -6,8 +6,9 @@ use GeminiLabs\SiteReviews\Helper;
|
|
6 |
use GeminiLabs\SiteReviews\Helpers\Arr;
|
7 |
use GeminiLabs\SiteReviews\Helpers\Cast;
|
8 |
use GeminiLabs\SiteReviews\Helpers\Str;
|
|
|
|
|
9 |
use GeminiLabs\SiteReviews\Modules\Html\Builder;
|
10 |
-
use GeminiLabs\SiteReviews\Modules\PixelAvatar;
|
11 |
use GeminiLabs\SiteReviews\Review;
|
12 |
|
13 |
class Avatar
|
@@ -66,6 +67,9 @@ class Avatar
|
|
66 |
public function generate($review, $size = 0)
|
67 |
{
|
68 |
$default = $this->fallbackDefault($review);
|
|
|
|
|
|
|
69 |
$size = $this->size($size);
|
70 |
$avatarUrl = get_avatar_url($this->userField($review), [
|
71 |
'default' => $default,
|
@@ -74,10 +78,9 @@ class Avatar
|
|
74 |
if (!$this->isUrl($avatarUrl)) {
|
75 |
return $this->fallbackUrl($review, $size);
|
76 |
}
|
77 |
-
if (
|
78 |
-
|
79 |
-
|
80 |
-
}
|
81 |
}
|
82 |
return $avatarUrl;
|
83 |
}
|
@@ -88,13 +91,7 @@ class Avatar
|
|
88 |
*/
|
89 |
public function generateInitials($review)
|
90 |
{
|
91 |
-
|
92 |
-
if (mb_strlen($initials) === 1) {
|
93 |
-
$initials = mb_substr(trim($review->author), 0, 2, 'UTF-8');
|
94 |
-
$initials = mb_strtoupper($initials, 'UTF-8');
|
95 |
-
}
|
96 |
-
$contents = $this->svgContent($initials);
|
97 |
-
return $this->svg($contents, $initials);
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -103,10 +100,7 @@ class Avatar
|
|
103 |
*/
|
104 |
public function generatePixels($review)
|
105 |
{
|
106 |
-
|
107 |
-
$hash = substr($hash, 0, 15);
|
108 |
-
$contents = glsr(PixelAvatar::class)->generate($hash);
|
109 |
-
return $this->svg($contents, $hash);
|
110 |
}
|
111 |
|
112 |
/**
|
6 |
use GeminiLabs\SiteReviews\Helpers\Arr;
|
7 |
use GeminiLabs\SiteReviews\Helpers\Cast;
|
8 |
use GeminiLabs\SiteReviews\Helpers\Str;
|
9 |
+
use GeminiLabs\SiteReviews\Modules\Avatars\InitialsAvatar;
|
10 |
+
use GeminiLabs\SiteReviews\Modules\Avatars\PixelAvatar;
|
11 |
use GeminiLabs\SiteReviews\Modules\Html\Builder;
|
|
|
12 |
use GeminiLabs\SiteReviews\Review;
|
13 |
|
14 |
class Avatar
|
67 |
public function generate($review, $size = 0)
|
68 |
{
|
69 |
$default = $this->fallbackDefault($review);
|
70 |
+
if ($default !== $this->type) {
|
71 |
+
$default = '404';
|
72 |
+
}
|
73 |
$size = $this->size($size);
|
74 |
$avatarUrl = get_avatar_url($this->userField($review), [
|
75 |
'default' => $default,
|
78 |
if (!$this->isUrl($avatarUrl)) {
|
79 |
return $this->fallbackUrl($review, $size);
|
80 |
}
|
81 |
+
if (404 === Helper::remoteStatusCheck($avatarUrl)) {
|
82 |
+
// @todo generate the images with javascript on canvas to avoid this status check
|
83 |
+
return $this->fallbackUrl($review, $size);
|
|
|
84 |
}
|
85 |
return $avatarUrl;
|
86 |
}
|
91 |
*/
|
92 |
public function generateInitials($review)
|
93 |
{
|
94 |
+
return glsr(InitialsAvatar::class)->create($review->author);
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
/**
|
100 |
*/
|
101 |
public function generatePixels($review)
|
102 |
{
|
103 |
+
return glsr(PixelAvatar::class)->create($this->userField($review));
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
/**
|
plugin/Modules/Avatars/InitialsAvatar.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace GeminiLabs\SiteReviews\Modules\Avatars;
|
4 |
+
|
5 |
+
use GeminiLabs\SiteReviews\Helpers\Arr;
|
6 |
+
use GeminiLabs\SiteReviews\Helpers\Cast;
|
7 |
+
use GeminiLabs\SiteReviews\Helpers\Str;
|
8 |
+
|
9 |
+
class InitialsAvatar extends SvgAvatar
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* @param string $from
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function generate($from)
|
16 |
+
{
|
17 |
+
$colors = [
|
18 |
+
['background' => '#e3effb', 'color' => '#134d92'], // blue
|
19 |
+
['background' => '#e1f0ee', 'color' => '#125960'], // green
|
20 |
+
['background' => '#ffeff7', 'color' => '#ba3a80'], // pink
|
21 |
+
['background' => '#fcece3', 'color' => '#a14326'], // red
|
22 |
+
['background' => '#faf7d9', 'color' => '#da9640'], // yellow
|
23 |
+
];
|
24 |
+
$colors = glsr()->filterArray('avatar/colors', $colors);
|
25 |
+
shuffle($colors);
|
26 |
+
$color = Cast::toArray(Arr::get($colors, 0));
|
27 |
+
$data = wp_parse_args($color, [
|
28 |
+
'background' => '#dcdce6',
|
29 |
+
'color' => '#6f6f87',
|
30 |
+
'text' => $this->filename($from),
|
31 |
+
]);
|
32 |
+
return trim(glsr()->build('avatar', $data));
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @param string $from
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
protected function filename($from)
|
40 |
+
{
|
41 |
+
$initials = Str::convertToInitials($from);
|
42 |
+
if (mb_strlen($initials) === 1) {
|
43 |
+
$initials = mb_substr(trim($from), 0, 2, 'UTF-8');
|
44 |
+
$initials = mb_strtoupper($initials, 'UTF-8');
|
45 |
+
}
|
46 |
+
$initials = mb_substr($initials, 0, 2, 'UTF-8');
|
47 |
+
return $initials;
|
48 |
+
}
|
49 |
+
}
|
plugin/Modules/{PixelAvatar.php → Avatars/PixelAvatar.php}
RENAMED
@@ -5,9 +5,9 @@
|
|
5 |
* @see: https://www.binarymoon.co.uk/2020/08/pixel-avatars-a-privacy-first-gravatar-replacement/
|
6 |
*/
|
7 |
|
8 |
-
namespace GeminiLabs\SiteReviews\Modules;
|
9 |
|
10 |
-
class PixelAvatar
|
11 |
{
|
12 |
const HEIGHT = 11;
|
13 |
const WIDTH = 11;
|
@@ -313,13 +313,13 @@ class PixelAvatar
|
|
313 |
];
|
314 |
|
315 |
/**
|
316 |
-
* @param string $
|
317 |
* @return string
|
318 |
*/
|
319 |
-
public function generate($
|
320 |
{
|
321 |
$this->data = $this->newData();
|
322 |
-
$this->hash = $
|
323 |
$this->hashIndex = 0;
|
324 |
$this->addBody();
|
325 |
$this->addFace();
|
@@ -424,6 +424,17 @@ class PixelAvatar
|
|
424 |
);
|
425 |
}
|
426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
/**
|
428 |
* @param int $saturation
|
429 |
* @param int $lightness
|
5 |
* @see: https://www.binarymoon.co.uk/2020/08/pixel-avatars-a-privacy-first-gravatar-replacement/
|
6 |
*/
|
7 |
|
8 |
+
namespace GeminiLabs\SiteReviews\Modules\Avatars;
|
9 |
|
10 |
+
class PixelAvatar extends SvgAvatar
|
11 |
{
|
12 |
const HEIGHT = 11;
|
13 |
const WIDTH = 11;
|
313 |
];
|
314 |
|
315 |
/**
|
316 |
+
* @param string $from
|
317 |
* @return string
|
318 |
*/
|
319 |
+
public function generate($from)
|
320 |
{
|
321 |
$this->data = $this->newData();
|
322 |
+
$this->hash = $this->filename($from);
|
323 |
$this->hashIndex = 0;
|
324 |
$this->addBody();
|
325 |
$this->addFace();
|
424 |
);
|
425 |
}
|
426 |
|
427 |
+
/**
|
428 |
+
* @param string $from
|
429 |
+
* @return string
|
430 |
+
*/
|
431 |
+
protected function filename($from)
|
432 |
+
{
|
433 |
+
$hash = md5(strtolower(trim($from)));
|
434 |
+
$hash = substr($hash, 0, 15);
|
435 |
+
return $hash;
|
436 |
+
}
|
437 |
+
|
438 |
/**
|
439 |
* @param int $saturation
|
440 |
* @param int $lightness
|
plugin/Modules/Avatars/SvgAvatar.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace GeminiLabs\SiteReviews\Modules\Avatars;
|
4 |
+
|
5 |
+
abstract class SvgAvatar
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @param string $from
|
9 |
+
* @return string
|
10 |
+
*/
|
11 |
+
public function create($from)
|
12 |
+
{
|
13 |
+
return $this->save($this->generate($from), $this->filename($from));
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param string $from
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
abstract public function generate($from);
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param string $from
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
abstract protected function filename($from);
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param string $contents
|
30 |
+
* @param string $name
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
protected function save($contents, $name)
|
34 |
+
{
|
35 |
+
$uploadsDir = wp_upload_dir();
|
36 |
+
$baseDir = trailingslashit($uploadsDir['basedir']);
|
37 |
+
$baseUrl = trailingslashit($uploadsDir['baseurl']);
|
38 |
+
$pathDir = trailingslashit(glsr()->id).trailingslashit('avatars');
|
39 |
+
$filename = sprintf('%s.svg', $name);
|
40 |
+
$filepath = $baseDir.$pathDir.$filename;
|
41 |
+
if (!file_exists($filepath)) {
|
42 |
+
wp_mkdir_p($baseDir.$pathDir);
|
43 |
+
$fp = @fopen($filepath, 'wb');
|
44 |
+
if (false === $fp) {
|
45 |
+
return '';
|
46 |
+
}
|
47 |
+
mbstring_binary_safe_encoding();
|
48 |
+
$dataLength = strlen($contents);
|
49 |
+
$bytesWritten = fwrite($fp, $contents);
|
50 |
+
reset_mbstring_encoding();
|
51 |
+
fclose($fp);
|
52 |
+
if ($dataLength !== $bytesWritten) {
|
53 |
+
return '';
|
54 |
+
}
|
55 |
+
chmod($filepath, (fileperms(ABSPATH.'index.php') & 0777 | 0644));
|
56 |
+
}
|
57 |
+
return set_url_scheme($baseUrl.$pathDir.$filename);
|
58 |
+
}
|
59 |
+
}
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ 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.16.
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -138,6 +138,11 @@ All documentation can be found in the "Help" page of the plugin. If your questio
|
|
138 |
|
139 |
## Changelog
|
140 |
|
|
|
|
|
|
|
|
|
|
|
141 |
= 5.16.1 (2021-10-04) =
|
142 |
|
143 |
- Added compatibility fix for Review Themes v1.0.0-beta4
|
5 |
Tested up to: 5.8
|
6 |
Requires at least: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 5.16.2
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
138 |
|
139 |
## Changelog
|
140 |
|
141 |
+
= 5.16.2 (2021-10-06) =
|
142 |
+
|
143 |
+
- Fixed Initials Avatars
|
144 |
+
- Fixed Pixel Avatars
|
145 |
+
|
146 |
= 5.16.1 (2021-10-04) =
|
147 |
|
148 |
- Added compatibility fix for Review Themes v1.0.0-beta4
|
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.16.
|
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.16.2
|
11 |
* Author: Paul Ryley
|
12 |
* Author URI: https://geminilabs.io
|
13 |
* License: GPL2
|