Files
WP-Multi-Wiki/templates/admin/dashboard.php
2026-03-18 21:56:40 +01:00

147 lines
6.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<div class="wrap wmw-admin-wrap">
<div class="wmw-admin-header">
<div class="wmw-admin-header__logo">
<span class="wmw-admin-header__icon">📚</span>
<div>
<h1>WP Multi Wiki</h1>
<p>Verwalte alle deine Plugin-Wikis an einem Ort.</p>
</div>
</div>
<div class="wmw-admin-header__actions">
<a href="<?php echo admin_url('admin.php?page=wmw-new-wiki'); ?>" class="button button-primary wmw-btn-lg">
Neues Wiki erstellen
</a>
</div>
</div>
<!-- Stats Bar -->
<div class="wmw-stats-bar">
<div class="wmw-stat">
<span class="wmw-stat__num"><?php echo count($wikis); ?></span>
<span class="wmw-stat__label">Wikis</span>
</div>
<div class="wmw-stat">
<span class="wmw-stat__num"><?php echo $total_articles; ?></span>
<span class="wmw-stat__label">Artikel gesamt</span>
</div>
<div class="wmw-stat">
<span class="wmw-stat__num"><?php echo wp_count_terms('wmw_category'); ?></span>
<span class="wmw-stat__label">Kategorien</span>
</div>
</div>
<!-- Quick Search -->
<div class="wmw-admin-search-bar">
<input type="text" id="wmw-filter-wikis" placeholder="🔍 Wikis filtern…" class="regular-text">
</div>
<?php if ( empty( $wikis ) ) : ?>
<div class="wmw-empty-state">
<div class="wmw-empty-state__icon">📖</div>
<h2>Noch keine Wikis vorhanden</h2>
<p>Erstelle dein erstes Wiki für dein Plugin!</p>
<a href="<?php echo admin_url('admin.php?page=wmw-new-wiki'); ?>" class="button button-primary button-hero">
Erstes Wiki erstellen
</a>
</div>
<?php else : ?>
<div class="wmw-wiki-grid" id="wmw-wiki-grid">
<?php foreach ( $wikis as $wiki ) :
$wiki_id = $wiki->ID;
$articles = wmw_get_articles( $wiki_id );
$article_count = count( $articles );
$icon = wmw_get_wiki_icon( $wiki_id );
$color = wmw_get_wiki_color( $wiki_id );
$version = get_post_meta( $wiki_id, '_wmw_version', true ) ?: '1.0.0';
$edit_url = admin_url( 'admin.php?page=wmw-edit-wiki&id=' . $wiki_id );
$new_art_url = admin_url( 'admin.php?page=wmw-new-article&wiki_id=' . $wiki_id );
$articles_url = admin_url( 'admin.php?page=wmw-articles&wiki_id=' . $wiki_id );
$view_url = get_permalink( $wiki_id );
?>
<div class="wmw-wiki-card" data-title="<?php echo esc_attr( strtolower( $wiki->post_title ) ); ?>" style="--wiki-color: <?php echo esc_attr($color); ?>">
<div class="wmw-wiki-card__header">
<span class="wmw-wiki-card__icon"><?php echo $icon; ?></span>
<div class="wmw-wiki-card__meta">
<span class="wmw-wiki-card__version">v<?php echo esc_html($version); ?></span>
<span class="wmw-wiki-card__status <?php echo $wiki->post_status === 'publish' ? 'is-live' : 'is-draft'; ?>">
<?php echo $wiki->post_status === 'publish' ? '● Live' : '○ Entwurf'; ?>
</span>
</div>
</div>
<h3 class="wmw-wiki-card__title"><?php echo esc_html( $wiki->post_title ); ?></h3>
<?php if ( $wiki->post_excerpt ) : ?>
<p class="wmw-wiki-card__desc"><?php echo esc_html( wp_trim_words( $wiki->post_excerpt, 12 ) ); ?></p>
<?php endif; ?>
<div class="wmw-wiki-card__stats">
<span>📄 <?php echo $article_count; ?> Artikel</span>
</div>
<div class="wmw-wiki-card__actions">
<a href="<?php echo esc_url($edit_url); ?>" class="button button-small">✏️ Bearbeiten</a>
<a href="<?php echo esc_url($articles_url); ?>" class="button button-small">📋 Artikel</a>
<a href="<?php echo esc_url($new_art_url); ?>" class="button button-small button-primary"> Artikel</a>
<a href="<?php echo esc_url($view_url); ?>" target="_blank" class="button button-small">🔗 Ansehen</a>
<button class="button button-small wmw-delete-wiki" data-id="<?php echo $wiki_id; ?>" data-title="<?php echo esc_attr($wiki->post_title); ?>">🗑️</button>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<!-- Shortcode Reference -->
<div class="wmw-shortcode-ref">
<h3>📋 Shortcode-Referenz</h3>
<div class="wmw-shortcode-grid">
<div class="wmw-shortcode-item">
<code>[wmw_wiki_list]</code>
<span>Alle Wikis als Karten anzeigen</span>
</div>
<div class="wmw-shortcode-item">
<code>[wmw_wiki id="1"]</code>
<span>Ein Wiki mit allen Artikeln</span>
</div>
<div class="wmw-shortcode-item">
<code>[wmw_wiki slug="mein-plugin"]</code>
<span>Wiki per Slug einbinden</span>
</div>
<div class="wmw-shortcode-item">
<code>[wmw_search wiki_id="1"]</code>
<span>Suchfeld für ein Wiki</span>
</div>
<div class="wmw-shortcode-item">
<code>[wmw_article id="5"]</code>
<span>Einzelnen Artikel einbetten</span>
</div>
<div class="wmw-shortcode-item">
<code>[wmw_breadcrumb]</code>
<span>Breadcrumb-Navigation</span>
</div>
</div>
</div>
</div>
<!-- Suchindex -->
<div class="wmw-shortcode-ref" style="margin-top:16px">
<h3>🔍 Suchindex</h3>
<p class="description">Falls die Suche keine Ergebnisse liefert (z.B. nach einem Gitea-Import), den Index neu aufbauen.</p>
<button id="wmw-reindex-btn" class="button button-secondary">🔄 Suchindex neu aufbauen</button>
<span id="wmw-reindex-result" style="margin-left:12px;font-weight:600"></span>
</div>
<script>
jQuery(function($){
$('#wmw-reindex-btn').on('click', function(){
var $btn = $(this);
var $res = $('#wmw-reindex-result');
$btn.prop('disabled', true).text('⏳ Läuft…');
$.post(wmwAdmin.ajaxUrl, { action: 'wmw_reindex', nonce: wmwAdmin.nonce }, function(res){
$btn.prop('disabled', false).text('🔄 Suchindex neu aufbauen');
if(res.success){ $res.css('color','#2e7d32').text('✅ ' + res.data.message); }
else { $res.css('color','#c62828').text('❌ Fehler'); }
});
});
});
</script>