Skip to content

Commit

Permalink
Split method to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Nov 28, 2022
1 parent dbd4828 commit c621360
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/wp-includes/class-wp-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,6 @@ final class WP_Autoload {
/**
* Register the autoloader.
*
* Note: the autoloader is *prepended* in the autoload queue.
* This is done to ensure that the Requests 2.0 autoloader takes precedence
* over a potentially (dependency-registered) Requests 1.x autoloader.
*
* @return void
*/
public static function register() {
Expand All @@ -375,18 +371,33 @@ public static function register() {
return;
}

// Register autoloaders for external, bundled libraries.
static::register_external_bundled();
static::register_core();

static::$registered = true;
}

/**
* Register the autoloader for external, bundled libraries.
*
* @return void
*/
public static function register_external_bundled() {
require_once ABSPATH . 'wp-includes/class-simplepie.php';
require_once ABSPATH . 'wp-includes/class-requests.php';
require_once ABSPATH . 'wp-includes/sodium_compat/autoload.php';

spl_autoload_register( 'wp_simplepie_autoload' );
spl_autoload_register( array( 'Requests', 'autoloader' ) );
}

// Autoload WordPress classes.
spl_autoload_register( array( __CLASS__, 'autoload' ), true, true );

static::$registered = true;
/**
* Register the autoloader for WordPress Core classes.
*
* @return void
*/
public static function register_core() {
spl_autoload_register( array( __CLASS__, 'autoload_core' ), true, true );
}

/**
Expand All @@ -395,7 +406,7 @@ public static function register() {
* @param string $class Class name.
* @return bool True if the class was loaded, false otherwise.
*/
public static function autoload( $class_name ) {
public static function autoload_core( $class_name ) {
// Lowercase the classname to accomodate for WP classes written with wrong cases.
$class_name = strtolower( $class_name );

Expand Down

0 comments on commit c621360

Please sign in to comment.