Make WordPress Core


Ignore:
Timestamp:
07/27/2024 12:25:44 AM (22 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/theme.php

    r58409 r58813  
    494494 */
    495495function themes_api( $action, $args = array() ) {
    496     // Include an unmodified $wp_version.
    497     require ABSPATH . WPINC . '/version.php';
    498 
    499496    if ( is_array( $args ) ) {
    500497        $args = (object) $args;
     
    512509
    513510    if ( ! isset( $args->wp_version ) ) {
    514         $args->wp_version = substr( $wp_version, 0, 3 ); // x.y
     511        $args->wp_version = substr( wp_get_wp_version(), 0, 3 ); // x.y
    515512    }
    516513
     
    563560        $http_args = array(
    564561            'timeout'    => 15,
    565             'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
     562            'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
    566563        );
    567564        $request   = wp_remote_get( $url, $http_args );
Note: See TracChangeset for help on using the changeset viewer.