forked from wp-cli/doctor-command
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.php
More file actions
27 lines (23 loc) · 698 Bytes
/
Copy pathcommand.php
File metadata and controls
27 lines (23 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
if ( ! class_exists( 'WP_CLI' ) ) {
return;
}
spl_autoload_register(
function( $class ) {
$class = ltrim( $class, '\\' );
if ( 0 !== stripos( $class, 'runcommand\\Doctor\\' ) ) {
return;
}
$parts = explode( '\\', $class );
array_shift( $parts ); // Don't need "runcommand\Doctor"
array_shift( $parts );
$last = array_pop( $parts ); // File should be 'class-[...].php'
$last = 'class-' . $last . '.php';
$parts[] = $last;
$file = dirname( __FILE__ ) . '/inc/' . str_replace( '_', '-', strtolower( implode( '/', $parts ) ) );
if ( file_exists( $file ) ) {
require $file;
}
}
);
WP_CLI::add_command( 'doctor', 'runcommand\Doctor\Command' );