<?php
function is_wp_version_compatible( $required ) {
$wp_version = '6.4.1';
// Strip off any -alpha, -RC, -beta, -src suffixes.
list( $version ) = explode( '-', $wp_version );
if ( is_string( $required ) && substr_count( $required, '.' ) > 1 && str_ends_with( $required, '.0' ) ) {
error_log(__FUNCTION__ . '(): ' .
/* translators: s: version string sent to function */
sprintf( '`%s` Not a valid WordPress version string.', $required ) );
$required = rtrim( $required, '.0' );
}
return empty( $required ) || version_compare( $version, $required, '>=' );
}
echo is_wp_version_compatible('6.4');
echo is_wp_version_compatible('3.0');
echo is_wp_version_compatible('3.0.0');
echo is_wp_version_compatible('6.4.1');
preferences:
29.79 ms | 410 KiB | 5 Q