$tmpfname = wp_tempnam($url);
$response = wp_remote_post( $url, array( 'timeout' => $timeout, 'body' => $body, 'stream' => true, 'filename' => $tmpfname ) );
- if ( !is_wp_error( $response ) && $response['response']['code'] == 200 )
- WP_CLI::success( "Created theme '".$data['theme_name']."'." );
+ if ( is_wp_error( $response ) ) {
+ WP_CLI::error( $response );
+ }
+
+ $response_code = wp_remote_retrieve_response_code( $response );
+ if ( 200 != $response_code ) {
+ WP_CLI::error( "Couldn't create theme (received $response_code response)." );
+ }
unzip_file( $tmpfname, $theme_path );
unlink( $tmpfname );
+ WP_CLI::success( "Created theme '{$data['theme_name']}'." );
+
if ( isset( $assoc_args['activate'] ) )
WP_CLI::run_command( array( 'theme', 'activate', $theme_slug ) );