Make WordPress Core


Ignore:
Timestamp:
07/27/2024 12:25:44 AM (11 months ago)
Author:
peterwilsoncc
Message:

General: Introduce wp_get_wp_version() to get unmodified version.

Introduces wp_get_wp_version() to get an unmodified value of $wp_version from wp-includes/version.php. Some plugins modify the global in an attempt to improve security through obscurity. This practice can cause errors in WordPress so the ability to get an unmodified version is needed.

Replaces instances within the code base in which version.php was required in order to get an unmodified value. script-loader.php is intentionally excluded from the replacements as the function is not always available to the file.

Props debarghyabanerjee, afragen, costdev.
See #61627.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r58763 r58813  
    90079007    echo wp_kses_post( wp_get_admin_notice( $message, $args ) );
    90089008}
     9009
     9010/**
     9011 * Returns the current WordPress Version.
     9012 *
     9013 * Returns an unmodified version of `$wp_version`. Some plugins modify the
     9014 * global in an attempt to improve security through obscurity. This
     9015 * practice can cause errors in WordPress so the ability to get an
     9016 * unmodified version is needed.
     9017 *
     9018 * @since 6.7.0
     9019 *
     9020 * @return string The current WordPress Version.
     9021 */
     9022function wp_get_wp_version() {
     9023    require ABSPATH . WPINC . '/version.php';
     9024
     9025    return $wp_version;
     9026}
Note: See TracChangeset for help on using the changeset viewer.