wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



is_wp_version_compatible › WordPress Function

Seit5.2.0
Veraltetn/v
is_wp_version_compatible ( $required )
Parameter:
  • (string) $required Minimum required WordPress version.
    Erforderlich: Ja
Gibt zurück:
  • (bool) True if required version is compatible or empty, false if not.
Definiert in:
Codex:

Checks compatibility with the current WordPress version.



Quellcode

function is_wp_version_compatible( $required ) {
	if (
		defined( 'WP_RUN_CORE_TESTS' )
		&& WP_RUN_CORE_TESTS
		&& isset( $GLOBALS['_wp_tests_wp_version'] )
	) {
		$wp_version = $GLOBALS['_wp_tests_wp_version'];
	} else {
		$wp_version = wp_get_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, '>=' );
}