_array_only as $name) { if (!is_array($this->{$name})) { $this->{$name} = array(); } } foreach ($this->_array_or_string as $name) { $this->{$name} = ACF_Stylizer_Utilities::check_array($this->{$name}); } } /** * Get a default value based on the provided name. * * @since 2.0.0 * * @access protected * @param string $name Name of the value to return. * @return mixed Default value if it exists, otherwise an empty string. */ protected function _default($name) { switch ($name) { /** * Additional attributes to add to the field. * * @since 2.0.0 * * @var array */ case 'attributes': /** * CSS classes added to the field input element. * * @since 2.0.0 * * @var array */ case 'classes': /** * Conditions for a field to be visible. * * @since 2.0.0 * * @var array */ case 'conditions': /** * Child fields for this field. * * @since 2.0.0 * * @var array */ case 'fields': /** * Value collection containing the values for all meta box fields. * * @since 2.0.0 * * @var mixed */ case 'value_collection': /** * Attributes for the field wrapper. * * @since 2.0.0 * * @var array */ case 'wrapper_attributes': /** * CSS classes added to the field wrapper. * * @since 2.0.0 * * @var array */ case 'wrapper_classes': return array(); /** * Conditions output generated by other fields. * * @since 2.0.0 * * @var string */ case 'conditions_output': /** * Short description display with the field. * * @since 2.0.0 * * @var string */ case 'description': /** * Output label displayed with the field. * * @since 2.0.0 * * @var string */ case 'label': /** * Base name for the field. * * @since 2.0.0 * * @var string */ case 'name': /** * Field box option name. * * @since 2.0.0 * * @var string */ case 'option_name': return ''; /** * True if the labels should be hidden from the field output. * * @since 2.0.0 * * @var boolean */ case 'hide_labels': /** * True if a clear DIV should be added after this field. * * @since 2.0.0 * * @var boolean */ case 'include_clear': /** * True if the field is tall and the description should be displayed below the label. * * @since 2.0.0 * * @var boolean */ case 'is_tall': /** * True if the current field is a template. * * @since 2.0.0 * * @var boolean */ case 'is_template': /** * True if the field has been outputted. * * @since 2.0.0 * * @var boolean */ case 'outputted': return false; /** * Generated DOM ID. * * @since 2.0.0 * * @var string */ case 'id': $name = $this->name; if (!empty($name)) { $has_sanitization = (!empty($this->sanitization)); if (empty($this->option_name)) { $name = ($has_sanitization) ? $this->sanitization . '[' . $name . ']' : $name; } else { $name = '[' . $name . ']'; $name = ($has_sanitization) ? $this->option_name . '[' . $this->sanitization . ']' . $name : $this->option_name . $name; } } return str_replace('[]]', '][]', $name); /** * Generated field identifier attributes. * * @since 2.0.2 Improved condition. * @since 2.0.0 * * @var string */ case 'input_attributes': $attributes = ''; if (!empty($this->id)) { $attributes = (strpos($this->id, '__i__') === false) ? ' id="acfs-' . $this->id . '" name="' . $this->id . '"' : ' data-acfs-identifier="' . $this->id . '"'; } foreach ($this->attributes as $name => $value) { if ($value !== '') { $attributes .= ' ' . sanitize_key($name) . '="' . esc_attr($value) . '"'; } } return $attributes; /** * Generated label attributes. * * @since 2.0.0 * * @var string */ case 'label_attribute': if (empty($this->id)) { return ''; } return (strpos($this->id, '__i__') === false) ? ' for="acfs-' . $this->id . '"' : ' data-acfs-identifier="acfs-' . $this->id . '"'; /** * Sanitization name to use for the field. * * @since 2.0.0 * * @var string */ case 'sanitization': return ACF_Stylizer_Sanitization::TEXT; /** * Current value for the field. * * @since 2.0.1 Improved value collection functionality. * @since 2.0.0 * * @var mixed */ case 'value': if ( empty($this->name) || empty($this->value_collection) ) { return ''; } $value_collection = $this->value_collection; if (is_object($value_collection)) { return (isset($value_collection->{$this->name})) ? $value_collection->{$this->name} : ''; } return (isset($value_collection[$this->name])) ? $value_collection[$this->name] : ''; } return parent::_default($name); } /** * Assemble the field classes. * * @since 2.0.0 * * @access protected * @param boolean $add_attr True if the class attribute should be added. * @return string Assembled field class(es). */ protected function _field_classes($add_attr = true) { if (!empty($this->classes)) { $classes = esc_attr(implode(' ', $this->classes)); return ($add_attr) ? ' class="' . $classes . '"' : ' ' . $classes; } return ''; } /** * Generate the output for the field. * * @since 2.0.0 * * @access protected * @param string $field Generated field output. * @param string $type Field type slug. * @param boolean $echo True if the field should be echoed. * @return string Generated field if $echo is false. */ protected function _output($field, $type, $echo) { $this->outputted = true; $output = ''; if (!empty($field)) { $wrapper_attributes = $description = $label_description = $label = ''; $condition_attr = ' data-acfs-field="'; $condition_replacement = $condition_attr . '__f__"'; $this->push('wrapper_classes', 'acfs-field'); $this->push('wrapper_classes', 'acfs-field-' . sanitize_key($type)); if ($this->is_template) { $this->push('wrapper_classes', 'acfs-field-template'); } foreach ($this->wrapper_attributes as $name => $value) { $wrapper_attributes .= ' ' . sanitize_key($name) . '="' . esc_attr($value) . '"'; } if (!$this->hide_labels) { if (!empty($this->description)) { $description = '