对小工具进行了一些修复

This commit is contained in:
2026-08-26 08:41:24 +08:00
parent e877ceb560
commit bb9413cba6
15 changed files with 463 additions and 136 deletions
+7 -1
View File
@@ -13,7 +13,7 @@ final class FieldSchema {
public static function supported_types(): array {
return [
'text', 'textarea', 'number', 'spinner', 'slider', 'switcher', 'radio',
'button_set', 'select', 'checkbox', 'color', 'palette', 'icon', 'upload',
'button_set', 'select', 'checkbox', 'color', 'palette', 'image_select', 'icon', 'upload',
'link', 'spacing', 'background', 'group', 'fieldset', 'accordion',
'content', 'subheading', 'submessage',
];
@@ -59,6 +59,7 @@ final class FieldSchema {
case 'button_set':
case 'select':
case 'palette':
case 'image_select':
return self::choice($field, $value);
case 'checkbox':
return self::checkbox($field, $value);
@@ -86,6 +87,11 @@ final class FieldSchema {
if (($field['sanitize'] ?? '') === 'ids') {
return implode(',', array_values(array_unique(array_filter(array_map('absint', preg_split('/[,,\s]+/', (string) $value))))));
}
if (($field['sanitize'] ?? '') === 'reference_ids') {
$tokens = preg_split('/[,,\s]+/', trim((string) $value), -1, PREG_SPLIT_NO_EMPTY);
$tokens = array_map(static fn($token): string => preg_match('/^-?\d+$/', (string) $token) ? (string) (int) $token : '', $tokens ?: []);
return implode(',', array_values(array_unique(array_filter($tokens, static fn($token): bool => $token !== ''))));
}
return !empty($field['allow_html']) ? wp_kses_post((string) $value) : sanitize_text_field((string) $value);
}
}