WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Countries::get_formatted_address() WC 1.0

Get country address format.

Это метод класса: WC_Countries

Хуки из метода
Возвращает

Строку.

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

$WC_Countries = new WC_Countries();
$var = $WC_Countries->get_formatted_address( $args, $separator );
$args(массив)
Arguments.
По умолчанию: array()
$separator(строка)
How to separate address lines. @since 3.5.0.
По умолчанию: '
'

Код WC Countries::get formatted address: woocommerce/includes/class-wc-countries.php WC 3.6.3

<?php
public function get_formatted_address( $args = array(), $separator = '<br/>' ) {
	$default_args = array(
		'first_name' => '',
		'last_name'  => '',
		'company'    => '',
		'address_1'  => '',
		'address_2'  => '',
		'city'       => '',
		'state'      => '',
		'postcode'   => '',
		'country'    => '',
	);

	$args    = array_map( 'trim', wp_parse_args( $args, $default_args ) );
	$state   = $args['state'];
	$country = $args['country'];

	// Get all formats.
	$formats = $this->get_address_formats();

	// Get format for the address' country.
	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];

	// Handle full country name.
	$full_country = ( isset( $this->countries[ $country ] ) ) ? $this->countries[ $country ] : $country;

	// Country is not needed if the same as base.
	if ( $country === $this->get_base_country() && ! apply_filters( 'woocommerce_formatted_address_force_country_display', false ) ) {
		$format = str_replace( '{country}', '', $format );
	}

	// Handle full state name.
	$full_state = ( $country && $state && isset( $this->states[ $country ][ $state ] ) ) ? $this->states[ $country ][ $state ] : $state;

	// Substitute address parts into the string.
	$replace = array_map(
		'esc_html',
		apply_filters(
			'woocommerce_formatted_address_replacements',
			array(
				'{first_name}'       => $args['first_name'],
				'{last_name}'        => $args['last_name'],
				'{name}'             => $args['first_name'] . ' ' . $args['last_name'],
				'{company}'          => $args['company'],
				'{address_1}'        => $args['address_1'],
				'{address_2}'        => $args['address_2'],
				'{city}'             => $args['city'],
				'{state}'            => $full_state,
				'{postcode}'         => $args['postcode'],
				'{country}'          => $full_country,
				'{first_name_upper}' => wc_strtoupper( $args['first_name'] ),
				'{last_name_upper}'  => wc_strtoupper( $args['last_name'] ),
				'{name_upper}'       => wc_strtoupper( $args['first_name'] . ' ' . $args['last_name'] ),
				'{company_upper}'    => wc_strtoupper( $args['company'] ),
				'{address_1_upper}'  => wc_strtoupper( $args['address_1'] ),
				'{address_2_upper}'  => wc_strtoupper( $args['address_2'] ),
				'{city_upper}'       => wc_strtoupper( $args['city'] ),
				'{state_upper}'      => wc_strtoupper( $full_state ),
				'{state_code}'       => wc_strtoupper( $state ),
				'{postcode_upper}'   => wc_strtoupper( $args['postcode'] ),
				'{country_upper}'    => wc_strtoupper( $full_country ),
			),
			$args
		)
	);

	$formatted_address = str_replace( array_keys( $replace ), $replace, $format );

	// Clean up white space.
	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
	$formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );

	// Break newlines apart and remove empty lines/trim commas and white space.
	$formatted_address = array_filter( array_map( array( $this, 'trim_formatted_address_line' ), explode( "\n", $formatted_address ) ) );

	// Add html breaks.
	$formatted_address = implode( $separator, $formatted_address );

	// We're done!
	return $formatted_address;
}