Update from Git Manager GUI
This commit is contained in:
56
templates/sidebar.php
Normal file
56
templates/sidebar.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
global $post;
|
||||
$current_id = $post ? $post->ID : 0;
|
||||
?>
|
||||
<div class="wmw-sidebar-nav">
|
||||
<div class="wmw-sidebar-nav__wiki">
|
||||
<a href="<?php echo get_permalink($wiki->ID); ?>" class="wmw-sidebar-nav__wiki-link">
|
||||
<span class="wmw-sidebar-nav__wiki-icon"><?php echo wmw_get_wiki_icon($wiki->ID); ?></span>
|
||||
<span class="wmw-sidebar-nav__wiki-name"><?php echo esc_html($wiki->post_title); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// Group articles by category
|
||||
$grouped = array();
|
||||
$cat_names = array();
|
||||
|
||||
foreach ($articles as $art) {
|
||||
$cats = get_the_terms($art->ID, 'wmw_category');
|
||||
if ($cats && !is_wp_error($cats)) {
|
||||
foreach ($cats as $cat) {
|
||||
$grouped[$cat->term_id][] = $art;
|
||||
$cat_names[$cat->term_id] = $cat->name;
|
||||
}
|
||||
} else {
|
||||
$grouped['_none'][] = $art;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort: named categories first, then uncategorized
|
||||
ksort($grouped);
|
||||
|
||||
foreach ($grouped as $cat_id => $cat_arts):
|
||||
$cat_label = $cat_id === '_none' ? 'Allgemein' : ($cat_names[$cat_id] ?? 'Sonstige');
|
||||
|
||||
// Sort by order
|
||||
usort($cat_arts, function($a,$b){
|
||||
$oa = (int)get_post_meta($a->ID,'_wmw_order',true);
|
||||
$ob = (int)get_post_meta($b->ID,'_wmw_order',true);
|
||||
return $oa - $ob;
|
||||
});
|
||||
?>
|
||||
<div class="wmw-sidebar-nav__group">
|
||||
<div class="wmw-sidebar-nav__group-label"><?php echo esc_html($cat_label); ?></div>
|
||||
<ul class="wmw-sidebar-nav__list">
|
||||
<?php foreach ($cat_arts as $art): ?>
|
||||
<li class="wmw-sidebar-nav__item <?php echo ($art->ID === $current_id) ? 'is-active' : ''; ?>">
|
||||
<a href="<?php echo get_permalink($art->ID); ?>" class="wmw-sidebar-nav__link">
|
||||
<?php echo esc_html($art->post_title); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user