php/WP_CLI/Runner.php
private function find_wp_root() {
		if ( ! empty( $this->config['path'] ) ) {
			$path = $this->config['path'];
			if ( ! Utils\is_path_absolute( $path ) ) {
				$path = getcwd() . '/' . $path;
			}

			return $path;
		}

		if ( $this->cmd_starts_with( array( 'core', 'download' ) ) ) {
			return getcwd();
		}

		$dir = getcwd();

		while ( is_readable( $dir ) ) {
			if ( file_exists( "$dir/wp-load.php" ) ) {
				return $dir;
			}

			if ( file_exists( "$dir/index.php" ) ) {
				$path = self::extract_subdir_path( "$dir/index.php" );
				if ( ! empty( $path ) ) {
					return $path;
				}
			}

			$parent_dir = dirname( $dir );
			if ( empty( $parent_dir ) || $parent_dir === $dir ) {
				break;
			}
			$dir = $parent_dir;
		}
	}
private function find_wp_root() {
		if ( ! empty( $this->config['path'] ) ) {
			$path = $this->config['path'];
			if ( ! Utils\is_path_absolute( $path ) ) {
				$path = getcwd() . '/' . $path;
			}

			return $path;
		}

		if ( $this->cmd_starts_with( array( 'core', 'download' ) ) ) {
			return getcwd();
		}

		$dir = getcwd();

		while ( is_readable( $dir ) ) {
			if ( file_exists( "$dir/wp-load.php" ) ) {
				return $dir;
			}

			if ( file_exists( "$dir/index.php" ) ) {
				$path = self::extract_subdir_path( "$dir/index.php" );
				if ( ! empty( $path ) ) {
					return $path;
				}
			}

			$parent_dir = dirname( $dir );
			if ( empty( $parent_dir ) || $parent_dir === $dir ) {
				break;
			}
			$dir = $parent_dir;
		}
	}
private function find_wp_root ( ) { if ( ! empty ( $ this -> config [ 'path' ] ) ) { $ path = $ this -> config [ 'path' ] ; if ( ! Utils \ is_path_absolute ( $ path ) ) { $ path = getcwd ( ) . '/' . $ path ; } return $ path ; } if ( $ this -> cmd_starts_with ( array ( 'core' , 'download' ) ) ) { return getcwd ( ) ; } $ dir = getcwd ( ) ; while ( is_readable ( $ dir ) ) { if ( file_exists ( "$dir/wp-load.php" ) ) { return $ dir ; } if ( file_exists ( "$dir/index.php" ) ) { $ path = self :: extract_subdir_path ( "$dir/index.php" ) ; if ( ! empty ( $ path ) ) { return $ path ; } } $ parent_dir = dirname ( $ dir ) ; if ( empty ( $ parent_dir ) || $ parent_dir === $ dir ) { break ; } $ dir = $ parent_dir ; } }
Find the directory that contains the WordPress files.
Defaults to the current working dir.

@return string An absolute path
Find the directory that contains the WordPress files . Defaults to the current working dir .