# do_shortcode_tag()

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

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

## Сигнатура

```php
do_shortcode_tag( array $m ): string
```

## Описание

См. alsoget_shortcode_regex(): подробности о содержимом массива совпадений.

## Параметры

- `$m` `array` — обязательный. Массив совпадений регулярного выражения.
  
  0 string Полный текст совпавшего шорткода.
  
  1 string Необязательная вторая открывающая скобка для экранирования шорткодов.
  
  2 string Имя шорткода.
  
  3 string Список аргументов шорткода.
  
  4 string Необязательный самозакрывающий слеш.
  
  5 string Содержимое шорткода, когда он оборачивает какой-либо контент.
  
  6 string Необязательная вторая закрывающая скобка для экранирования шорткодов.

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

`string`

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

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

```php
function do_shortcode_tag( $m ) {
	global $shortcode_tags;

	// Allow [[foo]] syntax for escaping a tag.
	if ( '[' === $m[1] && ']' === $m[6] ) {
		return substr( $m[0], 1, -1 );
	}

	$tag  = $m[2];
	$attr = shortcode_parse_atts( $m[3] );

	if ( ! is_callable( $shortcode_tags[ $tag ] ) ) {
		_doing_it_wrong(
			__FUNCTION__,
			/* translators: %s: Shortcode tag. */
			sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag ),
			'4.3.0'
		);
		return $m[0];
	}

	/**
	 * Filters whether to call a shortcode callback.
	 *
	 * Returning a non-false value from filter will short-circuit the
	 * shortcode generation process, returning that value instead.
	 *
	 * @since 4.7.0
	 * @since 6.5.0 The `$attr` parameter is always an array.
	 *
	 * @param false|string $output Short-circuit return value. Either false or the value to replace the shortcode with.
	 * @param string       $tag    Shortcode name.
	 * @param array        $attr   Shortcode attributes array, can be empty if the original arguments string cannot be parsed.
	 * @param array        $m      Regular expression match array.
	 */
	$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
	if ( false !== $return ) {
		return $return;
	}

	$content = $m[5] ?? null;

	$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];

	/**
	 * Filters the output created by a shortcode callback.
	 *
	 * @since 4.7.0
	 * @since 6.5.0 The `$attr` parameter is always an array.
	 *
	 * @param string $output Shortcode output.
	 * @param string $tag    Shortcode name.
	 * @param array  $attr   Shortcode attributes array, can be empty if the original arguments string cannot be parsed.
	 * @param array  $m      Regular expression match array.
	 */
	return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
}
```

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

- 2.5.0 — Introduced.

## Связанные

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

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