# get_theme_root()

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

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

## Сигнатура

```php
get_theme_root( string $stylesheet_or_template = '' ): string
```

## Описание

Без завершающего слэша.

## Параметры

- `$stylesheet_or_template` `string` — необязательный, по умолчанию `''`. Имя таблицы стилей или шаблона темы.
  
  По умолчанию используется основной корневой каталог тем.

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

`string`

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

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

```php
function get_theme_root( $stylesheet_or_template = '' ) {
	global $wp_theme_directories;

	$theme_root = '';

	if ( $stylesheet_or_template ) {
		$theme_root = get_raw_theme_root( $stylesheet_or_template );
		if ( $theme_root ) {
			/*
			 * Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
			 * This gives relative theme roots the benefit of the doubt when things go haywire.
			 */
			if ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
				$theme_root = WP_CONTENT_DIR . $theme_root;
			}
		}
	}

	if ( ! $theme_root ) {
		$theme_root = WP_CONTENT_DIR . '/themes';
	}

	/**
	 * Filters the absolute path to the themes directory.
	 *
	 * @since 1.5.0
	 *
	 * @param string $theme_root Absolute path to themes directory.
	 */
	return apply_filters( 'theme_root', $theme_root );
}
```

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

- 1.5.0 — Introduced.

## Связанные

Использует: [`get_raw_theme_root`](https://chugunov.pro/api-wordpress/functions/get_raw_theme_root/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`_load_script_textdomain_from_src`](https://chugunov.pro/api-wordpress/functions/_load_script_textdomain_from_src/), `WP_Debug_Data::get_wp_filesystem`, `WP_Debug_Data::get_wp_paths_sizes`, `WP_Debug_Data::get_sizes`, `WP_Automatic_Updater::update`, `Theme_Upgrader::check_parent_theme_filter`, `Theme_Upgrader::install`, `Theme_Upgrader::upgrade`, `Theme_Upgrader::bulk_upgrade`, `WP_Upgrader::fs_connect`, `WP_Filesystem_Base::wp_themes_dir`, [`get_stylesheet_directory`](https://chugunov.pro/api-wordpress/functions/get_stylesheet_directory/), [`get_template_directory`](https://chugunov.pro/api-wordpress/functions/get_template_directory/).

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