` - WordPress installation isn't on the server. * * `hosted-maintenance` - WordPress installation is hosted but renders maintenance page. * * `hosted-php-fatal` - WordPress installation is hosted but has a PHP fatal. * * `hosted-broken-wp-login` - WordPress installation is hosted but the login page is broken. * * `hosted-valid-login` - WordPress installation is hosted on server and login page loads. * * ## OPTIONS * * * : Path to search the subdirectories of. * * [--fields=] * : Limit the output to specific row fields. * * [--field=] * : Output a specific field for each row. * * [--format=] * : Render output in a specific format. * --- * default: table * options: * - table * - json * - csv * - yaml * - count * --- * * @when before_wp_load */ WP_CLI::add_command( 'dh-find-check', function( $args, $assoc_args ){ list( $find_path ) = $args; $installations = WP_CLI::runcommand( "find {$find_path} --fields=wp_path,version,db_host,db_name,db_user --format=json", array( 'return' => true, 'parse' => 'json', ) ); foreach ( $installations as $i => $installation ) { $host_check = WP_CLI::runcommand( "host-check --path={$installation['wp_path']}", array( 'return' => true, 'exit_error' => false, ) ); $installations[ $i ]['status'] = 'check-failed'; if ( preg_match( '#Summary:[^,]+,([^,]+),#', $host_check, $matches ) ) { $installations[ $i ]['status'] = trim( $matches[1] ); } } $fields = array( 'wp_path', 'version', 'db_host', 'db_name', 'db_user', 'status' ); if ( ! empty( $assoc_args['fields'] ) ) { $fields = explode( ',', $assoc_args['fields'] ); } WP_CLI\Utils\format_items( $assoc_args['format'], $installations, $fields ); } );