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.


git-svn-id: https://develop.svn.wordpress.org/trunk@41605 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse
2017-09-27 07:59:14 +00:00
parent 1545e58ea6
commit 2ff224a044
7 changed files with 50 additions and 11 deletions

View File

@@ -141,12 +141,16 @@ function plugins_api( $action, $args = array() ) {
$res = apply_filters( 'plugins_api', false, $action, $args );
if ( false === $res ) {
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );
$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
$url = set_url_scheme( $url, 'https' );
$http_args = array(
'timeout' => 15,
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
'body' => array(
'action' => $action,
'request' => serialize( $args )