S// MODUL 18 - KINSKI ZITATE - NUR IM VORLETZEN ABSATZ if (isset($rates['module_18']) && $rates['module_18'] > 0) { $kinski_file = plugin_dir_path(__FILE__) . 'zitate-kinski.txt'; $kinski_quotes = []; if (file_exists($kinski_file)) { $file_content = file_get_contents($kinski_file); if ($file_content !== false) { $file_content = str_replace(["\r\n", "\r"], "\n", $file_content); $lines = explode("\n", $file_content); foreach ($lines as $line) { $line = trim($line); if (!empty($line) && strlen($line) > 50) { $kinski_quotes[] = $line; } } } } if (!empty($kinski_quotes)) { // Ermittle alle Absatz-Endpositionen $paragraph_end_positions = []; $offset = 0; while (($pos = strpos($text, '

', $offset)) !== false) { $paragraph_end_positions[] = $pos; $offset = $pos + 4; } $paragraph_count = count($paragraph_end_positions); // Prüfe ob genügend Absätze vorhanden sind // Schütze Absätze 0, 1, 2, 3 und den letzten - benötigen mindestens 6 Absätze if ($paragraph_count >= 6) { // Berechne den vorletzten Absatz (paragraph_count - 2) $penultimate_paragraph_index = $paragraph_count - 2; // Hole einen zufälligen Kinski-Zitat $global_quote_counter = get_option('kinski_quote_counter', 0); $quote_index = $global_quote_counter % count($kinski_quotes); $random_quote = $kinski_quotes[$quote_index]; $global_quote_counter++; // Erstelle das Kinski-Zitat Element $h3_title = "⚔️ Triggert mich wie der Directors Cut vom Irrsinn"; $emoji = "🔥"; $kinski_paragraph = '

' . $h3_title . ' ' . $emoji . '

' . $random_quote; // Füge das Zitat nach dem vorletzen Absatz ein $insert_position = $paragraph_end_positions[$penultimate_paragraph_index] + 4; $text = substr_replace($text, $kinski_paragraph, $insert_position, 0); // Aktualisiere den globalen Counter update_option('kinski_quote_counter', $global_quote_counter); } } } Haftpflichtversicherunginfo.de – Seite 19 – Täglich Infos über die haftpflichtversicherunginfo und Versicherungen allgemein