Skip to content

Commit 9752552

Browse files
Merge pull request #22 from ItinerisLtd/multisite-support
fix(feature): Add multisite support
2 parents 4ab42aa + ac0624b commit 9752552

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/AcornFavicons.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
class AcornFavicons
1010
{
1111
protected string $app_name = '';
12+
protected string $app_slug = '';
1213
protected string $app_url = '';
1314
protected string $manifest_path = '';
15+
protected string $prefix = '';
1416

1517
private array $faviconConfig = [
1618
'appleIcon' => [
@@ -43,6 +45,8 @@ public function __construct(
4345
private array $paths = []
4446
) {
4547
$this->app_name = htmlspecialchars_decode($this->config['appName'] ?? get_bloginfo('name'));
48+
$this->app_slug = sanitize_title($this->config['appSlug'] ?? $this->app_name);
49+
$this->prefix = is_multisite() ? "{$this->app_slug}-" : '';
4650
$this->app_url = home_url();
4751
$this->manifest_path = $this->config['manifest_path'] ?? static::MANIFEST_PATH;
4852

@@ -64,7 +68,7 @@ protected function getPublicPath(string $path, bool $addToPaths = true): ?string
6468
}
6569

6670
$webPath = rtrim(ABSPATH, '/wp');
67-
$path = ltrim($path, '/');
71+
$path = ltrim("{$this->prefix}{$path}", '/');
6872

6973
if (! file_exists($webPath . '/' . $path)) {
7074
return null;
@@ -309,12 +313,12 @@ public function serveSiteManifest(): void
309313
'theme_color' => $this->config['theme_color'] ?? '#ffffff',
310314
'icons' => [
311315
[
312-
'src' => "{$this->app_url}/android-chrome-192x192.png",
316+
'src' => "{$this->app_url}/{$this->prefix}android-chrome-192x192.png",
313317
'sizes' => '192x192',
314318
'type' => 'image/png',
315319
],
316320
[
317-
'src' => "{$this->app_url}/android-chrome-512x512.png",
321+
'src' => "{$this->app_url}/{$this->prefix}android-chrome-512x512.png",
318322
'sizes' => '512x512',
319323
'type' => 'image/png',
320324
],

0 commit comments

Comments
 (0)