OSDN Git Service

make local plugin lookup case-sensitive
[wvm/wvm.git] / php / WP_CLI / Fetchers / Plugin.php
index f596725..37f3e10 100644 (file)
@@ -7,31 +7,13 @@ class Plugin extends Base {
        protected $msg = "The '%s' plugin could not be found.";
 
        public function get( $name ) {
-               $plugins = get_plugins( '/' . $name );
-
-               // some-plugin/the-plugin.php
-               while ( !empty( $plugins ) ) {
-                       $file = key( $plugins );
-                       array_shift( $plugins );
-
-                       // ignore files inside a plugin's subdirectory (like WP does)
-                       if ( dirname( $file ) == '.' ) {
-                               return (object) array(
-                                       'name' => $name,
-                                       'file' => $name . '/' . $file
-                               );
+               foreach ( get_plugins() as $file => $_ ) {
+                       if ( $file === "$name.php" ||
+                               ( dirname( $file ) === $name && $name !== '.' ) ) {
+                               return (object) compact( 'name', 'file' );
                        }
                }
 
-               // some-plugin.php
-               $file = $name . '.php';
-
-               $plugins = get_plugins();
-
-               if ( isset( $plugins[ $file ] ) ) {
-                       return (object) compact( 'name', 'file' );
-               }
-
                return false;
        }
 }