/** * Presave function, which handles sanitization and validation * * @param int|array $values This will either be a post ID or array of * post IDs. * @return int|array Sanitized values. */ public function presave($values, $current_values = array()) { if (is_array($values)) { // Fieldmanager_Field doesn't like it when $values is an array, // so we need to replicate what it does here. foreach ($values as $value) { foreach ($this->validate as $func) { if (!call_user_func($func, $value)) { $this->_failed_validation(sprintf(__('Input "%1$s" is not valid for field "%2$s" ', 'fm-zones'), (string) $value, $this->label)); } } } return array_map($this->sanitize, $values); } else { return parent::presave($values, $current_values); } }