public function set_options($label, $options)
{
if (is_array($label)) {
$options = $label;
} else {
$options['label'] = $label;
}
// Get all the public properties for this object
$properties = call_user_func('get_object_vars', $this);
foreach ($options as $key => $value) {
if (array_key_exists($key, $properties)) {
$this->{$key} = $value;
} elseif (self::$debug) {
$message = sprintf(__('You attempted to set a property "%1$s" that is nonexistant or invalid for an instance of "%2$s" named "%3$s".', 'fieldmanager'), $key, get_class($this), !empty($options['name']) ? $options['name'] : 'NULL');
throw new FM_Developer_Exception(esc_html($message));
}
}
// If this is a single field with a limit of 1, serialize_data has no impact
if (!$this->serialize_data && !$this->is_group() && 1 == $this->limit) {
$this->serialize_data = true;
}
// Cannot use serialize_data => false with index => true
if (!$this->serialize_data && $this->index) {
throw new FM_Developer_Exception(esc_html__('You cannot use `"serialize_data" => false` with `"index" => true`', 'fieldmanager'));
}
}