acf_field_google_map::format_value_for_jsonldpublicACF 6.8.0

Formats the field value for JSON-LD output.

Метод класса: acf_field_google_map{}

Хуков нет.

Возвращает

mixed.

Использование

$acf_field_google_map = new acf_field_google_map();
$acf_field_google_map->format_value_for_jsonld( $value, $post_id, $field );
$value(разное) (обязательный)
The value of the field.
$post_id(int|строка) (обязательный)
The ID of the post.
$field(массив) (обязательный)
The field array.

Список изменений

С версии 6.8.0 Введена.

Код acf_field_google_map::format_value_for_jsonld() ACF 6.8.8

public function format_value_for_jsonld( $value, $post_id, $field ) {
	if ( empty( $value ) || ! is_array( $value ) ) {
		return null;
	}

	// Get output format with fallback.
	$output_format = $field['schema_output_format'] ?? '';
	if ( empty( $output_format ) ) {
		$property      = $field['schema_property'] ?? '';
		$output_format = \ACF\AI\GEO\Schema::get_default_output_format( $this->name, $property );
	}

	// Default to Place if no format determined.
	if ( empty( $output_format ) ) {
		$output_format = 'Place';
	}

	switch ( $output_format ) {
		case 'GeoCoordinates':
			return $this->format_geo_coordinates( $value );

		case 'PostalAddress':
			return $this->format_postal_address( $value );

		case 'Place':
		default:
			return $this->format_place( $value );
	}
}