# convert_smilies()

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

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

## Сигнатура

```php
convert_smilies( string $text ): string
```

## Описание

Преобразует смайлики только если опция ‘use_smilies’ равна true, а используемый в функции глобальный массив не пуст.

## Параметры

- `$text` `string` — обязательный. Содержимое, в котором текстовые смайлики нужно преобразовать.

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

`string`

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

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

```php
function convert_smilies( $text ) {
	global $wp_smiliessearch;

	if ( ! get_option( 'use_smilies' ) || empty( $wp_smiliessearch ) ) {
		// Return default text.
		return $text;
	}

	// HTML loop taken from texturize function, could possible be consolidated.
	$textarr = preg_split( '/(<[^>]*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Capture the tags as well as in between.

	if ( false === $textarr ) {
		// Return default text.
		return $text;
	}

	// Loop stuff.
	$stop   = count( $textarr );
	$output = '';

	// Ignore processing of specific tags.
	$tags_to_ignore       = 'code|pre|style|script|textarea';
	$ignore_block_element = '';

	for ( $i = 0; $i < $stop; $i++ ) {
		$content = $textarr[ $i ];

		// If we're in an ignore block, wait until we find its closing tag.
		if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) {
			$ignore_block_element = $matches[1];
		}

		// If it's not a tag and not in ignore block.
		if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) {
			$content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content );
		}

		// Did we exit ignore block?
		if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) {
			$ignore_block_element = '';
		}

		$output .= $content;
	}

	return $output;
}
```

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

- 0.71 — Introduced.

## Связанные

Использует: [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: [`get_the_block_template_html`](https://chugunov.pro/api-wordpress/functions/get_the_block_template_html/).

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