Fix custom CSS injection so base styles always load

This commit is contained in:
AudioCore Bot
2026-03-05 17:25:09 +00:00
parent af6bb638ac
commit 2eaa61654b

View File

@@ -13,7 +13,8 @@ $seoDefaultDescription = trim(Settings::get('seo_meta_description', ''));
$seoRobotsIndex = Settings::get('seo_robots_index', '1') === '1' ? 'index' : 'noindex'; $seoRobotsIndex = Settings::get('seo_robots_index', '1') === '1' ? 'index' : 'noindex';
$seoRobotsFollow = Settings::get('seo_robots_follow', '1') === '1' ? 'follow' : 'nofollow'; $seoRobotsFollow = Settings::get('seo_robots_follow', '1') === '1' ? 'follow' : 'nofollow';
$seoOgImage = trim(Settings::get('seo_og_image', '')); $seoOgImage = trim(Settings::get('seo_og_image', ''));
$siteCustomCss = (string)Settings::get('site_custom_css', ''); $siteCustomCssRaw = (string)Settings::get('site_custom_css', '');
$siteCustomCss = preg_replace('~<\s*/?\s*style\b[^>]*>~i', '', $siteCustomCssRaw) ?? $siteCustomCssRaw;
$pageTitleValue = trim((string)($pageTitle ?? $siteTitleSetting)); $pageTitleValue = trim((string)($pageTitle ?? $siteTitleSetting));
$metaTitle = $pageTitleValue; $metaTitle = $pageTitleValue;
if ($seoTitleSuffix !== '' && stripos($pageTitleValue, $seoTitleSuffix) === false) { if ($seoTitleSuffix !== '' && stripos($pageTitleValue, $seoTitleSuffix) === false) {
@@ -527,10 +528,12 @@ if (session_status() === PHP_SESSION_ACTIVE && isset($_SESSION['ac_site_notice']
padding-top: 2px; padding-top: 2px;
} }
} }
<?php if (trim($siteCustomCss) !== ''): ?>
<?= str_replace('</style', '</ style', $siteCustomCss) . "\n" ?>
<?php endif; ?>
</style> </style>
<?php if (trim($siteCustomCss) !== ''): ?>
<style id="ac-custom-css">
<?= $siteCustomCss . "\n" ?>
</style>
<?php endif; ?>
</head> </head>
<body> <body>
<?php require __DIR__ . '/../partials/header.php'; ?> <?php require __DIR__ . '/../partials/header.php'; ?>