| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Utilities; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
|
| 7 |
class TicketExtraInfoFormatter |
| 8 |
{ |
| 9 |
public static function sanitizeContent($value): string |
| 10 |
{ |
| 11 |
$value = wp_check_invalid_utf8(wp_unslash((string) $value)); |
| 12 |
|
| 13 |
if (strpos($value, '<') !== false) { |
| 14 |
$value = wp_pre_kses_less_than($value); |
| 15 |
$value = wp_strip_all_tags($value, false); |
| 16 |
$value = str_replace("<\n", "<\n", $value); |
| 17 |
} |
| 18 |
|
| 19 |
$value = str_replace(["\r\n", "\r"], "\n", $value); |
| 20 |
$value = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', '', $value); |
| 21 |
|
| 22 |
return trim($value); |
| 23 |
} |
| 24 |
|
| 25 |
public static function appendFromRequest(string $content, array $request): string |
| 26 |
{ |
| 27 |
// Kept as a compatibility shim for third-party callers. Access data is |
| 28 |
// intentionally ignored and must be sent with TicketAccessData instead. |
| 29 |
return trim($content); |
| 30 |
} |
| 31 |
} |
| 32 |
|