acf_field_google_map::format_place │ private │ ACF 6.8.0

Format value as Place.

Method of the class: acf_field_google_map{}

No Hooks.

Returns

array|null.

Usage

// private - for code of main (parent) class only
$result = $this->format_place( $value );
$value(array) (required)
The google map value array.

Changelog

Since 6.8.0 Introduced.

acf_field_google_map::format_place() code ACF 6.8.8

private function format_place( $value ) {
	$place = array(
		'@type' => 'Place',
	);

	// Add name if available.
	if ( ! empty( $value['name'] ) ) {
		$place['name'] = $value['name'];
	}

	// Add full address as formatted string.
	if ( ! empty( $value['address'] ) ) {
		$place['address'] = $value['address'];
	}

	// Add geo coordinates.
	$geo = $this->format_geo_coordinates( $value );
	if ( $geo ) {
		$place['geo'] = $geo;
	}

	// Only return if we have meaningful data beyond @type.
	if ( count( $place ) > 1 ) {
		return $place;
	}

	return null;
}