And the {PLUGIN_DIR}/zombieland/zombieland.php file should exist
And the {PLUGIN_DIR}/zombieland/phpunit.xml file should exist
- When I run `wp plugin status zombieland`
+ # Check that the inner-plugin is not picked up
+ When I run `mv {PLUGIN_DIR}/plugin1 {PLUGIN_DIR}/zombieland/`
+ And I run `wp plugin status zombieland`
Then STDOUT should contain:
"""
Plugin zombieland details:
public function get( $name ) {
$plugins = get_plugins( '/' . $name );
- if ( !empty( $plugins ) ) {
- $file = $name . '/' . key( $plugins );
- } else {
- $file = $name . '.php';
+ // 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
+ );
+ }
+ }
- $plugins = get_plugins();
+ // some-plugin.php
+ $file = $name . '.php';
- if ( !isset( $plugins[$file] ) ) {
- return false;
- }
+ $plugins = get_plugins();
+
+ if ( isset( $plugins[ $file ] ) ) {
+ return (object) compact( 'name', 'file' );
}
- return (object) array(
- 'name' => $name,
- 'file' => $file
- );
+ return false;
}
}