3 namespace WP_CLI\Fetchers;
5 class Plugin extends Base {
7 protected $msg = "The '%s' plugin could not be found.";
9 public function get( $name ) {
10 $plugins = get_plugins( '/' . $name );
12 // some-plugin/the-plugin.php
13 while ( !empty( $plugins ) ) {
14 $file = key( $plugins );
15 array_shift( $plugins );
17 // ignore files inside a plugin's subdirectory (like WP does)
18 if ( dirname( $file ) == '.' ) {
19 return (object) array(
21 'file' => $name . '/' . $file
27 $file = $name . '.php';
29 $plugins = get_plugins();
31 if ( isset( $plugins[ $file ] ) ) {
32 return (object) compact( 'name', 'file' );