Skip to content

Instantly share code, notes, and snippets.

@tillkruss
Last active January 23, 2018 02:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tillkruss/b2cb59f601d7144e3497 to your computer and use it in GitHub Desktop.
Save tillkruss/b2cb59f601d7144e3497 to your computer and use it in GitHub Desktop.
Prevent `api.wordpress.org` requests timeouts: "Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server's configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org.)"
<?php
// increase `timeout` for `api.wordpress.org` requests
add_filter( 'http_request_args', function( $request, $url ) {
if ( strpos( $url, '://api.wordpress.org/' ) !== false ) {
$request[ 'timeout' ] = 15;
}
return $request;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment