# _make_url_clickable_cb()

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

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

## Сигнатура

```php
_make_url_clickable_cb( array $matches ): string
```

## Описание

Эта функция была портирована из 2.5.0 в 2.3.2. Функция обратного вызова для регулярного выражения в make_clickable() .

## Параметры

- `$matches` `array` — обязательный. Одиночное совпадение регулярного выражения.

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

`string`

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

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

```php
function _make_url_clickable_cb( $matches ) {
	$url = $matches[2];

	if ( ')' === $matches[3] && strpos( $url, '(' ) ) {
		/*
		 * If the trailing character is a closing parenthesis, and the URL has an opening parenthesis in it,
		 * add the closing parenthesis to the URL. Then we can let the parenthesis balancer do its thing below.
		 */
		$url   .= $matches[3];
		$suffix = '';
	} else {
		$suffix = $matches[3];
	}

	if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
		$url .= $matches[4];
	}

	// Include parentheses in the URL only if paired.
	while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
		$suffix = strrchr( $url, ')' ) . $suffix;
		$url    = substr( $url, 0, strrpos( $url, ')' ) );
	}

	$url = esc_url( $url );
	if ( empty( $url ) ) {
		return $matches[0];
	}

	$rel_attr = _make_clickable_rel_attr( $url );

	return $matches[1] . "<a href=\"{$url}\"{$rel_attr}>{$url}</a>" . $suffix;
}
```

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

- 2.3.2 — Introduced.

## Связанные

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

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