# wp_get_theme_preview_path()

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

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

## Сигнатура

```php
wp_get_theme_preview_path( string $current_stylesheet = null ): string
```

## Описание

Фильтрует опцию блога, чтобы вернуть путь к просматриваемой теме.

## Параметры

- `$current_stylesheet` `string` — необязательный, по умолчанию `null`. Путь к таблице стилей или шаблону текущей темы.

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

`string`

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

Файл: `wp-includes/theme-previews.php:16`

```php
function wp_get_theme_preview_path( $current_stylesheet = null ) {
	if ( ! current_user_can( 'switch_themes' ) ) {
		return $current_stylesheet;
	}

	$preview_stylesheet = ! empty( $_GET['wp_theme_preview'] ) ? sanitize_text_field( wp_unslash( $_GET['wp_theme_preview'] ) ) : null;
	$wp_theme           = wp_get_theme( $preview_stylesheet );
	if ( ! is_wp_error( $wp_theme->errors() ) ) {
		if ( current_filter() === 'template' ) {
			$theme_path = $wp_theme->get_template();
		} else {
			$theme_path = $wp_theme->get_stylesheet();
		}

		return sanitize_text_field( $theme_path );
	}

	return $current_stylesheet;
}
```

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

- 6.3.0 — Introduced.

## Связанные

Использует: `WP_Theme::get_template`, `WP_Theme::get_stylesheet`, `WP_Theme::errors`, [`current_filter`](https://chugunov.pro/api-wordpress/functions/current_filter/), [`current_user_can`](https://chugunov.pro/api-wordpress/functions/current_user_can/), [`wp_get_theme`](https://chugunov.pro/api-wordpress/functions/wp_get_theme/), `WP_Theme`, [`sanitize_text_field`](https://chugunov.pro/api-wordpress/functions/sanitize_text_field/), [`wp_unslash`](https://chugunov.pro/api-wordpress/functions/wp_unslash/), [`is_wp_error`](https://chugunov.pro/api-wordpress/functions/is_wp_error/).
Используется в: [`wp_block_theme_activate_nonce`](https://chugunov.pro/api-wordpress/functions/wp_block_theme_activate_nonce/).

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