This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
Omphaloskepsis/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-updates-status-endpoint.php
2018-03-21 18:19:20 +00:00

34 lines
922 B
PHP

<?php
class Jetpack_JSON_API_Updates_Status extends Jetpack_JSON_API_Endpoint {
// GET /sites/%s/updates
protected $needed_capabilities = 'manage_options';
protected function result() {
wp_update_themes();
wp_update_plugins();
$update_data = wp_get_update_data();
if ( ! isset( $update_data['counts'] ) ) {
return new WP_Error( 'get_update_data_error', __( 'There was an error while getting the update data for this site.', 'jetpack' ), 500 );
}
$result = $update_data['counts'];
include( ABSPATH . WPINC . '/version.php' ); // $wp_version;
$result['wp_version'] = isset( $wp_version ) ? $wp_version : null;
if ( ! empty( $result['wordpress'] ) ) {
$cur = get_preferred_from_update_core();
if ( isset( $cur->response ) && $cur->response === 'upgrade' ) {
$result['wp_update_version'] = $cur->current;
}
}
$result['jp_version'] = JETPACK__VERSION;
return $result;
}
}