Networks and Sites: Load WP_Metadata_Lazyloader class file if class does not exist.

Follow on from [55747].

As `get_sites` can be called very early in the bootstrap process, like in the sunrise.php file, it means that the `WP_Metadata_Lazyloader` may not have been loaded yet in the wp-settings.php file. Add a simple check to see if the class exists and if it does not exist then load the class file in. 

Props spacedmonkey, peterwilsoncc, dd32.
See #58185.

git-svn-id: https://develop.svn.wordpress.org/trunk@55818 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
spacedmonkey
2023-05-17 09:42:02 +00:00
parent e4e3bb397e
commit ac87b8701f

View File

@@ -1214,6 +1214,9 @@ function wp_metadata_lazyloader() {
static $wp_metadata_lazyloader;
if ( null === $wp_metadata_lazyloader ) {
if ( ! class_exists( 'WP_Metadata_Lazyloader' ) ) {
require_once ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php';
}
$wp_metadata_lazyloader = new WP_Metadata_Lazyloader();
}