From e417f31c99599151acbf6555eb9c46e777a60972 Mon Sep 17 00:00:00 2001
From: M_Viper
Date: Mon, 30 Mar 2026 20:42:44 +0200
Subject: [PATCH] Update from Git Manager GUI
---
Minecraft-Modern-Theme/inc/assistant-ajax.php | 169 +++++++++++++++---
.../inc/assistant-widget.php | 155 +++++++++++-----
Minecraft-Modern-Theme/inc/customizer.php | 66 +++++--
3 files changed, 303 insertions(+), 87 deletions(-)
diff --git a/Minecraft-Modern-Theme/inc/assistant-ajax.php b/Minecraft-Modern-Theme/inc/assistant-ajax.php
index 7efff11..2a298f9 100644
--- a/Minecraft-Modern-Theme/inc/assistant-ajax.php
+++ b/Minecraft-Modern-Theme/inc/assistant-ajax.php
@@ -110,26 +110,39 @@ function mm_assistant_query() {
$player_name = mm_extract_player_name( $q );
- foreach ( $active as $intent => $score ) {
- // Ban-Intent dominant → Regeln nicht zusätzlich auslösen
- if ( $intent === 'rules' && isset( $intents['ban_check'] ) && $intents['ban_check'] >= 25 ) {
- continue;
+ // Wenn Discord-Intent erkannt wurde, NUR diesen ausführen
+ if (isset($active['discord'])) {
+ $result = mm_handle_intent('discord', $q, $q_lc, $player_name, $bot);
+ if ($result) {
+ $parts[] = $result;
+ }
+ } elseif (isset($active['team'])) {
+ $result = mm_handle_intent('team', $q, $q_lc, $player_name, $bot);
+ if ($result) {
+ $parts[] = $result;
+ }
+ } else {
+ foreach ( $active as $intent => $score ) {
+ // Ban-Intent dominant → Regeln nicht zusätzlich auslösen
+ if ( $intent === 'rules' && isset( $intents['ban_check'] ) && $intents['ban_check'] >= 25 ) {
+ continue;
+ }
+ // Ban-Intent dominant → Shop/Ticket/Forum nicht zusätzlich auslösen
+ if ( in_array( $intent, array( 'shop', 'ticket', 'forum' ), true )
+ && isset( $intents['ban_check'] ) && $intents['ban_check'] >= 40 ) {
+ continue;
+ }
+ // Player-History dominant → Server-Status nicht zusätzlich auslösen
+ if ( $intent === 'server_status'
+ && isset( $intents['player_history'] ) && $intents['player_history'] >= 15 ) {
+ continue;
+ }
+ $result = mm_handle_intent( $intent, $q, $q_lc, $player_name, $bot );
+ if ( $result ) {
+ $parts[] = $result;
+ }
+ }
}
- // Ban-Intent dominant → Shop/Ticket/Forum nicht zusätzlich auslösen
- if ( in_array( $intent, array( 'shop', 'ticket', 'forum' ), true )
- && isset( $intents['ban_check'] ) && $intents['ban_check'] >= 40 ) {
- continue;
- }
- // Player-History dominant → Server-Status nicht zusätzlich auslösen
- if ( $intent === 'server_status'
- && isset( $intents['player_history'] ) && $intents['player_history'] >= 15 ) {
- continue;
- }
- $result = mm_handle_intent( $intent, $q, $q_lc, $player_name, $bot );
- if ( $result ) {
- $parts[] = $result;
- }
- }
if ( empty( $parts ) ) {
$parts[] = mm_fallback_response( $bot );
@@ -163,7 +176,19 @@ function mm_score_intents( $q_lc, $q_raw ) {
'forum' => 0,
'gallery' => 0,
'faq' => 0,
+ 'discord' => 0,
+ 'team' => 0,
];
+ // Team
+ foreach ([
+ 'team', 'teammitglieder', 'admins', 'moderatoren', 'wer ist im team', 'wer sind die admins', 'wer sind die moderatoren', 'serverteam', 'staff', 'supporter', 'admin', 'mod', 'leitung', 'server leitung', 'wer ist staff', 'wer ist admin', 'wer ist mod'
+ ] as $kw) {
+ if (strpos($q_lc, $kw) !== false) $scores['team'] += 20;
+ }
+ // Discord
+ foreach (['discord', 'dc', 'discord link', 'discord einladung', 'discord server', 'discord invite'] as $kw) {
+ if (strpos($q_lc, $kw) !== false) $scores['discord'] += 20;
+ }
// Server-Status
foreach ( ['ip', 'adresse', 'join', 'einloggen', 'verbinden', 'server ip',
@@ -250,9 +275,12 @@ function mm_score_intents( $q_lc, $q_raw ) {
$scores['gallery'] += 20;
}
- // FAQ
- foreach ( ['faq', 'häufige frage', 'frequently', 'oft gefragt'] as $kw ) {
- if ( strpos( $q_lc, $kw ) !== false ) $scores['faq'] += 10;
+ // FAQ: Mehr Keywords und höheres Scoring, damit typische Fragen wie "Wie ...?", "Was ...?", "Wieso ...?", "Erklärung ..." erkannt werden
+ foreach ([
+ 'faq', 'häufige frage', 'frequently', 'oft gefragt',
+ 'wie ', 'was ', 'wieso ', 'wo ', 'wer ', 'hilfe', 'erklärung', 'funktioniert', 'bedeutet', 'nutzen', 'benutzen', 'erkläre', 'erklärt', 'erfahre', 'erfahren', 'frage', 'fragen', 'hilfe', 'problem', 'tipp', 'tipps', 'anleitung', 'erläutere', 'erläutert', 'erläutern', 'erläutere', 'erläutert', 'erläutern', 'beschreibe', 'beschreibt', 'beschreiben', 'beschreibe', 'beschreibt', 'beschreiben', 'wie kann', 'wie mache', 'wie mache ich', 'wie funktioniert', 'wie nutze', 'wie benutze', 'wie setze', 'wie entferne', 'wie öffne', 'wie melde', 'wie erreiche', 'wie akzeptiere', 'wie fordere', 'wie wechsle', 'wie sehe', 'wie teleportiere', 'wie sende', 'wie setze ich', 'wie entferne ich', 'wie öffne ich', 'wie melde ich', 'wie erreiche ich', 'wie akzeptiere ich', 'wie fordere ich', 'wie wechsle ich', 'wie sehe ich', 'wie teleportiere ich', 'wie sende ich'
+ ] as $kw) {
+ if ( strpos( $q_lc, $kw ) !== false ) $scores['faq'] += 18;
}
return $scores;
@@ -274,8 +302,87 @@ function mm_handle_intent( $intent, $q, $q_lc, $player_name, $bot ) {
case 'forum': return mm_intent_forum( $q );
case 'gallery': return mm_intent_gallery( $bot, $q_lc );
case 'faq': return mm_intent_faq( $q );
+ case 'discord': return mm_intent_discord( $bot );
+ case 'team': return mm_intent_team();
+ }
+}
+
+// ============================================================
+// INTENT: TEAM
+// ============================================================
+function mm_intent_team() {
+ $query = new WP_Query( array(
+ 'post_type' => 'team_member',
+ 'posts_per_page' => -1,
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC',
+ ) );
+ if ( ! $query->have_posts() ) {
+ return [
+ 'source' => 'team',
+ 'title' => '👥 Team',
+ 'content' => 'Es wurden noch keine Teammitglieder eingetragen.',
+ ];
+ }
+ $html = '';
+ $html .= '
👥 Team
';
+ while ( $query->have_posts() ) {
+ $query->the_post();
+ $name = get_the_title();
+ $rank = get_post_meta( get_the_ID(), '_team_member_rank', true );
+ $uuid = get_post_meta( get_the_ID(), '_team_member_uuid', true );
+ $img = get_the_post_thumbnail_url( get_the_ID(), 'medium' );
+ $desc = get_the_excerpt();
+ $avatar = '';
+ if ( $uuid ) {
+ $avatar = 'https://visage.surgeplay.com/bust/' . esc_attr( $uuid ) . '.png';
+ } elseif ( $img ) {
+ $avatar = $img;
+ }
+ $html .= '
';
+ if ( $avatar ) {
+ $html .= '
 . ')
';
+ } else {
+ $html .= '
' . esc_html( mb_substr( $name, 0, 1 ) ) . '
';
+ }
+ $html .= '
';
+ $html .= '
' . esc_html( $name ) . '
';
+ if ( $rank ) {
+ $html .= '
' . esc_html( $rank ) . '
';
+ }
+ if ( $desc ) {
+ $html .= '
' . esc_html( $desc ) . '
';
+ }
+ $html .= '
';
+ $html .= '
';
+ }
+ $html .= '
';
+ wp_reset_postdata();
+ return [
+ 'source' => 'team',
+ 'title' => '👥 Team',
+ 'content' => $html,
+ ];
+}
+// ============================================================
+// INTENT: DISCORD
+// ============================================================
+
+function mm_intent_discord( $bot ) {
+ $discord = $bot['link_discord'] ?? '';
+ if ( ! empty( $discord ) ) {
+ return [
+ 'source' => 'discord',
+ 'title' => '💬 Discord',
+ 'content' => 'Hier ist der Discord-Einladungslink:
' . esc_html( $discord ) . '',
+ ];
+ } else {
+ return [
+ 'source' => 'discord',
+ 'title' => '💬 Discord',
+ 'content' => 'Es wurde kein Discord-Link im Backend hinterlegt.',
+ ];
}
- return null;
}
// ============================================================
@@ -1889,17 +1996,21 @@ function mm_intent_faq( $q ) {
if ( empty( $results ) ) return null;
- $html = [];
+ $html = '';
foreach ( $results as $post ) {
- $excerpt = get_the_excerpt( $post->ID );
- $html[] = '❓
' . esc_html( $post->post_title ) . ''
- . ( $excerpt ? '
' . wp_trim_words( $excerpt, 40, '…' ) : '' );
+ $title = esc_html( $post->post_title );
+ $content = apply_filters( 'the_content', $post->post_content );
+ $html .= '
';
+ $html .= '
' . $title . '
';
+ $html .= '
' . $content . '
';
+ $html .= '
';
}
+ $html .= '
';
return [
'source' => 'faq',
- 'title' => '❓ FAQ',
- 'content' => implode( '
', $html ),
+ 'title' => 'FAQ',
+ 'content' => $html,
];
}
diff --git a/Minecraft-Modern-Theme/inc/assistant-widget.php b/Minecraft-Modern-Theme/inc/assistant-widget.php
index 5142cb4..5bdc670 100644
--- a/Minecraft-Modern-Theme/inc/assistant-widget.php
+++ b/Minecraft-Modern-Theme/inc/assistant-widget.php
@@ -1,4 +1,10 @@
prepare( 'post_content LIKE %s', '%[' . $wpdb->esc_like( $sc ) . '%' );
+ }
+ if ( empty( $conditions ) ) return '';
+ $where = implode( ' OR ', $conditions );
+ $page = $wpdb->get_row(
+ "SELECT ID FROM {$wpdb->posts}
+ WHERE post_status = 'publish'
+ AND post_type IN ('page','post')
+ AND ({$where})
+ LIMIT 1"
+ );
+ return $page ? get_permalink( $page->ID ) : '';
+}
+endif;
+
function mm_render_bot_admin() {
$data = get_option( 'mm_bot_data', [] );
?>
@@ -166,25 +197,6 @@ function mm_render_bot_admin() {
prepare( 'post_content LIKE %s', '%[' . $wpdb->esc_like( $sc ) . '%' );
- }
- if ( empty( $conditions ) ) return '';
- $where = implode( ' OR ', $conditions );
- $page = $wpdb->get_row(
- "SELECT ID FROM {$wpdb->posts}
- WHERE post_status = 'publish'
- AND post_type IN ('page','post')
- AND ({$where})
- LIMIT 1"
- );
- return $page ? get_permalink( $page->ID ) : '';
- }
-
$autodetect = [
'url_wiki' => mm_find_page_by_shortcode( ['wmw_wiki', 'wmw_search', 'wmw_article'] ),
'url_rules' => mm_find_page_by_shortcode( ['mrp_rules', 'mc_rules', 'multi_rules'] ),
@@ -390,8 +402,17 @@ add_action( 'wp_enqueue_scripts', function () {
add_action( 'wp_footer', 'mm_bot_render_widget', 50 );
function mm_bot_render_widget() {
- $data = get_option( 'mm_bot_data', [] );
- $uuid = sanitize_text_field( trim( get_theme_mod( 'assistant_minecraft_uuid', 'Steve' ) ) );
+ // Sichtbarkeit prüfen: Assistent nur anzeigen, wenn im Customizer aktiviert
+ // BUG-FIX: Early return MUSS als erstes kommen, bevor andere Variablen gelesen werden.
+ if ( ! get_theme_mod( 'assistant_enabled', false ) ) {
+ return;
+ }
+ $data = get_option( 'mm_bot_data', [] );
+ $uuid = sanitize_text_field( trim( get_theme_mod( 'assistant_minecraft_uuid', 'Steve' ) ) );
+ // BUG-FIX: $avatar_view muss VOR $body_offset definiert werden.
+ $avatar_view = get_theme_mod( 'assistant_avatar_view', 'head' );
+ // Offset für Chat-Fenster, wenn Ganzkörper-Avatar aktiv ist
+ $body_offset = ( $avatar_view === 'body' ) ? 'margin-right: 60px;' : '';
$name = ! empty( $data['bot_name'] ) ? esc_html( $data['bot_name'] ) : 'Viper-Bot';
$welcome = ! empty( $data['welcome'] ) ? $data['welcome'] : 'Hallo! Wie kann ich dir helfen? 👋';
$nonce = wp_create_nonce( 'mm_bot_nonce' );
@@ -454,17 +475,29 @@ function mm_bot_render_widget() {
}
?>
-
+
+
-
+
@@ -501,9 +534,27 @@ function mm_bot_render_widget() {
-
@@ -615,35 +666,43 @@ function mm_bot_render_widget() {
/* ── Wrapper ── */
#mm-bot-root {
position: fixed;
- bottom: 30px;
- right: 30px;
z-index: 999999;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
+ /* Positionsklassen */
+ #mm-bot-root.mm-bot-pos-bottom_right { bottom: 30px; right: 100px; }
+ #mm-bot-root.mm-bot-pos-bottom_left { bottom: 90px; left: 30px; }
+ #mm-bot-root.mm-bot-pos-top_right { top: 30px; right: 30px; }
+ #mm-bot-root.mm-bot-pos-top_left { top: 30px; left: 30px; }
+
+ /* Chat-Fenster dynamisch positionieren */
+ #mm-bot-root.mm-bot-pos-bottom_right #mm-bot-chat { bottom: 78px; right: 0; left: auto; top: auto; }
+ #mm-bot-root.mm-bot-pos-bottom_left #mm-bot-chat { bottom: 78px; left: 0; right: auto; top: auto; }
+ #mm-bot-root.mm-bot-pos-top_right #mm-bot-chat { top: 78px; right: 0; left: auto; bottom: auto; }
+ #mm-bot-root.mm-bot-pos-top_left #mm-bot-chat { top: 78px; left: 0; right: auto; bottom: auto; }
/* ── Launcher ── */
#mm-bot-launcher {
- background: #0099ff;
- border: none;
- border-radius: 50%;
- width: 62px;
- height: 62px;
- cursor: pointer;
- box-shadow: 0 4px 16px rgba(0,153,255,.45);
- transition: transform .25s, box-shadow .25s;
+ background: transparent !important;
+ border: none !important;
+ box-shadow: none !important;
+ width: auto !important;
+ height: auto !important;
+ padding: 0 !important;
display: flex;
align-items: center;
justify-content: center;
- overflow: hidden;
- }
- #mm-bot-launcher:hover {
- transform: scale(1.1);
- box-shadow: 0 6px 22px rgba(0,153,255,.6);
+ overflow: visible;
+ border-radius: 0 !important;
+ cursor: pointer;
+ transition: none;
}
#mm-bot-launcher img {
- width: 44px;
- height: 44px;
- border-radius: 4px;
+ width: 60px;
+ height: 60px;
+ border-radius: 8px;
+ background: none !important;
+ box-shadow: none !important;
}
/* ── Chat-Fenster ── */
diff --git a/Minecraft-Modern-Theme/inc/customizer.php b/Minecraft-Modern-Theme/inc/customizer.php
index 9b9ff86..45cfb16 100644
--- a/Minecraft-Modern-Theme/inc/customizer.php
+++ b/Minecraft-Modern-Theme/inc/customizer.php
@@ -103,29 +103,75 @@ function minecraft_modern_customize_register( $wp_customize ) {
// =========================================================================
// 9. Virtueller Assistent
// =========================================================================
+ // BUG-FIX: add_section() muss VOR add_setting()/add_control() stehen.
+ // Vorher war add_setting/add_control für 'assistant_avatar_view' aufgerufen
+ // bevor die Section 'assistant_settings' überhaupt registriert war.
$wp_customize->add_section( 'assistant_settings', array(
- 'title' => __('Virtueller Assistent', 'minecraft-modern-theme'),
- 'priority' => 80,
- 'description' => __('Steuert den virtuellen Assistenten im Frontend. Avatar basiert auf Minecraft-UUID.', 'minecraft-modern-theme'),
+ 'title' => __( 'Virtueller Assistent', 'minecraft-modern-theme' ),
+ 'priority' => 80,
+ 'description' => __( 'Steuert den virtuellen Assistenten im Frontend. Avatar basiert auf Minecraft-UUID.', 'minecraft-modern-theme' ),
) );
+
$wp_customize->add_setting( 'assistant_enabled', array(
- 'default' => false,
+ 'default' => false,
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'assistant_enabled', array(
- 'label' => __('Virtuellen Assistenten aktivieren', 'minecraft-modern-theme'),
+ 'label' => __( 'Virtuellen Assistenten aktivieren', 'minecraft-modern-theme' ),
'section' => 'assistant_settings',
- 'type' => 'checkbox',
+ 'type' => 'checkbox',
) );
+
$wp_customize->add_setting( 'assistant_minecraft_uuid', array(
- 'default' => '',
+ 'default' => '',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'assistant_minecraft_uuid', array(
- 'label' => __('Minecraft UUID für Avatar', 'minecraft-modern-theme'),
+ 'label' => __( 'Minecraft UUID für Avatar', 'minecraft-modern-theme' ),
+ 'section' => 'assistant_settings',
+ 'type' => 'text',
+ 'description' => __( 'Gib die Minecraft-UUID für den Avatar des Assistenten ein.', 'minecraft-modern-theme' ),
+ ) );
+
+ $wp_customize->add_setting( 'assistant_avatar_view', array(
+ 'default' => 'head',
+ 'sanitize_callback' => function ( $v ) {
+ return in_array( $v, array( 'head', 'body', '3dhead' ), true ) ? $v : 'head';
+ },
+ ) );
+ $wp_customize->add_control( 'assistant_avatar_view', array(
+ 'label' => __( 'Avatar-Ansicht', 'minecraft-modern-theme' ),
+ 'section' => 'assistant_settings',
+ 'type' => 'select',
+ 'choices' => array(
+ 'head' => __( 'Kopf', 'minecraft-modern-theme' ),
+ 'body' => __( 'Ganzkörper', 'minecraft-modern-theme' ),
+ '3dhead' => __( '3D Kopf', 'minecraft-modern-theme' ),
+ ),
+ 'description' => __( 'Wähle, wie der Minecraft-Avatar im Assistenten angezeigt wird.', 'minecraft-modern-theme' ),
+ ) );
+
+ // BUG-FIX: assistant_position war in assistant-widget.php in einem eigenen
+ // customize_register-Hook registriert – also BEVOR diese Section existierte.
+ // Jetzt korrekt hier innerhalb von minecraft_modern_customize_register().
+ $wp_customize->add_setting( 'assistant_position', array(
+ 'default' => 'bottom_right',
+ 'transport' => 'refresh',
+ 'sanitize_callback' => function ( $v ) {
+ $allowed = array( 'bottom_right', 'bottom_left', 'top_right', 'top_left' );
+ return in_array( $v, $allowed, true ) ? $v : 'bottom_right';
+ },
+ ) );
+ $wp_customize->add_control( 'assistant_position', array(
+ 'label' => __( 'Position des Assistenten', 'minecraft-modern-theme' ),
'section' => 'assistant_settings',
- 'type' => 'text',
- 'description' => __('Gib die Minecraft-UUID für den Avatar des Assistenten ein.', 'minecraft-modern-theme'),
+ 'type' => 'select',
+ 'choices' => array(
+ 'bottom_right' => __( 'Unten rechts', 'minecraft-modern-theme' ),
+ 'bottom_left' => __( 'Unten links', 'minecraft-modern-theme' ),
+ 'top_right' => __( 'Oben rechts', 'minecraft-modern-theme' ),
+ 'top_left' => __( 'Oben links', 'minecraft-modern-theme' ),
+ ),
) );
// =========================================================================