Files
Minecraft-Modern-Theme/Minecraft-Modern-Theme/inc/assistant/intent-faq.php
T
2026-11-17 21:15:36 +00:00

49 lines
1.7 KiB
PHP

<?php
/**
* Assistent: FAQ (Custom Post Type faq).
*
* Ausgelagert aus inc/assistant-ajax.php; wird von dort geladen.
*
* @package Minecraft-Modern-Theme
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// ============================================================
// INTENT: FAQ (Custom Post Type 'faq')
// ============================================================
function mm_intent_faq( $q ) {
if ( ! post_type_exists( 'faq' ) ) return null;
$search = preg_replace( '/\b(faq|häufig|frage|oft gefragt)\b/i', '', $q );
$search = trim( $search );
$results = get_posts( [
'post_type' => 'faq',
'post_status' => 'publish',
's' => strlen( $search ) >= 3 ? $search : '',
'posts_per_page' => 4,
'orderby' => 'relevance',
] );
if ( empty( $results ) ) return null;
$html = '<div style="background:#fff;border-radius:12px;padding:16px 14px 10px 14px;box-shadow:0 2px 8px rgba(0,0,0,0.04);max-width:480px;margin:0 auto;">';
foreach ( $results as $post ) {
$title = esc_html( $post->post_title );
$content = apply_filters( 'the_content', $post->post_content );
$html .= '<div style="margin-bottom:18px;padding-bottom:10px;border-bottom:1px solid #e5e7eb;">';
$html .= '<div style="font-size:1.08em;font-weight:600;color:#23272e;margin-bottom:4px;">' . $title . '</div>';
$html .= '<div style="font-size:1em;color:#444;opacity:.97;line-height:1.6;">' . $content . '</div>';
$html .= '</div>';
}
$html .= '</div>';
return [
'source' => 'faq',
'title' => 'FAQ',
'content' => $html,
];
}