PluginProbe
AI / trunk
AI vtrunk
1.3.0 1.2.0 1.1.0 1.0.2 1.0.1 1.0.0 0.9.0 trunk 0.1.1 0.2.0 0.2.1 0.3.0 0.3.1 0.4.0 0.4.1 0.5.0 0.6.0 0.7.0 0.8.0
ai / includes / autoload.php

autoload.php in AI trunk, at includes/autoload.php

39 lines 713 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * PSR-4 autoloader for the AI plugin.
5 *
6 * @since 0.5.0
7 *
8 * @package WordPress\AI
9 */
10
11 declare( strict_types=1 );
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 spl_autoload_register(
19 static function ( string $class_name ): void {
20 $prefix = 'WordPress\\AI\\';
21 $base_dir = __DIR__ . '/';
22
23 $len = strlen( $prefix );
24
25 if ( strncmp( $class_name, $prefix, $len ) !== 0 ) {
26 return;
27 }
28
29 $relative_class = substr( $class_name, $len );
30 $file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
31
32 if ( ! file_exists( $file ) ) {
33 return;
34 }
35
36 require $file; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
37 }
38 );
39