对小工具进行了一些修复
This commit is contained in:
@@ -125,21 +125,7 @@ final class FieldSchema {
|
||||
}
|
||||
|
||||
private static function choice(array $field, $value) {
|
||||
$raw_options = $field['options'] ?? [];
|
||||
// Reference-theme AJAX selects declare an option source (for example
|
||||
// `post` or `categories`) instead of an inline option map. Preserve the
|
||||
// selected IDs until the remote picker resolves their labels.
|
||||
if (!is_array($raw_options)) {
|
||||
if (!empty($field['multiple'])) {
|
||||
$values = is_array($value) ? $value : preg_split('/[,,\s]+/', (string) $value, -1, PREG_SPLIT_NO_EMPTY);
|
||||
return array_values(array_unique(array_filter(array_map(static function ($item): string {
|
||||
$item = trim((string) $item);
|
||||
return preg_match('/^\d+$/', $item) ? (string) (int) $item : '';
|
||||
}, $values ?: []))));
|
||||
}
|
||||
return sanitize_text_field((string) $value);
|
||||
}
|
||||
$options = $raw_options;
|
||||
$options = (array) ($field['options'] ?? []);
|
||||
if (!empty($field['multiple'])) {
|
||||
$values = is_array($value) ? $value : [];
|
||||
return array_values(array_filter(array_map('strval', $values), static fn($item) => array_key_exists($item, $options)));
|
||||
|
||||
Reference in New Issue
Block a user