Make WordPress Core


Ignore:
Timestamp:
07/27/2024 12:25:44 AM (20 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-admin/includes/translation-install.php

    r58409 r58813  
    1818 */
    1919function translations_api( $type, $args = null ) {
    20     // Include an unmodified $wp_version.
    21     require ABSPATH . WPINC . '/version.php';
    22 
    2320    if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
    2421        return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
     
    4744            'timeout' => 3,
    4845            'body'    => array(
    49                 'wp_version' => $wp_version,
     46                'wp_version' => wp_get_wp_version(),
    5047                'locale'     => get_locale(),
    5148                'version'    => $args['version'], // Version of plugin, theme or core.
     
    129126    }
    130127
    131     // Include an unmodified $wp_version.
    132     require ABSPATH . WPINC . '/version.php';
    133 
    134     $api = translations_api( 'core', array( 'version' => $wp_version ) );
     128    $api = translations_api( 'core', array( 'version' => wp_get_wp_version() ) );
    135129
    136130    if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.