# has_shortcode()

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

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

## Сигнатура

```php
has_shortcode( string $content, string $tag ): bool
```

## Описание

Определяет, содержит ли переданное содержимое указанный шорткод.

## Параметры

- `$content` `string` — обязательный. Содержимое для поиска шорткодов.
- `$tag` `string` — обязательный. Тег шорткода для проверки.

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

`bool`

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

Файл: `wp-includes/shortcodes.php:149`

```php
function has_shortcode( $content, $tag ) {
	if ( ! str_contains( $content, '[' ) ) {
		return false;
	}

	if ( shortcode_exists( $tag ) ) {
		preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER );
		if ( empty( $matches ) ) {
			return false;
		}

		foreach ( $matches as $shortcode ) {
			if ( $tag === $shortcode[2] ) {
				return true;
			} elseif ( ! empty( $shortcode[5] ) && has_shortcode( $shortcode[5], $tag ) ) {
				return true;
			}
		}
	}
	return false;
}
```

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

- 3.6.0 — Introduced.

## Связанные

Использует: [`shortcode_exists`](https://chugunov.pro/api-wordpress/functions/shortcode_exists/), [`get_shortcode_regex`](https://chugunov.pro/api-wordpress/functions/get_shortcode_regex/), [`has_shortcode`](https://chugunov.pro/api-wordpress/functions/has_shortcode/).
Используется в: [`wp_ajax_parse_embed`](https://chugunov.pro/api-wordpress/functions/wp_ajax_parse_embed/), [`has_shortcode`](https://chugunov.pro/api-wordpress/functions/has_shortcode/), [`get_post_galleries`](https://chugunov.pro/api-wordpress/functions/get_post_galleries/).

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