@@ -78,6 +78,13 @@ class Find_Command {
7878 */
7979 private $ start_time = false ;
8080
81+ /**
82+ * Resolved alias paths
83+ *
84+ * @var array
85+ */
86+ private $ resolved_aliases = array ();
87+
8188 /**
8289 * Found WordPress installs.
8390 *
@@ -147,10 +154,19 @@ public function __invoke( $args, $assoc_args ) {
147154 $ this ->skip_ignored_paths = Utils \get_flag_value ( $ assoc_args , 'skip-ignored-paths ' );
148155 $ this ->max_depth = Utils \get_flag_value ( $ assoc_args , 'max_depth ' , false );
149156 $ this ->verbose = Utils \get_flag_value ( $ assoc_args , 'verbose ' );
157+
158+ $ aliases = WP_CLI ::get_runner ()->aliases ;
159+ foreach ( $ aliases as $ alias => $ target ) {
160+ if ( empty ( $ target ['path ' ] ) ) {
161+ continue ;
162+ }
163+ $ this ->resolved_aliases [ rtrim ( $ target ['path ' ], '/ ' ) ] = $ alias ;
164+ }
165+
150166 $ this ->start_time = microtime ( true );
151167 $ this ->log ( "Searching for WordPress installs in ' {$ path }' " );
152168 $ this ->recurse_directory ( $ this ->base_path );
153- $ formatter = new \WP_CLI \Formatter ( $ assoc_args , array ( 'version_path ' , 'version ' , 'depth ' ) );
169+ $ formatter = new \WP_CLI \Formatter ( $ assoc_args , array ( 'version_path ' , 'version ' , 'depth ' , ' alias ' ) );
154170 $ formatter ->display_items ( $ this ->found_wp );
155171 }
156172
@@ -181,10 +197,13 @@ private function recurse_directory( $path ) {
181197 if ( '/wp-includes/ ' === substr ( $ path , -13 )
182198 && file_exists ( $ path . 'version.php ' ) ) {
183199 $ version_path = $ path . 'version.php ' ;
200+ $ wp_path = substr ( $ path , 0 , -13 );
201+ $ alias = isset ( $ this ->resolved_aliases [ $ wp_path ] ) ? $ this ->resolved_aliases [ $ wp_path ] : '' ;
184202 $ this ->found_wp [ $ version_path ] = array (
185203 'version_path ' => $ version_path ,
186204 'version ' => self ::get_wp_version ( $ version_path ),
187205 'depth ' => $ this ->current_depth - 1 ,
206+ 'alias ' => $ alias ,
188207 );
189208 $ this ->log ( "Found WordPress install at ' {$ version_path }' " );
190209 return ;
0 commit comments