修复了一些问题

This commit is contained in:
2026-08-23 20:59:34 +08:00
parent af52f9e94d
commit d7634d1ff6
9 changed files with 316 additions and 24 deletions
+4
View File
@@ -92,6 +92,10 @@ abstract class ControllerBase {
case 'array':
$out[$key] = is_array($val) ? $val : [];
break;
case 'attachment_ids':
$ids = is_array($val) ? array_filter(array_map('absint', $val)) : [];
$out[$key] = array_values(array_unique($ids));
break;
default:
$out[$key] = sanitize_text_field($val);
}
+11
View File
@@ -443,6 +443,12 @@ class SchemaProvider {
private function sanitize_value($value, string $type) {
switch ($type) {
case 'attachment_ids':
if (!is_array($value)) {
return [];
}
$ids = array_values(array_filter(array_map('absint', $value)));
return array_values(array_unique($ids));
case 'html':
return wp_kses_post((string) $value);
case 'textarea':
@@ -488,6 +494,10 @@ class SchemaProvider {
return $this->sanitize_value($value, $sanitize_type);
}
if ($type === 'gallery') {
return $this->sanitize_value($value, 'attachment_ids');
}
if (in_array($type, ['fieldset', 'accordion'], true)) {
return $this->sanitize_object_fields($value, (array) ($field['fields'] ?? []));
}
@@ -658,6 +668,7 @@ class SchemaProvider {
'icon' => 'string',
'media' => 'url',
'upload' => 'url',
'gallery' => 'attachment_ids',
'code' => 'code',
];