diff --git a/wp-rest/Autoloader.php b/wp-rest/Autoloader.php index dfa95f8a0219f6d8126f0b77110135049c693690..01118666154c90313681973608f4d3444fd69a6b 100644 --- a/wp-rest/Autoloader.php +++ b/wp-rest/Autoloader.php @@ -93,10 +93,10 @@ class Autoloader { */ private function autoload( $class_name ) { - if ( false === strpos( $class_name, $this->namespace ) ) return; - $parts = explode( '\\', $class_name ); + if ( $this->namespace !== $parts[0] ) return; + // remove namespace and join class path $class_path = str_replace( '_', '-', implode( DIRECTORY_SEPARATOR, array_slice( $parts, 1 ) ) );