# _wptexturize_pushpop_element()

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

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

## Сигнатура

```php
_wptexturize_pushpop_element( string $text, string[] $stack, string[] $disabled_elements )
```

## Описание

Предполагает, что первый символ $text — открытие тега, а последний — закрытие тега.
Предполагает, что второй символ $text может быть /, обозначающим закрытие, как в .

## Параметры

- `$text` `string` — обязательный. Текст для проверки. Должен быть тегом вроде или [shortcode].
- `$stack` `string[]` — обязательный. Массив элементов открытых тегов.
- `$disabled_elements` `string[]` — обязательный. Массив имён тегов для сопоставления. Пробелы в именах тегов не допускаются.

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

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

```php
function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
	// Is it an opening tag or closing tag?
	if ( isset( $text[1] ) && '/' !== $text[1] ) {
		$opening_tag = true;
		$name_offset = 1;
	} elseif ( 0 === count( $stack ) ) {
		// Stack is empty. Just stop.
		return;
	} else {
		$opening_tag = false;
		$name_offset = 2;
	}

	// Parse out the tag name.
	$space = strpos( $text, ' ' );
	if ( false === $space ) {
		$space = -1;
	} else {
		$space -= $name_offset;
	}
	$tag = substr( $text, $name_offset, $space );

	// Handle disabled tags.
	if ( in_array( $tag, $disabled_elements, true ) ) {
		if ( $opening_tag ) {
			/*
			 * This disables texturize until we find a closing tag of our type
			 * (e.g. <pre>) even if there was invalid nesting before that.
			 *
			 * Example: in the case <pre>sadsadasd</code>"baba"</pre>
			 *          "baba" won't be texturized.
			 */

			array_push( $stack, $tag );
		} elseif ( end( $stack ) === $tag ) {
			array_pop( $stack );
		}
	}
}
```

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

- 2.9.0 — Introduced.

## Связанные

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

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