is_wp_version_compatible( string $required ): bool

In this article

Checks compatibility with the current WordPress version.

Parameters

$requiredstringrequired
Minimum required WordPress version.

Return

bool True if required version is compatible or empty, false if not.

Source

function is_wp_version_compatible( $required ) {
	global $wp_version;

	// Strip off any -alpha, -RC, -beta, -src suffixes.
	list( $version ) = explode( '-', $wp_version );

	if ( is_string( $required ) ) {
		$trimmed = trim( $required );

		if ( substr_count( $trimmed, '.' ) > 1 && str_ends_with( $trimmed, '.0' ) ) {
			$required = substr( $trimmed, 0, -2 );
		}
	}

	return empty( $required ) || version_compare( $version, $required, '>=' );
}

Changelog

VersionDescription
5.2.0Introduced.

User Contributed Notes

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