# get_theme_root_uri()

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

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

## Сигнатура

```php
get_theme_root_uri( string $stylesheet_or_template = '', string $theme_root = '' ): string
```

## Описание

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

## Параметры

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

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

`string`

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

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

```php
function get_theme_root_uri( $stylesheet_or_template = '', $theme_root = '' ) {
	global $wp_theme_directories;

	if ( $stylesheet_or_template && ! $theme_root ) {
		$theme_root = get_raw_theme_root( $stylesheet_or_template );
	}

	if ( $stylesheet_or_template && $theme_root ) {
		if ( in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
			// Absolute path. Make an educated guess. YMMV -- but note the filter below.
			if ( str_starts_with( $theme_root, WP_CONTENT_DIR ) ) {
				$theme_root_uri = content_url( str_replace( WP_CONTENT_DIR, '', $theme_root ) );
			} elseif ( str_starts_with( $theme_root, ABSPATH ) ) {
				$theme_root_uri = site_url( str_replace( ABSPATH, '', $theme_root ) );
			} elseif ( str_starts_with( $theme_root, WP_PLUGIN_DIR ) || str_starts_with( $theme_root, WPMU_PLUGIN_DIR ) ) {
				$theme_root_uri = plugins_url( basename( $theme_root ), $theme_root );
			} else {
				$theme_root_uri = $theme_root;
			}
		} else {
			$theme_root_uri = content_url( $theme_root );
		}
	} else {
		$theme_root_uri = content_url( 'themes' );
	}

	/**
	 * Filters the URI for themes directory.
	 *
	 * @since 1.5.0
	 *
	 * @param string $theme_root_uri         The URI for themes directory.
	 * @param string $siteurl                WordPress web address which is set in General Options.
	 * @param string $stylesheet_or_template The stylesheet or template name of the theme.
	 */
	return apply_filters( 'theme_root_uri', $theme_root_uri, get_option( 'siteurl' ), $stylesheet_or_template );
}
```

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

- 1.5.0 — Introduced.

## Связанные

Использует: [`get_raw_theme_root`](https://chugunov.pro/api-wordpress/functions/get_raw_theme_root/), [`content_url`](https://chugunov.pro/api-wordpress/functions/content_url/), [`plugins_url`](https://chugunov.pro/api-wordpress/functions/plugins_url/), [`site_url`](https://chugunov.pro/api-wordpress/functions/site_url/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: [`get_stylesheet_directory_uri`](https://chugunov.pro/api-wordpress/functions/get_stylesheet_directory_uri/), [`get_template_directory_uri`](https://chugunov.pro/api-wordpress/functions/get_template_directory_uri/), `WP_Theme::get_theme_root_uri`.

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