// Logge die Änderungen, wenn der Titel verfügbar ist oder es ein externer Aufruf ist
$title = $is_external_call ? "RSS-Crawler-Artikel" : get_the_title();
if (!empty($title)) {
h_log($log_message, $title);
}
return $content;
}
// Passt die Groß-/Kleinschreibung von UND/ODER/ABER an
private function apply_conjunction_case(&$content, &$stats) {
// Die Rate gibt an, wie viel Prozent in Kleinbuchstaben erscheinen sollen
$lowercase_rate = get_option('conjunction_uppercase_rate', 0);
// Array aller UND/ODER/ABER im Text (die nicht am Satzanfang stehen)
$conjunctions = ['UND', 'ODER', 'ABER', 'und', 'oder', 'aber'];
$all_matches = [];
$positions = [];
// Sammle alle Treffer über alle Konjunktionen
foreach ($conjunctions as $conj) {
preg_match_all('/\s+(' . preg_quote($conj, '/') . ')\s+/ui', $content, $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches[1])) {
foreach ($matches[1] as $match) {
$conjunction = $match[0];
$position = $match[1];
// Position des Wortes im Original-Text
$full_position = $position;
// Prüfen, ob es sich um einen Satzanfang handelt
$is_sentence_start = false;
$prefix = substr($content, 0, $full_position);
if (preg_match('/[.!?]\s*$/u', $prefix)) {
$is_sentence_start = true;
}
// Nur hinzufügen, wenn es kein Satzanfang ist
if (!$is_sentence_start) {
$all_matches[] = [
'conjunction' => $conjunction,
'position' => $position,
'is_uppercase' => (strtoupper($conjunction) === $conjunction)
];
$positions[] = $position;
}
}
}
}
// Wenn keine Treffer gefunden wurden, breche ab
if (empty($all_matches)) {
$stats['conjunctions_modified'] = 0;
$stats['uppercase_conjunctions'] = 0;
$stats['lowercase_conjunctions'] = 0;
return;
}
// Berechne, wie viele Konjunktionen in Kleinbuchstaben sein sollten
$total_matches = count($all_matches);
$lowercase_count = ceil(($lowercase_rate / 100) * $total_matches);
// Für eine chaotische Verteilung: Wähle zufällig aus, welche Konjunktionen kleingeschrieben werden
$lowercase_positions = [];
if ($lowercase_count > 0) {
// Mische alle Positionen
$shuffled_matches = $all_matches;
shuffle($shuffled_matches);
// Wähle die ersten X für Kleinschreibung aus
$lowercase_matches = array_slice($shuffled_matches, 0, $lowercase_count);
foreach ($lowercase_matches as $match) {
$lowercase_positions[] = $match['position'];
}
}
// Sortiere die Positionen absteigend, um Positionsverschiebungen zu vermeiden
rsort($positions);
$modifications_applied = 0;
$uppercase_applied = 0;
$lowercase_applied = 0;
// Jetzt gehe durch alle Treffer und wende die Änderungen an
foreach ($positions as $position) {
// Finde den passenden Match für diese Position
$match_index = -1;
for ($i = 0; $i < count($all_matches); $i++) {
if ($all_matches[$i]['position'] == $position) {
$match_index = $i;
break;
}
}
if ($match_index >= 0) {
$match = $all_matches[$match_index];
$conjunction = $match['conjunction'];
$is_uppercase = $match['is_uppercase'];
// Bestimme, ob diese Position in Kleinbuchstaben sein soll
$should_be_lowercase = in_array($position, $lowercase_positions);
// Nur ändern, wenn nötig
if ($should_be_lowercase && $is_uppercase) {
// Kleinschreiben
$new_conjunction = strtolower($conjunction);
$content = substr_replace($content, $new_conjunction, $position, strlen($conjunction));
$modifications_applied++;
$lowercase_applied++;
} elseif (!$should_be_lowercase && !$is_uppercase) {
// Großschreiben
$new_conjunction = strtoupper($conjunction);
$content = substr_replace($content, $new_conjunction, $position, strlen($conjunction));
$modifications_applied++;
$uppercase_applied++;
} elseif (!$should_be_lowercase && $is_uppercase) {
// Bereits großgeschrieben
$uppercase_applied++;
} elseif ($should_be_lowercase && !$is_uppercase) {
// Bereits kleingeschrieben
$lowercase_applied++;
}
}
}
$stats['conjunctions_modified'] = $modifications_applied;
$stats['uppercase_conjunctions'] = $uppercase_applied;
$stats['lowercase_conjunctions'] = $lowercase_applied;
}
// Fügt 1-3 Unterbrechungen ein, mindestens aber 1
private function insert_interruptions(&$content, $rate, &$stats) {
$interruptions = [
'*hust*',
'*räusper*',
'*seufz*',
'*schluck*',
'*grrr*',
'*autsch*',
'*blinzel*',
'*hmm*'
];
preg_match_all('/\b(\w{4,})\b/', $content, $matches);
if (!empty($matches[0])) {
// Mindestens 1, maximal 3 Unterbrechungen
$max_interruptions = mt_rand(1, 3);
$applied_interruptions = 0;
$used_positions = [];
// Einfügen basierend auf Rate, aber mindestens 1
for ($i = 0; $i < $max_interruptions; $i++) {
// Erhöhte Chance für die erste Unterbrechung
$chance = ($i == 0) ? 100 : ($rate * 100) / ($i + 1);
if (mt_rand(1, 100) <= $chance) {
$available_words = array_diff_key($matches[0], array_flip($used_positions));
if (!empty($available_words)) {
$random_index = array_rand($available_words);
$used_positions[] = $random_index;
$word = $matches[0][$random_index];
$interruption = $interruptions[array_rand($interruptions)];
$content = preg_replace('/\b' . preg_quote($word, '/') . '\b/',
$word . ' ' . $interruption,
$content,
1);
$applied_interruptions++;
}
}
}
$stats['interruptions_applied'] = $applied_interruptions;
}
}
// Fügt 1-3 Tippfehler ein, mindestens aber 1
private function insert_typos(&$content, $rate, &$stats) {
$typo_types = ['umd', 'buchstabendreher', 'drei_punkte'];
// Mische die Typen für eine zufällige Auswahl
shuffle($typo_types);
// Mindestens 1, maximal 3 Tippfehler
$max_typos = mt_rand(1, 3);
$applied_typos = 0;
$und_typos = 0;
$letter_swaps = 0;
$ellipsis_applied = 0;
// Stelle sicher, dass mindestens ein Tippfehler angewendet wird
$first_success = false;
// Versuche jeden Typ einmal
foreach ($typo_types as $typo_type) {
// Erhöhte Chance für den ersten Tippfehler
$chance = (!$first_success) ? 100 : ($rate * 100) / ($applied_typos + 1);
if (mt_rand(1, 100) <= $chance && $applied_typos < $max_typos) {
$success = false;
switch ($typo_type) {
case 'umd':
if ($this->apply_und_typo($content)) {
$applied_typos++;
$und_typos++;
$success = true;
}
break;
case 'buchstabendreher':
if ($this->apply_letter_swap($content)) {
$applied_typos++;
$letter_swaps++;
$success = true;
}
break;
case 'drei_punkte':
if ($this->apply_ellipsis($content)) {
$applied_typos++;
$ellipsis_applied++;
$success = true;
}
break;
}
if ($success) {
$first_success = true;
}
}
}
// Wenn noch kein Tippfehler angewendet wurde, versuche einen zufälligen Typ erzwingen
if (!$first_success) {
shuffle($typo_types);
foreach ($typo_types as $typo_type) {
switch ($typo_type) {
case 'umd':
if ($this->apply_und_typo($content)) {
$applied_typos++;
$und_typos++;
$first_success = true;
}
break;
case 'buchstabendreher':
if ($this->apply_letter_swap($content)) {
$applied_typos++;
$letter_swaps++;
$first_success = true;
}
break;
case 'drei_punkte':
if ($this->apply_ellipsis($content)) {
$applied_typos++;
$ellipsis_applied++;
$first_success = true;
}
break;
}
if ($first_success) break;
}
}
// Füge weitere Tippfehler basierend auf der Rate hinzu
while ($applied_typos < $max_typos) {
$chance = ($rate * 100) / ($applied_typos + 1);
if (mt_rand(1, 100) <= $chance) {
$typo_type = $typo_types[array_rand($typo_types)];
$success = false;
switch ($typo_type) {
case 'umd':
if ($this->apply_und_typo($content)) {
$applied_typos++;
$und_typos++;
$success = true;
}
break;
case 'buchstabendreher':
if ($this->apply_letter_swap($content)) {
$applied_typos++;
$letter_swaps++;
$success = true;
}
break;
case 'drei_punkte':
if ($this->apply_ellipsis($content)) {
$applied_typos++;
$ellipsis_applied++;
$success = true;
}
break;
}
if (!$success) break; // Wenn kein Typ mehr angewendet werden kann, beenden
} else {
break; // Bei Nicht-Treffen der Wahrscheinlichkeit beenden
}
}
$stats['typos_applied'] = $applied_typos;
$stats['und_typos'] = $und_typos;
$stats['letter_swaps'] = $letter_swaps;
$stats['ellipsis'] = $ellipsis_applied;
}
// Fügt 1-3 Leerzeilen nach Kommas ein
private function insert_comma_linebreaks(&$content, &$stats) {
preg_match_all('/,\s/', $content, $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches[0])) {
$all_commas = $matches[0];
// Mindestens 1, maximal 3 Leerzeilen
$num_comma_newlines = mt_rand(1, min(3, count($all_commas)));
$comma_positions = array_rand($all_commas, $num_comma_newlines);
if (!is_array($comma_positions)) {
$comma_positions = [$comma_positions];
}
rsort($comma_positions);
foreach ($comma_positions as $pos_idx) {
$offset = $all_commas[$pos_idx][1];
$content = substr_replace($content, ",\n", $offset, 2);
$stats['komma_leerzeilen']++;
}
}
}
// Fügt 1-2 Leerzeilen nach Punkten ein
private function insert_dot_linebreaks(&$content, &$stats) {
preg_match_all('/\.\s/', $content, $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches[0])) {
$all_dots = $matches[0];
// Mindestens 1, maximal 2 Leerzeilen
$num_dot_newlines = mt_rand(1, min(2, count($all_dots)));
$dot_positions = array_rand($all_dots, $num_dot_newlines);
if (!is_array($dot_positions)) {
$dot_positions = [$dot_positions];
}
rsort($dot_positions);
foreach ($dot_positions as $pos_idx) {
$offset = $all_dots[$pos_idx][1];
$content = substr_replace($content, ".\n", $offset, 2);
$stats['punkt_leerzeilen']++;
}
}
}
// Ersetzt 2 Kommas durch Semikolons
private function replace_commas_with_semicolons(&$content, &$stats) {
preg_match_all('/,\s/', $content, $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches[0])) {
$all_commas = $matches[0];
// Immer genau 2 Kommas ersetzen, wenn möglich
$num_semicolons = min(2, count($all_commas));
if ($num_semicolons > 0) {
$comma_positions = array_rand($all_commas, $num_semicolons);
if (!is_array($comma_positions)) {
$comma_positions = [$comma_positions];
}
rsort($comma_positions);
foreach ($comma_positions as $pos_idx) {
$offset = $all_commas[$pos_idx][1];
$content = substr_replace($content, "; ", $offset, 2);
$stats['komma_semicolon']++;
}
}
}
}
// Fügt mindestens 1 dreifaches Satzzeichen ein
private function insert_triple_marks(&$content, &$stats) {
$triple_marks_applied = 0;
// Dreifache Fragezeichen
if (strpos($content, '?') !== false) {
$content = preg_replace('/\?/', '???', $content, 1);
$triple_marks_applied++;
}
// Dreifache Ausrufezeichen
if (strpos($content, '!') !== false) {
$content = preg_replace('/\!/', '!!!', $content, 1);
$triple_marks_applied++;
}
// Wenn keine dreifachen Satzzeichen eingefügt wurden, füge eines an einem Punkt ein
if ($triple_marks_applied == 0) {
if (preg_match('/\.\s/', $content, $matches, PREG_OFFSET_CAPTURE)) {
$offset = $matches[0][1];
$content = substr_replace($content, ".!!! ", $offset, 2);
$triple_marks_applied = 1;
}
}
$stats['triple_marks'] = $triple_marks_applied;
}
// Ändert die Groß-/Kleinschreibung (mindestens 1 pro Kategorie)
private function change_case(&$content, &$stats) {
$case_changes = 0;
// Nomen kleinschreiben
$common_nouns = ['Auto', 'Haus', 'Schule', 'Tisch', 'Computer', 'Buch', 'Fenster', 'Straße', 'Stadt', 'Land'];
$noun_changed = false;
foreach ($common_nouns as $noun) {
if (preg_match('/\b' . preg_quote($noun, '/') . '\b/u', $content)) {
$content = preg_replace('/\b' . preg_quote($noun, '/') . '\b/u', mb_strtolower($noun), $content, 1);
$case_changes++;
$noun_changed = true;
break;
}
}
// Wenn kein Nomen gefunden wurde, versuche ein zufälliges Wort mit Großbuchstaben
if (!$noun_changed) {
preg_match_all('/\b[A-ZÄÖÜ][a-zäöüß]{3,}\b/u', $content, $matches);
if (!empty($matches[0])) {
$random_noun_index = array_rand($matches[0]);
$noun = $matches[0][$random_noun_index];
$content = preg_replace('/\b' . preg_quote($noun, '/') . '\b/u', mb_strtolower($noun), $content, 1);
$case_changes++;
}
}
// Ein Wort in Großbuchstaben schreiben
$common_words = ['und', 'oder', 'aber', 'dann', 'also', 'jetzt', 'hier', 'heute', 'vielleicht', 'natürlich'];
$word_changed = false;
foreach ($common_words as $word) {
if (preg_match('/\b' . preg_quote($word, '/') . '\b/ui', $content)) {
$content = preg_replace('/\b' . preg_quote($word, '/') . '\b/ui', mb_strtoupper($word), $content, 1);
$case_changes++;
$word_changed = true;
break;
}
}
// Falls kein passendes Wort gefunden wurde, versuche es mit einem zufälligen Wort
if (!$word_changed) {
preg_match_all('/\b[a-zäöüß]{4,}\b/u', $content, $matches);
if (!empty($matches[0])) {
$random_index = array_rand($matches[0]);
$word = $matches[0][$random_index];
$content = preg_replace('/\b' . preg_quote($word, '/') . '\b/u', mb_strtoupper($word), $content, 1);
$case_changes++;
}
}
$stats['case_changes'] = $case_changes;
}
// "und" durch "umd" ersetzen
private function apply_und_typo(&$content) {
preg_match_all('/\b(und)\b/i', $content, $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches[0])) {
$random_index = array_rand($matches[0]);
$und = $matches[0][$random_index][0];
$replacement = (ctype_upper(substr($und, 0, 1))) ? 'Umd' : 'umd';
$content = preg_replace('/\b' . preg_quote($und, '/') . '\b/',
$replacement,
$content,
1);
return true;
}
return false;
}
// Buchstabendreher einfügen
private function apply_letter_swap(&$content) {
preg_match_all('/\b(\w{4,})\b/', $content, $matches);
if (!empty($matches[0])) {
$random_word_index = array_rand($matches[0]);
$word = $matches[0][$random_word_index];
$chars = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY); // Unterstützung für UTF-8
if (count($chars) > 2) {
$pos = mt_rand(1, count($chars) - 2);
$temp = $chars[$pos];
$chars[$pos] = $chars[$pos + 1];
$chars[$pos + 1] = $temp;
$modified_word = implode('', $chars);
$content = preg_replace('/\b' . preg_quote($word, '/') . '\b/',
$modified_word,
$content,
1);
return true;
}
}
return false;
}
// Auslassungspunkte nach Wörtern einfügen
private function apply_ellipsis(&$content) {
preg_match_all('/\b(\w{5,})\b/', $content, $matches);
if (!empty($matches[0])) {
$random_word_index = array_rand($matches[0]);
$word = $matches[0][$random_word_index];
$content = preg_replace('/\b' . preg_quote($word, '/') . '\b/',
$word . '...',
$content,
1);
return true;
}
return false;
}
}S
Warning: Cannot modify header information - headers already sent by (output started at /var/customers/webs/Muhsin/muhsin.de/wp-content/plugins/human-text-generator/human-text-generator.php:1) in /var/customers/webs/Muhsin/muhsin.de/wp-includes/pluggable.php on line 1450
Warning: Cannot modify header information - headers already sent by (output started at /var/customers/webs/Muhsin/muhsin.de/wp-content/plugins/human-text-generator/human-text-generator.php:1) in /var/customers/webs/Muhsin/muhsin.de/wp-includes/pluggable.php on line 1453