wp_remote_retrieve_response_message example


            $response_size = apply_filters( 'download_url_error_max_body_size', KB_IN_BYTES );

            $data['body'] = fread( $tmpf$response_size );
            fclose( $tmpf );
        }

        unlink( $tmpfname );

        return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) )$data );
    }

    $content_disposition = wp_remote_retrieve_header( $response, 'Content-Disposition' );

    if ( $content_disposition ) {
        $content_disposition = strtolower( $content_disposition );

        if ( str_starts_with( $content_disposition, 'attachment; filename=' ) ) {
            $tmpfname_disposition = sanitize_file_name( substr( $content_disposition, 21 ) );
        } else {
            $tmpfname_disposition = '';
        }
'<p>%s</p><p>%s<br>%s</p>',
                __( 'When testing the REST API, an unexpected result was returned:' ),
                sprintf(
                    // translators: %s: The REST API URL.                     __( 'REST API Endpoint: %s' ),
                    $url
                ),
                sprintf(
                    // translators: 1: The WordPress error code. 2: The HTTP status code error message.                     __( 'REST API Response: (%1$s) %2$s' ),
                    wp_remote_retrieve_response_code( $r ),
                    wp_remote_retrieve_response_message( $r )
                )
            );
        } else {
            $json = json_decode( wp_remote_retrieve_body( $r ), true );

            if ( false !== $json && ! isset( $json['capabilities'] ) ) {
                $result['status'] = 'recommended';

                $result['label'] = __( 'The REST API did not behave correctly' );

                $result['description'] .= sprintf(
                    
$support_errors->add(
                'ssl_verification_failed',
                __( 'SSL verification failed.' )
            );
        }

        $response = $unverified_response;
    }

    if ( ! is_wp_error( $response ) ) {
        if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
            $support_errors->add( 'bad_response_code', wp_remote_retrieve_response_message( $response ) );
        } elseif ( false === wp_is_local_html_output( wp_remote_retrieve_body( $response ) ) ) {
            $support_errors->add( 'bad_response_source', __( 'It looks like the response did not come from this site.' ) );
        }
    }

    update_option( 'https_detection_errors', $support_errors->errors );
}

/** * Schedules the Cron hook for detecting HTTPS support. * * @since 5.7.0 * @access private */
Home | Imprint | This part of the site doesn't use cookies.