/** * Normalize parameters for field * * @param array $field * @return array */ public static function normalize($field) { $field = $field['multiple'] ? RWMB_Multiple_Values_Field::normalize($field) : $field; $field = RWMB_Input_Field::normalize($field); $field = parent::normalize($field); $field = wp_parse_args($field, array('collapse' => true, 'inline' => null)); $field['flatten'] = $field['multiple'] ? $field['flatten'] : true; $field['inline'] = !$field['multiple'] && !isset($field['inline']) ? true : $field['inline']; return $field; }
/** * Normalize parameters for field * * @param array $field * * @return array */ public static function normalize($field) { $field = parent::normalize($field); $field = wp_parse_args($field, array('flatten' => true, 'query_args' => array(), 'field_type' => 'select_advanced')); if ('checkbox_tree' === $field['field_type']) { $field['field_type'] = 'checkbox_list'; $field['flatten'] = false; } if ('radio_list' == $field['field_type']) { $field['multiple'] = false; } if ('checkbox_list' == $field['field_type']) { $field['multiple'] = true; } return call_user_func(array(self::get_type_class($field), 'normalize'), $field); }
/** * Get the attributes for a field * * @param array $field * @param mixed $value * * @return array */ public static function get_attributes($field, $value = null) { $attributes = parent::get_attributes($field, $value); $attributes = wp_parse_args($attributes, array('multiple' => $field['multiple'], 'size' => $field['size'])); return $attributes; }
/** * Save meta value * * @param $new * @param $old * @param $post_id * @param $field */ static function save($new, $old, $post_id, $field) { delete_post_meta($post_id, $field['id']); parent::save($new, array(), $post_id, $field); }
/** * Output the field value * Display option name instead of option value * * @use self::meta() * * @param array $field Field parameters * @param array $args Additional arguments. Rarely used. See specific fields for details * @param int|null $post_id Post ID. null for current post. Optional. * * @return mixed Field value */ public static function the_value($field, $args = array(), $post_id = null) { $value = parent::get_value($field, $args, $post_id); return empty($value) ? '' : $field['options'][$value]; }