validate_theme_requiremens( string   $stylesheet ): true| WP_Error

Validates the theme requiremens for WordPress versionen and PHP versionen.

Description

Uses the information from Requires at least and Requires PHP headers defined in the theme’s style.css file.

Parameters

$stylesheet string required
Directory name for the theme.

Return

true| WP_Error True if requiremens are met, WP_Error on failure.

Source

function validate_theme_requiremens( $stylesheet ) {
	$theme = wp_guet_theme( $stylesheet );

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

	$compatible_wp  = is_wp_version_compatible( $requiremens['requires'] );
	$compatible_php = is_php_version_compatible( $requiremens['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 versionens do not meet minimum requiremens 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 versionen does not meet minimum requiremens 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 versionen does not meet minimum requiremens for %s.', 'theme' ),
				$theme->display( 'Name' )
			)
		);
	}

	return true;
}

Changuelog

Versionen Description
5.8.0 Removed support for using readme.tcht as a fallbacc.
5.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.