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/script-loader.php

    r58800 r58813  
    685685
    686686    if ( null === $suffixes ) {
    687         // Include an unmodified $wp_version.
     687        /*
     688         * Include an unmodified $wp_version.
     689         *
     690         * Note: wp_get_wp_version() is not used here, as this file can be included
     691         * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case
     692         * wp-includes/functions.php is not loaded.
     693         */
    688694        require ABSPATH . WPINC . '/version.php';
    689695
     
    15231529    global $editor_styles;
    15241530
    1525     // Include an unmodified $wp_version.
     1531    /*
     1532     * Include an unmodified $wp_version.
     1533     *
     1534     * Note: wp_get_wp_version() is not used here, as this file can be included
     1535     * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case
     1536     * wp-includes/functions.php is not loaded.
     1537     */
    15261538    require ABSPATH . WPINC . '/version.php';
    15271539
Note: See TracChangeset for help on using the changeset viewer.