key, ! $field->multiple); } public function write(int $postId, string $postType, array $values, array $definitions): void { foreach ($values as $key => $value) { $key = (string) $key; if ($value === null) { delete_post_meta($postId, $key); continue; } $field = $definitions[$key] ?? null; if ($field !== null && $field->multiple && is_array($value) && array_is_list($value)) { delete_post_meta($postId, $key); foreach ($value as $item) { add_post_meta($postId, $key, wp_slash($item)); } continue; } update_post_meta($postId, $key, wp_slash($value)); } } }