General: Use clean WordPress version in `is_wp_version_compatible()`.

Update `is_wp_version_compatible()` to use `wp_get_wp_version()` introduced in [58813] to ensure the value of `$wp_version` has not been modified by a theme or plugin.

Props costdev, mukesh27, Cybr, sergeybiryukov.
Fixes #61781.


Built from https://develop.svn.wordpress.org/trunk@58843


git-svn-id: http://core.svn.wordpress.org/trunk@58239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2024-08-02 22:38:15 +00:00
parent 99fc7666ac
commit 6a559b739b
2 changed files with 11 additions and 3 deletions

View File

@ -8833,13 +8833,21 @@ function wp_get_wp_version() {
*
* @since 5.2.0
*
* @global string $wp_version The WordPress version string.
* @global string $_wp_tests_wp_version The WordPress version string. Used only in Core tests.
*
* @param string $required Minimum required WordPress version.
* @return bool True if required version is compatible or empty, false if not.
*/
function is_wp_version_compatible( $required ) {
global $wp_version;
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 );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58842';
$wp_version = '6.7-alpha-58843';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.