Make WordPress Core


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

    r58409 r58813  
    265265        }
    266266
    267         // Include an unmodified $wp_version.
    268         require ABSPATH . WPINC . '/version.php';
    269 
    270         $is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
     267        $is_development_version = preg_match( '/alpha|beta|RC/', wp_get_wp_version() );
    271268
    272269        if ( $is_development_version ) {
     
    855852 */
    856853function maintenance_nag() {
    857         // Include an unmodified $wp_version.
    858         require ABSPATH . WPINC . '/version.php';
    859854        global $upgrading;
    860855
     
    874869                 */
    875870                $comparison = ! empty( $failed['critical'] ) ? '>=' : '>';
    876                 if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], $wp_version, $comparison ) ) {
     871                if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], wp_get_wp_version(), $comparison ) ) {
    877872                        $nag = true;
    878873                }
Note: See TracChangeset for help on using the changeset viewer.