Standardise on performing api.WordPress.org requests over SSL when possible, falling back to non-SSL when appropriate.
This also standardises the `User-Agent` used when communicating with WordPress.org, allowing for more consistent version detection. Fixes #42004. Built from https://develop.svn.wordpress.org/trunk@41605 git-svn-id: http://core.svn.wordpress.org/trunk@41440 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1509,12 +1509,20 @@ function wp_check_browser_version() {
|
||||
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
|
||||
|
||||
if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
|
||||
// include an unmodified $wp_version
|
||||
include( ABSPATH . WPINC . '/version.php' );
|
||||
|
||||
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
|
||||
$options = array(
|
||||
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
|
||||
'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url()
|
||||
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
|
||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
|
||||
);
|
||||
|
||||
$response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options );
|
||||
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
$response = wp_remote_post( $url, $options );
|
||||
|
||||
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user