Merge pull request #21073 from woocommerce/fix/20694

Show system status updates for woocommerce wp.org plugins
This commit is contained in:
Claudiu Lodromanean 2018-08-20 10:29:01 -07:00 committed by GitHub
commit 42e2e4a4b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 11 deletions

View File

@ -796,6 +796,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
$version_data = get_transient( md5( $plugin ) . '_version_data' );
if ( false === $version_data ) {
$changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
if ( 200 === wp_remote_retrieve_response_code( $changelog ) ) {
$cl_lines = explode( "\n", wp_remote_retrieve_body( $changelog ) );
if ( ! empty( $cl_lines ) ) {
foreach ( $cl_lines as $line_num => $cl_line ) {
@ -814,6 +815,29 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
}
}
}
} else {
$args = (object) array(
'slug' => $dirname,
);
$request = array(
'action' => 'plugin_information',
'request' => serialize( $args ),
);
$plugin_info = wp_safe_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', array( 'body' => $request ) );
if ( 200 === wp_remote_retrieve_response_code( $plugin_info ) ) {
$body = maybe_unserialize( wp_remote_retrieve_body( $plugin_info ) );
if ( is_object( $body ) && isset( $body->sections['changelog'] ) ) {
$version_data = array(
'date' => $body->last_updated,
'version' => $body->version,
'update' => $body->sections['changelog'],
'changelog' => $body->sections['changelog'],
);
set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS );
break;
}
}
}
}
$version_latest = $version_data['version'];
} elseif ( isset( $available_updates[ $plugin ]->update->new_version ) ) {