Skip to content

ConvertKit for WordPress Snippets

George Gecewicz edited this page Dec 10, 2020 · 3 revisions

Snippet: Bump Request Timeout Limit


The default timeout for ConvertKit.com API calls from within the plugin is 10 seconds. You can add the snippet below to your site to change that timeout limit to something higher, which can be helpful for customers who have many, many forms or landing pages.

/**
  * Increases the HTTP request timeout for ConvertKit API calls.
  *
  * This is useful for accounts that might have many, many forms or landing pages.
  *
  * @since 2020-10-10
  *
  * @param array  $parsed_args An array of HTTP request arguments.
  * @param string $url         The request URL.
  * @return array
  */
function convertkit_bump_request_timeout_limit( $parsed_args, $url ) {
    if ( empty( $url ) ) {
        return $parsed_args;
    }

    if ( false === strpos( $url, 'api.convertkit.com' ) ) {
        return $parsed_args;
    }

    $parsed_args['timeout'] = 60;

    return $parsed_args;
}

add_filter( 'http_request_args', 'convertkit_bump_request_timeout_limit', 10, 2 );