forked from laysense/laysite
Seed editable default header and footer pages
This commit is contained in:
+13
-1
@@ -105,7 +105,7 @@ final class Html
|
||||
return self::bodyMarkup($body);
|
||||
}
|
||||
|
||||
public static function sharedFragment(string $html, string $scope, string $account): string
|
||||
public static function sharedFragment(string $html, string $scope, string $account, ?string $path = null): string
|
||||
{
|
||||
$document = new DOMDocument('1.0', 'UTF-8');
|
||||
$document->loadHTML('<!doctype html><html><head><meta charset="UTF-8"></head><body>' . $html . '</body></html>', LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
||||
@@ -114,6 +114,18 @@ final class Html
|
||||
return '';
|
||||
}
|
||||
self::scopeIds($body, $scope);
|
||||
if ($path !== null) {
|
||||
foreach ($body->getElementsByTagName('nav') as $nav) {
|
||||
if (!in_array('primary-nav', preg_split('/\s+/', $nav->getAttribute('class')), true)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($nav->getElementsByTagName('a') as $link) {
|
||||
if ($link->getAttribute('href') === $path) {
|
||||
$link->setAttribute('aria-current', 'page');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (iterator_to_array($body->getElementsByTagName('a')) as $node) {
|
||||
if (!in_array('studio-member-slot', preg_split('/\s+/', $node->getAttribute('class')), true)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user