# wp_sprintf_l()

URL: https://chugunov.pro/api-wordpress/functions/wp_sprintf_l/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.5.0.

## Сигнатура

```php
wp_sprintf_l( string $pattern, array $args ): string
```

## Описание

‘%l’ должен находиться в самом начале, а далее может следовать остальное содержимое. К элементам списка добавляются ‘, ‘, ‘, and’ и ‘ and ‘ в зависимости от количества элементов списка в параметре $args.

## Параметры

- `$pattern` `string` — обязательный. Содержимое, начинающееся с '%l'.
- `$args` `array` — обязательный. Элементы списка, которые добавляются в начало содержимого и заменяют '%l'.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/formatting.php:5324`

```php
function wp_sprintf_l( $pattern, $args ) {
	// Not a match.
	if ( ! str_starts_with( $pattern, '%l' ) ) {
		return $pattern;
	}

	// Nothing to work with.
	if ( empty( $args ) ) {
		return '';
	}

	/**
	 * Filters the translated delimiters used by wp_sprintf_l().
	 * Placeholders (%s) are included to assist translators and then
	 * removed before the array of strings reaches the filter.
	 *
	 * Please note: Ampersands and entities should be avoided here.
	 *
	 * @since 2.5.0
	 *
	 * @param array $delimiters An array of translated delimiters.
	 */
	$l = apply_filters(
		'wp_sprintf_l',
		array(
			/* translators: Used to join items in a list with more than 2 items. */
			'between'          => sprintf( __( '%1$s, %2$s' ), '', '' ),
			/* translators: Used to join last two items in a list with more than 2 times. */
			'between_last_two' => sprintf( __( '%1$s, and %2$s' ), '', '' ),
			/* translators: Used to join items in a list with only 2 items. */
			'between_only_two' => sprintf( __( '%1$s and %2$s' ), '', '' ),
		)
	);

	$args   = (array) $args;
	$result = array_shift( $args );
	if ( 1 === count( $args ) ) {
		$result .= $l['between_only_two'] . array_shift( $args );
	}

	// Loop when more than two args.
	$i = count( $args );
	while ( $i ) {
		$arg = array_shift( $args );
		--$i;
		if ( 0 === $i ) {
			$result .= $l['between_last_two'] . $arg;
		} else {
			$result .= $l['between'] . $arg;
		}
	}

	return $result . substr( $pattern, 2 );
}
```

## История изменений

- 2.5.0 — Introduced.

## Связанные

Использует: [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_sprintf_l/
