'application/json' ); $response = Utils\http_request( 'GET', $url, null, $headers, array( 'timeout' => 30 ) ); if ( 200 === $response->status_code ) { return $response->body; } WP_CLI::error( "Couldn't fetch response from {$url} (HTTP code {$response->status_code})." ); } /** * Recursively get the list of files for a given path. * * @param string $path Root path to start the recursive traversal in. * * @return array */ protected function get_files( $path ) { $filtered_files = array(); try { $files = new RecursiveIteratorIterator( new RecursiveCallbackFilterIterator( new RecursiveDirectoryIterator( $path, RecursiveDirectoryIterator::SKIP_DOTS ), function ( $current, $key, $iterator ) use ( $path ) { return $this->filter_file( self::normalize_directory_separators( substr( $current->getPathname(), strlen( $path ) ) ) ); } ), RecursiveIteratorIterator::CHILD_FIRST ); foreach ( $files as $file_info ) { if ( $file_info->isFile() ) { $filtered_files[] = self::normalize_directory_separators( substr( $file_info->getPathname(), strlen( $path ) ) ); } } } catch ( Exception $e ) { WP_CLI::error( $e->getMessage() ); } return $filtered_files; } /** * Whether to include the file in the verification or not. * * Can be overridden in subclasses. * * @param string $filepath Path to a file. * * @return bool */ protected function filter_file( $filepath ) { return true; } }