S NEU: 0. KLAMMERBEGRIFFE MIT BINDESTRICHEN VERBINDEN (2-5 WÖRTER) $pattern = '/\(([a-zA-ZäöüÄÖÜß\s]+\s[a-zA-ZäöüÄÖÜß\s]+(\s[a-zA-ZäöüÄÖÜß\s]+)?(\s[a-zA-ZäöüÄÖÜß\s]+)?(\s[a-zA-ZäöüÄÖÜß\s]+)?)\)/u'; if (preg_match_all($pattern, $text, $matches)) { foreach ($matches[0] as $index => $full_match) { $inner_text = $matches[1][$index]; $modified_inner = trim(preg_replace('/\s+/', '-', $inner_text)); $new_text = '(' . $modified_inner . ')'; $text = str_replace($full_match, $new_text, $text); } } // NEU: 0.1 WÖRTER IM TEXT GROSSSCHREIBEN (2x) // Strikt 1x im ersten Absatz und 1x im vorletzten Absatz (nicht letzter!) preg_match_all('/
]*>(.*?)<\/p>/s', $text, $p_matches); $replacements_done = 0; if (!empty($p_matches[0])) { $paragraphs_count = count($p_matches[0]); $first_index = 0; $last_index = max(0, $paragraphs_count - 2); $positions_to_process = array($first_index, $last_index); foreach ($positions_to_process as $index) { $p_tag = $p_matches[0][$index]; $p_content = $p_matches[1][$index]; if (preg_match_all('/\b([A-ZÄÖÜ][a-zäöüß]{2,})\b/u', $p_content, $word_matches)) { if (!empty($word_matches[0])) { $word_count = count($word_matches[0]); $middle_index = intval($word_count / 2); $word = $word_matches[0][$middle_index > 0 ? $middle_index : 0]; $replacement = strtoupper($word); $new_content = preg_replace('/\b' . preg_quote($word, '/') . '\b/u', $replacement, $p_content, 1); $new_p_tag = str_replace($p_content, $new_content, $p_tag); $text = str_replace($p_tag, $new_p_tag, $text); $replacements_done++; } else { if (preg_match_all('/\b([a-zA-ZäöüÄÖÜß]{4,})\b/u', $p_content, $alt_word_matches)) { if (!empty($alt_word_matches[0])) { $word_count = count($alt_word_matches[0]); $middle_index = intval($word_count / 2); $word = $alt_word_matches[0][$middle_index > 0 ? $middle_index : 0]; $replacement = strtoupper($word); $new_content = preg_replace('/\b' . preg_quote($word, '/') . '\b/u', $replacement, $p_content, 1); $new_p_tag = str_replace($p_content, $new_content, $p_tag); $text = str_replace($p_tag, $new_p_tag, $text); $replacements_done++; } } } } } } // NEU: 0.5 NACH BINDESTRICH GROSSSCHREIBUNG BIS ZUM NÄCHSTEN SATZZEICHEN (2x pro Text) $all_positions = array(); $offset = 0; while (($pos = strpos($text, ' – ', $offset)) !== false || ($pos = strpos($text, ' - ', $offset)) !== false) { $all_positions[] = $pos + 3; $offset = $pos + 3; } if (!empty($all_positions)) { shuffle($all_positions); $selected_positions = array_slice($all_positions, 0, min(2, count($all_positions))); foreach ($selected_positions as $pos) { $next_period = strpos($text, '.', $pos); $next_exclamation = strpos($text, '!', $pos); $next_question = strpos($text, '?', $pos); $next_colon = strpos($text, ':', $pos); $next_semicolon = strpos($text, ';', $pos); $punctuation_positions = array(); if ($next_period !== false) $punctuation_positions[] = $next_period; if ($next_exclamation !== false) $punctuation_positions[] = $next_exclamation; if ($next_question !== false) $punctuation_positions[] = $next_question; if ($next_colon !== false) $punctuation_positions[] = $next_colon; if ($next_semicolon !== false) $punctuation_positions[] = $next_semicolon; if (!empty($punctuation_positions)) { $next_punctuation = min($punctuation_positions); $text_to_uppercase = substr($text, $pos, $next_punctuation - $pos); $uppercase_text = strtoupper($text_to_uppercase); $text = substr_replace($text, $uppercase_text, $pos, strlen($text_to_uppercase)); } } } // MODUL 11 - VERBEN MIT DOPPELPUNKT UND GROSSSCHREIBUNG (verben.txt Version) if (isset($rates['module_11']) && $rates['module_11'] > 0) { $log_file = plugin_dir_path(__FILE__) . 'error_log.txt'; $verbs_file = plugin_dir_path(__FILE__) . 'verben.txt'; $timestamp = date('Y-m-d H:i:s'); file_put_contents($log_file, "\n=== VERBEN MODUL 11 TEST - $timestamp ===\n", FILE_APPEND); file_put_contents($log_file, "Rate: " . $rates['module_11'] . "%\n", FILE_APPEND); $verbs = array(); if (file_exists($verbs_file)) { $verbs_content = file_get_contents($verbs_file); $verbs = array_filter(array_map('trim', explode("\n", $verbs_content))); file_put_contents($log_file, "Verben geladen: " . count($verbs) . " aus verben.txt\n", FILE_APPEND); } else { file_put_contents($log_file, "FEHLER: verben.txt nicht gefunden! Modul deaktiviert.\n", FILE_APPEND); file_put_contents($log_file, "=== ENDE ===\n", FILE_APPEND); return $text; } $verb_positions = array(); foreach ($verbs as $verb) { if (empty($verb)) continue; $pattern = '/\b' . preg_quote($verb, '/') . '\s+([a-zA-ZäöüÄÖÜß]+(?:\s+[a-zA-ZäöüÄÖÜß]+)*)/u'; if (preg_match_all($pattern, $text, $matches, PREG_OFFSET_CAPTURE)) { foreach ($matches[0] as $index => $match) { $full_match = $match[0]; $position = $match[1]; $following_words = $matches[1][$index][0]; if (!preg_match('/[.!?:;]/', $following_words)) { $verb_positions[] = array( 'verb' => $verb, 'position' => $position, 'full_match' => $full_match, 'following_words' => $following_words ); } } } } file_put_contents($log_file, "Gültige Verb-Matches gefunden: " . count($verb_positions) . "\n", FILE_APPEND); if (!empty($verb_positions)) { shuffle($verb_positions); shuffle($verb_positions); $replace_count = intval(count($verb_positions) * ($rates['module_11'] / 100)); $selected_positions = array_slice($verb_positions, 0, max(1, $replace_count)); file_put_contents($log_file, "Ersetzungen (" . $rates['module_11'] . "%): " . count($selected_positions) . " von " . count($verb_positions) . "\n", FILE_APPEND); usort($selected_positions, function($a, $b) { return $b['position'] - $a['position']; }); foreach ($selected_positions as $verb_data) { $verb = $verb_data['verb']; $position = $verb_data['position']; $full_match = $verb_data['full_match']; $following_words = $verb_data['following_words']; $words_array = explode(' ', $following_words); if (!empty($words_array)) { $words_array[0] = ucfirst($words_array[0]); $capitalized_following = implode(' ', $words_array); $replacement = $verb . ':' . "\n\n" . $capitalized_following; file_put_contents($log_file, "ERSETZT: '$full_match' → '$replacement'\n", FILE_APPEND); $text = substr_replace($text, $replacement, $position, strlen($full_match)); } } } else { file_put_contents($log_file, "Keine gültigen Verben gefunden!\n", FILE_APPEND); } file_put_contents($log_file, "=== ENDE ===\n", FILE_APPEND); } // MODUL 12 - ANTI-KI: ALLE MENSCHLICHEN STILMITTEL if (isset($rates['module_12']) && $rates['module_12'] > 0) { $transformations_made = 0; $max_transformations = $rates['module_12']; // 1. WORT-WIEDERHOLUNGEN (3x Mantra-Style) if ($transformations_made < $max_transformations) { preg_match_all('/\b([A-ZÄÖÜ][a-zäöüß]{2,})\b/u', $text, $word_matches); if (!empty($word_matches[0])) { $word_count = count($word_matches[0]); $middle_index = intval($word_count / 2); $word = $word_matches[0][$middle_index > 0 ? $middle_index : 0]; $replacement = $word . '. ' . $word . '. ' . $word . '.'; $text = preg_replace('/\b' . preg_quote($word, '/') . '\b/u', $replacement, $text, 1); $transformations_made++; } } // 2. LAUTMALEREI & BUCHSTABEN-VERLÄNGERUNG if ($transformations_made < $max_transformations) { $stretch_patterns = array( '/\bja\b/i' => 'jaaaaaaa', '/\bnein\b/i' => 'neiiiiiiin', '/\bwow\b/i' => 'wooooow', '/\boh\b/i' => 'ohhhhhhh', '/\bah\b/i' => 'ahhhhhhh', '/\bso\b/i' => 'soooooo' ); foreach ($stretch_patterns as $pattern => $replacement) { if (preg_match($pattern, $text)) { $text = preg_replace($pattern, $replacement, $text, 1); $transformations_made++; break; } } } // 3. SOUNDEFFEKTE EINFÜGEN if ($transformations_made < $max_transformations) { $soundeffects = array('[KRACH]', '[BOOM]', '[fieeeep]', '[Peeep]', '[PLING]', '[RATSCH]', '[BUMM]', '[psssst]', '[KLICK]', '[DONG]'); $exclamation_positions = array(); for ($i = 0; $i < strlen($text); $i++) { if ($text[$i] === '!' && $i < strlen($text) - 1) { $exclamation_positions[] = $i + 1; } } if (!empty($exclamation_positions)) { $pos = $exclamation_positions[array_rand($exclamation_positions)]; $sound = $soundeffects[array_rand($soundeffects)]; $text = substr_replace($text, ' ' . $sound, $pos, 0); $transformations_made++; } } // 4. VERFREMDETE NAMEN/WÖRTER (Ästhetische Fehlschreibung) if ($transformations_made < $max_transformations) { $weird_replacements = array( 'okay' => 'okayyy', 'super' => 'suuuper', 'toll' => 'tolllll', 'krass' => 'krassss', 'cool' => 'coooool', 'nice' => 'niiice' ); foreach ($weird_replacements as $original => $weird) { if (stripos($text, $original) !== false) { $text = str_ireplace($original, $weird, $text); $transformations_made++; break; } } } // 5. BUCHSTABEN-VERDOPPLUNG FÜR BETONUNG if ($transformations_made < $max_transformations) { $emphasis_words = array('sehr', 'mega', 'ultra', 'extrem', 'total', 'echt', 'wirklich', 'absolut'); foreach ($emphasis_words as $word) { if (stripos($text, $word) !== false) { $new_word = $word . substr($word, -1) . substr($word, -1) . substr($word, -1); $text = str_ireplace($word, $new_word, $text); $transformations_made++; break; } } } // 6. NEBENSÄTZE MIT KOMMA/SEMIKOLON ZU BULLETPOINTS if ($transformations_made < $max_transformations) { $sentences = preg_split('/[.!?]+/', $text); shuffle($sentences); foreach ($sentences as $sentence) { if ($transformations_made >= $max_transformations) break; $comma_count = substr_count($sentence, ','); $semicolon_count = substr_count($sentence, ';'); if (($comma_count + $semicolon_count) >= 3 && strlen(trim($sentence)) > 20) { $parts = preg_split('/[,;]+/', $sentence); $parts = array_filter(array_map('trim', $parts)); if (count($parts) >= 3) { $bullet_list = ''; foreach ($parts as $part_index => $part) { if (!empty($part)) { if ($part_index === 0) { $bullet_list .= ucfirst($part) . "\n"; } else { $bullet_list .= "• " . ucfirst($part) . "\n"; } } } $text = str_replace($sentence, $bullet_list, $text); $transformations_made++; break; } } } } } // MODUL 13 - NEBENSÄTZE ZU BULLETPOINTS if (isset($rates['module_13']) && $rates['module_13'] > 0) { $paragraphs = preg_split('/<\/p>/', $text); $transformations_done = 0; $max_transformations = $rates['module_13']; // Rate für die maximale Anzahl von Transformationen // Sammle alle Sätze, die die Kriterien erfüllen $eligible_sentences = array(); for ($i = 1; $i < count($paragraphs); $i++) { $sentences = preg_split('/[.!?]+/', $paragraphs[$i]); foreach ($sentences as $sentence) { $comma_count = substr_count($sentence, ','); $semicolon_count = substr_count($sentence, ';'); if (($comma_count + $semicolon_count) >= 3 && strlen(trim($sentence)) > 20) { $eligible_sentences[] = array( 'paragraph_index' => $i, 'sentence' => $sentence ); } } } // Mische die Sätze, um zufällige Auswahl zu gewährleisten shuffle($eligible_sentences); // Wähle die ersten $max_transformations Sätze aus $selected_sentences = array_slice($eligible_sentences, 0, $max_transformations); // Führe die Transformationen durch foreach ($selected_sentences as $sentence_data) { $paragraph_index = $sentence_data['paragraph_index']; $sentence = $sentence_data['sentence']; $parts = preg_split('/[,;]+/', $sentence); $parts = array_filter(array_map('trim', $parts)); if (count($parts) >= 3) { $bullet_list = ''; foreach ($parts as $part_index => $part) { if (!empty($part)) { if ($part_index === 0) { $bullet_list .= ucfirst($part) . ":\n"; // Doppelpunkt hinzufügen } else { $bullet_list .= "• " . ucfirst($part); // Füge zufällig einen Haken hinzu if (rand(0, 100) < 30) { // 30% Chance, einen Haken hinzuzufügen $bullet_list .= " ✓"; } $bullet_list .= "\n"; } } } $paragraphs[$paragraph_index] = str_replace($sentence, $bullet_list, $paragraphs[$paragraph_index]); $transformations_done++; // Erhöhe den Zähler für die durchgeführten Transformationen } } // Füge die Absätze wieder zusammen $text = implode("
", $paragraphs); } // MODUL 14 - WÖRTER IN ANFÜHRUNGSZEICHEN if (isset($rates['module_14']) && $rates['module_14'] > 0) { $words = preg_split('/\s+/', $text, -1, PREG_SPLIT_NO_EMPTY); $words = array_filter($words, function($word) { return strlen($word) >= 5 && preg_match('/^[a-zA-ZäöüÄÖÜß]+$/', $word); // Filtere Wörter mit mindestens 5 Buchstaben und nur Buchstaben }); $total_transformations = $rates['module_14']; $transformations_done = 0; if (!empty($words)) { shuffle($words); // Mische die Wörter, um zufällige Auswahl zu gewährleisten foreach ($words as $index => $word) { if ($transformations_done >= $total_transformations) break; // Entscheide zufällig, ob das Wort in Groß- oder Kleinbuchstaben in Anführungszeichen gesetzt wird $transform_type = rand(0, 1); if ($transform_type) { // Großbuchstaben $transformed_word = $word; } else { // Kleinbuchstaben $transformed_word = strtolower($word); } // Ersetze das Wort im Text durch die transformierte Version in Anführungszeichen $text = preg_replace('/\b' . preg_quote($word, '/') . '\b/', '"' . $transformed_word . '"', $text, 1); $transformations_done++; } } } // 1. PUNKTE → ..., :, -, \, .... (70%) - ABER NICHT BEI ZAHLEN/DATUM $all_positions = array(); for ($i = 0; $i < strlen($text); $i++) { if ($text[$i] === '.') { $before_is_digit = ($i > 0 && is_numeric($text[$i-1])); $after_is_digit = ($i < strlen($text)-1 && is_numeric($text[$i+1])); if (!$before_is_digit && !$after_is_digit) { $all_positions[] = $i; } } } if (!empty($all_positions)) { shuffle($all_positions); shuffle($all_positions); $replace_count = intval(count($all_positions) * ($rates['module_4'] / 100)); $selected_positions = array_slice($all_positions, 0, max(1, $replace_count)); rsort($selected_positions); foreach ($selected_positions as $pos) { $replacements = ['...', ' ...', '....', ' ....', '.....', ' .....', '|', ' |', '-', ' -', '/', ' /', '\\', ' \\', '¦', ' ↪', '///', ' ⟡', '⁂', '‖']; $replacement = $replacements[array_rand($replacements)]; $text = substr_replace($text, $replacement, $pos, 1); } } // 2. KOMMAS → ; (50% gewürfelt) $all_positions = array(); for ($i = 0; $i < strlen($text); $i++) { if ($text[$i] === ',') { $all_positions[] = $i; } } if (!empty($all_positions)) { shuffle($all_positions); shuffle($all_positions); $replace_count = intval(count($all_positions) * ($rates['module_5'] / 100)); $selected_positions = array_slice($all_positions, 0, max(1, $replace_count)); rsort($selected_positions); foreach ($selected_positions as $pos) { $text = substr_replace($text, ';', $pos, 1); } } // 3. FRAGEZEICHEN → ?!, ???, ?!? (31% gewürfelt) $all_positions = array(); for ($i = 0; $i < strlen($text); $i++) { if ($text[$i] === '?') { $all_positions[] = $i; } } if (!empty($all_positions)) { shuffle($all_positions); shuffle($all_positions); $replace_count = intval(count($all_positions) * ($rates['module_6'] / 100)); $selected_positions = array_slice($all_positions, 0, max(1, $replace_count)); $replacements = ['?!', '???', '?!?', '??!', '?...', '!?']; rsort($selected_positions); foreach ($selected_positions as $pos) { $replacement = $replacements[array_rand($replacements)]; $text = substr_replace($text, $replacement, $pos, 1); } } //