diff --git a/admin/css/wmw-admin.css b/admin/css/wmw-admin.css new file mode 100644 index 0000000..0b11d5f --- /dev/null +++ b/admin/css/wmw-admin.css @@ -0,0 +1,145 @@ +/* ─── WP Multi Wiki — Admin CSS ─────────────────────────────────────── */ +:root { + --wmw-admin-accent: #2271b1; + --wmw-admin-bg: #f6f7f7; + --wmw-admin-border: #dcdcde; + --wmw-admin-radius: 8px; + --wmw-admin-shadow: 0 1px 4px rgba(0,0,0,.08); +} + +/* ─── Layout ─────────────────────────────────────────────────────────── */ +.wmw-admin-wrap { max-width: 1400px; } + +.wmw-admin-header { + display: flex; align-items: center; justify-content: space-between; + padding: 20px 0 16px; margin-bottom: 20px; + border-bottom: 2px solid var(--wmw-admin-border); +} +.wmw-admin-header--small { padding: 12px 0 12px; } +.wmw-admin-header__logo { display: flex; align-items: center; gap: 14px; } +.wmw-admin-header__icon { font-size: 36px; line-height: 1; } +.wmw-admin-header h1 { margin: 0 0 2px; font-size: 22px; } +.wmw-admin-header p { margin: 0; color: #666; font-size: 13px; } +.wmw-admin-header__actions { display: flex; gap: 8px; flex-wrap: wrap; } + +.wmw-form-layout { + display: grid; + grid-template-columns: 1fr 300px; + gap: 20px; + margin-top: 16px; +} +@media(max-width:960px){ .wmw-form-layout { grid-template-columns: 1fr; } } + +/* ─── Stats Bar ──────────────────────────────────────────────────────── */ +.wmw-stats-bar { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap:wrap; } +.wmw-stat { + background: #fff; border: 1px solid var(--wmw-admin-border); + border-radius: var(--wmw-admin-radius); padding: 14px 20px; + display: flex; flex-direction: column; align-items: center; min-width: 90px; + box-shadow: var(--wmw-admin-shadow); +} +.wmw-stat__num { font-size: 28px; font-weight: 700; color: var(--wmw-admin-accent); line-height: 1; } +.wmw-stat__label { font-size: 11px; color: #888; margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; } + +/* ─── Cards ──────────────────────────────────────────────────────────── */ +.wmw-card { + background: #fff; border: 1px solid var(--wmw-admin-border); + border-radius: var(--wmw-admin-radius); padding: 20px; + margin-bottom: 16px; box-shadow: var(--wmw-admin-shadow); +} +.wmw-card__title { margin: 0 0 16px; font-size: 14px; font-weight: 600; padding-bottom: 10px; border-bottom: 1px solid var(--wmw-admin-border); } + +/* ─── Wiki Grid ──────────────────────────────────────────────────────── */ +.wmw-wiki-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); + gap: 16px; margin: 16px 0 24px; +} +.wmw-wiki-card { + background: #fff; border: 1px solid var(--wmw-admin-border); + border-radius: var(--wmw-admin-radius); padding: 18px; + box-shadow: var(--wmw-admin-shadow); transition: box-shadow .2s, transform .2s; + border-top: 3px solid var(--wiki-color, var(--wmw-admin-accent)); +} +.wmw-wiki-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-2px); } +.wmw-wiki-card__header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; } +.wmw-wiki-card__icon { font-size: 28px; line-height: 1; } +.wmw-wiki-card__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; } +.wmw-wiki-card__version{ font-size: 11px; background: var(--wmw-admin-bg); border-radius: 4px; padding: 1px 6px; color: #666; } +.wmw-wiki-card__status { font-size: 10px; font-weight: 600; letter-spacing: .3px; } +.wmw-wiki-card__status.is-live { color: #2e7d32; } +.wmw-wiki-card__status.is-draft { color: #9e6c00; } +.wmw-wiki-card__title { font-size: 15px; font-weight: 700; margin: 0 0 5px; color: #1e1e1e; } +.wmw-wiki-card__desc { font-size: 12px; color: #757575; margin: 0 0 10px; line-height: 1.4; } +.wmw-wiki-card__stats { font-size: 11px; color: #888; margin-bottom: 12px; } +.wmw-wiki-card__actions{ display: flex; flex-wrap: wrap; gap: 4px; } +.wmw-wiki-card__actions .button { font-size: 11px !important; padding: 2px 8px !important; } + +/* ─── Filter / Search ────────────────────────────────────────────────── */ +.wmw-admin-search-bar { margin-bottom: 12px; } +.wmw-filter-bar { margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 6px; } +.wmw-mb { margin-bottom: 12px; } + +/* ─── Empty State ────────────────────────────────────────────────────── */ +.wmw-empty-state { + text-align: center; padding: 60px 20px; + background: #fff; border: 2px dashed var(--wmw-admin-border); + border-radius: 12px; margin: 20px 0; +} +.wmw-empty-state__icon { font-size: 56px; margin-bottom: 12px; } +.wmw-empty-state h2 { color: #555; margin-bottom: 8px; } +.wmw-empty-state p { color: #888; margin-bottom: 20px; } + +/* ─── Forms / Fields ─────────────────────────────────────────────────── */ +.wmw-field { margin-bottom: 16px; } +.wmw-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: #1e1e1e; } +.required { color: #d63638; } +.wmw-cat-list{ max-height: 160px; overflow-y: auto; border: 1px solid var(--wmw-admin-border); border-radius: 4px; padding: 8px; } +.wmw-checkbox{ display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 0; cursor: pointer; } +.wmw-btn-full{ width: 100%; justify-content: center; margin-bottom: 0 !important; } +.wmw-btn-lg { height: 36px; font-size: 13px; } +.wmw-mt-sm { margin-top: 8px !important; display: block; text-align: center; } + +/* ─── Emoji Picker ───────────────────────────────────────────────────── */ +.wmw-emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; } +.wmw-emoji-btn { background: var(--wmw-admin-bg); border: 1px solid var(--wmw-admin-border); border-radius: 4px; padding: 4px 6px; font-size: 18px; cursor: pointer; line-height: 1; transition: background .15s; } +.wmw-emoji-btn:hover { background: #e2e8f0; } + +/* ─── Badges ─────────────────────────────────────────────────────────── */ +.wmw-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; letter-spacing: .3px; text-transform: uppercase; } +.wmw-badge--green { background: #e8f5e9; color: #2e7d32; } +.wmw-badge--gray { background: #f0f0f0; color: #757575; } + +/* ─── Shortcode Reference ────────────────────────────────────────────── */ +.wmw-shortcode-ref { background: #fff; border: 1px solid var(--wmw-admin-border); border-radius: var(--wmw-admin-radius); padding: 20px; margin-top: 20px; } +.wmw-shortcode-ref h3 { margin: 0 0 14px; } +.wmw-shortcode-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 10px; } +.wmw-shortcode-item { background: var(--wmw-admin-bg); border-radius: 6px; padding: 10px 14px; } +.wmw-shortcode-item code { display: block; font-size: 12px; color: #c0392b; margin-bottom: 4px; font-family: monospace; } +.wmw-shortcode-item span { font-size: 12px; color: #555; } + +/* ─── Article Table ──────────────────────────────────────────────────── */ +.wmw-article-table-wrap { background: #fff; border-radius: var(--wmw-admin-radius); overflow: hidden; border: 1px solid var(--wmw-admin-border); } +.wmw-article-table th, .wmw-article-table td { vertical-align: middle !important; } + +/* ─── Wiki-Form Sidebar: Plugin-Info & Status Fix ────────────────────── */ +.wmw-form-sidebar .wmw-card input[type="text"], +.wmw-form-sidebar .wmw-card input[type="number"], +.wmw-form-sidebar .wmw-card select { + width: 100%; + padding: 8px 10px; + border: 1px solid var(--wmw-admin-border); + border-radius: 4px; + background: var(--wmw-admin-bg); + color: #1e1e1e; + font-size: 13px; + box-sizing: border-box; +} +.wmw-form-sidebar .wmw-card input[type="text"]:focus, +.wmw-form-sidebar .wmw-card select:focus { + border-color: var(--wmw-admin-accent); + outline: none; + box-shadow: 0 0 0 2px rgba(34,113,177,.15); +} +/* Status-Dropdown Checkmark-Icon korrekt anzeigen */ +.wmw-form-sidebar select option { padding: 4px; } \ No newline at end of file diff --git a/admin/js/wmw-admin.js b/admin/js/wmw-admin.js new file mode 100644 index 0000000..31d108a --- /dev/null +++ b/admin/js/wmw-admin.js @@ -0,0 +1,169 @@ +/* jshint esversion: 6 */ +jQuery(function ($) { + 'use strict'; + + // ── Color Picker ────────────────────────────────────────────────────── + $('.wmw-color-picker').wpColorPicker(); + + // ── Emoji Picker ───────────────────────────────────────────────────── + $(document).on('click', '.wmw-emoji-btn', function () { + var emoji = $(this).data('emoji'); + $('#wmw_icon').val(emoji); + }); + + // ── Live Filter – Wiki Grid ─────────────────────────────────────────── + $('#wmw-filter-wikis').on('input', function () { + var q = $(this).val().toLowerCase(); + $('.wmw-wiki-card').each(function () { + var title = $(this).data('title') || ''; + $(this).toggle(title.includes(q)); + }); + }); + + // ── Live Filter – Article Table ─────────────────────────────────────── + $('#wmw-filter-articles').on('input', function () { + var q = $(this).val().toLowerCase(); + $('.wmw-article-table tbody tr').each(function () { + var title = $(this).data('title') || ''; + $(this).toggle(title.includes(q)); + }); + }); + + // ── Save Wiki ───────────────────────────────────────────────────────── + $('#wmw-save-wiki').on('click', function () { + var $btn = $(this); + var id = $btn.data('id'); + + var data = { + action: 'wmw_save_wiki', + nonce: wmwAdmin.nonce, + id: id, + title: $('#wmw_title').val().trim(), + description: '', + icon: $('#wmw_icon').val(), + color: $('#wmw_color').val(), + version: $('[name="wmw_version"]').val(), + status: $('[name="wmw_status"]').val(), + }; + + // Get TinyMCE content if available + if (typeof tinymce !== 'undefined' && tinymce.get('wmw_description')) { + data.description = tinymce.get('wmw_description').getContent(); + } else { + data.description = $('[name="wmw_description"]').val() || ''; + } + + if (!data.title) { + alert('Bitte gib einen Titel ein.'); + return; + } + + showSaving(); + $.post(wmwAdmin.ajaxUrl, data, function (res) { + hideSaving(); + if (res.success) { + if (!id) { + window.location.href = ajaxurl.replace('admin-ajax.php','') + 'admin.php?page=wmw-edit-wiki&id=' + res.data.id + '&wmw_saved=1'; + } else { + showNotice('✅ Wiki gespeichert!', 'success'); + } + } else { + showNotice('❌ Fehler: ' + (res.data && res.data.message ? res.data.message : 'Unbekannter Fehler'), 'error'); + } + }); + }); + + // ── Save Article ────────────────────────────────────────────────────── + $('#wmw-save-article').on('click', function () { + var $btn = $(this); + var id = $btn.data('id'); + + var cats = []; + $('[name="wmw_categories[]"]:checked').each(function () { cats.push($(this).val()); }); + + var content = ''; + if (typeof tinymce !== 'undefined' && tinymce.get('wmw_content')) { + content = tinymce.get('wmw_content').getContent(); + } else { + content = $('[name="wmw_content"]').val() || ''; + } + + var data = { + action: 'wmw_save_article', + nonce: wmwAdmin.nonce, + id: id, + title: $('#wmw_a_title').val().trim(), + content: content, + excerpt: $('#wmw_a_excerpt').val(), + wiki_id: $('#wmw_a_wiki_id').val(), + categories: cats, + tags: $('#wmw_a_tags').val(), + status: $('#wmw_a_status').val(), + order: $('#wmw_a_order').val(), + }; + + if (!data.title) { alert('Bitte gib einen Titel ein.'); return; } + if (!data.wiki_id) { alert('Bitte wähle ein Wiki aus.'); return; } + + showSaving(); + $.post(wmwAdmin.ajaxUrl, data, function (res) { + hideSaving(); + if (res.success) { + if (!id) { + var base = wmwAdmin.ajaxUrl.replace('admin-ajax.php', ''); + window.location.href = base + 'admin.php?page=wmw-edit-article&id=' + res.data.id + '&wmw_saved=1'; + } else { + showNotice('✅ Artikel gespeichert!', 'success'); + } + } else { + showNotice('❌ ' + (res.data && res.data.message ? res.data.message : 'Fehler'), 'error'); + } + }); + }); + + // ── Delete Wiki ─────────────────────────────────────────────────────── + $(document).on('click', '.wmw-delete-wiki', function (e) { + e.preventDefault(); + var $btn = $(this); + var id = $btn.data('id'); + var title = $btn.data('title'); + if (!confirm('Wiki "' + title + '" und ALLE Artikel darin löschen?')) return; + + $.post(wmwAdmin.ajaxUrl, { action: 'wmw_delete_wiki', nonce: wmwAdmin.nonce, id: id }, function (res) { + if (res.success) { + $btn.closest('.wmw-wiki-card').fadeOut(300, function () { $(this).remove(); }); + } else { + alert('Fehler beim Löschen.'); + } + }); + }); + + // ── Delete Article ──────────────────────────────────────────────────── + $(document).on('click', '.wmw-delete-article', function (e) { + e.preventDefault(); + if (!confirm(wmwAdmin.confirm_delete)) return; + var $el = $(this); + var id = $el.data('id'); + + $.post(wmwAdmin.ajaxUrl, { action: 'wmw_delete_article', nonce: wmwAdmin.nonce, id: id }, function (res) { + if (res.success) { + $el.closest('tr').fadeOut(300, function () { $(this).remove(); }); + } + }); + }); + + // ── Helpers ─────────────────────────────────────────────────────────── + function showSaving() { + if (!$('#wmw-saving-overlay').length) { + $('body').append('
' + msg + '