feat: move favicons to template media folder and clean up old locations
- Favicons now output to media/templates/site/mokoonyx/images/favicons/ - On install/update: removes old /images/favicons/ directory - On install/update: removes stale favicon files from site root Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -100,14 +100,40 @@ class Tpl_MokoonyxInstallerScript implements InstallerScriptInterface
|
||||
/**
|
||||
* Delete the favicon stamp file so favicons and site.webmanifest
|
||||
* are regenerated on the next page load after install/update.
|
||||
* Also removes the old /images/favicons/ location.
|
||||
*/
|
||||
private function clearFaviconStamp(): void
|
||||
{
|
||||
$stampFile = JPATH_ROOT . '/images/favicons/.favicon_generated';
|
||||
// Clear new location stamp
|
||||
$stampFile = JPATH_ROOT . '/media/templates/site/' . self::NEW_NAME . '/images/favicons/.favicon_generated';
|
||||
if (is_file($stampFile)) {
|
||||
@unlink($stampFile);
|
||||
$this->logMessage('Cleared favicon stamp — will regenerate on next page load.');
|
||||
}
|
||||
|
||||
// Remove old /images/favicons/ directory from previous versions
|
||||
$oldDir = JPATH_ROOT . '/images/favicons';
|
||||
if (is_dir($oldDir)) {
|
||||
$files = glob($oldDir . '/*');
|
||||
if ($files) {
|
||||
foreach ($files as $file) {
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
@unlink($oldDir . '/.favicon_generated');
|
||||
@rmdir($oldDir);
|
||||
$this->logMessage('Removed old favicon directory: images/favicons/');
|
||||
}
|
||||
|
||||
// Remove any favicon files left in the site root
|
||||
$rootFavicons = ['favicon.ico', 'favicon.png', 'apple-touch-icon.png', 'site.webmanifest'];
|
||||
foreach ($rootFavicons as $file) {
|
||||
$path = JPATH_ROOT . '/' . $file;
|
||||
if (is_file($path)) {
|
||||
@unlink($path);
|
||||
$this->logMessage('Removed root favicon: ' . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user