Make WordPress Core

Changeset 58827


Ignore:
Timestamp:
07/29/2024 03:00:44 PM (10 months ago)
Author:
SergeyBiryukov
Message:

General: Memoize the return value in wp_get_wp_version().

This aims to optimize performance by saving the return value to a static variable, so that the version.php file is not unnecessarily required on each function call.

Follow-up to [58813].

Props Cybr, debarghyabanerjee, mukesh27.
Fixes #61782. See #61627.

File:
1 edited

Legend:

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

    r58826 r58827  
    88208820 */
    88218821function wp_get_wp_version() {
    8822     require ABSPATH . WPINC . '/version.php';
     8822    static $wp_version;
     8823
     8824    if ( ! isset( $wp_version ) ) {
     8825        require ABSPATH . WPINC . '/version.php';
     8826    }
    88238827
    88248828    return $wp_version;
Note: See TracChangeset for help on using the changeset viewer.