(admin): show the sidebar page only if the theme support it

This commit is contained in:
Kazhnuz 2025-01-18 19:34:20 +01:00
parent 9dd82a6015
commit e26aaa72b9
5 changed files with 34 additions and 2 deletions

View file

@ -12,6 +12,7 @@ First forked version from bludit
### Added
- Admin: Added a sidebar panel that show all sidebar widget to be activated/deactivated
- Admin: Show some pages only if the theme support their features
### Changed

View file

@ -35,9 +35,11 @@
<li class="nav-item">
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'themes' ?>"><span class="fa fa-desktop fa-fw"></span><?php $L->p('Themes') ?></a>
</li>
<?php if (Theme::supports("sidebar", false)): ?>
<li class="nav-item">
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'sidebar' ?>"><span class="fa fa-list fa-fw"></span><?php $L->p('Sidebar') ?></a>
</li>
<?php endif; ?>
<li class="nav-item mt-3">
<h4><?php $L->p('Settings') ?></h4>

View file

@ -282,4 +282,31 @@ class Theme
// https://github.com/psfpro/bootstrap-html5sortable
return '<script ' . $attributes . ' src="' . DOMAIN_CORE_JS . 'jquery.sortable.min.js?version=' . KOBLOG_VERSION . '"></script>' . PHP_EOL;
}
public static function supports($featureToCheck, $verifySidebar = true)
{
global $site;
global $themes;
$themeName = $site->theme();
if (isset($themes)) {
foreach ($themes as $theme) {
if ($theme['dirname'] == $site->theme()) {
if (isset($theme['supports'])) {
foreach ($theme['supports'] as $feature) {
if ($featureToCheck == $feature) {
return true;
}
if ($verifySidebar && $feature == "sidebar") {
// TODO: add check to see if a plugin support it in the sidebar
return true;
}
}
return false;
}
}
}
}
return false;
}
}

View file

@ -7,5 +7,6 @@
"license": "MIT",
"compatible": "3.15",
"notes": "",
"plugin": "alternative"
"plugin": "alternative",
"supports": []
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"supports": ["sidebar"]
}