| | |
| | | MetaTypeManager::getSanitizeCallback($field_config['type']); |
| | | } |
| | | |
| | | protected static function sanitizeTaxonomy(array|string $values, array $field_config):string |
| | | protected static function sanitizeTaxonomy(string $values, array $field_config):string |
| | | { |
| | | if (!is_array($values)) { |
| | | $values = explode(',', $values); |
| | | } |
| | | $values = array_map('absint', explode(',', $values)); |
| | | |
| | | // Ensure taxonomy starts with BASE |
| | | $taxonomy = (str_starts_with($field_config['taxonomy'], BASE)) |
| | |
| | | return implode(',', $values); |
| | | } |
| | | |
| | | protected static function sanitizeUser(array|string $values, array $field_config):string |
| | | protected static function sanitizeUser(string $values, array $field_config):string |
| | | { |
| | | if (!is_array($values)) { |
| | | $values = explode(',', $values); |
| | | } |
| | | $values = array_map('absint', explode(',', $values)); |
| | | |
| | | $values = array_filter($values, fn($value) => (bool)get_userdata((int)$value)); |
| | | |
| | | return implode(',', $values); |
| | | } |
| | | |
| | | protected static function sanitizePost(string $values, array $config):string |
| | | { |
| | | $values = array_map('absint', explode(',', $values)); |
| | | return implode(',', array_filter($values, fn($value) => (bool)get_post((int)$value))); |
| | | } |
| | | |
| | | protected static function sanitizeTagList(array $values, array $field_config): array |
| | | { |
| | | if (empty(array_filter($values, fn($value) => !empty($value)))) { |
| | |
| | | return $sanitized; |
| | | } |
| | | |
| | | protected static function sanitizeSelector(string $value, array $config):string |
| | | { |
| | | if (array_key_exists('type', $config)) { |
| | | return match ($config['type']) { |
| | | 'user' => self::sanitizeUser($value, $config), |
| | | 'taxonomy'=> self::sanitizeTaxonomy($value, $config), |
| | | 'post' => self::sanitizePost($value, $config), |
| | | }; |
| | | } |
| | | return implode(',',array_map('absint', explode(',',$value))); |
| | | } |
| | | |
| | | protected static function sanitizeUpload(array|string $value):string |
| | | { |
| | | if (empty($value)) { |