Lettersail: online English school for kids on MODX 3 (templates, chunks, snippets, plugins, scripts)

This commit is contained in:
jimagie committed 2026-11-01 18:30:36 +05:00
commit 3799cf8de5
96 files changed
+4423

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
<?php
$text = trim((string) ($text ?? ''));
$mode = $mode ?? 'line';
$escape = static fn(string $value): string => htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
if ($mode === 'words') {
$words = preg_split('/\s+/u', $text, -1, PREG_SPLIT_NO_EMPTY);
$out = [];
foreach ($words as $index => $word) {
$out[] = '<span class="kick-word" style="--w:' . $index . '">' . $escape($word) . '</span>';
}
return implode(' ', $out);
}
$lines = preg_split('/\R/u', $text);
$lines = array_map(static fn(string $line): string => $escape(trim($line)), $lines);
return implode($mode === 'br' ? '<br>' : ' ', $lines);