Carbon_Fields\Helper\Helper::get_field_value PHP Method

get_field_value() public static method

Handles the logic for different field types.
public static get_field_value ( string $data_type, string $name, string $type = null, integer $id = null ) : mixed
$data_type string Data type.
$name string Custom field name.
$type string Custom field type (optional).
$id integer ID (optional).
return mixed Meta value.
    public static function get_field_value($data_type, $name, $type = null, $id = null)
    {
        $datastore_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $data_type)));
        switch ($type) {
            case 'complex':
                $value = self::get_complex_fields($datastore_name, $name, $id);
                break;
            case 'map':
            case 'map_with_address':
                $value = array('lat' => (double) self::get_field_value_by_store($data_type, $name . '-lat', $id), 'lng' => (double) self::get_field_value_by_store($data_type, $name . '-lng', $id), 'address' => self::get_field_value_by_store($data_type, $name . '-address', $id), 'zoom' => (int) self::get_field_value_by_store($data_type, $name . '-zoom', $id));
                if (!array_filter($value)) {
                    $value = array();
                }
                break;
            case 'association':
                $raw_value = self::get_field_value_by_store($data_type, $name, $id);
                $value = self::parse_relationship_field($raw_value, $type);
                break;
            default:
                $value = self::get_field_value_by_store($data_type, $name, $id);
                // backward compatibility for the old Relationship field
                $value = self::maybe_old_relationship_field($value);
        }
        return $value;
    }