# validate_theme_requirements()

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

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

## Сигнатура

```php
validate_theme_requirements( string $stylesheet ): true|WP_Error
```

## Описание

Использует данные из заголовков Requires at least и Requires PHP, заданных в файле style.css темы.

## Параметры

- `$stylesheet` `string` — обязательный. Имя каталога темы.

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

`true|WP_Error` — WP_Error

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

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

```php
function validate_theme_requirements( $stylesheet ) {
	$theme = wp_get_theme( $stylesheet );

	$requirements = array(
		'requires'     => ! empty( $theme->get( 'RequiresWP' ) ) ? $theme->get( 'RequiresWP' ) : '',
		'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '',
	);

	$compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
	$compatible_php = is_php_version_compatible( $requirements['requires_php'] );

	if ( ! $compatible_wp && ! $compatible_php ) {
		return new WP_Error(
			'theme_wp_php_incompatible',
			sprintf(
				/* translators: %s: Theme name. */
				_x( '<strong>Error:</strong> Current WordPress and PHP versions do not meet minimum requirements for %s.', 'theme' ),
				$theme->display( 'Name' )
			)
		);
	} elseif ( ! $compatible_php ) {
		return new WP_Error(
			'theme_php_incompatible',
			sprintf(
				/* translators: %s: Theme name. */
				_x( '<strong>Error:</strong> Current PHP version does not meet minimum requirements for %s.', 'theme' ),
				$theme->display( 'Name' )
			)
		);
	} elseif ( ! $compatible_wp ) {
		return new WP_Error(
			'theme_wp_incompatible',
			sprintf(
				/* translators: %s: Theme name. */
				_x( '<strong>Error:</strong> Current WordPress version does not meet minimum requirements for %s.', 'theme' ),
				$theme->display( 'Name' )
			)
		);
	}

	/**
	 * Filters the theme requirement validation response.
	 *
	 * If a theme fails due to a Core-provided validation (incompatible WP, PHP versions), this
	 * filter will not fire. A WP_Error response will already be returned.
	 *
	 * This filter is intended to add additional validation steps by site administrators.
	 *
	 * @since 6.9.0
	 *
	 * @param bool|WP_Error $met_requirements True if the theme meets requirements, WP_Error if not.
	 * @param string $stylesheet Directory name for the theme.
	 */
	return apply_filters( 'validate_theme_requirements', true, $stylesheet );
}
```

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

- 5.8.0 — Removed support for using readme.txt as a fallback.
- 5.5.0 — Introduced.

## Связанные

Использует: [`is_wp_version_compatible`](https://chugunov.pro/api-wordpress/functions/is_wp_version_compatible/), [`is_php_version_compatible`](https://chugunov.pro/api-wordpress/functions/is_php_version_compatible/), [`wp_get_theme`](https://chugunov.pro/api-wordpress/functions/wp_get_theme/), `WP_Theme`, [`_x`](https://chugunov.pro/api-wordpress/functions/_x/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), `WP_Error::__construct`.
Используется в: [`switch_theme`](https://chugunov.pro/api-wordpress/functions/switch_theme/).

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